dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #08546
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2070: Add Filter Excel file when uploading a file.
------------------------------------------------------------
revno: 2070
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-11-16 14:37:56 +0700
message:
Add Filter Excel file when uploading a file.
added:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/ajaxfileupload.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ValidateUploadExcelFileAction.java
modified:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/UploadExcelFileAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ImportPatientAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/UploadExcelFileAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/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
=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/ajaxfileupload.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/ajaxfileupload.js 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/ajaxfileupload.js 2010-11-16 07:37:56 +0000
@@ -0,0 +1,201 @@
+
+jQuery.extend({
+
+
+ createUploadIframe: function(id, uri)
+ {
+ //create frame
+ var frameId = 'jUploadFrame' + id;
+
+ if(window.ActiveXObject) {
+ var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
+ if(typeof uri== 'boolean'){
+ io.src = 'javascript:false';
+ }
+ else if(typeof uri== 'string'){
+ io.src = uri;
+ }
+ }
+ else {
+ var io = document.createElement('iframe');
+ io.id = frameId;
+ io.name = frameId;
+ }
+ io.style.position = 'absolute';
+ io.style.top = '-1000px';
+ io.style.left = '-1000px';
+
+ document.body.appendChild(io);
+
+ return io
+ },
+ createUploadForm: function(id, fileElementId)
+ {
+ //create form
+ var formId = 'jUploadForm' + id;
+ var fileId = 'jUploadFile' + id;
+ var form = $('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
+ var oldElement = $('#' + fileElementId);
+ var newElement = $(oldElement).clone();
+ $(oldElement).attr('id', fileId);
+ $(oldElement).before(newElement);
+ $(oldElement).appendTo(form);
+ //set attributes
+ $(form).css('position', 'absolute');
+ $(form).css('top', '-1200px');
+ $(form).css('left', '-1200px');
+ $(form).appendTo('body');
+ return form;
+ },
+
+ ajaxFileUpload: function(s) {
+ // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
+ s = jQuery.extend({}, jQuery.ajaxSettings, s);
+ var id = new Date().getTime()
+ var form = jQuery.createUploadForm(id, s.fileElementId);
+ var io = jQuery.createUploadIframe(id, s.secureuri);
+ var frameId = 'jUploadFrame' + id;
+ var formId = 'jUploadForm' + id;
+ // Watch for a new set of requests
+ if ( s.global && ! jQuery.active++ )
+ {
+ jQuery.event.trigger( "ajaxStart" );
+ }
+ var requestDone = false;
+ // Create the request object
+ var xml = {}
+ if ( s.global )
+ jQuery.event.trigger("ajaxSend", [xml, s]);
+ // Wait for a response to come back
+ var uploadCallback = function(isTimeout)
+ {
+ var io = document.getElementById(frameId);
+ try
+ {
+ if(io.contentWindow)
+ {
+ xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
+ xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
+
+ }else if(io.contentDocument)
+ {
+ xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
+ xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
+ }
+ }catch(e)
+ {
+ jQuery.handleError(s, xml, null, e);
+ }
+ if ( xml || isTimeout == "timeout")
+ {
+ requestDone = true;
+ var status;
+ try {
+ status = isTimeout != "timeout" ? "success" : "error";
+ // Make sure that the request was successful or notmodified
+ if ( status != "error" )
+ {
+ // process the data (runs the xml through httpData regardless of callback)
+ var data = jQuery.uploadHttpData( xml, s.dataType );
+ // If a local callback was specified, fire it and pass it the data
+ if ( s.success )
+ s.success( data, status );
+
+ // Fire the global callback
+ if( s.global )
+ jQuery.event.trigger( "ajaxSuccess", [xml, s] );
+ } else
+ jQuery.handleError(s, xml, status);
+ } catch(e)
+ {
+ status = "error";
+ jQuery.handleError(s, xml, status, e);
+ }
+
+ // The request was completed
+ if( s.global )
+ jQuery.event.trigger( "ajaxComplete", [xml, s] );
+
+ // Handle the global AJAX counter
+ if ( s.global && ! --jQuery.active )
+ jQuery.event.trigger( "ajaxStop" );
+
+ // Process result
+ if ( s.complete )
+ s.complete(xml, status);
+
+ jQuery(io).unbind()
+
+ setTimeout(function()
+ { try
+ {
+ $(io).remove();
+ $(form).remove();
+
+ } catch(e)
+ {
+ jQuery.handleError(s, xml, null, e);
+ }
+
+ }, 100)
+
+ xml = null
+
+ }
+ }
+ // Timeout checker
+ if ( s.timeout > 0 )
+ {
+ setTimeout(function(){
+ // Check to see if the request is still happening
+ if( !requestDone ) uploadCallback( "timeout" );
+ }, s.timeout);
+ }
+ try
+ {
+ // var io = $('#' + frameId);
+ var form = $('#' + formId);
+ $(form).attr('action', s.url);
+ $(form).attr('method', 'POST');
+ $(form).attr('target', frameId);
+ if(form.encoding)
+ {
+ form.encoding = 'multipart/form-data';
+ }
+ else
+ {
+ form.enctype = 'multipart/form-data';
+ }
+ $(form).submit();
+
+ } catch(e)
+ {
+ jQuery.handleError(s, xml, null, e);
+ }
+ if(window.attachEvent){
+ document.getElementById(frameId).attachEvent('onload', uploadCallback);
+ }
+ else{
+ document.getElementById(frameId).addEventListener('load', uploadCallback, false);
+ }
+ return {abort: function () {}};
+
+ },
+
+ uploadHttpData: function( r, type ) {
+ var data = !type;
+ data = type == "xml" || data ? r.responseXML : r.responseText;
+ // If the type is "script", eval it in global context
+ if ( type == "script" )
+ jQuery.globalEval( data );
+ // Get the JavaScript object, if JSON is used.
+ if ( type == "json" )
+ eval( "data = " + data );
+ // evaluate scripts within html
+ if ( type == "html" )
+ jQuery("<div>").html(data).evalScripts();
+ //alert($('param', data).each(function(){alert($(this).attr('value'));}));
+ return data;
+ }
+})
+
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/UploadExcelFileAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/UploadExcelFileAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/UploadExcelFileAction.java 2010-11-16 07:37:56 +0000
@@ -92,7 +92,7 @@
selectionManager.setUploadFilePath( output.getAbsolutePath() );
StreamUtils.write( upload, output );
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ImportPatientAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ImportPatientAction.java 2010-11-16 05:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ImportPatientAction.java 2010-11-16 07:37:56 +0000
@@ -248,7 +248,7 @@
{
return errPatients;
}
-
+
public HashMap<Integer, String> getErrMessage()
{
return errMessage;
@@ -277,6 +277,11 @@
public String execute()
throws Exception
{
+ if ( output == null )
+ {
+ return ERROR;
+ }
+
try
{
// -----------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/UploadExcelFileAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/UploadExcelFileAction.java 2010-11-16 05:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/UploadExcelFileAction.java 2010-11-16 07:37:56 +0000
@@ -41,9 +41,9 @@
public class UploadExcelFileAction
implements Action
{
- // -------------------------------------------
+ // -------------------------------------------------------------------------
// Input & Output
- // -------------------------------------------
+ // -------------------------------------------------------------------------
private File output;
@@ -54,10 +54,10 @@
private File upload;
-// public File getUpload()
-// {
-// return upload;
-// }
+ public File getUpload()
+ {
+ return upload;
+ }
public void setUpload( File upload )
{
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ValidateUploadExcelFileAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ValidateUploadExcelFileAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientimport/ValidateUploadExcelFileAction.java 2010-11-16 07:37:56 +0000
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2004-2010, 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.
+ */
+
+package org.hisp.dhis.patient.action.patientimport;
+
+import java.io.File;
+
+import org.hisp.dhis.i18n.I18n;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version ValidateUploadExcelFileAction.java Nov 16, 2010 1:19:57 PM
+ */
+public class ValidateUploadExcelFileAction
+ implements Action
+{
+ private static final String CONTENT_TYPE = "application/vnd.ms-excel";
+
+ // -------------------------------------------------------------------------
+ // Input & Output
+ // -------------------------------------------------------------------------
+
+ private String uploadContentType;
+
+ public void setUploadContentType( String uploadContentType )
+ {
+ this.uploadContentType = uploadContentType;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ private File upload;
+
+ public File getUpload()
+ {
+ return upload;
+ }
+
+ public void setUpload( File upload )
+ {
+ this.upload = upload;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ if ( upload == null || !upload.exists() )
+ {
+ message = i18n.getString( "upload_file_null" );
+
+ return ERROR;
+ }
+
+ if ( !CONTENT_TYPE.contains( uploadContentType ) )
+ {
+ message = i18n.getString( "file_type_not_supported" );
+
+ return ERROR;
+ }
+
+ return SUCCESS;
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2010-11-16 05:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2010-11-16 07:37:56 +0000
@@ -158,8 +158,9 @@
<property name="relationshipService"
ref="org.hisp.dhis.relationship.RelationshipService" />
</bean>
-
- <bean id="org.hisp.dhis.patient.action.relationship.ShowAddRelationshipPatientAction"
+
+ <bean
+ id="org.hisp.dhis.patient.action.relationship.ShowAddRelationshipPatientAction"
class="org.hisp.dhis.patient.action.relationship.ShowAddRelationshipPatientAction"
scope="prototype">
<property name="patientService">
@@ -169,7 +170,8 @@
<ref bean="org.hisp.dhis.patient.PatientAttributeService" />
</property>
<property name="patientAttributeValueService">
- <ref bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+ <ref
+ bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
</property>
<property name="patientAttributeGroupService"
ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
@@ -182,9 +184,11 @@
<property name="selectedStateManager"
ref="org.hisp.dhis.patient.state.SelectedStateManager" />
</bean>
-
- <bean id="org.hisp.dhis.patient.action.relationship.AddRelationshipPatientAction"
- class="org.hisp.dhis.patient.action.relationship.AddRelationshipPatientAction" scope="prototype">
+
+ <bean
+ id="org.hisp.dhis.patient.action.relationship.AddRelationshipPatientAction"
+ class="org.hisp.dhis.patient.action.relationship.AddRelationshipPatientAction"
+ scope="prototype">
<property name="selectionManager"
ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
@@ -195,7 +199,7 @@
<property name="patientAttributeValueService"
ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
<property name="patientAttributeService"
- ref ="org.hisp.dhis.patient.PatientAttributeService" />
+ ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="patientIdentifierTypeService"
ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
<property name="patientAttributeOptionService"
@@ -205,15 +209,17 @@
<property name="relationshipTypeService"
ref="org.hisp.dhis.relationship.RelationshipTypeService" />
</bean>
-
- <bean id="org.hisp.dhis.patient.action.relationship.ValidateAddRelationshipPatientAction"
+
+ <bean
+ id="org.hisp.dhis.patient.action.relationship.ValidateAddRelationshipPatientAction"
class="org.hisp.dhis.patient.action.relationship.ValidateAddRelationshipPatientAction"
scope="prototype">
<property name="selectionManager"
ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="patientAttributeValueService">
- <ref bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+ <ref
+ bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
</property>
<property name="patientIdentifierService"
ref="org.hisp.dhis.patient.PatientIdentifierService" />
@@ -283,7 +289,7 @@
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.patientattribute.GetPatientAttributesWithdoutGroupAction"
class="org.hisp.dhis.patient.action.patientattribute.GetPatientAttributesWithdoutGroupAction"
@@ -291,7 +297,7 @@
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.patientattribute.RemovePatientAttributeOptionAction"
class="org.hisp.dhis.patient.action.patientattribute.RemovePatientAttributeOptionAction"
@@ -308,8 +314,7 @@
id="org.hisp.dhis.patient.action.patientattribute.ShowUpdatePatientAttributeValueAction"
class="org.hisp.dhis.patient.action.patientattribute.ShowUpdatePatientAttributeValueAction"
scope="prototype">
- <property name="patientService"
- ref="org.hisp.dhis.patient.PatientService" />
+ <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="patientAttributeGroupService"
@@ -343,11 +348,10 @@
</bean>
<!-- Patient -->
-
- <bean id="org.hisp.dhis.patient.action.patient.SearchPersonAction"
+
+ <bean id="org.hisp.dhis.patient.action.patient.SearchPersonAction"
class="org.hisp.dhis.patient.action.patient.SearchPersonAction">
- <property name="patientService"
- ref="org.hisp.dhis.patient.PatientService" />
+ <property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="patientAttributeValueService"
ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
</bean>
@@ -419,7 +423,7 @@
<property name="selectedStateManager"
ref="org.hisp.dhis.patient.state.SelectedStateManager" />
<property name="patientAttributeService"
- ref ="org.hisp.dhis.patient.PatientAttributeService" />
+ ref="org.hisp.dhis.patient.PatientAttributeService" />
<property name="patientIdentifierTypeService"
ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
<property name="patientAttributeOptionService"
@@ -474,7 +478,8 @@
ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
<property name="patientAttributeValueService">
- <ref bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+ <ref
+ bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
</property>
<property name="patientIdentifierService"
ref="org.hisp.dhis.patient.PatientIdentifierService" />
@@ -482,20 +487,22 @@
<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
</property>
</bean>
-
- <bean id="org.hisp.dhis.patient.action.patient.ShowAddRepresentativeAction"
+
+ <bean
+ id="org.hisp.dhis.patient.action.patient.ShowAddRepresentativeAction"
class="org.hisp.dhis.patient.action.patient.ShowAddRepresentativeAction"
scope="prototype">
- <property name="relationshipTypeService"
+ <property name="relationshipTypeService"
ref="org.hisp.dhis.relationship.RelationshipTypeService" />
- <property name="patientIdentifierTypeService"
+ <property name="patientIdentifierTypeService"
ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
- <property name="patientAttributeService"
+ <property name="patientAttributeService"
ref="org.hisp.dhis.patient.PatientAttributeService" />
</bean>
-
+
<bean id="org.hisp.dhis.patient.action.patient.AddRepresentativeAction"
- class="org.hisp.dhis.patient.action.patient.AddRepresentativeAction" scope="prototype">
+ class="org.hisp.dhis.patient.action.patient.AddRepresentativeAction"
+ scope="prototype">
<property name="selectionManager"
ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
@@ -515,7 +522,8 @@
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="selectedStateManager"
ref="org.hisp.dhis.patient.state.SelectedStateManager" />
- <property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+ <property name="programAttributeService"
+ ref="org.hisp.dhis.program.ProgramAttributeService" />
</bean>
<bean id="org.hisp.dhis.patient.action.patient.ProgramEnrollmentAction"
@@ -584,7 +592,7 @@
class="org.hisp.dhis.patient.action.program.GetProgramListAction"
scope="prototype">
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
</bean>
<bean id="org.hisp.dhis.patient.action.program.GetProgramAction"
@@ -620,40 +628,56 @@
<!-- Program Attribute -->
- <bean id="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction"
- class="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction" scope="prototype">
- <property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+ <bean
+ id="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction"
+ class="org.hisp.dhis.patient.action.program.GetProgramAttributeListAction"
+ scope="prototype">
+ <property name="programAttributeService"
+ ref="org.hisp.dhis.program.ProgramAttributeService" />
</bean>
-
+
<bean id="org.hisp.dhis.patient.action.program.GetProgramAttributeAction"
- class="org.hisp.dhis.patient.action.program.GetProgramAttributeAction" scope="prototype">
- <property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+ class="org.hisp.dhis.patient.action.program.GetProgramAttributeAction"
+ scope="prototype">
+ <property name="programAttributeService"
+ ref="org.hisp.dhis.program.ProgramAttributeService" />
</bean>
-
+
<bean id="org.hisp.dhis.patient.action.program.AddProgramAttributeAction"
- class="org.hisp.dhis.patient.action.program.AddProgramAttributeAction" scope="prototype">
- <property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
- </bean>
-
- <bean id="org.hisp.dhis.patient.action.program.UpdateProgramAttributeAction"
- class="org.hisp.dhis.patient.action.program.UpdateProgramAttributeAction" scope="prototype">
- <property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
- <property name="programAttributeOptionService" ref="org.hisp.dhis.program.ProgramAttributeOptionService" />
- </bean>
-
- <bean id="org.hisp.dhis.patient.action.program.RemoveProgramAttributeAction"
- class="org.hisp.dhis.patient.action.program.RemoveProgramAttributeAction" scope="prototype">
- <property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
- </bean>
-
- <bean id="org.hisp.dhis.patient.action.program.ValidateProgramAttributeAction"
+ class="org.hisp.dhis.patient.action.program.AddProgramAttributeAction"
+ scope="prototype">
+ <property name="programAttributeService"
+ ref="org.hisp.dhis.program.ProgramAttributeService" />
+ </bean>
+
+ <bean
+ id="org.hisp.dhis.patient.action.program.UpdateProgramAttributeAction"
+ class="org.hisp.dhis.patient.action.program.UpdateProgramAttributeAction"
+ scope="prototype">
+ <property name="programAttributeService"
+ ref="org.hisp.dhis.program.ProgramAttributeService" />
+ <property name="programAttributeOptionService"
+ ref="org.hisp.dhis.program.ProgramAttributeOptionService" />
+ </bean>
+
+ <bean
+ id="org.hisp.dhis.patient.action.program.RemoveProgramAttributeAction"
+ class="org.hisp.dhis.patient.action.program.RemoveProgramAttributeAction"
+ scope="prototype">
+ <property name="programAttributeService"
+ ref="org.hisp.dhis.program.ProgramAttributeService" />
+ </bean>
+
+ <bean
+ id="org.hisp.dhis.patient.action.program.ValidateProgramAttributeAction"
class="org.hisp.dhis.patient.action.program.ValidateProgramAttributeAction"
scope="prototype">
- <property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
+ <property name="programAttributeService"
+ ref="org.hisp.dhis.program.ProgramAttributeService" />
</bean>
-
+
<!-- Program_OrganisationUnit Association -->
-
+
<bean
id="org.hisp.dhis.patient.action.program.DefineProgramAssociationsAction"
class="org.hisp.dhis.patient.action.program.DefineProgramAssociationsAction"
@@ -662,7 +686,7 @@
ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
-
+
<!-- Program_ValidationDE Association -->
<bean
@@ -670,9 +694,10 @@
class="org.hisp.dhis.patient.action.program.ShowValidationDEAssociationsFormAction"
scope="prototype">
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="programStageDEValidationService" ref="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
+ <property name="programStageDEValidationService"
+ ref="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
</bean>
-
+
<!-- ProgramStage -->
<bean id="org.hisp.dhis.patient.action.programstage.AddProgramStageAction"
@@ -749,7 +774,7 @@
</bean>
<!-- Data Entry Form -->
-
+
<bean
id="org.hisp.dhis.patient.action.dataentryform.ShowDataEntryFormAction"
class="org.hisp.dhis.patient.action.dataentryform.ShowDataEntryFormAction"
@@ -761,7 +786,7 @@
<ref bean="org.hisp.dhis.patient.screen.DataEntryManager" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.dataentryform.ViewDataEntryFormAction"
class="org.hisp.dhis.patient.action.dataentryform.ViewDataEntryFormAction"
@@ -774,12 +799,12 @@
</property>
<property name="dataEntryManager">
<ref bean="org.hisp.dhis.patient.screen.DataEntryManager" />
- </property>
- <property name="editorManager" ref="editorManager"/>
+ </property>
+ <property name="editorManager" ref="editorManager" />
<property name="programStageDataElementService"
- ref="org.hisp.dhis.program.ProgramStageDataElementService" />
+ ref="org.hisp.dhis.program.ProgramStageDataElementService" />
</bean>
-
+
<bean id="org.hisp.dhis.patient.screen.DataEntryManager" class="org.hisp.dhis.patient.screen.DefaultDataEntryManager"
scope="prototype">
<property name="dataElementService">
@@ -860,7 +885,7 @@
scope="prototype">
<property name="dataEntryFormService">
<ref bean="org.hisp.dhis.dataentryform.DataEntryFormService" />
- </property>
+ </property>
<property name="dataElementService">
<ref bean="org.hisp.dhis.dataelement.DataElementService" />
</property>
@@ -929,7 +954,7 @@
</bean>
<!-- Patient Identifier Type -->
-
+
<bean
id="org.hisp.dhis.patient.action.patientidentifiertype.AddPatientIdentifierTypeAction"
class="org.hisp.dhis.patient.action.patientidentifiertype.AddPatientIdentifierTypeAction"
@@ -947,7 +972,7 @@
<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.patientidentifiertype.GetPatientIdentifierTypeListAction"
class="org.hisp.dhis.patient.action.patientidentifiertype.GetPatientIdentifierTypeListAction"
@@ -956,7 +981,7 @@
<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.patientidentifiertype.RemovePatientIdentifierTypeAction"
class="org.hisp.dhis.patient.action.patientidentifiertype.RemovePatientIdentifierTypeAction"
@@ -1055,16 +1080,16 @@
<ref bean="org.hisp.dhis.dataelement.DataElementCategoryService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.caseaggregation.CaseAggregationOptionCaptureAction"
class="org.hisp.dhis.patient.action.caseaggregation.CaseAggregationOptionCaptureAction"
scope="prototype">
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService"/>
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
</bean>
-
+
<!-- Validation - PatientValidationCriteria -->
-
+
<bean
id="org.hisp.dhis.patient.action.validation.AddValidationCriteriaAction"
class="org.hisp.dhis.patient.action.validation.AddValidationCriteriaAction"
@@ -1073,31 +1098,31 @@
<ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.GetProgramListForValidationCriteriaAction"
class="org.hisp.dhis.patient.action.validation.GetProgramListForValidationCriteriaAction"
scope="prototype">
<property name="validationCriteriaService">
- <ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
+ <ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
</property>
<property name="programService">
- <ref bean="org.hisp.dhis.program.ProgramService" />
+ <ref bean="org.hisp.dhis.program.ProgramService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.DefineProgramListForValidationCriteriaAction"
class="org.hisp.dhis.patient.action.validation.DefineProgramListForValidationCriteriaAction"
scope="prototype">
<property name="validationCriteriaService">
- <ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
+ <ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
</property>
<property name="programService">
- <ref bean="org.hisp.dhis.program.ProgramService" />
+ <ref bean="org.hisp.dhis.program.ProgramService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.GetValidationCriteriaAction"
class="org.hisp.dhis.patient.action.validation.GetValidationCriteriaAction"
@@ -1106,7 +1131,7 @@
<ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.GetValidationCriteriaListAction"
class="org.hisp.dhis.patient.action.validation.GetValidationCriteriaListAction"
@@ -1115,7 +1140,7 @@
<ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.RemoveValidationCriteriaAction"
class="org.hisp.dhis.patient.action.validation.RemoveValidationCriteriaAction"
@@ -1124,7 +1149,7 @@
<ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.UpdateValidationCriteriaAction"
class="org.hisp.dhis.patient.action.validation.UpdateValidationCriteriaAction"
@@ -1133,7 +1158,7 @@
<ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.ValidateValidationCriteriaAction"
class="org.hisp.dhis.patient.action.validation.ValidateValidationCriteriaAction"
@@ -1142,36 +1167,36 @@
<ref bean="org.hisp.dhis.validation.ValidationCriteriaService" />
</property>
</bean>
-
+
<!-- Validation - ProgramStageDataElementValidation -->
-
+
<bean
id="org.hisp.dhis.patient.action.validation.AddProgramStageDEValidationAction"
class="org.hisp.dhis.patient.action.validation.AddProgramStageDEValidationAction"
scope="prototype">
<property name="validationService">
- <ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
+ <ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
</property>
<property name="programStageService">
- <ref bean="org.hisp.dhis.program.ProgramStageService" />
+ <ref bean="org.hisp.dhis.program.ProgramStageService" />
</property>
<property name="dataElementService">
- <ref bean="org.hisp.dhis.dataelement.DataElementService" />
+ <ref bean="org.hisp.dhis.dataelement.DataElementService" />
</property>
<property name="programStageDataElementService">
- <ref bean="org.hisp.dhis.program.ProgramStageDataElementService" />
+ <ref bean="org.hisp.dhis.program.ProgramStageDataElementService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationAction"
class="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationAction"
scope="prototype">
<property name="validationService">
- <ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
+ <ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationListAction"
class="org.hisp.dhis.patient.action.validation.GetProgramStageDEValidationListAction"
@@ -1180,7 +1205,7 @@
<ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.validation.RemoveProgramStageDEValidationAction"
class="org.hisp.dhis.patient.action.validation.RemoveProgramStageDEValidationAction"
@@ -1189,9 +1214,9 @@
<ref bean="org.hisp.dhis.program.ProgramStageDataElementValidationService" />
</property>
</bean>
-
+
<!-- Configuration -->
-
+
<bean
id="org.hisp.dhis.patient.action.configuration.GetPatientExcelItemplateFileAction"
class="org.hisp.dhis.patient.action.configuration.GetPatientExcelItemplateFileAction"
@@ -1200,7 +1225,7 @@
<ref bean="org.hisp.dhis.options.SystemSettingManager" />
</property>
</bean>
-
+
<bean
id="org.hisp.dhis.patient.action.configuration.SetPatientExcelItemplateFileAction"
class="org.hisp.dhis.patient.action.configuration.SetPatientExcelItemplateFileAction"
@@ -1209,16 +1234,22 @@
<ref bean="org.hisp.dhis.options.SystemSettingManager" />
</property>
</bean>
-
+
<!-- Import patient -->
+
<bean
id="org.hisp.dhis.patient.action.patientimport.UploadExcelFileAction"
class="org.hisp.dhis.patient.action.patientimport.UploadExcelFileAction"
scope="prototype">
</bean>
-
+
<bean
- id="org.hisp.dhis.patient.action.patientimport.ImportPatientAction"
+ id="org.hisp.dhis.patient.action.patientimport.ValidateUploadExcelFileAction"
+ class="org.hisp.dhis.patient.action.patientimport.ValidateUploadExcelFileAction"
+ scope="prototype">
+ </bean>
+
+ <bean id="org.hisp.dhis.patient.action.patientimport.ImportPatientAction"
class="org.hisp.dhis.patient.action.patientimport.ImportPatientAction"
scope="prototype">
<property name="patientService">
@@ -1259,11 +1290,12 @@
</property>
<property name="patientIdentifierService">
<ref bean="org.hisp.dhis.patient.PatientIdentifierService" />
-
+
</property>
<property name="patientAttributeValueService">
- <ref bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+ <ref
+ bean="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
</property>
</bean>
-
+
</beans>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2010-11-16 05:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2010-11-16 07:37:56 +0000
@@ -440,3 +440,5 @@
birthday_is_null = Birthday is null
duplicate = Duplicate
excel_file = Excel file.
+upload_file_null = Upload file is null
+file_type_not_supported = File type is not supported
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2010-11-16 05:45:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2010-11-16 07:37:56 +0000
@@ -1152,17 +1152,29 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-patient/importPatientParams.vm</param>
<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
- </action>
-
+ <param name="javascripts">../dhis-web-commons/javascripts/ajaxfileupload.js, javascript/import.js</param>
+ </action>
+
+ <action name="validateUploadExcelFile"
+ class="org.hisp.dhis.patient.action.patientimport.ValidateUploadExcelFileAction">
+ <interceptor-ref name="fileUploadStack" />
+ <result name="success" type="velocity-xml">
+ /dhis-web-maintenance-patient/responseSuccess.vm</result>
+ <result name="error" type="velocity-xml">
+ /dhis-web-maintenance-patient/responseError.vm</result>
+ </action>
+
<action name="importPatient"
class="org.hisp.dhis.patient.action.patientimport.UploadExcelFileAction">
<result name="success" type="chain">importPatientChain</result>
+ <result name="error" type="redirect">importPatientForm.action</result>
<interceptor-ref name="fileUploadStack" />
</action>
<action name="importPatientChain"
class="org.hisp.dhis.patient.action.patientimport.ImportPatientAction">
<result name="success" type="chain">importPatientResult</result>
+ <result name="error" type="redirect">importPatientResult</result>
</action>
<action name="importPatientResult"
@@ -1170,6 +1182,7 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">/dhis-web-maintenance-patient/importPatientResult.vm</param>
<param name="menu">/dhis-web-maintenance-patient/menu.vm</param>
+ <param name="javascripts">../dhis-web-commons/javascripts/ajaxfileupload.js, javascript/import.js</param>
</action>
</package>