← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4912: Cleaned up i18n and period generation in light module

 

------------------------------------------------------------
revno: 4912
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-10-12 19:49:13 +0200
message:
  Cleaned up i18n and period generation in light module
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_page.vm
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntry.vm
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectDataSet.vm
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.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-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java	2011-10-12 17:32:39 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetPeriodsAction.java	2011-10-12 17:49:13 +0000
@@ -26,12 +26,9 @@
  */
 package org.hisp.dhis.light.dataentry.action;
 
-
 import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
-import java.util.GregorianCalendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -45,7 +42,8 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.CalendarPeriodType;
 import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
+import org.hisp.dhis.system.util.FilterUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -55,6 +53,8 @@
 public class GetPeriodsAction
     implements Action
 {
+    private static final int MAX_PERIODS = 36;
+    
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -129,13 +129,6 @@
         return periods;
     }
 
-    private PeriodService periodService;
-
-    public void setPeriodService( PeriodService periodService )
-    {
-        this.periodService = periodService;
-    }
-
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -146,17 +139,18 @@
         if ( dataSetId != null )
         {
             OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+            
             DataSet dataSet = dataSetService.getDataSet( dataSetId );
             CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType();
-            periods = periodType.generatePeriods( new Date() );
-            Calendar cal = new GregorianCalendar();
-            Date dateEnd = cal.getTime();
-            cal.add( Calendar.MONTH, -12 );
-            Date dateStart = cal.getTime();
-
-            //FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
-            Collection<Period> periodsBetweenDates = periodService.getPeriodsBetweenDates( periodType, dateStart, dateEnd );
-            periods = (List<Period>) periodsBetweenDates;
+            periods = periodType.generateLast5Years( new Date() );            
+            FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
+            Collections.reverse( periods );
+            
+            if ( periods.size() > MAX_PERIODS )
+            {
+                periods = periods.subList( 0, MAX_PERIODS );
+            }
+            
             for ( Period period : periods )
             {
                 period.setName( format.formatPeriod( period ) );
@@ -166,7 +160,6 @@
 
                 periodCompletedMap.put( period, registration != null ? true : false );
             }
-
         }
 
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2011-10-11 17:30:01 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2011-10-12 17:49:13 +0000
@@ -30,7 +30,6 @@
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
     <property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
-    <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
   </bean>
 
   <bean id="org.hisp.dhis.light.dataentry.action.GetSectionFormAction" class="org.hisp.dhis.light.dataentry.action.GetSectionFormAction">

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2011-10-12 17:32:39 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2011-10-12 17:49:13 +0000
@@ -5,7 +5,7 @@
 data_entry = Data Entry
 dashboard = Dashboard
 available_datasets = Available data sets
-available_organisation_units = Available organisation Units
+available_organisation_units = Available organisation units
 logout = Logout
 available_periods = Available periods
 menu = Menu

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_page.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_page.vm	2011-10-11 06:38:29 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dashboard_page.vm	2011-10-12 17:49:13 +0000
@@ -1,19 +1,18 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd";>
 <html>
-<head>
-  <title>$i18n.getString("DHIS_2")</title>
-  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+  <head>
+	<title>$i18n.getString("DHIS_2")</title>
+	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 
 	<link type="text/css" rel="stylesheet" media="screen" href="style/dashboard.css">
-
+	
 	<script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.min.js"></script>
 	<script type="text/javascript" src="../dhis-web-commons/javascripts/commons.js"></script>
 	<script type="text/javascript" src="../dhis-web-commons/javascripts/commons.ajax.js"></script>
 	<script type="text/javascript" src="../dhis-web-commons/oust/oust.js"></script>
 	<script type="text/javascript" src="../request.js"></script>
 	<script type="text/javascript" src="javascript/dashboard.js"></script>
-
-</head>
+  </head>
 <head>
 <body>
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntry.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntry.vm	2011-10-11 17:30:01 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntry.vm	2011-10-12 17:49:13 +0000
@@ -1,7 +1,7 @@
 
 #set( $Integer = 0 )
 
-<h2>$dataSet.name</h2>
+<h2>$encoder.htmlEncode( $dataSet.name )</h2>
 
 #if( $validationRuleViolations.size() > 0 )
 <div class="header-box" align="center">

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm	2011-10-12 13:13:14 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/menu.vm	2011-10-12 17:49:13 +0000
@@ -1,12 +1,11 @@
 
-<h2>$i18n.getString("menu")</h2>
-    
+<h2>$i18n.getString( "menu" )</h2>
 
 <p>
-    <ul>
-        <li><a href="dashboard.action">$i18n.getString("dashboard")</a></li>
-        <li><a href="selectOrganisationUnit.action">$i18n.getString("data_entry")</a></li>
-    </ul>
+<ul>
+    <li><a href="selectOrganisationUnit.action">$i18n.getString( "data_entry" )</a></li>
+    <li><a href="dashboard.action">$i18n.getString( "dashboard" )</a></li>
+</ul>
 </p>
 
 <div id="footer">

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectDataSet.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectDataSet.vm	2011-10-12 17:32:39 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectDataSet.vm	2011-10-12 17:49:13 +0000
@@ -2,9 +2,9 @@
 <h2>$i18n.getString( "available_datasets" )</h2>
 <p>
 <ul>
-	#foreach( $dataSet in $dataSets )
-	<li><a href="selectPeriod.action?organisationUnitId=$organisationUnitId&dataSetId=$dataSet.id">$!encoder.jsonEncode( ${dataSet.name} )</a></li>
-	#end
+#foreach( $dataSet in $dataSets )
+<li><a href="selectPeriod.action?organisationUnitId=$organisationUnitId&dataSetId=$dataSet.id">$!encoder.jsonEncode( ${dataSet.name} )</a></li>
+#end
 </ul>
 </p>
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm	2011-10-12 17:32:39 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm	2011-10-12 17:49:13 +0000
@@ -2,14 +2,14 @@
 <h2>$i18n.getString( "available_periods" )</h2>
 
 <p>
-	<ul>
-		#foreach( $period in $periods )
-		<li>
-			<a href="dataEntry.action?organisationUnitId=$organisationUnitId&dataSetId=$dataSetId&periodId=$period.getExternalId()">$!encoder.jsonEncode( ${period.name} )</a>
-			#if( $periodCompletedMap.get($period) )<img src="/dhis-web-light/images/check.jpg" />#end
-		</li>
-		#end
-	</ul>
+<ul>
+#foreach( $period in $periods )
+<li>
+	<a href="dataEntry.action?organisationUnitId=$organisationUnitId&dataSetId=$dataSetId&periodId=$period.getExternalId()">$!encoder.jsonEncode( ${period.name} )</a>
+	#if( $periodCompletedMap.get($period) )<img src="/dhis-web-light/images/check.jpg" />#end
+</li>
+#end
+</ul>
 </p>
 
 <div id="footer">