← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1081: Merged CollectionConversionUtils class with ConversionUtils.

 

------------------------------------------------------------
revno: 1081
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Mon 2009-11-23 12:51:03 +0100
message:
  Merged CollectionConversionUtils class with ConversionUtils.
removed:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CollectionConversionUtils.java
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java
  dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.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.
=== removed file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CollectionConversionUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CollectionConversionUtils.java	2009-11-21 16:22:30 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CollectionConversionUtils.java	1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
-package org.hisp.dhis.system.util;
-
-/*
- * Copyright (c) 2004-2007, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * 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.List;
-import java.util.Set;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class CollectionConversionUtils
-{
-    /**
-     * Creates a Set of objects out of a Collection of objects.
-     * 
-     * @param objects the Collection of objects.
-     * @return a Set of objects.
-     */
-    public static <T> Set<T> getSet( Collection<T> objects )
-    {
-        Set<T> set = new HashSet<T>();
-        
-        for ( T object : objects )
-        {
-            set.add( object );
-        }
-        
-        return set;
-    }
-    
-    /**
-     * Creates a List of objects out of a Collection of objects.
-     * 
-     * @param objects the Collection of objects.
-     * @return a List of objects.
-     */
-    public static <T> List<T> getList( Collection<T> objects )
-    {
-        List<T> list = new ArrayList<T>();
-        
-        for ( T object : objects )
-        {
-            list.add( object );
-        }
-        
-        return list;
-    }
-}

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java	2009-11-21 16:22:30 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java	2009-11-23 11:51:03 +0000
@@ -30,6 +30,9 @@
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * @author Lars Helge Overland
@@ -125,4 +128,40 @@
         
         return Integer.parseInt( string );
     }
+    
+    /**
+     * Creates a Set of objects out of a Collection of objects.
+     * 
+     * @param objects the Collection of objects.
+     * @return a Set of objects.
+     */
+    public static <T> Set<T> getSet( Collection<T> objects )
+    {
+        Set<T> set = new HashSet<T>();
+        
+        for ( T object : objects )
+        {
+            set.add( object );
+        }
+        
+        return set;
+    }
+    
+    /**
+     * Creates a List of objects out of a Collection of objects.
+     * 
+     * @param objects the Collection of objects.
+     * @return a List of objects.
+     */
+    public static <T> List<T> getList( Collection<T> objects )
+    {
+        List<T> list = new ArrayList<T>();
+        
+        for ( T object : objects )
+        {
+            list.add( object );
+        }
+        
+        return list;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java'
--- dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java	2009-11-21 16:22:30 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java	2009-11-23 11:51:03 +0000
@@ -37,7 +37,7 @@
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.PeriodService;
-import org.hisp.dhis.system.util.CollectionConversionUtils;
+import static org.hisp.dhis.system.util.ConversionUtils.*;
 
 import com.opensymphony.xwork2.Action;
 
@@ -143,14 +143,10 @@
         
         export.setName( name );
         
-        export.setDataElements( CollectionConversionUtils.getSet( 
-            dataElementService.getDataElements( getIntegerCollection( selectedDataElements ) ) ) );
-        export.setIndicators( CollectionConversionUtils.getSet( 
-            indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) ) );
-        export.setPeriods( CollectionConversionUtils.getSet( 
-            periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) ) );
-        export.setOrganisationUnits( CollectionConversionUtils.getSet( 
-            organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) ) );
+        export.setDataElements( getSet( dataElementService.getDataElements( getIntegerCollection( selectedDataElements ) ) ) );
+        export.setIndicators( getSet( indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) ) );
+        export.setPeriods( getSet( periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) ) );
+        export.setOrganisationUnits( getSet( organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) ) );
         
         dataMartExportService.saveDataMartExport( export );
         

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java	2009-11-21 16:22:30 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/chart/action/SaveChartAction.java	2009-11-23 11:51:03 +0000
@@ -41,7 +41,8 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.reporttable.RelativePeriods;
-import org.hisp.dhis.system.util.CollectionConversionUtils;
+
+import static org.hisp.dhis.system.util.ConversionUtils.*;
 
 import com.opensymphony.xwork2.Action;
 
@@ -271,12 +272,9 @@
     {
         Chart chart = new Chart();
 
-        List<Indicator> indicators = CollectionConversionUtils.getList( 
-            indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) );
-        List<Period> periods = CollectionConversionUtils.getList( 
-            periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) );        
-        List<OrganisationUnit> organisationUnits = CollectionConversionUtils.getList( 
-            organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) );
+        List<Indicator> indicators = getList( indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) );
+        List<Period> periods = getList( periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) );        
+        List<OrganisationUnit> organisationUnits = getList( organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) );
 
         chart.setId( id != null ? id : 0 );
         chart.setTitle( title );

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java	2009-11-21 16:22:30 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/reportviewer/action/AddReportAction.java	2009-11-23 11:51:03 +0000
@@ -40,12 +40,12 @@
 import org.hisp.dhis.report.ReportService;
 import org.hisp.dhis.report.manager.ReportConfiguration;
 import org.hisp.dhis.reporttable.ReportTableService;
-import org.hisp.dhis.system.util.CollectionConversionUtils;
-import org.hisp.dhis.system.util.ConversionUtils;
 import org.hisp.dhis.system.util.StreamUtils;
 
 import com.opensymphony.xwork2.ActionSupport;
 
+import static org.hisp.dhis.system.util.ConversionUtils.*;
+
 /**
  * @author Lars Helge Overland
  * @version $Id: UploadDesignAction.java 5207 2008-05-22 12:16:36Z larshelg $
@@ -250,8 +250,8 @@
         report.setName( name );
         report.setDesign( fileName );
         report.setType( type );
-        report.setReportTables( selectedReportTables != null ? CollectionConversionUtils.getSet( 
-            reportTableService.getReportTables( ConversionUtils.getIntegerCollection( selectedReportTables ) ) ) : null );
+        report.setReportTables( selectedReportTables != null ? getSet( 
+            reportTableService.getReportTables( getIntegerCollection( selectedReportTables ) ) ) : null );
         
         reportService.saveReport( report );
         

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2009-11-21 16:22:30 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/tablecreator/action/SaveTableAction.java	2009-11-23 11:51:03 +0000
@@ -27,7 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.system.util.ConversionUtils.getIntegerCollection;
+import static org.hisp.dhis.system.util.ConversionUtils.*;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -48,7 +48,6 @@
 import org.hisp.dhis.reporttable.ReportParams;
 import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.reporttable.ReportTableService;
-import org.hisp.dhis.system.util.CollectionConversionUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -347,20 +346,11 @@
     private ReportTable getReportTable()
         throws Exception
     {
-        List<DataElement> dataElements = CollectionConversionUtils.getList( 
-            dataElementService.getDataElements( getIntegerCollection( selectedDataElements ) ) );
-        
-        List<Indicator> indicators = CollectionConversionUtils.getList( 
-            indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) );
-        
-        List<DataSet> dataSets = CollectionConversionUtils.getList( 
-            dataSetService.getDataSets( getIntegerCollection( selectedDataSets ) ) );
-        
-        List<Period> periods = CollectionConversionUtils.getList( 
-            periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) );
-        
-        List<OrganisationUnit> organisationUnits = CollectionConversionUtils.getList( 
-            organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) );
+        List<DataElement> dataElements = getList( dataElementService.getDataElements( getIntegerCollection( selectedDataElements ) ) );        
+        List<Indicator> indicators = getList( indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) );        
+        List<DataSet> dataSets = getList( dataSetService.getDataSets( getIntegerCollection( selectedDataSets ) ) );        
+        List<Period> periods = getList( periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) );        
+        List<OrganisationUnit> units = getList( organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) );
 
         DimensionSet dimensionSet = dimensionService.getDimensionSet( dimensionSetId );
         
@@ -391,7 +381,7 @@
         if ( tableId == null )
         {
             reportTable = new ReportTable( tableName, mode, regression,
-                dataElements, indicators, dataSets, periods, null, organisationUnits, null,
+                dataElements, indicators, dataSets, periods, null, units, null,
                 dimensionSet, doIndicators, doCategoryOptionCombos, doPeriods, doOrganisationUnits, relatives, reportParams, 
                 null, null );
         }
@@ -405,7 +395,7 @@
             reportTable.setIndicators( indicators );
             reportTable.setDataSets( dataSets );
             reportTable.setPeriods( periods );
-            reportTable.setUnits( organisationUnits );
+            reportTable.setUnits( units );
             reportTable.setDoIndicators( doIndicators );
             reportTable.setDoCategoryOptionCombos( doCategoryOptionCombos );
             reportTable.setDoPeriods( doPeriods );