← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3839: Minor fix

 

------------------------------------------------------------
revno: 3839
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-06-04 15:52:42 +0200
message:
  Minor fix
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/CrossTabService.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/DefaultCrossTabService.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/CrossTabStore.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/JDBCCrossTabStore.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/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.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/datavalue/DataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java	2011-06-04 13:52:42 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.util.Collection;
+import java.util.Set;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -260,7 +261,5 @@
      * @param operands the data element operands to filter.
      * @return the data element operands with registered data values.
      */
-    Collection<DataElementOperand> getOperandsWithDataValues( Collection<DataElementOperand> operands );    
+    Set<DataElementOperand> getOperandsWithDataValues( Set<DataElementOperand> operands );    
 }
-
-

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java	2011-06-04 13:52:42 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.util.Collection;
+import java.util.Set;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -252,5 +253,5 @@
      * @param operands the data element operands to filter.
      * @return the data element operands with registered data values.
      */
-    Collection<DataElementOperand> getOperandsWithDataValues( Collection<DataElementOperand> operands );
+    Set<DataElementOperand> getOperandsWithDataValues( Set<DataElementOperand> operands );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java	2011-06-04 13:52:42 +0000
@@ -30,6 +30,7 @@
 import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE;
 
 import java.util.Collection;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -198,7 +199,7 @@
         return true;
     }
 
-    public Collection<DataElementOperand> getOperandsWithDataValues( Collection<DataElementOperand> operands )
+    public Set<DataElementOperand> getOperandsWithDataValues( Set<DataElementOperand> operands )
     {
         return dataValueStore.getOperandsWithDataValues( operands );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2011-04-22 21:04:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2011-06-04 13:52:42 +0000
@@ -31,6 +31,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Set;
 
 import org.amplecode.quick.StatementHolder;
 import org.amplecode.quick.StatementManager;
@@ -377,9 +378,9 @@
         return (DataValue) query.uniqueResult();
     }
     
-    public Collection<DataElementOperand> getOperandsWithDataValues( Collection<DataElementOperand> operands )
+    public Set<DataElementOperand> getOperandsWithDataValues( Set<DataElementOperand> operands )
     {
-        final Collection<DataElementOperand> operandsWithData = new ArrayList<DataElementOperand>();
+        final Set<DataElementOperand> operandsWithData = new HashSet<DataElementOperand>();
         
         final StatementHolder holder = statementManager.getHolder();
         

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/CrossTabService.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/CrossTabService.java	2011-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/CrossTabService.java	2011-06-04 13:52:42 +0000
@@ -28,6 +28,8 @@
  */
 
 import java.util.Collection;
+import java.util.List;
+import java.util.Set;
 
 import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.datamart.CrossTabDataValue;
@@ -46,18 +48,18 @@
      * @param operands the DataElementOperands.
      * @return the DataElementOperands with data.
      */
-    Collection<DataElementOperand> getOperandsWithData( Collection<DataElementOperand> operands );
+    Set<DataElementOperand> getOperandsWithData( Set<DataElementOperand> operands );
     
     /**
      * Creates and populates the crosstab table. Operands without data will be
      * removed from the operands argument collection.
      * 
-     * @param operands the collection of DataElementOperands.
+     * @param operands the list of DataElementOperands.
      * @param periodIds the collection of Period identifiers.
      * @param organisationUnitIds the collection of OrganisationUnit identifiers.
      * @return a List of random keys for each generated crosstab table. 
      */
-    String populateCrossTabTable( Collection<DataElementOperand> operands, 
+    String populateCrossTabTable( List<DataElementOperand> operands, 
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds );
 
     /**

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/DefaultCrossTabService.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/DefaultCrossTabService.java	2011-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/DefaultCrossTabService.java	2011-06-04 13:52:42 +0000
@@ -31,6 +31,7 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.amplecode.quick.BatchHandler;
 import org.amplecode.quick.BatchHandlerFactory;
@@ -90,13 +91,13 @@
     // CrossTabService implementation
     // -------------------------------------------------------------------------
 
-    public Collection<DataElementOperand> getOperandsWithData( Collection<DataElementOperand> operands )
+    public Set<DataElementOperand> getOperandsWithData( Set<DataElementOperand> operands )
     {
         return dataValueService.getOperandsWithDataValues( operands );
     }
     
-    public String populateCrossTabTable( final Collection<DataElementOperand> operands,
-        final Collection<Integer> periodIds, final Collection<Integer> organisationUnitIds )
+    public String populateCrossTabTable( List<DataElementOperand> operands,
+        Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )
     {
         final String key = RandomStringUtils.randomAlphanumeric( 8 );
         

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/CrossTabStore.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/CrossTabStore.java	2011-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/CrossTabStore.java	2011-06-04 13:52:42 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.util.Collection;
+import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElementOperand;
 import org.hisp.dhis.datamart.CrossTabDataValue;
@@ -49,7 +50,7 @@
      * 
      * @param operands the DataElementOperands.
      */
-    void createCrossTabTable( Collection<DataElementOperand> operands, String key );
+    void createCrossTabTable( List<DataElementOperand> operands, String key );
 
     /**
      * Drops the crosstab table.

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/JDBCCrossTabStore.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/JDBCCrossTabStore.java	2011-06-02 12:50:56 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/crosstab/jdbc/JDBCCrossTabStore.java	2011-06-04 13:52:42 +0000
@@ -62,7 +62,7 @@
     // CrossTabStore implementation
     // -------------------------------------------------------------------------
 
-    public void createCrossTabTable( final Collection<DataElementOperand> operands, String key )
+    public void createCrossTabTable( List<DataElementOperand> operands, String key )
     {
         final StringBuffer sql = new StringBuffer( "CREATE TABLE " + TABLE_PREFIX + key + " ( " );
         

=== 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-06-03 21:33:10 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2011-06-04 13:52:42 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
@@ -192,7 +193,7 @@
         // Remove operands without data
         // ---------------------------------------------------------------------
 
-        allOperands = new HashSet<DataElementOperand>( crossTabService.getOperandsWithData( allOperands ) );
+        allOperands = crossTabService.getOperandsWithData( allOperands );
 
         dataElementOperands.retainAll( allOperands );
         indicatorOperands.retainAll( allOperands );
@@ -208,7 +209,7 @@
         Collection<Integer> childrenIds = organisationUnitService.getOrganisationUnitHierarchy().getChildren( organisationUnitIds );
         Collection<Integer> intersectingPeriodIds = ConversionUtils.getIdentifiers( Period.class, periodService.getIntersectionPeriods( periods ) );
 
-        String key = crossTabService.populateCrossTabTable( allOperands, intersectingPeriodIds, childrenIds );
+        String key = crossTabService.populateCrossTabTable( new ArrayList<DataElementOperand>( allOperands ), intersectingPeriodIds, childrenIds );
         
         if ( CollectionUtils.isEmpty( allOperands ) )
         {
@@ -249,7 +250,7 @@
         {
             count += dataElementDataMart.exportDataValues( dataElementOperands, periods, organisationUnits, key );
 
-            log.info( "Exported values for data element operands: " + TimeUtils.getHMS() );
+            log.info( "Exported values for data element operands (" + dataElementOperands.size() + "): " + TimeUtils.getHMS() );
         }
 
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java	2011-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/test/java/org/hisp/dhis/datamart/crosstab/CrossTabServiceTest.java	2011-06-04 13:52:42 +0000
@@ -31,10 +31,12 @@
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertTrue;
 
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 
 import org.hisp.dhis.DhisTest;
 import org.hisp.dhis.dataelement.DataElement;
@@ -65,7 +67,7 @@
     
     private Iterator<Period> generatedPeriods;
 
-    private Collection<DataElementOperand> operands;
+    private List<DataElementOperand> operands;
     private Collection<Integer> periodIds;
     private Collection<Integer> organisationUnitIds;
 
@@ -154,7 +156,7 @@
             organisationUnitIds.add( organisationUnitService.addOrganisationUnit( organisationUnit ) );
         }
         
-        operands = categoryService.getOperands( dataElements );
+        operands = new ArrayList<DataElementOperand>( categoryService.getOperands( dataElements ) );
         
         for ( DataElement dataElement : dataElements )
         {