← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1074: Made the CollectionConversionUtils class more generic.

 

------------------------------------------------------------
revno: 1074
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2009-11-21 17:22:30 +0100
message:
  Made the CollectionConversionUtils class more generic.
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CodecUtils.java
  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/ConversionUtils.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/UUIdUtils.java
  dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataExcelOrganizationGroupAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataNormalExcelGroupAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataCategoryAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataOrganizationGroupAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateUpdateReportExcelItemAction.java
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/periodcolumn/action/UpdatePeriodColumnAction.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.
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CodecUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CodecUtils.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CodecUtils.java	2009-11-21 16:22:30 +0000
@@ -87,6 +87,7 @@
         }
     }
 	
+    //TODO remove
     public static String unescape( String s )
     {
         StringBuffer sbuf = new StringBuffer();

=== modified 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-03-03 16:46:36 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/CollectionConversionUtils.java	2009-11-21 16:22:30 +0000
@@ -37,22 +37,15 @@
  * @author Lars Helge Overland
  * @version $Id$
  */
-public class CollectionConversionUtils<T>
+public class CollectionConversionUtils
 {
     /**
-     * Default constructor.
-     */
-    public CollectionConversionUtils()
-    {   
-    }
-    
-    /**
      * Creates a Set of objects out of a Collection of objects.
      * 
      * @param objects the Collection of objects.
      * @return a Set of objects.
      */
-    public Set<T> getSet( Collection<T> objects )
+    public static <T> Set<T> getSet( Collection<T> objects )
     {
         Set<T> set = new HashSet<T>();
         
@@ -70,7 +63,7 @@
      * @param objects the Collection of objects.
      * @return a List of objects.
      */
-    public List<T> getList( Collection<T> objects )
+    public static <T> List<T> getList( Collection<T> objects )
     {
         List<T> list = new ArrayList<T>();
         

=== 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-18 15:19:26 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java	2009-11-21 16:22:30 +0000
@@ -43,8 +43,7 @@
      * @param clazz the clazz of the argument objects.
      * @param objects for which to get the identifiers.
      */
-    @SuppressWarnings( "unchecked" )
-    public static Collection<Integer> getIdentifiers( Class clazz, Collection<?> objects )
+    public static Collection<Integer> getIdentifiers( Class<?> clazz, Collection<?> objects )
     {
         try
         {
@@ -96,7 +95,6 @@
      */
     public static Integer[] getIntegerArray( String[] strings )
     {
-
         if ( strings == null )
         {
             return new Integer[0];

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/UUIdUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/UUIdUtils.java	2009-03-03 16:46:36 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/UUIdUtils.java	2009-11-21 16:22:30 +0000
@@ -41,8 +41,6 @@
      */
     public static String getUUId()
     {
-        UUID uuid = UUID.randomUUID();
-        
-        return uuid.toString().toUpperCase();
+        return UUID.randomUUID().toString().toUpperCase();
     }
 }

=== 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-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-datamart/src/main/java/org/hisp/dhis/datamart/action/SaveDataMartExportAction.java	2009-11-21 16:22:30 +0000
@@ -31,15 +31,11 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.datamart.DataMartExport;
 import org.hisp.dhis.datamart.DataMartExportService;
-import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.system.util.CollectionConversionUtils;
 
@@ -147,13 +143,13 @@
         
         export.setName( name );
         
-        export.setDataElements( new CollectionConversionUtils<DataElement>().getSet( 
+        export.setDataElements( CollectionConversionUtils.getSet( 
             dataElementService.getDataElements( getIntegerCollection( selectedDataElements ) ) ) );
-        export.setIndicators( new CollectionConversionUtils<Indicator>().getSet( 
+        export.setIndicators( CollectionConversionUtils.getSet( 
             indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) ) );
-        export.setPeriods( new CollectionConversionUtils<Period>().getSet( 
+        export.setPeriods( CollectionConversionUtils.getSet( 
             periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) ) );
-        export.setOrganisationUnits( new CollectionConversionUtils<OrganisationUnit>().getSet( 
+        export.setOrganisationUnits( CollectionConversionUtils.getSet( 
             organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) ) );
         
         dataMartExportService.saveDataMartExport( export );

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataExcelOrganizationGroupAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataExcelOrganizationGroupAction.java	2009-11-18 04:14:34 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataExcelOrganizationGroupAction.java	2009-11-21 16:22:30 +0000
@@ -27,14 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.io.File;
 import java.io.FileInputStream;
 import java.util.Date;
-import java.util.Locale;
-
-import jxl.Sheet;
-import jxl.Workbook;
-import jxl.WorkbookSettings;
 
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataNormalExcelGroupAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataNormalExcelGroupAction.java	2009-11-18 04:14:34 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ImportDataNormalExcelGroupAction.java	2009-11-21 16:22:30 +0000
@@ -27,16 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.io.File;
 import java.io.FileInputStream;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
-import java.util.Locale;
-
-import jxl.Sheet;
-import jxl.Workbook;
-import jxl.WorkbookSettings;
 
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataCategoryAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataCategoryAction.java	2009-11-18 04:14:34 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataCategoryAction.java	2009-11-21 16:22:30 +0000
@@ -32,9 +32,6 @@
 import java.util.ArrayList;
 import java.util.Collections;
 
-import jxl.Sheet;
-import jxl.Workbook;
-
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.hisp.dhis.dataelement.DataElement;

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataOrganizationGroupAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataOrganizationGroupAction.java	2009-11-18 04:14:34 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataOrganizationGroupAction.java	2009-11-21 16:22:30 +0000
@@ -33,9 +33,6 @@
 import java.util.Collection;
 import java.util.List;
 
-import jxl.Sheet;
-import jxl.Workbook;
-
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.hisp.dhis.organisationunit.OrganisationUnit;

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateUpdateReportExcelItemAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateUpdateReportExcelItemAction.java	2009-11-09 07:03:05 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/ValidateUpdateReportExcelItemAction.java	2009-11-21 16:22:30 +0000
@@ -26,8 +26,6 @@
  */
 package org.hisp.dhis.reportexcel.item.action;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.reportexcel.ReportExcel;
 import org.hisp.dhis.reportexcel.ReportExcelItem;
 import org.hisp.dhis.reportexcel.ReportExcelService;
@@ -40,7 +38,6 @@
 public class ValidateUpdateReportExcelItemAction
     extends ActionSupport
 {
-    private static final Log log = LogFactory.getLog( ValidateUpdateReportExcelItemAction.class );
     // -------------------------------------------
     // Dependency
     // -------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/periodcolumn/action/UpdatePeriodColumnAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/periodcolumn/action/UpdatePeriodColumnAction.java	2009-11-13 10:28:52 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/periodcolumn/action/UpdatePeriodColumnAction.java	2009-11-21 16:22:30 +0000
@@ -28,7 +28,6 @@
 package org.hisp.dhis.reportexcel.periodcolumn.action;
 
 import org.hisp.dhis.reportexcel.PeriodColumn;
-import org.hisp.dhis.reportexcel.ReportExcelPeriodColumnListing;
 import org.hisp.dhis.reportexcel.ReportExcelService;
 import org.hisp.dhis.reportexcel.action.ActionSupport;
 

=== 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-08-20 08:17:49 +0000
+++ 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
@@ -271,13 +271,11 @@
     {
         Chart chart = new Chart();
 
-        List<Indicator> indicators = new CollectionConversionUtils<Indicator>().getList( 
+        List<Indicator> indicators = CollectionConversionUtils.getList( 
             indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) );
-
-        List<Period> periods = new CollectionConversionUtils<Period>().getList( 
-            periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) );
-        
-        List<OrganisationUnit> organisationUnits = new CollectionConversionUtils<OrganisationUnit>().getList( 
+        List<Period> periods = CollectionConversionUtils.getList( 
+            periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) );        
+        List<OrganisationUnit> organisationUnits = CollectionConversionUtils.getList( 
             organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) );
 
         chart.setId( id != null ? id : 0 );

=== 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-18 15:19:26 +0000
+++ 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
@@ -39,7 +39,6 @@
 import org.hisp.dhis.report.ReportManager;
 import org.hisp.dhis.report.ReportService;
 import org.hisp.dhis.report.manager.ReportConfiguration;
-import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.reporttable.ReportTableService;
 import org.hisp.dhis.system.util.CollectionConversionUtils;
 import org.hisp.dhis.system.util.ConversionUtils;
@@ -251,7 +250,7 @@
         report.setName( name );
         report.setDesign( fileName );
         report.setType( type );
-        report.setReportTables( selectedReportTables != null ? new CollectionConversionUtils<ReportTable>().getSet( 
+        report.setReportTables( selectedReportTables != null ? CollectionConversionUtils.getSet( 
             reportTableService.getReportTables( ConversionUtils.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-16 10:32:46 +0000
+++ 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
@@ -347,19 +347,19 @@
     private ReportTable getReportTable()
         throws Exception
     {
-        List<DataElement> dataElements = new CollectionConversionUtils<DataElement>().getList( 
+        List<DataElement> dataElements = CollectionConversionUtils.getList( 
             dataElementService.getDataElements( getIntegerCollection( selectedDataElements ) ) );
         
-        List<Indicator> indicators = new CollectionConversionUtils<Indicator>().getList( 
+        List<Indicator> indicators = CollectionConversionUtils.getList( 
             indicatorService.getIndicators( getIntegerCollection( selectedIndicators ) ) );
         
-        List<DataSet> dataSets = new CollectionConversionUtils<DataSet>().getList( 
+        List<DataSet> dataSets = CollectionConversionUtils.getList( 
             dataSetService.getDataSets( getIntegerCollection( selectedDataSets ) ) );
         
-        List<Period> periods = new CollectionConversionUtils<Period>().getList( 
+        List<Period> periods = CollectionConversionUtils.getList( 
             periodService.getPeriods( getIntegerCollection( selectedPeriods ) ) );
         
-        List<OrganisationUnit> organisationUnits = new CollectionConversionUtils<OrganisationUnit>().getList( 
+        List<OrganisationUnit> organisationUnits = CollectionConversionUtils.getList( 
             organisationUnitService.getOrganisationUnits( getIntegerCollection( selectedOrganisationUnits ) ) );
 
         DimensionSet dimensionSet = dimensionService.getDimensionSet( dimensionSetId );