← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 850: Reducing usage of the categorycombo -> categoryoptioncombo association.

 

------------------------------------------------------------
revno: 850
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-10-13 16:08:04 +0200
message:
  Reducing usage of the categorycombo -> categoryoptioncombo association.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/UuidPopulator.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/CalculateCDEsAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml


--
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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/UuidPopulator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/UuidPopulator.java	2009-10-02 17:35:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/UuidPopulator.java	2009-10-13 14:08:04 +0000
@@ -35,9 +35,8 @@
 /**
  * @author Bob Jolliffe
  * @version $Id$
- *
- * Provides uuids to uniquely indentifiable objects which do not
- * already have them.
+ * 
+ * Provides uuids to uniquely indentifiable objects which do not already have them.
  */
 public class UuidPopulator
     extends AbstractStartupRoutine
@@ -48,13 +47,15 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-	// Should be all the things requiring uuids .. there are more.  
-	// What follows is a bit of a compromise hack essentially copying
-	// and pasting 3 times.  Should reimplement with common interface
-	// IdentifiableObject or something similar.
-	
-	private DataElementCategoryOptionService categoryOptionService;
+    // Should be all the things requiring uuids .. there are more.
+    // What follows is a bit of a compromise hack essentially copying
+    // and pasting 3 times. Should reimplement with common interface
+    // IdentifiableObject or something similar.
+
+    private DataElementCategoryOptionService categoryOptionService;
+
     private DataElementCategoryService categoryService;
+
     private DataElementService dataElementService;
 
     public void setCategoryOptionService( DataElementCategoryOptionService categoryOptionService )
@@ -62,12 +63,12 @@
         this.categoryOptionService = categoryOptionService;
     }
 
-	public void setCategoryService( DataElementCategoryService categoryService )
+    public void setCategoryService( DataElementCategoryService categoryService )
     {
         this.categoryService = categoryService;
     }
 
-	public void setDataElementService( DataElementService dataElementService )
+    public void setDataElementService( DataElementService dataElementService )
     {
         this.dataElementService = dataElementService;
     }
@@ -82,42 +83,37 @@
         for ( DataElementCategoryOption option : categoryOptionService.getAllDataElementCategoryOptions() )
         {
             if ( option.getUuid() == null )
-        	{
-           		option.setUuid( UUIdUtils.getUUId() );
-           		categoryOptionService.updateDataElementCategoryOption( option );           		
-			    log.info( "Added uuid for CategoryOption '"+option.getName()+"'" );
-			
-        	}        
+            {
+                option.setUuid( UUIdUtils.getUUId() );
+                categoryOptionService.updateDataElementCategoryOption( option );
+                log.info( "Added uuid for CategoryOption '" + option.getName() + "'" );
+
+            }
         }
         log.info( "Checked CategoryOption uuids" );
 
-
         for ( DataElementCategory category : categoryService.getAllDataElementCategories() )
         {
             if ( category.getUuid() == null )
-        	{
-           		category.setUuid( UUIdUtils.getUUId() );
-           		categoryService.updateDataElementCategory( category );           		
-			    log.info( "Added uuid for Category '"+category.getName()+"'" );
-			
-        	}        
+            {
+                category.setUuid( UUIdUtils.getUUId() );
+                categoryService.updateDataElementCategory( category );
+                log.info( "Added uuid for Category '" + category.getName() + "'" );
+
+            }
         }
         log.info( "Checked Category uuids" );
 
         for ( DataElement de : dataElementService.getAllDataElements() )
         {
             if ( de.getUuid() == null )
-        	{
-           		de.setUuid( UUIdUtils.getUUId() );
-           		dataElementService.updateDataElement( de );           		
-			    log.info( "Added uuid for DataElement '"+de.getName()+"'" );
-			
-        	}        
+            {
+                de.setUuid( UUIdUtils.getUUId() );
+                dataElementService.updateDataElement( de );
+                log.info( "Added uuid for DataElement '" + de.getName() + "'" );
+
+            }
         }
         log.info( "Checked DataElement uuids" );
-
-     }   
-
+    }
 }
-
-

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/CalculateCDEsAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/CalculateCDEsAction.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/CalculateCDEsAction.java	2009-10-13 14:08:04 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryComboService;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.de.state.SelectedStateManager;
 import org.hisp.dhis.de.state.StatefulDataValueSaver;
@@ -85,11 +86,11 @@
         this.expressionService = expressionService;
     }
     
-    private DataElementCategoryComboService dataElementCategoryComboService;
+    private DataElementCategoryOptionComboService categoryOptionComboService;
 
-    public void setDataElementCategoryComboService( DataElementCategoryComboService dataElementCategoryComboService )
+    public void setCategoryOptionComboService( DataElementCategoryOptionComboService categoryOptionComboService )
     {
-        this.dataElementCategoryComboService = dataElementCategoryComboService;
+        this.categoryOptionComboService = categoryOptionComboService;
     }
 
     // -------------------------------------------------------------------------
@@ -155,10 +156,8 @@
 
     		// Should the value be saved to the database?
     		if ( cde.isSaved() )
-    		{        			
-    		    DataElementCategoryCombo catCombo = dataElementCategoryComboService.
-    		        getDataElementCategoryComboByName( DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME );
-    		    DataElementCategoryOptionCombo optionCombo = catCombo.getOptionCombos().iterator().next();
+    		{
+                    DataElementCategoryOptionCombo optionCombo = categoryOptionComboService.getDefaultDataElementCategoryOptionCombo();
     		    statefulDataValueSaver.saveValue( cde.getId(), optionCombo.getId(), "" + value );
     		}
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2009-09-27 23:08:36 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2009-10-13 14:08:04 +0000
@@ -40,6 +40,7 @@
 import org.hisp.dhis.dataelement.CalculatedDataElement;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
 import org.hisp.dhis.datalock.DataSetLock;
 import org.hisp.dhis.datalock.DataSetLockService;
 import org.hisp.dhis.dataset.DataEntryForm;
@@ -154,6 +155,13 @@
         this.dataSetLockService = dataSetLockService;
     }
 
+    private DataElementCategoryOptionComboService categoryOptionComboService;
+
+    public void setCategoryOptionComboService( DataElementCategoryOptionComboService categoryOptionComboService )
+    {
+        this.categoryOptionComboService = categoryOptionComboService;
+    }
+
     // -------------------------------------------------------------------------
     // DisplayPropertyHandler
     // -------------------------------------------------------------------------
@@ -316,10 +324,9 @@
             return SUCCESS;
         }
 
-        Collection<DataElementCategoryOptionCombo> defaultOptionCombo = dataElements.iterator().next()
-            .getCategoryCombo().getOptionCombos();
-
-        optionComboId = defaultOptionCombo.iterator().next().getId();
+        DataElementCategoryOptionCombo defaultOptionCombo = categoryOptionComboService.getDefaultDataElementCategoryOptionCombo();
+        
+        optionComboId = defaultOptionCombo.getId();
 
         // ---------------------------------------------------------------------
         // Get the min/max values
@@ -338,7 +345,7 @@
         // Get the DataValues and create a map
         // ---------------------------------------------------------------------
 
-        Collection<DataValue> dataValues = dataValueService.getDataValues( organisationUnit, period, dataElements, defaultOptionCombo );
+        Collection<DataValue> dataValues = dataValueService.getDataValues( organisationUnit, period, dataElements );
 
         dataValueMap = new HashMap<Integer, DataValue>( dataValues.size() );
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/HistoryAction.java	2009-10-13 14:08:04 +0000
@@ -30,8 +30,6 @@
 import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryCombo;
-import org.hisp.dhis.dataelement.DataElementCategoryComboService;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -87,13 +85,6 @@
         this.dataElementCategoryOptionComboService = dataElementCategoryOptionComboService;
     }
     
-    private DataElementCategoryComboService dataElementCategoryComboService;
-
-    public void setDataElementCategoryComboService( DataElementCategoryComboService dataElementCategoryComboService )
-    {
-        this.dataElementCategoryComboService = dataElementCategoryComboService;
-    }
-
     private SelectedStateManager selectedStateManager;
 
     public void setSelectedStateManager( SelectedStateManager selectedStateManager )
@@ -183,9 +174,7 @@
         
         if ( optionCombo == null )
         {
-            String defaultName = DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME;
-            
-            optionCombo = dataElementCategoryComboService.getDataElementCategoryComboByName( defaultName ).getOptionCombos().iterator().next();
+            optionCombo = dataElementCategoryOptionComboService.getDefaultDataElementCategoryOptionCombo();
         }
 
         if ( dataElement == null )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/MinMaxGeneratingAction.java	2009-10-13 14:08:04 +0000
@@ -118,7 +118,7 @@
         {        	
             if ( dataelement.getType().equals( DataElement.TYPE_INT ) )
             {            	
-                for( DataElementCategoryOptionCombo optionCombo : dataelement.getCategoryCombo().getOptionCombos() )
+                for ( DataElementCategoryOptionCombo optionCombo : dataelement.getCategoryCombo().getOptionCombos() )
                 {                	
                     DataElementHistory dataElementHistory = historyRetriever.getHistory( 
                         dataelement, optionCombo, organisationUnit, period, HISTORY_LENGTH );                	

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SaveValueAction.java	2009-10-13 14:08:04 +0000
@@ -33,6 +33,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionComboService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
@@ -84,7 +85,14 @@
     {
         this.selectedStateManager = selectedStateManager;
     }    
-    
+
+    private DataElementCategoryOptionComboService categoryOptionComboService;
+
+    public void setCategoryOptionComboService( DataElementCategoryOptionComboService categoryOptionComboService )
+    {
+        this.categoryOptionComboService = categoryOptionComboService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
@@ -160,9 +168,10 @@
         
         // ---------------------------------------------------------------------
         // Save or update
-        // ---------------------------------------------------------------------      
-        
-        DataElementCategoryOptionCombo defaultOptionCombo = dataElement.getCategoryCombo().getOptionCombos().iterator().next();        
+        // ---------------------------------------------------------------------
+        
+        DataElementCategoryOptionCombo defaultOptionCombo = categoryOptionComboService.getDefaultDataElementCategoryOptionCombo();
+        
         DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, defaultOptionCombo );
 
         if ( dataValue == null )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2009-09-10 13:17:59 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/resources/META-INF/dhis/beans.xml	2009-10-13 14:08:04 +0000
@@ -119,7 +119,10 @@
       ref="org.hisp.dhis.options.SystemSettingManager"/>
     <property name="customValueService">
       <ref bean="org.hisp.dhis.customvalue.CustomValueService"/>
-    </property>            
+    </property>    
+    <property name="dataElementCategoryOptionComboService"
+      ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService">
+    </property>
   </bean>
 	
   <bean id="org.hisp.dhis.de.action.multidimensional.FormAction"
@@ -186,7 +189,9 @@
     <property name="dataValueService"
       ref="org.hisp.dhis.datavalue.DataValueService"/>
     <property name="selectedStateManager"
-      ref="org.hisp.dhis.de.state.SelectedStateManager"/>    
+      ref="org.hisp.dhis.de.state.SelectedStateManager"/>
+    <property name="categoryOptionComboService"
+      ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/> 
   </bean>
   
   <bean id="org.hisp.dhis.de.action.multidimensional.SaveValueAction"
@@ -256,8 +261,8 @@
       ref="org.hisp.dhis.de.state.SelectedStateManager"/>
     <property name="statefulDataValueSaver"
       ref="org.hisp.dhis.de.state.StatefulDataValueSaver"/>
-	<property name="dataElementCategoryComboService"
-      ref="org.hisp.dhis.dataelement.DataElementCategoryComboService"/>      
+	<property name="dataElementCategoryOptionComboService"
+      ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/>      
   </bean>
   
   <bean id="org.hisp.dhis.de.action.order.GetDataElementOrderAction"
@@ -333,16 +338,12 @@
   <bean id="org.hisp.dhis.de.action.HistoryAction"
     class="org.hisp.dhis.de.action.HistoryAction" 
     scope="prototype">
-    <property name="historyRetriever">
-      <ref local="org.hisp.dhis.de.history.HistoryRetriever"/>
-    </property>
-    <property name="dataElementService">
-      <ref bean="org.hisp.dhis.dataelement.DataElementService"/>
-    </property>
+    <property name="historyRetriever"
+      ref="org.hisp.dhis.de.history.HistoryRetriever"/>
+    <property name="dataElementService"
+      ref="org.hisp.dhis.dataelement.DataElementService"/>
     <property name="selectedStateManager"
       ref="org.hisp.dhis.de.state.SelectedStateManager"/>
-    <property name="dataElementCategoryComboService"
-      ref="org.hisp.dhis.dataelement.DataElementCategoryComboService"/>
     <property name="dataElementCategoryOptionComboService"
       ref="org.hisp.dhis.dataelement.DataElementCategoryOptionComboService"/>
     <property name="dataValueService"