dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25389
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12588: add new filter to /api/organisationUnits, userOnly=true, filter on current users OUs
------------------------------------------------------------
revno: 12588
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-10-11 14:29:27 +0200
message:
add new filter to /api/organisationUnits, userOnly=true, filter on current users OUs
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.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-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java 2013-09-10 11:03:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java 2013-10-11 12:29:27 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitByLevelComparator;
+import org.hisp.dhis.user.CurrentUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -68,6 +69,9 @@
@Autowired
private OrganisationUnitService organisationUnitService;
+ @Autowired
+ private CurrentUserService currentUserService;
+
@Override
protected List<OrganisationUnit> getEntityList( WebMetaData metaData, WebOptions options )
{
@@ -84,7 +88,11 @@
level = Integer.parseInt( options.getOptions().get( "level" ) );
}
- if ( lastUpdated != null )
+ if ( options.getOptions().get( "userOnly" ).equals( "true" ) )
+ {
+ entityList = new ArrayList<OrganisationUnit>( currentUserService.getCurrentUser().getOrganisationUnits() );
+ }
+ else if ( lastUpdated != null )
{
entityList = new ArrayList<OrganisationUnit>( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) );