dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28095
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13998: Impl support for category option groups and group sets in analytics api. Added support for catego...
------------------------------------------------------------
revno: 13998
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-02-12 16:47:58 +0100
message:
Impl support for category option groups and group sets in analytics api. Added support for category option groups in charts and pivot table favcorites.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionType.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.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-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2014-01-07 19:21:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java 2014-02-12 15:47:58 +0000
@@ -59,6 +59,7 @@
import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.common.view.DimensionalView;
import org.hisp.dhis.common.view.ExportView;
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryDimension;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -129,6 +130,9 @@
@Scanned
protected List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
+
+ @Scanned
+ protected List<CategoryOptionGroup> categoryOptionGroups = new ArrayList<CategoryOptionGroup>();
protected boolean userOrganisationUnit;
@@ -314,6 +318,8 @@
}
else // Group set
{
+ // Data element group set
+
ListMap<String, NameableObject> deGroupMap = new ListMap<String, NameableObject>();
for ( DataElementGroup group : dataElementGroups )
@@ -331,6 +337,8 @@
type = DimensionType.DATAELEMENT_GROUPSET;
}
+ // Organisation unit group set
+
ListMap<String, NameableObject> ouGroupMap = new ListMap<String, NameableObject>();
for ( OrganisationUnitGroup group : organisationUnitGroups )
@@ -347,6 +355,25 @@
type = DimensionType.ORGANISATIONUNIT_GROUPSET;
}
+
+ // Category option group set
+
+ ListMap<String, NameableObject> coGroupMap = new ListMap<String, NameableObject>();
+
+ for ( CategoryOptionGroup group : categoryOptionGroups )
+ {
+ if ( group.getGroupSet() != null )
+ {
+ coGroupMap.putValue( group.getGroupSet().getUid(), group );
+ }
+ }
+
+ if ( coGroupMap.containsKey( dimension ) )
+ {
+ items.addAll( coGroupMap.get( dimension ) );
+
+ type = DimensionType.CATEGORYOPTION_GROUPSET;
+ }
}
IdentifiableObjectUtils.removeDuplicates( items );
@@ -470,6 +497,8 @@
}
else // Group set
{
+ // Data element group set
+
ListMap<String, BaseNameableObject> deGroupMap = new ListMap<String, BaseNameableObject>();
for ( DataElementGroup group : dataElementGroups )
@@ -485,6 +514,8 @@
objects.add( new BaseDimensionalObject( dimension, DimensionType.DATAELEMENT_GROUPSET, deGroupMap.get( dimension ) ) );
}
+ // Organisation unit group set
+
ListMap<String, BaseNameableObject> ouGroupMap = new ListMap<String, BaseNameableObject>();
for ( OrganisationUnitGroup group : organisationUnitGroups )
@@ -499,6 +530,23 @@
{
objects.add( new BaseDimensionalObject( dimension, DimensionType.ORGANISATIONUNIT_GROUPSET, ouGroupMap.get( dimension ) ) );
}
+
+ // Category option group set
+
+ ListMap<String, BaseNameableObject> coGroupMap = new ListMap<String, BaseNameableObject>();
+
+ for ( CategoryOptionGroup group : categoryOptionGroups )
+ {
+ if ( group.getGroupSet() != null )
+ {
+ coGroupMap.putValue( group.getGroupSet().getUid(), group );
+ }
+ }
+
+ if ( coGroupMap.containsKey( dimension ) )
+ {
+ objects.add( new BaseDimensionalObject( dimension, DimensionType.CATEGORYOPTION_GROUPSET, coGroupMap.get( dimension ) ) );
+ }
}
return objects;
@@ -622,6 +670,7 @@
categoryDimensions.clear();
dataElementGroups.clear();
organisationUnitGroups.clear();
+ categoryOptionGroups.clear();
userOrganisationUnit = false;
userOrganisationUnitChildren = false;
userOrganisationUnitGrandChildren = false;
@@ -651,6 +700,7 @@
categoryDimensions.addAll( object.getCategoryDimensions() );
dataElementGroups.addAll( object.getDataElementGroups() );
organisationUnitGroups.addAll( object.getOrganisationUnitGroups() );
+ categoryOptionGroups.addAll( object.getCategoryOptionGroups() );
userOrganisationUnit = object.isUserOrganisationUnit();
userOrganisationUnitChildren = object.isUserOrganisationUnitChildren();
userOrganisationUnitGrandChildren = object.isUserOrganisationUnitGrandChildren();
@@ -806,6 +856,17 @@
this.organisationUnitGroups = organisationUnitGroups;
}
+ //TODO json annotations
+ public List<CategoryOptionGroup> getCategoryOptionGroups()
+ {
+ return categoryOptionGroups;
+ }
+
+ public void setCategoryOptionGroups( List<CategoryOptionGroup> categoryOptionGroups )
+ {
+ this.categoryOptionGroups = categoryOptionGroups;
+ }
+
@JsonProperty
@JsonView( {DetailedView.class, ExportView.class} )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0)
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionType.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionType.java 2014-02-12 15:47:58 +0000
@@ -41,6 +41,7 @@
CATEGORY_OPTION_COMBO,
PERIOD,
ORGANISATIONUNIT,
+ CATEGORYOPTION_GROUPSET,
DATAELEMENT_GROUPSET,
ORGANISATIONUNIT_GROUPSET,
CATEGORY
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java 2014-02-09 15:36:46 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java 2014-02-12 15:47:58 +0000
@@ -40,6 +40,7 @@
import org.hisp.dhis.analytics.AnalyticsTable;
import org.hisp.dhis.analytics.DataQueryParams;
+import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
import org.hisp.dhis.dataelement.DataElementGroupSet;
@@ -165,6 +166,7 @@
"from datavalue dv " +
"left join _dataelementgroupsetstructure degs on dv.dataelementid=degs.dataelementid " +
"left join _organisationunitgroupsetstructure ougs on dv.sourceid=ougs.organisationunitid " +
+ "left join _categoryoptiongroupsetstructure cogs on dv.categoryoptioncomboid=cogs.categoryoptioncomboid " +
"left join _categorystructure dcs on dv.categoryoptioncomboid=dcs.categoryoptioncomboid " +
"left join _categorystructure acs on dv.attributeoptioncomboid=acs.categoryoptioncomboid " +
"left join _orgunitstructure ous on dv.sourceid=ous.organisationunitid " +
@@ -194,6 +196,9 @@
Collection<OrganisationUnitGroupSet> orgUnitGroupSets =
organisationUnitGroupService.getDataDimensionOrganisationUnitGroupSets();
+ Collection<CategoryOptionGroupSet> categoryOptionGroupSets =
+ categoryService.getDataDimensionCategoryOptionGroupSets();
+
Collection<DataElementCategory> disaggregationCategories =
categoryService.getDisaggregationDataDimensionCategories();
@@ -214,6 +219,12 @@
String[] col = { quote( groupSet.getUid() ), "character(11)", "ougs." + quote( groupSet.getUid() ) };
columns.add( col );
}
+
+ for ( CategoryOptionGroupSet groupSet : categoryOptionGroupSets )
+ {
+ String[] col = { quote( groupSet.getUid() ), "character(11)", "cogs." + quote( groupSet.getUid() ) };
+ columns.add( col );
+ }
for ( DataElementCategory category : disaggregationCategories )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java 2014-01-08 11:18:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/DefaultDimensionService.java 2014-02-12 15:47:58 +0000
@@ -36,6 +36,7 @@
import static org.hisp.dhis.common.DimensionType.INDICATOR;
import static org.hisp.dhis.common.DimensionType.ORGANISATIONUNIT;
import static org.hisp.dhis.common.DimensionType.ORGANISATIONUNIT_GROUPSET;
+import static org.hisp.dhis.common.DimensionType.CATEGORYOPTION_GROUPSET;
import static org.hisp.dhis.common.DimensionType.PERIOD;
import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_LEVEL;
@@ -50,6 +51,8 @@
import java.util.List;
import java.util.Map;
+import org.hisp.dhis.dataelement.CategoryOptionGroup;
+import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
import org.hisp.dhis.dataelement.DataElementCategoryDimension;
@@ -128,6 +131,13 @@
{
return ougs;
}
+
+ CategoryOptionGroupSet cogs = identifiableObjectManager.get( CategoryOptionGroupSet.class, uid );
+
+ if ( cogs != null )
+ {
+ return cogs;
+ }
return null;
}
@@ -139,7 +149,7 @@
if ( cat != null )
{
return DimensionType.CATEGORY;
- }
+ }
DataElementGroupSet degs = identifiableObjectManager.get( DataElementGroupSet.class, uid );
@@ -154,6 +164,13 @@
{
return DimensionType.ORGANISATIONUNIT_GROUPSET;
}
+
+ CategoryOptionGroupSet cogs = identifiableObjectManager.get( CategoryOptionGroupSet.class, uid );
+
+ if ( cogs != null )
+ {
+ return DimensionType.CATEGORYOPTION_GROUPSET;
+ }
final Map<String, DimensionType> dimObjectTypeMap = new HashMap<String, DimensionType>();
@@ -172,12 +189,14 @@
public List<DimensionalObject> getAllDimensions()
{
Collection<DataElementCategory> dcs = categoryService.getDataDimensionDataElementCategories();
+ Collection<CategoryOptionGroupSet> cogs = categoryService.getDataDimensionCategoryOptionGroupSets();
Collection<DataElementGroupSet> degs = dataElementService.getDataDimensionDataElementGroupSets();
Collection<OrganisationUnitGroupSet> ougs = organisationUnitGroupService.getDataDimensionOrganisationUnitGroupSets();
final List<DimensionalObject> dimensions = new ArrayList<DimensionalObject>();
dimensions.addAll( dcs );
+ dimensions.addAll( cogs );
dimensions.addAll( degs );
dimensions.addAll( ougs );
@@ -345,6 +364,10 @@
{
object.getOrganisationUnitGroups().addAll( identifiableObjectManager.getByUid( OrganisationUnitGroup.class, uids ) );
}
+ else if ( CATEGORYOPTION_GROUPSET.equals( type ) )
+ {
+ object.getCategoryOptionGroups().addAll( identifiableObjectManager.getByUid( CategoryOptionGroup.class, uids ) );
+ }
}
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2013-10-15 16:53:50 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml 2014-02-12 15:47:58 +0000
@@ -127,6 +127,14 @@
foreign-key="fk_chart_orgunitgroups_orgunitgroupid" />
</list>
+ <list name="categoryOptionGroups" table="chart_categoryoptiongroups">
+ <cache usage="read-write" />
+ <key column="chartid" foreign-key="fk_chart_categoryoptiongroups_chartid" />
+ <list-index column="sort_order" base="0" />
+ <many-to-many column="categoryoptiongroupid" class="org.hisp.dhis.dataelement.CategoryOptionGroup"
+ foreign-key="fk_chart_categoryoptiongroups_categoryoptiongroupid" />
+ </list>
+
<list name="organisationUnitLevels" table="chart_orgunitlevels">
<cache usage="read-write" />
<key column="chartid" foreign-key="fk_chart_orgunitlevels_chartid" />
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2014-01-29 11:02:07 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml 2014-02-12 15:47:58 +0000
@@ -96,6 +96,14 @@
foreign-key="fk_reporttable_orgunitgroups_orgunitgroupid" />
</list>
+ <list name="categoryOptionGroups" table="reporttable_categoryoptiongroups">
+ <cache usage="read-write" />
+ <key column="reporttableid" foreign-key="fk_reporttable_categoryoptiongroups_reporttableid" />
+ <list-index column="sort_order" base="0" />
+ <many-to-many column="categoryoptiongroupid" class="org.hisp.dhis.dataelement.CategoryOptionGroup"
+ foreign-key="fk_reporttable_categoryoptiongroups_categoryoptiongroupid" />
+ </list>
+
<list name="organisationUnitLevels" table="reporttable_orgunitlevels">
<cache usage="read-write" />
<key column="reporttableid" foreign-key="fk_reporttable_orgunitlevels_reporttableid" />