dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29831
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15141: Analytics, added last 2 years strategy option
------------------------------------------------------------
revno: 15141
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-05-04 14:21:18 +0200
message:
Analytics, added last 2 years strategy option
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceTableController.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-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java 2014-04-19 07:47:34 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableManager.java 2014-05-04 12:21:18 +0000
@@ -51,9 +51,9 @@
* be generated starting from the earliest existing data value until the
* latest existing data value.
*
- * @param last3YearsOnly whether to generate for last 3 years only.
+ * @param lastYears the number of last years of data to include, null if all years.
*/
- List<AnalyticsTable> getTables( boolean last3YearsOnly );
+ List<AnalyticsTable> getTables( Integer lastYears );
/**
* Returns analytics tables which yearly partitions.
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableService.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsTableService.java 2014-05-04 12:21:18 +0000
@@ -38,10 +38,10 @@
/**
* Rebuilds the analytics tables.
*
- * @param last3Years whether to update last 3 years of data only or all.
+ * @param lastYears the number of last years of data to include, null if all.
* @param taskId the TaskId.
*/
- void update( boolean last3Years, TaskId id );
+ void update( Integer lastYears, TaskId id );
/**
* Drops analytics and and temporary analytics tables between 1900 and 2100.
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java 2014-05-04 12:21:18 +0000
@@ -66,11 +66,11 @@
@Autowired
private MessageService messageService;
- private boolean last3Years = false;
+ private Integer lastYears;
- public void setLast3Years( boolean last3Years )
+ public void setLastYears( Integer lastYears )
{
- this.last3Years = last3Years;
+ this.lastYears = lastYears;
}
private boolean skipResourceTables = false;
@@ -121,22 +121,22 @@
if ( !skipAggregate )
{
notifier.notify( taskId, "Updating analytics tables" );
- analyticsTableService.update( last3Years, taskId );
+ analyticsTableService.update( lastYears, taskId );
notifier.notify( taskId, "Updating completeness table" );
- completenessTableService.update( last3Years, taskId );
+ completenessTableService.update( lastYears, taskId );
notifier.notify( taskId, "Updating completeness target table" );
- completenessTargetTableService.update( last3Years, taskId );
+ completenessTargetTableService.update( lastYears, taskId );
notifier.notify( taskId, "Updating organisation unit target table" );
- orgUnitTargetTableService.update( last3Years, taskId );
+ orgUnitTargetTableService.update( lastYears, taskId );
}
if ( !skipEvents )
{
notifier.notify( taskId, "Updating event analytics table" );
- eventAnalyticsTableService.update( last3Years, taskId );
+ eventAnalyticsTableService.update( lastYears, taskId );
}
notifier.notify( taskId, INFO, "Analytics tables updated", true );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java 2014-04-10 13:40:11 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java 2014-05-04 12:21:18 +0000
@@ -111,13 +111,20 @@
// -------------------------------------------------------------------------
@Transactional
- public List<AnalyticsTable> getTables( boolean last3YearsOnly )
+ public List<AnalyticsTable> getTables( Integer lastYears )
{
- Date threeYrsAgo = new Cal().subtract( Calendar.YEAR, 2 ).set( 1, 1 ).time();
- Date earliest = last3YearsOnly ? threeYrsAgo : getEarliestData();
- Date latest = getLatestData();
-
- return getTables( earliest, latest );
+ Date earliest = null;
+
+ if ( lastYears != null )
+ {
+ earliest = new Cal().now().subtract( Calendar.YEAR, ( lastYears - 1 ) ).set( 1, 1 ).time();
+ }
+ else
+ {
+ earliest = getEarliestData();
+ }
+
+ return getTables( earliest, getLatestData() );
}
@Transactional
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java 2014-04-19 10:51:12 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java 2014-05-04 12:21:18 +0000
@@ -91,7 +91,7 @@
// Implementation
// -------------------------------------------------------------------------
- public void update( boolean last3YearsOnly, TaskId taskId )
+ public void update( Integer lastYears, TaskId taskId )
{
Clock clock = new Clock().startClock().logTime( "Starting update, no of processes: " + getProcessNo() );
@@ -103,9 +103,9 @@
return;
}
- final List<AnalyticsTable> tables = tableManager.getTables( last3YearsOnly );
+ final List<AnalyticsTable> tables = tableManager.getTables( lastYears );
- clock.logTime( "Partition tables: " + tables + ", last 3 years: " + last3YearsOnly );
+ clock.logTime( "Partition tables: " + tables + ", last 3 years: " + lastYears );
notifier.notify( taskId, "Creating analytics tables" );
@@ -149,7 +149,7 @@
public void dropTables()
{
- List<AnalyticsTable> tables = tableManager.getTables( false );
+ List<AnalyticsTable> tables = tableManager.getTables( null );
for ( AnalyticsTable table : tables )
{
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcCompletenessTargetTableManager.java 2014-05-04 12:21:18 +0000
@@ -49,7 +49,7 @@
{
@Override
@Transactional
- public List<AnalyticsTable> getTables( boolean last3YearsOnly )
+ public List<AnalyticsTable> getTables( Integer lastYears )
{
List<AnalyticsTable> tables = new ArrayList<AnalyticsTable>();
tables.add( new AnalyticsTable( getTableName(), getDimensionColumns( null ) ) );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcOrgUnitTargetTableManager.java 2014-05-04 12:21:18 +0000
@@ -48,7 +48,7 @@
{
@Override
@Transactional
- public List<AnalyticsTable> getTables( boolean last3YearsOnly )
+ public List<AnalyticsTable> getTables( Integer lastYears )
{
List<AnalyticsTable> tables = new ArrayList<AnalyticsTable>();
tables.add( new AnalyticsTable( getTableName(), getDimensionColumns( null ) ) );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml 2014-04-19 10:51:12 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml 2014-05-04 12:21:18 +0000
@@ -60,12 +60,14 @@
<!-- Scheduled tasks -->
- <bean id="analyticsAllTask" class="org.hisp.dhis.analytics.scheduling.AnalyticsTableTask">
- <property name="last3Years" value="false" />
+ <bean id="analyticsAllTask" class="org.hisp.dhis.analytics.scheduling.AnalyticsTableTask"/>
+
+ <bean id="analyticsLast2YearsTask" class="org.hisp.dhis.analytics.scheduling.AnalyticsTableTask">
+ <property name="lastYears" value="2" />
</bean>
-
+
<bean id="analyticsLast3YearsTask" class="org.hisp.dhis.analytics.scheduling.AnalyticsTableTask">
- <property name="last3Years" value="true" />
+ <property name="lastYears" value="3" />
</bean>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceTableController.java 2014-05-04 09:55:24 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceTableController.java 2014-05-04 12:21:18 +0000
@@ -82,13 +82,13 @@
@RequestParam(required=false) boolean skipResourceTables,
@RequestParam(required=false) boolean skipAggregate,
@RequestParam(required=false) boolean skipEvents,
- @RequestParam(required=false) boolean last3Years,
+ @RequestParam(required=false) Integer lastYears,
HttpServletResponse response )
{
analyticsTableTask.setSkipResourceTables( skipResourceTables );
analyticsTableTask.setSkipAggregate( skipAggregate );
analyticsTableTask.setSkipEvents( skipEvents );
- analyticsTableTask.setLast3Years( last3Years );
+ analyticsTableTask.setLastYears( lastYears );
analyticsTableTask.setTaskId( new TaskId( TaskCategory.DATAMART, currentUserService.getCurrentUser() ) );
scheduler.executeTask( analyticsTableTask );
=== 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 2014-04-10 14:59:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2014-05-04 12:21:18 +0000
@@ -281,6 +281,7 @@
data_mart=Data mart
analytics_tables=Analytics tables
analytics_tables_task_strategy=Analytics tables task strategy
+last_2_years_daily=Last 2 years daily
last_3_years_daily=Last 3 years daily
all_daily=All daily
resource_table_task_strategy=Resource tables task strategy
=== 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 2014-02-08 18:09:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/viewScheduledTasks.vm 2014-05-04 12:21:18 +0000
@@ -28,6 +28,7 @@
<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="last2YearsDaily"#if( $analyticsStrategy && $analyticsStrategy == "last2YearsDaily" ) selected="selected"#end>$i18n.getString( "last_2_years_daily" )</option>
<option value="last3YearsDaily"#if( $analyticsStrategy && $analyticsStrategy == "last3YearsDaily" ) selected="selected"#end>$i18n.getString( "last_3_years_daily" )</option>
</select>
</div>