=== 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 organisationUnits = new ArrayList(); + + public List 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( 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"> + + + + + + + + + + + class="org.hisp.dhis.light.anonymous.action.SearchOrgUnitAction"> /light/anonymous.action?orgUnitId=${orgUnitId} /dhis-web-light/main.vm /dhis-web-light/anonymous/selectAnonymousOrgUnit.vm === 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 @@

$i18n.getString( "select_organisation_unit" )

+
+
+

+ + +

+

+ +

+
+

    #foreach( $organisationUnit in $organisationUnits )