dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22983
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11175: Migrated png map impl to analytics service. Removed AggregatedMapValue object.
------------------------------------------------------------
revno: 11175
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-06-08 23:51:15 +0200
message:
Migrated png map impl to analytics service. Removed AggregatedMapValue object.
removed:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedMapValue.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapValueController.java
added:
dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/MapValue.java
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-api/src/main/java/org/hisp/dhis/mapping/MappingService.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-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml
dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java
dhis-2/dhis-services/dhis-service-mapgeneration/src/main/resources/META-INF/dhis/beans.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/aggregation/AggregatedDataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java 2013-05-24 12:59:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java 2013-06-08 21:51:15 +0000
@@ -201,28 +201,6 @@
public int countDataValuesAtLevel( OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods );
// ----------------------------------------------------------------------
- // AggregatedDataMapValue
- // ----------------------------------------------------------------------
-
- /**
- * Retrieves the AggregatedDataMapValues for the given arguments.
- *
- * @param dataElementId the DataElement identifier.
- * @param periodId the Period identifier.
- * @param level the OrganisationUnit level.
- */
- 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
// ----------------------------------------------------------------------
@@ -292,19 +270,6 @@
public int countIndicatorValuesAtLevel( OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods );
// ----------------------------------------------------------------------
- // AggregatedIndicatorMapValue
- // ----------------------------------------------------------------------
-
- /**
- * Retrieves the AggregatedIndicatorMapValues for the given arguments.
- *
- * @param indicatorId the Indicator identifier.
- * @param periodId the Period identifier.
- * @param organisationUnitIds the collection of OrganisationUnit identifiers.
- */
- Collection<AggregatedMapValue> getAggregatedIndicatorMapValues( int indicatorId, int periodId, Collection<Integer> organisationUnitIds );
-
- // ----------------------------------------------------------------------
// AggregatedDataSetCompleteness
// ----------------------------------------------------------------------
=== 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 2013-05-24 12:59:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java 2013-06-08 21:51:15 +0000
@@ -178,28 +178,6 @@
public int countDataValuesAtLevel( OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods );
// ----------------------------------------------------------------------
- // AggregatedDataMapValue
- // ----------------------------------------------------------------------
-
- /**
- * Retrieves the AggregatedDataMapValues for the given arguments.
- *
- * @param dataElementId the DataElement identifier.
- * @param periodId the Period identifier.
- * @param organisationUnitIds the set of OrganisationUnit identifiers.
- */
- 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
// ----------------------------------------------------------------------
@@ -270,19 +248,6 @@
public int countIndicatorValuesAtLevel( OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods );
// ----------------------------------------------------------------------
- // AggregatedIndicatorMapValue
- // ----------------------------------------------------------------------
-
- /**
- * Retrieves the AggregatedIndicatorMapValues for the given arguments.
- *
- * @param indicatorId the Indicator identifier.
- * @param periodId the Period identifier.
- * @param organisationUnitIds the collection of OrganisationUnit identifiers.
- */
- Collection<AggregatedMapValue> getAggregatedIndicatorMapValues( int indicatorId, int periodId, Collection<Integer> organisationUnitIds );
-
- // ----------------------------------------------------------------------
// AggregatedDataSetCompleteness
// ----------------------------------------------------------------------
=== removed 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 2013-02-13 03:57:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedMapValue.java 1970-01-01 00:00:00 +0000
@@ -1,185 +0,0 @@
-package org.hisp.dhis.aggregation;
-
-import org.hisp.dhis.common.DxfNamespaces;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @author Lars Helge Overland
- */
-@JacksonXmlRootElement( localName = "dxf2", namespace = DxfNamespaces.DXF_2_0)
-public class AggregatedMapValue
-{
- private int organisationUnitId;
-
- private String organisationUnitName;
-
- private int organisationUnitLevel;
-
- private int periodId;
-
- private String dataElementName;
-
- private double value;
-
- private double factor;
-
- private double numeratorValue;
-
- private double denominatorValue;
-
- // ----------------------------------------------------------------------
- // Constructors
- // ----------------------------------------------------------------------
-
- public AggregatedMapValue()
- {
- }
-
- public AggregatedMapValue( int organisationUnitId, String organisationUnitName, int periodId, String dataElementName, double value, double factor, double numeratorValue, double denominatorValue )
- {
- this.organisationUnitId = organisationUnitId;
- this.organisationUnitName = organisationUnitName;
- this.periodId = periodId;
- this.dataElementName = dataElementName;
- this.value = value;
- this.factor = factor;
- this.numeratorValue = numeratorValue;
- this.denominatorValue = denominatorValue;
- }
-
- // ----------------------------------------------------------------------
- // Logic
- // ----------------------------------------------------------------------
-
- public void clear()
- {
- this.organisationUnitId = 0;
- this.organisationUnitName = null;
- this.value = 0.0;
- }
-
- // ----------------------------------------------------------------------
- // Getters and setters
- // ----------------------------------------------------------------------
-
- @JsonProperty
- public int getOrganisationUnitId()
- {
- return organisationUnitId;
- }
-
- public void setOrganisationUnitId( int organisationUnitId )
- {
- this.organisationUnitId = organisationUnitId;
- }
-
- public String getOrganisationUnitName()
- {
- return organisationUnitName;
- }
-
- public void setOrganisationUnitName( String organisationUnitName )
- {
- this.organisationUnitName = organisationUnitName;
- }
-
- public int getOrganisationUnitLevel()
- {
- return organisationUnitLevel;
- }
-
- public void setOrganisationUnitLevel( int organisationUnitLevel )
- {
- this.organisationUnitLevel = organisationUnitLevel;
- }
-
- public int getPeriodId()
- {
- return periodId;
- }
-
- public void setPeriodId( int periodId )
- {
- this.periodId = periodId;
- }
-
- public String getDataElementName()
- {
- return dataElementName;
- }
-
- public void setDataElementName( String dataElementName )
- {
- this.dataElementName = dataElementName;
- }
-
- @JsonProperty
- public double getValue()
- {
- return value;
- }
-
- public void setValue( double value )
- {
- this.value = value;
- }
-
- public double getFactor()
- {
- return factor;
- }
-
- public void setFactor( double factor )
- {
- this.factor = factor;
- }
-
- public double getNumeratorValue()
- {
- return numeratorValue;
- }
-
- public void setNumeratorValue( double numeratorValue )
- {
- this.numeratorValue = numeratorValue;
- }
-
- public double getDenominatorValue()
- {
- return denominatorValue;
- }
-
- public void setDenominatorValue( double denominatorValue )
- {
- this.denominatorValue = denominatorValue;
- }
-}
=== 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 2013-05-21 11:39:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2013-06-08 21:51:15 +0000
@@ -31,9 +31,6 @@
import java.util.List;
import java.util.Set;
-import org.hisp.dhis.aggregation.AggregatedMapValue;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-
/**
* @author Jan Henrik Overland
* @version $Id$
@@ -59,26 +56,6 @@
final String MAP_LAYER_TYPE_OVERLAY = "overlay";
// -------------------------------------------------------------------------
- // IndicatorMapValue
- // -------------------------------------------------------------------------
-
- Collection<AggregatedMapValue> getIndicatorMapValues( int indicatorId, int periodId, int parentOrganisationUnitId,
- Integer level );
-
- Collection<AggregatedMapValue> getIndicatorMapValues( int indicatorId, int periodId, Collection<OrganisationUnit> units );
-
- // -------------------------------------------------------------------------
- // DataMapValue
- // -------------------------------------------------------------------------
-
- Collection<AggregatedMapValue> getDataElementMapValues( int dataElementId, int periodId,
- int parentOrganisationUnitId, Integer level );
-
- Collection<AggregatedMapValue> getDataElementMapValues( int dataElementId, int periodId, Collection<OrganisationUnit> units );
-
- Collection<AggregatedMapValue> getInfrastructuralDataElementMapValues( Integer periodId, Integer organisationUnitId );
-
- // -------------------------------------------------------------------------
// MapLegend
// -------------------------------------------------------------------------
=== 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 2013-05-24 12:59:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java 2013-06-08 21:51:15 +0000
@@ -133,20 +133,6 @@
{
return aggregatedDataValueStore.countDataValuesAtLevel( orgunit, level, periods );
}
-
- // -------------------------------------------------------------------------
- // AggregatedDataMapValue
- // -------------------------------------------------------------------------
-
- public Collection<AggregatedMapValue> getAggregatedDataMapValues( int dataElementId, int periodId, Collection<Integer> organisationUnitIds )
- {
- return aggregatedDataValueStore.getAggregatedDataMapValues( dataElementId, periodId, organisationUnitIds );
- }
-
- public Collection<AggregatedMapValue> getAggregatedDataMapValues( Collection<Integer> dataElementIds, int periodId, int organisationUnitId )
- {
- return aggregatedDataValueStore.getAggregatedDataMapValues( dataElementIds, periodId, organisationUnitId );
- }
// -------------------------------------------------------------------------
// AggregatedIndicatorValue
@@ -195,15 +181,6 @@
}
// -------------------------------------------------------------------------
- // AggregatedIndicatorMapValue
- // -------------------------------------------------------------------------
-
- public Collection<AggregatedMapValue> getAggregatedIndicatorMapValues( int indicatorId, int periodId, Collection<Integer> organisationUnitIds )
- {
- return aggregatedDataValueStore.getAggregatedIndicatorMapValues( indicatorId, periodId, organisationUnitIds );
- }
-
- // -------------------------------------------------------------------------
// AggregatedDataSetCompleteness
// -------------------------------------------------------------------------
=== 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 2013-05-24 12:59:08 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java 2013-06-08 21:51:15 +0000
@@ -41,7 +41,6 @@
import org.hisp.dhis.aggregation.AggregatedDataValue;
import org.hisp.dhis.aggregation.AggregatedDataValueStore;
import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
-import org.hisp.dhis.aggregation.AggregatedMapValue;
import org.hisp.dhis.aggregation.StoreIterator;
import org.hisp.dhis.completeness.DataSetCompletenessResult;
import org.hisp.dhis.dataelement.DataElement;
@@ -50,10 +49,8 @@
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
import org.hisp.dhis.period.Period;
-import org.hisp.dhis.system.objectmapper.AggregatedDataMapValueRowMapper;
import org.hisp.dhis.system.objectmapper.AggregatedDataSetCompletenessRowMapper;
import org.hisp.dhis.system.objectmapper.AggregatedDataValueRowMapper;
-import org.hisp.dhis.system.objectmapper.AggregatedIndicatorMapValueRowMapper;
import org.hisp.dhis.system.objectmapper.AggregatedIndicatorValueRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
@@ -273,49 +270,6 @@
}
// -------------------------------------------------------------------------
- // AggregatedDataMapValue
- // -------------------------------------------------------------------------
-
- public Collection<AggregatedMapValue> getAggregatedDataMapValues( int dataElementId, int periodId, Collection<Integer> organisationUnitIds )
- {
- final String sql =
- "SELECT a.periodid, o.organisationunitid, o.name, SUM(a.value) AS value " +
- "FROM aggregateddatavalue AS a " +
- "JOIN organisationunit AS o ON (a.organisationunitid=o.organisationunitid) " +
- "WHERE a.dataelementid = " + dataElementId + " " +
- "AND a.periodid = " + periodId + " " +
- "AND a.organisationunitid IN (" + getCommaDelimitedString( organisationUnitIds ) + ") " +
- "GROUP BY a.periodid, o.organisationunitid, o.name";
-
- return jdbcTemplate.query( sql, new AggregatedDataMapValueRowMapper() );
- }
-
- public Collection<AggregatedMapValue> getAggregatedDataMapValues( Collection<Integer> dataElementIds, int periodId, int organisationUnitId )
- {
- final String sql =
- "SELECT d.name, a.periodid, SUM(a.value) AS value " +
- "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 + " " +
- "GROUP BY d.name, a.periodid";
-
- 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.setPeriodId( resultSet.getInt( 2 ) );
- value.setValue( resultSet.getDouble( 3 ) );
- return value;
- }
- } );
- }
-
- // -------------------------------------------------------------------------
// AggregatedIndicatorValue
// -------------------------------------------------------------------------
@@ -432,23 +386,6 @@
}
// -------------------------------------------------------------------------
- // AggregatedIndicatorMapValue
- // -------------------------------------------------------------------------
-
- public Collection<AggregatedMapValue> getAggregatedIndicatorMapValues( int indicatorId, int periodId, Collection<Integer> organisationUnitIds )
- {
- final String sql =
- "SELECT a.periodid, o.organisationunitid, o.name, a.value, a.factor, a.numeratorvalue, a.denominatorvalue " +
- "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 ) + ")";
-
- return jdbcTemplate.query( sql, new AggregatedIndicatorMapValueRowMapper() );
- }
-
- // -------------------------------------------------------------------------
// DataSetCompleteness
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2013-05-21 11:39:31 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2013-06-08 21:51:15 +0000
@@ -32,12 +32,8 @@
import java.util.List;
import java.util.Set;
-import org.hisp.dhis.aggregation.AggregatedDataValueService;
-import org.hisp.dhis.aggregation.AggregatedMapValue;
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
-import org.hisp.dhis.configuration.ConfigurationService;
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -46,8 +42,6 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.system.util.ConversionUtils;
-import org.hisp.dhis.system.util.MathUtils;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -117,153 +111,11 @@
this.periodService = periodService;
}
- private AggregatedDataValueService aggregatedDataValueService;
-
- public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
- {
- this.aggregatedDataValueService = aggregatedDataValueService;
- }
-
- private ConfigurationService configurationService;
-
- public void setConfigurationService( ConfigurationService configurationService )
- {
- this.configurationService = configurationService;
- }
-
// -------------------------------------------------------------------------
// MappingService implementation
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
- // OrganisationUnits
- // -------------------------------------------------------------------------
-
- /**
- * Returns the relevant OrganisationUnits for the given parent identifier
- * and / or level.
- *
- * @param parentOrganisationUnitId the OrganisationUnit level.
- * @param level the OrganisationUnit level.
- * @return a collection of OrganisationUnits.
- */
- private Collection<OrganisationUnit> getOrganisationUnits( Integer parentOrganisationUnitId, Integer level )
- {
- Collection<OrganisationUnit> organisationUnits = null;
-
- if ( parentOrganisationUnitId != null && level != null )
- {
- organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level,
- organisationUnitService.getOrganisationUnit( parentOrganisationUnitId ) );
- }
- else if ( level != null )
- {
- organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level );
- }
- else if ( parentOrganisationUnitId != null )
- {
- organisationUnits = organisationUnitService.getOrganisationUnit( parentOrganisationUnitId ).getChildren();
- }
-
- return organisationUnits;
- }
-
- // -------------------------------------------------------------------------
- // IndicatorMapValues
- // -------------------------------------------------------------------------
-
- /**
- * Generates a collection AggregatedMapValues. Only one of Period and
- * start/end date can be specified. At least one of parent organisation unit
- * and level must be specified. Period should be specified with "real time"
- * aggregation strategy, any may be specified with "batch" aggregation
- * strategy.
- *
- * @param indicatorId the Indicator identifier.
- * @param periodId the Period identifier. Ignored if null.
- * @param parentOrganisationUnitId the parent OrganisationUnit identifier.
- * Ignored if null.
- * @param level the OrganisationUnit level. Ignored if null.
- * @return a collection of AggregatedMapValues.
- */
- public Collection<AggregatedMapValue> getIndicatorMapValues( int indicatorId, int periodId,
- int parentOrganisationUnitId, Integer level )
- {
- Collection<OrganisationUnit> units = getOrganisationUnits( parentOrganisationUnitId, level );
-
- return getIndicatorMapValues( indicatorId, periodId, units );
- }
-
- public Collection<AggregatedMapValue> getIndicatorMapValues( int indicatorId, int periodId,
- Collection<OrganisationUnit> units )
- {
- Collection<AggregatedMapValue> values = aggregatedDataValueService.getAggregatedIndicatorMapValues(
- indicatorId, periodId, ConversionUtils.getIdentifiers( OrganisationUnit.class, units ) );
-
- for ( AggregatedMapValue value : values )
- {
- value.setValue( MathUtils.getRounded( value.getValue(), 2 ) );
- }
-
- return values;
- }
-
- // -------------------------------------------------------------------------
- // DataElementMapValues
- // -------------------------------------------------------------------------
-
- /**
- * Generates a collection AggregatedMapValues. Only one of Period and
- * start/end date can be specified. At least one of parent organisation unit
- * and level must be specified. Period should be specified with "real time"
- * aggregation strategy, any may be specified with "batch" aggregation
- * strategy.
- *
- * @param dataElementId the DataElement identifier.
- * @param periodId the Period identifier. Ignored if null.
- * @param parentOrganisationUnitId the parent OrganisationUnit identifier.
- * Ignored if null.
- * @param level the OrganisationUnit level. Ignored if null.
- * @return a collection of AggregatedMapValues.
- */
- public Collection<AggregatedMapValue> getDataElementMapValues( int dataElementId, int periodId,
- int parentOrganisationUnitId, Integer level )
- {
- Collection<OrganisationUnit> units = getOrganisationUnits( parentOrganisationUnitId, level );
-
- return getDataElementMapValues( dataElementId, periodId, units );
- }
-
- public Collection<AggregatedMapValue> getDataElementMapValues( int dataElementId, int periodId,
- Collection<OrganisationUnit> units )
- {
- Collection<AggregatedMapValue> values = aggregatedDataValueService.getAggregatedDataMapValues( dataElementId,
- periodId, ConversionUtils.getIdentifiers( OrganisationUnit.class, units ) );
-
- for ( AggregatedMapValue value : values )
- {
- value.setValue( MathUtils.getRounded( value.getValue(), 2 ) );
- }
-
- return values;
- }
-
- public Collection<AggregatedMapValue> getInfrastructuralDataElementMapValues( Integer periodId,
- Integer organisationUnitId )
- {
- DataElementGroup group = configurationService.getConfiguration().getInfrastructuralDataElements();
-
- if ( group == null )
- {
- return new HashSet<AggregatedMapValue>();
- }
-
- Collection<Integer> dataElementIds = ConversionUtils.getIdentifiers( DataElement.class, group.getMembers() );
-
- return aggregatedDataValueService.getAggregatedDataMapValues( dataElementIds, periodId, organisationUnitId );
- }
-
- // -------------------------------------------------------------------------
// MapLegend
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-05-27 12:47:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-06-08 21:51:15 +0000
@@ -573,8 +573,6 @@
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
- <property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
- <property name="configurationService" ref="org.hisp.dhis.configuration.ConfigurationService" />
</bean>
<bean id="org.hisp.dhis.setting.SystemSettingManager" class="org.hisp.dhis.setting.DefaultSystemSettingManager">
=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml'
--- dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml 2013-05-31 08:27:38 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/pom.xml 2013-06-08 21:51:15 +0000
@@ -27,7 +27,7 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
- <artifactId>dhis-service-aggregationengine-default</artifactId>
+ <artifactId>dhis-service-analytics</artifactId>
</dependency>
<!-- Other -->
=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2012-10-25 14:58:43 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/GeoToolsMapGenerationService.java 2013-06-08 21:51:15 +0000
@@ -27,16 +27,21 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.common.NameableObjectUtils.getList;
+
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.apache.commons.lang.StringUtils;
-import org.hisp.dhis.aggregation.AggregatedMapValue;
+import org.hisp.dhis.analytics.AnalyticsService;
+import org.hisp.dhis.analytics.DataQueryParams;
+import org.hisp.dhis.common.Grid;
import org.hisp.dhis.mapgeneration.IntervalSet.DistributionStrategy;
import org.hisp.dhis.mapping.MapView;
-import org.hisp.dhis.mapping.MappingService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
@@ -65,11 +70,11 @@
this.organisationUnitService = organisationUnitService;
}
- private MappingService mappingService;
+ private AnalyticsService analyticsService;
- public void setMappingService( MappingService mappingService )
+ public void setAnalyticsService( AnalyticsService analyticsService )
{
- this.mappingService = mappingService;
+ this.analyticsService = analyticsService;
}
// -------------------------------------------------------------------------
@@ -126,24 +131,44 @@
private InternalMapLayer buildSingleInternalMapLayer( MapView mapView )
{
Assert.isTrue( mapView != null );
- Assert.isTrue( mapView.getValueType() != null );
boolean isIndicator = MapView.VALUE_TYPE_INDICATOR.equals( mapView.getValueType() );
- Collection<AggregatedMapValue> mapValues;
-
- if ( isIndicator )
- {
- mapValues = mappingService.getIndicatorMapValues( mapView.getIndicator().getId(), mapView.getPeriod()
- .getId(), mapView.getParentOrganisationUnit().getId(), mapView.getOrganisationUnitLevel().getLevel() );
- }
- else
- {
- mapValues = mappingService.getDataElementMapValues( mapView.getDataElement().getId(), mapView.getPeriod()
- .getId(), mapView.getParentOrganisationUnit().getId(), mapView.getOrganisationUnitLevel().getLevel() );
- }
-
- if ( !( mapValues != null && mapValues.size() > 0 ) )
+ List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitService.
+ getOrganisationUnitsAtLevel( mapView.getOrganisationUnitLevel().getLevel(), mapView.getParentOrganisationUnit() ) );
+
+ DataQueryParams params = new DataQueryParams();
+
+ if ( mapView.getIndicator() != null )
+ {
+ params.setIndicators( getList( mapView.getIndicator() ) );
+ }
+ else if ( mapView.getDataElement() != null )
+ {
+ params.setDataElements( getList( mapView.getDataElement() ) );
+ }
+
+ //TODO operands
+
+ params.setOrganisationUnits( organisationUnits );
+ params.setFilterPeriods( getList( mapView.getPeriod() ) );
+
+ Grid grid = analyticsService.getAggregatedDataValues( params );
+
+ Collection<MapValue> mapValues = new ArrayList<MapValue>();
+
+ for ( List<Object> row : grid.getRows() )
+ {
+ if ( row != null && row.size() >= 3 )
+ {
+ String ou = (String) row.get( 1 );
+ Double value = (Double) row.get( 2 );
+
+ mapValues.add( new MapValue( ou, value ) );
+ }
+ }
+
+ if ( mapValues.isEmpty() )
{
return null;
}
@@ -188,14 +213,14 @@
// Build and set the internal GeoTools map objects for the layer
- for ( AggregatedMapValue mapValue : mapValues )
+ for ( MapValue mapValue : mapValues )
{
// Get the org unit for this map value
- OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( mapValue.getOrganisationUnitId() );
+ OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( mapValue.getOu() );
if ( orgUnit != null && orgUnit.hasCoordinates() && orgUnit.hasFeatureType() )
{
- buildSingleGeoToolsMapObjectForMapLayer( mapLayer, mapValue, orgUnit );
+ buildSingleGeoToolsMapObjectForMapLayer( mapLayer, mapValue.getValue(), orgUnit );
}
}
@@ -215,12 +240,12 @@
}
private GeoToolsMapObject buildSingleGeoToolsMapObjectForMapLayer( InternalMapLayer mapLayer,
- AggregatedMapValue mapValue, OrganisationUnit orgUnit )
+ double mapValue, OrganisationUnit orgUnit )
{
// Create and setup an internal map object
GeoToolsMapObject mapObject = new GeoToolsMapObject();
mapObject.setName( orgUnit.getName() );
- mapObject.setValue( mapValue.getValue() );
+ mapObject.setValue( mapValue );
mapObject.setFillOpacity( mapLayer.getOpacity() );
mapObject.setStrokeColor( mapLayer.getStrokeColor() );
mapObject.setStrokeWidth( mapLayer.getStrokeWidth() );
=== added file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/MapValue.java'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/MapValue.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/java/org/hisp/dhis/mapgeneration/MapValue.java 2013-06-08 21:51:15 +0000
@@ -0,0 +1,34 @@
+package org.hisp.dhis.mapgeneration;
+
+public class MapValue
+{
+ private String ou;
+
+ private double value;
+
+ public MapValue( String ou, double value )
+ {
+ this.ou = ou;
+ this.value = value;
+ }
+
+ public String getOu()
+ {
+ return ou;
+ }
+
+ public void setOu( String ou )
+ {
+ this.ou = ou;
+ }
+
+ public double getValue()
+ {
+ return value;
+ }
+
+ public void setValue( double value )
+ {
+ this.value = value;
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-mapgeneration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mapgeneration/src/main/resources/META-INF/dhis/beans.xml 2012-12-14 13:46:47 +0000
+++ dhis-2/dhis-services/dhis-service-mapgeneration/src/main/resources/META-INF/dhis/beans.xml 2013-06-08 21:51:15 +0000
@@ -6,8 +6,8 @@
<!-- Service definitions -->
<bean id="org.hisp.dhis.mapgeneration.MapGenerationService" class="org.hisp.dhis.mapgeneration.GeoToolsMapGenerationService">
- <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="analyticsService" ref="org.hisp.dhis.analytics.AnalyticsService" />
</bean>
</beans>
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapValueController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapValueController.java 2012-11-05 19:23:01 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapValueController.java 1970-01-01 00:00:00 +0000
@@ -1,185 +0,0 @@
-package org.hisp.dhis.api.controller.mapping;
-
-/*
- * Copyright (c) 2011, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.Collection;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.hisp.dhis.aggregation.AggregatedMapValue;
-import org.hisp.dhis.api.utils.ContextUtils;
-import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.mapping.MappingService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
-import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
-import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.period.PeriodType;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-/**
- * @author Jan Henrik Overland
- */
-@Controller
-@RequestMapping( value = MapValueController.RESOURCE_PATH )
-public class MapValueController
-{
- public static final String RESOURCE_PATH = "/mapValues";
-
- @Autowired
- private MappingService mappingService;
-
- @Autowired
- private IndicatorService indicatorService;
-
- @Autowired
- private DataElementService dataElementService;
-
- @Autowired
- private PeriodService periodService;
-
- @Autowired
- private OrganisationUnitService organisationUnitService;
-
- @Autowired
- private ContextUtils contextUtils;
-
- @RequestMapping( value = "/in", method = RequestMethod.GET )
- public String getIndicatorMapValues(
- @RequestParam String in,
- @RequestParam String pe,
- @RequestParam String ou,
- @RequestParam String le,
- Model model,
- HttpServletResponse response ) throws Exception
- {
- Indicator indicator = indicatorService.getIndicator( in );
-
- if ( indicator == null )
- {
- ContextUtils.conflictResponse( response, "Invalid indicator identifier" );
- return null;
- }
-
- Period period = PeriodType.getPeriodFromIsoString( pe );
-
- if ( period == null )
- {
- ContextUtils.conflictResponse( response, "Invalid period identifier" );
- return null;
- }
-
- period = periodService.reloadPeriod( period );
-
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou );
-
- if ( organisationUnit == null )
- {
- ContextUtils.conflictResponse( response, "Invalid organisation unit identifier" );
- return null;
- }
-
- OrganisationUnitLevel level = organisationUnitService.getOrganisationUnitLevel( le );
-
- if ( level == null )
- {
- ContextUtils.conflictResponse( response, "Invalid organisation unit level identifier" );
- return null;
- }
-
- Collection<AggregatedMapValue> mapValues = mappingService.getIndicatorMapValues( indicator.getId(), period.getId(), organisationUnit.getId(), level.getLevel() );
-
- model.addAttribute( "model", mapValues );
-
- contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
-
- return "mapValues";
- }
-
- @RequestMapping( value = "/de", method = RequestMethod.GET )
- public String getDataElementMapValues(
- @RequestParam String de,
- @RequestParam String pe,
- @RequestParam String ou,
- @RequestParam String le,
- Model model,
- HttpServletResponse response ) throws Exception
- {
- DataElement dataElement = dataElementService.getDataElement( de );
-
- if ( dataElement == null )
- {
- ContextUtils.conflictResponse( response, "Invalid indicator identifier" );
- return null;
- }
-
- Period period = PeriodType.getPeriodFromIsoString( pe );
-
- if ( period == null )
- {
- ContextUtils.conflictResponse( response, "Invalid period identifier" );
- return null;
- }
-
- period = periodService.reloadPeriod( period );
-
- OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( ou );
-
- if ( organisationUnit == null )
- {
- ContextUtils.conflictResponse( response, "Invalid organisation unit identifier" );
- return null;
- }
-
- OrganisationUnitLevel level = organisationUnitService.getOrganisationUnitLevel( le );
-
- if ( level == null )
- {
- ContextUtils.conflictResponse( response, "Invalid organisation unit level identifier" );
- return null;
- }
-
- Collection<AggregatedMapValue> mapValues = mappingService.getDataElementMapValues( dataElement.getId(), period.getId(), organisationUnit.getId(), level.getLevel() );
-
- model.addAttribute( "model", mapValues );
-
- contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING );
-
- return "mapValues";
- }
-}