← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7337: add orgunit to user if parent is null

 

------------------------------------------------------------
revno: 7337
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-06-20 22:38:02 +0300
message:
  add orgunit to user if parent is null
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.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-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2012-06-20 18:52:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2012-06-20 19:38:02 +0000
@@ -96,6 +96,13 @@
     @Override
     public int addOrganisationUnit( OrganisationUnit organisationUnit )
     {
+        if(organisationUnit.getParent() == null)
+        {
+            // we are adding a new root node, add this node to the current user
+            // this makes sense in most cases, and makes sure that we don't have "zombie nodes"
+            currentUserService.getCurrentUser().getOrganisationUnits().add( organisationUnit );
+        }
+
         int id = organisationUnitStore.save( organisationUnit );
 
         log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_ADD,