← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14074: Minor

 

------------------------------------------------------------
revno: 14074
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-02-19 11:28:50 +0100
message:
  Minor
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java
  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-api/src/main/java/org/hisp/dhis/user/User.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2014-02-19 09:12:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/User.java	2014-02-19 10:28:50 +0000
@@ -196,6 +196,11 @@
     {
         return !CollectionUtils.isEmpty( organisationUnits );
     }
+    
+    public boolean hasDataViewOrganisationUnit()
+    {
+        return !CollectionUtils.isEmpty( dataViewOrganisationUnits );
+    }
 
     public String getOrganisationUnitsName()
     {
@@ -446,7 +451,7 @@
     @JsonSerialize( contentAs = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlElementWrapper( localName = "dataViewOrganisationUnits", namespace = DxfNamespaces.DXF_2_0 )
-    @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
+    @JacksonXmlProperty( localName = "dataViewOrganisationUnit", namespace = DxfNamespaces.DXF_2_0 )
     public Set<OrganisationUnit> getDataViewOrganisationUnits()
     {
         return dataViewOrganisationUnits;

=== 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	2014-02-19 09:12:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/organisationunit/OrganisationUnitController.java	2014-02-19 10:28:50 +0000
@@ -54,6 +54,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitByLevelComparator;
 import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -116,10 +117,23 @@
         {
             entityList = new ArrayList<OrganisationUnit>( currentUserService.getCurrentUser().getOrganisationUnits() );
         }
-        if ( "true".equals( options.getOptions().get( "userDataViewOnly" ) ) )
+        else if ( "true".equals( options.getOptions().get( "userDataViewOnly" ) ) )
         {
             entityList = new ArrayList<OrganisationUnit>( currentUserService.getCurrentUser().getDataViewOrganisationUnits() );
         }
+        else if ( "true".equals( options.getOptions().get( "userDataViewFallback" ) ) )
+        {
+            User user = currentUserService.getCurrentUser();
+            
+            if ( user != null && user.hasDataViewOrganisationUnit() )
+            {
+                entityList = new ArrayList<OrganisationUnit>( user.getDataViewOrganisationUnits() );
+            }
+            else
+            {
+                entityList = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( 1 ) );
+            }
+        }
         else if ( lastUpdated != null )
         {
             entityList = new ArrayList<OrganisationUnit>( manager.getByLastUpdatedSorted( getEntityClass(), lastUpdated ) );