← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11158: PNG charts, fixed bug with rendering of charts with data element operands

 

------------------------------------------------------------
revno: 11158
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-06-06 10:48:20 +0200
message:
  PNG charts, fixed bug with rendering of charts with data element operands
modified:
  dhis-2/build.sh*
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.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/build.sh' (properties changed: -x to +x)
=== 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	2013-05-27 12:47:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java	2013-06-06 08:48:20 +0000
@@ -189,6 +189,24 @@
         return name;
     }
     
+    @Override
+    public String getShortName()
+    {
+        String shortName = null;
+        
+        if ( dataElement != null )
+        {
+            shortName = dataElement.getShortName();
+        }
+        
+        if ( categoryOptionCombo != null )
+        {
+            shortName += SPACE + categoryOptionCombo.getName();
+        }
+        
+        return shortName;
+    }
+    
     /**
      * Tests whether the operand has any aggregation levels.
      */

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-05-29 18:35:32 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-06-06 08:48:20 +0000
@@ -96,6 +96,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementGroupSet;
 import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.dataelement.DataElementOperandService;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
@@ -171,6 +172,9 @@
     
     @Autowired
     private CurrentUserService currentUserService;
+    
+    @Autowired
+    private DataElementOperandService operandService;
 
     // -------------------------------------------------------------------------
     // Implementation
@@ -670,6 +674,7 @@
             List<NameableObject> indicators = new ArrayList<NameableObject>();
             List<NameableObject> dataElements = new ArrayList<NameableObject>();
             List<NameableObject> dataSets = new ArrayList<NameableObject>();
+            List<NameableObject> operandDataElements = new ArrayList<NameableObject>();
             
             options : for ( String uid : items )
             {
@@ -697,6 +702,14 @@
                     continue options;
                 }
                 
+                DataElementOperand dc = operandService.getDataElementOperandByUid( uid );
+                
+                if ( dc != null )
+                {
+                    operandDataElements.add( dc.getDataElement() );
+                    continue options;
+                }
+                
                 throw new IllegalQueryException( "Data dimension option identifier does not reference any option: " + uid );                
             }
             
@@ -715,7 +728,13 @@
                 dataDimensions.add( new BaseDimensionalObject( DATASET_DIM_ID, DimensionType.DATASET, dataSets ) );
             }
             
-            if ( indicators.isEmpty() && dataElements.isEmpty() && dataSets.isEmpty() )
+            if ( !operandDataElements.isEmpty() )
+            {
+                dataDimensions.add( new BaseDimensionalObject( DATAELEMENT_DIM_ID, DimensionType.DATAELEMENT, operandDataElements ) );
+                dataDimensions.add( new BaseDimensionalObject( CATEGORYOPTIONCOMBO_DIM_ID, DimensionType.CATEGORY_OPTION_COMBO, new ArrayList<NameableObject>() ) );
+            }
+            
+            if ( indicators.isEmpty() && dataElements.isEmpty() && dataSets.isEmpty() && operandDataElements.isEmpty() )
             {
                 throw new IllegalQueryException( "Dimension dx is present in query without any valid dimension options" );
             }

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2013-05-29 13:18:45 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/impl/DefaultChartService.java	2013-06-06 08:48:20 +0000
@@ -60,6 +60,7 @@
 import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DataValueService;
 import org.hisp.dhis.i18n.I18nFormat;
@@ -694,6 +695,10 @@
 
                 String key = series.getUid() + DIMENSION_SEP + category.getUid();
 
+                // Replace potential operand separator with dimension separator
+                
+                key = key.replace( DataElementOperand.SEPARATOR, DIMENSION_SEP );
+
                 Double value = valueMap.get( key );
                 
                 regularDataSet.addValue( value, series.getShortName(), category.getShortName() );