dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21387
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10106: Add more option to set periods to schedule case aggregate task.
------------------------------------------------------------
revno: 10106
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-03-09 22:25:42 +0700
message:
Add more option to set periods to schedule case aggregate task.
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/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/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/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/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/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-04-03 22:10:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/setting/SystemSettingManager.java 2013-03-09 15:25:42 +0000
@@ -73,6 +73,9 @@
final String KEY_PHONE_NUMBER_AREA_CODE = "phoneNumberAreaCode";
final String KEY_MULTI_ORGANISATION_UNIT_FORMS = "multiOrganisationUnitForms";
final String KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASKS = "scheduleAggregateQueryBuilder";
+ final String KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY = "scheduleAggregateQueryBuilderTackStrategy";
+ final String DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY = "lastMonth";
+
final String KEY_CONFIGURATION = "keyConfig";
final String KEY_ACCOUNT_RECOVERY = "keyAccountRecovery";
=== modified 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 2013-01-03 06:54:08 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionSchedulingManager.java 2013-03-09 15:25:42 +0000
@@ -37,6 +37,11 @@
public interface CaseAggregateConditionSchedulingManager
{
final String TASK_AGGREGATE_QUERY_BUILDER = "aggregateQueryBuilder";
+ final String TASK_AGGREGATE_QUERY_BUILDER_LAST_MONTH = "lastMonth";
+ final String TASK_AGGREGATE_QUERY_BUILDER_LAST_3_MONTH = "last3Month";
+ final String TASK_AGGREGATE_QUERY_BUILDER_LAST_6_MONTH = "last6Month";
+ final String TASK_AGGREGATE_QUERY_BUILDER_LAST_12_MONTH = "last12Month";
+
void scheduleTasks();
void scheduleTasks( Map<String, String> keyCronMap );
=== 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 2013-03-07 14:25:42 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java 2013-03-09 15:25:42 +0000
@@ -27,9 +27,18 @@
package org.hisp.dhis.patient.scheduling;
+import static org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_12_MONTH;
+import static org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_3_MONTH;
+import static org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_6_MONTH;
+import static org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER_LAST_MONTH;
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY;
+
+import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
+import java.util.List;
import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
import org.hisp.dhis.caseaggregation.CaseAggregationConditionService;
@@ -43,6 +52,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.setting.SystemSettingManager;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
@@ -68,13 +78,16 @@
private DataElementCategoryService categoryService;
+ private SystemSettingManager systemSettingManager;
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
public CaseAggregateConditionTask( OrganisationUnitService organisationUnitService,
CaseAggregationConditionService aggregationConditionService, DataValueService dataValueService,
- JdbcTemplate jdbcTemplate, DataElementService dataElementService, DataElementCategoryService categoryService )
+ JdbcTemplate jdbcTemplate, DataElementService dataElementService, DataElementCategoryService categoryService,
+ SystemSettingManager systemSettingManager )
{
this.organisationUnitService = organisationUnitService;
this.aggregationConditionService = aggregationConditionService;
@@ -82,6 +95,7 @@
this.jdbcTemplate = jdbcTemplate;
this.dataElementService = dataElementService;
this.categoryService = categoryService;
+ this.systemSettingManager = systemSettingManager;
}
// -------------------------------------------------------------------------
@@ -91,6 +105,9 @@
@Override
public void run()
{
+ String taskStrategy = (String) systemSettingManager.getSystemSetting(
+ KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY, DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY );
+
Collection<OrganisationUnit> orgunits = organisationUnitService.getAllOrganisationUnits();
String datasetSQL = "select dm.datasetid as datasetid, pt.name as periodname";
@@ -104,9 +121,9 @@
{
int datasetId = rsDataset.getInt( "datasetid" );
- Period period = getPeriod( rsDataset.getString( "periodname" ) );
+ List<Period> periods = getPeriod( rsDataset.getString( "periodname" ), taskStrategy );
- if ( period != null )
+ for( Period period : periods )
{
String sql = "select caseaggregationconditionid, aggregationdataelementid, optioncomboid "
+ " from caseaggregationcondition cagg inner join datasetmembers dm "
@@ -148,6 +165,7 @@
// -----------------------------------------------------
// Add dataValue
// -----------------------------------------------------
+
if ( dataValue == null )
{
dataValue = new DataValue( dElement, period, orgUnit, "" + resultValue, "", new Date(),
@@ -189,16 +207,39 @@
// Supportive methods
// -------------------------------------------------------------------------
- private Period getPeriod( String periodTypeName )
- {
- Calendar today = Calendar.getInstance();
+ private List<Period> getPeriod( String periodTypeName, String taskStrategy )
+ {
+ Calendar calStartDate = Calendar.getInstance();
+
+ if ( TASK_AGGREGATE_QUERY_BUILDER_LAST_MONTH.equals( taskStrategy ) )
+ {
+ calStartDate.add( Calendar.MONTH, -1 );
+ }
+ else if ( TASK_AGGREGATE_QUERY_BUILDER_LAST_3_MONTH.equals( taskStrategy ) )
+ {
+ calStartDate.add( Calendar.MONTH, -3 );
+ }
+ else if ( TASK_AGGREGATE_QUERY_BUILDER_LAST_6_MONTH.equals( taskStrategy ) )
+ {
+ calStartDate.add( Calendar.MONTH, -6 );
+ }
+ else if ( TASK_AGGREGATE_QUERY_BUILDER_LAST_12_MONTH.equals( taskStrategy ) )
+ {
+ calStartDate.add( Calendar.MONTH, -12 );
+ }
- today.add( Calendar.DATE, -1 );
+ Date startDate = calStartDate.getTime();
+
+ Calendar calEndDate = Calendar.getInstance();
+
+ Date endDate = calEndDate.getTime();
CalendarPeriodType periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( periodTypeName );
- Period period = periodType.createPeriod( today );
-
- return (period.getEndDate().before( today.getTime() )) ? period : null;
+ List<Period> periods = new ArrayList<Period>();
+
+ periods.addAll( periodType.generatePeriods( startDate , endDate ) );
+
+ return periods;
}
}
=== 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 2013-03-08 09:15:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-03-09 15:25:42 +0000
@@ -483,6 +483,7 @@
<constructor-arg ref="jdbcTemplate" />
<constructor-arg ref="org.hisp.dhis.dataelement.DataElementService" />
<constructor-arg ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ <constructor-arg ref="org.hisp.dhis.setting.SystemSettingManager" />
</bean>
<bean id="aggregateQueryBuilder" class="org.hisp.dhis.patient.scheduling.CaseAggregateConditionTask"
=== 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-11-16 03:50:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/GetScheduleAggQueryBuilderParamsAction.java 2013-03-09 15:25:42 +0000
@@ -27,7 +27,11 @@
package org.hisp.dhis.patient.action.schedule;
+import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY;
+
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;
@@ -51,7 +55,14 @@
{
this.schedulingManager = schedulingManager;
}
-
+
+ private SystemSettingManager systemSettingManager;
+
+ public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+ {
+ this.systemSettingManager = systemSettingManager;
+ }
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -70,6 +81,13 @@
return running;
}
+ private String taskStrategy;
+
+ public String getTaskStrategy()
+ {
+ return taskStrategy;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -78,6 +96,9 @@
public String execute()
throws Exception
{
+ taskStrategy = (String) systemSettingManager.getSystemSetting(
+ KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY, DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY );
+
status = schedulingManager.getTaskStatus();
running = Scheduler.STATUS_RUNNING.equals( status );
=== 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 2013-01-03 06:54:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/schedule/ScheduleCaseAggregateConditionAction.java 2013-03-09 15:25:42 +0000
@@ -27,10 +27,13 @@
package org.hisp.dhis.patient.action.schedule;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY;
+
import java.util.HashMap;
import java.util.Map;
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;
@@ -54,6 +57,13 @@
this.schedulingManager = schedulingManager;
}
+ private SystemSettingManager systemSettingManager;
+
+ public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+ {
+ this.systemSettingManager = systemSettingManager;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -83,6 +93,13 @@
return running;
}
+ private String taskStrategy;
+
+ public void setTaskStrategy( String taskStrategy )
+ {
+ this.taskStrategy = taskStrategy;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -103,6 +120,9 @@
}
else
{
+ systemSettingManager.saveSystemSetting( KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY,
+ taskStrategy );
+
Map<String, String> keyCronMap = new HashMap<String, String>();
keyCronMap.put( CaseAggregateConditionSchedulingManager.TASK_AGGREGATE_QUERY_BUILDER,
=== 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 2013-03-08 13:27:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-03-09 15:25:42 +0000
@@ -1033,6 +1033,9 @@
scope="prototype">
<property name="schedulingManager"
ref="org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager" />
+ <property name="systemSettingManager">
+ <ref bean="org.hisp.dhis.setting.SystemSettingManager" />
+ </property>
</bean>
<bean
@@ -1041,6 +1044,9 @@
scope="prototype">
<property name="schedulingManager"
ref="org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager" />
+ <property name="systemSettingManager">
+ <ref bean="org.hisp.dhis.setting.SystemSettingManager" />
+ </property>
</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 2013-03-01 14:09:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2013-03-09 15:25:42 +0000
@@ -361,4 +361,9 @@
insert_data_elements = Insert data elements
only_enroll_once = Only enroll one
insert_a_due_date = Please insert a due-date
-capture_coordinates = Capture coordinates
\ No newline at end of file
+capture_coordinates = Capture coordinates
+task_stragely = Task stragely
+last_month = Last month
+last_3_month = Last 3 month
+last_6_month = Last 6 month
+last_12_month = Last 12 month
\ 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 2013-01-03 06:54:08 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/scheduling.js 2013-03-09 15:25:42 +0000
@@ -1,3 +1,4 @@
+
// -----------------------------------------------------------------------
// Schedule Messages
// -----------------------------------------------------------------------
@@ -46,6 +47,7 @@
function schedulingAggCondTasks()
{
$.post( 'scheduleCaseAggTasks.action',{
+ taskStrategy:getFieldValue('taskStrategy'),
execute:false
}, function( json ){
var status = json.scheduleTasks.status;
@@ -71,6 +73,7 @@
if ( ok )
{
$.post( 'scheduleCaseAggTasks.action',{
+ taskStrategy:getFieldValue('taskStrategy'),
execute:true
},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 2013-01-07 09:11:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewScheduledCaseAggTasks.vm 2013-03-09 15:25:42 +0000
@@ -17,7 +17,20 @@
<input type='hidden' id='execute' name='execute'/>
<table>
-
+
+<tr>
+ <th>$i18n.getString("task_stragely")</th>
+</tr>
+<tr>
+ <td>
+ <select id='taskStrategy' name='taskStrategy'>
+ <option value='lastMonth' #if($taskStrategy=='lastMonth') selected #end>$i18n.getString("last_month")</option>
+ <option value='last3Month' #if($taskStrategy=='last3Month') selected #end>$i18n.getString("last_3_month")</option>
+ <option value='last6Month' #if($taskStrategy=='last6Month') selected #end>$i18n.getString("last_6_month")</option>
+ <option value='last12Month' #if($taskStrategy=='last12Month') selected #end>$i18n.getString("last_12_month")</option>
+ </select>
+ </td>
+</tr>
<tr>
<td>
<input type="button" style="width:140px" onclick="schedulingAggCondTasks();" id="scheduledBtn" name="scheduledBtn"