dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #02029
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 671: Implemented getMapValues method in MappingService.
------------------------------------------------------------
revno: 671
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2009-09-11 12:12:03 +0200
message:
Implemented getMapValues method in MappingService.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedMapValue.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
dhis-2/dhis-services/dhis-service-mapping/pom.xml
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/AggregatedMapValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedMapValue.java 2009-09-11 09:43:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedMapValue.java 2009-09-11 10:12:03 +0000
@@ -37,6 +37,8 @@
private String organisationUnitName;
+ private String featureId;
+
private double value;
// ----------------------------------------------------------------------
@@ -47,10 +49,11 @@
{
}
- public AggregatedMapValue( int organisationUnitId, String organisationUnitName, double value )
+ public AggregatedMapValue( int organisationUnitId, String organisationUnitName, String featureId, double value )
{
this.organisationUnitId = organisationUnitId;
this.organisationUnitName = organisationUnitName;
+ this.featureId = featureId;
this.value = value;
}
@@ -62,6 +65,7 @@
{
this.organisationUnitId = 0;
this.organisationUnitName = null;
+ this.featureId = null;
this.value = 0.0;
}
@@ -89,6 +93,16 @@
this.organisationUnitName = organisationUnitName;
}
+ public String getFeatureId()
+ {
+ return featureId;
+ }
+
+ public void setFeatureId( String featureId )
+ {
+ this.featureId = featureId;
+ }
+
public double getValue()
{
return value;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2009-09-10 07:33:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2009-09-11 10:12:03 +0000
@@ -29,6 +29,7 @@
import java.util.Collection;
+import org.hisp.dhis.aggregation.AggregatedMapValue;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -46,7 +47,13 @@
final String MAP_SOURCE_TYPE_DATABASE = "database";
final String MAP_SOURCE_TYPE_SHAPEFILE = "shapefile";
+
+ // -------------------------------------------------------------------------
+ // MapValue
+ // -------------------------------------------------------------------------
+ Collection<AggregatedMapValue> getAggregatedMapValues( int indicatorId, int periodId, String mapLayerPath );
+
// -------------------------------------------------------------------------
// Map
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/pom.xml'
--- dhis-2/dhis-services/dhis-service-mapping/pom.xml 2009-09-06 15:51:11 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/pom.xml 2009-09-11 10:12:03 +0000
@@ -35,6 +35,10 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-datamart-default</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
<artifactId>dhis-support-hibernate</artifactId>
</dependency>
<dependency>
=== 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 2009-09-11 08:04:37 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2009-09-11 10:12:03 +0000
@@ -38,6 +38,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.aggregation.AggregatedMapValue;
+import org.hisp.dhis.datamart.DataMartStore;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorService;
@@ -101,12 +103,57 @@
{
this.userSettingService = userSettingService;
}
+
+ private DataMartStore dataMartStore;
+
+ public void setDataMartStore( DataMartStore dataMartStore )
+ {
+ this.dataMartStore = dataMartStore;
+ }
// -------------------------------------------------------------------------
// MappingService implementation
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
+ // MapValues
+ // -------------------------------------------------------------------------
+
+ public Collection<AggregatedMapValue> getAggregatedMapValues( int indicatorId, int periodId, String mapLayerPath )
+ {
+ Map map = getMapByMapLayerPath( mapLayerPath );
+
+ int level = map.getOrganisationUnitLevel().getLevel();
+
+ Collection<AggregatedMapValue> mapValues = dataMartStore.getAggregatedMapValues( indicatorId, periodId, level );
+
+ java.util.Map<Integer, String> relations = getOrganisationUnitFeatureMap( getMapOrganisationUnitRelationByMap( map ) );
+
+ for ( AggregatedMapValue value : mapValues )
+ {
+ value.setFeatureId( relations.get( value.getOrganisationUnitId() ) );
+ }
+
+ return mapValues;
+ }
+
+ /**
+ * Returns a map for the given MapOrganisationUnitRelations where the key
+ * is the OrganisationUnit identifier and the value is the feature identifier.
+ */
+ private java.util.Map<Integer, String> getOrganisationUnitFeatureMap( Collection<MapOrganisationUnitRelation> relations )
+ {
+ java.util.Map<Integer, String> map = new HashMap<Integer, String>();
+
+ for ( MapOrganisationUnitRelation relation : relations )
+ {
+ map.put( relation.getOrganisationUnit().getId(), relation.getFeatureId() );
+ }
+
+ return map;
+ }
+
+ // -------------------------------------------------------------------------
// Map
// -------------------------------------------------------------------------