dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36313
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18600: GetOrganisationUnitTreeAction, cleanup
------------------------------------------------------------
revno: 18600
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-03-13 17:08:55 +0100
message:
GetOrganisationUnitTreeAction, cleanup
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 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2015-03-13 16:08:55 +0000
@@ -174,18 +174,14 @@
username = currentUserService.getCurrentUsername();
- Collection<OrganisationUnit> userOrganisationUnits = new ArrayList<>();
-
User user = currentUserService.getCurrentUser();
if ( user != null && user.hasOrganisationUnit() )
{
- userOrganisationUnits = new ArrayList<>( user.getOrganisationUnits() );
rootOrganisationUnits = new ArrayList<>( user.getOrganisationUnits() );
}
else if ( currentUserService.currentUserIsSuper() || user == null )
{
- userOrganisationUnits = new ArrayList<>( organisationUnitService.getRootOrganisationUnits() );
rootOrganisationUnits = new ArrayList<>( organisationUnitService.getRootOrganisationUnits() );
}
@@ -246,14 +242,9 @@
if ( !versionOnly && !rootOrganisationUnits.isEmpty() )
{
- OrganisationUnitLevel offlineOrgUnitLevel = offlineLevel != null ? new OrganisationUnitLevel( offlineLevel, "<no-name>" )
- : configurationService.getConfiguration().getOfflineOrganisationUnitLevel();
-
- List<OrganisationUnitLevel> orgUnitLevels = organisationUnitService.getOrganisationUnitLevels();
-
- final Integer maxLevels = (offlineOrgUnitLevel != null && !orgUnitLevels.isEmpty()) ? offlineOrgUnitLevel.getLevel() : null;
-
- for ( OrganisationUnit unit : userOrganisationUnits )
+ final Integer maxLevels = getMaxLevels();
+
+ for ( OrganisationUnit unit : rootOrganisationUnits )
{
organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( unit.getId(), maxLevels ) );
}
@@ -287,4 +278,14 @@
return orgUnitVersion.getValue();
}
+
+ private Integer getMaxLevels()
+ {
+ OrganisationUnitLevel offlineOrgUnitLevel = offlineLevel != null ? new OrganisationUnitLevel( offlineLevel, "" )
+ : configurationService.getConfiguration().getOfflineOrganisationUnitLevel();
+
+ List<OrganisationUnitLevel> orgUnitLevels = organisationUnitService.getOrganisationUnitLevels();
+
+ return ( offlineOrgUnitLevel != null && !orgUnitLevels.isEmpty() ) ? offlineOrgUnitLevel.getLevel() : null;
+ }
}