dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38982
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19790: bugfix for analytics start of year, uses Calendar.startOfYear instead of assuming start is at 1.1
------------------------------------------------------------
revno: 19790
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-08-19 15:08:11 +0700
message:
bugfix for analytics start of year, uses Calendar.startOfYear instead of assuming start is at 1.1
modified:
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/JdbcEventAnalyticsTableManager.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.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
=== 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 2015-07-02 23:34:24 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/AbstractJdbcTableManager.java 2015-08-19 08:08:11 +0000
@@ -42,6 +42,7 @@
import org.hisp.dhis.analytics.AnalyticsIndex;
import org.hisp.dhis.analytics.AnalyticsTable;
import org.hisp.dhis.analytics.AnalyticsTableManager;
+import org.hisp.dhis.calendar.Calendar;
import org.hisp.dhis.common.CodeGenerator;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.commons.collection.ListUtils;
@@ -52,6 +53,7 @@
import org.hisp.dhis.jdbc.StatementBuilder;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.resourcetable.ResourceTableService;
import org.hisp.dhis.setting.SystemSettingManager;
import org.springframework.beans.factory.annotation.Autowired;
@@ -144,14 +146,15 @@
private List<AnalyticsTable> getTables( List<Integer> dataYears )
{
List<AnalyticsTable> tables = new ArrayList<>();
-
+ Calendar calendar = PeriodType.getCalendar();
+
Collections.sort( dataYears );
String baseName = getTableName();
for ( Integer year : dataYears )
{
- Period period = PartitionUtils.getPeriod( year );
+ Period period = PartitionUtils.getPeriod( calendar, year );
tables.add( new AnalyticsTable( baseName, getDimensionColumns( null ), period ) );
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2015-08-06 20:36:58 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcEventAnalyticsTableManager.java 2015-08-19 08:08:11 +0000
@@ -39,6 +39,7 @@
import java.util.concurrent.Future;
import org.hisp.dhis.analytics.AnalyticsTable;
+import org.hisp.dhis.calendar.Calendar;
import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.commons.collection.ListUtils;
import org.hisp.dhis.dataelement.DataElement;
@@ -84,6 +85,7 @@
private List<AnalyticsTable> getTables( List<Integer> dataYears )
{
List<AnalyticsTable> tables = new ArrayList<>();
+ Calendar calendar = PeriodType.getCalendar();
Collections.sort( dataYears );
@@ -91,7 +93,7 @@
for ( Integer year : dataYears )
{
- Period period = PartitionUtils.getPeriod( year );
+ Period period = PartitionUtils.getPeriod( calendar, year );
List<Integer> programs = getDataPrograms( period );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java 2015-07-02 23:34:24 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java 2015-08-19 08:08:11 +0000
@@ -55,9 +55,10 @@
public static final String SEP = "_";
- public static Period getPeriod( Integer year )
+ public static Period getPeriod( Calendar calendar, Integer year )
{
- DateTime time = new DateTime( year, 1, 1, 1, 1 );
+ DateTimeUnit startOfYear = calendar.startOfYear();
+ DateTime time = new DateTime( year, startOfYear.getMonth(), startOfYear.getDay(), 1, 1 );
return PERIODTYPE.createPeriod( time.toDate() );
}