← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21587: Fixed bug. Org units were unassigned from data set and groups when form controles were hidden.

 

------------------------------------------------------------
revno: 21587
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-01-05 13:17:59 +0100
message:
  Fixed bug. Org units were unassigned from data set and groups when form controles were hidden.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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<String> dataSets = new HashSet<>();
+    private Collection<String> dataSets;
 
     public void setDataSets( Collection<String> dataSets )
     {
         this.dataSets = dataSets;
     }
 
-    private List<String> orgUnitGroupSets = new ArrayList<>();
+    private List<String> orgUnitGroupSets;
 
     public void setOrgUnitGroupSets( List<String> orgUnitGroupSets )
     {
         this.orgUnitGroupSets = orgUnitGroupSets;
     }
 
-    private List<String> orgUnitGroups = new ArrayList<>();
+    private List<String> orgUnitGroups;
 
     public void setOrgUnitGroups( List<String> orgUnitGroups )
     {
@@ -287,37 +286,43 @@
             organisationUnit.setFeatureType( featureType );
         }
 
-        Set<DataSet> sets = new HashSet<>();
-
-        for ( String id : dataSets )
+        if ( dataSets != null )
         {
-            sets.add( manager.getNoAcl( DataSet.class, Integer.parseInt( id ) ) );
+            Set<DataSet> 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 );
+                }
             }
         }