dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21829
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10430: Add notification when to run Aggregation Query Builder fomulas in Schedule automated aggregation ...
------------------------------------------------------------
revno: 10430
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-03-29 11:26:45 +0700
message:
Add notification when to run Aggregation Query Builder fomulas in Schedule automated aggregation function.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.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/ScheduleCaseAggregateConditionAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
--
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/scheduling/TaskCategory.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.java 2013-03-05 19:00:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/scheduling/TaskCategory.java 2013-03-29 04:26:45 +0000
@@ -36,5 +36,6 @@
RESOURCETABLE_UPDATE,
DATAVALUE_IMPORT,
METADATA_IMPORT,
- METADATA_EXPORT
+ METADATA_EXPORT,
+ AGGREGATE_QUERY_BUILDER
}
=== 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-25 07:02:35 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/scheduling/CaseAggregateConditionTask.java 2013-03-29 04:26:45 +0000
@@ -33,6 +33,7 @@
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 static org.hisp.dhis.system.notification.NotificationLevel.INFO;
import java.util.Calendar;
import java.util.Collection;
@@ -51,7 +52,11 @@
import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.program.ProgramStageInstanceService;
+import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.notification.Notifier;
+import org.hisp.dhis.system.util.Clock;
+import org.hisp.dhis.system.util.SystemUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
@@ -80,7 +85,21 @@
private ProgramStageInstanceService programStageInstanceService;
private OrganisationUnitService organisationUnitService;
-
+
+ private Notifier notifier;
+
+ public void setNotifier( Notifier notifier )
+ {
+ this.notifier = notifier;
+ }
+
+ private TaskId taskId;
+
+ public void setTaskId( TaskId taskId )
+ {
+ this.taskId = taskId;
+ }
+
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
@@ -88,7 +107,7 @@
public CaseAggregateConditionTask( CaseAggregationConditionService aggregationConditionService,
DataValueService dataValueService, JdbcTemplate jdbcTemplate, DataElementService dataElementService,
DataElementCategoryService categoryService, SystemSettingManager systemSettingManager,
- ProgramStageInstanceService programStageInstanceService, OrganisationUnitService organisationUnitService )
+ ProgramStageInstanceService programStageInstanceService, OrganisationUnitService organisationUnitService, Notifier notifier )
{
this.aggregationConditionService = aggregationConditionService;
this.dataValueService = dataValueService;
@@ -98,6 +117,7 @@
this.systemSettingManager = systemSettingManager;
this.programStageInstanceService = programStageInstanceService;
this.organisationUnitService = organisationUnitService;
+ this.notifier = notifier;
}
// -------------------------------------------------------------------------
@@ -107,10 +127,14 @@
@Override
public void run()
{
+ final int cpuCores = SystemUtils.getCpuCores();
+ Clock clock = new Clock().startClock().logTime( "Aggregate process started, number of CPU cores: " + cpuCores + ", " + SystemUtils.getMemoryString() );
+ notifier.clear( taskId ).notify( taskId, "Aggregate process started" );
+
String taskStrategy = (String) systemSettingManager.getSystemSetting(
KEY_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY, DEFAULT_SCHEDULE_AGGREGATE_QUERY_BUILDER_TASK_STRATEGY );
- String datasetSQL = "select dm.datasetid as datasetid, pt.name as periodname";
+ String datasetSQL = "select dm.datasetid as datasetid, pt.name as periodname, ds.name as datasetname";
datasetSQL += " from caseaggregationcondition cagg inner join datasetmembers dm ";
datasetSQL += " on cagg.aggregationdataelementid=dm.dataelementid inner join dataset ds ";
datasetSQL += " on ds.datasetid = dm.datasetid inner join periodtype pt ";
@@ -120,7 +144,8 @@
while ( rsDataset.next() )
{
int datasetId = rsDataset.getInt( "datasetid" );
-
+ String datasetName = rsDataset.getString( "datasetname" );
+
Collection<Period> periods = getPeriod( rsDataset.getString( "periodname" ), taskStrategy );
for ( Period period : periods )
@@ -201,10 +226,13 @@
dataValueService.deleteDataValue( dataValue );
}
}
-
}
+
}
+ clock.logTime( "Improrted aggregate data completed for data set " + datasetName );
+ notifier.notify( taskId, "Improrted aggregate data completed for data set " + datasetName );
}
+ notifier.notify( taskId, INFO, "Improrted aggregate data completed", true );
}
// -------------------------------------------------------------------------
=== 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-25 04:56:23 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2013-03-29 04:26:45 +0000
@@ -489,6 +489,7 @@
<constructor-arg ref="org.hisp.dhis.dataelement.DataElementService" />
<constructor-arg ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
<constructor-arg ref="org.hisp.dhis.setting.SystemSettingManager" />
+ <constructor-arg ref="notifier" />
</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/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-03-09 15:25:42 +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-29 04:26:45 +0000
@@ -33,8 +33,16 @@
import java.util.Map;
import org.hisp.dhis.patient.scheduling.CaseAggregateConditionSchedulingManager;
+import org.hisp.dhis.patient.scheduling.CaseAggregateConditionTask;
+import org.hisp.dhis.scheduling.DataMartTask;
+import org.hisp.dhis.scheduling.ScheduledTasks;
+import org.hisp.dhis.scheduling.TaskCategory;
+import org.hisp.dhis.scheduling.TaskId;
import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.notification.Notifier;
import org.hisp.dhis.system.scheduling.Scheduler;
+import org.hisp.dhis.user.CurrentUserService;
+import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -57,6 +65,13 @@
this.schedulingManager = schedulingManager;
}
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
private SystemSettingManager systemSettingManager;
public void setSystemSettingManager( SystemSettingManager systemSettingManager )
@@ -100,6 +115,20 @@
this.taskStrategy = taskStrategy;
}
+ private CaseAggregateConditionTask aggregateConditionTask;
+
+ public void setAggregateConditionTask( CaseAggregateConditionTask aggregateConditionTask )
+ {
+ this.aggregateConditionTask = aggregateConditionTask;
+ }
+
+ private Notifier notifier;
+
+ public void setNotifier( Notifier notifier )
+ {
+ this.notifier = notifier;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -108,6 +137,10 @@
public String execute()
throws Exception
{
+ TaskId taskId = new TaskId( TaskCategory.AGGREGATE_QUERY_BUILDER, currentUserService.getCurrentUser() );
+ notifier.clear( taskId );
+ aggregateConditionTask.setTaskId( taskId );
+
if ( execute )
{
schedulingManager.executeTasks();
@@ -122,7 +155,7 @@
{
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-09 15:25:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2013-03-29 04:26:45 +0000
@@ -1047,6 +1047,11 @@
<property name="systemSettingManager">
<ref bean="org.hisp.dhis.setting.SystemSettingManager" />
</property>
+ <property name="currentUserService">
+ <ref bean="org.hisp.dhis.user.CurrentUserService" />
+ </property>
+ <property name="notifier" ref="notifier" />
+ <property name="aggregateConditionTask" ref="aggregateQueryBuilder"/>
</bean>
</beans>
\ No newline at end of file