← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2635: Fixed potential issue with datamart scheduling

 

------------------------------------------------------------
revno: 2635
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-01-19 12:53:21 +0100
message:
  Fixed potential issue with datamart scheduling
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/DataMartScheduler.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/DataMartTask.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/SpringDataMartScheduler.java


--
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-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/DataMartScheduler.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/DataMartScheduler.java	2011-01-11 13:11:31 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/DataMartScheduler.java	2011-01-19 11:53:21 +0000
@@ -33,6 +33,7 @@
 public interface DataMartScheduler
 {
     final String CRON_NIGHTLY = "0 0 2 * * ?";
+    final String CRON_TEST = "0 * * * * ?";
     
     final String STATUS_RUNNING = "running";
     final String STATUS_DONE = "done";

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/DataMartTask.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/DataMartTask.java	2011-01-11 13:11:31 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/DataMartTask.java	2011-01-19 11:53:21 +0000
@@ -30,8 +30,17 @@
 import java.util.Collection;
 import java.util.HashSet;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.datamart.DataMartService;
+import org.hisp.dhis.indicator.Indicator;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.RelativePeriods;
+import org.hisp.dhis.system.util.ConversionUtils;
 
 /**
  * @author Lars Helge Overland
@@ -39,26 +48,36 @@
 public class DataMartTask
     implements Runnable
 {
+    private static final Log log = LogFactory.getLog( DataMartTask.class );
+    
     private DataMartService dataMartService;
  
-    private Collection<Integer> dataElementIds;
-    private Collection<Integer> indicatorIds;
-    private Collection<Integer> organisationUnitIds;
-    private RelativePeriods relatives;
-    
-    public DataMartTask( DataMartService dataMartService, Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
-        Collection<Integer> organisationUnitIds, RelativePeriods relatives )
+    private DataElementService dataElementService;
+    
+    private IndicatorService indicatorService;
+    
+    private OrganisationUnitService organisationUnitService;
+        
+    public DataMartTask( DataMartService dataMartService, DataElementService dataElementService, IndicatorService indicatorService,
+        OrganisationUnitService organisationUnitService )
     {
         this.dataMartService = dataMartService;
-        this.dataElementIds = dataElementIds;
-        this.indicatorIds = indicatorIds;
-        this.organisationUnitIds = organisationUnitIds;
-        this.relatives = relatives;
+        this.dataElementService = dataElementService;
+        this.indicatorService = indicatorService;
+        this.organisationUnitService = organisationUnitService;
     }
     
     @Override
     public void run()
     {
+        Collection<Integer> dataElementIds = ConversionUtils.getIdentifiers( DataElement.class, dataElementService.getAllDataElements() );
+        Collection<Integer> indicatorIds = ConversionUtils.getIdentifiers( Indicator.class, indicatorService.getAllIndicators() );
+        Collection<Integer> organisationUnitIds = ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnitService.getAllOrganisationUnits() );
+        
+        RelativePeriods relatives = new RelativePeriods( false, true, true, true, false, false, false );
+        
+        log.info( "Starting scheduled data mart task" );
+        
         dataMartService.export( dataElementIds, indicatorIds, new HashSet<Integer>(), organisationUnitIds, relatives );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/SpringDataMartScheduler.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/SpringDataMartScheduler.java	2011-01-11 13:11:31 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/SpringDataMartScheduler.java	2011-01-19 11:53:21 +0000
@@ -27,19 +27,13 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
 import java.util.concurrent.ScheduledFuture;
 
-import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.datamart.DataMartScheduler;
 import org.hisp.dhis.datamart.DataMartService;
-import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.system.util.ConversionUtils;
 import org.springframework.scheduling.TaskScheduler;
 import org.springframework.scheduling.support.CronTrigger;
 
@@ -96,13 +90,7 @@
 
     public void scheduleDataMartExport()
     {
-        Collection<Integer> dataElementIds = ConversionUtils.getIdentifiers( DataElement.class, dataElementService.getAllDataElements() );
-        Collection<Integer> indicatorIds = ConversionUtils.getIdentifiers( Indicator.class, indicatorService.getAllIndicators() );
-        Collection<Integer> organisationUnitIds = ConversionUtils.getIdentifiers( OrganisationUnit.class, organisationUnitService.getAllOrganisationUnits() );
-        
-        RelativePeriods relatives = new RelativePeriods( false, true, true, true, false, false, false );
-        
-        DataMartTask task = new DataMartTask( dataMartService, dataElementIds, indicatorIds, organisationUnitIds, relatives );
+        DataMartTask task = new DataMartTask( dataMartService, dataElementService, indicatorService, organisationUnitService );
         
         scheduledFuture = taskScheduler.schedule( task, new CronTrigger( CRON_NIGHTLY ) );        
     }