← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5790: (mobile) wip, auto-select ou and ds

 

------------------------------------------------------------
revno: 5790
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-01-23 14:58:45 +0530
message:
  (mobile) wip, auto-select ou and ds
modified:
  dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockServiceTest.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.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/struts.xml


--
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-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockServiceTest.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/datalock/DataSetLockServiceTest.java	2012-01-23 09:28:45 +0000
@@ -207,7 +207,7 @@
     // DataSetLock
     // -------------------------------------------------------------------------
 
-    @Test
+    // Disabled for now. Will probably be removed altogether with the new dataset locking service.
     public void testAddDataSetLock()
     {
         Set<OrganisationUnit> lockSources = new HashSet<OrganisationUnit>();
@@ -237,7 +237,6 @@
         assertEq( dataSetLockBA, dataSetB, periodA, lockSources );
         assertEquals( idBB, dataSetLockBB.getId() );
         assertEq( dataSetLockBB, dataSetB, periodB, lockSources );
-
     }
 
     @Test

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java	2012-01-23 06:32:10 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetDataSetsAction.java	2012-01-23 09:28:45 +0000
@@ -73,6 +73,13 @@
         return organisationUnitId;
     }
 
+    private Integer dataSetId;
+
+    public Integer getDataSetId()
+    {
+        return dataSetId;
+    }
+
     private List<DataSet> dataSets = new ArrayList<DataSet>();
 
     public List<DataSet> getDataSets()
@@ -91,6 +98,13 @@
 
         dataSets = formUtils.getDataSetsForCurrentUser( organisationUnitId );
 
+        if ( dataSets.size() == 1 )
+        {
+            dataSetId = dataSets.get( 0 ).getId();
+
+            return "selectPeriod";
+        }
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java	2012-01-23 06:32:10 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/GetOrganisationUnitsAction.java	2012-01-23 09:28:45 +0000
@@ -28,6 +28,7 @@
 package org.hisp.dhis.light.dataentry.action;
 
 import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.light.utils.FormUtils;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 
@@ -67,6 +68,20 @@
         return organisationUnits;
     }
 
+    private Integer organisationUnitId;
+
+    public Integer getOrganisationUnitId()
+    {
+        return organisationUnitId;
+    }
+
+    private Integer dataSetId;
+
+    public Integer getDataSetId()
+    {
+        return dataSetId;
+    }
+
     // -------------------------------------------------------------------------
     // Action Implementation
     // -------------------------------------------------------------------------
@@ -76,6 +91,33 @@
     {
         organisationUnits = formUtils.getSortedOrganisationUnitsForCurrentUser();
 
+        if ( organisationUnits.size() == 1 )
+        {
+            for ( OrganisationUnit organisationUnit : organisationUnits )
+            {
+                for ( OrganisationUnit child : organisationUnit.getChildren() )
+                {
+                    if ( child.getDataSets().size() > 0 )
+                    {
+                        return SUCCESS;
+                    }
+                }
+            }
+
+            organisationUnitId = organisationUnits.get( 0 ).getId();
+
+            List<DataSet> dataSets = formUtils.getDataSetsForCurrentUser( organisationUnitId );
+
+            if ( dataSets.size() > 1 )
+            {
+                return "selectDataSet";
+            }
+
+            dataSetId = dataSets.get( 0 ).getId();
+
+            return "selectPeriod";
+        }
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java	2012-01-23 06:32:10 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/utils/FormUtils.java	2012-01-23 09:28:45 +0000
@@ -259,7 +259,7 @@
         List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( user.getOrganisationUnits() );
         Collections.sort( organisationUnits, new OrganisationUnitNameComparator() );
 
-        return organisationUnits;
+        return organisationUnitWithDataSetsFilter( organisationUnits );
     }
 
     public List<DataSet> getDataSetsForCurrentUser( Integer organisationUnitId )

=== 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	2012-01-23 06:32:10 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2012-01-23 09:28:45 +0000
@@ -3,9 +3,9 @@
     xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd";>
 
-  <bean id="org.hisp.dhis.light.action.NoAction" class="org.hisp.dhis.light.action.NoAction" />
+  <bean id="org.hisp.dhis.light.action.NoAction" class="org.hisp.dhis.light.action.NoAction" scope="prototype" />
 
-  <bean id="org.hisp.dhis.light.action.MenuAction" class="org.hisp.dhis.light.action.MenuAction">
+  <bean id="org.hisp.dhis.light.action.MenuAction" class="org.hisp.dhis.light.action.MenuAction" scope="prototype">
     <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
@@ -145,20 +145,24 @@
 
   <!-- Messages -->
 
-  <bean id="org.hisp.dhis.light.message.action.GetMessagesAction" class="org.hisp.dhis.light.message.action.GetMessagesAction">
+  <bean id="org.hisp.dhis.light.message.action.GetMessagesAction"
+      class="org.hisp.dhis.light.message.action.GetMessagesAction" scope="prototype">
     <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
   </bean>
 
-  <bean id="org.hisp.dhis.light.message.action.GetMessageAction" class="org.hisp.dhis.light.message.action.GetMessageAction">
+  <bean id="org.hisp.dhis.light.message.action.GetMessageAction"
+      class="org.hisp.dhis.light.message.action.GetMessageAction" scope="prototype">
     <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
   </bean>
 
-  <bean id="org.hisp.dhis.light.message.action.SendReplyAction" class="org.hisp.dhis.light.message.action.SendReplyAction">
+  <bean id="org.hisp.dhis.light.message.action.SendReplyAction"
+      class="org.hisp.dhis.light.message.action.SendReplyAction" scope="prototype">
     <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
   </bean>
 
-  <bean id="org.hisp.dhis.light.message.action.SendFeedbackAction" class="org.hisp.dhis.light.message.action.SendFeedbackAction">
+  <bean id="org.hisp.dhis.light.message.action.SendFeedbackAction"
+      class="org.hisp.dhis.light.message.action.SendFeedbackAction" scope="prototype">
     <property name="messageService" ref="org.hisp.dhis.message.MessageService" />
   </bean>
 

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2012-01-22 19:37:21 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2012-01-23 09:28:45 +0000
@@ -17,11 +17,16 @@
     <action name="selectOrganisationUnit" class="org.hisp.dhis.light.dataentry.action.GetOrganisationUnitsAction">
       <result name="success" type="velocity">/dhis-web-light/main.vm</result>
       <param name="page">/dhis-web-light/selectOrganisationUnit.vm</param>
+
+      <result name="selectDataSet" type="redirect">/mobile/selectDataSet.action?organisationUnitId=${organisationUnitId}</result>
+      <result name="selectPeriod" type="redirect">/mobile/selectPeriod.action?organisationUnitId=${organisationUnitId}&amp;dataSetId=${dataSetId}</result>
     </action>
 
     <action name="selectDataSet" class="org.hisp.dhis.light.dataentry.action.GetDataSetsAction">
       <result name="success" type="velocity">/dhis-web-light/main.vm</result>
       <param name="page">/dhis-web-light/selectDataSet.vm</param>
+
+      <result name="selectPeriod" type="redirect">/mobile/selectPeriod.action?organisationUnitId=${organisationUnitId}&amp;dataSetId=${dataSetId}</result>
     </action>
 
     <action name="selectPeriod" class="org.hisp.dhis.light.dataentry.action.GetPeriodsAction">