dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #18336
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7690: disable OU-level filtering in OUWT if OU-levels have not been generated
------------------------------------------------------------
revno: 7690
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-07-24 12:23:00 +0200
message:
disable OU-level filtering in OUWT if OU-levels have not been generated
modified:
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.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-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2012-07-24 09:56:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2012-07-24 10:23:00 +0000
@@ -173,34 +173,38 @@
organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( unit.getId() ) );
}
- OrganisationUnitLevel offlineOrganisationUnitLevel = configurationService.getConfiguration().getOfflineOrganisationUnitLevel();
-
- int size = organisationUnitService.getOrganisationUnitLevels().size();
-
- if ( offlineOrganisationUnitLevel == null )
- {
- offlineOrganisationUnitLevel = organisationUnitService.getOrganisationUnitLevelByLevel( size );
- }
-
- int minLevel = rootOrganisationUnits.get( 0 ).getLevel();
- int maxLevel = organisationUnitService.getOrganisationUnitLevelByLevel( size ).getLevel();
- int total = minLevel + offlineOrganisationUnitLevel.getLevel() - 1;
-
- if ( total > offlineOrganisationUnitLevel.getLevel() )
- {
- total = maxLevel;
- }
-
- final int finalTotal = total;
-
- CollectionUtils.filter( organisationUnits, new Predicate<OrganisationUnit>()
- {
- @Override
- public boolean evaluate( OrganisationUnit organisationUnit )
- {
- return organisationUnit.getLevel() <= finalTotal;
- }
- } );
+ // only try OU-level filtering if there are any levels available
+ if ( !organisationUnitService.getOrganisationUnitLevels().isEmpty() )
+ {
+ OrganisationUnitLevel offlineOrganisationUnitLevel = configurationService.getConfiguration().getOfflineOrganisationUnitLevel();
+
+ int size = organisationUnitService.getOrganisationUnitLevels().size();
+
+ if ( offlineOrganisationUnitLevel == null )
+ {
+ offlineOrganisationUnitLevel = organisationUnitService.getOrganisationUnitLevelByLevel( size );
+ }
+
+ int minLevel = rootOrganisationUnits.get( 0 ).getLevel();
+ int maxLevel = organisationUnitService.getOrganisationUnitLevelByLevel( size ).getLevel();
+ int total = minLevel + offlineOrganisationUnitLevel.getLevel() - 1;
+
+ if ( total > offlineOrganisationUnitLevel.getLevel() )
+ {
+ total = maxLevel;
+ }
+
+ final int finalTotal = total;
+
+ CollectionUtils.filter( organisationUnits, new Predicate<OrganisationUnit>()
+ {
+ @Override
+ public boolean evaluate( OrganisationUnit organisationUnit )
+ {
+ return organisationUnit.getLevel() <= finalTotal;
+ }
+ } );
+ }
}
Collections.sort( rootOrganisationUnits, IdentifiableObjectNameComparator.INSTANCE );