dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23940
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11674: Minor fix related to org unit level calculation
------------------------------------------------------------
revno: 11674
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-08-15 16:09:04 +0200
message:
Minor fix related to org unit level calculation
modified:
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/hibernate/HibernateOrganisationUnitLevelStore.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/DefaultAppManagerServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.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 2013-08-15 11:30:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2013-08-15 14:09:04 +0000
@@ -437,17 +437,13 @@
if ( level == parentLevel )
{
+ parent.setLevel( level );
result.add( parent );
}
else
{
addOrganisationUnitChildrenAtLevel( parent, parentLevel + 1, level, result );
}
-
- for ( OrganisationUnit unit : result )
- {
- unit.setLevel( level );
- }
}
}
@@ -464,7 +460,11 @@
{
if ( currentLevel == targetLevel )
{
- result.addAll( parent.getChildren() );
+ for ( OrganisationUnit child : parent.getChildren() )
+ {
+ child.setLevel( currentLevel );
+ result.add( child );
+ }
}
else
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitLevelStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitLevelStore.java 2013-08-12 09:30:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitLevelStore.java 2013-08-15 14:09:04 +0000
@@ -27,8 +27,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/DefaultAppManagerServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/DefaultAppManagerServiceTest.java 2013-05-23 00:18:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/appmanager/DefaultAppManagerServiceTest.java 2013-08-15 14:09:04 +0000
@@ -107,8 +107,8 @@
{
System.out.println( "getInstalledApps" );
DefaultAppManagerService instance = new DefaultAppManagerService();
- List expResult = null;
- List result = instance.getInstalledApps();
+ List<App> expResult = null;
+ List<App> result = instance.getInstalledApps();
assertEquals( expResult, result );
// TODO review the generated test code and remove the default call to fail.
fail( "The test case is a prototype." );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java 2013-08-14 19:22:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java 2013-08-15 14:09:04 +0000
@@ -345,6 +345,14 @@
assertTrue( equals( organisationUnitService.getOrganisationUnitsAtLevel( 3, unitB ), unitD, unitE ) );
assertTrue( equals( organisationUnitService.getOrganisationUnitsAtLevel( 4, unitB ), unitH, unitI, unitJ, unitK ) );
assertTrue( equals( organisationUnitService.getOrganisationUnitsAtLevel( 2, nill ), unitB, unitC ) );
+
+ assertEquals( 2, unitB.getLevel() );
+ assertEquals( 3, unitD.getLevel() );
+ assertEquals( 3, unitE.getLevel() );
+ assertEquals( 4, unitH.getLevel() );
+ assertEquals( 4, unitI.getLevel() );
+ assertEquals( 4, unitJ.getLevel() );
+ assertEquals( 4, unitK.getLevel() );
}
@Test
@@ -407,6 +415,14 @@
assertTrue( equals( organisationUnitService.getOrganisationUnitsAtLevel( 4, unitsA ), unitH, unitI, unitJ, unitK, unitL, unitM, unitN, unitO ) );
assertTrue( equals( organisationUnitService.getOrganisationUnitsAtLevel( 4, unitsB ), unitH, unitI, unitJ, unitK ) );
assertTrue( equals( organisationUnitService.getOrganisationUnitsAtLevel( 2, nill ), unitB, unitC ) );
+
+ assertEquals( 2, unitB.getLevel() );
+ assertEquals( 3, unitD.getLevel() );
+ assertEquals( 3, unitE.getLevel() );
+ assertEquals( 4, unitH.getLevel() );
+ assertEquals( 4, unitI.getLevel() );
+ assertEquals( 4, unitJ.getLevel() );
+ assertEquals( 4, unitK.getLevel() );
}
@Test