dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08947
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2267: Simplification in datamart
------------------------------------------------------------
revno: 2267
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2010-12-02 23:32:52 +0100
message:
Simplification in datamart
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/CalculatedDataElementDataMart.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/DefaultCalculatedDataElementDataMart.java
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/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/expression/ExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2010-09-01 09:34:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2010-12-02 22:32:52 +0000
@@ -31,6 +31,7 @@
import java.util.Map;
import java.util.Set;
+import org.hisp.dhis.dataelement.CalculatedDataElement;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.period.Period;
@@ -114,7 +115,7 @@
* @param id the CalculatedDataElement identifier.
* @return a Set of DataElements.
*/
- Set<DataElement> getDataElementsInCalculatedDataElement( int id );
+ Set<DataElement> getDataElementsInCalculatedDataElement( CalculatedDataElement calculatedDataElement );
/**
* Returns all DataElements included in the given expression string.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2010-11-29 17:19:06 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2010-12-02 22:32:52 +0000
@@ -152,16 +152,9 @@
return expressionString != null ? calculateExpression( expressionString ) : null;
}
- public Set<DataElement> getDataElementsInCalculatedDataElement( int id )
+ public Set<DataElement> getDataElementsInCalculatedDataElement( CalculatedDataElement calculatedDataElement )
{
- final DataElement dataElement = dataElementService.getDataElement( id );
-
- if ( dataElement != null && dataElement instanceof CalculatedDataElement )
- {
- return getDataElementsInExpression( ((CalculatedDataElement) dataElement).getExpression().getExpression() );
- }
-
- return null;
+ return calculatedDataElement != null ? getDataElementsInExpression( calculatedDataElement.getExpression().getExpression() ) : null;
}
public Set<DataElement> getDataElementsInExpression( String expression )
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/CalculatedDataElementDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/CalculatedDataElementDataMart.java 2010-12-02 21:24:43 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/CalculatedDataElementDataMart.java 2010-12-02 22:32:52 +0000
@@ -29,6 +29,7 @@
import java.util.Collection;
+import org.hisp.dhis.dataelement.CalculatedDataElement;
import org.hisp.dhis.dataelement.DataElementOperand;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.Period;
@@ -39,6 +40,6 @@
*/
public interface CalculatedDataElementDataMart
{
- int exportCalculatedDataElements( Collection<Integer> calculatedDataElementIds,
+ int exportCalculatedDataElements( Collection<CalculatedDataElement> calculatedDataElements,
Collection<Period> periods, Collection<OrganisationUnit> organisationUnits, Collection<DataElementOperand> operands, String key );
}
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/DefaultCalculatedDataElementDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/DefaultCalculatedDataElementDataMart.java 2010-12-02 21:24:43 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/calculateddataelement/DefaultCalculatedDataElementDataMart.java 2010-12-02 22:32:52 +0000
@@ -43,7 +43,6 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementOperand;
-import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.datamart.aggregation.cache.AggregationCache;
import org.hisp.dhis.datamart.aggregation.dataelement.DataElementAggregator;
import org.hisp.dhis.datamart.crosstab.CrossTabService;
@@ -101,13 +100,6 @@
{
this.crossTabService = crossTabService;
}
-
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
private DataElementCategoryService categoryService;
@@ -134,13 +126,11 @@
// CalculatedDataElementDataMart implementation
// -------------------------------------------------------------------------
- public int exportCalculatedDataElements( final Collection<Integer> calculatedDataElementIds, final Collection<Period> periods,
+ public int exportCalculatedDataElements( final Collection<CalculatedDataElement> calculatedDataElements, final Collection<Period> periods,
final Collection<OrganisationUnit> organisationUnits, final Collection<DataElementOperand> operands, String key )
{
final Map<DataElementOperand, Integer> operandIndexMap = crossTabService.getOperandIndexMap( operands, key );
- final Collection<DataElement> calculatedDataElements = dataElementService.getDataElements( calculatedDataElementIds );
-
final DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
final BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
=== 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 2010-12-02 22:05:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2010-12-02 22:32:52 +0000
@@ -227,16 +227,16 @@
Collection<Indicator> indicators = indicatorService.getIndicators( indicatorIds );
Collection<Period> periods = periodService.getPeriods( periodIds );
Collection<OrganisationUnit> organisationUnits = organisationUnitService.getOrganisationUnits( organisationUnitIds );
-
+ Collection<CalculatedDataElement> calculatedDataElements = dataElementService.getCalculatedDataElements( dataElementIds );
+
// ---------------------------------------------------------------------
// Filter and get operands
// ---------------------------------------------------------------------
final Set<Integer> nonCalculatedDataElementIds = filterCalculatedDataElementIds( dataElementIds, false );
- final Set<Integer> calculatedDataElementIds = filterCalculatedDataElementIds( dataElementIds, true );
final Set<Integer> dataElementInIndicatorIds = getDataElementIdsInIndicators( indicators );
- final Set<Integer> dataElementInCalculatedDataElementIds = getDataElementIdsInCalculatedDataElements( calculatedDataElementIds );
+ final Set<Integer> dataElementInCalculatedDataElementIds = getDataElementIdsInCalculatedDataElements( calculatedDataElements );
final Set<Integer> allDataElementIds = new HashSet<Integer>();
allDataElementIds.addAll( nonCalculatedDataElementIds );
@@ -374,12 +374,12 @@
// Calculated data element export
// ---------------------------------------------------------------------
- if ( calculatedDataElementIds != null && calculatedDataElementIds.size() > 0 )
+ if ( calculatedDataElements != null && calculatedDataElements.size() > 0 )
{
- count += calculatedDataElementDataMart.exportCalculatedDataElements( calculatedDataElementIds, periods,
+ count += calculatedDataElementDataMart.exportCalculatedDataElements( calculatedDataElements, periods,
organisationUnits, dataElementInCalculatedDataElementOperands, key );
- log.info( "Exported values for calculated data elements (" + calculatedDataElementIds.size() + "): "
+ log.info( "Exported values for calculated data elements (" + calculatedDataElements.size() + "): "
+ TimeUtils.getHMS() );
}
@@ -440,13 +440,13 @@
* Returns all data element identifiers included in the calculated data
* elements in the given identifier collection.
*/
- private Set<Integer> getDataElementIdsInCalculatedDataElements( final Collection<Integer> calculatedDataElementIds )
+ private Set<Integer> getDataElementIdsInCalculatedDataElements( final Collection<CalculatedDataElement> calculatedDataElements )
{
final Set<Integer> identifiers = new HashSet<Integer>();
- for ( final Integer id : calculatedDataElementIds )
+ for ( final CalculatedDataElement calculatedDataElement : calculatedDataElements )
{
- final Set<DataElement> dataElements = expressionService.getDataElementsInCalculatedDataElement( id );
+ final Set<DataElement> dataElements = expressionService.getDataElementsInCalculatedDataElement( calculatedDataElement );
if ( dataElements != null )
{
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml 2010-12-02 21:24:43 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml 2010-12-02 22:32:52 +0000
@@ -191,8 +191,6 @@
ref="org.hisp.dhis.datamart.aggregation.dataelement.AverageIntSingleValueAggregator"/>
<property name="crossTabService"
ref="org.hisp.dhis.datamart.crosstab.CrossTabService"/>
- <property name="dataElementService"
- ref="org.hisp.dhis.dataelement.DataElementService"/>
<property name="categoryService"
ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
<property name="aggregationCache"