dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12362
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3788: Impl proper handling of OrganisationUnit-OrganisationUnitGroup association. Will do it consistenl...
------------------------------------------------------------
revno: 3788
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-05-30 14:43:38 +0200
message:
Impl proper handling of OrganisationUnit-OrganisationUnitGroup association. Will do it consistenly for all bidirectional associations.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java
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/organisationunitgroup/AddOrganisationUnitGroupAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/UpdateOrganisationUnitGroupAction.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/organisationunit/OrganisationUnitGroup.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java 2011-05-05 21:14:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroup.java 2011-05-30 12:43:38 +0000
@@ -63,6 +63,38 @@
}
// -------------------------------------------------------------------------
+ // Logic
+ // -------------------------------------------------------------------------
+
+ public void addOrganisationUnit( OrganisationUnit unit )
+ {
+ members.add( unit );
+ unit.getGroups().add( this );
+ }
+
+ public void removeOrganisationUnit( OrganisationUnit unit )
+ {
+ members.remove( unit );
+ unit.getGroups().remove( this );
+ }
+
+ public void updateOrganisationUnits( Set<OrganisationUnit> units )
+ {
+ for ( OrganisationUnit unit : members )
+ {
+ if ( !units.contains( unit ) )
+ {
+ removeOrganisationUnit( unit );
+ }
+ }
+
+ for ( OrganisationUnit unit : units )
+ {
+ addOrganisationUnit( unit );
+ }
+ }
+
+ // -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2011-05-28 18:05:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/AddOrganisationUnitAction.java 2011-05-30 12:43:38 +0000
@@ -46,8 +46,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: AddOrganisationUnitAction.java 1898 2006-09-22 12:06:56Z
- * torgeilo $
*/
public class AddOrganisationUnitAction
implements Action
@@ -279,8 +277,7 @@
if ( group != null )
{
- group.getMembers().add( organisationUnit );
- organisationUnit.getGroups().add( group );
+ group.addOrganisationUnit( organisationUnit );
organisationUnitGroupService.updateOrganisationUnitGroup( group );
}
}
=== 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 2011-05-28 18:05:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/UpdateOrganisationUnitAction.java 2011-05-30 12:43:38 +0000
@@ -48,8 +48,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: UpdateOrganisationUnitAction.java 1898 2006-09-22 12:06:56Z
- * torgeilo $
*/
public class UpdateOrganisationUnitAction
implements Action
@@ -302,13 +300,13 @@
if ( oldGroup != null && oldGroup.getMembers().remove( organisationUnit ) )
{
- organisationUnit.getGroups().remove( oldGroup );
+ oldGroup.removeOrganisationUnit( organisationUnit );
organisationUnitGroupService.updateOrganisationUnitGroup( oldGroup );
}
if ( newGroup != null && newGroup.getMembers().add( organisationUnit ) )
{
- organisationUnit.getGroups().add( newGroup );
+ newGroup.addOrganisationUnit( organisationUnit );
organisationUnitGroupService.updateOrganisationUnitGroup( newGroup );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/AddOrganisationUnitGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/AddOrganisationUnitGroupAction.java 2010-05-17 16:13:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/AddOrganisationUnitGroupAction.java 2011-05-30 12:43:38 +0000
@@ -28,7 +28,6 @@
*/
import java.util.Collection;
-import java.util.HashSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
@@ -39,8 +38,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: AddOrganisationUnitGroupAction.java 1898 2006-09-22 12:06:56Z
- * torgeilo $
*/
@SuppressWarnings("serial")
public class AddOrganisationUnitGroupAction
@@ -86,8 +83,11 @@
Collection<OrganisationUnit> selectedOrganisationUnits = selectionTreeManager.getReloadedSelectedOrganisationUnits();
- organisationUnitGroup.setMembers( new HashSet<OrganisationUnit>( selectedOrganisationUnits ) );
-
+ for ( OrganisationUnit unit : selectedOrganisationUnits )
+ {
+ organisationUnitGroup.addOrganisationUnit( unit );
+ }
+
organisationUnitGroupService.addOrganisationUnitGroup( organisationUnitGroup );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/UpdateOrganisationUnitGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/UpdateOrganisationUnitGroupAction.java 2010-05-17 16:13:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/UpdateOrganisationUnitGroupAction.java 2011-05-30 12:43:38 +0000
@@ -39,8 +39,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: UpdateOrganisationUnitGroupAction.java 1898 2006-09-22
- * 12:06:56Z torgeilo $
*/
@SuppressWarnings("serial")
public class UpdateOrganisationUnitGroupAction
@@ -95,7 +93,7 @@
Collection<OrganisationUnit> selectedOrganisationUnits = selectionTreeManager.getReloadedSelectedOrganisationUnits();
- organisationUnitGroup.setMembers( new HashSet<OrganisationUnit>( selectedOrganisationUnits ) );
+ organisationUnitGroup.updateOrganisationUnits( new HashSet<OrganisationUnit>( selectedOrganisationUnits ) );
organisationUnitGroupService.updateOrganisationUnitGroup( organisationUnitGroup );