dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20433
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9323: Analytics, impl support for data element group sets
------------------------------------------------------------
revno: 9323
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-12-14 17:54:08 +0100
message:
Analytics, impl support for data element group sets
modified:
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java
dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.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/table/JdbcAnalyticsTableManager.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-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java 2012-12-13 20:45:26 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateDataElementGroupSetTableStatement.java 2012-12-14 16:54:08 +0000
@@ -63,7 +63,7 @@
for ( DataElementGroupSet groupSet : groupSets )
{
statement += CodecUtils.databaseEncode( groupSet.getName() ) + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
- statement += "dgs_" + groupSet.getUid() + SPACE + "CHARACTER(11)" + SEPARATOR;
+ statement += groupSet.getUid() + SPACE + "CHARACTER(11)" + SEPARATOR;
}
statement += "PRIMARY KEY ( dataelementid ) )";
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java 2012-12-13 20:45:26 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateIndicatorGroupSetTableStatement.java 2012-12-14 16:54:08 +0000
@@ -63,7 +63,7 @@
for ( IndicatorGroupSet groupSet : groupSets )
{
statement += CodecUtils.databaseEncode( groupSet.getName() ) + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
- statement += "igs_" + groupSet.getUid() + SPACE + "CHARACTER(11)" + SEPARATOR;
+ statement += groupSet.getUid() + SPACE + "CHARACTER(11)" + SEPARATOR;
}
statement += "PRIMARY KEY ( indicatorid ) )";
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.java 2012-12-13 20:45:26 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/resourcetable/statement/CreateOrganisationUnitGroupSetTableStatement.java 2012-12-14 16:54:08 +0000
@@ -63,7 +63,7 @@
for ( OrganisationUnitGroupSet groupSet : groupSets )
{
statement += CodecUtils.databaseEncode( groupSet.getName() ) + SPACE + LONG_TEXT_COLUMN_TYPE + SEPARATOR;
- statement += "ougs_" + groupSet.getUid() + SPACE + "CHARACTER(11)" + SEPARATOR;
+ statement += groupSet.getUid() + SPACE + "CHARACTER(11)" + SEPARATOR;
}
statement += "PRIMARY KEY ( organisationunitid ) )";
=== 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 2012-12-14 15:04:48 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java 2012-12-14 16:54:08 +0000
@@ -46,6 +46,7 @@
implements AnalyticsService
{
private static final String VALUE_NAME = "value";
+ private static final String VALUE_HEADER_NAME = "Value";
//TODO period aggregation for multiple period types
//TODO hierarchy aggregation for org units at multiple levels
@@ -63,10 +64,11 @@
for ( String col : params.getDimensionNames() )
{
- grid.addHeader( new GridHeader( col, false, true ) );
- grid.addHeader( new GridHeader( VALUE_NAME, false, false ) );
+ grid.addHeader( new GridHeader( col, col, String.class.getName(), false, true ) );
}
+ grid.addHeader( new GridHeader( VALUE_NAME, VALUE_HEADER_NAME, Double.class.getName(), false, false ) );
+
for ( Map.Entry<String, Double> entry : map.entrySet() )
{
grid.addRow();
=== 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 2012-12-14 15:04:48 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java 2012-12-14 16:54:08 +0000
@@ -37,6 +37,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.analytics.AnalyticsTableManager;
+import org.hisp.dhis.common.CodeGenerator;
+import org.hisp.dhis.dataelement.DataElementGroupSet;
+import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -71,12 +74,15 @@
public static final String PREFIX_ORGUNITGROUPSET = "ougs_";
public static final String PREFIX_ORGUNITLEVEL = "uidlevel";
- public static final String PREFIX_INDEX = "index_";
+ public static final String PREFIX_INDEX = "in_";
@Autowired
private OrganisationUnitService organisationUnitService;
@Autowired
+ private DataElementService dataElementService;
+
+ @Autowired
private OrganisationUnitGroupService organisationUnitGroupService;
@Autowired
@@ -113,7 +119,7 @@
{
for ( String column : columns )
{
- final String index = PREFIX_INDEX + column + "_" + tableName;
+ final String index = PREFIX_INDEX + column + "_" + tableName + "_" + CodeGenerator.generateCode();
final String sql = "create index " + index + " on " + tableName + " (" + column + ")";
@@ -175,6 +181,7 @@
select += valueExpression + " " +
"from datavalue dv " +
+ "left join _dataelementgroupsetstructure degs on dv.dataelementid=degs.dataelementid " +
"left join _organisationunitgroupsetstructure ougs on dv.sourceid=ougs.organisationunitid " +
"left join _orgunitstructure ous on dv.sourceid=ous.organisationunitid " +
"left join _period_no_disaggregation_structure ps on dv.periodid=ps.periodid " +
@@ -203,16 +210,24 @@
{
List<String[]> columns = new ArrayList<String[]>();
+ Collection<DataElementGroupSet> dataElementGroupSets =
+ dataElementService.getCompulsoryDataElementGroupSets();
+
Collection<OrganisationUnitGroupSet> orgUnitGroupSets =
organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets();
Collection<OrganisationUnitLevel> levels =
organisationUnitService.getOrganisationUnitLevels();
+ for ( DataElementGroupSet groupSet : dataElementGroupSets )
+ {
+ String[] col = { groupSet.getUid(), "character(11)", "degs." + groupSet.getUid() };
+ columns.add( col );
+ }
+
for ( OrganisationUnitGroupSet groupSet : orgUnitGroupSets )
{
- String column = PREFIX_ORGUNITGROUPSET + groupSet.getUid();
- String[] col = { column, "character(11)", "ougs." + column };
+ String[] col = { groupSet.getUid(), "character(11)", "ougs." + groupSet.getUid() };
columns.add( col );
}