=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2010-12-12 17:09:27 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java 2010-12-12 18:39:35 +0000 @@ -183,8 +183,7 @@ } } - return query.list(); - + return query.list(); } // ------------------------------------------------------------------------- === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/GetCompulsoryGroupSetsAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/GetCompulsoryGroupSetsAction.java 2010-12-12 17:09:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/GetCompulsoryGroupSetsAction.java 1970-01-01 00:00:00 +0000 @@ -1,68 +0,0 @@ -package org.hisp.dhis.oum.action.search; - -/* - * Copyright (c) 2004-2010, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; -import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator; - -import com.opensymphony.xwork2.Action; - -/** - * @author Lars Helge Overland - */ -public class GetCompulsoryGroupSetsAction - implements Action -{ - private OrganisationUnitGroupService organisationUnitGroupService; - - public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) - { - this.organisationUnitGroupService = organisationUnitGroupService; - } - - private List groupSets; - - public List getGroupSets() - { - return groupSets; - } - - public String execute() - { - groupSets = new ArrayList( organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets() ); - - Collections.sort( groupSets, new OrganisationUnitGroupSetNameComparator() ); - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/SearchOrganisationUnitsAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/SearchOrganisationUnitsAction.java 2010-12-12 17:09:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/search/SearchOrganisationUnitsAction.java 2010-12-12 18:39:35 +0000 @@ -27,13 +27,20 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; +import java.util.List; +import org.apache.commons.lang.StringUtils; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupSetNameComparator; +import org.springframework.util.CollectionUtils; import com.opensymphony.xwork2.Action; @@ -43,7 +50,7 @@ public class SearchOrganisationUnitsAction implements Action { - private static final int ANY = -1; + private static final int ANY = 0; // ------------------------------------------------------------------------- // Depdencies @@ -64,34 +71,51 @@ } // ------------------------------------------------------------------------- - // Input + // Input and output // ------------------------------------------------------------------------- private String name; + public String getName() + { + return name; + } + public void setName( String name ) { this.name = name; } - private Collection group = new HashSet(); - - public void setGroup( Collection group ) - { - this.group = group; + private Collection groupId = new HashSet(); + + public Collection getGroupId() + { + return groupId; + } + + public void setGroupId( Collection groupId ) + { + this.groupId = groupId; } // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- + private List groupSets; + + public List getGroupSets() + { + return groupSets; + } + private Collection organisationUnits; public Collection getOrganisationUnits() { return organisationUnits; } - + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -99,18 +123,33 @@ public String execute() throws Exception { - Collection groups = new HashSet(); - - for ( Integer id : group ) + // --------------------------------------------------------------------- + // Assemble groups and get search result + // --------------------------------------------------------------------- + + if ( StringUtils.isNotBlank( name ) || !CollectionUtils.isEmpty( groupId ) ) { - if ( id != ANY ) + Collection groups = new HashSet(); + + for ( Integer id : groupId ) { - OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup( id ); - groups.add( group ); + if ( id != ANY ) + { + OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup( id ); + groups.add( group ); + } } + + organisationUnits = organisationUnitService.getOrganisationUnitsByNameAndGroups( name, groups ); } + + // --------------------------------------------------------------------- + // Get group sets + // --------------------------------------------------------------------- - organisationUnits = organisationUnitService.getOrganisationUnitsByNameAndGroups( name, groups ); + groupSets = new ArrayList( organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets() ); + + Collections.sort( groupSets, new OrganisationUnitGroupSetNameComparator() ); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2010-12-12 17:09:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/META-INF/dhis/beans.xml 2010-12-12 18:39:35 +0000 @@ -315,14 +315,6 @@ - - - - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2010-12-12 17:09:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/resources/struts.xml 2010-12-12 18:39:35 +0000 @@ -297,17 +297,12 @@ + class="org.hisp.dhis.oum.action.search.SearchOrganisationUnitsAction"> /main.vm /dhis-web-maintenance-organisationunit/organisationUnitSearch.vm /dhis-web-maintenance-organisationunit/menu.vm - - organisationUnitSearch - - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm 2010-12-12 17:09:27 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/organisationUnitSearch.vm 2010-12-12 18:39:35 +0000 @@ -1,7 +1,7 @@

$i18n.getString( "org_unit_search_management" )

-
+ @@ -10,30 +10,33 @@ + #foreach( $groupSet in $groupSets ) #end - + - +
$i18n.getString( "criteria" )
$i18n.getString( "name" ) -
$encoder.htmlEncode( $groupSet.name ) - + + #foreach( $group in $groupSet.organisationUnitGroups ) + + #end
+