← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10551: [mobile] support find orgunit with keyword

 

------------------------------------------------------------
revno: 10551
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Mon 2013-04-15 16:36:45 +0700
message:
  [mobile] support find orgunit with keyword
added:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/anonymous/action/SearchOrgUnitAction.java
modified:
  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/resources/struts.xml
  dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/anonymous/selectAnonymousOrgUnit.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
=== added file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/anonymous/action/SearchOrgUnitAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/anonymous/action/SearchOrgUnitAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/anonymous/action/SearchOrgUnitAction.java	2013-04-15 09:36:45 +0000
@@ -0,0 +1,87 @@
+package org.hisp.dhis.light.anonymous.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import com.opensymphony.xwork2.Action;
+
+public class SearchOrgUnitAction
+    implements Action
+{
+
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public OrganisationUnitService getOrganisationUnitService()
+    {
+        return organisationUnitService;
+    }
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    public CurrentUserService getCurrentUserService()
+    {
+        return currentUserService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input & Output
+    // -------------------------------------------------------------------------
+
+    private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
+
+    public List<OrganisationUnit> getOrganisationUnits()
+    {
+        return organisationUnits;
+    }
+
+    private String keyword;
+
+    public String getKeyword()
+    {
+        return keyword;
+    }
+
+    public void setKeyword( String keyword )
+    {
+        this.keyword = keyword;
+    }
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        User user = currentUserService.getCurrentUser();
+
+        if ( keyword == null )
+            keyword = "";
+
+        if ( user != null )
+        {
+            organisationUnits = new ArrayList<OrganisationUnit>( user.getOrganisationUnits() );
+            organisationUnitService.searchOrganisationUnitByName( organisationUnits, keyword );
+            Collections.sort( organisationUnits, IdentifiableObjectNameComparator.INSTANCE );
+        }
+
+        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	2013-03-29 07:39:49 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/META-INF/dhis/beans.xml	2013-04-15 09:36:45 +0000
@@ -530,6 +530,17 @@
 		class="org.hisp.dhis.light.message.action.SendFeedbackAction" scope="prototype">
 		<property name="messageService" ref="org.hisp.dhis.message.MessageService" />
 	</bean>
+	
+	<!-- Anonymous -->
+	
+	<bean
+		id="org.hisp.dhis.light.anonymous.action.SearchOrgUnitAction"
+		class="org.hisp.dhis.light.anonymous.action.SearchOrgUnitAction"
+		scope="prototype">
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+	</bean>
+	
 	<bean
 		id="org.hisp.dhis.light.anonymous.action.GetAllAnonymousProgramAction"
 		class="org.hisp.dhis.light.anonymous.action.GetAllAnonymousProgramAction"

=== 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	2013-03-21 06:01:22 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/org/hisp/dhis/light/i18n_module.properties	2013-04-15 09:36:45 +0000
@@ -130,3 +130,4 @@
 allow_provided_elsewhere=Provided elsewhere
 search_user=Search user by name
 last_recipients=Last recipients
+search_orgunit=Search Organisation Unit
\ No newline at end of file

=== 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	2013-03-20 04:29:27 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/resources/struts.xml	2013-04-15 09:36:45 +0000
@@ -500,8 +500,11 @@
 
     <!-- Anonymous -->
     
+    <!-- <action name="selectAnonymousOrgUnit"
+        class="org.hisp.dhis.light.beneficiaryregistration.action.GetBeneficiaryRegistrationOrganisationUnitAction"> -->
+        
     <action name="selectAnonymousOrgUnit"
-        class="org.hisp.dhis.light.beneficiaryregistration.action.GetBeneficiaryRegistrationOrganisationUnitAction">
+        class="org.hisp.dhis.light.anonymous.action.SearchOrgUnitAction">
 	  <result name="redirect" type="redirect">/light/anonymous.action?orgUnitId=${orgUnitId}</result>	
       <result name="success" type="velocity">/dhis-web-light/main.vm</result>
       <param name="page">/dhis-web-light/anonymous/selectAnonymousOrgUnit.vm</param>

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/anonymous/selectAnonymousOrgUnit.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/anonymous/selectAnonymousOrgUnit.vm	2013-03-18 08:17:23 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/anonymous/selectAnonymousOrgUnit.vm	2013-04-15 09:36:45 +0000
@@ -1,4 +1,15 @@
 <h2>$i18n.getString( "select_organisation_unit" )</h2>
+<form action="selectAnonymousOrgUnit.action" method="POST">
+<div class="header-box" align="center">
+<p style="text-align: left;">
+	<label>$i18n.getString( "search_orgunit" )</label>
+	<input type="text" name="keyword" value="" style="width: 100%;"/>
+</p>
+<p>
+	<input type="submit" style="width: 100%;" value="$i18n.getString("search")" />
+</p>
+</div>
+</form>
 <p>
 <ul>
 #foreach( $organisationUnit in $organisationUnits )