← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3802: Removed type="chain" into dhis-web-importexport.

 

------------------------------------------------------------
revno: 3802
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-05-31 13:27:22 +0700
message:
  Removed type="chain" into dhis-web-importexport.
modified:
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/object/DiscardObjectAction.java
  dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/object/MatchObjectAction.java
  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/struts.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-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java	2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/imp/ImportAction.java	2011-05-31 06:27:22 +0000
@@ -44,7 +44,9 @@
 import org.amplecode.cave.process.ProcessExecutor;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.external.configuration.NoConfigurationFoundException;
 import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.importexport.IbatisConfigurationManager;
 import org.hisp.dhis.importexport.ImportInternalProcess;
 import org.hisp.dhis.importexport.ImportParams;
 import org.hisp.dhis.importexport.ImportStrategy;
@@ -62,17 +64,13 @@
     implements Action
 {
     private static final String IMPORT_INTERNAL_PROCESS_ID_POSTFIX = "ImportService";
-    
+
     private static final Log log = LogFactory.getLog( ImportAction.class );
 
-    private static final List<String> ALLOWED_CONTENT_TYPES = getList( 
-        "application/x-zip-compressed", 
-        "application/zip", 
-        "application/x-gzip", 
-        "application/octet-stream", 
-        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
-        "text/xml" );
-    
+    private static final List<String> ALLOWED_CONTENT_TYPES = getList( "application/x-zip-compressed",
+        "application/zip", "application/x-gzip", "application/octet-stream",
+        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "text/xml" );
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -83,14 +81,21 @@
     {
         this.processCoordinator = processCoordinator;
     }
-    
+
     private CurrentUserService currentUserService;
 
     public void setCurrentUserService( CurrentUserService currentUserService )
     {
         this.currentUserService = currentUserService;
     }
-    
+
+    private IbatisConfigurationManager configurationManager;
+
+    public void setConfigurationManager( IbatisConfigurationManager configurationManager )
+    {
+        this.configurationManager = configurationManager;
+    }
+
     private I18n i18n;
 
     public void setI18n( I18n i18n )
@@ -101,7 +106,7 @@
     // -------------------------------------------------------------------------
     // Input & output report params
     // -------------------------------------------------------------------------
-    
+
     private String type;
 
     public String getType()
@@ -120,21 +125,21 @@
     {
         this.incomingRecords = incomingRecords;
     }
-    
+
     private boolean dataValues;
 
     public void setDataValues( boolean dataValues )
     {
         this.dataValues = dataValues;
     }
-    
+
     private boolean skipCheckMatching;
 
     public void setSkipCheckMatching( boolean skipCheckMatching )
     {
         this.skipCheckMatching = skipCheckMatching;
     }
-    
+
     private String lastUpdated;
 
     public void setLastUpdated( String lastUpdated )
@@ -154,12 +159,12 @@
     }
 
     private String fileName;
-    
+
     public void setUploadFileName( String fileName )
     {
         this.fileName = fileName;
     }
-    
+
     private String contentType;
 
     public void setUploadContentType( String contentType )
@@ -176,7 +181,14 @@
     public String getMessage()
     {
         return message;
-    }    
+    }
+    
+    private String importFormat;
+
+    public String getImportFormat()
+    {
+        return importFormat;
+    }
     
     // -------------------------------------------------------------------------
     // Action implementation
@@ -185,8 +197,8 @@
     public String execute()
         throws Exception
     {
-        String importFormat = getCurrentRunningProcessImportFormat();
-        
+        importFormat = getCurrentRunningProcessImportFormat();
+
         InputStream in = null;
 
         // ---------------------------------------------------------------------
@@ -198,24 +210,24 @@
             if ( file == null )
             {
                 message = i18n.getString( "specify_file" );
-                
+
                 log.warn( "File not specified" );
-                
+
                 return SUCCESS;
             }
-            
+
             // accept zip, gzip or uncompressed xml
             // TODO: check cross-browser content type strings
-            
+
             if ( !ALLOWED_CONTENT_TYPES.contains( contentType ) )
             {
                 message = i18n.getString( "file_type_not_allowed" );
 
                 log.warn( "Content type not allowed: " + contentType );
             }
-            
+
             in = new BufferedInputStream( new FileInputStream( file ) );
-            
+
             log.info( "Content-type: " + contentType + ", filename: " + file.getCanonicalPath() );
         }
 
@@ -224,36 +236,52 @@
         // ---------------------------------------------------------------------
 
         ImportParams params = new ImportParams();
-        
+
         ImportStrategy strategy = ImportStrategy.valueOf( incomingRecords );
 
-        params.setType( ImportType.valueOf( type ) );   
+        params.setType( ImportType.valueOf( type ) );
         params.setImportStrategy( strategy );
         params.setDataValues( dataValues );
         params.setSkipCheckMatching( skipCheckMatching );
-        params.setLastUpdated( ( lastUpdated != null && lastUpdated.trim().length() > 0 ) ? DateUtils.getMediumDate( lastUpdated ) : null );
-        
+        params.setLastUpdated( (lastUpdated != null && lastUpdated.trim().length() > 0) ? DateUtils
+            .getMediumDate( lastUpdated ) : null );
+
         // ---------------------------------------------------------------------
         // Process
         // ---------------------------------------------------------------------
-        
+
         String importType = importFormat + IMPORT_INTERNAL_PROCESS_ID_POSTFIX;
-        
+
         String owner = currentUserService.getCurrentUsername();
 
         ProcessExecutor executor = processCoordinator.newProcess( importType, owner );
-        
+
         ImportInternalProcess importProcess = (ImportInternalProcess) executor.getProcess();
-        
+
         importProcess.setImportParams( params );
         importProcess.setInputStream( in );
 
         processCoordinator.requestProcessExecution( executor );
-        
+
         setCurrentRunningProcess( PROCESS_KEY_IMPORT, executor.getId() );
         setCurrentRunningProcessType( type );
         setCurrentImportFileName( fileName );
-        
+
+        // ---------------------------------------------------------------------
+        // Verify import configuration
+        // ---------------------------------------------------------------------
+
+        if ( importFormat != null && importFormat.equals( "DHIS14FILE" ) )
+        {
+            try
+            {
+                configurationManager.getIbatisConfiguration();
+            }
+            catch ( NoConfigurationFoundException ex )
+            {
+                return "dhis14";
+            }
+        }
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/object/DiscardObjectAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/object/DiscardObjectAction.java	2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/object/DiscardObjectAction.java	2011-05-31 06:27:22 +0000
@@ -27,8 +27,12 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.importexport.action.util.ImportExportInternalProcessUtil.getCurrentRunningProcessImportFormat;
+
 import java.util.Collection;
 
+import org.hisp.dhis.external.configuration.NoConfigurationFoundException;
+import org.hisp.dhis.importexport.IbatisConfigurationManager;
 import org.hisp.dhis.importexport.ImportObjectService;
 
 import com.opensymphony.xwork2.Action;
@@ -61,7 +65,14 @@
     {
         return message;
     }
-    
+
+    private String importFormat;
+
+    public String getImportFormat()
+    {
+        return importFormat;
+    }
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -73,6 +84,13 @@
         this.importObjectService = importObjectService;
     }
 
+    private IbatisConfigurationManager configurationManager;
+
+    public void setConfigurationManager( IbatisConfigurationManager configurationManager )
+    {
+        this.configurationManager = configurationManager;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -81,21 +99,35 @@
         throws Exception
     {
         int count = 0;
-        
+
         if ( id != null )
         {
             for ( String identifier : id )
             {
                 importObjectService.cascadeDeleteImportObject( Integer.parseInt( identifier ) );
-                
+
                 count++;
             }
-            
+
             message = String.valueOf( count );
-            
+
+            importFormat = getCurrentRunningProcessImportFormat();
+
+            if ( importFormat != null && importFormat.equals( "DHIS14FILE" ) )
+            {
+                try
+                {
+                    configurationManager.getIbatisConfiguration();
+                }
+                catch ( NoConfigurationFoundException ex )
+                {
+                    return "dhis14";
+                }
+            }
+
             return SUCCESS;
         }
-        
+
         return ERROR;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/object/MatchObjectAction.java'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/object/MatchObjectAction.java	2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/java/org/hisp/dhis/importexport/action/object/MatchObjectAction.java	2011-05-31 06:27:22 +0000
@@ -27,6 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.importexport.action.util.ImportExportInternalProcessUtil.getCurrentRunningProcessImportFormat;
+
+import org.hisp.dhis.external.configuration.NoConfigurationFoundException;
+import org.hisp.dhis.importexport.IbatisConfigurationManager;
 import org.hisp.dhis.importexport.ImportObjectService;
 
 import com.opensymphony.xwork2.Action;
@@ -48,14 +52,21 @@
     {
         this.importObjectId = importObjectId;
     }
-    
+
     private Integer existingObjectId;
 
     public void setExistingObjectId( Integer existingObjectId )
     {
         this.existingObjectId = existingObjectId;
     }
-    
+
+    private String importFormat;
+
+    public String getImportFormat()
+    {
+        return importFormat;
+    }
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -67,6 +78,13 @@
         this.importObjectService = importObjectService;
     }
 
+    private IbatisConfigurationManager configurationManager;
+
+    public void setConfigurationManager( IbatisConfigurationManager configurationManager )
+    {
+        this.configurationManager = configurationManager;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -78,7 +96,23 @@
         {
             importObjectService.matchObject( importObjectId, existingObjectId );
         }
-        
+
+        // ---------------------------------------------------------------------
+        // Verify import configuration
+        // ---------------------------------------------------------------------
+        importFormat = getCurrentRunningProcessImportFormat();
+
+        if ( importFormat != null && importFormat.equals( "DHIS14FILE" ) )
+        {
+            try
+            {
+                configurationManager.getIbatisConfiguration();
+            }
+            catch ( NoConfigurationFoundException ex )
+            {
+                return "dhis14";
+            }
+        }
         return SUCCESS;
     }
 }

=== 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	2011-04-24 12:47:31 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/META-INF/dhis/beans.xml	2011-05-31 06:27:22 +0000
@@ -12,6 +12,8 @@
 		class="org.hisp.dhis.importexport.action.imp.ImportAction" scope="prototype">
 		<property name="processCoordinator" ref="processCoordinator" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
+		<property name="configurationManager"
+			ref="org.hisp.dhis.importexport.IbatisConfigurationManager" />
 	</bean>
 
 	<bean id="org.hisp.dhis.importexport.action.imp.GetImportOptionsAction"
@@ -49,6 +51,8 @@
 		scope="prototype">
 		<property name="importObjectService"
 			ref="org.hisp.dhis.importexport.ImportObjectService" />
+		<property name="configurationManager"
+			ref="org.hisp.dhis.importexport.IbatisConfigurationManager" />
 	</bean>
 
 	<bean id="org.hisp.dhis.importexport.action.object.DiscardObjectAction"
@@ -56,6 +60,8 @@
 		scope="prototype">
 		<property name="importObjectService"
 			ref="org.hisp.dhis.importexport.ImportObjectService" />
+		<property name="configurationManager"
+			ref="org.hisp.dhis.importexport.IbatisConfigurationManager" />
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2011-03-22 13:57:39 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2011-05-31 06:27:22 +0000
@@ -48,7 +48,11 @@
     </action>
 		
     <action name="import" class="org.hisp.dhis.importexport.action.imp.ImportAction">
-      <result name="success" type="chain">displayImportForm</result>
+      <result name="dhis14" type="redirect">displayConfigDhis14Form.action</result>
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-importexport/importForm.vm</param>
+      <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+      <param name="javascripts">javascript/import.js,javascript/process.js</param>
       <interceptor-ref name="fileUploadStack"/>
     </action>
     
@@ -113,11 +117,17 @@
     </action>
 		
     <action name="matchObject" class="org.hisp.dhis.importexport.action.object.MatchObjectAction">
-      <result name="success" type="chain">displayPreviewForm</result>
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-importexport/previewForm.vm</param>
+      <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+      <param name="javascripts">javascript/import.js</param>
     </action>
 		
     <action name="discardObject" class="org.hisp.dhis.importexport.action.object.DiscardObjectAction">
-      <result name="success" type="chain">displayPreviewForm</result>
+      <result name="success" type="velocity">/main.vm</result>
+      <param name="page">/dhis-web-importexport/previewForm.vm</param>
+      <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
+      <param name="javascripts">javascript/import.js</param>
     </action>
 		
     <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->