← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3: DataEntry made not to let users enter value for future periods.

 

------------------------------------------------------------
revno: 3
committer: abyot <abyota@xxxxxxxxx>
branch nick: trunk
timestamp: Sun 2009-03-08 16:51:22 +0530
message:
  DataEntry made not to let users enter value for future periods.
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/state/DefaultSelectedStateManager.java	2009-03-08 11:21:22 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -45,6 +46,7 @@
 import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.period.CalendarPeriodType;
 import org.hisp.dhis.period.Period;
+import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.UserAuthorityGroup;
@@ -72,6 +74,13 @@
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
+    
+    private PeriodService periodService;
+
+    public void setPeriodService( PeriodService periodService )
+    {
+        this.periodService = periodService;
+    }
 
     private DataSetService dataSetService;
 
@@ -190,6 +199,22 @@
 
             generatedPeriodsCache.set( periods );
         }
+        
+        Date now = new Date();
+
+        Iterator<Period> iterator = periods.iterator();
+        
+        Collection<Period> persistedPeriods = periodService.getAllPeriods();
+
+        while ( iterator.hasNext() )
+        {
+            Period period = iterator.next();
+
+            if ( period.getStartDate().after( now ) || !persistedPeriods.contains( period ))
+            {
+                iterator.remove();
+            }
+        }
 
         return periods;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2009-03-08 10:57:22 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2009-03-08 11:21:22 +0000
@@ -32,7 +32,8 @@
       ref="org.hisp.dhis.user.UserStore"/>
     <property name="currentUserService"
       ref="org.hisp.dhis.user.CurrentUserService"/>
-	
+	<property name="periodService"
+      ref="org.hisp.dhis.period.PeriodService"/>
   </bean>
   
   <bean id="org.hisp.dhis.de.screen.DataEntryScreenManager"



--

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.