← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1212: Displaying start-from date rather than fixed relative period names when relative periods are on t...

 

------------------------------------------------------------
revno: 1212
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2009-12-11 09:01:25 +0100
message:
  Displaying start-from date rather than fixed relative period names when relative periods are on the rows in report tables.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.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-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2009-11-05 19:04:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java	2009-12-11 08:01:25 +0000
@@ -86,7 +86,7 @@
      *        
      * @return a Collection of Periods of the RelativePeriodType.
      */
-    List<Period> getRelativePeriods( RelativePeriods relatives, int months );
+    List<Period> getRelativePeriods( ReportTable reportTable, int months, I18nFormat format );
     
     /**
      * Returns the current date subtracted with the given number of months.

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2009-11-26 14:02:44 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2009-12-11 08:01:25 +0000
@@ -162,7 +162,7 @@
 
             if ( reportTable.getReportParams() != null && reportTable.getReportParams().isParamReportingMonth() )
             {
-                reportTable.setRelativePeriods( getRelativePeriods( reportTable.getRelatives(), reportingPeriod ) );
+                reportTable.setRelativePeriods( getRelativePeriods( reportTable, reportingPeriod, format ) );
                 
                 date = getDateFromPreviousMonth( reportingPeriod );
                 
@@ -170,7 +170,7 @@
             }
             else
             {
-                reportTable.setRelativePeriods( getRelativePeriods( reportTable.getRelatives(), 1 ) );
+                reportTable.setRelativePeriods( getRelativePeriods( reportTable, 1, format ) );
                 
                 date = getDateFromPreviousMonth( 1 );
                 
@@ -317,8 +317,12 @@
     }
     
     @Transactional
-    public List<Period> getRelativePeriods( RelativePeriods relatives, int months )
+    public List<Period> getRelativePeriods( ReportTable reportTable, int months, I18nFormat format )
     {
+        RelativePeriods relatives = reportTable.getRelatives();
+        
+        boolean dynamicNames = !reportTable.isDoPeriods();
+            
         List<Period> relativePeriods = new ArrayList<Period>();
         
         Date date = getDateFromPreviousMonth( months );
@@ -328,31 +332,31 @@
             if ( relatives.isReportingMonth() )
             {
                 Period period = periodService.getRelativePeriod( date, -1 );
-                period.setName( RelativePeriods.REPORTING_MONTH );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.REPORTING_MONTH );
                 relativePeriods.add( period );
             }
             if ( relatives.isLast3Months() )
             {
                 Period period = periodService.getRelativePeriod( date, -3 );
-                period.setName( RelativePeriods.LAST_3_MONTHS );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.LAST_3_MONTHS );
                 relativePeriods.add( period );            
             }
             if ( relatives.isLast6Months() )
             {
                 Period period = periodService.getRelativePeriod( date, -6 );
-                period.setName( RelativePeriods.LAST_6_MONTHS );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.LAST_6_MONTHS );
                 relativePeriods.add( period );
             }
             if ( relatives.isLast9Months() )
             {
                 Period period = periodService.getRelativePeriod( date, -9 );
-                period.setName( RelativePeriods.LAST_9_MONTHS );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.LAST_9_MONTHS );
                 relativePeriods.add( period );
             }
             if ( relatives.isLast12Months() )
             {
                 Period period = periodService.getRelativePeriod( date, -12 );
-                period.setName( RelativePeriods.LAST_12_MONTHS );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.LAST_12_MONTHS );
                 relativePeriods.add( period );
             }
             if ( relatives.isSoFarThisYear() )
@@ -365,7 +369,7 @@
                 period.setEndDate( periodType.createPeriod( date ).getEndDate() );
                 
                 period = savePeriod( period );
-                period.setName( RelativePeriods.SO_FAR_THIS_YEAR );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.SO_FAR_THIS_YEAR );
                 relativePeriods.add( period );
             }
             if ( relatives.isSoFarThisFinancialYear() )
@@ -378,25 +382,25 @@
                 period.setEndDate( periodType.createPeriod( date ).getEndDate() );
                 
                 period = savePeriod( period );
-                period.setName( RelativePeriods.SO_FAR_THIS_FINANCIAL_YEAR );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.SO_FAR_THIS_FINANCIAL_YEAR );
                 relativePeriods.add( period );
             }
             if ( relatives.isLast3To6Months() )
             {
                 Period period = periodService.getRelativePeriod( date, -6, -3 );
-                period.setName( RelativePeriods.LAST_3_TO_6_MONTHS );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.LAST_3_TO_6_MONTHS );
                 relativePeriods.add( period );
             }
             if ( relatives.isLast6To9Months() )
             {
                 Period period = periodService.getRelativePeriod( date, -9, -6 );
-                period.setName( RelativePeriods.LAST_6_TO_9_MONTHS );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.LAST_6_TO_9_MONTHS );
                 relativePeriods.add( period );
             }
             if ( relatives.isLast9To12Months() )
             {
                 Period period = periodService.getRelativePeriod( date, -12, -9 );
-                period.setName( RelativePeriods.LAST_9_TO_12_MONTHS );
+                period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.LAST_9_TO_12_MONTHS );
                 relativePeriods.add( period );
             }
             if ( relatives.isLast12IndividualMonths() )
@@ -406,7 +410,7 @@
                     int periodNumber = i - 12;
                     
                     Period period = periodService.getRelativePeriod( date, periodNumber, periodNumber + 1 );
-                    period.setName( RelativePeriods.PREVIOUS_MONTH_NAMES[i] );
+                    period.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.PREVIOUS_MONTH_NAMES[i] );
                     relativePeriods.add( period );
                 }
             }
@@ -424,7 +428,7 @@
                     Period month = periods.get( i );
                     month.setPeriodType( new RelativePeriodType() );
                     month = savePeriod( month );
-                    month.setName( RelativePeriods.MONTHS_THIS_YEAR[i] );                
+                    month.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.MONTHS_THIS_YEAR[i] );                
                     relativePeriods.add( month );
                 }            
             }
@@ -442,7 +446,7 @@
                     Period quarter = periods.get( i );
                     quarter.setPeriodType( new RelativePeriodType() );
                     quarter = savePeriod( quarter );
-                    quarter.setName( RelativePeriods.QUARTERS_THIS_YEAR[i] );
+                    quarter.setName( dynamicNames ? format.formatPeriod( period ) : RelativePeriods.QUARTERS_THIS_YEAR[i] );
                     relativePeriods.add( quarter );
                 }
             }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2009-12-11 02:18:27 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/multidimensional/FormAction.java	2009-12-11 08:01:25 +0000
@@ -32,12 +32,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.TreeMap;
 
 import org.hisp.dhis.customvalue.CustomValue;
 import org.hisp.dhis.customvalue.CustomValueService;

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java	2009-08-24 12:43:02 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetDisplayTableOptionsAction.java	2009-12-11 08:01:25 +0000
@@ -94,7 +94,7 @@
     {
         reportTable = reportTableService.getReportTable( id );
         
-        reportTable.setRelativePeriods( reportTableService.getRelativePeriods( reportTable.getRelatives(), 1 ) );
+        reportTable.setRelativePeriods( reportTableService.getRelativePeriods( reportTable, 1, format ) );
         reportTable.setI18nFormat( format );
         reportTable.init();