← Back to team overview

dhis2-devs team mailing list archive

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

 

------------------------------------------------------------
revno: 16867
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-09-29 21:53:06 +0200
message:
  Minor
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.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/organisationunit/OrganisationUnitService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2014-09-29 19:04:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2014-09-29 19:53:06 +0000
@@ -391,7 +391,7 @@
      */
     Collection<OrganisationUnit> getOrganisationUnitsByNameAndGroups( String name, Collection<OrganisationUnitGroup> groups, OrganisationUnit parent, boolean limit );
 
-    OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet();
+    OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet( Integer maxlevels );
 
     void filterOrganisationUnitsWithoutData( Collection<OrganisationUnit> organisationUnits );
 

=== 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	2014-09-29 19:04:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2014-09-29 19:53:06 +0000
@@ -29,6 +29,7 @@
  */
 
 import static org.hisp.dhis.i18n.I18nUtils.i18n;
+import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
 
 import java.awt.geom.Point2D;
 import java.util.ArrayList;
@@ -564,12 +565,12 @@
             : intersection;
     }
 
-    public OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet()
+    public OrganisationUnitDataSetAssociationSet getOrganisationUnitDataSetAssociationSet( Integer maxLevels )
     {
         Map<String, Set<String>> associationSet = Maps.newHashMap( organisationUnitStore.getOrganisationUnitDataSetAssocationMap() );
 
         filterUserDataSets( associationSet );
-        filterChildOrganisationUnits( associationSet );
+        filterChildOrganisationUnits( associationSet, maxLevels );
 
         OrganisationUnitDataSetAssociationSet set = new OrganisationUnitDataSetAssociationSet();
 
@@ -613,21 +614,21 @@
     /**
      * Retains only the organisation units in the sub-tree of the current user.
      * 
-     * TODO use offline levels
-     * 
      * @param associationMap the associations between organisation unit and data sets.
+     * @param maxLevels the maximum number of levels to include relative to 
+     *        current user, inclusive.
      */
-    private void filterChildOrganisationUnits( Map<String, Set<String>> associationMap )
+    private void filterChildOrganisationUnits( Map<String, Set<String>> associationMap, Integer maxLevels )
     {
         User currentUser = currentUserService.getCurrentUser();
 
         if ( currentUser != null && currentUser.getOrganisationUnits() != null )
         {
-            Collection<String> parentIds = IdentifiableObjectUtils.getUids( currentUser.getOrganisationUnits() );
+            Collection<String> parentIds = getUids( currentUser.getOrganisationUnits() );
 
-            Collection<OrganisationUnit> organisationUnitsWithChildren = getOrganisationUnitsWithChildren( parentIds );
+            Collection<OrganisationUnit> organisationUnitsWithChildren = getOrganisationUnitsWithChildren( parentIds, maxLevels );
             
-            Collection<String> children = IdentifiableObjectUtils.getUids( organisationUnitsWithChildren );
+            Collection<String> children = getUids( organisationUnitsWithChildren );
 
             associationMap.keySet().retainAll( children );
         }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-09-19 16:13:09 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-09-29 19:53:06 +0000
@@ -29,9 +29,11 @@
  */
 
 import com.opensymphony.xwork2.Action;
+
 import org.hisp.dhis.acl.AclService;
 import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.configuration.ConfigurationService;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategory;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
@@ -44,6 +46,7 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnitDataSetAssociationSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
@@ -119,6 +122,9 @@
     @Autowired
     protected AclService aclService;
 
+    @Autowired
+    private ConfigurationService configurationService;
+    
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -238,7 +244,11 @@
 
         expressionService.substituteExpressions( indicators, null );
 
-        OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet();
+        OrganisationUnitLevel offlineOrgUnitLevel = configurationService.getConfiguration().getOfflineOrganisationUnitLevel();
+        
+        Integer level = offlineOrgUnitLevel != null ? offlineOrgUnitLevel.getLevel() : null;
+        
+        OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet( null ); //TODO change null > "level"
 
         dataSetAssociationSets = organisationUnitSet.getDataSetAssociationSets();