dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15026
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5261: WIP performance improvements in GIS
------------------------------------------------------------
revno: 5261
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-12-01 18:08:55 +0100
message:
WIP performance improvements in GIS
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java
dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.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/aggregation/AggregatedDataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java 2011-12-01 16:05:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java 2011-12-01 17:08:55 +0000
@@ -253,6 +253,15 @@
*/
Collection<AggregatedMapValue> getAggregatedDataMapValues( int dataElementId, int periodId, Collection<Integer> organisationUnitIds );
+ /**
+ * Retrieves the AggregatedDataMapValues for the given arguments.
+ *
+ * @param dataElementIds the set of DataElement identifiers.
+ * @param periodId the Period identifier.
+ * @param organisationUnitId the OrganisationUnit identifier.
+ */
+ Collection<AggregatedMapValue> getAggregatedDataMapValues( Collection<Integer> dataElementIds, int periodId, int organisationUnitId );
+
// ----------------------------------------------------------------------
// AggregatedIndicatorValue
// ----------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java 2011-12-01 16:05:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java 2011-12-01 17:08:55 +0000
@@ -221,6 +221,15 @@
*/
Collection<AggregatedMapValue> getAggregatedDataMapValues( int dataElementId, int periodId, Collection<Integer> organisationUnitIds );
+ /**
+ * Retrieves the AggregatedDataMapValues for the given arguments.
+ *
+ * @param dataElementIds the set of DataElement identifiers.
+ * @param periodId the Period identifier.
+ * @param organisationUnitId the OrganisationUnit identifier.
+ */
+ Collection<AggregatedMapValue> getAggregatedDataMapValues( Collection<Integer> dataElementIds, int periodId, int organisationUnitId );
+
// ----------------------------------------------------------------------
// AggregatedIndicatorValue
// ----------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java 2011-12-01 16:05:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java 2011-12-01 17:08:55 +0000
@@ -157,6 +157,11 @@
return aggregatedDataValueStore.getAggregatedDataMapValues( dataElementId, periodId, organisationUnitIds );
}
+ public Collection<AggregatedMapValue> getAggregatedDataMapValues( Collection<Integer> dataElementIds, int periodId, int organisationUnitId )
+ {
+ return aggregatedDataValueStore.getAggregatedDataMapValues( dataElementIds, periodId, organisationUnitId );
+ }
+
// -------------------------------------------------------------------------
// AggregatedIndicatorValue
// -------------------------------------------------------------------------
@@ -235,5 +240,4 @@
{
return aggregatedDataValueStore.getDataValueMap( periodId, sourceId );
}
-
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java 2011-12-01 16:05:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java 2011-12-01 17:08:55 +0000
@@ -443,6 +443,30 @@
return jdbcTemplate.query( sql, new AggregatedDataMapValueRowMapper() );
}
+ public Collection<AggregatedMapValue> getAggregatedDataMapValues( Collection<Integer> dataElementIds, int periodId, int organisationUnitId )
+ {
+ final String sql =
+ "SELECT d.name, a.value, a.periodid " +
+ "FROM aggregateddatavalue AS a " +
+ "JOIN dataelement AS d ON (a.dataelementid = d.dataelementid) " +
+ "WHERE a.dataelementid IN (" + getCommaDelimitedString( dataElementIds ) + ") " +
+ "AND a.periodid = " + periodId + " " +
+ "AND a.organisationunitid = " + organisationUnitId;
+
+ return jdbcTemplate.query( sql, new org.springframework.jdbc.core.RowMapper<AggregatedMapValue>()
+ {
+ public AggregatedMapValue mapRow( ResultSet resultSet, int rowNum )
+ throws SQLException
+ {
+ AggregatedMapValue value = new AggregatedMapValue();
+ value.setDataElementName( resultSet.getString( 1 ) );
+ value.setValue( resultSet.getDouble( 2 ) );
+ value.setPeriodId( resultSet.getInt( 3 ) );
+ return value;
+ }
+ } );
+ }
+
// -------------------------------------------------------------------------
// AggregatedIndicatorValue
// -------------------------------------------------------------------------
@@ -626,7 +650,8 @@
{
final String sql =
"SELECT o.organisationunitid, o.name, a.value, a.periodid, a.factor, a.numeratorvalue, a.denominatorvalue " +
- "FROM aggregatedindicatorvalue AS a, organisationunit AS o " +
+ "FROM aggregatedindicatorvalue AS a " +
+ "JOIN organisationunit AS o ON (a.organisationunitid=o.organisationunitid) " +
"WHERE a.indicatorid = " + indicatorId + " " +
"AND a.periodid = " + periodId + " " +
"AND a.organisationunitid IN (" + getCommaDelimitedString( organisationUnitIds ) + ")";
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2011-12-01 16:08:37 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2011-12-01 17:08:55 +0000
@@ -242,32 +242,12 @@
if ( group == null )
{
- group = dataElementService.getAllDataElementGroups().iterator().next();
- }
-
- Period period = periodService.getPeriod( periodId );
-
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
-
- Collection<AggregatedMapValue> values = new HashSet<AggregatedMapValue>();
-
- if ( group != null )
- {
- for ( DataElement dataElement : group.getMembers() )
- {
- Double value = aggregatedDataValueService.getAggregatedValue( dataElement, period, organisationUnit );
-
- value = value != null ? value : 0; // TODO improve
-
- AggregatedMapValue mapValue = new AggregatedMapValue();
- mapValue.setDataElementName( dataElement.getShortName() );
- mapValue.setValue( value );
-
- values.add( mapValue );
- }
- }
-
- return values;
+ return new HashSet<AggregatedMapValue>();
+ }
+
+ Collection<Integer> dataElementIds = ConversionUtils.getIdentifiers( DataElement.class, group.getMembers() );
+
+ return aggregatedDataValueService.getAggregatedDataMapValues( dataElementIds, periodId, organisationUnitId );
}
// -------------------------------------------------------------------------