← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8457: Add schedule function for Aggregation Query builder.

 

------------------------------------------------------------
revno: 8457
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-10 15:50:17 +0700
message:
  Add schedule function for Aggregation Query builder.
removed:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menuScheduling.vm
added:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionSchedulingManager.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/DefaultCaseAggregateConditionSchedulingManager.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleParamsAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2012-10-03 18:12:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2012-10-10 08:50:17 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_PERIOD_TYPES;
+
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.HashSet;
@@ -72,6 +74,9 @@
     final String KEY_SEND_MESSAGE_SCHEDULED_TASKS = "sendMessageScheduled";
     final String KEY_SCHEDULE_MESSAGE_TASKS = "scheduleMessage";
     final String PHONE_NUMBER_AREA_CODE = "phoneNumberAreaCode";
+    final String KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS = "scheduleAggregateQueryBuilder";
+    final String KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES = "keyScheduledAggregateQueryBuilderPeriodTypes";
+    final String KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL = "aggQueryBuilderorgUnitGroupSetAggregationLevel";
 
     final int DEFAULT_MAX_NUMBER_OF_ATTEMPTS = 20;
     final int DEFAULT_TIMEFRAME_MINUTES = 1;

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionSchedulingManager.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionSchedulingManager.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionSchedulingManager.java	2012-10-10 08:50:17 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.scheduling;
+
+import java.util.Map;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version CaseAggregateConditionSchedulingManager.java 10:42:58 AM Oct 10, 2012 $
+ */
+public interface CaseAggregateConditionSchedulingManager
+{
+    final String TASK_AGGREGATE_QUERY_BUILDER_LAST_12_MONTHS = "aggregateLast12MonthsTask";
+    final String TASK_AGGREGATE_QUERY_BUILDER_LAST_6_MONTS = "aggregateLast6MonthsTask";
+    final String TASK_AGGREGATE_QUERY_BUILDER_FROM_6_TO_12_MONTS = "aggregateFrom6To12MonthsTask";
+    
+    void scheduleTasks();
+    
+    void scheduleTasks( Map<String, String> keyCronMap );
+    
+    void stopTasks();
+    
+    void executeTasks();
+    
+    Map<String, String> getScheduledTasks();
+    
+    String getTaskStatus();   
+}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java	2012-10-10 08:50:17 +0000
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.scheduling;
+
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_ORGUNITGROUPSET_AGG_LEVEL;
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_PERIOD_TYPES;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
+import org.hisp.dhis.caseaggregation.CaseAggregationConditionService;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.RelativePeriods;
+import org.hisp.dhis.setting.SystemSettingManager;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version RunCaseAggregateConditionTask.java 9:52:10 AM Oct 10, 2012 $
+ */
+public class CaseAggregateConditionTask
+    implements Runnable
+{
+    private OrganisationUnitService organisationUnitService;
+
+    private CaseAggregationConditionService aggregationConditionService;
+
+    private DataValueService dataValueService;
+
+    private SystemSettingManager systemSettingManager;
+
+    // -------------------------------------------------------------------------
+    // Params
+    // -------------------------------------------------------------------------
+
+    private List<Period> periods;
+
+    public void setPeriods( List<Period> periods )
+    {
+        this.periods = periods;
+    }
+
+    private boolean last6Months;
+
+    public void setLast6Months( boolean last6Months )
+    {
+        this.last6Months = last6Months;
+    }
+
+    private boolean last6To12Months;
+
+    public void setLast6To12Months( boolean last6To12Months )
+    {
+        this.last6To12Months = last6To12Months;
+    }
+
+    // -------------------------------------------------------------------------
+    // Constructors
+    // -------------------------------------------------------------------------
+
+    public CaseAggregateConditionTask( OrganisationUnitService organisationUnitService,
+        CaseAggregationConditionService aggregationConditionService, DataValueService dataValueService,
+        SystemSettingManager systemSettingManager )
+    {
+        this.organisationUnitService = organisationUnitService;
+        this.aggregationConditionService = aggregationConditionService;
+        this.dataValueService = dataValueService;
+        this.systemSettingManager = systemSettingManager;
+    }
+
+    // -------------------------------------------------------------------------
+    // Runnable implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    @SuppressWarnings( "unchecked" )
+    public void run()
+    {
+        int level = (Integer) systemSettingManager.getSystemSetting(
+            KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL );
+        Collection<OrganisationUnit> orgunits = organisationUnitService.getOrganisationUnitsAtLevel( level );
+
+        Collection<CaseAggregationCondition> aggConditions = aggregationConditionService
+            .getAllCaseAggregationCondition();
+
+        // ---------------------------------------------------------------------
+        // Get Period list in system-setting
+        // ---------------------------------------------------------------------
+
+        Set<String> periodTypes = (Set<String>) systemSettingManager.getSystemSetting(
+            KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES );
+
+        List<Period> periods = getPeriods( periodTypes );
+
+        // ---------------------------------------------------------------------
+        // Aggregation
+        // ---------------------------------------------------------------------
+
+        for ( OrganisationUnit orgUnit : orgunits )
+        {
+            for ( CaseAggregationCondition aggCondition : aggConditions )
+            {
+                DataElementCategoryOptionCombo optionCombo = aggCondition.getOptionCombo();
+
+                DataElement dElement = aggCondition.getAggregationDataElement();
+
+                for ( Period period : periods )
+                {
+                    Double resultValue = aggregationConditionService.parseConditition( aggCondition, orgUnit, period );
+
+                    DataValue dataValue = dataValueService.getDataValue( orgUnit, dElement, period, optionCombo );
+
+                    if ( resultValue != null && resultValue != 0.0 )
+                    {
+                        // -----------------------------------------
+                        // Add dataValue
+                        // -----------------------------------------
+
+                        if ( dataValue == null )
+                        {
+                            dataValue = new DataValue( dElement, period, orgUnit, "" + resultValue, "", new Date(),
+                                null, optionCombo );
+                            dataValueService.addDataValue( dataValue );
+                        }
+                        // -----------------------------------------
+                        // Update dataValue
+                        // -----------------------------------------
+                        else
+                        {
+                            dataValue.setValue( "" + resultValue );
+                            dataValue.setTimestamp( new Date() );
+                            dataValueService.updateDataValue( dataValue );
+                        }
+
+                    }
+                    // -----------------------------------------
+                    // Delete dataValue
+                    // -----------------------------------------
+                    else if ( dataValue != null )
+                    {
+                        dataValueService.deleteDataValue( dataValue );
+                    }
+
+                }
+            }
+        }
+
+    }
+
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+
+    private List<Period> getPeriods( Set<String> periodTypes )
+    {
+        if ( periods != null && periods.size() > 0 )
+        {
+            return periods;
+        }
+
+        List<Period> relatives = new ArrayList<Period>();
+
+        if ( last6Months )
+        {
+            relatives.addAll( new RelativePeriods().getLast6Months( periodTypes ) );
+        }
+
+        if ( last6To12Months )
+        {
+            relatives.addAll( new RelativePeriods().getLast6To12Months( periodTypes ) );
+        }
+
+        return relatives;
+    }
+
+}

=== added file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/DefaultCaseAggregateConditionSchedulingManager.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/DefaultCaseAggregateConditionSchedulingManager.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/DefaultCaseAggregateConditionSchedulingManager.java	2012-10-10 08:50:17 +0000
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.scheduling;
+
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS;
+import static org.hisp.dhis.system.scheduling.Scheduler.STATUS_NOT_STARTED;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.scheduling.Scheduler;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version DefaultCaseAggregateConditionSchedulingManager.java 10:42:25 AM Oct
+ *          10, 2012 $
+ */
+public class DefaultCaseAggregateConditionSchedulingManager
+    implements CaseAggregateConditionSchedulingManager
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private SystemSettingManager systemSettingManager;
+
+    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+    {
+        this.systemSettingManager = systemSettingManager;
+    }
+
+    private Scheduler scheduler;
+
+    public void setScheduler( Scheduler scheduler )
+    {
+        this.scheduler = scheduler;
+    }
+
+    private Map<String, Runnable> tasks = new HashMap<String, Runnable>();
+
+    public void setTasks( Map<String, Runnable> tasks )
+    {
+        this.tasks = tasks;
+    }
+
+    // -------------------------------------------------------------------------
+    // SchedulingManager implementation
+    // -------------------------------------------------------------------------
+
+    public void scheduleTasks()
+    {
+        Map<String, String> keyCronMap = getScheduledTasks();
+
+        for ( String key : keyCronMap.keySet() )
+        {
+            String cron = keyCronMap.get( key );
+            Runnable task = tasks.get( key );
+
+            if ( cron != null && task != null )
+            {
+                scheduler.scheduleTask( key, task, cron );
+            }
+        }
+    }
+
+    public void scheduleTasks( Map<String, String> keyCronMap )
+    {
+        systemSettingManager.saveSystemSetting( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS,
+            new HashMap<String, String>( keyCronMap ) );
+
+        scheduleTasks();
+    }
+
+    public void stopTasks()
+    {
+        systemSettingManager.saveSystemSetting( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS, null );
+
+        scheduler.stopAllTasks();
+    }
+
+    public void executeTasks()
+    {
+        Map<String, String> keyCronMap = getScheduledTasks();
+
+        for ( String key : keyCronMap.keySet() )
+        {
+            Runnable task = tasks.get( key );
+
+            if ( task != null )
+            {
+                scheduler.executeTask( task );
+            }
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public Map<String, String> getScheduledTasks()
+    {
+        return (Map<String, String>) systemSettingManager.getSystemSetting( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS,
+            new HashMap<String, String>() );
+    }
+
+    public String getTaskStatus()
+    {
+        Map<String, String> keyCronMap = getScheduledTasks();
+
+        if ( keyCronMap.size() == 0 )
+        {
+            return STATUS_NOT_STARTED;
+        }
+
+        return scheduler.getTaskStatus( keyCronMap.keySet().iterator().next() );
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-10-04 15:05:38 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-10-10 08:50:17 +0000
@@ -141,6 +141,8 @@
         executeSql( "CREATE INDEX index_programinstance ON programinstance( programinstanceid )" );
         
         executeSql( "ALTER TABLE program DROP COLUMN maxDaysAllowedInputData");
+        
+        executeSql( "ALTER TABLE programstage_dataelements DROP CONSTRAINT \"fkaf0e5fc634ee4761\" ");
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-10-02 06:23:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-10-10 08:50:17 +0000
@@ -365,7 +365,7 @@
 		class="org.hisp.dhis.program.ProgramStageInstanceDeletionHandler">
 		<property name="jdbcTemplate" ref="jdbcTemplate" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.program.ProgramStageSectionDeletionHandler"
 		class="org.hisp.dhis.program.ProgramStageSectionDeletionHandler">
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
@@ -418,6 +418,46 @@
 		<property name="sendingMessage" value="false" />
 	</bean>
 
+	<bean id="org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager"
+		class="org.hisp.dhis.patient.scheduling.DefaultCaseAggregateConditionSchedulingManager"
+		init-method="scheduleTasks">
+		<property name="systemSettingManager" ref="org.hisp.dhis.setting.SystemSettingManager" />
+		<property name="scheduler" ref="scheduler" />
+		<property name="tasks">
+			<map>
+				<entry key="aggregateLast12MonthsTask" value-ref="aggregateLast12MonthsTask" />
+				<entry key="aggregateLast6MonthsTask" value-ref="aggregateLast6MonthsTask" />
+				<entry key="aggregateFrom6To12MonthsTask" value-ref="aggregateFrom6To12MonthsTask" />
+			</map>
+		</property>
+	</bean>
+
+	<bean id="abstractRunCaseAggregateConditionTask"
+		class="org.hisp.dhis.patient.scheduling.CaseAggregateConditionTask">
+		<constructor-arg
+			ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
+		<constructor-arg ref="org.hisp.dhis.datavalue.DataValueService" />
+		<constructor-arg
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<constructor-arg ref="org.hisp.dhis.setting.SystemSettingManager" />
+	</bean>
+
+	<bean id="aggregateLast12MonthsTask" class="org.hisp.dhis.patient.scheduling.CaseAggregateConditionTask"
+		parent="abstractRunCaseAggregateConditionTask">
+		<property name="last6Months" value="true" />
+		<property name="last6To12Months" value="true" />
+	</bean>
+
+	<bean id="aggregateLast6MonthsTask" class="org.hisp.dhis.patient.scheduling.CaseAggregateConditionTask"
+		parent="abstractRunCaseAggregateConditionTask">
+		<property name="last6Months" value="true" />
+	</bean>
+
+	<bean id="aggregateFrom6To12MonthsTask" class="org.hisp.dhis.patient.scheduling.CaseAggregateConditionTask"
+		parent="abstractRunCaseAggregateConditionTask">
+		<property name="last6To12Months" value="true" />
+	</bean>
+
 	<!-- Startup -->
 
 	<bean id="org.hisp.dhis.patient.startup.TableAlteror" class="org.hisp.dhis.patient.startup.TableAlteror">
@@ -451,10 +491,12 @@
 			<list>
 				<list>
 					<ref local="org.hisp.dhis.patient.PatientDeletionHandler" />
-					<ref local="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler" />
+					<ref
+						local="org.hisp.dhis.patientattributevalue.PatientAttributeValueDeletionHandler" />
 					<ref local="org.hisp.dhis.patient.PatientIdentifierDeletionHandler" />
 					<ref local="org.hisp.dhis.relationship.RelationshipDeletionHandler" />
-					<ref local="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler" />
+					<ref
+						local="org.hisp.dhis.patientdatavalue.PatientDataValueDeletionHandler" />
 
 					<ref local="org.hisp.dhis.program.ProgramDeletionHandler" />
 					<ref local="org.hisp.dhis.program.ProgramStageSectionDeletionHandler" />
@@ -464,7 +506,8 @@
 					<ref local="org.hisp.dhis.program.ProgramValidationDeletionHandler" />
 					<ref local="org.hisp.dhis.program.ProgramDataEntryFormDeletionHandler" />
 
-					<ref local="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler" />
+					<ref
+						local="org.hisp.dhis.caseaggregation.CaseAggregationConditionDeletionHandler" />
 				</list>
 			</list>
 		</property>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleParamsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleParamsAction.java	2012-09-25 06:44:53 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleParamsAction.java	2012-10-10 08:50:17 +0000
@@ -32,9 +32,7 @@
 
 import org.hisp.dhis.patient.scheduling.ProgramSchedulingManager;
 import org.hisp.dhis.setting.SystemSettingManager;
-import org.hisp.dhis.sms.outbound.OutboundSmsTransportService;
 import org.hisp.dhis.system.scheduling.Scheduler;
-import org.springframework.beans.factory.annotation.Autowired;
 
 import com.opensymphony.xwork2.Action;
 
@@ -56,10 +54,7 @@
     {
         this.systemSettingManager = systemSettingManager;
     }
-
-    @Autowired
-    private OutboundSmsTransportService transportService;
-
+    
     private ProgramSchedulingManager schedulingManager;
 
     public void setSchedulingManager( ProgramSchedulingManager schedulingManager )

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java	2012-10-10 08:50:17 +0000
@@ -0,0 +1,223 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.schedule;
+
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_ORGUNITGROUPSET_AGG_LEVEL;
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_PERIOD_TYPES;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager;
+import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.scheduling.Scheduler;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version ScheduleCaseAggregateConditionAction.java 11:14:34 AM Oct 10, 2012 $
+ */
+public class ScheduleCaseAggregateConditionAction
+    implements Action
+{
+    private static final String STRATEGY_LAST_12_DAILY = "last12Daily";
+
+    private static final String STRATEGY_LAST_6_DAILY_6_TO_12_WEEKLY = "last6Daily6To12Weekly";
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private SystemSettingManager systemSettingManager;
+
+    public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+    {
+        this.systemSettingManager = systemSettingManager;
+    }
+
+    private CaseAggregateConditionSchedulingManager schedulingManager;
+
+    public void setSchedulingManager( CaseAggregateConditionSchedulingManager schedulingManager )
+    {
+        this.schedulingManager = schedulingManager;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private boolean execute;
+
+    public void setExecute( boolean execute )
+    {
+        this.execute = execute;
+    }
+
+    private boolean schedule;
+
+    public void setSchedule( boolean schedule )
+    {
+        this.schedule = schedule;
+    }
+
+    private Set<String> scheduledPeriodTypes = new HashSet<String>();
+
+    public Set<String> getScheduledPeriodTypes()
+    {
+        return scheduledPeriodTypes;
+    }
+
+    public void setScheduledPeriodTypes( Set<String> scheduledPeriodTypes )
+    {
+        this.scheduledPeriodTypes = scheduledPeriodTypes;
+    }
+
+    private Integer orgUnitGroupSetAggLevel;
+
+    public Integer getOrgUnitGroupSetAggLevel()
+    {
+        return orgUnitGroupSetAggLevel;
+    }
+
+    public void setOrgUnitGroupSetAggLevel( Integer orgUnitGroupSetAggLevel )
+    {
+        this.orgUnitGroupSetAggLevel = orgUnitGroupSetAggLevel;
+    }
+
+    private String aggQueryBuilderStrategy;
+
+    public String getAggQueryBuilderStrategy()
+    {
+        return aggQueryBuilderStrategy;
+    }
+
+    public void setAggQueryBuilderStrategy( String aggQueryBuilderStrategy )
+    {
+        this.aggQueryBuilderStrategy = aggQueryBuilderStrategy;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private String status;
+
+    public String getStatus()
+    {
+        return status;
+    }
+
+    private boolean running;
+
+    public boolean isRunning()
+    {
+        return running;
+    }
+
+    private List<OrganisationUnitLevel> levels;
+
+    public List<OrganisationUnitLevel> getLevels()
+    {
+        return levels;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @SuppressWarnings( "unchecked" )
+    @Override
+    public String execute()
+        throws Exception
+    {
+        if ( execute )
+        {
+            schedulingManager.executeTasks();
+        }
+        else if ( schedule )
+        {
+            systemSettingManager.saveSystemSetting( KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES,
+                (HashSet<String>) scheduledPeriodTypes );
+            
+            if ( Scheduler.STATUS_RUNNING.equals( schedulingManager.getTaskStatus() ) )
+            {
+                schedulingManager.stopTasks();
+            }
+            else
+            {
+                Map<String, String> keyCronMap = new HashMap<String, String>();
+
+                if ( STRATEGY_LAST_12_DAILY.equals( aggQueryBuilderStrategy ) )
+                {
+                    keyCronMap.put( CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_12_MONTHS, Scheduler.CRON_DAILY_0AM );
+                }
+                else if ( STRATEGY_LAST_6_DAILY_6_TO_12_WEEKLY.equals( aggQueryBuilderStrategy ) )
+                {
+                    keyCronMap.put( CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_6_MONTS,
+                        Scheduler.CRON_DAILY_0AM_EXCEPT_SUNDAY );
+                    keyCronMap.put( CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_FROM_6_TO_12_MONTS,
+                        Scheduler.CRON_WEEKLY_SUNDAY_0AM );
+                }
+
+                schedulingManager.scheduleTasks( keyCronMap );
+            }
+        }
+        else
+        {
+            scheduledPeriodTypes = (Set<String>) systemSettingManager.getSystemSetting(
+                KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES );
+            orgUnitGroupSetAggLevel = (Integer) systemSettingManager.getSystemSetting(
+                KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL );
+            aggQueryBuilderStrategy = schedulingManager.getScheduledTasks().containsKey(
+                CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_12_MONTHS ) ? STRATEGY_LAST_12_DAILY
+                : STRATEGY_LAST_6_DAILY_6_TO_12_WEEKLY;
+        }
+
+        status = schedulingManager.getTaskStatus();
+        running = Scheduler.STATUS_RUNNING.equals( status );
+        levels = organisationUnitService.getOrganisationUnitLevels();
+
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-10-01 09:38:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml	2012-10-10 08:50:17 +0000
@@ -150,10 +150,9 @@
 		scope="prototype">
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="programService"
-			ref="org.hisp.dhis.program.ProgramService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
-	
+
 	<!-- Program -->
 
 	<bean id="org.hisp.dhis.patient.action.program.AddProgramAction"
@@ -161,8 +160,10 @@
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientIdentifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.action.program.GetProgramListAction"
@@ -172,12 +173,13 @@
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 	</bean>
 
-	<bean id="org.hisp.dhis.patient.action.program.GetUnAnonymousProgramAction"
+	<bean
+		id="org.hisp.dhis.patient.action.program.GetUnAnonymousProgramAction"
 		class="org.hisp.dhis.patient.action.program.GetUnAnonymousProgramAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.patient.action.program.GetProgramAction"
 		class="org.hisp.dhis.patient.action.program.GetProgramAction" scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
@@ -195,25 +197,32 @@
 		class="org.hisp.dhis.patient.action.program.ShowAddProgramFormAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientIdentifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.program.ShowUpdateProgramFormAction"
+
+	<bean
+		id="org.hisp.dhis.patient.action.program.ShowUpdateProgramFormAction"
 		class="org.hisp.dhis.patient.action.program.ShowUpdateProgramFormAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientIdentifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
-	
+
 
 	<bean id="org.hisp.dhis.patient.action.program.UpdateProgramAction"
 		class="org.hisp.dhis.patient.action.program.UpdateProgramAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientIdentifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.patient.action.program.ValidateProgramAction"
@@ -289,50 +298,71 @@
 		scope="prototype">
 		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
 	</bean>
-	
+
 	<!-- Program Stage Section -->
 
-	<bean id="org.hisp.dhis.patient.action.programstage.AddProgramStageSectionAction"
-		class="org.hisp.dhis.patient.action.programstage.AddProgramStageSectionAction" scope="prototype">
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
-		<property name="programStageDataElementService" ref="org.hisp.dhis.program.ProgramStageDataElementService" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.programstage.UpdateProgramStageSectionAction"
-		class="org.hisp.dhis.patient.action.programstage.UpdateProgramStageSectionAction" scope="prototype">
-		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
-		<property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-		<property name="programStageDataElementService" ref="org.hisp.dhis.program.ProgramStageDataElementService" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.programstage.RemoveProgramStageSectionAction"
-		class="org.hisp.dhis.patient.action.programstage.RemoveProgramStageSectionAction" scope="prototype">
-		<property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionAction"
-		class="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionAction" scope="prototype">
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-		<property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.programstage.ShowAddProgramStageSectionAction"
-		class="org.hisp.dhis.patient.action.programstage.ShowAddProgramStageSectionAction" scope="prototype">
-		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.programstage.ValidateProgramStageSectionAction"
-		class="org.hisp.dhis.patient.action.programstage.ValidateProgramStageSectionAction" scope="prototype">
-		<property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.patient.action.programstage.SaveProgramStageSectionSortOrderAction"
-		class="org.hisp.dhis.patient.action.programstage.SaveProgramStageSectionSortOrderAction" scope="prototype">
-		<property name="programStageSectionService" ref="org.hisp.dhis.program.ProgramStageSectionService" />
-	</bean>
-	
+	<bean
+		id="org.hisp.dhis.patient.action.programstage.AddProgramStageSectionAction"
+		class="org.hisp.dhis.patient.action.programstage.AddProgramStageSectionAction"
+		scope="prototype">
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="programStageDataElementService"
+			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.programstage.UpdateProgramStageSectionAction"
+		class="org.hisp.dhis.patient.action.programstage.UpdateProgramStageSectionAction"
+		scope="prototype">
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="programStageSectionService"
+			ref="org.hisp.dhis.program.ProgramStageSectionService" />
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="programStageDataElementService"
+			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.programstage.RemoveProgramStageSectionAction"
+		class="org.hisp.dhis.patient.action.programstage.RemoveProgramStageSectionAction"
+		scope="prototype">
+		<property name="programStageSectionService"
+			ref="org.hisp.dhis.program.ProgramStageSectionService" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionAction"
+		class="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionAction"
+		scope="prototype">
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="programStageSectionService"
+			ref="org.hisp.dhis.program.ProgramStageSectionService" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.programstage.ShowAddProgramStageSectionAction"
+		class="org.hisp.dhis.patient.action.programstage.ShowAddProgramStageSectionAction"
+		scope="prototype">
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.programstage.ValidateProgramStageSectionAction"
+		class="org.hisp.dhis.patient.action.programstage.ValidateProgramStageSectionAction"
+		scope="prototype">
+		<property name="programStageSectionService"
+			ref="org.hisp.dhis.program.ProgramStageSectionService" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.patient.action.programstage.SaveProgramStageSectionSortOrderAction"
+		class="org.hisp.dhis.patient.action.programstage.SaveProgramStageSectionSortOrderAction"
+		scope="prototype">
+		<property name="programStageSectionService"
+			ref="org.hisp.dhis.program.ProgramStageSectionService" />
+	</bean>
+
 	<!-- Data Entry Form -->
 
 	<bean
@@ -556,7 +586,7 @@
 			<ref bean="org.hisp.dhis.program.ProgramService" />
 		</property>
 	</bean>
-	
+
 	<!-- Case Aggregation Mapping -->
 
 	<bean
@@ -594,13 +624,14 @@
 			<ref bean="org.hisp.dhis.dataset.DataSetService" />
 		</property>
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.patient.action.caseaggregation.GetParamsByProgramAction"
 		class="org.hisp.dhis.patient.action.caseaggregation.GetParamsByProgramAction"
 		scope="prototype">
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="attributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="attributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 
 	<bean
@@ -713,7 +744,7 @@
 			<ref bean="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
 		</property>
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.patient.action.caseaggregation.GetDataElementsByDataSetAction"
 		class="org.hisp.dhis.patient.action.caseaggregation.GetDataElementsByDataSetAction"
@@ -856,7 +887,7 @@
 			<ref bean="org.hisp.dhis.program.ProgramValidationService" />
 		</property>
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.patient.action.validation.GetDateDataElementsAction"
 		class="org.hisp.dhis.patient.action.validation.GetDateDataElementsAction"
@@ -867,7 +898,7 @@
 		<property name="programValidationService"
 			ref="org.hisp.dhis.program.ProgramValidationService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.patient.action.validation.GetProgramValidationDescriptionAction"
 		class="org.hisp.dhis.patient.action.validation.GetProgramValidationDescriptionAction"
@@ -876,9 +907,9 @@
 			<ref bean="org.hisp.dhis.program.ProgramValidationService" />
 		</property>
 	</bean>
-	
+
 	<!-- Scheduling -->
-	
+
 	<bean id="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction"
 		class="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction"
 		scope="prototype">
@@ -898,5 +929,15 @@
 		<property name="jdbcTemplate" ref="jdbcTemplate" />
 		<property name="outboundSmsService" ref="org.hisp.dhis.sms.outbound.OutboundSmsService" />
 	</bean>
+	
+	<bean id="org.hisp.dhis.patient.action.schedule.ScheduleCaseAggregateConditionAction"
+		class="org.hisp.dhis.patient.action.schedule.ScheduleCaseAggregateConditionAction"
+		scope="prototype">
+		<property name="systemSettingManager"
+			ref="org.hisp.dhis.setting.SystemSettingManager" />
+		<property name="schedulingManager" ref="org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager" />
+		<property name="organisationUnitService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+	</bean>
 
 </beans>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-10-10 02:23:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-10-10 08:50:17 +0000
@@ -303,4 +303,13 @@
 confirm_delete_prorgam_stage_section = Are you sure you want to delete this program stage section ?
 form_details = Form details
 enrollment_details = Enrollment details
-repeatable_program_stage_details = Repeatable program stage details
\ No newline at end of file
+repeatable_program_stage_details = Repeatable program stage details
+schedule_aggregation_query_builder = Aggregation Query Builder
+intro_schedule_aggregation_query_builder = Schedule for running aggregate builder formulas automatically.
+aggregation_period_types = Aggregation period types
+financial_yearly = Financial Yearly
+organisation_unit_group_set_aggregation_level = Organisation unit group set aggregation level
+aggregate task strategy = Aggregate task strategy
+last_12_months_daily = Last 12 months daily
+last_6_months_daily_6_to_12_months_weekly = Last 6 months daily + 6 to 12 months weekly
+execute_tasks_confirmation=Are you sure you want to execute all tasks now? Task processing might fully utilize your system resources and slow down other operations.
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-09-28 06:26:01 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml	2012-10-10 08:50:17 +0000
@@ -28,14 +28,16 @@
 		<action name="getRelationshipType"
 			class="org.hisp.dhis.patient.action.relationship.GetRelationshipTypeAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonRelationshipType.vm</result>
+				/dhis-web-commons/ajax/jsonRelationshipType.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="removeRelationshipType"
 			class="org.hisp.dhis.patient.action.relationship.RemoveRelationshipTypeAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<param name="requiredAuthorities">F_RELATIONSHIPTYPE_DELETE</param>
 		</action>
 
@@ -73,11 +75,14 @@
 		<action name="validateRelationshipType"
 			class="org.hisp.dhis.patient.action.relationship.ValidateRelationshipTypeAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+				/dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
@@ -95,30 +100,35 @@
 		<action name="getPatientAttribute"
 			class="org.hisp.dhis.patient.action.patientattribute.GetPatientAttributeAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonPatientAttribute.vm</result>
+				/dhis-web-commons/ajax/jsonPatientAttribute.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="getPatientAttributes"
 			class="org.hisp.dhis.patient.action.patientattribute.GetPatientAttributeListAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonPatientAttributes.vm</result>
+				/dhis-web-commons/ajax/jsonPatientAttributes.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="getPatientAttributeWithoutGroup"
 			class="org.hisp.dhis.patient.action.patientattribute.GetPatientAttributesWithoutGroupAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonPatientAttributes.vm</result>
+				/dhis-web-commons/ajax/jsonPatientAttributes.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
-		
+
 		<action name="removePatientAttribute"
 			class="org.hisp.dhis.patient.action.patientattribute.RemovePatientAttributeAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+				/dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<param name="requiredAuthorities">F_PATIENTATTRIBUTE_DELETE</param>
 		</action>
 
@@ -159,20 +169,25 @@
 		<action name="validatePatientAttribute"
 			class="org.hisp.dhis.patient.action.patientattribute.ValidatePatientAttributeAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="removePatientAttributeOption"
 			class="org.hisp.dhis.patient.action.patientattribute.RemovePatientAttributeOptionAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+				/dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<param name="requiredAuthorities">F_PATIENTATTRIBUTE_DELETE</param>
 		</action>
 
@@ -189,16 +204,19 @@
 		<action name="getProgram"
 			class="org.hisp.dhis.patient.action.program.GetProgramAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonProgram.vm</result>
+				/dhis-web-commons/ajax/jsonProgram.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="removeProgram"
 			class="org.hisp.dhis.patient.action.program.RemoveProgramAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+				/dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<param name="requiredAuthorities">F_PROGRAM_DELETE</param>
 		</action>
 
@@ -238,14 +256,17 @@
 		<action name="validateProgram"
 			class="org.hisp.dhis.patient.action.program.ValidateProgramAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+				/dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
-	   
+
 		<!-- Program_OrganisationUnit Association -->
 
 		<action name="defineProgramAssociationsForm"
@@ -274,14 +295,16 @@
 		<action name="getProgramStage"
 			class="org.hisp.dhis.patient.action.programstage.GetProgramStageAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonProgramStage.vm</result>
+				/dhis-web-commons/ajax/jsonProgramStage.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="showAddProgramStageForm"
 			class="org.hisp.dhis.patient.action.program.GetProgramAction">
 			<result name="input" type="velocity-xml">
-				/dhis-web-commons/ajax/xmlResponseInput.vm</result>
+				/dhis-web-commons/ajax/xmlResponseInput.vm
+			</result>
 			<result name="success" type="velocity">/main.vm</result>
 			<param name="page">
 				/dhis-web-maintenance-patient/addProgramStageForm.vm</param>
@@ -300,16 +323,19 @@
 		<action name="validateProgramStage"
 			class="org.hisp.dhis.patient.action.programstage.ValidateProgramStageAction">
 			<result name="success" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				../dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseError.vm</result>
+				../dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="updateProgramStage"
 			class="org.hisp.dhis.patient.action.programstage.UpdateProgramStageAction">
 			<result name="success" type="redirect">
-				programStage.action?id=${programId}</result>
+				programStage.action?id=${programId}
+			</result>
 			<param name="requiredAuthorities">F_PROGRAMSTAGE_UPDATE</param>
 		</action>
 
@@ -326,9 +352,11 @@
 		<action name="removeProgramStage"
 			class="org.hisp.dhis.patient.action.programstage.RemoveProgramStageAction">
 			<result name="success" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				../dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseError.vm</result>
+				../dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 			<param name="requiredAuthorities">F_PROGRAMSTAGE_DELETE</param>
 		</action>
@@ -336,18 +364,19 @@
 		<action name="saveProgramStageSortOder"
 			class="org.hisp.dhis.patient.action.programstage.SaveProgramStageSortOrderAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 		</action>
-		
+
 		<action name="programStageList"
 			class="org.hisp.dhis.patient.action.programstage.GetProgramStageListAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-maintenance-patient/programStageList.vm</param>
 			<param name="javascripts">javascript/programStage.js</param>
 		</action>
-		
+
 		<!-- Program stage section -->
-		
+
 		<action name="programStageSectionList"
 			class="org.hisp.dhis.patient.action.programstage.GetProgramStageAction">
 			<result name="success" type="velocity">/main.vm</result>
@@ -357,7 +386,7 @@
 			<param name="stylesheets">style/basic.css</param>
 			<param name="requiredAuthorities">F_PROGRAMSTAGE_SECTION_MANAGEMENT</param>
 		</action>
-		
+
 		<action name="showAddProgramStageSectionForm"
 			class="org.hisp.dhis.patient.action.programstage.ShowAddProgramStageSectionAction">
 			<result name="success" type="velocity">/main.vm</result>
@@ -367,14 +396,14 @@
 			<param name="stylesheets">style/basic.css</param>
 			<param name="requiredAuthorities">F_PROGRAMSTAGE_SECTION_ADD</param>
 		</action>
-		
+
 		<action name="addProgramStageSection"
 			class="org.hisp.dhis.patient.action.programstage.AddProgramStageSectionAction">
 			<result name="success" type="redirect">programStageSectionList.action?id=${programStageId}
 			</result>
 			<param name="requiredAuthorities">F_PROGRAMSTAGE_SECTION_ADD</param>
 		</action>
-		
+
 		<action name="showUpdateProgramStageSectionForm"
 			class="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionAction">
 			<result name="success" type="velocity">/main.vm</result>
@@ -384,7 +413,7 @@
 			<param name="stylesheets">style/basic.css</param>
 			<param name="requiredAuthorities">F_PROGRAMSTAGE_SECTION_UPDATE</param>
 		</action>
-		
+
 		<action name="updateProgramStageSection"
 			class="org.hisp.dhis.patient.action.programstage.UpdateProgramStageSectionAction">
 			<result name="success" type="redirect">programStageSectionList.action?id=${programStageId}
@@ -395,18 +424,21 @@
 		<action name="getProgramStageSection"
 			class="org.hisp.dhis.patient.action.programstage.GetProgramStageSectionAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-maintenance-patient/jsonProgramStageSection.vm</result>
+				/dhis-web-maintenance-patient/jsonProgramStageSection.vm
+			</result>
 		</action>
-		
+
 		<action name="removeProgramStageSection"
 			class="org.hisp.dhis.patient.action.programstage.RemoveProgramStageSectionAction">
 			<result name="success" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				../dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseError.vm</result>
+				../dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<param name="requiredAuthorities">F_PROGRAMSTAGE_SECTION_DELETE</param>
 		</action>
-		
+
 		<action name="showProgramStageSectionSortedOderForm"
 			class="org.hisp.dhis.patient.action.programstage.GetProgramStageAction">
 			<result name="success" type="velocity">/main.vm</result>
@@ -416,20 +448,23 @@
 			<param name="stylesheets">style/basic.css</param>
 			<param name="requiredAuthorities">F_PROGRAMSTAGE_SECTION_MANAGEMENT</param>
 		</action>
-		
+
 		<action name="saveProgramStageSectionSortOrder"
 			class="org.hisp.dhis.patient.action.programstage.SaveProgramStageSectionSortOrderAction">
-			<result name="success" type="redirect">programStageSectionList.action?id=${id}</result>
+			<result name="success" type="redirect">programStageSectionList.action?id=${id}
+			</result>
 		</action>
-		
+
 		<action name="validateProgramStageSection"
 			class="org.hisp.dhis.patient.action.programstage.ValidateProgramStageSectionAction">
 			<result name="success" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				../dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseError.vm</result>
+				../dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 		</action>
-		
+
 		<!-- Data Entry Form -->
 
 		<action name="viewDataEntryForm"
@@ -446,28 +481,33 @@
 		<action name="saveDataEntryForm"
 			class="org.hisp.dhis.patient.action.dataentryform.SaveDataEntryFormAction">
 			<result name="success" type="redirect">
-				programStage.action?id=${programId}</result>
+				programStage.action?id=${programId}
+			</result>
 		</action>
 
 		<action name="delDataEntryForm"
 			class="org.hisp.dhis.patient.action.dataentryform.DelDataEntryFormAction">
 			<result name="success" type="redirect">
-				programStage.action?id=${programId}</result>
+				programStage.action?id=${programId}
+			</result>
 		</action>
 
 		<action name="validateDataEntryForm"
 			class="org.hisp.dhis.patient.action.dataentryform.ValidateDataEntryFormAction">
 			<result name="success" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				../dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				../dhis-web-commons/ajax/jsonResponseError.vm</result>
+				../dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="getSelectedDataElements"
 			class="org.hisp.dhis.patient.action.dataentryform.GetSelectedDataElementsAction">
 			<result name="success" type="velocity-xml">
-				/dhis-web-maintenance-patient/responseSelDataElementList.vm</result>
+				/dhis-web-maintenance-patient/responseSelDataElementList.vm
+			</result>
 		</action>
 
 		<action name="showDataEntryForm"
@@ -498,7 +538,8 @@
 		<action name="removePatientAttributeGroup"
 			class="org.hisp.dhis.patient.action.patientattributegroup.RemovePatientAttributeGroupAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<param name="requiredAuthorities">F_PATIENTATTRIBUTE_DELETE</param>
 		</action>
 
@@ -536,11 +577,14 @@
 		<action name="validatePatientAttributeGroup"
 			class="org.hisp.dhis.patient.action.patientattributegroup.ValidatePatientAttributeGroupAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+				/dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
@@ -574,11 +618,14 @@
 		<action name="validatePatientIdentifierType"
 			class="org.hisp.dhis.patient.action.patientidentifiertype.ValidatePatientIdentifierTypeAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+				/dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
@@ -612,9 +659,11 @@
 		<action name="removePatientIdentifierType"
 			class="org.hisp.dhis.patient.action.patientidentifiertype.RemovePatientIdentifierTypeAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="error" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseError.vm</result>
+				/dhis-web-commons/ajax/jsonResponseError.vm
+			</result>
 			<param name="requiredAuthorities">F_PATIENTIDENTIFIERTYPE_DELETE</param>
 		</action>
 
@@ -674,22 +723,24 @@
 		<action name="removeCaseAggregation"
 			class="org.hisp.dhis.patient.action.caseaggregation.RemoveCaseAggregationConditionAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 		</action>
 
-		<action name="getDataElementsByDataset" class="org.hisp.dhis.patient.action.caseaggregation.GetDataElementsByDataSetAction">
+		<action name="getDataElementsByDataset"
+			class="org.hisp.dhis.patient.action.caseaggregation.GetDataElementsByDataSetAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-maintenance-patient/responseAggerateDataElement.vm
 			</result>
 		</action>
-		
+
 		<action name="getParamsByProgram"
 			class="org.hisp.dhis.patient.action.caseaggregation.GetParamsByProgramAction">
 			<result name="success" type="velocity-json">
 				/dhis-web-maintenance-patient/jsonParamsByProgram.vm
 			</result>
 		</action>
-		
+
 		<action name="getPatientDataElements"
 			class="org.hisp.dhis.patient.action.caseaggregation.GetPatientDataElementsAction">
 			<result name="success" type="velocity-json">
@@ -707,32 +758,38 @@
 		<action name="getCaseAggregation"
 			class="org.hisp.dhis.patient.action.caseaggregation.GetCaseAggregationConditionAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonCaseAggregation.vm</result>
+				/dhis-web-commons/ajax/jsonCaseAggregation.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="getCaseAggregationDescription"
 			class="org.hisp.dhis.patient.action.caseaggregation.GetAggConditionDescriptionAction">
 			<result name="success" type="velocity">
-				/dhis-web-maintenance-patient/responseCaseAggDescription.vm</result>
+				/dhis-web-maintenance-patient/responseCaseAggDescription.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="validateCaseAggregation"
 			class="org.hisp.dhis.patient.action.caseaggregation.ValidateCaseAggregationConditionAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
 		<action name="testCaseAggregationCondition"
 			class="org.hisp.dhis.patient.action.caseaggregation.TestCaseAggregationConditionAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
@@ -777,7 +834,8 @@
 		<action name="getValidationCriteria"
 			class="org.hisp.dhis.patient.action.validation.GetValidationCriteriaAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonValidationCriteria.vm</result>
+				/dhis-web-commons/ajax/jsonValidationCriteria.vm
+			</result>
 		</action>
 
 		<action name="updateValidationCriteria"
@@ -790,16 +848,19 @@
 		<action name="removeValidationCriteria"
 			class="org.hisp.dhis.patient.action.validation.RemoveValidationCriteriaAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<param name="requiredAuthorities">F_VALIDATIONCRITERIA_DELETE</param>
 		</action>
 
 		<action name="validateValidationCriteria"
 			class="org.hisp.dhis.patient.action.validation.ValidateValidationCriteriaAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<result name="input" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseInput.vm</result>
+				/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 		</action>
 
 		<action name="showProgramsForValidationCriteriaForm"
@@ -813,7 +874,8 @@
 		<action name="defineProgramsForValidationCriteria"
 			class="org.hisp.dhis.patient.action.validation.DefineProgramListForValidationCriteriaAction">
 			<result name="success" type="redirect">
-				validationCriteria.action</result>
+				validationCriteria.action
+			</result>
 			<param name="requiredAuthorities">F_PROGRAM_UPDATE</param>
 		</action>
 
@@ -856,7 +918,8 @@
 		<action name="addProgramValidation"
 			class="org.hisp.dhis.patient.action.validation.AddProgramValidationAction">
 			<result name="success" type="redirect">
-				programValidation.action?programId=${programId}</result>
+				programValidation.action?programId=${programId}
+			</result>
 			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
 		</action>
 
@@ -881,21 +944,24 @@
 		<action name="updateProgramValidation"
 			class="org.hisp.dhis.patient.action.validation.UpdateProgramValidationAction">
 			<result name="success" type="redirect">
-				programValidation.action?programId=${programId}</result>
+				programValidation.action?programId=${programId}
+			</result>
 			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
 		</action>
 
 		<action name="removeProgramValidation"
 			class="org.hisp.dhis.patient.action.validation.RemoveProgramValidationAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
 		</action>
 
 		<action name="getProgramValidation"
 			class="org.hisp.dhis.patient.action.validation.GetProgramValidationAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonProgramValidation.vm</result>
+				/dhis-web-commons/ajax/jsonProgramValidation.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
 
@@ -908,46 +974,73 @@
 		<action name="addDateProgramValidation"
 			class="org.hisp.dhis.patient.action.validation.AddProgramValidationAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
 		</action>
 
 		<action name="updateDateProgramValidation"
 			class="org.hisp.dhis.patient.action.validation.UpdateProgramValidationAction">
 			<result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
 			<param name="requiredAuthorities">F_PROGRAM_VALIDATION</param>
 		</action>
 
 		<action name="getProgramValidationDescription"
 			class="org.hisp.dhis.patient.action.validation.GetProgramValidationDescriptionAction">
 			<result name="success" type="velocity">
-				/dhis-web-maintenance-patient/responseCaseAggDescription.vm</result>
+				/dhis-web-maintenance-patient/responseCaseAggDescription.vm
+			</result>
 			<param name="onExceptionReturn">plainTextError</param>
 		</action>
-		
+
 		<!-- Scheduling -->
-		
-		<action name="viewScheduleTasks" class="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction">
-	      <result name="success" type="velocity">/main.vm</result>
-	      <param name="page">/dhis-web-maintenance-patient/scheduleSendMessage.vm</param>
-	      <param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
-	      <param name="javascripts">javascript/scheduling.js</param>
-		  <param name="schedule">true</param>
-	      <param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
-	    </action>
-	    
-		<action name="scheduleTasks" class="org.hisp.dhis.patient.action.schedule.ScheduleSendMessageTasksAction">
-	      <result name="success" type="velocity-json">
-				/dhis-web-maintenance-patient/jsonResponseScheduleTasks.vm</result>
-	      <param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
-	    </action>
-	    
-	    <action name="executeSendMessage" class="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction">
-	      <result name="success" type="velocity-json">
-				/dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
-	      <param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
-	    </action>
-		
+
+		<action name="viewScheduleTasks"
+			class="org.hisp.dhis.patient.action.schedule.GetScheduleParamsAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/scheduleSendMessage.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
+			<param name="javascripts">javascript/scheduling.js</param>
+			<param name="schedule">true</param>
+			<param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
+		</action>
+
+		<action name="scheduleTasks"
+			class="org.hisp.dhis.patient.action.schedule.ScheduleSendMessageTasksAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-maintenance-patient/jsonResponseScheduleTasks.vm
+			</result>
+			<param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
+		</action>
+
+		<action name="executeSendMessage"
+			class="org.hisp.dhis.patient.action.schedule.ExecuteSendMessageAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonResponseSuccess.vm
+			</result>
+			<param name="requiredAuthorities">F_SCHEDULING_SEND_MESSAGE</param>
+		</action>
+
+		<action name="viewScheduledCaseAggCondTasks"
+			class="org.hisp.dhis.patient.action.schedule.ScheduleCaseAggregateConditionAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
+			<param name="javascripts">javascript/scheduling.js</param>
+			<param name="requiredAuthorities">F_SCHEDULING_ADMIN</param>
+		</action>
+
+		<action name="scheduleCaseAggTasks"
+			class="org.hisp.dhis.patient.action.schedule.ScheduleCaseAggregateConditionAction">
+			<result name="success" type="velocity">/main.vm</result>
+			<param name="page">/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm</param>
+			<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
+			<param name="javascripts">javascript/scheduling.js</param>
+			<param name="schedule">true</param>
+			<param name="requiredAuthorities">F_SCHEDULING_ADMIN</param>
+		</action>
+
 	</package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm	2012-10-06 05:12:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/index.vm	2012-10-10 08:50:17 +0000
@@ -19,4 +19,7 @@
 	#if( $auth.hasAccess( "dhis-web-maintenance-patient", "viewScheduleTasks" ) )
 		#introListImgItem( "viewScheduleTasks.action" "schedule_message" "scheduling" )
 	#end
+	
+	#introListImgItem( "viewScheduledCaseAggCondTasks.action" "schedule_aggregation_query_builder" "scheduling" )
+	
 </ul>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js	2012-10-09 05:25:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js	2012-10-10 08:50:17 +0000
@@ -1,3 +1,8 @@
+
+// -----------------------------------------------------------------------
+// Schedule Messages
+// -----------------------------------------------------------------------
+
 function scheduleTasks()
 {
 	$.post( 'scheduleTasks.action',{
@@ -31,3 +36,23 @@
 		setMessage(i18n_execute_success);
 	});
 }
+
+// -----------------------------------------------------------------------
+// Schedule Aggregate Query Builder
+// -----------------------------------------------------------------------
+
+function submitSchedulingForm()
+{
+	$( '.scheduling' ).removeAttr( 'disabled' );
+	$( '#schedulingForm' ).submit();
+}
+
+function executeAggCondTasks()
+{
+	var ok = confirm( i18n_execute_tasks_confirmation );
+	
+	if ( ok )
+	{
+		$.get( 'scheduleCaseAggTasks.action?execute=true' );
+	}
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2012-10-06 05:12:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menu.vm	2012-10-10 08:50:17 +0000
@@ -17,5 +17,6 @@
 <h2>$i18n.getString( "scheduling" )</h2>
 <ul>
 	<li><a href="viewScheduleTasks.action">$i18n.getString( "schedule_message" )</a></li>
+	<li><a href="viewScheduledCaseAggCondTasks.action">$i18n.getString( "schedule_aggregation_query_builder" )</a></li>
 </ul>
 #end

=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menuScheduling.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menuScheduling.vm	2012-09-10 10:28:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/menuScheduling.vm	1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
-<h2>$i18n.getString( "patients" )</h2>
-<ul>
-	<li><a href="patientAttribute.action">$i18n.getString( "patient_attribute" )</a></li>
-	<li><a href="patientAttributeGroup.action">$i18n.getString( "patient_attribute_group" )</a></li>
-	<li><a href="patientIdentifierType.action">$i18n.getString( "patient_identifier_type" )</a></li>
-	<li><a href="relationshipType.action">$i18n.getString( "relationship_type" )</a></li>
-</ul>
-
-<h2>$i18n.getString( "programs" )</h2>
-<ul>
-	<li><a href="program.action">$i18n.getString( "program" )</a></li>
-	<li><a href="caseAggregation.action">$i18n.getString( "aggregation_query_builder" )</a></li>
-	<li><a href="validationCriteria.action">$i18n.getString( "validation_criteria" )</a></li>
-</ul>

=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm	2012-10-10 08:50:17 +0000
@@ -0,0 +1,76 @@
+<script type="text/javascript">
+    var i18n_execute_tasks_confirmation = '$encoder.jsEscape( $i18n.getString( "execute_tasks_confirmation" ), "'" )';
+</script>
+
+<h3>$i18n.getString( "schedule_aggregation_query_builder" ) #openHelp( "scheduling" )</h3>
+
+<input id="isRunning" type="hidden" value="${running}">
+
+<form id="schedulingForm" action="scheduleCaseAggTasks.action" method="get">
+<input type='hidden' id='schedule' name='schedule' value='true'/>
+	
+<table style="width:300px">
+<tr>
+	<th style="width:100%">$i18n.getString( "aggregation_period_types" )</th>
+</tr>
+<tr>
+	<td>
+		<label for="weekly">$i18n.getString( "Weekly" )</label><input type="checkbox" id="weekly" class="scheduling" name="scheduledPeriodTypes" value="Weekly"#if( $scheduledPeriodTypes.contains( "Weekly" ) ) checked="checked"#end>&nbsp;
+		<label for="monthly">$i18n.getString( "Monthly" )</label><input type="checkbox" id="monthly" class="scheduling" name="scheduledPeriodTypes" value="Monthly"#if( $scheduledPeriodTypes.contains( "Monthly" ) ) checked="checked"#end>&nbsp;
+		<label for="biMonthly">$i18n.getString( "BiMonthly" )</label><input type="checkbox" id="biMonthly" class="scheduling" name="scheduledPeriodTypes" value="BiMonthly"#if( $scheduledPeriodTypes.contains( "BiMonthly" ) ) checked="checked"#end>&nbsp;
+		<label for="quarterly">$i18n.getString( "Quarterly" )</label><input type="checkbox" id="quarterly" class="scheduling" name="scheduledPeriodTypes" value="Quarterly"#if( $scheduledPeriodTypes.contains( "Quarterly" ) ) checked="checked"#end><br><br>
+		<label for="sixMonthly">$i18n.getString( "SixMonthly" )</label><input type="checkbox" id="sixMonthly" class="scheduling" name="scheduledPeriodTypes" value="SixMonthly"#if( $scheduledPeriodTypes.contains( "SixMonthly" ) ) checked="checked"#end>&nbsp;
+		<label for="yearly">$i18n.getString( "Yearly" )</label><input type="checkbox" id="yearly" class="scheduling" name="scheduledPeriodTypes" value="Yearly"#if( $scheduledPeriodTypes.contains( "Yearly" ) ) checked="checked"#end>&nbsp;
+		<label for="financialYearly">$i18n.getString( "financial_yearly" )</label><input type="checkbox" id="financialYearly" class="scheduling" name="scheduledPeriodTypes" value="FinancialJuly"#if( $scheduledPeriodTypes.contains( "FinancialJuly" ) ) checked="checked"#end>			
+	</td>
+</tr>
+<tr>
+	<td style="height:10px"></td>
+</tr>
+<tr>
+	<th>$i18n.getString( "organisation_unit_group_set_aggregation_level" )</th>
+</tr>
+<tr>
+	<td>
+		<select id="orgUnitGroupSetAggLevel" name="orgUnitGroupSetAggLevel" class="scheduling" style="width:100%">
+		<option value="0"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == 0 ) selected="selected"#end>[$i18n.getString( "no_aggregation" )]</option>
+		#foreach( $level in $levels )
+		<option value="$level.level"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == $level.level ) selected="selected"#end>$encoder.htmlEncode( $level.name )</option>
+		#end
+		</select>
+	</td>
+</tr>
+<tr>
+	<td style="height:10px"></td>
+</tr>
+<tr>
+	<th>$i18n.getString( "aggregate_task_strategy" )</th>
+</tr>
+<tr>
+	<td>
+		<select id="aggQueryBuilderStrategy" name="aggQueryBuilderStrategy" class="scheduling" style="width:100%">
+		<option value="never">$i18n.getString( "never" )</option>
+		<option value="last12Daily"#if( $aggQueryBuilderStrategy && $aggQueryBuilderStrategy == "last12Daily" ) selected="selected"#end>$i18n.getString( "last_12_months_daily" )</option>
+		<option value="last6Daily6To12Weekly"#if( $aggQueryBuilderStrategy && $aggQueryBuilderStrategy == "last6Daily6To12Weekly" ) selected="selected"#end>$i18n.getString( "last_6_months_daily_6_to_12_months_weekly" )</option>		
+		</select>
+	</td>
+</tr>
+<tr>
+	<td style="height:10px"></td>
+</tr>
+<tr>
+	<td>
+		<input type="button" style="width:140px" onclick="submitSchedulingForm()"
+		#if ( $running )
+		value="$i18n.getString( 'stop' )"
+		#else
+		value="$i18n.getString( 'start' )"
+		#end
+		/>
+		<input type="button" id="executeButton" style="width:140px" onclick="executeAggCondTasks()" value="$i18n.getString( 'execute' )" />
+	</td>
+</tr>
+</table>
+</form>
+
+<span id="info">$i18n.getString( "scheduling_is" ) $!i18n.getString( $!status )</span>