=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java 2012-12-18 06:44:18 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormByTemplate.java 2012-12-18 08:08:53 +0000 @@ -85,14 +85,13 @@ import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportNormal; import org.hisp.dhis.reportsheet.ExportReportService; +import org.hisp.dhis.reportsheet.action.ActionSupport; import org.hisp.dhis.reportsheet.importitem.ImportItem; import org.hisp.dhis.reportsheet.state.SelectionManager; import org.hisp.dhis.validation.ValidationRule; import org.hisp.dhis.validation.ValidationRuleService; import org.springframework.beans.factory.annotation.Autowired; -import com.opensymphony.xwork2.Action; - /** * Simple demo class which uses the api to present the contents of an excel 97 * spreadsheet as an XML document, using a workbook and output stream of your @@ -104,7 +103,7 @@ */ public class AutoGenerateFormByTemplate - implements Action + extends ActionSupport { private static final String REPORT_EXCEL_GROUP = "BÁO CÁO KIỂM TRA BỆNH VIỆN"; @@ -122,6 +121,8 @@ private static final String INDICATOR_KEY = "id"; + private static final String VALIDATIONRULE_KEY = "vr"; + private static final String INDICATOR_NAME = " - CS "; private static final String INDICATOR_TYPE_NAME = "Loại số"; @@ -255,6 +256,13 @@ return new HashSet( vrList ); } + private String message; + + public String getMessage() + { + return message; + } + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -271,6 +279,13 @@ excelFileName = getName( pathFileName ); commonName = getBaseName( pathFileName ); + if ( dataSetService.getDataSetByName( commonName ) != null ) + { + message = i18n.getString( "form_name_already_exists" ); + + return INPUT; + } + if ( getExtension( pathFileName ).equals( "xls" ) ) { WORKBOOK = new HSSFWorkbook( new FileInputStream( pathFileName ) ); @@ -309,6 +324,8 @@ } catch ( Exception e ) { + xml = null; + e.printStackTrace(); return ERROR; @@ -368,6 +385,7 @@ { int colIdx = convertColumnNameToNumber( colName ); String name = deName + " (" + colIdx + ")"; + message = DATAELEMENT_KEY + "@" + name; // Generate DataElement DataElement dataElement = new DataElement( name ); @@ -408,19 +426,23 @@ Integer colIdx = colIndex + 1; String idName = commonName + INDICATOR_NAME; - if ( values.length == 3 ) + switch ( values.length ) { + case 3: idName += "(" + values[2]; colIdx = convertColumnNameToNumber( values[2] ); - } - else if ( values.length == 4 ) - { + break; + case 4: idName += "(" + values[2]; colIdx = convertColumnNameToNumber( values[2] ); rowIndex = Integer.parseInt( values[3] ) - 1; + default: + idName += "(" + convertColumnNumberToName( colIdx + 1 ); + break; } idName += rowIndex + ")"; + message = INDICATOR_KEY + "@" + idName; // Create Indicator Indicator indicator = new Indicator(); @@ -428,7 +450,7 @@ indicator.setShortName( idName ); indicator.setAnnualized( false ); indicator.setIndicatorType( indicatorType ); - indicator.setNumerator( prepareExcelFormulaForAutoForm( values[2] ) ); + indicator.setNumerator( prepareExcelFormulaForAutoForm( values[1] ) ); indicator.setNumeratorDescription( DESCRIPTION ); indicator.setDenominator( 1 + "" ); indicator.setDenominatorDescription( DESCRIPTION ); @@ -457,6 +479,7 @@ { String name = commonName + VALIDATION_RULE_NAME + "(" + convertColumnNumberToName( colIndex + 1 ) + (rowIndex + 1) + ")"; + message = VALIDATIONRULE_KEY + "@" + name; // Validation rules Expression leftSide = new Expression(); === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormRollBack.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormRollBack.java 2012-12-17 12:53:25 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/AutoGenerateFormRollBack.java 2012-12-18 08:08:53 +0000 @@ -27,7 +27,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.hisp.dhis.dataelement.DataElementService; @@ -49,6 +51,20 @@ public class AutoGenerateFormRollBack extends ActionSupport { + private static final Map keyMap = new HashMap() + { + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put( "de", "data_element_duplicated" ); + put( "id", "indicator_duplicated" ); + put( "vr", "validation_rule_duplicated" ); + } + }; + // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- @@ -115,7 +131,19 @@ { try { - message = ""; + if ( message == null || message.trim().isEmpty() ) + { + message = ""; + } + else + { + String values[] = message.split( "@" ); + + message = i18n.getString( keyMap.get( values[0] ) ) + " \"" + values[1] + "\"
"; + message += "----------------------------------
"; + message += i18n.getString( "rollback_result" ) + "
"; + message += "----------------------------------
"; + } if ( exportReportId > 0 ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2012-12-17 10:36:42 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2012-12-18 08:08:53 +0000 @@ -165,7 +165,6 @@ input_sheet_no = Not input sheet yet choose_export_report = Not choose export report yet choose_import_report = Not choose import report yet -choose_dataelement = Not choose dataelement yet warning_upload_is_null = Please choose your excel file to upload \! list_of_import_items = List of import items selected_dataelements = Selected Data Elements @@ -393,4 +392,9 @@ auto_generate_form = Automatic generating form generate_form = Generate form generate_form_confirm = Would you like to generate form now ? -auto_generate_form_completed = Form generated \ No newline at end of file +auto_generate_form_completed = Form generated +form_name_already_exists = Form name already exists +data_element_duplicated = Data element duplicated +indicator_duplicated = Indicator duplicated +validation_rule_duplicated = Validation rule duplicated +rollback_result = ROLLBACK RESULT \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2012-12-17 10:36:42 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2012-12-18 08:08:53 +0000 @@ -424,4 +424,9 @@ auto_generate_form = T\u1ef1 \u0111\u1ed9ng t\u1ea1o bi\u1ec3u m\u1eabu generate_form = T\u1ea1o bi\u1ec3u m\u1eabu generate_form_confirm = B\u1ea1n c\u00f3 mu\u1ed1n t\u1ea1o bi\u1ec3u m\u1eabu ngay b\u00e2y gi\u1edd ? -auto_generate_form_completed = Bi\u1ec3u m\u1eabu \u0111\u01b0\u1ee3c ho\u00e0n th\u00e0nh \ No newline at end of file +auto_generate_form_completed = Bi\u1ec3u m\u1eabu \u0111\u01b0\u1ee3c ho\u00e0n th\u00e0nh +form_name_already_exists = Bi\u1ec3u m\u1eabu b\u1ecb tr\u00f9ng t\u00ean +data_element_duplicated = Ph\u1ea7n t\u1eed d\u1eef li\u1ec7u tr\u00f9ng t\u00ean +indicator_duplicated = Ch\u1ec9 s\u1ed1 b\u1ecb tr\u00f9ng t\u00ean +validation_rule_duplicated = \u0110i\u1ec1u ki\u1ec7n ki\u1ec3m tra tr\u00f9ng t\u00ean +rollback_result = K\u1ebeT Q\u1ee6A PH\u1ee4C H\u1ed2I D\u1eee LI\u1ec6U \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2012-12-17 10:36:42 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2012-12-18 08:08:53 +0000 @@ -1862,6 +1862,8 @@ /dhis-web-spreadsheet-reporting/responseExportReportPreview.vm /dhis-web-spreadsheet-reporting/responseAutoGenerateFormError.vm + + ../dhis-web-commons/ajax/xmlResponseInput.vm