← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5479: WIP org unit groups data mart

 

------------------------------------------------------------
revno: 5479
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-12-19 17:44:56 +0100
message:
  WIP org unit groups 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/aggregation/AggregatedOrgUnitDataValueService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedOrgUnitDataValueStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedOrgUnitDataValueService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedOrgUnitDataValueStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml
  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/impl/DefaultDataMartService.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitAboveOrEqualToLevelFilter.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.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-15 14:49:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValue.java	2011-12-19 16:44:56 +0000
@@ -267,11 +267,25 @@
     // hashCode and equals
     // ----------------------------------------------------------------------
 
+    @Override
+    public String toString()
+    {
+        return 
+            "[Data element: " + dataElementId + 
+            " option combo: " + categoryOptionComboId +
+            " period: " + periodId +
+            " org unit: " + organisationUnitId +
+            " org unit group: " + organisationUnitGroupId +
+            " value: " + value + "]";
+    }
+    
+    @Override
     public int hashCode()
     {
         return dataElementId * periodId * organisationUnitId * 17;
     }
     
+    @Override
     public boolean equals( Object object )
     {
         if ( this == object )

=== 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:40:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedIndicatorValue.java	2011-12-19 16:44:56 +0000
@@ -315,11 +315,24 @@
     // hashCode and equals
     // ----------------------------------------------------------------------
 
+    @Override
+    public String toString()
+    {
+        return 
+            "[Indicator: " + indicatorId +
+            " period: " + periodId +
+            " org unit: " + organisationUnitId +
+            " org unit group: " + organisationUnitGroupId +
+            " value: " + value + "]";
+    }
+    
+    @Override
     public int hashCode()
     {
         return indicatorId * periodId * organisationUnitId * 17;
     }
-    
+
+    @Override
     public boolean equals( Object o )
     {
         if ( this == o )

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedOrgUnitDataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedOrgUnitDataValueService.java	2011-12-11 01:24:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedOrgUnitDataValueService.java	2011-12-19 16:44:56 +0000
@@ -29,8 +29,23 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
+
 public interface AggregatedOrgUnitDataValueService
 {
+    String ID = AggregatedOrgUnitDataValueService.class.getName();
+    
+    // -------------------------------------------------------------------------
+    // AggregatedDataValue
+    // -------------------------------------------------------------------------
+    
+    Double getAggregatedValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo, 
+        Period period, OrganisationUnit organisationUnit, OrganisationUnitGroup group );
+    
     void deleteAggregatedDataValues( Collection<Integer> dataElementIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds );
     
     void deleteAggregatedDataValues( Collection<Integer> periodIds );
@@ -39,6 +54,10 @@
     
     void dropIndex( boolean dataElement, boolean indicator );
 
+    // -------------------------------------------------------------------------
+    // AggregatedIndicatorValue
+    // -------------------------------------------------------------------------
+    
     void deleteAggregatedIndicatorValues( Collection<Integer> indicatorIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds );
     
     void deleteAggregatedIndicatorValues( Collection<Integer> periodIds );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedOrgUnitDataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedOrgUnitDataValueStore.java	2011-12-11 01:24:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedOrgUnitDataValueStore.java	2011-12-19 16:44:56 +0000
@@ -31,6 +31,12 @@
 
 public interface AggregatedOrgUnitDataValueStore
 {
+    // -------------------------------------------------------------------------
+    // AggregatedDataValue
+    // -------------------------------------------------------------------------
+    
+    Double getAggregatedDataValue( int dataElement, int categoryOptionCombo, int period, int organisationUnit, int organisationUnitGroup );
+    
     void deleteAggregatedDataValues( Collection<Integer> dataElementIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds );
     
     void deleteAggregatedDataValues( Collection<Integer> periodIds );
@@ -38,6 +44,10 @@
     void createIndex( boolean dataElement, boolean indicator );
     
     void dropIndex( boolean dataElement, boolean indicator );
+
+    // -------------------------------------------------------------------------
+    // AggregatedIndicatorValue
+    // -------------------------------------------------------------------------
     
     void deleteAggregatedIndicatorValues( Collection<Integer> indicatorIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds );
     

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-12-15 08:46:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/options/SystemSettingManager.java	2011-12-19 16:44:56 +0000
@@ -72,7 +72,7 @@
     final int DEFAULT_MAX_NUMBER_OF_ATTEMPTS = 20;
     final int DEFAULT_TIMEFRAME_MINUTES = 1;
     final double DEFAULT_FACTOR_OF_DEVIATION = 2.0;
-    final int DEFAULT_ORGUNITGROUPSET_AGG_LEVEL = 1;    
+    final int DEFAULT_ORGUNITGROUPSET_AGG_LEVEL = 2;    
     final String DEFAULT_GOOGLE_MAPS_API_KEY = "ABQIAAAAut6AhySExnYIXm5s2OFIkxRKNzJ-_9njnryRTbvC6CtrS4sRvRREWnxwlZUa630pLuPf3nD9i4fq9w";
     
     final String AGGREGATION_STRATEGY_REAL_TIME = "real_time";

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedOrgUnitDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedOrgUnitDataValueService.java	2011-12-11 01:24:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedOrgUnitDataValueService.java	2011-12-19 16:44:56 +0000
@@ -2,6 +2,12 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.period.Period;
+
 /*
  * Copyright (c) 2004-2010, University of Oslo
  * All rights reserved.
@@ -47,6 +53,16 @@
     // AggregatedOrgUnitDataValueService implementation
     // -------------------------------------------------------------------------
 
+    // -------------------------------------------------------------------------
+    // AggregatedDataValue
+    // -------------------------------------------------------------------------
+
+    public Double getAggregatedValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo, 
+        Period period, OrganisationUnit organisationUnit, OrganisationUnitGroup group )
+    {
+        return aggregatedDataValueStore.getAggregatedDataValue( dataElement.getId(), optionCombo.getId(), period.getId(), organisationUnit.getId(), group.getId() );
+    }
+    
     public void deleteAggregatedDataValues( Collection<Integer> dataElementIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )
     {
         aggregatedDataValueStore.deleteAggregatedDataValues( dataElementIds, periodIds, organisationUnitIds );
@@ -68,7 +84,7 @@
     }
 
     // -------------------------------------------------------------------------
-    // AggregatedOrgUnitDataValueService implementation
+    // AggregatedIndicatorValue
     // -------------------------------------------------------------------------
 
     public void deleteAggregatedIndicatorValues( Collection<Integer> indicatorIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedOrgUnitDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedOrgUnitDataValueStore.java	2011-12-11 01:24:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedOrgUnitDataValueStore.java	2011-12-19 16:44:56 +0000
@@ -64,6 +64,20 @@
     // AggregatedOrgUnitDataValueStore implementation
     // -------------------------------------------------------------------------
 
+    public Double getAggregatedDataValue( int dataElement, int categoryOptionCombo, int period, int organisationUnit, int organisationUnitGroup )
+    {
+        final String sql =
+            "SELECT value " +
+            "FROM aggregatedorgunitdatavalue " +
+            "WHERE dataelementid = " + dataElement + " " +
+            "AND categoryoptioncomboid = " + categoryOptionCombo + " " +
+            "AND periodid = " + period + " " +
+            "AND organisationunitid = " + organisationUnit + " " +
+            "AND organisationunitgroupid = " + organisationUnitGroup;
+        
+        return statementManager.getHolder().queryForDouble( sql );
+    }
+
     public void deleteAggregatedDataValues( Collection<Integer> dataElementIds, Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )
     {
         final String sql =

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml	2011-11-23 18:07:35 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/datavalue/hibernate/DataValue.hbm.xml	2011-12-19 16:44:56 +0000
@@ -21,7 +21,7 @@
 
     <property name="comment" length="360" />
 
-    <property name="followup" not-null="true" />
+    <property name="followup" />
 
   </class>
 </hibernate-mapping>

=== 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-19 14:21:03 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2011-12-19 16:44:56 +0000
@@ -398,7 +398,7 @@
             clock.logTime( "Created indexes" );
         }
 
-        final boolean isGroups = organisationUnitGroupIds != null && organisationUnitGroupIds.size() > 0;
+        final boolean isGroups = organisationUnitGroups != null && organisationUnitGroups.size() > 0;
         
         final int groupLevel = (Integer) systemSettingManager.getSystemSetting( KEY_ORGUNITGROUPSET_AGG_LEVEL, DEFAULT_ORGUNITGROUPSET_AGG_LEVEL );
         

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java	2011-12-19 14:21:03 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java	2011-12-19 16:44:56 +0000
@@ -122,7 +122,7 @@
             periodIds.addAll( getIdentifiers( Period.class, periodService.reloadPeriods( relatives.getRelativePeriods() ) ) );
         }
         
-        dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, null, completeExport, new OutputHolderState() );
+        dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, organisationUnitGroupIds, completeExport, new OutputHolderState() );
     }
     
     // -------------------------------------------------------------------------

=== 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	2011-12-11 16:07:13 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/resources/META-INF/dhis/beans.xml	2011-12-19 16:44:56 +0000
@@ -24,6 +24,7 @@
 
   <bean id="org.hisp.dhis.datamart.engine.DataMartEngine" class="org.hisp.dhis.datamart.engine.DefaultDataMartEngine">
     <property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
+    <property name="aggregatedOrgUnitDataValueService" ref="org.hisp.dhis.aggregation.AggregatedOrgUnitDataValueService" />
     <property name="crossTabService" ref="org.hisp.dhis.datamart.crosstab.CrossTabService" />
     <property name="dataElementDataMart" ref="org.hisp.dhis.datamart.dataelement.DataElementDataMart" />
     <property name="indicatorDataMart" ref="org.hisp.dhis.datamart.indicator.IndicatorDataMart" />

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitAboveOrEqualToLevelFilter.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitAboveOrEqualToLevelFilter.java	2011-12-11 16:07:13 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitAboveOrEqualToLevelFilter.java	2011-12-19 16:44:56 +0000
@@ -50,6 +50,6 @@
     @Override
     public boolean retain( OrganisationUnit object )
     {
-        return object != null &&  object.getOrganisationUnitLevel() >= level;
+        return object != null && object.getOrganisationUnitLevel() <= level;
     }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2011-11-22 15:48:30 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2011-12-19 16:44:56 +0000
@@ -37,6 +37,7 @@
 import java.util.Set;
 
 import org.hisp.dhis.aggregation.AggregatedDataValueService;
+import org.hisp.dhis.aggregation.AggregatedOrgUnitDataValueService;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.concept.Concept;
 import org.hisp.dhis.constant.Constant;
@@ -133,6 +134,8 @@
     protected OrganisationUnitGroupService organisationUnitGroupService;
 
     protected AggregatedDataValueService aggregatedDataValueService;
+    
+    protected AggregatedOrgUnitDataValueService aggregatedOrgUnitDataValueService;
 
     protected PeriodService periodService;