dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15093
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5315: WIP org unit groups in data mart
------------------------------------------------------------
revno: 5315
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-06 20:40:38 +0100
message:
WIP org unit groups in data mart
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValue.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AggregatedValue.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DataElementDataMart.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java
dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.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/AggregatedDataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValue.java 2011-12-06 19:12:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValue.java 2011-12-06 19:40:38 +0000
@@ -53,7 +53,7 @@
private int organisationUnitId;
- private int groupId;
+ private int organisationUnitGroupId;
private int level;
@@ -183,14 +183,14 @@
this.organisationUnitId = organisationUnitId;
}
- public int getGroupId()
+ public int getOrganisationUnitGroupId()
{
- return groupId;
+ return organisationUnitGroupId;
}
- public void setGroupId( int groupId )
+ public void setOrganisationUnitGroupId( int organisationUnitGroupId )
{
- this.groupId = groupId;
+ this.organisationUnitGroupId = organisationUnitGroupId;
}
public int getPeriodId()
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java 2011-12-06 19:12:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java 2011-12-06 19:40:38 +0000
@@ -51,7 +51,7 @@
private int organisationUnitId;
- private int groupId;
+ private int organisationUnitGroupId;
private int level;
@@ -231,14 +231,14 @@
this.organisationUnitId = organisationUnitId;
}
- public int getGroupId()
+ public int getOrganisationUnitGroupId()
{
- return groupId;
+ return organisationUnitGroupId;
}
- public void setGroupId( int groupId )
+ public void setOrganisationUnitGroupId( int organisationUnitGroupId )
{
- this.groupId = groupId;
+ this.organisationUnitGroupId = organisationUnitGroupId;
}
public int getPeriodId()
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AggregatedValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AggregatedValue.java 2011-12-06 19:12:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AggregatedValue.java 2011-12-06 19:40:38 +0000
@@ -40,7 +40,7 @@
int getOrganisationUnitId();
- int getGroupId();
+ int getOrganisationUnitGroupId();
double getValue();
}
=== 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 2011-12-06 19:12:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/completeness/DataSetCompletenessResult.java 2011-12-06 19:40:38 +0000
@@ -55,7 +55,7 @@
private int organisationUnitId;
- private int groupId;
+ private int organisationUnitGroupId;
// -------------------------------------------------------------------------
// Properties 2
@@ -251,14 +251,14 @@
this.organisationUnitId = organisationUnitId;
}
- public int getGroupId()
+ public int getOrganisationUnitGroupId()
{
- return groupId;
+ return organisationUnitGroupId;
}
- public void setGroupId( int groupId )
+ public void setOrganisationUnitGroupId( int organisationUnitGroupId )
{
- this.groupId = groupId;
+ this.organisationUnitGroupId = organisationUnitGroupId;
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DataElementDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DataElementDataMart.java 2011-07-01 11:20:25 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DataElementDataMart.java 2011-12-06 19:40:38 +0000
@@ -30,9 +30,12 @@
import java.util.Collection;
import java.util.concurrent.Future;
+import org.amplecode.quick.BatchHandler;
+import org.hisp.dhis.aggregation.AggregatedDataValue;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.datamart.DataElementOperandList;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
/**
@@ -41,5 +44,6 @@
public interface DataElementDataMart
{
Future<?> exportDataValues( Collection<DataElementOperand> operands, Collection<Period> periods,
- Collection<OrganisationUnit> organisationUnits, DataElementOperandList operandList, String key );
+ Collection<OrganisationUnit> organisationUnits, Collection<OrganisationUnitGroup> organisationUnitGroups,
+ DataElementOperandList operandList, Class<? extends BatchHandler<AggregatedDataValue>> clazz, String key );
}
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java 2011-12-03 17:32:57 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java 2011-12-06 19:40:38 +0000
@@ -27,8 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import static org.hisp.dhis.datamart.crosstab.jdbc.CrossTabStore.AGGREGATEDDATA_CACHE_PREFIX;
import static org.hisp.dhis.system.util.MathUtils.getRounded;
-import static org.hisp.dhis.datamart.crosstab.jdbc.CrossTabStore.*;
import java.util.Collection;
import java.util.HashMap;
@@ -46,9 +46,9 @@
import org.hisp.dhis.datamart.DataElementOperandList;
import org.hisp.dhis.datamart.aggregation.cache.AggregationCache;
import org.hisp.dhis.datamart.aggregation.dataelement.DataElementAggregator;
-import org.hisp.dhis.jdbc.batchhandler.AggregatedDataValueBatchHandler;
import org.hisp.dhis.jdbc.batchhandler.GenericBatchHandler;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
@@ -144,11 +144,12 @@
@Async
public Future<?> exportDataValues( Collection<DataElementOperand> operands, Collection<Period> periods,
- Collection<OrganisationUnit> organisationUnits, DataElementOperandList operandList, String key )
+ Collection<OrganisationUnit> organisationUnits, Collection<OrganisationUnitGroup> organisationUnitGroups,
+ DataElementOperandList operandList, Class<? extends BatchHandler<AggregatedDataValue>> clazz, String key )
{
statementManager.initialise(); // Running in separate thread
- final BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
+ final BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( clazz ).init();
final BatchHandler<Object> cacheHandler = inMemoryBatchHandlerFactory.createBatchHandler( GenericBatchHandler.class ).setTableName( AGGREGATEDDATA_CACHE_PREFIX + key ).init();
@@ -166,46 +167,50 @@
final Collection<DataElementOperand> sumBoolOperands = sumBoolAggregator.filterOperands( operands, period.getPeriodType() );
final Collection<DataElementOperand> averageBoolOperands = averageBoolAggregator.filterOperands( operands, period.getPeriodType() );
- for ( final OrganisationUnit unit : organisationUnits )
+ for ( OrganisationUnitGroup group : organisationUnitGroups )
{
- operandList.init( period, unit );
-
- final int level = aggregationCache.getLevelOfOrganisationUnit( unit.getId() );
-
- final Collection<Integer> orgUnitChildren = hierarchy.getChildren( unit.getId() );
-
- valueMap.clear();
- valueMap.putAll( sumIntAggregator.getAggregatedValues( sumIntOperands, period, level, orgUnitChildren, key ) );
- valueMap.putAll( averageIntAggregator.getAggregatedValues( averageIntOperands, period, level, orgUnitChildren, key ) );
- valueMap.putAll( averageIntSingleValueAggregator.getAggregatedValues( averageIntSingleValueOperands, period, level, orgUnitChildren, key ) );
- valueMap.putAll( sumBoolAggregator.getAggregatedValues( sumBoolOperands, period, level, orgUnitChildren, key ) );
- valueMap.putAll( averageBoolAggregator.getAggregatedValues( averageBoolOperands, period, level, orgUnitChildren, key ) );
-
- if ( valueMap.size() > 0 )
- {
- for ( Entry<DataElementOperand, Double> entry : valueMap.entrySet() )
- {
- aggregatedValue.clear();
-
- final double value = getRounded( entry.getValue(), DECIMALS );
-
- aggregatedValue.setDataElementId( entry.getKey().getDataElementId() );
- aggregatedValue.setCategoryOptionComboId( entry.getKey().getOptionComboId() );
- aggregatedValue.setPeriodId( period.getId() );
- aggregatedValue.setPeriodTypeId( period.getPeriodType().getId() );
- aggregatedValue.setOrganisationUnitId( unit.getId() );
- aggregatedValue.setLevel( level );
- aggregatedValue.setValue( value );
-
- batchHandler.addObject( aggregatedValue );
-
- operandList.addValue( entry.getKey(), value );
- }
- }
-
- if ( operandList.hasValues() )
- {
- cacheHandler.addObject( operandList.getList() );
+ for ( final OrganisationUnit unit : organisationUnits )
+ {
+ operandList.init( period, unit );
+
+ final int level = aggregationCache.getLevelOfOrganisationUnit( unit.getId() );
+
+ final Collection<Integer> orgUnitChildren = hierarchy.getChildren( unit.getId() );
+
+ valueMap.clear();
+ valueMap.putAll( sumIntAggregator.getAggregatedValues( sumIntOperands, period, level, orgUnitChildren, key ) );
+ valueMap.putAll( averageIntAggregator.getAggregatedValues( averageIntOperands, period, level, orgUnitChildren, key ) );
+ valueMap.putAll( averageIntSingleValueAggregator.getAggregatedValues( averageIntSingleValueOperands, period, level, orgUnitChildren, key ) );
+ valueMap.putAll( sumBoolAggregator.getAggregatedValues( sumBoolOperands, period, level, orgUnitChildren, key ) );
+ valueMap.putAll( averageBoolAggregator.getAggregatedValues( averageBoolOperands, period, level, orgUnitChildren, key ) );
+
+ if ( valueMap.size() > 0 )
+ {
+ for ( Entry<DataElementOperand, Double> entry : valueMap.entrySet() )
+ {
+ aggregatedValue.clear();
+
+ final double value = getRounded( entry.getValue(), DECIMALS );
+
+ aggregatedValue.setDataElementId( entry.getKey().getDataElementId() );
+ aggregatedValue.setCategoryOptionComboId( entry.getKey().getOptionComboId() );
+ aggregatedValue.setPeriodId( period.getId() );
+ aggregatedValue.setPeriodTypeId( period.getPeriodType().getId() );
+ aggregatedValue.setOrganisationUnitId( unit.getId() );
+ aggregatedValue.setOrganisationUnitGroupId( group.getId() );
+ aggregatedValue.setLevel( level );
+ aggregatedValue.setValue( value );
+
+ batchHandler.addObject( aggregatedValue );
+
+ operandList.addValue( entry.getKey(), value );
+ }
+ }
+
+ if ( operandList.hasValues() )
+ {
+ cacheHandler.addObject( operandList.getList() );
+ }
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-12-05 18:54:20 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-12-06 19:40:38 +0000
@@ -48,7 +48,9 @@
import org.hisp.dhis.expression.ExpressionService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
+import org.hisp.dhis.jdbc.batchhandler.AggregatedDataValueBatchHandler;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -68,6 +70,11 @@
public class DefaultDataMartEngine
implements DataMartEngine
{
+ private static final Set<OrganisationUnitGroup> DUMMY_ORG_UNIT_GROUPS = new HashSet<OrganisationUnitGroup>()
+ { {
+ add( new OrganisationUnitGroup( "" ) );
+ } };
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -290,7 +297,8 @@
for ( List<OrganisationUnit> organisationUnitPage : organisationUnitPages )
{
- futures.add( dataElementDataMart.exportDataValues( allOperands, periods, organisationUnitPage, new DataElementOperandList( indicatorOperands ), key ) );
+ futures.add( dataElementDataMart.exportDataValues( allOperands, periods, organisationUnitPage,
+ DUMMY_ORG_UNIT_GROUPS, new DataElementOperandList( indicatorOperands ), AggregatedDataValueBatchHandler.class, key ) );
}
ConcurrentUtils.waitForCompletion( futures );
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java 2011-12-06 19:12:08 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitDataValueBatchHandler.java 2011-12-06 19:40:38 +0000
@@ -68,7 +68,7 @@
statementBuilder.setUniqueValue( value.getDataElementId() );
statementBuilder.setUniqueValue( value.getPeriodId() );
statementBuilder.setUniqueValue( value.getOrganisationUnitId() );
- statementBuilder.setUniqueValue( value.getGroupId() );
+ statementBuilder.setUniqueValue( value.getOrganisationUnitGroupId() );
}
protected void setColumns()
@@ -90,7 +90,7 @@
statementBuilder.setValue( value.getPeriodId() );
statementBuilder.setValue( value.getPeriodTypeId() );
statementBuilder.setValue( value.getOrganisationUnitId() );
- statementBuilder.setValue( value.getGroupId() );
+ statementBuilder.setValue( value.getOrganisationUnitGroupId() );
statementBuilder.setValue( value.getLevel() );
statementBuilder.setValue( value.getValue() );
}
=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java 2011-12-06 19:12:08 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/AggregatedOrgUnitIndicatorValueBatchHandler.java 2011-12-06 19:40:38 +0000
@@ -68,7 +68,7 @@
statementBuilder.setUniqueValue( value.getIndicatorId() );
statementBuilder.setUniqueValue( value.getPeriodId() );
statementBuilder.setUniqueValue( value.getOrganisationUnitId() );
- statementBuilder.setUniqueValue( value.getGroupId() );
+ statementBuilder.setUniqueValue( value.getOrganisationUnitGroupId() );
}
protected void setColumns()
@@ -92,7 +92,7 @@
statementBuilder.setValue( value.getPeriodId() );
statementBuilder.setValue( value.getPeriodTypeId() );
statementBuilder.setValue( value.getOrganisationUnitId() );
- statementBuilder.setValue( value.getGroupId() );
+ statementBuilder.setValue( value.getOrganisationUnitGroupId() );
statementBuilder.setValue( value.getLevel() );
statementBuilder.setValue( value.getAnnualized() );
statementBuilder.setValue( value.getFactor() );