← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2278: Removing default category option combo name in custom data entry editor

 

------------------------------------------------------------
revno: 2278
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2010-12-03 23:30:34 +0100
message:
  Removing default category option combo name in custom data entry editor
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.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/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java	2010-10-08 10:12:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java	2010-12-03 22:30:34 +0000
@@ -216,6 +216,16 @@
     {
         return COLUMN_PREFIX + dataElementId + COLUMN_SEPARATOR + optionComboId;
     }
+    
+    public String getPrettyName()
+    {
+        if ( dataElement == null || categoryOptionCombo == null )
+        {
+            return null;
+        }
+        
+        return categoryOptionCombo.isDefault() ? dataElement.getName() : dataElement.getName() + SPACE + categoryOptionCombo.getName();
+    }
 
     public void updateProperties()
     {
@@ -223,19 +233,15 @@
         {
             throw new NullPointerException( "Data Element or Category Option Combo is null" );
         }
-        else
-        {
-            this.dataElementId = this.dataElement.getId();
-            this.optionComboId = this.categoryOptionCombo.getId();
-            this.operandId = this.dataElementId + SEPARATOR + this.optionComboId;
-            this.operandName = this.dataElement.getName() + this.categoryOptionCombo.getName();
-            this.aggregationOperator = this.dataElement.getAggregationOperator();
-            this.frequencyOrder = this.dataElement.getFrequencyOrder();
-            this.aggregationLevels = new ArrayList<Integer>( dataElement.getAggregationLevels() );
-            this.valueType = this.dataElement.getType();            
-
-        }
-
+        
+        this.dataElementId = this.dataElement.getId();
+        this.optionComboId = this.categoryOptionCombo.getId();
+        this.operandId = this.dataElementId + SEPARATOR + this.optionComboId;
+        this.operandName = getPrettyName();
+        this.aggregationOperator = this.dataElement.getAggregationOperator();
+        this.frequencyOrder = this.dataElement.getFrequencyOrder();
+        this.aggregationLevels = new ArrayList<Integer>( this.dataElement.getAggregationLevels() );
+        this.valueType = this.dataElement.getType();
     }
 
     // -------------------------------------------------------------------------

=== 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	2010-10-08 10:12:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java	2010-12-03 22:30:34 +0000
@@ -39,7 +39,6 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.hisp.dhis.common.GenericIdentifiableObjectStore;
 import org.hisp.dhis.common.GenericStore;
-import org.hisp.dhis.period.TwoYearlyPeriodType;
 import org.hisp.dhis.system.util.Filter;
 import org.hisp.dhis.system.util.FilterUtils;
 import org.hisp.dhis.system.util.UUIdUtils;
@@ -402,31 +401,29 @@
 
         for ( DataElement dataElement : dataElements )
         {
-            Set<DataElementCategoryOptionCombo> categoryOptionCombos = dataElement.getCategoryCombo().getOptionCombos();
-
-            int frequencyOrder = dataElement.getPeriodType() != null ? dataElement.getPeriodType().getFrequencyOrder()
-                : TwoYearlyPeriodType.FREQUENCY_ORDER; // Assume lowest
-            // frequency if no
-            // PeriodType
-
-            if ( categoryOptionCombos.size() > 1 && !(dataElement instanceof CalculatedDataElement) )
+            for ( DataElementCategoryOptionCombo optionCombo : dataElement.getCategoryCombo().getOptionCombos() )
             {
-                for ( DataElementCategoryOptionCombo optionCombo : categoryOptionCombos )
-                {
-                    DataElementOperand operand = new DataElementOperand( dataElement.getId(), optionCombo.getId(),
-                        dataElement.getName() + optionCombo.getName(), dataElement.getType(), dataElement
-                            .getAggregationOperator(), new ArrayList<Integer>( dataElement.getAggregationLevels() ),
-                        frequencyOrder );
+                DataElementOperand operand = new DataElementOperand( dataElement.getId(), optionCombo.getId(),
+                    dataElement.getName() + optionCombo.getName(), dataElement.getType(), dataElement.getAggregationOperator(), 
+                    new ArrayList<Integer>( dataElement.getAggregationLevels() ), dataElement.getFrequencyOrder() );
 
-                    operands.add( operand );
-                }
+                operands.add( operand );
             }
-            else
+        }
+
+        return operands;
+    }
+
+    public Collection<DataElementOperand> getFullOperands( Collection<DataElement> dataElements )
+    {
+        Collection<DataElementOperand> operands = new ArrayList<DataElementOperand>();
+
+        for ( DataElement dataElement : dataElements )
+        {
+            for ( DataElementCategoryOptionCombo optionCombo : dataElement.getCategoryCombo().getOptionCombos() )
             {
-                DataElementOperand operand = new DataElementOperand( dataElement.getId(), categoryOptionCombos
-                    .iterator().next().getId(), dataElement.getName(), dataElement.getType(), dataElement
-                    .getAggregationOperator(), new ArrayList<Integer>( dataElement.getAggregationLevels() ),
-                    frequencyOrder );
+                DataElementOperand operand = new DataElementOperand( dataElement, optionCombo );
+                operand.updateProperties();
 
                 operands.add( operand );
             }
@@ -667,42 +664,4 @@
 
         return optionsMap;
     }
-
-    @Override
-    public Collection<DataElementOperand> getFullOperands( Collection<DataElement> dataElements )
-    {
-        Collection<DataElementOperand> operands = new ArrayList<DataElementOperand>();
-
-        for ( DataElement dataElement : dataElements )
-        {
-            Set<DataElementCategoryOptionCombo> categoryOptionCombos = dataElement.getCategoryCombo().getOptionCombos();
-            
-            if ( categoryOptionCombos.size() > 1 && !(dataElement instanceof CalculatedDataElement) )
-            {
-                for ( DataElementCategoryOptionCombo optionCombo : categoryOptionCombos )
-                {
-
-                    DataElementOperand operand = new DataElementOperand();
-                    operand.setDataElement( dataElement );
-                    operand.setCategoryOptionCombo( optionCombo );
-                    operand.updateProperties();
-
-                    operands.add( operand );
-                }
-            }
-            else
-            {
-
-                DataElementOperand operand = new DataElementOperand();
-                operand.setDataElement( dataElement );
-                operand.setCategoryOptionCombo( categoryOptionCombos.iterator().next() );
-                operand.updateProperties();
-
-                operands.add( operand );
-
-            }
-        }
-
-        return operands;
-    }
 }