=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java 2011-10-24 05:42:25 +0000 @@ -27,20 +27,22 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.io.FileInputStream; +import java.util.Date; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Workbook; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.dataelement.DataElementCategoryService; +import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.datavalue.DataValueService; import org.hisp.dhis.expression.ExpressionService; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.period.Period; +import org.hisp.dhis.reportsheet.action.ActionSupport; import org.hisp.dhis.reportsheet.importitem.ImportReportService; -import org.hisp.dhis.reportsheet.action.ActionSupport; import org.hisp.dhis.reportsheet.period.generic.PeriodGenericManager; import org.hisp.dhis.reportsheet.state.SelectionManager; import org.hisp.dhis.user.CurrentUserService; @@ -147,13 +149,9 @@ if ( organisationUnit != null ) { - FileInputStream inputStream = new FileInputStream( selectionManager.getUploadFilePath() ); - - Workbook wb = new HSSFWorkbook( inputStream ); - Period period = periodGenericManager.getSelectedPeriod(); - executeToImport( organisationUnit, period, importItemIds, wb ); + executeToImport( organisationUnit, period, importItemIds ); } message = i18n.getString( "import_successfully" ); @@ -165,7 +163,37 @@ // Abstract method // ------------------------------------------------------------------------- - public abstract void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds, - Workbook wb ); - + public abstract void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds ); + + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + + protected void addDataValue( OrganisationUnit unit, Period period, String expression, String value ) + { + DataElementOperand operand = expressionService.getOperandsInExpression( expression ).iterator().next(); + + DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() ); + + DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( operand + .getOptionComboId() ); + + String storedBy = currentUserService.getCurrentUsername(); + + DataValue dataValue = dataValueService.getDataValue( unit, dataElement, period, optionCombo ); + + if ( dataValue == null ) + { + dataValue = new DataValue( dataElement, period, unit, value, storedBy, new Date(), null, optionCombo ); + dataValueService.addDataValue( dataValue ); + } + else + { + dataValue.setValue( value ); + dataValue.setTimestamp( new Date() ); + dataValue.setStoredBy( storedBy ); + + dataValueService.updateDataValue( dataValue ); + } + } } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataCategoryAction.java 2011-10-24 05:42:25 +0000 @@ -27,13 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Date; - -import org.apache.poi.ss.usermodel.Workbook; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementOperand; -import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.importing.ImportDataGeneric; @@ -51,44 +44,11 @@ // Override the abstract method // ------------------------------------------------------------------------- - public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds, Workbook wb ) + public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds ) { for ( int i = 0; i < importItemIds.length; i++ ) { - addDataValue( importItemIds[i].split( "-" )[0], importItemIds[i].split( "-" )[1], organisationUnit, period ); - } - } - - // ------------------------------------------------------------------------- - // Supportive method - // ------------------------------------------------------------------------- - - private void addDataValue( String expression, String value, OrganisationUnit organisationUnit, Period period ) - { - DataElementOperand operand = expressionService.getOperandsInExpression( expression ).iterator().next(); - - DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() ); - - DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( operand - .getOptionComboId() ); - - String storedBy = currentUserService.getCurrentUsername(); - - DataValue dataValue = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo ); - - if ( dataValue == null ) - { - dataValue = new DataValue( dataElement, period, organisationUnit, value + "", storedBy, new Date(), null, - optionCombo ); - dataValueService.addDataValue( dataValue ); - } - else - { - dataValue.setValue( value + "" ); - dataValue.setTimestamp( new Date() ); - dataValue.setStoredBy( storedBy ); - - dataValueService.updateDataValue( dataValue ); + addDataValue( organisationUnit, period, importItemIds[i].split( "-" )[0], importItemIds[i].split( "-" )[1] ); } } } \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataNormalAction.java 2011-10-24 05:42:25 +0000 @@ -27,13 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Date; - -import org.apache.poi.ss.usermodel.Workbook; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementOperand; -import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; import org.hisp.dhis.reportsheet.importing.ImportDataGeneric; @@ -51,43 +44,11 @@ // Override the abstract method // ------------------------------------------------------------------------- - public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds, Workbook wb ) + public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds ) { - String value = null; - for ( int i = 0; i < importItemIds.length; i++ ) { - value = importItemIds[i].split( "_" )[1]; - - if ( value.length() > 0 ) - { - DataElementOperand operand = expressionService.getOperandsInExpression( importItemIds[i].split( "_" )[0] ) - .iterator().next(); - - DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() ); - - DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( operand - .getOptionComboId() ); - - String storedBy = currentUserService.getCurrentUsername(); - - DataValue dataValue = dataValueService - .getDataValue( organisationUnit, dataElement, period, optionCombo ); - - if ( dataValue == null ) - { - dataValue = new DataValue( dataElement, period, organisationUnit, value + "", storedBy, new Date(), - null, optionCombo ); - dataValueService.addDataValue( dataValue ); - } - else - { - dataValue.setValue( value + "" ); - dataValue.setTimestamp( new Date() ); - dataValue.setStoredBy( storedBy ); - dataValueService.updateDataValue( dataValue ); - } - } + addDataValue( organisationUnit, period, importItemIds[i].split( "-" )[0], importItemIds[i].split( "-" )[1] ); } } } \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataOrganizationGroupAction.java 2011-10-24 05:42:25 +0000 @@ -27,22 +27,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Date; - -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementOperand; -import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; -import org.hisp.dhis.reportsheet.importitem.ImportItem; import org.hisp.dhis.reportsheet.importing.ImportDataGeneric; -import org.hisp.dhis.reportsheet.utils.ExcelUtils; /** * @author Chau Thu Tran + * @author Dang Duy Hieu * @version $Id$ */ @@ -54,60 +45,14 @@ // ------------------------------------------------------------------------- @Override - public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds, Workbook wb ) + public void executeToImport( OrganisationUnit organisationUnit, Period period, String[] importItemIds ) { for ( int i = 0; i < importItemIds.length; i++ ) { - int orgunitId = Integer.parseInt( importItemIds[i].split( "-" )[0] ); - - OrganisationUnit o = organisationUnitService.getOrganisationUnit( orgunitId ); - - int row = Integer.parseInt( importItemIds[i].split( "-" )[1] ); - - int importItemId = Integer.parseInt( importItemIds[i].split( "-" )[2] ); - - ImportItem importItem = importReportService.getImportItem( importItemId ); - - if ( importItem.getId() == importItemId ) - { - writeDataValue( importItem, wb, row, o, period ); - } - } - } - - private void writeDataValue( ImportItem importItem, Workbook wb, int row, OrganisationUnit o, Period period ) - { - Sheet sheet = wb.getSheetAt( importItem.getSheetNo() - 1 ); - - String value = ExcelUtils.readValueImportingByPOI( importItem.getRow() + row, importItem.getColumn(), sheet ); - - if ( value.length() > 0 ) - { - DataElementOperand operand = expressionService.getOperandsInExpression( importItem.getExpression() ) - .iterator().next(); - - DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() ); - - DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( operand - .getOptionComboId() ); - - String storedBy = currentUserService.getCurrentUsername(); - - DataValue dataValue = dataValueService.getDataValue( o, dataElement, period, optionCombo ); - - if ( dataValue == null ) - { - dataValue = new DataValue( dataElement, period, o, value + "", storedBy, new Date(), null, optionCombo ); - dataValueService.addDataValue( dataValue ); - } - else - { - dataValue.setValue( value + "" ); - dataValue.setTimestamp( new Date() ); - dataValue.setStoredBy( storedBy ); - - dataValueService.updateDataValue( dataValue ); - } + OrganisationUnit o = organisationUnitService.getOrganisationUnit( Integer.parseInt( importItemIds[i] + .split( "-" )[0] ) ); + + addDataValue( o, period, importItemIds[i].split( "-" )[1], importItemIds[i].split( "-" )[2] ); } } } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataCategoryAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataCategoryAction.java 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataCategoryAction.java 2011-10-24 05:42:25 +0000 @@ -59,7 +59,7 @@ setUpImportItems( importReport, importItems, categoryImportItems ); xmlStructureResponse = new XMLStructureResponseImport( selectionManager.getUploadFilePath(), - importReportService.getAllSheet(), categoryImportItems, true, ImportReport.TYPE.CATEGORY ).getXml(); + importReportService.getAllSheet(), categoryImportItems, true ).getXml(); } catch ( Exception ex ) { @@ -83,13 +83,12 @@ for ( DataElement dataElement : dataElementGroup.getDataElements() ) { ImportItem item = new ImportItem(); - - item.setId( importItem.getId() ); - + + item.setSheetNo( importItem.getSheetNo() ); + item.setRow( rowBegin++ ); + item.setColumn( importItem.getColumn() ); item.setExpression( importItem.getExpression().replace( "*", dataElement.getId() + "" ) ); - - item.setRow( rowBegin++ ); - + importItemsDest.add( item ); } } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataNormalAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataNormalAction.java 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataNormalAction.java 2011-10-24 05:42:25 +0000 @@ -52,7 +52,7 @@ try { xmlStructureResponse = new XMLStructureResponseImport( selectionManager.getUploadFilePath(), - importReportService.getAllSheet(), importItems, true, ImportReport.TYPE.NORMAL ).getXml(); + importReportService.getAllSheet(), importItems, true ).getXml(); } catch ( Exception ex ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataOrganizationGroupAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataOrganizationGroupAction.java 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ViewDataOrganizationGroupAction.java 2011-10-24 05:42:25 +0000 @@ -27,58 +27,32 @@ * 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.Collections; import java.util.List; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroup; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitNameComparator; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.reportsheet.importing.ViewDataGeneric; import org.hisp.dhis.reportsheet.importitem.ImportItem; import org.hisp.dhis.reportsheet.importitem.ImportReport; -import org.hisp.dhis.reportsheet.importitem.ImportReportService; -import org.hisp.dhis.reportsheet.importitem.comparator.ImportItemComparator; -import org.hisp.dhis.reportsheet.importing.ImportItemValue; -import org.hisp.dhis.reportsheet.importing.ImportItemValueByOrganisationUnit; -import org.hisp.dhis.reportsheet.state.SelectionManager; -import org.hisp.dhis.reportsheet.utils.ExcelUtils; - -import com.opensymphony.xwork2.Action; +import org.hisp.dhis.reportsheet.preview.action.XMLStructureResponseImport; /** - * @author Chau Thu Tran + * @author Dang Duy Hieu * @version $Id */ public class ViewDataOrganizationGroupAction - implements Action + extends ViewDataGeneric { // ------------------------------------------------------------------------- // Dependency // ------------------------------------------------------------------------- - private ImportReportService importReportService; - - public void setImportReportService( ImportReportService importReportService ) - { - this.importReportService = importReportService; - } - - private SelectionManager selectionManager; - - public void setSelectionManager( SelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - private OrganisationUnitSelectionManager organisationUnitSelectionManager; public void setOrganisationUnitSelectionManager( OrganisationUnitSelectionManager organisationUnitSelectionManager ) @@ -87,114 +61,65 @@ } // ------------------------------------------------------------------------- - // Inputs && Outputs - // ------------------------------------------------------------------------- - - private List importItemValueByOrgUnits; - - private String message; - - private I18n i18n; - - // ------------------------------------------------------------------------- - // Getters and Setters - // ------------------------------------------------------------------------- - - public List getImportItemValueByOrgUnits() - { - return importItemValueByOrgUnits; - } - - public String getMessage() - { - return message; - } - - public void setI18n( I18n i18n ) - { - this.i18n = i18n; - } - - // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- - public String execute() - { - try - { - OrganisationUnit unit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); - - if ( unit != null ) - { - FileInputStream inputStream = new FileInputStream( new File( selectionManager.getUploadFilePath() ) ); - - Workbook wb = new HSSFWorkbook( inputStream ); - - ImportReport importReport = importReportService - .getImportReport( selectionManager.getSelectedReportId() ); - - List importItems = new ArrayList( importReport.getImportItems() ); - - if ( importItems == null || importItems.isEmpty() ) + @Override + public void executeViewData( ImportReport importReport, List importItems ) + { + OrganisationUnit unit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); + + if ( unit != null ) + { + List orgUnitListingImportItems = new ArrayList(); + + setUpImportItems( importReport, unit, importItems, orgUnitListingImportItems ); + + try + { + xmlStructureResponse = new XMLStructureResponseImport( selectionManager.getUploadFilePath(), + importReportService.getAllSheet(), orgUnitListingImportItems, true ).getXml(); + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + } + + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + + private void setUpImportItems( ImportReport importReport, OrganisationUnit selectedUnit, + List importItemsSource, List importItemsDest ) + { + for ( OrganisationUnitGroup organisationUnitGroup : importReport.getOrganisationUnitGroups() ) + { + List organisationUnits = new ArrayList( getOrganisationUnits( + organisationUnitGroup, selectedUnit ) ); + + Collections.sort( organisationUnits, new OrganisationUnitNameComparator() ); + + int row = 0; + + for ( OrganisationUnit o : organisationUnits ) + { + for ( ImportItem importItem : importItemsSource ) { - message = i18n.getString( "import_excel_items_cannot_be_empty" ); + ImportItem item = new ImportItem(); + + item.setSheetNo( importItem.getSheetNo() ); + item.setRow( importItem.getRow() + row ); + item.setColumn( importItem.getColumn() ); + item.setExpression( o.getId() + "_" + importItem.getExpression() ); - return ERROR; + importItemsDest.add( item ); } - Collections.sort( importItems, new ImportItemComparator() ); - - importItemValueByOrgUnits = new ArrayList(); - - for ( OrganisationUnitGroup organisationUnitGroup : importReport.getOrganisationUnitGroups() ) - { - List organisationUnits = new ArrayList( getOrganisationUnits( - organisationUnitGroup, unit ) ); - - Collections.sort( organisationUnits, new OrganisationUnitNameComparator() ); - - int row = 0; - - for ( OrganisationUnit o : organisationUnits ) - { - ImportItemValueByOrganisationUnit importItemValueByOrgUnit = new ImportItemValueByOrganisationUnit( - o ); - List importItemValues = new ArrayList(); - - for ( ImportItem importItem : importItems ) - { - Sheet sheet = wb.getSheetAt( importItem.getSheetNo() - 1 ); - - String value = ExcelUtils.readValueImportingByPOI( importItem.getRow() + row, importItem - .getColumn(), sheet ); - - if ( value.length() > 0 ) - { - ImportItemValue importItemValue = new ImportItemValue( importItem, value ); - importItemValues.add( importItemValue ); - } - - }// end for (ImportItem ... - - row++; - - importItemValueByOrgUnit.setImportItemValues( importItemValues ); - - importItemValueByOrgUnits.add( importItemValueByOrgUnit ); - - }// end for (OrganisationUnit ... - - } // end for ( OrganisationUnitGroup ... - - }// end if (organisationUnit ... - } - catch ( Exception ex ) - { - ex.printStackTrace(); - } - - return SUCCESS; + row++; + } + } } private Collection getOrganisationUnits( OrganisationUnitGroup group, OrganisationUnit parentUnit ) === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java 2011-08-04 08:39:55 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java 2011-10-24 05:42:25 +0000 @@ -45,7 +45,6 @@ import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.hisp.dhis.reportsheet.importitem.ImportItem; -import org.hisp.dhis.reportsheet.importitem.ImportReport; /** * @@ -97,7 +96,7 @@ */ public XMLStructureResponseImport( String pathFileName, Collection collectSheets, - List importItems, boolean bWriteDescription, String type ) + List importItems, boolean bWriteDescription ) throws Exception { this.cleanUpForResponse(); @@ -113,7 +112,7 @@ this.WORKBOOK = new XSSFWorkbook( inputStream ); } - this.writeFormattedXML( collectSheets, importItems, bWriteDescription, type ); + this.writeFormattedXML( collectSheets, importItems, bWriteDescription ); } // ------------------------------------------------------------------------- @@ -126,7 +125,7 @@ } private void writeFormattedXML( Collection collectSheets, List importItems, - boolean bWriteDescription, String type ) + boolean bWriteDescription ) throws Exception { if ( bWriteDescription ) @@ -138,7 +137,7 @@ for ( Integer sheet : collectSheets ) { - this.writeData( sheet, importItems, type ); + this.writeData( sheet, importItems ); } xml.append( WORKBOOK_CLOSETAG ); @@ -157,7 +156,7 @@ xml.append( MERGEDCELL_CLOSETAG ); } - private void writeData( int sheetNo, List importItems, String TYPE ) + private void writeData( int sheetNo, List importItems ) { Sheet s = WORKBOOK.getSheetAt( sheetNo - 1 ); @@ -165,8 +164,8 @@ xml.append( "" ); int run = 0; - int i = 0; - int j = 0; + int i = 0;// Presented as row index + int j = 0;// Presented as column index for ( Row row : s ) { @@ -188,12 +187,8 @@ if ( (importItem.getSheetNo() == sheetNo) && (importItem.getRow() == (i + 1)) && (importItem.getColumn() == (j + 1)) ) { - if ( TYPE.equals( ImportReport.TYPE.NORMAL ) - || TYPE.equals( ImportReport.TYPE.CATEGORY ) ) - { - xml.append( " id='" + importItem.getExpression() + "'>" ); - } - + xml.append( " id='" + importItem.getExpression() + "'>" ); + // If there is any importItem matched the condition then break out the for loop break; }