------------------------------------------------------------ revno: 9969 committer: Lars Helge Ă˜verland <larshe...@gmail.com> branch nick: dhis2 timestamp: Mon 2013-03-04 21:41:25 +0100 message: Impl UI for scheduling of resource tables, analytics tables and data mart tasks added: dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/scheduling/SchedulingManagerTest.java modified: dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/ScheduledTasks.java dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm
-- 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-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java 2012-02-02 20:01:36 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/DefaultSchedulingManager.java 2013-03-04 20:41:25 +0000 @@ -33,6 +33,7 @@ import java.util.HashMap; import java.util.Map; +import org.hisp.dhis.common.ListMap; import org.hisp.dhis.setting.SystemSettingManager; import org.hisp.dhis.system.scheduling.Scheduler; @@ -72,17 +73,16 @@ // ------------------------------------------------------------------------- public void scheduleTasks() - { - Map<String, String> keyCronMap = getScheduledTasks(); + { + ListMap<String, String> cronKeyMap = getCronKeyMap(); - for ( String key : keyCronMap.keySet() ) + for ( String cron : cronKeyMap.keySet() ) { - String cron = keyCronMap.get( key ); - Runnable task = tasks.get( key ); + ScheduledTasks scheduledTasks = getScheduledTasksForCron( cron, cronKeyMap ); - if ( cron != null && task != null ) + if ( !scheduledTasks.isEmpty() ) { - scheduler.scheduleTask( key, task, cron ); + scheduler.scheduleTask( cron, scheduledTasks, cron ); } } } @@ -103,34 +103,82 @@ public void executeTasks() { - Map<String, String> keyCronMap = getScheduledTasks(); + ListMap<String, String> cronKeyMap = getCronKeyMap(); - for ( String key : keyCronMap.keySet() ) + for ( String cron : cronKeyMap.keySet() ) { - Runnable task = tasks.get( key ); + ScheduledTasks scheduledTasks = getScheduledTasksForCron( cron, cronKeyMap ); - if ( task != null ) + if ( !scheduledTasks.isEmpty() ) { - scheduler.executeTask( task ); + scheduler.executeTask( scheduledTasks ); } } } + + public ListMap<String, String> getCronKeyMap() + { + Map<String, String> keyCronMap = getKeyCronMap(); + + ListMap<String, String> cronKeyMap = new ListMap<String, String>(); + + for ( String key : keyCronMap.keySet() ) + { + String cron = keyCronMap.get( key ); + + cronKeyMap.putValue( cron, key ); + } + + return cronKeyMap; + } + + public boolean isScheduled( String key ) + { + Map<String, String> keyCronMap = getKeyCronMap(); + + return keyCronMap.get( key ) != null; + } + public String getTaskStatus() + { + ListMap<String, String> cronKeyMap = getCronKeyMap(); + + if ( cronKeyMap.size() == 0 ) + { + return STATUS_NOT_STARTED; + } + + String firstTask = cronKeyMap.keySet().iterator().next(); + + return scheduler.getTaskStatus( firstTask ); + } + + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + + /** + * Returns a ScheduledTasks object for the given cron expression. The + * ScheduledTasks object contains a list of tasks. + */ + private ScheduledTasks getScheduledTasksForCron( String cron, ListMap<String, String> cronKeyMap ) + { + ScheduledTasks scheduledTasks = new ScheduledTasks(); + + for ( String key : cronKeyMap.get( cron ) ) + { + scheduledTasks.addTask( tasks.get( key ) ); + } + + return scheduledTasks; + } + + /** + * Returns a mapping between task keys and cron expressions. + */ @SuppressWarnings("unchecked") - public Map<String, String> getScheduledTasks() + private Map<String, String> getKeyCronMap() { return (Map<String, String>) systemSettingManager.getSystemSetting( KEY_SCHEDULED_TASKS, new HashMap<String, String>() ); } - - public String getTaskStatus() - { - Map<String, String> keyCronMap = getScheduledTasks(); - - if ( keyCronMap.size() == 0 ) - { - return STATUS_NOT_STARTED; - } - - return scheduler.getTaskStatus( keyCronMap.keySet().iterator().next() ); - } } === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/ScheduledTasks.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/ScheduledTasks.java 2013-03-04 14:44:15 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/ScheduledTasks.java 2013-03-04 20:41:25 +0000 @@ -40,7 +40,15 @@ public void addTask( Runnable task ) { - this.tasks.add( task ); + if ( task != null ) + { + this.tasks.add( task ); + } + } + + public boolean isEmpty() + { + return tasks == null || tasks.size() == 0; } @Override === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java 2013-03-04 14:44:15 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/scheduling/SchedulingManager.java 2013-03-04 20:41:25 +0000 @@ -29,6 +29,8 @@ import java.util.Map; +import org.hisp.dhis.common.ListMap; + /** * @author Lars Helge Overland */ @@ -36,20 +38,46 @@ { final String TASK_RESOURCE_TABLE = "resourceTableTask"; final String TASK_DATAMART_LAST_12_MONTHS = "dataMartLast12MonthsTask"; - final String TASK_DATAMART_LAST_6_MONTS = "dataMartLast6MonthsTask"; + final String TASK_DATAMART_LAST_6_MONTHS = "dataMartLast6MonthsTask"; final String TASK_DATAMART_FROM_6_TO_12_MONTS = "dataMartFrom6To12MonthsTask"; final String TASK_ANALYTICS_ALL = "analyticsAllTask"; final String TASK_ANALYTICS_LAST_3_YEARS = "analyticsLast3YearsTask"; + /** + * Schedule all tasks. + */ void scheduleTasks(); + /** + * Schedule the given tasks. + * + * @param keyCronMap map of tasks to be scheduled. The map key is the key of + * the task, i.e. the task bean identifier. The map value is the cron + * expression to use when scheduling the task. + */ void scheduleTasks( Map<String, String> keyCronMap ); + /** + * Stop all tasks. + */ void stopTasks(); + /** + * Execute all tasks immediately. + */ void executeTasks(); - Map<String, String> getScheduledTasks(); - + /** + * Get a mapping of cron expressions and list of task keys for all scheduled + * tasks. + */ + ListMap<String, String> getCronKeyMap(); + + boolean isScheduled( String key ); + + /** + * Gets the task status. Can be STATUS_RUNNING, STATUS_DONE, STATUS_STOPPED, + * STATUS_NOT_STARTED. + */ String getTaskStatus(); } === added file 'dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/scheduling/SchedulingManagerTest.java' --- dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/scheduling/SchedulingManagerTest.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/test/java/org/hisp/dhis/scheduling/SchedulingManagerTest.java 2013-03-04 20:41:25 +0000 @@ -0,0 +1,108 @@ +package org.hisp.dhis.scheduling; + +/* + * Copyright (c) 2004-2012, 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.scheduling.SchedulingManager.TASK_ANALYTICS_ALL; +import static org.hisp.dhis.scheduling.SchedulingManager.TASK_DATAMART_LAST_6_MONTHS; +import static org.hisp.dhis.scheduling.SchedulingManager.TASK_RESOURCE_TABLE; +import static org.hisp.dhis.system.scheduling.Scheduler.CRON_DAILY_0AM; +import static org.hisp.dhis.system.scheduling.Scheduler.CRON_DAILY_0AM_EXCEPT_SUNDAY; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; + +import org.hisp.dhis.DhisSpringTest; +import org.hisp.dhis.common.ListMap; +import org.hisp.dhis.system.scheduling.Scheduler; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @author Lars Helge Overland + */ +public class SchedulingManagerTest + extends DhisSpringTest +{ + @Autowired + private SchedulingManager schedulingManager; + + @Test + public void testScheduleTasks() + { + Map<String, String> keyCronMap = new HashMap<String, String>(); + keyCronMap.put( TASK_RESOURCE_TABLE, CRON_DAILY_0AM ); + keyCronMap.put( TASK_ANALYTICS_ALL, CRON_DAILY_0AM ); + keyCronMap.put( TASK_DATAMART_LAST_6_MONTHS, CRON_DAILY_0AM_EXCEPT_SUNDAY ); + + schedulingManager.scheduleTasks( keyCronMap ); + + ListMap<String, String> cronKeyMap = schedulingManager.getCronKeyMap(); + + assertEquals( 2, cronKeyMap.size() ); + assertTrue( cronKeyMap.containsKey( CRON_DAILY_0AM ) ); + assertTrue( cronKeyMap.containsKey( CRON_DAILY_0AM_EXCEPT_SUNDAY ) ); + assertEquals( 2, cronKeyMap.get( CRON_DAILY_0AM ).size() ); + assertEquals( 1, cronKeyMap.get( CRON_DAILY_0AM_EXCEPT_SUNDAY ).size() ); + + assertEquals( Scheduler.STATUS_RUNNING, schedulingManager.getTaskStatus() ); + } + + @Test + public void testStopTasks() + { + Map<String, String> keyCronMap = new HashMap<String, String>(); + keyCronMap.put( TASK_RESOURCE_TABLE, CRON_DAILY_0AM ); + keyCronMap.put( TASK_ANALYTICS_ALL, CRON_DAILY_0AM ); + + assertEquals( Scheduler.STATUS_NOT_STARTED, schedulingManager.getTaskStatus() ); + + schedulingManager.scheduleTasks( keyCronMap ); + + assertEquals( Scheduler.STATUS_RUNNING, schedulingManager.getTaskStatus() ); + + schedulingManager.stopTasks(); + + assertEquals( Scheduler.STATUS_NOT_STARTED, schedulingManager.getTaskStatus() ); + } + + @Test + public void testIsScheduled() + { + Map<String, String> keyCronMap = new HashMap<String, String>(); + keyCronMap.put( TASK_RESOURCE_TABLE, CRON_DAILY_0AM ); + keyCronMap.put( TASK_ANALYTICS_ALL, CRON_DAILY_0AM ); + + schedulingManager.scheduleTasks( keyCronMap ); + + assertTrue( schedulingManager.isScheduled( TASK_RESOURCE_TABLE ) ); + assertFalse( schedulingManager.isScheduled( TASK_DATAMART_LAST_6_MONTHS ) ); + } +} === modified 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 2012-03-06 09:27:38 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/scheduling/Scheduler.java 2013-03-04 20:41:25 +0000 @@ -33,7 +33,6 @@ public interface Scheduler { final String CRON_DAILY_0AM = "0 0 0 * * ?"; - final String CRON_DAILY_1AM = "0 0 1 * * ?"; final String CRON_DAILY_0AM_EXCEPT_SUNDAY = "0 0 0 ? * 1-6"; final String CRON_WEEKLY_SUNDAY_0AM = "0 0 0 ? * 0"; final String CRON_TEST = "0 * * * * ?"; @@ -43,13 +42,46 @@ final String STATUS_STOPPED = "stopped"; final String STATUS_NOT_STARTED = "not_started"; + /** + * Execute the given task immediately. + * + * @task the task to execute. + */ void executeTask( Runnable task ); + /** + * Schedule the given task for future execution. The task can be referenced + * later through the given task key. A task cannot be scheduled if another + * task with the same key is already scheduled. The task must be unique for + * the task but can have an arbitrary value. + * + * @param key the task key, cannot be null. + * @param task the task to schedule. + * @param cronExpr the cron expression to use for the task scheduling. + * @return true if the task was scheduled for execution as a result of this + * operation, false if not. + */ boolean scheduleTask( String key, Runnable task, String cronExpr ); + /** + * Deactivates scheduling of the task with the given key. + * + * @param key the task key. + * @return true if the task was deactivated as a result of this operation, + * false if not. + */ boolean stopTask( String key ); + /** + * Deactivates scheduling for all tasks. + */ void stopAllTasks(); + /** + * Gets the status for the task with the given key. + * + * @param key the task key. + * @return the task status. + */ String getTaskStatus( String key ); } === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css 2012-12-04 13:16:24 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css 2013-03-04 20:41:25 +0000 @@ -486,8 +486,15 @@ /* Settings */ /*----------------------------------------------------------------------------*/ +.settingHeader +{ + padding: 6px 2px; + font-size: 12pt; + color: #373737; +} + .settingLabel -{ +{ padding: 2px; font-size: 10pt; } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java 2012-02-02 20:01:36 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/scheduling/ScheduleTasksAction.java 2013-03-04 20:41:25 +0000 @@ -27,21 +27,24 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_ORGUNITGROUPSET_AGG_LEVEL; import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_SCHEDULED_PERIOD_TYPES; import static org.hisp.dhis.setting.SystemSettingManager.KEY_ORGUNITGROUPSET_AGG_LEVEL; -import static org.hisp.dhis.setting.SystemSettingManager.DEFAULT_ORGUNITGROUPSET_AGG_LEVEL; import static org.hisp.dhis.setting.SystemSettingManager.KEY_SCHEDULED_PERIOD_TYPES; +import static org.hisp.dhis.scheduling.SchedulingManager.*; +import static org.hisp.dhis.system.scheduling.Scheduler.*; + import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import org.hisp.dhis.setting.SystemSettingManager; import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.scheduling.SchedulingManager; +import org.hisp.dhis.setting.SystemSettingManager; import org.hisp.dhis.system.scheduling.Scheduler; import com.opensymphony.xwork2.Action; @@ -54,7 +57,9 @@ { private static final String STRATEGY_LAST_12_DAILY = "last12Daily"; private static final String STRATEGY_LAST_6_DAILY_6_TO_12_WEEKLY = "last6Daily6To12Weekly"; - + private static final String STRATEGY_ALL_DAILY = "allDaily"; + private static final String STRATEGY_LAST_3_YEARS_DAILY = "last3YearsDaily"; + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -98,6 +103,30 @@ this.schedule = schedule; } + private String resourceTableStrategy; + + public String getResourceTableStrategy() + { + return resourceTableStrategy; + } + + public void setResourceTableStrategy( String resourceTableStrategy ) + { + this.resourceTableStrategy = resourceTableStrategy; + } + + private String analyticsStrategy; + + public String getAnalyticsStrategy() + { + return analyticsStrategy; + } + + public void setAnalyticsStrategy( String analyticsStrategy ) + { + this.analyticsStrategy = analyticsStrategy; + } + private Set<String> scheduledPeriodTypes = new HashSet<String>(); public Set<String> getScheduledPeriodTypes() @@ -182,15 +211,41 @@ else { Map<String, String> keyCronMap = new HashMap<String, String>(); + + // ------------------------------------------------------------- + // Resource tables + // ------------------------------------------------------------- + + if ( STRATEGY_ALL_DAILY.equals( resourceTableStrategy ) ) + { + keyCronMap.put( TASK_RESOURCE_TABLE, CRON_DAILY_0AM ); + } + + // ------------------------------------------------------------- + // Analytics + // ------------------------------------------------------------- + + if ( STRATEGY_ALL_DAILY.equals( analyticsStrategy ) ) + { + keyCronMap.put( TASK_ANALYTICS_ALL, CRON_DAILY_0AM ); + } + else if ( STRATEGY_LAST_3_YEARS_DAILY.equals( analyticsStrategy ) ) + { + keyCronMap.put( TASK_ANALYTICS_LAST_3_YEARS, CRON_DAILY_0AM ); + } + + // ------------------------------------------------------------- + // Data mart + // ------------------------------------------------------------- if ( STRATEGY_LAST_12_DAILY.equals( dataMartStrategy ) ) { - keyCronMap.put( SchedulingManager.TASK_DATAMART_LAST_12_MONTHS, Scheduler.CRON_DAILY_0AM ); + keyCronMap.put( TASK_DATAMART_LAST_12_MONTHS, CRON_DAILY_0AM ); } else if ( STRATEGY_LAST_6_DAILY_6_TO_12_WEEKLY.equals( dataMartStrategy ) ) { - keyCronMap.put( SchedulingManager.TASK_DATAMART_LAST_6_MONTS, Scheduler.CRON_DAILY_0AM_EXCEPT_SUNDAY ); - keyCronMap.put( SchedulingManager.TASK_DATAMART_FROM_6_TO_12_MONTS, Scheduler.CRON_WEEKLY_SUNDAY_0AM ); + keyCronMap.put( TASK_DATAMART_LAST_6_MONTHS, CRON_DAILY_0AM_EXCEPT_SUNDAY ); + keyCronMap.put( TASK_DATAMART_FROM_6_TO_12_MONTS, CRON_WEEKLY_SUNDAY_0AM ); } schedulingManager.scheduleTasks( keyCronMap ); @@ -198,16 +253,49 @@ } else { - scheduledPeriodTypes = (Set<String>) systemSettingManager.getSystemSetting( KEY_SCHEDULED_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES ); - orgUnitGroupSetAggLevel = (Integer) systemSettingManager.getSystemSetting( KEY_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL ); - dataMartStrategy = schedulingManager.getScheduledTasks().containsKey( SchedulingManager.TASK_DATAMART_LAST_12_MONTHS ) ? - STRATEGY_LAST_12_DAILY : STRATEGY_LAST_6_DAILY_6_TO_12_WEEKLY; + // ----------------------------------------------------------------- + // Resource tables + // ----------------------------------------------------------------- + + if ( schedulingManager.isScheduled( TASK_RESOURCE_TABLE ) ) + { + resourceTableStrategy = STRATEGY_ALL_DAILY; + } + + // ----------------------------------------------------------------- + // Analytics + // ----------------------------------------------------------------- + + if ( schedulingManager.isScheduled( TASK_ANALYTICS_ALL ) ) + { + analyticsStrategy = STRATEGY_ALL_DAILY; + } + else if ( schedulingManager.isScheduled( TASK_ANALYTICS_LAST_3_YEARS ) ) + { + analyticsStrategy = STRATEGY_LAST_3_YEARS_DAILY; + } + + // ----------------------------------------------------------------- + // Data mart + // ----------------------------------------------------------------- + + if ( schedulingManager.isScheduled( TASK_DATAMART_LAST_12_MONTHS ) ) + { + dataMartStrategy = STRATEGY_LAST_12_DAILY; + } + else if ( schedulingManager.isScheduled( TASK_DATAMART_LAST_6_MONTHS ) ) + { + dataMartStrategy = STRATEGY_LAST_6_DAILY_6_TO_12_WEEKLY; + } } - + + scheduledPeriodTypes = (Set<String>) systemSettingManager.getSystemSetting( KEY_SCHEDULED_PERIOD_TYPES, DEFAULT_SCHEDULED_PERIOD_TYPES ); + orgUnitGroupSetAggLevel = (Integer) systemSettingManager.getSystemSetting( KEY_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL ); + status = schedulingManager.getTaskStatus(); - running = Scheduler.STATUS_RUNNING.equals( status ); + running = STATUS_RUNNING.equals( status ); levels = organisationUnitService.getOrganisationUnitLevels(); - + return SUCCESS; } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2012-11-25 20:18:52 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2013-03-04 20:41:25 +0000 @@ -268,10 +268,18 @@ aggregation_period_types=Aggregation period types running=active done=done -datamart_task_strategy=Data mart task strategy +resource_tables=Resource tables +data_mart=Data mart +analytics_tables=Analytics tables +analytics_tables_task_strategy=Analytics tables task strategy +last_3_years_daily=Last 3 years daily +all_daily=All daily +resource_table_task_strategy=Resource tables task strategy +data_mart_task_strategy=Data mart task strategy never=Never last_12_months_daily=Last 12 months daily last_6_months_daily_6_to_12_months_weekly=Last 6 months daily + 6 to 12 months weekly +daily=Daily organisation_unit_group_set_aggregation_level=Organisation unit group set aggregation level aggregated_org_unit_data_values=Aggregated org unit data values aggregated_org_unit_indicator_values=Aggregated org unit indicator values === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm 2013-01-28 06:30:22 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm 2013-03-04 20:41:25 +0000 @@ -8,68 +8,81 @@ <form id="schedulingForm" action="scheduleTasks.action" method="post"> -<table style="width:300px"> -<tr> - <th style="width:100%">$i18n.getString( "aggregation_period_types" )</th> -</tr> -<tr> - <td> - <label for="weekly">$i18n.getString( "Weekly" )</label><input type="checkbox" id="weekly" class="scheduling" name="scheduledPeriodTypes" value="Weekly"#if( $scheduledPeriodTypes.contains( "Weekly" ) ) checked="checked"#end> - <label for="monthly">$i18n.getString( "Monthly" )</label><input type="checkbox" id="monthly" class="scheduling" name="scheduledPeriodTypes" value="Monthly"#if( $scheduledPeriodTypes.contains( "Monthly" ) ) checked="checked"#end> - <label for="biMonthly">$i18n.getString( "BiMonthly" )</label><input type="checkbox" id="biMonthly" class="scheduling" name="scheduledPeriodTypes" value="BiMonthly"#if( $scheduledPeriodTypes.contains( "BiMonthly" ) ) checked="checked"#end> - <label for="quarterly">$i18n.getString( "Quarterly" )</label><input type="checkbox" id="quarterly" class="scheduling" name="scheduledPeriodTypes" value="Quarterly"#if( $scheduledPeriodTypes.contains( "Quarterly" ) ) checked="checked"#end><br><br> - <label for="sixMonthly">$i18n.getString( "SixMonthly" )</label><input type="checkbox" id="sixMonthly" class="scheduling" name="scheduledPeriodTypes" value="SixMonthly"#if( $scheduledPeriodTypes.contains( "SixMonthly" ) ) checked="checked"#end> - <label for="yearly">$i18n.getString( "Yearly" )</label><input type="checkbox" id="yearly" class="scheduling" name="scheduledPeriodTypes" value="Yearly"#if( $scheduledPeriodTypes.contains( "Yearly" ) ) checked="checked"#end> - <label for="financialYearly">$i18n.getString( "financial_yearly" )</label><input type="checkbox" id="financialYearly" class="scheduling" name="scheduledPeriodTypes" value="FinancialJuly"#if( $scheduledPeriodTypes.contains( "FinancialJuly" ) ) checked="checked"#end> - </td> -</tr> -<tr> - <td style="height:10px"></td> -</tr> -<tr> - <th>$i18n.getString( "organisation_unit_group_set_aggregation_level" )</th> -</tr> -<tr> - <td> - <select id="orgUnitGroupSetAggLevel" name="orgUnitGroupSetAggLevel" class="scheduling" style="width:100%"> - <option value="0"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == 0 ) selected="selected"#end>[$i18n.getString( "no_aggregation" )]</option> - #foreach( $level in $levels ) - <option value="$level.level"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == $level.level ) selected="selected"#end>$encoder.htmlEncode( $level.displayName )</option> - #end - </select> - </td> -</tr> -<tr> - <td style="height:10px"></td> -</tr> -<tr> - <th>$i18n.getString( "datamart_task_strategy" )</th> -</tr> -<tr> - <td> - <select id="dataMartStrategy" name="dataMartStrategy" class="scheduling" style="width:100%"> - <option value="never">$i18n.getString( "never" )</option> - <option value="last12Daily"#if( $dataMartStrategy && $dataMartStrategy == "last12Daily" ) selected="selected"#end>$i18n.getString( "last_12_months_daily" )</option> - <option value="last6Daily6To12Weekly"#if( $dataMartStrategy && $dataMartStrategy == "last6Daily6To12Weekly" ) selected="selected"#end>$i18n.getString( "last_6_months_daily_6_to_12_months_weekly" )</option> - </select> - </td> -</tr> -<tr> - <td style="height:10px"></td> -</tr> -<tr> - <td> - <input type="button" style="width:140px" onclick="submitSchedulingForm()" - #if ( $running ) - value="$i18n.getString( 'stop' )" - #else - value="$i18n.getString( 'start' )" - #end - /> - <input type="button" id="executeButton" style="width:140px" onclick="executeTasks()" value="$i18n.getString( 'execute_now' )" /> - </td> -</tr> -</table> +<!-- Resource tables --> + +<div class="settingHeader">$i18n.getString( "resource_tables" )</div> + +<div class="settingLabel">$i18n.getString( "resource_table_task_strategy" )</div> + +<div class="setting"> +<select id="resourceTableStrategy" name="resourceTableStrategy" class="scheduling"> + <option value="never">$i18n.getString( "never" )</option> + <option value="allDaily"#if( $resourceTableStrategy && $resourceTableStrategy == "allDaily" ) selected="selected"#end>$i18n.getString( "daily" )</option> +</select> +</div> + +<!-- Analytics --> + +<div class="settingHeader">$i18n.getString( "analytics_tables" )</div> + +<div class="settingLabel">$i18n.getString( "analytics_tables_task_strategy" )</div> + +<div class="setting"> +<select id="analyticsStrategy" name="analyticsStrategy" class="scheduling"> + <option value="never">$i18n.getString( "never" )</option> + <option value="allDaily"#if( $analyticsStrategy && $analyticsStrategy == "allDaily" ) selected="selected"#end>$i18n.getString( "all_daily" )</option> + <option value="last3YearsDaily"#if( $analyticsStrategy && $analyticsStrategy == "last3YearsDaily" ) selected="selected"#end>$i18n.getString( "last_3_years_daily" )</option> +</select> +</div> + +<!-- Data mart --> + +<div class="settingHeader">$i18n.getString( "data_mart" )</div> + +<div class="settingLabel">$i18n.getString( "aggregation_period_types" )</div> + +<div class="setting"> +<label for="weekly">$i18n.getString( "Weekly" )</label><input type="checkbox" id="weekly" class="scheduling" name="scheduledPeriodTypes" value="Weekly"#if( $scheduledPeriodTypes.contains( "Weekly" ) ) checked="checked"#end> +<label for="monthly">$i18n.getString( "Monthly" )</label><input type="checkbox" id="monthly" class="scheduling" name="scheduledPeriodTypes" value="Monthly"#if( $scheduledPeriodTypes.contains( "Monthly" ) ) checked="checked"#end> +<label for="biMonthly">$i18n.getString( "BiMonthly" )</label><input type="checkbox" id="biMonthly" class="scheduling" name="scheduledPeriodTypes" value="BiMonthly"#if( $scheduledPeriodTypes.contains( "BiMonthly" ) ) checked="checked"#end> +<label for="quarterly">$i18n.getString( "Quarterly" )</label><input type="checkbox" id="quarterly" class="scheduling" name="scheduledPeriodTypes" value="Quarterly"#if( $scheduledPeriodTypes.contains( "Quarterly" ) ) checked="checked"#end><br> +<label for="sixMonthly">$i18n.getString( "SixMonthly" )</label><input type="checkbox" id="sixMonthly" class="scheduling" name="scheduledPeriodTypes" value="SixMonthly"#if( $scheduledPeriodTypes.contains( "SixMonthly" ) ) checked="checked"#end> +<label for="yearly">$i18n.getString( "Yearly" )</label><input type="checkbox" id="yearly" class="scheduling" name="scheduledPeriodTypes" value="Yearly"#if( $scheduledPeriodTypes.contains( "Yearly" ) ) checked="checked"#end> +<label for="financialYearly">$i18n.getString( "financial_yearly" )</label><input type="checkbox" id="financialYearly" class="scheduling" name="scheduledPeriodTypes" value="FinancialJuly"#if( $scheduledPeriodTypes.contains( "FinancialJuly" ) ) checked="checked"#end> +</div> + +<div class="settingLabel">$i18n.getString( "organisation_unit_group_set_aggregation_level" )</div> + +<div class="setting"> +<select id="orgUnitGroupSetAggLevel" name="orgUnitGroupSetAggLevel" class="scheduling"> + <option value="0"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == 0 ) selected="selected"#end>[$i18n.getString( "no_aggregation" )]</option> + #foreach( $level in $levels ) + <option value="$level.level"#if( $orgUnitGroupSetAggLevel && $orgUnitGroupSetAggLevel == $level.level ) selected="selected"#end>$encoder.htmlEncode( $level.displayName )</option> + #end +</select> +</div> + +<div class="settingLabel">$i18n.getString( "data_mart_task_strategy" )</div> + +<div class="setting"> +<select id="dataMartStrategy" name="dataMartStrategy" class="scheduling"> + <option value="never">$i18n.getString( "never" )</option> + <option value="last12Daily"#if( $dataMartStrategy && $dataMartStrategy == "last12Daily" ) selected="selected"#end>$i18n.getString( "last_12_months_daily" )</option> + <option value="last6Daily6To12Weekly"#if( $dataMartStrategy && $dataMartStrategy == "last6Daily6To12Weekly" ) selected="selected"#end>$i18n.getString( "last_6_months_daily_6_to_12_months_weekly" )</option> +</select> +</div> + +<div class="setting"> + <input type="button" style="width:140px" onclick="submitSchedulingForm()" + #if ( $running ) + value="$i18n.getString( 'stop' )" + #else + value="$i18n.getString( 'start' )" + #end + /> + <input type="button" id="executeButton" style="width:140px" onclick="executeTasks()" value="$i18n.getString( 'execute_now' )" /> +</div> + </form> <span id="info">$i18n.getString( "scheduling_is" ) $!i18n.getString( $!status )</span>
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp