dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16225
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6120: WIP reporting rates in data visualizer
------------------------------------------------------------
revno: 6120
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-02-27 15:12:54 +0100
message:
WIP reporting rates in data visualizer
added:
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/AggregatedDataSetCompletenessRowMapper.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/completeness/DataSetCompletenessResult.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-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesAction.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-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java 2012-02-27 14:12:54 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import java.util.Map;
+import org.hisp.dhis.completeness.DataSetCompletenessResult;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -338,6 +339,21 @@
* @param organisationUnitIds the collection of OrganisationUnit identifiers.
*/
Collection<AggregatedMapValue> getAggregatedIndicatorMapValues( int indicatorId, int periodId, Collection<Integer> organisationUnitIds );
+
+ // ----------------------------------------------------------------------
+ // AggregatedDataSetCompleteness
+ // ----------------------------------------------------------------------
+
+ /**
+ * Gets a collection of DataSetCompletenessResult. Populates the data set id,
+ * period id, organisation unit id and value properties.
+ *
+ * @param dataSetIds a collection of DataSet identifiers.
+ * @param periodIds a collection of Period identifiers.
+ * @param organisationUnitIds a collection of OrganisationUnit identifiers.
+ */
+ Collection<DataSetCompletenessResult> getAggregatedDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds,
+ Collection<Integer> organisationUnitIds );
// ----------------------------------------------------------------------
// DataValue
=== 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-26 10:07:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java 2012-02-27 14:12:54 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import java.util.Map;
+import org.hisp.dhis.completeness.DataSetCompletenessResult;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementOperand;
@@ -316,6 +317,21 @@
* @param organisationUnitIds the collection of OrganisationUnit identifiers.
*/
Collection<AggregatedMapValue> getAggregatedIndicatorMapValues( int indicatorId, int periodId, Collection<Integer> organisationUnitIds );
+
+ // ----------------------------------------------------------------------
+ // AggregatedDataSetCompleteness
+ // ----------------------------------------------------------------------
+
+ /**
+ * Gets a collection of DataSetCompletenessResult. Populates the data set id,
+ * period id, organisation unit id and value properties.
+ *
+ * @param dataSetIds a collection of DataSet identifiers.
+ * @param periodIds a collection of Period identifiers.
+ * @param organisationUnitIds a collection of OrganisationUnit identifiers.
+ */
+ Collection<DataSetCompletenessResult> getAggregatedDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds,
+ Collection<Integer> organisationUnitIds );
// ----------------------------------------------------------------------
// DataValue
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java 2012-02-13 17:18:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java 2012-02-27 14:12:54 +0000
@@ -36,8 +36,8 @@
extends AggregatedValue
{
// -------------------------------------------------------------------------
- // Properties 1
- // Inherit periodId, periodName, organisationUnitId, organisationUnitGroupId
+ // Properties 1, inherits periodId, periodName, organisationUnitId,
+ // organisationUnitGroupId, value
// -------------------------------------------------------------------------
private int dataSetId;
@@ -134,12 +134,6 @@
return dataSetId;
}
- @Override
- public double getValue()
- {
- return registrations;
- }
-
// -------------------------------------------------------------------------
// HashCode, equals, and toString
// -------------------------------------------------------------------------
=== 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-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java 2012-02-27 14:12:54 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import java.util.Map;
+import org.hisp.dhis.completeness.DataSetCompletenessResult;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -225,6 +226,16 @@
{
return aggregatedDataValueStore.getAggregatedIndicatorMapValues( indicatorId, periodId, organisationUnitIds );
}
+
+ // -------------------------------------------------------------------------
+ // AggregatedDataSetCompleteness
+ // -------------------------------------------------------------------------
+
+ public Collection<DataSetCompletenessResult> getAggregatedDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds,
+ Collection<Integer> organisationUnitIds )
+ {
+ return aggregatedDataValueStore.getAggregatedDataSetCompleteness( dataSetIds, periodIds, organisationUnitIds );
+ }
// -------------------------------------------------------------------------
// DataValue
=== 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-26 10:07:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java 2012-02-27 14:12:54 +0000
@@ -48,6 +48,7 @@
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;
import org.hisp.dhis.dataelement.DataElementCategoryOption;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -58,6 +59,7 @@
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;
@@ -580,7 +582,7 @@
}
@Override
- public StoreIterator<AggregatedIndicatorValue> getAggregatedIndicatorValuesAtLevel(OrganisationUnit rootOrgunit, OrganisationUnitLevel level, Collection<Period> periods)
+ public StoreIterator<AggregatedIndicatorValue> getAggregatedIndicatorValuesAtLevel( OrganisationUnit rootOrgunit, OrganisationUnitLevel level, Collection<Period> periods )
{
final StatementHolder holder = statementManager.getHolder( false );
@@ -670,6 +672,23 @@
return jdbcTemplate.query( sql, new AggregatedIndicatorMapValueRowMapper() );
}
+
+ // -------------------------------------------------------------------------
+ // DataSetCompleteness
+ // -------------------------------------------------------------------------
+
+ public Collection<DataSetCompletenessResult> getAggregatedDataSetCompleteness( Collection<Integer> dataSetIds, Collection<Integer> periodIds,
+ Collection<Integer> organisationUnitIds )
+ {
+ final String sql =
+ "SELECT datasetid, periodid, organisationunitid, value " +
+ "FROM aggregateddatasetcompleteness " +
+ "WHERE datasetid IN ( " + getCommaDelimitedString( dataSetIds ) + " ) " +
+ "AND periodid IN ( " + getCommaDelimitedString( periodIds ) + " ) " +
+ "AND organisationunitid IN ( " + getCommaDelimitedString( organisationUnitIds ) + " ) ";
+
+ return jdbcTemplate.query( sql, new AggregatedDataSetCompletenessRowMapper() );
+ }
// -------------------------------------------------------------------------
// DataValue
=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/AggregatedDataSetCompletenessRowMapper.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/AggregatedDataSetCompletenessRowMapper.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/objectmapper/AggregatedDataSetCompletenessRowMapper.java 2012-02-27 14:12:54 +0000
@@ -0,0 +1,62 @@
+package org.hisp.dhis.system.objectmapper;
+
+/*
+ * 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.
+ */
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.amplecode.quick.mapper.RowMapper;
+import org.hisp.dhis.completeness.DataSetCompletenessResult;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class AggregatedDataSetCompletenessRowMapper
+ implements RowMapper<DataSetCompletenessResult>, org.springframework.jdbc.core.RowMapper<DataSetCompletenessResult>
+{
+ @Override
+ public DataSetCompletenessResult mapRow( ResultSet resultSet )
+ throws SQLException
+ {
+ final DataSetCompletenessResult value = new DataSetCompletenessResult();
+
+ value.setDataSetId( resultSet.getInt( "datasetid" ) );
+ value.setPeriodId( resultSet.getInt( "periodid" ) );
+ value.setOrganisationUnitId( resultSet.getInt( "organisationunitid" ) );
+ value.setValue( resultSet.getDouble( "value" ) );
+
+ return value;
+ }
+
+ @Override
+ public DataSetCompletenessResult mapRow( ResultSet resultSet, int arg1 )
+ throws SQLException
+ {
+ return mapRow( resultSet );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesAction.java'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesAction.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesAction.java 2012-02-27 14:12:54 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.aggregation.AggregatedDataValue;
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.aggregation.AggregatedIndicatorValue;
+import org.hisp.dhis.completeness.DataSetCompletenessResult;
import com.opensymphony.xwork2.Action;
@@ -70,6 +71,13 @@
{
this.dataElementIds = dataElementIds;
}
+
+ private Collection<Integer> dataSetIds;
+
+ public void setDataSetIds( Collection<Integer> dataSetIds )
+ {
+ this.dataSetIds = dataSetIds;
+ }
private Collection<Integer> periodIds;
@@ -102,6 +110,13 @@
{
return dataValues;
}
+
+ private Collection<DataSetCompletenessResult> dataSetValues = new HashSet<DataSetCompletenessResult>();
+
+ public Collection<DataSetCompletenessResult> getDataSetValues()
+ {
+ return dataSetValues;
+ }
// -------------------------------------------------------------------------
// Action implementation
@@ -123,6 +138,11 @@
dataValues = aggregatedDataValueService.getAggregatedDataValueTotals( dataElementIds, periodIds,
organisationUnitIds );
}
+
+ if ( dataSetIds != null )
+ {
+ dataSetValues = aggregatedDataValueService.getAggregatedDataSetCompleteness( dataSetIds, periodIds, organisationUnitIds );
+ }
}
return SUCCESS;