=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/AddSelectedOrganisationUnitAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/AddSelectedOrganisationUnitAction.java 2010-10-07 08:40:58 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/AddSelectedOrganisationUnitAction.java 2011-04-24 08:46:21 +0000 @@ -30,8 +30,6 @@ import java.util.Collection; import java.util.HashSet; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitService; @@ -47,8 +45,6 @@ public class AddSelectedOrganisationUnitAction implements Action { - private static final Log LOG = LogFactory.getLog( AddSelectedOrganisationUnitAction.class ); - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -120,43 +116,34 @@ public String execute() throws Exception { - try - { - selectedUnits = new HashSet( selectionTreeManager.getSelectedOrganisationUnits() ); - - if ( id != null ) - { - OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); - selectedUnits.add( unit ); - } - - if ( level != null ) - { - selectedUnits.addAll( organisationUnitService.getOrganisationUnitsAtLevel( level ) ); - } - - if ( organisationUnitGroupId != null ) - { - selectedUnits.addAll( organisationUnitGroupService.getOrganisationUnitGroup( organisationUnitGroupId ) - .getMembers() ); - } - - if ( children != null && children == true ) - { - for ( OrganisationUnit selected : selectionTreeManager.getSelectedOrganisationUnits() ) - { - selectedUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( selected.getId() ) ); - } - } - - selectionTreeManager.setSelectedOrganisationUnits( selectedUnits ); - } - catch ( Exception e ) - { - LOG.error( e.getMessage(), e ); - - throw e; - } + selectedUnits = new HashSet( selectionTreeManager.getSelectedOrganisationUnits() ); + + if ( id != null ) + { + OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); + selectedUnits.add( unit ); + } + + if ( level != null ) + { + selectedUnits.addAll( organisationUnitService.getOrganisationUnitsAtLevel( level ) ); + } + + if ( organisationUnitGroupId != null ) + { + selectedUnits.addAll( organisationUnitGroupService.getOrganisationUnitGroup( organisationUnitGroupId ) + .getMembers() ); + } + + if ( children != null && children == true ) + { + for ( OrganisationUnit selected : selectionTreeManager.getSelectedOrganisationUnits() ) + { + selectedUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( selected.getId() ) ); + } + } + + selectionTreeManager.setSelectedOrganisationUnits( selectedUnits ); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/ClearSelectedOrganisationUnitsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/ClearSelectedOrganisationUnitsAction.java 2010-04-28 04:59:07 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/ClearSelectedOrganisationUnitsAction.java 2011-04-24 08:46:21 +0000 @@ -53,6 +53,7 @@ // ------------------------------------------------------------------------- // Output // ------------------------------------------------------------------------- + private String message; public String getMessage() @@ -63,6 +64,7 @@ // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- + public String execute() { try @@ -80,5 +82,4 @@ return SUCCESS; } - } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/ExpandSubtreeAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/ExpandSubtreeAction.java 2011-02-15 13:45:11 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/ExpandSubtreeAction.java 2011-04-24 08:46:21 +0000 @@ -28,16 +28,12 @@ */ import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator; import com.opensymphony.xwork2.Action; @@ -48,8 +44,6 @@ public class ExpandSubtreeAction implements Action { - private static final Log LOG = LogFactory.getLog( ExpandSubtreeAction.class ); - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -97,23 +91,14 @@ public String execute() throws Exception { - try - { - OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentId ); - - if ( parent == null ) - { - throw new RuntimeException( "OrganisationUnit with id " + parentId + " doesn't exist" ); - } - - addParentWithChildren( parent ); - } - catch ( Exception e ) - { - LOG.error( e.getMessage(), e ); - - throw e; - } + OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentId ); + + if ( parent == null ) + { + throw new RuntimeException( "OrganisationUnit with id " + parentId + " doesn't exist" ); + } + + addParentWithChildren( parent ); return SUCCESS; } @@ -121,27 +106,10 @@ private void addParentWithChildren( OrganisationUnit parent ) throws Exception { - List children = getChildren( parent ); + List children = parent.getSortedChildren(); parents.add( parent ); childrenMap.put( parent, children ); - - for ( OrganisationUnit child : children ) - { - boolean hasChildren = child.getChildren().size() > 0; // Dirty - // loading - - LOG.debug( "OrganisationUnit " + child.getId() + " has children = " + hasChildren ); - } - } - - private final List getChildren( OrganisationUnit parent ) - { - List children = new ArrayList( parent.getChildren() ); - - Collections.sort( children, new OrganisationUnitNameComparator() ); - - return children; } } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/GetExpandedTreeAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/GetExpandedTreeAction.java 2011-02-15 13:45:11 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/GetExpandedTreeAction.java 2011-04-24 08:46:21 +0000 @@ -36,8 +36,6 @@ import java.util.Map; import java.util.Set; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator; import org.hisp.dhis.oust.manager.SelectionTreeManager; @@ -51,8 +49,6 @@ public class GetExpandedTreeAction implements Action { - private static final Log LOG = LogFactory.getLog( GetExpandedTreeAction.class ); - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -123,10 +119,6 @@ for ( OrganisationUnit root : roots ) { - boolean hasChildren = root.getChildren().size() > 0; // Dirty loading - - LOG.debug( "OrganisationUnit " + root.getId() + " has children = " + hasChildren ); - if ( pathNodes.contains( root ) ) { addParentWithChildren( root, pathNodes ); @@ -139,7 +131,7 @@ private void addParentWithChildren( OrganisationUnit parent, Collection pathNodes ) throws Exception { - List children = getChildren( parent ); + List children = parent.getSortedChildren(); parents.add( parent ); @@ -147,10 +139,6 @@ for ( OrganisationUnit child : children ) { - boolean hasChildren = child.getChildren().size() > 0; // Dirty loading - - LOG.debug( "OrganisationUnit " + child.getId() + " has children = " + hasChildren ); - if ( pathNodes.contains( child ) ) { addParentWithChildren( child, pathNodes ); @@ -158,15 +146,6 @@ } } - private final List getChildren( OrganisationUnit parent ) - { - List children = new ArrayList( parent.getChildren() ); - - Collections.sort( children, new OrganisationUnitNameComparator() ); - - return children; - } - private final Collection findPathNodes( Collection roots, Collection selected ) { === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/RemoveSelectedOrganisationUnitAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/RemoveSelectedOrganisationUnitAction.java 2010-10-07 08:40:58 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/RemoveSelectedOrganisationUnitAction.java 2011-04-24 08:46:21 +0000 @@ -31,8 +31,6 @@ import java.util.HashSet; import java.util.Set; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitService; @@ -48,8 +46,6 @@ public class RemoveSelectedOrganisationUnitAction implements Action { - private static final Log LOG = LogFactory.getLog( RemoveSelectedOrganisationUnitAction.class ); - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -121,54 +117,45 @@ public String execute() throws Exception { - try - { - selectedUnits = selectionTreeManager.getSelectedOrganisationUnits(); - - if ( id != null ) - { - OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); - selectedUnits.remove( unit ); - } - - if ( level != null ) - { - selectedUnits.removeAll( organisationUnitService.getOrganisationUnitsAtLevel( level ) ); - } - - if ( organisationUnitGroupId != null ) - { - selectedUnits.removeAll( organisationUnitGroupService - .getOrganisationUnitGroup( organisationUnitGroupId ).getMembers() ); - } - - if ( children != null && children == true ) - { - - Set selectedOrganisationUnits = new HashSet( selectedUnits ); - - for ( OrganisationUnit selected : selectedOrganisationUnits ) + selectedUnits = selectionTreeManager.getSelectedOrganisationUnits(); + + if ( id != null ) + { + OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); + selectedUnits.remove( unit ); + } + + if ( level != null ) + { + selectedUnits.removeAll( organisationUnitService.getOrganisationUnitsAtLevel( level ) ); + } + + if ( organisationUnitGroupId != null ) + { + selectedUnits.removeAll( organisationUnitGroupService + .getOrganisationUnitGroup( organisationUnitGroupId ).getMembers() ); + } + + if ( children != null && children == true ) + { + + Set selectedOrganisationUnits = new HashSet( selectedUnits ); + + for ( OrganisationUnit selected : selectedOrganisationUnits ) + { + OrganisationUnit parent = selected.getParent(); + + if ( !selectedOrganisationUnits.contains( parent ) ) { - OrganisationUnit parent = selected.getParent(); - - if ( !selectedOrganisationUnits.contains( parent ) ) - { - selectedUnits.removeAll( organisationUnitService.getOrganisationUnitWithChildren( selected - .getId() ) ); - - selectedUnits.add( selected ); - } - } + selectedUnits.removeAll( organisationUnitService.getOrganisationUnitWithChildren( selected + .getId() ) ); + + selectedUnits.add( selected ); + } } - - selectionTreeManager.setSelectedOrganisationUnits( selectedUnits ); - } - catch ( Exception e ) - { - LOG.error( e.getMessage(), e ); - - throw e; - } + } + + selectionTreeManager.setSelectedOrganisationUnits( selectedUnits ); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/SelectAllOrganisationUnitAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/SelectAllOrganisationUnitAction.java 2010-09-14 09:03:41 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/SelectAllOrganisationUnitAction.java 2011-04-24 08:46:21 +0000 @@ -82,5 +82,4 @@ return SUCCESS; } - } === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/SetSelectedOrganisationUnitAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/SetSelectedOrganisationUnitAction.java 2010-09-14 09:03:41 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/SetSelectedOrganisationUnitAction.java 2011-04-24 08:46:21 +0000 @@ -30,8 +30,6 @@ import java.util.Collection; import java.util.HashSet; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.oust.manager.SelectionTreeManager; @@ -45,8 +43,6 @@ public class SetSelectedOrganisationUnitAction implements Action { - private static final Log LOG = LogFactory.getLog( SetSelectedOrganisationUnitAction.class ); - // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -90,26 +86,16 @@ public String execute() throws Exception { - try - { - - OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); - - if ( unit == null ) - { - throw new RuntimeException( "OrganisationUnit with id " + id + " doesn't exist" ); - } - - selectedUnits = new HashSet( 1 ); - selectedUnits.add( unit ); - selectionTreeManager.setSelectedOrganisationUnits( selectedUnits ); - } - catch ( Exception e ) - { - LOG.error( e.getMessage(), e ); - - throw e; - } + OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); + + if ( unit == null ) + { + throw new RuntimeException( "OrganisationUnit with id " + id + " doesn't exist" ); + } + + selectedUnits = new HashSet( 1 ); + selectedUnits.add( unit ); + selectionTreeManager.setSelectedOrganisationUnits( selectedUnits ); return SUCCESS; } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupForm.vm 2011-03-16 16:52:50 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitGroupForm.vm 2011-04-24 08:46:21 +0000 @@ -17,7 +17,7 @@
- #organisationUnitSelectionTree( false, true, true ) + #organisationUnitSelectionTree( false, true, false )