← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3471: Made add/update data element faster

 

------------------------------------------------------------
revno: 3471
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-04-26 19:29:50 +0200
message:
  Made add/update data element faster
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-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowAddDataElementForm.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowUpdateDataElementFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.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	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2011-04-26 17:29:50 +0000
@@ -29,6 +29,7 @@
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.hisp.dhis.hierarchy.HierarchyViolationException;
@@ -287,6 +288,8 @@
     
     List<OrganisationUnitLevel> getFilledOrganisationUnitLevels();
     
+    Map<Integer, OrganisationUnitLevel> getOrganisationUnitLevelMap();
+    
     int getNumberOfOrganisationUnits();
     
     int getMaxOfOrganisationUnitLevels();

=== 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	2011-04-23 18:52:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2011-04-26 17:29:50 +0000
@@ -508,11 +508,6 @@
         List<OrganisationUnitLevel> levels = new ArrayList<OrganisationUnitLevel>( organisationUnitStore
             .getOrganisationUnitLevels() );
 
-        if ( levels.isEmpty() )
-        {
-            levels = this.getFilledOrganisationUnitLevels();
-        }
-
         Collections.sort( levels, new OrganisationUnitLevelComparator() );
 
         return levels;
@@ -545,11 +540,13 @@
         return levels;
     }
 
-    private Map<Integer, OrganisationUnitLevel> getOrganisationUnitLevelMap()
+    public Map<Integer, OrganisationUnitLevel> getOrganisationUnitLevelMap()
     {
         Map<Integer, OrganisationUnitLevel> levelMap = new HashMap<Integer, OrganisationUnitLevel>();
 
-        for ( OrganisationUnitLevel level : organisationUnitStore.getOrganisationUnitLevels() )
+        Collection<OrganisationUnitLevel> levels = getOrganisationUnitLevels();
+        
+        for ( OrganisationUnitLevel level : levels )
         {
             levelMap.put( level.getLevel(), level );
         }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java	2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java	2011-04-26 17:29:50 +0000
@@ -40,8 +40,6 @@
 
 /**
  * @author Torgeir Lorange Ostby
- * @author Hans S. Toemmerholt
- * @version $Id: AddDataElementAction.java 6216 2008-11-06 18:06:42Z eivindwa $
  */
 public class AddDataElementAction
     extends ActionSupport

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowAddDataElementForm.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowAddDataElementForm.java	2010-05-06 13:24:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowAddDataElementForm.java	2011-04-26 17:29:50 +0000
@@ -32,11 +32,9 @@
 import java.util.Collections;
 import java.util.List;
 
-import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboNameComparator;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -79,14 +77,7 @@
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
-    
-    private final static int ALL = 0;
-    
-    public int getALL()
-    {
-        return ALL;
-    }
-        
+            
     private Collection<DataElementGroup> dataElementGroups;
     
     public Collection<DataElementGroup> getDataElementGroups()
@@ -108,13 +99,6 @@
     	return defaultCategoryCombo;
     }
     
-    private List<DataElementGroupSet> dataElementGroupSets;
-    
-    public List<DataElementGroupSet> getDataElementGroupSets()
-    {
-        return dataElementGroupSets;
-    }
-
     private List<OrganisationUnitLevel> organisationUnitLevels;
 
     public List<OrganisationUnitLevel> getOrganisationUnitLevels()
@@ -136,10 +120,6 @@
         
         Collections.sort( dataElementCategoryCombos, new DataElementCategoryComboNameComparator() );
         
-        dataElementGroupSets = new ArrayList<DataElementGroupSet>( dataElementService.getAllDataElementGroupSets() );
-
-        Collections.sort( dataElementGroupSets, new IdentifiableObjectNameComparator() );
-        
         organisationUnitLevels = organisationUnitService.getOrganisationUnitLevels();
         
         return SUCCESS;

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowUpdateDataElementFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowUpdateDataElementFormAction.java	2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ShowUpdateDataElementFormAction.java	2011-04-26 17:29:50 +0000
@@ -36,7 +36,6 @@
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -100,27 +99,6 @@
         return dataElementGroups;
     }
 
-    private Map<String, Double> factorMap;
-
-    public Map<String, Double> getFactorMap()
-    {
-        return factorMap;
-    }
-
-    private Collection<DataElementOperand> operands = new ArrayList<DataElementOperand>();
-
-    public Collection<DataElementOperand> getOperands()
-    {
-        return operands;
-    }
-
-    private final static int ALL = 0;
-
-    public int getALL()
-    {
-        return ALL;
-    }
-
     private List<DataElementCategoryCombo> dataElementCategoryCombos;
 
     public List<DataElementCategoryCombo> getDataElementCategoryCombos()
@@ -165,28 +143,15 @@
 
         organisationUnitLevels = organisationUnitService.getOrganisationUnitLevels();
 
-        List<OrganisationUnitLevel> filledOrganisationUnitLevels = organisationUnitService
-            .getFilledOrganisationUnitLevels();
-
+        Map<Integer, OrganisationUnitLevel> levelMap = organisationUnitService.getOrganisationUnitLevelMap();
+        
         for ( Integer level : dataElement.getAggregationLevels() )
         {
-            aggregationLevels.add( getOrganisationUnitLevel( level, filledOrganisationUnitLevels ) );
+            aggregationLevels.add( levelMap.get( level ) );
         }
 
         organisationUnitLevels.removeAll( aggregationLevels );
 
         return SUCCESS;
     }
-
-    private OrganisationUnitLevel getOrganisationUnitLevel( Integer level,
-        List<OrganisationUnitLevel> organisationUnitLevels )
-    {
-        for ( OrganisationUnitLevel organisationUnitLevel : organisationUnitLevels )
-        {
-            if ( level.equals( organisationUnitLevel.getLevel() ) )
-                return organisationUnitLevel;
-        }
-
-        return null;
-    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2011-04-26 17:29:50 +0000
@@ -43,9 +43,6 @@
 
 /**
  * @author Torgeir Lorange Ostby
- * @author Hans S. Toemmerholt
- * @version $Id: UpdateDataElementAction.java 6216 2008-11-06 18:06:42Z eivindwa
- *          $
  */
 public class UpdateDataElementAction
     extends ActionSupport