=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-09-21 12:46:20 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java 2011-10-13 15:15:00 +0000 @@ -62,11 +62,11 @@ private String firstName; private String email; - + private String phoneNumber; private UserCredentials userCredentials; - + /** * All OrgUnits where the user could belong * @@ -78,7 +78,7 @@ * Set of the dynamic attributes values that belong to this dataElement. */ private Set attributeValues = new HashSet(); - + // ------------------------------------------------------------------------- // hashCode and equals // ------------------------------------------------------------------------- @@ -90,7 +90,7 @@ int result = 1; result = result * prime + surname.hashCode(); - result = result * prime + firstName.hashCode(); + result = result * prime + firstName.hashCode(); return result; } @@ -115,10 +115,9 @@ final User other = (User) o; - return surname.equals( other.getSurname() ) - && firstName.equals( other.getFirstName() ); + return surname.equals( other.getSurname() ) && firstName.equals( other.getFirstName() ); } - + @Override public String toString() { @@ -134,13 +133,13 @@ organisationUnits.add( unit ); unit.getUsers().add( this ); } - + public void removeOrganisationUnit( OrganisationUnit unit ) { organisationUnits.remove( unit ); unit.getUsers().remove( this ); } - + public void updateOrganisationUnits( Set updates ) { for ( OrganisationUnit unit : new HashSet( organisationUnits ) ) @@ -150,13 +149,13 @@ removeOrganisationUnit( unit ); } } - + for ( OrganisationUnit unit : updates ) { addOrganisationUnit( unit ); } } - + /** * Returns the concatenated first name and surname. */ @@ -164,11 +163,12 @@ { return firstName + " " + surname; } - + /** - * Returns the first of the organisation units associated with the user. Null - * is returned if the user has no organisation units. Which organisation unit - * to return is undefined if the user has multiple organisation units. + * Returns the first of the organisation units associated with the user. + * Null is returned if the user has no organisation units. Which + * organisation unit to return is undefined if the user has multiple + * organisation units. * * @return an organisation unit associated with the user. */ @@ -176,22 +176,22 @@ { return CollectionUtils.isEmpty( organisationUnits ) ? null : organisationUnits.iterator().next(); } - + public boolean hasOrganisationUnit() { return !CollectionUtils.isEmpty( organisationUnits ); } - + public String getOrganisationUnitsName() { return IdentifiableObjectUtils.join( organisationUnits ); } - + public String getUsername() { return userCredentials != null ? userCredentials.getUsername() : null; } - + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- @@ -215,7 +215,7 @@ { this.firstName = firstName; } - + public String getSurname() { return surname; === 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 2011-04-24 08:46:21 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/oust/action/RemoveSelectedOrganisationUnitAction.java 2011-10-13 15:15:00 +0000 @@ -122,7 +122,12 @@ if ( id != null ) { OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); - selectedUnits.remove( unit ); + + // TODO fix this, not pretty, but selectionTreeManager is not + // correctly handling adding/removing selected orgunits + while ( selectedUnits.remove( unit ) ) + { + } } if ( level != null ) @@ -132,8 +137,8 @@ if ( organisationUnitGroupId != null ) { - selectedUnits.removeAll( organisationUnitGroupService - .getOrganisationUnitGroup( organisationUnitGroupId ).getMembers() ); + selectedUnits.removeAll( organisationUnitGroupService.getOrganisationUnitGroup( organisationUnitGroupId ) + .getMembers() ); } if ( children != null && children == true ) @@ -147,11 +152,11 @@ if ( !selectedOrganisationUnits.contains( parent ) ) { - selectedUnits.removeAll( organisationUnitService.getOrganisationUnitWithChildren( selected - .getId() ) ); - - selectedUnits.add( selected ); - } + selectedUnits + .removeAll( organisationUnitService.getOrganisationUnitWithChildren( selected.getId() ) ); + + selectedUnits.add( selected ); + } } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java 2011-09-22 10:32:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/UpdateUserAction.java 2011-10-13 15:15:00 +0000 @@ -217,7 +217,7 @@ userCredentials.setPassword( passwordManager.encodePassword( userCredentials.getUsername(), rawPassword ) ); } - if ( jsonAttributeValues != null) + if ( jsonAttributeValues != null ) { AttributeUtils.updateAttributeValuesFromJson( user.getAttributeValues(), jsonAttributeValues, attributeService ); @@ -226,6 +226,12 @@ userService.updateUserCredentials( userCredentials ); userService.updateUser( user ); + selectionManager.setRootOrganisationUnits( units ); + selectionManager.setSelectedOrganisationUnits( units ); + + selectionTreeManager.setRootOrganisationUnits( units ); + selectionTreeManager.setSelectedOrganisationUnits( units ); + if ( units.size() > 0 ) { selectionManager.setSelectedOrganisationUnits( units );