← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16760: in standard report, use a list of idObjects instead of period, so that its easier to provide loca...

 

------------------------------------------------------------
revno: 16760
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-09-21 15:42:21 +0700
message:
  in standard report, use a list of idObjects instead of period, so that its easier to provide local dates
modified:
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.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-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java	2014-05-13 17:35:09 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/GetReportParamsAction.java	2014-09-21 08:42:21 +0000
@@ -28,10 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
+import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.period.CalendarPeriodType;
 import org.hisp.dhis.period.Period;
@@ -44,9 +43,13 @@
 import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
 import org.hisp.dhis.system.util.FilterUtils;
 
-import com.opensymphony.xwork2.Action;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
 
-import static org.hisp.dhis.reporttable.ReportTableService.*;
+import static org.hisp.dhis.reporttable.ReportTableService.MODE_REPORT;
+import static org.hisp.dhis.reporttable.ReportTableService.MODE_REPORT_TABLE;
 
 /**
  * @author Lars Helge Overland
@@ -106,7 +109,7 @@
     {
         this.mode = mode;
     }
-    
+
     private String type;
 
     public String getType()
@@ -129,10 +132,10 @@
     {
         return reportParams;
     }
-    
-    private List<Period> periods;
-
-    public List<Period> getPeriods()
+
+    private List<IdentifiableObject> periods = new ArrayList<>();
+
+    public List<IdentifiableObject> getPeriods()
     {
         return periods;
     }
@@ -147,53 +150,57 @@
         {
             return SUCCESS;
         }
-                    
+
         RelativePeriods relatives = null;
-        
+
         if ( MODE_REPORT_TABLE.equals( mode ) )
         {
             ReportTable reportTable = reportTableService.getReportTable( uid );
-        
+
             if ( reportTable != null )
             {
-                reportParams = reportTable.getReportParams();                                
+                reportParams = reportTable.getReportParams();
                 relatives = reportTable.getRelatives();
             }
         }
         else if ( MODE_REPORT.equals( mode ) )
         {
             Report report = reportService.getReport( uid );
-            
+
             if ( report != null && report.isTypeReportTable() )
             {
-                reportParams = report.getReportTable().getReportParams();                
+                reportParams = report.getReportTable().getReportParams();
                 relatives = report.getReportTable().getRelatives();
             }
-            else if ( report != null && ( report.isTypeJdbc() || report.isTypeHtml() ) )
+            else if ( report != null && (report.isTypeJdbc() || report.isTypeHtml()) )
             {
-                reportParams = report.getReportParams();                
+                reportParams = report.getReportParams();
                 relatives = report.getRelatives();
             }
-            
+
             if ( type == null && report != null )
             {
                 type = report.getType(); // Set type based on report
             }
         }
-        
+
         if ( reportParams != null && reportParams.isParamReportingMonth() && relatives != null )
         {
             CalendarPeriodType periodType = (CalendarPeriodType) relatives.getPeriodType();
-            periods = periodType.generateLast5Years( new Date() );
+            List<Period> periods = periodType.generateLast5Years( new Date() );
             Collections.reverse( periods );
             FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
-            
-            for ( Period period : periods )
+
+            for ( Period period_ : periods )
             {
-                period.setName( format.formatPeriod( period ) );
+                BaseIdentifiableObject period = new BaseIdentifiableObject();
+                period.setUid( period_.getIsoDate() );
+                period.setDisplayName( format.formatPeriod( period_ ) );
+
+                this.periods.add( period );
             }
         }
-        
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2013-04-30 09:09:08 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/inputReportParamsForm.vm	2014-09-21 08:42:21 +0000
@@ -35,7 +35,7 @@
         <td>
             <select id="reportingPeriod" name="reportingPeriod" style="width:325px">               
                 #foreach ( $period in $periods )
-                    <option value="${period.isoDate}">${period.name}</option>
+                    <option value="${period.uid}">${period.displayName}</option>
                 #end
             </select>
         </td>