← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4714: (mobile) shows which periods are marked as complete in selectPeriod

 

------------------------------------------------------------
revno: 4714
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-09-27 13:56:18 +0200
message:
  (mobile) shows which periods are marked as complete in selectPeriod
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/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/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/action/GetPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetPeriodsAction.java	2011-09-27 11:21:17 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/action/GetPeriodsAction.java	2011-09-27 11:56:18 +0000
@@ -28,11 +28,17 @@
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
+import org.hisp.dhis.dataset.CompleteDataSetRegistration;
+import org.hisp.dhis.dataset.CompleteDataSetRegistrationService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.CalendarPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
@@ -50,6 +56,13 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
     private DataSetService dataSetService;
 
     public void setDataSetService( DataSetService dataSetService )
@@ -57,6 +70,13 @@
         this.dataSetService = dataSetService;
     }
 
+    private CompleteDataSetRegistrationService registrationService;
+
+    public void setRegistrationService( CompleteDataSetRegistrationService registrationService )
+    {
+        this.registrationService = registrationService;
+    }
+
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -92,6 +112,13 @@
         return dataSetId;
     }
 
+    private Map<Period, Boolean> periodCompletedMap = new HashMap<Period, Boolean>();
+
+    public Map<Period, Boolean> getPeriodCompletedMap()
+    {
+        return periodCompletedMap;
+    }
+
     private List<Period> periods = new ArrayList<Period>();
 
     public List<Period> getPeriods()
@@ -108,15 +135,21 @@
     {
         if ( dataSetId != null )
         {
+            OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
             DataSet dataSet = dataSetService.getDataSet( dataSetId );
             CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType();
             periods = periodType.generatePeriods( new Date() );
             FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
-        }
-
-        for ( Period period : periods )
-        {
-            period.setName( format.formatPeriod( period ) );
+
+            for ( Period period : periods )
+            {
+                period.setName( format.formatPeriod( period ) );
+
+                CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet,
+                    period, organisationUnit );
+
+                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-09-27 10:32:15 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2011-09-27 11:56:18 +0000
@@ -14,7 +14,9 @@
   </bean>
 
   <bean id="org.hisp.dhis.light.action.GetPeriodsAction" class="org.hisp.dhis.light.action.GetPeriodsAction">
+    <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" />
   </bean>
 
   <bean id="org.hisp.dhis.light.action.GetSectionFormAction" class="org.hisp.dhis.light.action.GetSectionFormAction">

=== 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-09-23 14:49:23 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/selectPeriod.vm	2011-09-27 11:56:18 +0000
@@ -4,7 +4,10 @@
 <p>
 	<ul>
 		#foreach( $period in $periods )
-		<li><a href="dataEntry.action?organisationUnitId=$organisationUnitId&dataSetId=$dataSetId&periodId=$period.getExternalId()">$!encoder.jsonEncode( ${period.name} )</a></li>
+		<li>
+			<a href="dataEntry.action?organisationUnitId=$organisationUnitId&dataSetId=$dataSetId&periodId=$period.getExternalId()">$!encoder.jsonEncode( ${period.name} )</a>
+			#if( $periodCompletedMap.get($period) )@#end
+		</li>
 		#end
 	</ul>
 </p>