=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTarget.java' --- local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTarget.java 2011-04-27 17:15:13 +0000 +++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/detarget/DeTarget.java 2011-06-17 10:57:52 +0000 @@ -145,6 +145,38 @@ return "[" + name + "]"; } + + // ------------------------------------------------------------------------- + // Logic + // ------------------------------------------------------------------------- + + public void addOrganisationUnit( OrganisationUnit unit ) + { + sources.add( unit ); + } + + public void removeOrganisationUnit( OrganisationUnit unit ) + { + sources.remove( unit ); + } + + public void updateOrganisationUnits( Set updates ) + { + for ( OrganisationUnit unit : new HashSet( sources ) ) + { + if ( !updates.contains( unit ) ) + { + removeOrganisationUnit( unit ); + } + } + + for ( OrganisationUnit unit : updates ) + { + addOrganisationUnit( unit ); + } + } + + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- === modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/Report_in.java' --- local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/Report_in.java 2011-04-27 17:15:13 +0000 +++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/reports/Report_in.java 2011-06-17 10:57:52 +0000 @@ -166,6 +166,40 @@ return name.equals( other.getName() ); } + + // ------------------------------------------------------------------------- + // Logic + // ------------------------------------------------------------------------- + + public void addOrganisationUnit( OrganisationUnit unit ) + { + sources.add( unit ); + } + + public void removeOrganisationUnit( OrganisationUnit unit ) + { + sources.remove( unit ); + } + + public void updateOrganisationUnits( Set updates ) + { + for ( OrganisationUnit unit : new HashSet( sources ) ) + { + if ( !updates.contains( unit ) ) + { + removeOrganisationUnit( unit ); + } + } + + for ( OrganisationUnit unit : updates ) + { + addOrganisationUnit( unit ); + } + } + + + + // ------------------------------------------------------------------------- // Getters and setters // ------------------------------------------------------------------------- === modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/survey/Survey.java' --- local/in/dhis-in-api/src/main/java/org/hisp/dhis/survey/Survey.java 2011-04-27 17:15:13 +0000 +++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/survey/Survey.java 2011-06-17 10:57:52 +0000 @@ -140,6 +140,37 @@ return "[" + name + "]"; } + + // ------------------------------------------------------------------------- + // Logic + // ------------------------------------------------------------------------- + + public void addOrganisationUnit( OrganisationUnit unit ) + { + sources.add( unit ); + } + + public void removeOrganisationUnit( OrganisationUnit unit ) + { + sources.remove( unit ); + } + + public void updateOrganisationUnits( Set updates ) + { + for ( OrganisationUnit unit : new HashSet( sources ) ) + { + if ( !updates.contains( unit ) ) + { + removeOrganisationUnit( unit ); + } + } + + for ( OrganisationUnit unit : updates ) + { + addOrganisationUnit( unit ); + } + } + // ------------------------------------------------------------------------- // Getters and setters // -------------------------------------------------------------------------