← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17163: Data etry, using queries to speed up retrieval of readable category options

 

------------------------------------------------------------
revno: 17163
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2014-10-18 09:31:50 +0200
message:
  Data etry, using queries to speed up retrieval of readable category options
modified:
  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-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-10-16 06:17:19 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetMetaDataAction.java	2014-10-18 07:31:50 +0000
@@ -28,9 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.acl.AclService;
-import org.hisp.dhis.common.ListMap;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.configuration.ConfigurationService;
 import org.hisp.dhis.dataelement.DataElement;
@@ -51,13 +57,7 @@
 import org.hisp.dhis.user.User;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import com.opensymphony.xwork2.Action;
 
 /**
  * @author Lars Helge Overland
@@ -119,9 +119,6 @@
     }
 
     @Autowired
-    protected AclService aclService;
-
-    @Autowired
     private ConfigurationService configurationService;
 
     // -------------------------------------------------------------------------
@@ -205,9 +202,9 @@
         return defaultCategoryCombo;
     }
 
-    private ListMap<String, DataElementCategoryOption> categoryOptionMap = new ListMap<>();
+    private Map<String, List<DataElementCategoryOption>> categoryOptionMap = new HashMap<String, List<DataElementCategoryOption>>();
 
-    public ListMap<String, DataElementCategoryOption> getCategoryOptionMap()
+    public Map<String, List<DataElementCategoryOption>> getCategoryOptionMap()
     {
         return categoryOptionMap;
     }
@@ -287,13 +284,9 @@
 
         for ( DataElementCategory category : categories )
         {
-            for ( DataElementCategoryOption categoryOption : category.getCategoryOptions() )
-            {
-                if ( aclService.canRead( user, categoryOption ) )
-                {
-                    categoryOptionMap.putValue( category.getUid(), categoryOption );
-                }
-            }
+            List<DataElementCategoryOption> categoryOptions = new ArrayList<>( categoryService.getDataElementCategoryOptions( category ) );
+            Collections.sort( categoryOptions, IdentifiableObjectNameComparator.INSTANCE );
+            categoryOptionMap.put( category.getUid(), categoryOptions );
         }
 
         Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );