=== 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 @@
-
-
-
-
-
-
-
-
-
-
-
'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> futures = new HashMap>();
+
+ // -------------------------------------------------------------------------
+ // 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 @@
+
+
+
+
+
=== 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 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
=== 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 @@
/dhis-web-datamart/responseInput.vm
-
-
-
- /main.vm
- /dhis-web-datamart/viewScheduledExport.vm
- /dhis-web-datamart/menu.vm
-
-
-
- getScheduledExportStatus.action
- F_DATAMART_ADMIN
-
-
-
- getScheduledExportStatus.action
- F_DATAMART_ADMIN
-
-
=== 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 @@