← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4052: Minor simplification in datamart

 

------------------------------------------------------------
revno: 4052
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-07-01 09:12:30 +0200
message:
  Minor simplification in datamart
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datamart/DataMartService.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/DataMartEngine.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/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/IndicatorDataMart.java
  dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PaginatedList.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/PaginatedListTest.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/datamart/DataMartService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datamart/DataMartService.java	2011-01-21 12:44:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datamart/DataMartService.java	2011-07-01 07:12:30 +0000
@@ -48,7 +48,7 @@
      * @id the DataMartExport identifier.
      * @return the number of exported values.
      */
-    int export( int id );
+    void export( int id );
 
     /**
      * Exports to data mart for the given arguments.
@@ -57,9 +57,8 @@
      * @param indicatorIds the indicator identifiers.
      * @param periodIds the period identifiers.
      * @param organisationUnitIds the organisation unit identifiers.
-     * @return the number of exported values.
      */
-    int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
+    void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds );
     
     /**
@@ -70,9 +69,8 @@
      * @param periodIds the period identifiers.
      * @param organisationUnitIds the organisation unit identifiers.
      * @param relatives the RelativePeriods.
-     * @return the number of exported values.
      */
-    int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
+    void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds, RelativePeriods relatives );
 
     /**
@@ -85,9 +83,8 @@
      * @param relatives the RelativePeriods.
      * @param useIndexes indicates whether to create indexes on the data mart tables
      *        after the export process.
-     * @return the number of exported values.
      */
-    int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
+    void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds, RelativePeriods relatives, boolean useIndexes );
     
     // ----------------------------------------------------------------------

=== 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-06-05 16:40:02 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DataElementDataMart.java	2011-07-01 07:12:30 +0000
@@ -39,6 +39,6 @@
  */
 public interface DataElementDataMart
 {
-    int exportDataValues( Collection<DataElementOperand> operands, Collection<Period> periods, 
+    void exportDataValues( Collection<DataElementOperand> operands, Collection<Period> periods, 
         Collection<OrganisationUnit> organisationUnits, DataElementOperandList operandList, 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-06-06 05:36:15 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/dataelement/DefaultDataElementDataMart.java	2011-07-01 07:12:30 +0000
@@ -132,7 +132,7 @@
     // DataMart functionality
     // -------------------------------------------------------------------------
     
-    public int exportDataValues( Collection<DataElementOperand> operands, Collection<Period> periods, 
+    public void exportDataValues( Collection<DataElementOperand> operands, Collection<Period> periods, 
         Collection<OrganisationUnit> organisationUnits, DataElementOperandList operandList, String key )
     {
         final BatchHandler<AggregatedDataValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedDataValueBatchHandler.class ).init();
@@ -141,8 +141,6 @@
         
         final OrganisationUnitHierarchy hierarchy = organisationUnitService.getOrganisationUnitHierarchy().prepareChildren( organisationUnits );
         
-        int count = 0;
-        
         final AggregatedDataValue aggregatedValue = new AggregatedDataValue();
         
         for ( final Period period : periods )
@@ -186,8 +184,6 @@
                         batchHandler.addObject( aggregatedValue );
                         
                         operandList.addValue( entry.getKey(), value );
-                        
-                        count++;
                     }
                 }
                 
@@ -203,7 +199,5 @@
         batchHandler.flush();
         
         cacheHandler.flush();
-        
-        return count;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DataMartEngine.java	2011-01-21 12:44:09 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DataMartEngine.java	2011-07-01 07:12:30 +0000
@@ -46,8 +46,7 @@
      * @param useIndexes indicates whether to create indexes on the data mart tables
      *        after the export process.
      * @param processState the state object.
-     * @return the number of values exported to the data mart tables.
      */
-    int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
+    void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds, boolean useIndexes, ProcessState processState );
 }

=== 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-12 09:34:27 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2011-07-01 07:12:30 +0000
@@ -147,11 +147,9 @@
     // -------------------------------------------------------------------------
 
     @Transactional
-    public int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
+    public void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds, boolean useIndexes, ProcessState state )
     {
-        int count = 0;
-
         Clock clock = new Clock().startClock().logTime( "Data mart export process started" );
         
         // ---------------------------------------------------------------------
@@ -247,7 +245,7 @@
 
         if ( allOperands.size() > 0 )
         {
-            count += dataElementDataMart.exportDataValues( allOperands, periods, organisationUnits, operandList, key );
+            dataElementDataMart.exportDataValues( allOperands, periods, organisationUnits, operandList, key );
 
             clock.logTime( "Exported values for data element operands (" + allOperands.size() + ")" );
         }
@@ -268,7 +266,7 @@
 
         if ( isIndicators )
         {
-            count += indicatorDataMart.exportIndicatorValues( indicators, periods, organisationUnits, indicatorOperands, key );
+            indicatorDataMart.exportIndicatorValues( indicators, periods, organisationUnits, indicatorOperands, key );
 
             clock.logTime( "Exported values for indicators (" + indicators.size() + ")" );
         }
@@ -295,8 +293,6 @@
         aggregationCache.clearCache();
 
         clock.logTime( "Data mart export process completed" );
-
-        return count;
     }
 
     // -------------------------------------------------------------------------

=== 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-03-01 23:29:00 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/impl/DefaultDataMartService.java	2011-07-01 07:12:30 +0000
@@ -81,7 +81,7 @@
     // -------------------------------------------------------------------------
 
     @Transactional
-    public int export( int id )
+    public void export( int id )
     {
         DataMartExport dataMartExport = getDataMartExport( id );
         
@@ -92,7 +92,7 @@
             allPeriods.addAll( periodService.reloadPeriods( dataMartExport.getRelatives().getRelativePeriods() ) );
         }
         
-        return dataMartEngine.export( 
+        dataMartEngine.export( 
             getIdentifiers( DataElement.class, dataMartExport.getDataElements() ), 
             getIdentifiers( Indicator.class, dataMartExport.getIndicators() ), 
             getIdentifiers( Period.class, allPeriods ),
@@ -101,21 +101,21 @@
     }
 
     @Transactional
-    public int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
+    public void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds )
     {
-        return dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, false, new OutputHolderState() );
+        dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, false, new OutputHolderState() );
     }
     
     @Transactional
-    public int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
+    public void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds, RelativePeriods relatives )
     {
-        return export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, relatives, false );
+        export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, relatives, false );
     }
 
     @Transactional
-    public int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
+    public void export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds, RelativePeriods relatives, boolean useIndexes )
     {
         if ( relatives != null )
@@ -123,7 +123,7 @@
             periodIds.addAll( getIdentifiers( Period.class, periodService.reloadPeriods( relatives.getRelativePeriods( 1, null, false ) ) ) );
         }
         
-        return dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, useIndexes, new OutputHolderState() );
+        dataMartEngine.export( dataElementIds, indicatorIds, periodIds, organisationUnitIds, useIndexes, new OutputHolderState() );
     }
     
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java	2011-06-29 15:25:19 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java	2011-07-01 07:12:30 +0000
@@ -117,13 +117,11 @@
     // IndicatorDataMart implementation
     // -------------------------------------------------------------------------
     
-    public int exportIndicatorValues( final Collection<Indicator> indicators, final Collection<Period> periods, 
+    public void exportIndicatorValues( final Collection<Indicator> indicators, final Collection<Period> periods, 
         final Collection<OrganisationUnit> organisationUnits, final Collection<DataElementOperand> operands, String key )
     {
         final BatchHandler<AggregatedIndicatorValue> batchHandler = batchHandlerFactory.createBatchHandler( AggregatedIndicatorValueBatchHandler.class ).init();
 
-        int count = 0;
-        
         final boolean omitZeroNumerator = (Boolean) systemSettingManager.getSystemSetting( KEY_OMIT_INDICATORS_ZERO_NUMERATOR_DATAMART, false );
         
         final AggregatedIndicatorValue indicatorValue = new AggregatedIndicatorValue();
@@ -173,8 +171,6 @@
                                 indicatorValue.setDenominatorValue( getRounded( denominatorValue, DECIMALS ) );
                                 
                                 batchHandler.addObject( indicatorValue );
-                                
-                                count++;
                             }
                         }
                     }
@@ -185,8 +181,6 @@
         }
         
         batchHandler.flush();
-        
-        return count;
     }
     
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/IndicatorDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/IndicatorDataMart.java	2011-04-15 15:02:55 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/IndicatorDataMart.java	2011-07-01 07:12:30 +0000
@@ -39,6 +39,6 @@
  */
 public interface IndicatorDataMart
 {
-    int exportIndicatorValues( Collection<Indicator> indicators, Collection<Period> periods, 
+    void exportIndicatorValues( Collection<Indicator> indicators, Collection<Period> periods, 
         Collection<OrganisationUnit> organisationUnits, Collection<DataElementOperand> operands, String key );
 }

=== modified file 'dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml	2011-06-23 14:44:17 +0000
+++ dhis-2/dhis-support/dhis-support-external/src/main/resources/META-INF/dhis/beans.xml	2011-07-01 07:12:30 +0000
@@ -1,13 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xmlns:context="http://www.springframework.org/schema/context"; xmlns:aop="http://www.springframework.org/schema/aop";
+  xmlns:task="http://www.springframework.org/schema/task";
   xsi:schemaLocation="
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
-    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd";>
+    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+	http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd";>
 
   <context:annotation-config />
-
+  
+  <task:annotation-driven/>
+    
   <bean id="configurationManager" class="org.hisp.dhis.external.configuration.DefaultConfigurationManager" />
 
   <bean id="dhisResolver" class="org.hisp.dhis.external.location.DefaultLocationManagerResolver">

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PaginatedList.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PaginatedList.java	2011-06-30 14:58:12 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/PaginatedList.java	2011-07-01 07:12:30 +0000
@@ -117,4 +117,21 @@
         
         return m == 0 ? r : ( r + 1 );
     }
+    
+    /**
+     * Returns a list of all pages.
+     */
+    public List<List<T>> getPages()
+    {
+        List<List<T>> pages = new ArrayList<List<T>>();
+        
+        List<T> page = new ArrayList<T>();
+        
+        while ( ( page = nextPage() ) != null )
+        {
+            pages.add( page );
+        }
+        
+        return pages;
+    }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/PaginatedListTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/PaginatedListTest.java	2011-06-30 14:58:12 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/PaginatedListTest.java	2011-07-01 07:12:30 +0000
@@ -136,4 +136,20 @@
         assertNull( page );
     }
     
+    @Test
+    public void testGetPages()
+    {
+        PaginatedList<String> list = new PaginatedList<String>( Arrays.asList( "A", "B", "C", "D", "E" ) ).setPageSize( 2 );
+        
+        List<List<String>> pages = list.getPages();
+
+        assertNotNull( pages );
+        assertEquals( 3, pages.size() );
+        
+        List<String> page = pages.get( 0 );
+        assertNotNull( page );
+        assertEquals( 2, page.size() );
+        assertTrue( page.contains( "A" ) );
+        assertTrue( page.contains( "B" ) );
+    }
 }