=== 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 taskClass ); + + String getTaskStatus( Class 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 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 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 @@ \ 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 @@

$i18n.getString( "datamart" )

\ 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 @@ - -

$i18n.getString( "data_mart_scheduling_management" )

- -$i18n.getString( "scheduled_export_is" ) $!i18n.getString( $status ) - -

- - -

\ 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"/> + + + + + + + + + + === 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 @@ + + + + /main.vm + /dhis-web-reporting/viewScheduledTasks.vm + /dhis-web-reporting/menu.vm + true + F_SCHEDULING_ADMIN + + + + /main.vm + /dhis-web-reporting/viewScheduledTasks.vm + /dhis-web-reporting/menu.vm + F_SCHEDULING_ADMIN + + === 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 @@ + +

$i18n.getString( "scheduling" ) 

+ \ 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 @@ + +

$i18n.getString( "scheduling_management" )

+ +$i18n.getString( "scheduling_is" ) $!i18n.getString( $!status ) + +

+ + +

\ No newline at end of file