dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #10213
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2811: Impl generic task scheduler which replaces the DataMartScheduler. More tasks to come.
------------------------------------------------------------
revno: 2811
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-02-03 17:35:12 +0100
message:
Impl generic task scheduler which replaces the DataMartScheduler. More tasks to come.
removed:
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/SpringDataMartScheduler.java
dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/ExecuteExportAction.java
dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/ScheduleExportAction.java
dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/viewScheduledExport.vm
added:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/scheduling/
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/scheduling/action/
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/scheduling/action/ScheduleTasksAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewScheduledTasks.vm
renamed:
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/DataMartTask.java => dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java
modified:
dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-datamart/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-datamart/src/main/resources/org/hisp/dhis/datamart/i18n_module.properties
dhis-2/dhis-web/dhis-web-datamart/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/index.vm
dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/menu.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.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
=== removed directory 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task'
=== removed 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-20 07:45:51 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/SpringDataMartScheduler.java 1970-01-01 00:00:00 +0000
@@ -1,137 +0,0 @@
-package org.hisp.dhis.datamart.task;
-
-/*
- * Copyright (c) 2004-2010, 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.
- */
-
-import java.util.concurrent.ScheduledFuture;
-
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.datamart.DataMartScheduler;
-import org.hisp.dhis.datamart.DataMartService;
-import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.springframework.core.task.TaskExecutor;
-import org.springframework.scheduling.TaskScheduler;
-import org.springframework.scheduling.support.CronTrigger;
-
-/**
- * @author Lars Helge Overland
- */
-public class SpringDataMartScheduler
- implements DataMartScheduler
-{
- private ScheduledFuture<?> scheduledFuture = null; // Gives class state but no better way to handle this?
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataMartService dataMartService;
-
- public void setDataMartService( DataMartService dataMartService )
- {
- this.dataMartService = dataMartService;
- }
-
- private TaskScheduler taskScheduler;
-
- public void setTaskScheduler( TaskScheduler taskScheduler )
- {
- this.taskScheduler = taskScheduler;
- }
-
- private TaskExecutor taskExecutor;
-
- public void setTaskExecutor( TaskExecutor taskExecutor )
- {
- this.taskExecutor = taskExecutor;
- }
-
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
- private IndicatorService indicatorService;
-
- public void setIndicatorService( IndicatorService indicatorService )
- {
- this.indicatorService = indicatorService;
- }
-
- private OrganisationUnitService organisationUnitService;
-
- public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
- {
- this.organisationUnitService = organisationUnitService;
- }
-
- // -------------------------------------------------------------------------
- // DataMartSceduler implementation
- // -------------------------------------------------------------------------
-
- public void executeDataMartExport()
- {
- DataMartTask task = new DataMartTask( dataMartService, dataElementService, indicatorService, organisationUnitService );
-
- taskExecutor.execute( task );
- }
-
- public void scheduleDataMartExport()
- {
- DataMartTask task = new DataMartTask( dataMartService, dataElementService, indicatorService, organisationUnitService );
-
- scheduledFuture = taskScheduler.schedule( task, new CronTrigger( CRON_NIGHTLY ) );
- }
-
- public boolean stopDataMartExport()
- {
- return scheduledFuture != null ? scheduledFuture.cancel( true ) : false;
- }
-
- public String getDataMartExportStatus()
- {
- if ( scheduledFuture == null )
- {
- return STATUS_NOT_STARTED;
- }
- else if ( scheduledFuture.isCancelled() )
- {
- return STATUS_STOPPED;
- }
- else if ( scheduledFuture.isDone() )
- {
- return STATUS_DONE;
- }
- else
- {
- return STATUS_RUNNING;
- }
- }
-}
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml 2011-01-20 07:45:51 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml 2011-02-03 16:35:12 +0000
@@ -191,24 +191,6 @@
<property name="batchHandlerFactory" ref="batchHandlerFactory"/>
</bean>
- <!-- Scheduler -->
-
- <bean id="org.hisp.dhis.datamart.DataMartScheduler"
- class="org.hisp.dhis.datamart.task.SpringDataMartScheduler">
- <property name="dataMartService"
- ref="org.hisp.dhis.datamart.DataMartService"/>
- <property name="taskScheduler"
- ref="taskScheduler"/>
- <property name="taskExecutor"
- ref="taskScheduler"/>
- <property name="dataElementService"
- ref="org.hisp.dhis.dataelement.DataElementService"/>
- <property name="indicatorService"
- ref="org.hisp.dhis.indicator.IndicatorService"/>
- <property name="organisationUnitService"
- ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
- </bean>
-
<!-- DeletionHandler -->
<bean id="org.hisp.dhis.datamart.DataMartExportDeletionHandler"
=== added directory 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling'
=== renamed file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/DataMartTask.java' => 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/task/DataMartTask.java 2011-01-21 12:44:09 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/DataMartTask.java 2011-02-03 16:35:12 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.datamart.task;
+package org.hisp.dhis.system.scheduling;
/*
* Copyright (c) 2004-2010, University of Oslo
=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java 2011-02-03 16:35:12 +0000
@@ -0,0 +1,23 @@
+package org.hisp.dhis.system.scheduling;
+
+public interface Scheduler
+{
+ final String CRON_NIGHTLY_1AM = "0 0 1 * * ?";
+ final String CRON_NIGHTLY_2AM = "0 0 2 * * ?";
+ final String CRON_NIGHTLY_3AM = "0 0 3 * * ?";
+ final String CRON_NIGHTLY_4AM = "0 0 4 * * ?";
+ final String CRON_TEST = "0 * * * * ?";
+
+ final String STATUS_RUNNING = "running";
+ final String STATUS_DONE = "done";
+ final String STATUS_STOPPED = "stopped";
+ final String STATUS_NOT_STARTED = "not_started";
+
+ void executeTask( Runnable task );
+
+ boolean scheduleTask( Runnable task, String cronExpr );
+
+ boolean stopTask( Class<? extends Runnable> taskClass );
+
+ String getTaskStatus( Class<? extends Runnable> taskClass );
+}
=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/SpringScheduler.java 2011-02-03 16:35:12 +0000
@@ -0,0 +1,138 @@
+package org.hisp.dhis.system.scheduling;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ScheduledFuture;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.task.TaskExecutor;
+import org.springframework.scheduling.TaskScheduler;
+import org.springframework.scheduling.support.CronTrigger;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class SpringScheduler
+ implements Scheduler
+{
+ private static final Log log = LogFactory.getLog( SpringScheduler.class );
+
+ private Map<String, ScheduledFuture<?>> futures = new HashMap<String, ScheduledFuture<?>>();
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private TaskScheduler taskScheduler;
+
+ public void setTaskScheduler( TaskScheduler taskScheduler )
+ {
+ this.taskScheduler = taskScheduler;
+ }
+
+ private TaskExecutor taskExecutor;
+
+ public void setTaskExecutor( TaskExecutor taskExecutor )
+ {
+ this.taskExecutor = taskExecutor;
+ }
+
+ // -------------------------------------------------------------------------
+ // Sceduler implementation
+ // -------------------------------------------------------------------------
+
+ public void executeTask( Runnable task )
+ {
+ taskExecutor.execute( task );
+ }
+
+ public boolean scheduleTask( Runnable task, String cronExpr )
+ {
+ String key = task != null ? task.getClass().getName() : null;
+
+ if ( key != null && !futures.containsKey( key ) )
+ {
+ ScheduledFuture<?> future = taskScheduler.schedule( task, new CronTrigger( cronExpr ) );
+
+ futures.put( key, future );
+
+ log.info( "Sceduled task of type: " + key );
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean stopTask( Class<? extends Runnable> taskClass )
+ {
+ String key = taskClass != null ? taskClass.getName() : null;
+
+ if ( key != null )
+ {
+ ScheduledFuture<?> future = futures.get( key );
+
+ boolean result = future != null ? future.cancel( true ) : false;
+
+ futures.remove( key );
+
+ log.info( "Stopped task of type: " + taskClass.getName() );
+
+ return result;
+ }
+
+ return false;
+ }
+
+ public String getTaskStatus( Class<? extends Runnable> taskClass )
+ {
+ String key = taskClass != null ? taskClass.getName() : null;
+
+ ScheduledFuture<?> future = futures.get( key );
+
+ if ( future == null )
+ {
+ return STATUS_NOT_STARTED;
+ }
+ else if ( future.isCancelled() )
+ {
+ return STATUS_STOPPED;
+ }
+ else if ( future.isDone() )
+ {
+ return STATUS_DONE;
+ }
+ else
+ {
+ return STATUS_RUNNING;
+ }
+ }
+}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml 2011-01-07 16:43:23 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/META-INF/dhis/beans.xml 2011-02-03 16:35:12 +0000
@@ -22,4 +22,9 @@
<property name="poolSize" value="10"/>
</bean>
+ <bean id="scheduler" class="org.hisp.dhis.system.scheduling.SpringScheduler">
+ <property name="taskScheduler" ref="taskScheduler"/>
+ <property name="taskExecutor" ref="taskScheduler"/>
+ </bean>
+
</beans>
=== removed file 'dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/ExecuteExportAction.java'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/ExecuteExportAction.java 2011-01-20 07:45:51 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/ExecuteExportAction.java 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
-package org.hisp.dhis.datamart.action;
-
-import org.hisp.dhis.datamart.DataMartScheduler;
-
-import com.opensymphony.xwork2.Action;
-
-public class ExecuteExportAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataMartScheduler dataMartScheduler;
-
- public void setDataMartScheduler( DataMartScheduler dataMartScheduler )
- {
- this.dataMartScheduler = dataMartScheduler;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- @Override
- public String execute()
- {
- dataMartScheduler.executeDataMartExport();
-
- return SUCCESS;
- }
-}
=== removed file 'dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/ScheduleExportAction.java'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/ScheduleExportAction.java 2011-01-11 13:11:31 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/ScheduleExportAction.java 1970-01-01 00:00:00 +0000
@@ -1,71 +0,0 @@
-package org.hisp.dhis.datamart.action;
-
-/*
- * Copyright (c) 2004-2010, 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.
- */
-
-import static org.hisp.dhis.datamart.DataMartScheduler.STATUS_RUNNING;
-
-import org.hisp.dhis.datamart.DataMartScheduler;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Lars Helge Overland
- */
-public class ScheduleExportAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataMartScheduler dataMartScheduler;
-
- public void setDataMartScheduler( DataMartScheduler dataMartScheduler )
- {
- this.dataMartScheduler = dataMartScheduler;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- @Override
- public String execute()
- {
- if ( dataMartScheduler.getDataMartExportStatus().equals( STATUS_RUNNING ) )
- {
- dataMartScheduler.stopDataMartExport();
- }
- else
- {
- dataMartScheduler.scheduleDataMartExport();
- }
-
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/resources/META-INF/dhis/beans.xml 2011-01-21 16:22:50 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/resources/META-INF/dhis/beans.xml 2011-02-03 16:35:12 +0000
@@ -88,28 +88,5 @@
<property name="dataMartService"
ref="org.hisp.dhis.datamart.DataMartService"/>
</bean>
-
- <!-- Schedule -->
-
- <bean id="org.hisp.dhis.datamart.action.GetScheduledExportStatusAction"
- class="org.hisp.dhis.datamart.action.GetScheduledExportStatusAction"
- scope="prototype">
- <property name="dataMartScheduler"
- ref="org.hisp.dhis.datamart.DataMartScheduler"/>
- </bean>
-
- <bean id="org.hisp.dhis.datamart.action.ScheduleExportAction"
- class="org.hisp.dhis.datamart.action.ScheduleExportAction"
- scope="prototype">
- <property name="dataMartScheduler"
- ref="org.hisp.dhis.datamart.DataMartScheduler"/>
- </bean>
-
- <bean id="org.hisp.dhis.datamart.action.ExecuteExportAction"
- class="org.hisp.dhis.datamart.action.ExecuteExportAction"
- scope="prototype">
- <property name="dataMartScheduler"
- ref="org.hisp.dhis.datamart.DataMartScheduler"/>
- </bean>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/resources/org/hisp/dhis/datamart/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/resources/org/hisp/dhis/datamart/i18n_module.properties 2011-01-11 16:52:46 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/resources/org/hisp/dhis/datamart/i18n_module.properties 2011-02-03 16:35:12 +0000
@@ -74,17 +74,9 @@
last_year = Last year
prev = Prev
next = Next
-scheduled_export_is = Scheduled export is
-running = running
-done = done
-stopped = stopped
-not_started = not started
-refresh = Refresh
-data_mart_export = Data Mart Export
-data_mart_scheduling = Data Mart Scheduling
-data_mart_scheduling_management = Data mart scheduling management
start = Start
stop = Stop
refresh = Refresh
intro_data_mart_export = Create data mart exports. Data mart exports contains data elements, indicators, organisation units and periods.
-intro_data_mart_scheduling = Set up and manage scheduled data mart exports, which will run at 2 AM every night for periods of this year.
\ No newline at end of file
+intro_data_mart_scheduling = Set up and manage scheduled data mart exports, which will run at 2 AM every night for periods of this year.
+data_mart_export = Data Mart Export
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/resources/struts.xml 2011-01-25 13:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/resources/struts.xml 2011-02-03 16:35:12 +0000
@@ -73,23 +73,5 @@
<result name="input" type="velocity-xml">/dhis-web-datamart/responseInput.vm</result>
</action>
- <!-- Schedule -->
-
- <action name="getScheduledExportStatus" class="org.hisp.dhis.datamart.action.GetScheduledExportStatusAction">
- <result name="success" type="velocity">/main.vm</result>
- <param name="page">/dhis-web-datamart/viewScheduledExport.vm</param>
- <param name="menu">/dhis-web-datamart/menu.vm</param>
- </action>
-
- <action name="scheduleExport" class="org.hisp.dhis.datamart.action.ScheduleExportAction">
- <result name="success" type="redirect">getScheduledExportStatus.action</result>
- <param name="requiredAuthorities">F_DATAMART_ADMIN</param>
- </action>
-
- <action name="executeExport" class="org.hisp.dhis.datamart.action.ExecuteExportAction">
- <result name="success" type="redirect">getScheduledExportStatus.action</result>
- <param name="requiredAuthorities">F_DATAMART_ADMIN</param>
- </action>
-
</package>
</struts>
=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/index.vm'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/index.vm 2011-01-11 16:52:46 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/index.vm 2011-02-03 16:35:12 +0000
@@ -3,5 +3,4 @@
<ul id="introList">
#introListImgItem( "getDataMartExports.action" "data_mart_export" "data_mart_export" )
- #introListImgItem( "getScheduledExportStatus.action" "data_mart_scheduling" "scheduling" )
</ul>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/menu.vm'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/menu.vm 2011-01-11 13:11:31 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/menu.vm 2011-02-03 16:35:12 +0000
@@ -1,6 +1,5 @@
<h2>$i18n.getString( "datamart" ) </h2>
<ul>
- <li><a href="getDataMartExports.action">$i18n.getString( "data_mart_export" ) </a></li>
- <li><a href="getScheduledExportStatus.action">$i18n.getString( "data_mart_scheduling" ) </a></li>
+ <li><a href="getDataMartExports.action">$i18n.getString( "data_mart_export" ) </a></li>
</ul>
\ No newline at end of file
=== removed file 'dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/viewScheduledExport.vm'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/viewScheduledExport.vm 2011-01-11 13:11:31 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/webapp/dhis-web-datamart/viewScheduledExport.vm 1970-01-01 00:00:00 +0000
@@ -1,15 +0,0 @@
-
-<h3>$i18n.getString( "data_mart_scheduling_management" )</h3>
-
-<span id="info">$i18n.getString( "scheduled_export_is" ) $!i18n.getString( $status )</span>
-
-<p>
-<input type="button" style="width:140px" onclick="window.location.href='scheduleExport.action'"
-#if ( $running )
-value="$i18n.getString( 'stop' )"
-#else
-value="$i18n.getString( 'start' )"
-#end
->
-<input type="button" style="width:140px" onclick="window.location.href='getScheduledExportStatus.action'" value="$i18n.getString( 'refresh' )">
-</p>
\ No newline at end of file
=== added directory 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/scheduling'
=== added directory 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/scheduling/action'
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/scheduling/action/ScheduleTasksAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/scheduling/action/ScheduleTasksAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/scheduling/action/ScheduleTasksAction.java 2011-02-03 16:35:12 +0000
@@ -0,0 +1,150 @@
+package org.hisp.dhis.reporting.scheduling.action;
+
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.datamart.DataMartService;
+import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.system.scheduling.DataMartTask;
+import org.hisp.dhis.system.scheduling.Scheduler;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class ScheduleTasksAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private Scheduler scheduler;
+
+ public void setScheduler( Scheduler scheduler )
+ {
+ this.scheduler = scheduler;
+ }
+
+ private DataMartService dataMartService;
+
+ public void setDataMartService( DataMartService dataMartService )
+ {
+ this.dataMartService = dataMartService;
+ }
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ private IndicatorService indicatorService;
+
+ public void setIndicatorService( IndicatorService indicatorService )
+ {
+ this.indicatorService = indicatorService;
+ }
+
+ 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 statusOnly = false;
+
+ public void setStatusOnly( boolean statusOnly )
+ {
+ this.statusOnly = statusOnly;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private String status;
+
+ public String getStatus()
+ {
+ return status;
+ }
+
+ private boolean running;
+
+ public boolean isRunning()
+ {
+ return running;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ DataMartTask dataMartTask = new DataMartTask( dataMartService, dataElementService, indicatorService, organisationUnitService );
+
+ if ( !statusOnly )
+ {
+ if ( execute )
+ {
+ scheduler.executeTask( dataMartTask );
+ }
+ else if ( scheduler.getTaskStatus( DataMartTask.class ).equals( Scheduler.STATUS_RUNNING ) )
+ {
+ scheduler.stopTask( DataMartTask.class );
+ }
+ else
+ {
+ scheduler.scheduleTask( dataMartTask, Scheduler.CRON_NIGHTLY_1AM );
+ }
+ }
+
+ status = scheduler.getTaskStatus( DataMartTask.class );
+
+ running = scheduler.getTaskStatus( DataMartTask.class ).equals( Scheduler.STATUS_RUNNING );
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-02-01 11:03:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2011-02-03 16:35:12 +0000
@@ -483,4 +483,20 @@
ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService"/>
</bean>
+ <!-- Scheduling -->
+
+ <bean id="org.hisp.dhis.reporting.scheduling.action.ScheduleTasksAction"
+ class="org.hisp.dhis.reporting.scheduling.action.ScheduleTasksAction"
+ scope="prototype">
+ <property name="scheduler" ref="scheduler"/>
+ <property name="dataMartService"
+ ref="org.hisp.dhis.datamart.DataMartService"/>
+ <property name="dataElementService"
+ ref="org.hisp.dhis.dataelement.DataElementService"/>
+ <property name="indicatorService"
+ ref="org.hisp.dhis.indicator.IndicatorService"/>
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
+ </bean>
+
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-01-31 19:47:04 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/org/hisp/dhis/reporting/i18n_module.properties 2011-02-03 16:35:12 +0000
@@ -310,4 +310,15 @@
get_report_as_jasper = Download as Jasper
get_report_as_jrxml = Download as JRXML
user_organisation_unit = Include current user organisation unit
-select_category_combo = Select category combination
\ No newline at end of file
+select_category_combo = Select category combination
+scheduled_export_is = Scheduled export is
+running = running
+done = done
+stopped = stopped
+not_started = not started
+scheduling = Scheduling
+scheduling_management = Scheduling management
+scheduling_is = Scheduling is
+start = Start
+stop = Stop
+refresh = Refresh
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2011-02-01 11:03:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2011-02-03 16:35:12 +0000
@@ -364,5 +364,22 @@
<result name="success" type="chart"></result>
</action>
+ <!-- Scheduling -->
+
+ <action name="viewScheduledTasks" class="org.hisp.dhis.reporting.scheduling.action.ScheduleTasksAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-reporting/viewScheduledTasks.vm</param>
+ <param name="menu">/dhis-web-reporting/menu.vm</param>
+ <param name="statusOnly">true</param>
+ <param name="requiredAuthorities">F_SCHEDULING_ADMIN</param>
+ </action>
+
+ <action name="scheduleTasks" class="org.hisp.dhis.reporting.scheduling.action.ScheduleTasksAction">
+ <result name="success" type="velocity">/main.vm</result>
+ <param name="page">/dhis-web-reporting/viewScheduledTasks.vm</param>
+ <param name="menu">/dhis-web-reporting/menu.vm</param>
+ <param name="requiredAuthorities">F_SCHEDULING_ADMIN</param>
+ </action>
+
</package>
</struts>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm 2011-02-01 11:03:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/menu.vm 2011-02-03 16:35:12 +0000
@@ -19,3 +19,8 @@
<ul>
<li><a href="displayPivotTableForm.action">$i18n.getString( "pivot_table" ) </a></li>
</ul>
+
+<h2>$i18n.getString( "scheduling" ) </h2>
+<ul>
+ <li><a href="viewScheduledTasks.action">$i18n.getString( "scheduling" )</a></li>
+</ul>
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewScheduledTasks.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewScheduledTasks.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewScheduledTasks.vm 2011-02-03 16:35:12 +0000
@@ -0,0 +1,15 @@
+
+<h3>$i18n.getString( "scheduling_management" )</h3>
+
+<span id="info">$i18n.getString( "scheduling_is" ) $!i18n.getString( $!status )</span>
+
+<p>
+<input type="button" style="width:140px" onclick="window.location.href='scheduleTasks.action'"
+#if ( $running )
+value="$i18n.getString( 'stop' )"
+#else
+value="$i18n.getString( 'start' )"
+#end
+>
+<input type="button" style="width:140px" onclick="window.location.href='viewScheduledTasks.action'" value="$i18n.getString( 'refresh' )">
+</p>
\ No newline at end of file