dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33897
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17364: Analytics, fixed bugs. Option combo meta-data not returned for option combos without data. Downlo...
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 17364 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-11-06 08:55:15 +0100
message:
Analytics, fixed bugs. Option combo meta-data not returned for option combos without data. Download of pivot tables with table layout and operands not working for more than one category combo.
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java
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/DefaultQueryPlanner.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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2014-09-29 17:27:42 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2014-11-06 01:15:06 +0000
@@ -68,6 +68,7 @@
import org.hisp.dhis.common.NameableObject;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementGroupSet;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.dataset.DataSet;
@@ -1289,9 +1290,17 @@
if ( des != null && !des.isEmpty() )
{
- DataElement de = (DataElement) des.get( 0 );
-
- items.addAll( de.getCategoryCombo().getSortedOptionCombos() );
+ Set<DataElementCategoryCombo> categoryCombos = new HashSet<>();
+
+ for ( NameableObject de : des )
+ {
+ categoryCombos.add( ((DataElement) de).getCategoryCombo() );
+ }
+
+ for ( DataElementCategoryCombo cc : categoryCombos )
+ {
+ items.addAll( cc.getSortedOptionCombos() );
+ }
}
}
else
=== 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 2014-11-03 00:24:32 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2014-11-06 07:25:08 +0000
@@ -108,6 +108,7 @@
import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementGroupSet;
@@ -133,16 +134,15 @@
import org.hisp.dhis.reporttable.ReportTable;
import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.system.grid.ListGrid;
-import org.hisp.dhis.system.util.ConversionUtils;
import org.hisp.dhis.system.util.DebugUtils;
import org.hisp.dhis.system.util.ListUtils;
import org.hisp.dhis.system.util.MathUtils;
import org.hisp.dhis.system.util.SystemUtils;
-import org.hisp.dhis.util.Timer;
import org.hisp.dhis.system.util.UniqueArrayList;
import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
+import org.hisp.dhis.util.Timer;
import org.springframework.beans.factory.annotation.Autowired;
/**
@@ -485,12 +485,10 @@
{
if ( !params.isSkipMeta() )
{
- Integer cocIndex = params.getCocIndex();
-
Map<Object, Object> metaData = new HashMap<>();
Map<String, String> uidNameMap = getUidNameMap( params );
- Map<String, String> cocNameMap = getCocNameMap( grid, cocIndex );
+ Map<String, String> cocNameMap = getCocNameMap( params );
uidNameMap.putAll( cocNameMap );
metaData.put( NAMES_META_KEY, uidNameMap );
@@ -1274,25 +1272,36 @@
/**
* Returns a mapping between the category option combo identifiers and names
- * in the given grid. Returns an empty map if the grid or cocIndex parameters
- * are null.
+ * in the given grid.
*
- * @param grid the grid.
- * @param cocIndex the category option combo index in the grid.
+ * @param params the data query parameters.
*/
- private Map<String, String> getCocNameMap( Grid grid, Integer cocIndex )
+ private Map<String, String> getCocNameMap( DataQueryParams params )
{
Map<String, String> metaData = new HashMap<>();
- if ( grid != null && cocIndex != null )
+ List<NameableObject> des = params.getDimensionOrFilter( DATAELEMENT_DIM_ID );
+
+ if ( des != null && !des.isEmpty() )
{
- Set<String> uids = new HashSet<>( ConversionUtils.<String>cast( grid.getColumn( cocIndex ) ) );
-
- Collection<DataElementCategoryOptionCombo> cocs = categoryService.getDataElementCategoryOptionCombosByUid( uids );
-
- for ( DataElementCategoryOptionCombo coc : cocs )
- {
- metaData.put( coc.getUid(), coc.getName() );
+ Set<DataElementCategoryCombo> categoryCombos = new HashSet<>();
+
+ for ( NameableObject de : des )
+ {
+ DataElement dataElement = (DataElement) de;
+
+ if ( dataElement.getCategoryCombo() != null )
+ {
+ categoryCombos.add( dataElement.getCategoryCombo() );
+ }
+ }
+
+ for ( DataElementCategoryCombo cc : categoryCombos )
+ {
+ for ( DataElementCategoryOptionCombo coc : cc.getOptionCombos() )
+ {
+ metaData.put( coc.getUid(), coc.getName() );
+ }
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2014-10-16 17:23:01 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java 2014-11-06 07:25:08 +0000
@@ -155,6 +155,11 @@
violation = "Data sets and data element group sets cannot be specified simultaneously";
}
+ if ( params.hasDimensionOrFilter( CATEGORYOPTIONCOMBO_DIM_ID ) && !params.hasDimensionOrFilter( DATAELEMENT_DIM_ID ) )
+ {
+ violation = "Category option combos cannot be specified when data elements are not specified";
+ }
+
if ( violation != null )
{
log.warn( "Validation failed: " + violation );