← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8700: Allow select only one period type in scheduling aggregate query builder.

 

------------------------------------------------------------
revno: 8700
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-25 11:06:54 +0700
message:
  Allow select only one period type in scheduling aggregate query builder.
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/scheduling/CaseAggregateConditionTask.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.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/javascript/scheduling.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.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-23 08:04:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java	2012-10-25 04:06:54 +0000
@@ -73,7 +73,7 @@
     final String KEY_SCHEDULE_MESSAGE_TASKS = "scheduleMessage";
     final String KEY_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_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE = "keyScheduledAggregateQueryBuilderPeriodType";
     final String KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL = "aggQueryBuilderorgUnitGroupSetAggregationLevel";
     final String KEY_CONFIGURATION = "keyConfig";
 
@@ -87,6 +87,7 @@
     final int DEFAULT_COMPLETENESS_OFFSET = 15;
     final String DEFAULT_TIME_FOR_SENDING_MESSAGE = "08:00";
     
+    final String DEFAULT_SCHEDULED_CASE_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES = MonthlyPeriodType.NAME;
     final HashSet<String> DEFAULT_SCHEDULED_PERIOD_TYPES = new HashSet<String>() { {
         add( MonthlyPeriodType.NAME ); 
         add( QuarterlyPeriodType.NAME );

=== modified 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	2012-10-12 06:24:32 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java	2012-10-25 04:06:54 +0000
@@ -28,13 +28,13 @@
 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 static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -81,14 +81,7 @@
     // -------------------------------------------------------------------------
     // Params
     // -------------------------------------------------------------------------
-
-    private List<Period> periods;
-
-    public void setPeriods( List<Period> periods )
-    {
-        this.periods = periods;
-    }
-
+    
     private boolean last6Months;
 
     public void setLast6Months( boolean last6Months )
@@ -126,7 +119,6 @@
     // -------------------------------------------------------------------------
 
     @Override
-    @SuppressWarnings( "unchecked" )
     public void run()
     {
         int level = (Integer) systemSettingManager.getSystemSetting(
@@ -140,11 +132,11 @@
         // 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 );
-
+        String periodType = (String) systemSettingManager.getSystemSetting(
+            KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE, KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE );
+       
+        List<Period> periods = getPeriods( periodType );
+        
         // ---------------------------------------------------------------------
         // Aggregation
         // ---------------------------------------------------------------------
@@ -220,13 +212,11 @@
     // Supportive methods
     // -------------------------------------------------------------------------
 
-    private List<Period> getPeriods( Set<String> periodTypes )
+    private List<Period> getPeriods( String periodType )
     {
-        if ( periods != null && periods.size() > 0 )
-        {
-            return periods;
-        }
-
+        Set<String> periodTypes = new HashSet<String>();
+        periodTypes.add( periodType );
+        
         List<Period> relatives = new ArrayList<Period>();
 
         if ( last6Months )

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.java	2012-10-12 07:57:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.java	2012-10-25 04:06:54 +0000
@@ -28,13 +28,11 @@
 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.DEFAULT_SCHEDULED_CASE_AGGREGATE_QUERY_BUILDER_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 static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE;
 
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -82,11 +80,11 @@
     // Output
     // -------------------------------------------------------------------------
 
-    private Set<String> scheduledPeriodTypes = new HashSet<String>();
+    private String scheduledPeriodType;
 
-    public Set<String> getScheduledPeriodTypes()
+    public String getScheduledPeriodType()
     {
-        return scheduledPeriodTypes;
+        return scheduledPeriodType;
     }
 
     private Integer orgUnitGroupSetAggLevel;
@@ -128,13 +126,12 @@
     // Action implementation
     // -------------------------------------------------------------------------
 
-    @SuppressWarnings( "unchecked" )
     @Override
     public String execute()
         throws Exception
     {
-        scheduledPeriodTypes = (Set<String>) systemSettingManager.getSystemSetting(
-            KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES );
+        scheduledPeriodType = (String) systemSettingManager.getSystemSetting(
+            KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE, DEFAULT_SCHEDULED_CASE_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES );
 
         orgUnitGroupSetAggLevel = (Integer) systemSettingManager.getSystemSetting(
             KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL );

=== modified 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	2012-10-12 07:34:56 +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-25 04:06:54 +0000
@@ -28,12 +28,10 @@
 package org.hisp.dhis.patient.action.schedule;
 
 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 static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE;
 
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 
 import org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager;
 import org.hisp.dhis.setting.SystemSettingManager;
@@ -82,11 +80,11 @@
         this.execute = execute;
     }
 
-    private Set<String> scheduledPeriodTypes = new HashSet<String>();
+    private String scheduledPeriodType;
 
-    public void setScheduledPeriodTypes( Set<String> scheduledPeriodTypes )
+    public void setScheduledPeriodType( String scheduledPeriodType )
     {
-        this.scheduledPeriodTypes = scheduledPeriodTypes;
+        this.scheduledPeriodType = scheduledPeriodType;
     }
 
     private Integer orgUnitGroupSetAggLevel;
@@ -135,8 +133,7 @@
         }
         else
         {
-            systemSettingManager.saveSystemSetting( KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPES,
-                (HashSet<String>) scheduledPeriodTypes );
+            systemSettingManager.saveSystemSetting( KEY_SCHEDULED_AGGREGATE_QUERY_BUILDER_PERIOD_TYPE, scheduledPeriodType );
             systemSettingManager.saveSystemSetting( KEY_AGGREGATE_QUERY_BUILDER_ORGUNITGROUPSET_AGG_LEVEL,
                 orgUnitGroupSetAggLevel );
 

=== 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-22 04:00:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js	2012-10-25 04:06:54 +0000
@@ -43,15 +43,11 @@
 
 function schedulingAggCondTasks()
 {
-	var scheduledPeriodTypes = "";
-	jQuery("#scheduledPeriodTypes").each(function(){
-		scheduledPeriodTypes+='&scheduledPeriodTypes=' + this.value;
-	});
-	
-	$.post( 'scheduleCaseAggTasks.action?' + scheduledPeriodTypes,{
+	$.post( 'scheduleCaseAggTasks.action',{
 		execute:false,
 		orgUnitGroupSetAggLevel:getFieldValue("orgUnitGroupSetAggLevel"),
-		aggQueryBuilderStrategy:getFieldValue("aggQueryBuilderStrategy")
+		aggQueryBuilderStrategy:getFieldValue("aggQueryBuilderStrategy"),
+		scheduledPeriodType: jQuery("[name=scheduledPeriodType]:checked").val()
 	}, function( json ){
 		var status = json.scheduleTasks.status;
 		if( status=='not_started' ){
@@ -73,15 +69,11 @@
 	setWaitMessage( i18n_executing );	
 	if ( ok )
 	{
-		var scheduledPeriodTypes = "";
-		jQuery("#scheduledPeriodTypes").each(function(){
-			scheduledPeriodTypes+='&scheduledPeriodTypes=' + this.value;
-		});
-		
-		$.post( 'scheduleCaseAggTasks.action?' + scheduledPeriodTypes,{
+		$.post( 'scheduleCaseAggTasks.action',{
 			execute:true,
 			orgUnitGroupSetAggLevel:getFieldValue("orgUnitGroupSetAggLevel"),
-			aggQueryBuilderStrategy:getFieldValue("aggQueryBuilderStrategy")
+			aggQueryBuilderStrategy:getFieldValue("aggQueryBuilderStrategy"),
+			scheduledPeriodType: jQuery("[name=scheduledPeriodType]:checked").val()
 		},function( json ){
 			setMessage(i18n_execute_success);
 		});

=== modified 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	2012-10-22 06:17:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm	2012-10-25 04:06:54 +0000
@@ -22,17 +22,17 @@
 </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>
+		<label for="weekly">$i18n.getString( "Weekly" )</label><input type="radio" id="weekly" class="scheduling" name="scheduledPeriodType" value="Weekly"#if( $scheduledPeriodType.contains( "Weekly" ) ) checked="checked"#end>&nbsp;
+		<label for="monthly">$i18n.getString( "Monthly" )</label><input type="radio" id="monthly" class="scheduling" name="scheduledPeriodType" value="Monthly"#if( $scheduledPeriodType.contains( "Monthly" ) ) checked="checked"#end>&nbsp;
+		<label for="biMonthly">$i18n.getString( "BiMonthly" )</label><input type="radio" id="biMonthly" class="scheduling" name="scheduledPeriodType" value="BiMonthly"#if( $scheduledPeriodType.contains( "BiMonthly" ) ) checked="checked"#end>&nbsp;
+		<label for="quarterly">$i18n.getString( "Quarterly" )</label><input type="radio" id="quarterly" class="scheduling" name="scheduledPeriodType" value="Quarterly"#if( $scheduledPeriodType.contains( "Quarterly" ) ) checked="checked"#end>
 	</td>
 </tr>
 <tr>
 	<td>
-		<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>			
+		<label for="sixMonthly">$i18n.getString( "SixMonthly" )</label><input type="radio" id="sixMonthly" class="scheduling" name="scheduledPeriodType" value="SixMonthly"#if( $scheduledPeriodTypes.contains( "SixMonthly" ) ) checked="checked"#end>&nbsp;
+		<label for="yearly">$i18n.getString( "Yearly" )</label><input type="radio" id="yearly" class="scheduling" name="scheduledPeriodType" value="Yearly"#if( $scheduledPeriodTypes.contains( "Yearly" ) ) checked="checked"#end>&nbsp;
+		<label for="financialYearly">$i18n.getString( "financial_yearly" )</label><input type="radio" id="financialYearly" class="scheduling" name="scheduledPeriodType" value="FinancialJuly"#if( $scheduledPeriodTypes.contains( "FinancialJuly" ) ) checked="checked"#end>			
 	</td>
 </tr>
 <tr>