← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4689: Pushed some logic code to api

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4689 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-09-26 17:36:02 +0200
message:
  Pushed some logic code to api
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.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/dataelement/DataElementCategoryCombo.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java	2011-09-26 15:17:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombo.java	2011-09-26 15:36:02 +0000
@@ -33,6 +33,7 @@
 import java.util.Set;
 
 import org.hisp.dhis.common.AbstractIdentifiableObject;
+import org.hisp.dhis.common.CombinationGenerator;
 
 /**
  * @author Abyot Aselefew
@@ -133,6 +134,22 @@
         return arrays;
     }
     
+    public void generateOptionCombos()
+    {
+        CombinationGenerator<DataElementCategoryOption> generator = 
+            new CombinationGenerator<DataElementCategoryOption>( this.getCategoryOptionsAsArray() );
+        
+        while ( generator.hasNext() )
+        {
+            DataElementCategoryOptionCombo optionCombo = new DataElementCategoryOptionCombo();
+            optionCombo.setCategoryOptions( generator.getNext() );
+            optionCombo.setCategoryCombo( this );
+            this.optionCombos.add( optionCombo );
+        }
+    }
+    
+    //TODO update category option -> category option combo association
+    
     // -------------------------------------------------------------------------
     // hashCode, equals and toString
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2011-09-26 15:17:15 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2011-09-26 15:36:02 +0000
@@ -469,24 +469,14 @@
 
     public void generateOptionCombos( DataElementCategoryCombo categoryCombo )
     {        
-        CombinationGenerator<DataElementCategoryOption> generator = 
-            new CombinationGenerator<DataElementCategoryOption>( categoryCombo.getCategoryOptionsAsArray() );
-        
-        Set<DataElementCategoryOptionCombo> optionCombos = new HashSet<DataElementCategoryOptionCombo>();
-        
-        while ( generator.hasNext() )
+        categoryCombo.generateOptionCombos();
+        
+        for ( DataElementCategoryOptionCombo optionCombo : categoryCombo.getOptionCombos() )
         {
-            DataElementCategoryOptionCombo optionCombo = new DataElementCategoryOptionCombo();
-            optionCombo.setCategoryOptions( generator.getNext() );
-            optionCombo.setCategoryCombo( categoryCombo );
-            optionCombos.add( optionCombo );            
             addDataElementCategoryOptionCombo( optionCombo );
         }
         
-        categoryCombo.setOptionCombos( optionCombos );
         updateDataElementCategoryCombo( categoryCombo );
-        
-        //TODO update category option -> category option combo association
     }
     
     public List<DataElementCategoryOptionCombo> sortOptionCombos( DataElementCategoryCombo categoryCombo )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2011-09-10 08:40:27 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2011-09-26 15:24:25 +0000
@@ -259,18 +259,18 @@
     {
         Map<DataElementCategoryCombo, List<DataElement>> mappedDataElements = new HashMap<DataElementCategoryCombo, List<DataElement>>();
 
-        for ( DataElement de : dataElements )
+        for ( DataElement dataElement : dataElements )
         {
-            if ( mappedDataElements.containsKey( de.getCategoryCombo() ) )
+            if ( mappedDataElements.containsKey( dataElement.getCategoryCombo() ) )
             {
-                mappedDataElements.get( de.getCategoryCombo() ).add( de );
+                mappedDataElements.get( dataElement.getCategoryCombo() ).add( dataElement );
             }
             else
             {
                 List<DataElement> des = new ArrayList<DataElement>();
-                des.add( de );
+                des.add( dataElement );
 
-                mappedDataElements.put( de.getCategoryCombo(), des );
+                mappedDataElements.put( dataElement.getCategoryCombo(), des );
             }
         }
 
@@ -281,9 +281,9 @@
     {
         Set<DataElementCategoryCombo> setCategoryCombos = new HashSet<DataElementCategoryCombo>();
 
-        for ( DataElement de : dataElements )
+        for ( DataElement dataElement : dataElements )
         {
-            setCategoryCombos.add( de.getCategoryCombo() );
+            setCategoryCombos.add( dataElement.getCategoryCombo() );
         }
 
         List<DataElementCategoryCombo> listCategoryCombos = new ArrayList<DataElementCategoryCombo>( setCategoryCombos );

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java	2011-08-16 07:51:39 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java	2011-09-26 15:24:25 +0000
@@ -238,7 +238,7 @@
 
         for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos )
         {
-            Collection<DataElementCategoryOptionCombo> optionCombos = categoryService.sortOptionCombos( categoryCombo );
+            List<DataElementCategoryOptionCombo> optionCombos = categoryService.sortOptionCombos( categoryCombo );
 
             orderdCategoryOptionCombos.put( categoryCombo.getId(), optionCombos );