=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2016-01-05 12:17:59 +0000 @@ -127,7 +127,7 @@ /** * Selection mode for the specified organisation units, default is ACCESSIBLE. */ - private OrganisationUnitSelectionMode organisationUnitMode = OrganisationUnitSelectionMode.ACCESSIBLE; + private OrganisationUnitSelectionMode organisationUnitMode = OrganisationUnitSelectionMode.DESCENDANTS; /** * Status of any events in the specified program. === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2016-01-04 02:27:49 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2016-01-05 12:17:59 +0000 @@ -43,7 +43,6 @@ import org.hisp.dhis.system.util.ValidationUtils; import org.springframework.beans.factory.annotation.Autowired; -import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.HashSet; @@ -188,21 +187,21 @@ this.phoneNumber = phoneNumber; } - private Collection dataSets = new HashSet<>(); + private Collection dataSets; public void setDataSets( Collection dataSets ) { this.dataSets = dataSets; } - private List orgUnitGroupSets = new ArrayList<>(); + private List orgUnitGroupSets; public void setOrgUnitGroupSets( List orgUnitGroupSets ) { this.orgUnitGroupSets = orgUnitGroupSets; } - private List orgUnitGroups = new ArrayList<>(); + private List orgUnitGroups; public void setOrgUnitGroups( List orgUnitGroups ) { @@ -287,37 +286,43 @@ organisationUnit.setFeatureType( featureType ); } - Set sets = new HashSet<>(); - - for ( String id : dataSets ) + if ( dataSets != null ) { - sets.add( manager.getNoAcl( DataSet.class, Integer.parseInt( id ) ) ); + Set sets = new HashSet<>(); + + for ( String id : dataSets ) + { + sets.add( manager.getNoAcl( DataSet.class, Integer.parseInt( id ) ) ); + } + + organisationUnit.updateDataSets( sets ); } - organisationUnit.updateDataSets( sets ); - organisationUnitService.updateOrganisationUnit( organisationUnit ); - for ( int i = 0; i < orgUnitGroupSets.size(); i++ ) + if ( orgUnitGroupSets != null && orgUnitGroups != null ) { - OrganisationUnitGroupSet groupSet = manager.getNoAcl( OrganisationUnitGroupSet.class, Integer - .parseInt( orgUnitGroupSets.get( i ) ) ); - - OrganisationUnitGroup oldGroup = groupSet.getGroup( organisationUnit ); - - OrganisationUnitGroup newGroup = manager.getNoAcl( OrganisationUnitGroup.class, Integer - .parseInt( orgUnitGroups.get( i ) ) ); - - if ( oldGroup != null && oldGroup.getMembers().remove( organisationUnit ) ) - { - oldGroup.removeOrganisationUnit( organisationUnit ); - manager.updateNoAcl( oldGroup ); - } - - if ( newGroup != null && newGroup.getMembers().add( organisationUnit ) ) - { - newGroup.addOrganisationUnit( organisationUnit ); - manager.updateNoAcl( newGroup ); + for ( int i = 0; i < orgUnitGroupSets.size(); i++ ) + { + OrganisationUnitGroupSet groupSet = manager.getNoAcl( OrganisationUnitGroupSet.class, Integer + .parseInt( orgUnitGroupSets.get( i ) ) ); + + OrganisationUnitGroup oldGroup = groupSet.getGroup( organisationUnit ); + + OrganisationUnitGroup newGroup = manager.getNoAcl( OrganisationUnitGroup.class, Integer + .parseInt( orgUnitGroups.get( i ) ) ); + + if ( oldGroup != null && oldGroup.getMembers().remove( organisationUnit ) ) + { + oldGroup.removeOrganisationUnit( organisationUnit ); + manager.updateNoAcl( oldGroup ); + } + + if ( newGroup != null && newGroup.getMembers().add( organisationUnit ) ) + { + newGroup.addOrganisationUnit( organisationUnit ); + manager.updateNoAcl( newGroup ); + } } }