← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1383: Replaced ImportExportServiceManager with the generic ServiceProvider.

 

------------------------------------------------------------
revno: 1383
committer: Lars Helge Oeverland <larshelge@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-02-02 20:21:58 +0100
message:
  Replaced ImportExportServiceManager with the generic ServiceProvider.
removed:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportExportServiceManager.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/manager/
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/manager/DefaultImportExportServiceManager.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ServiceProvider.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DetailedMetaDataExportAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml


--
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/common/ServiceProvider.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ServiceProvider.java	2010-02-02 13:21:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/ServiceProvider.java	2010-02-02 19:21:58 +0000
@@ -28,6 +28,7 @@
  */
 
 import java.util.Map;
+import java.util.Set;
 
 /**
  * @author Lars Helge Overland
@@ -45,4 +46,9 @@
     {
         return services.get( key );
     }
+    
+    public Set<String> getServiceKeySet()
+    {
+        return services.keySet();
+    }
 }

=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportExportServiceManager.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportExportServiceManager.java	2009-04-23 18:11:33 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/ImportExportServiceManager.java	1970-01-01 00:00:00 +0000
@@ -1,45 +0,0 @@
-package org.hisp.dhis.importexport;
-
-/*
- * 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.Collection;
-
-/**
- * @author Lars Helge Overland
- * @version $Id: ImportExportServiceManager.java 4646 2008-02-26 14:54:29Z larshelg $
- */
-public interface ImportExportServiceManager
-{
-    Collection<String> getImportFormats();
-    
-    ImportService getImportService( String format );
-    
-    Collection<String> getExportFormats();
-    
-    ExportService getExportService( String format );
-}

=== removed directory 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/manager'
=== removed file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/manager/DefaultImportExportServiceManager.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/manager/DefaultImportExportServiceManager.java	2009-04-23 18:11:33 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/manager/DefaultImportExportServiceManager.java	1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
-package org.hisp.dhis.importexport.manager;
-
-/*
- * 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.Collection;
-import java.util.Map;
-
-import org.hisp.dhis.importexport.ExportService;
-import org.hisp.dhis.importexport.ImportExportServiceManager;
-import org.hisp.dhis.importexport.ImportService;
-
-/**
- * @author Lars Helge Overland
- * @version $Id: DefaultImportExportServiceManager.java 4646 2008-02-26 14:54:29Z larshelg $
- */
-public class DefaultImportExportServiceManager
-    implements ImportExportServiceManager
-{
-    // -------------------------------------------------------------------------
-    // Properties
-    // -------------------------------------------------------------------------
-    
-    private Map<String, ImportService> importServices;
-
-    public void setImportServices( Map<String, ImportService> importServices )
-    {
-        this.importServices = importServices;
-    }
-    
-    private Map<String, ExportService> exportServices;
-
-    public void setExportServices( Map<String, ExportService> exportServices )
-    {
-        this.exportServices = exportServices;
-    }
-
-    // -------------------------------------------------------------------------
-    // ImportExportServiceManager implementation
-    // -------------------------------------------------------------------------
-    
-    public Collection<String> getImportFormats()
-    {
-        return importServices.keySet();
-    }
-    
-    public ImportService getImportService( String format )
-    {
-        return importServices.get( format );
-    }
-    
-    public Collection<String> getExportFormats()
-    {
-        return exportServices.keySet();
-    }
-    
-    public ExportService getExportService( String format )
-    {
-        return exportServices.get( format );
-    }
-}

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2009-11-25 09:34:14 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/resources/META-INF/dhis/beans.xml	2010-02-02 19:21:58 +0000
@@ -7,37 +7,9 @@
 	<!-- ImportExportServiceManager                                    -->
 	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 
-	<bean id="org.hisp.dhis.importexport.ImportExportServiceManager"
-		class="org.hisp.dhis.importexport.manager.DefaultImportExportServiceManager">
-		<property name="importServices">
-			<map>
-				<entry>
-					<key>
-						<value>IXF</value>
-					</key>
-					<ref bean="org.hisp.dhis.importexport.IXFImportService" />
-				</entry>
-				<entry>
-					<key>
-						<value>DXF</value>
-					</key>
-					<ref bean="org.hisp.dhis.importexport.DXFImportService" />
-				</entry>
-				<entry>
-					<key>
-						<value>DHIS14XML</value>
-					</key>
-					<ref bean="org.hisp.dhis.importexport.Dhis14XMLImportService" />
-				</entry>
-				<entry>
-					<key>
-						<value>DHIS14FILE</value>
-					</key>
-					<ref bean="org.hisp.dhis.importexport.Dhis14FILEImportService" />
-				</entry>
-			</map>
-		</property>
-		<property name="exportServices">
+	<bean id="exportServiceProvider" 
+		class="org.hisp.dhis.common.ServiceProvider">		
+		<property name="services">
 			<map>
 				<entry>
 					<key>

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DataValueExportAction.java	2010-02-02 19:21:58 +0000
@@ -35,11 +35,11 @@
 import java.io.InputStream;
 import java.util.Collection;
 
+import org.hisp.dhis.common.ServiceProvider;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSetService;
 import org.hisp.dhis.importexport.ExportParams;
 import org.hisp.dhis.importexport.ExportService;
-import org.hisp.dhis.importexport.ImportExportServiceManager;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.oust.manager.SelectionTreeManager;
@@ -71,11 +71,11 @@
         this.selectionTreeManager = selectionTreeManager;
     }
 
-    private ImportExportServiceManager serviceManager;
+    private ServiceProvider<ExportService> serviceProvider;
 
-    public void setServiceManager( ImportExportServiceManager serviceManager )
+    public void setServiceProvider( ServiceProvider<ExportService> serviceProvider )
     {
-        this.serviceManager = serviceManager;
+        this.serviceProvider = serviceProvider;
     }
 
     private DataSetService dataSetService;
@@ -254,7 +254,7 @@
         // Export
         // ---------------------------------------------------------------------
         
-        ExportService exportService = serviceManager.getExportService( exportFormat );        
+        ExportService exportService = serviceProvider.provide( exportFormat );        
         
         inputStream = exportService.exportData( params );
         

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DetailedMetaDataExportAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DetailedMetaDataExportAction.java	2009-08-20 08:17:49 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/DetailedMetaDataExportAction.java	2010-02-02 19:21:58 +0000
@@ -36,6 +36,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import org.hisp.dhis.common.ServiceProvider;
 import org.hisp.dhis.dataelement.CalculatedDataElement;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -45,7 +46,6 @@
 import org.hisp.dhis.importexport.ExportParams;
 import org.hisp.dhis.importexport.ExportService;
 import org.hisp.dhis.importexport.ImportDataValueService;
-import org.hisp.dhis.importexport.ImportExportServiceManager;
 import org.hisp.dhis.importexport.ImportObjectService;
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorService;
@@ -78,12 +78,12 @@
     {
         this.format = format;
     }
-        
-    private ImportExportServiceManager serviceManager;
-
-    public void setServiceManager( ImportExportServiceManager serviceManager )
+
+    private ServiceProvider<ExportService> serviceProvider;
+
+    public void setServiceProvider( ServiceProvider<ExportService> serviceProvider )
     {
-        this.serviceManager = serviceManager;
+        this.serviceProvider = serviceProvider;
     }
 
     private DataElementService dataElementService;
@@ -219,7 +219,7 @@
         params.setI18n( i18n );
         params.setFormat( format );
 
-        ExportService exportService = serviceManager.getExportService( exportFormat );
+        ExportService exportService = serviceProvider.provide( exportFormat );
         
         inputStream = exportService.exportData( params );
         

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java	2009-11-01 21:32:55 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/exp/MetaDataExportAction.java	2010-02-02 19:21:58 +0000
@@ -29,12 +29,12 @@
 
 import java.io.InputStream;
 
+import org.hisp.dhis.common.ServiceProvider;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.importexport.ExportParams;
 import org.hisp.dhis.importexport.ExportService;
 import org.hisp.dhis.importexport.ImportDataValueService;
-import org.hisp.dhis.importexport.ImportExportServiceManager;
 import org.hisp.dhis.importexport.ImportObjectService;
 import org.hisp.dhis.options.datadictionary.DataDictionaryModeManager;
 
@@ -53,11 +53,11 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private ImportExportServiceManager serviceManager;
+    private ServiceProvider<ExportService> serviceProvider;
 
-    public void setServiceManager( ImportExportServiceManager serviceManager )
+    public void setServiceProvider( ServiceProvider<ExportService> serviceProvider )
     {
-        this.serviceManager = serviceManager;
+        this.serviceProvider = serviceProvider;
     }
 
     private ImportObjectService importObjectService;
@@ -337,7 +337,7 @@
         params.setI18n( i18n );
         params.setFormat( format );
         
-        ExportService exportService = serviceManager.getExportService( exportFormat );
+        ExportService exportService = serviceProvider.provide( exportFormat );
         
         inputStream = exportService.exportData( params );
         

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml	2009-10-27 06:36:41 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml	2010-02-02 19:21:58 +0000
@@ -128,8 +128,7 @@
 	<bean id="org.hisp.dhis.importexport.action.exp.MetaDataExportAction"
 		class="org.hisp.dhis.importexport.action.exp.MetaDataExportAction"
 		scope="prototype">
-		<property name="serviceManager"
-			ref="org.hisp.dhis.importexport.ImportExportServiceManager" />
+		<property name="serviceProvider" ref="exportServiceProvider" />
 		<property name="importObjectService"
 			ref="org.hisp.dhis.importexport.ImportObjectService" />
 		<property name="importDataValueService"
@@ -140,8 +139,7 @@
 		id="org.hisp.dhis.importexport.action.exp.DetailedMetaDataExportAction"
 		class="org.hisp.dhis.importexport.action.exp.DetailedMetaDataExportAction"
 		scope="prototype">
-		<property name="serviceManager"
-			ref="org.hisp.dhis.importexport.ImportExportServiceManager" />
+		<property name="serviceProvider" ref="exportServiceProvider" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
 		<property name="expressionService" ref="org.hisp.dhis.expression.ExpressionService" />
@@ -156,8 +154,7 @@
 		scope="prototype">
 		<property name="selectionTreeManager"
 			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
-		<property name="serviceManager"
-			ref="org.hisp.dhis.importexport.ImportExportServiceManager" />
+		<property name="serviceProvider" ref="exportServiceProvider" />
 		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
 		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 		<property name="organisationUnitService"