dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37119
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18986: Analytics tables, moved AnalyticsTableTask to new package
------------------------------------------------------------
revno: 18986
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-04-22 18:20:05 +0200
message:
Analytics tables, moved AnalyticsTableTask to new package
removed:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java
added:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java
modified:
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/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ResourceTableController.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart/action/StartExportAction.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== removed directory 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling'
=== removed 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 2015-03-08 08:26:56 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/scheduling/AnalyticsTableTask.java 1970-01-01 00:00:00 +0000
@@ -1,172 +0,0 @@
-package org.hisp.dhis.analytics.scheduling;
-
-/*
- * Copyright (c) 2004-2015, 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.system.notification.NotificationLevel.ERROR;
-import static org.hisp.dhis.system.notification.NotificationLevel.INFO;
-import static org.hisp.dhis.setting.SystemSettingManager.KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE;
-
-import java.util.Date;
-
-import javax.annotation.Resource;
-
-import org.hisp.dhis.analytics.AnalyticsTableService;
-import org.hisp.dhis.message.MessageService;
-import org.hisp.dhis.scheduling.TaskId;
-import org.hisp.dhis.setting.SystemSettingManager;
-import org.hisp.dhis.system.notification.Notifier;
-import org.hisp.dhis.system.util.Clock;
-import org.hisp.dhis.system.util.DebugUtils;
-import org.joda.time.DateTime;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * @author Lars Helge Overland
- */
-public class AnalyticsTableTask
- implements Runnable
-{
- @Resource(name="org.hisp.dhis.analytics.AnalyticsTableService")
- private AnalyticsTableService analyticsTableService;
-
- @Resource(name="org.hisp.dhis.analytics.CompletenessTableService")
- private AnalyticsTableService completenessTableService;
-
- @Resource(name="org.hisp.dhis.analytics.CompletenessTargetTableService")
- private AnalyticsTableService completenessTargetTableService;
-
- @Resource(name="org.hisp.dhis.analytics.OrgUnitTargetTableService")
- private AnalyticsTableService orgUnitTargetTableService;
-
- @Resource(name="org.hisp.dhis.analytics.EventAnalyticsTableService")
- private AnalyticsTableService eventAnalyticsTableService;
-
- @Autowired
- private Notifier notifier;
-
- @Autowired
- private MessageService messageService;
-
- @Autowired
- private SystemSettingManager systemSettingManager;
-
- private Integer lastYears;
-
- public void setLastYears( Integer lastYears )
- {
- this.lastYears = lastYears;
- }
-
- private boolean skipResourceTables = false;
-
- public void setSkipResourceTables( boolean skipResourceTables )
- {
- this.skipResourceTables = skipResourceTables;
- }
-
- private boolean skipAggregate = false;
-
- public void setSkipAggregate( boolean skipAggregate )
- {
- this.skipAggregate = skipAggregate;
- }
-
- private boolean skipEvents = false;
-
- public void setSkipEvents( boolean skipEvents )
- {
- this.skipEvents = skipEvents;
- }
-
- private TaskId taskId;
-
- public void setTaskId( TaskId taskId )
- {
- this.taskId = taskId;
- }
-
- // -------------------------------------------------------------------------
- // Runnable implementation
- // -------------------------------------------------------------------------
-
- @Override
- public void run()
- {
- final Date startTime = new Date();
- final Clock clock = new Clock().startClock();
-
- notifier.clear( taskId ).notify( taskId, "Analytics table update process started" );
-
- try
- {
- if ( !skipResourceTables )
- {
- notifier.notify( taskId, "Updating resource tables" );
- analyticsTableService.generateResourceTables();
- }
-
- if ( !skipAggregate )
- {
- notifier.notify( taskId, "Updating analytics tables" );
- analyticsTableService.update( lastYears, taskId );
-
- notifier.notify( taskId, "Updating completeness table" );
- completenessTableService.update( lastYears, taskId );
-
- notifier.notify( taskId, "Updating completeness target table" );
- completenessTargetTableService.update( lastYears, taskId );
-
- notifier.notify( taskId, "Updating organisation unit target table" );
- orgUnitTargetTableService.update( lastYears, taskId );
- }
-
- if ( !skipEvents )
- {
- notifier.notify( taskId, "Updating event analytics table" );
- eventAnalyticsTableService.update( lastYears, taskId );
- }
-
- notifier.notify( taskId, INFO, "Analytics tables updated: " + clock.time(), true );
- }
- catch ( RuntimeException ex )
- {
- notifier.notify( taskId, ERROR, "Process failed: " + ex.getMessage(), true );
-
- messageService.sendSystemNotification(
- "Analytics table process failed",
- "Analytics table process failed, please check the logs. Time: " + new DateTime().toString() + ". " +
- "Message: " + ex.getMessage() + " " +
- "Cause: " + DebugUtils.getStackTrace( ex.getCause() ) );
-
- throw ex;
- }
-
- systemSettingManager.saveSystemSetting( KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE, startTime );
- }
-}
=== 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 2015-04-22 15:42:48 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/DefaultAnalyticsTableService.java 2015-04-22 16:20:05 +0000
@@ -259,7 +259,7 @@
}
}
- log.info( "No of indexes: " + indexes.size() );
+ log.info( "No of analytics table indexes: " + indexes.size() );
List<Future<?>> futures = new ArrayList<>();
=== added directory 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling'
=== added file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/scheduling/AnalyticsTableTask.java 2015-04-22 16:20:05 +0000
@@ -0,0 +1,177 @@
+package org.hisp.dhis.analytics.table.scheduling;
+
+/*
+ * Copyright (c) 2004-2015, 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.system.notification.NotificationLevel.ERROR;
+import static org.hisp.dhis.system.notification.NotificationLevel.INFO;
+import static org.hisp.dhis.setting.SystemSettingManager.KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE;
+
+import java.util.Date;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.analytics.AnalyticsTableService;
+import org.hisp.dhis.message.MessageService;
+import org.hisp.dhis.scheduling.TaskId;
+import org.hisp.dhis.setting.SystemSettingManager;
+import org.hisp.dhis.system.notification.Notifier;
+import org.hisp.dhis.system.util.Clock;
+import org.hisp.dhis.system.util.DebugUtils;
+import org.joda.time.DateTime;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class AnalyticsTableTask
+ implements Runnable
+{
+ private static final Log log = LogFactory.getLog( AnalyticsTableTask.class );
+
+ @Resource(name="org.hisp.dhis.analytics.AnalyticsTableService")
+ private AnalyticsTableService analyticsTableService;
+
+ @Resource(name="org.hisp.dhis.analytics.CompletenessTableService")
+ private AnalyticsTableService completenessTableService;
+
+ @Resource(name="org.hisp.dhis.analytics.CompletenessTargetTableService")
+ private AnalyticsTableService completenessTargetTableService;
+
+ @Resource(name="org.hisp.dhis.analytics.OrgUnitTargetTableService")
+ private AnalyticsTableService orgUnitTargetTableService;
+
+ @Resource(name="org.hisp.dhis.analytics.EventAnalyticsTableService")
+ private AnalyticsTableService eventAnalyticsTableService;
+
+ @Autowired
+ private Notifier notifier;
+
+ @Autowired
+ private MessageService messageService;
+
+ @Autowired
+ private SystemSettingManager systemSettingManager;
+
+ private Integer lastYears;
+
+ public void setLastYears( Integer lastYears )
+ {
+ this.lastYears = lastYears;
+ }
+
+ private boolean skipResourceTables = false;
+
+ public void setSkipResourceTables( boolean skipResourceTables )
+ {
+ this.skipResourceTables = skipResourceTables;
+ }
+
+ private boolean skipAggregate = false;
+
+ public void setSkipAggregate( boolean skipAggregate )
+ {
+ this.skipAggregate = skipAggregate;
+ }
+
+ private boolean skipEvents = false;
+
+ public void setSkipEvents( boolean skipEvents )
+ {
+ this.skipEvents = skipEvents;
+ }
+
+ private TaskId taskId;
+
+ public void setTaskId( TaskId taskId )
+ {
+ this.taskId = taskId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Runnable implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void run()
+ {
+ final Date startTime = new Date();
+ final Clock clock = new Clock( log ).startClock();
+
+ notifier.clear( taskId ).notify( taskId, "Analytics table update process started" );
+
+ try
+ {
+ if ( !skipResourceTables )
+ {
+ notifier.notify( taskId, "Updating resource tables" );
+ analyticsTableService.generateResourceTables();
+ }
+
+ if ( !skipAggregate )
+ {
+ notifier.notify( taskId, "Updating analytics tables" );
+ analyticsTableService.update( lastYears, taskId );
+
+ notifier.notify( taskId, "Updating completeness table" );
+ completenessTableService.update( lastYears, taskId );
+
+ notifier.notify( taskId, "Updating completeness target table" );
+ completenessTargetTableService.update( lastYears, taskId );
+
+ notifier.notify( taskId, "Updating organisation unit target table" );
+ orgUnitTargetTableService.update( lastYears, taskId );
+ }
+
+ if ( !skipEvents )
+ {
+ notifier.notify( taskId, "Updating event analytics table" );
+ eventAnalyticsTableService.update( lastYears, taskId );
+ }
+
+ clock.logTime( "Analytics tables updated" );
+ notifier.notify( taskId, INFO, "Analytics tables updated: " + clock.time(), true );
+ }
+ catch ( RuntimeException ex )
+ {
+ notifier.notify( taskId, ERROR, "Process failed: " + ex.getMessage(), true );
+
+ messageService.sendSystemNotification(
+ "Analytics table process failed",
+ "Analytics table process failed, please check the logs. Time: " + new DateTime().toString() + ". " +
+ "Message: " + ex.getMessage() + " " +
+ "Cause: " + DebugUtils.getStackTrace( ex.getCause() ) );
+
+ throw ex;
+ }
+
+ systemSettingManager.saveSystemSetting( KEY_LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE, startTime );
+ }
+}
=== 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 2015-04-17 07:41:39 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/resources/META-INF/dhis/beans.xml 2015-04-22 16:20:05 +0000
@@ -60,13 +60,13 @@
<!-- Scheduled tasks -->
- <bean id="analyticsAllTask" class="org.hisp.dhis.analytics.scheduling.AnalyticsTableTask" scope="prototype" />
+ <bean id="analyticsAllTask" class="org.hisp.dhis.analytics.table.scheduling.AnalyticsTableTask" scope="prototype" />
- <bean id="analyticsLast2YearsTask" class="org.hisp.dhis.analytics.scheduling.AnalyticsTableTask" scope="prototype">
+ <bean id="analyticsLast2YearsTask" class="org.hisp.dhis.analytics.table.scheduling.AnalyticsTableTask" scope="prototype">
<property name="lastYears" value="2" />
</bean>
- <bean id="analyticsLast3YearsTask" class="org.hisp.dhis.analytics.scheduling.AnalyticsTableTask" scope="prototype">
+ <bean id="analyticsLast3YearsTask" class="org.hisp.dhis.analytics.table.scheduling.AnalyticsTableTask" scope="prototype">
<property name="lastYears" value="3" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ResourceTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ResourceTableController.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ResourceTableController.java 2015-04-22 16:20:05 +0000
@@ -28,7 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.analytics.scheduling.AnalyticsTableTask;
+import org.hisp.dhis.analytics.table.scheduling.AnalyticsTableTask;
import org.hisp.dhis.resourcetable.scheduling.ResourceTableTask;
import org.hisp.dhis.scheduling.DataMartTask;
import org.hisp.dhis.scheduling.TaskCategory;
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart/action/StartExportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart/action/StartExportAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/datamart/action/StartExportAction.java 2015-04-22 16:20:05 +0000
@@ -34,7 +34,7 @@
import java.util.List;
import java.util.Set;
-import org.hisp.dhis.analytics.scheduling.AnalyticsTableTask;
+import org.hisp.dhis.analytics.table.scheduling.AnalyticsTableTask;
import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodType;