Author: jleroux
Date: Mon Dec 3 08:17:47 2018 New Revision: 1848026 URL: http://svn.apache.org/viewvc?rev=1848026&view=rev Log: "Applied fix from plugins for revision: 1848009" ------------------------------------------------------------------------ r1848009 | shijh | 2018-12-02 19:51:51 +0100 (dim. 02 déc. 2018) | 16 lignes Improved: OFBizPricatUtil class don't use a org.apache.ofbiz.pricat package (OFBIZ-10655) I didn't realized OFBizPricatUtil under org.apache.poi package is a bug for OFBiz project at the first sight of this issue. When I tried to think from Jacques view as our project SQA, I understood this OFBizPricatUtil may be missed during code style check, and this is a major problem :). Now I moved the OFBizPricatUtil under org.apache.ofbiz.pricat.util package and changed two other files accordingly. I upgraded the implement to match the POI 3.7 used in the OFBiz plugins trunk, and I also tested it with POI 4.0.0 and it worked fine. Thanks: Jacques for pointing out this issue ------------------------------------------------------------------------ jleroux: I fixed 2 small conflicts by hand in AbstractPricatParser and SamplePricatParser.java Added: ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/util/ - copied from r1848009, ofbiz/ofbiz-plugins/trunk/pricat/src/main/java/org/apache/ofbiz/pricat/util/ Removed: ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/poi/ Modified: ofbiz/ofbiz-plugins/branches/release17.12/ (props changed) ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java Propchange: ofbiz/ofbiz-plugins/branches/release17.12/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Mon Dec 3 08:17:47 2018 @@ -11,4 +11,4 @@ /ofbiz/branches/multitenant20100310/plugins:921280-927264 /ofbiz/branches/release13.07/plugins:1547657 /ofbiz/ofbiz-framework/trunk:1836107 -/ofbiz/ofbiz-plugins/trunk:1819576,1819580,1819582,1819589,1820962,1820973,1821045,1821049,1821051,1822129,1822133,1822139,1822143,1822145,1822389,1822391,1822395,1824646,1824648,1824650,1824654,1828569,1830856,1831084,1832727,1832800,1837796,1837845,1837857,1838249,1838381,1838816,1841650,1845558,1847272,1847346,1847398,1847528,1847530 +/ofbiz/ofbiz-plugins/trunk:1819576,1819580,1819582,1819589,1820962,1820973,1821045,1821049,1821051,1822129,1822133,1822139,1822143,1822145,1822389,1822391,1822395,1824646,1824648,1824650,1824654,1828569,1830856,1831084,1832727,1832800,1837796,1837845,1837857,1838249,1838381,1838816,1841650,1845558,1847272,1847346,1847398,1847528,1847530,1848009 Modified: ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java?rev=1848026&r1=1848025&r2=1848026&view=diff ============================================================================== --- ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java (original) +++ ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/AbstractPricatParser.java Mon Dec 3 08:17:47 2018 @@ -33,12 +33,12 @@ import javax.servlet.http.HttpServletReq import javax.servlet.http.HttpSession; import org.apache.poi.hssf.usermodel.HSSFDataFormatter; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType; import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.WorkbookUtil; -import org.apache.poi.xssf.usermodel.OFBizPricatUtil; import org.apache.poi.xssf.usermodel.XSSFAnchor; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFClientAnchor; @@ -57,6 +57,7 @@ import org.apache.commons.fileupload.Fil import org.apache.ofbiz.htmlreport.InterfaceReport; import org.apache.ofbiz.order.finaccount.FinAccountHelper; +import org.apache.ofbiz.pricat.util.OFBizPricatUtil; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.FileUtil; import org.apache.ofbiz.base.util.UtilDateTime; @@ -295,22 +296,22 @@ public abstract class AbstractPricatPars XSSFCell cell = sourceRow.getCell(j); if (cell != null) { XSSFCell newCell = targetRow.createCell(j); - int cellType = cell.getCellType(); + CellType cellType = cell.getCellTypeEnum(); newCell.setCellType(cellType); switch (cellType) { - case XSSFCell.CELL_TYPE_BOOLEAN: + case BOOLEAN: newCell.setCellValue(cell.getBooleanCellValue()); break; - case XSSFCell.CELL_TYPE_ERROR: + case ERROR: newCell.setCellErrorValue(cell.getErrorCellValue()); break; - case XSSFCell.CELL_TYPE_FORMULA: + case FORMULA: newCell.setCellFormula(cell.getCellFormula()); break; - case XSSFCell.CELL_TYPE_NUMERIC: + case NUMERIC: newCell.setCellValue(cell.getNumericCellValue()); break; - case XSSFCell.CELL_TYPE_STRING: + case STRING: newCell.setCellValue(cell.getRichStringCellValue()); break; default: @@ -427,10 +428,10 @@ public abstract class AbstractPricatPars cell = row.createCell(i); } } - int cellType = cell.getCellType(); + CellType cellType = cell.getCellTypeEnum(); String cellValue = formatter.formatCellValue(cell); if (UtilValidate.isNotEmpty(cellValue)) { - if (cellType == XSSFCell.CELL_TYPE_FORMULA) { + if (cellType == CellType.FORMULA) { cellValue = BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding).toString(); report.print(((i == 0)?"":", ") + cellValue, InterfaceReport.FORMAT_NOTE); } else { @@ -446,13 +447,13 @@ public abstract class AbstractPricatPars results.add(null); continue; } - if (((Boolean) colNames.get(i)[2]).booleanValue() && cellType != (int) colNames.get(i)[1]) { + if ((Boolean) colNames.get(i)[2] && cellType != colNames.get(i)[1]) { // String warningMessage = ""; - if ((int) colNames.get(i)[1] == XSSFCell.CELL_TYPE_STRING) { + if (colNames.get(i)[1] == CellType.STRING) { results.add(cellValue); - } else if ((int) colNames.get(i)[1] == XSSFCell.CELL_TYPE_NUMERIC) { - if (cell.getCellType() != XSSFCell.CELL_TYPE_STRING) { - cell.setCellType(XSSFCell.CELL_TYPE_STRING); + } else if (colNames.get(i)[1] == CellType.NUMERIC) { + if (cell.getCellTypeEnum() != CellType.STRING) { + cell.setCellType(CellType.STRING); } try { results.add(BigDecimal.valueOf(Double.parseDouble(cell.getStringCellValue())).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding)); @@ -466,21 +467,21 @@ public abstract class AbstractPricatPars results.add(null); continue; } - if ((int) colNames.get(i)[1] == XSSFCell.CELL_TYPE_STRING) { - if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) { + if (colNames.get(i)[1] == CellType.STRING) { + if (cell.getCellTypeEnum() == CellType.STRING) { results.add(cell.getStringCellValue()); } else { results.add(cellValue); } - } else if ((int) colNames.get(i)[1] == XSSFCell.CELL_TYPE_NUMERIC) { - if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) { + } else if (colNames.get(i)[1] == CellType.NUMERIC) { + if (cell.getCellTypeEnum() == CellType.STRING) { try { results.add(BigDecimal.valueOf(Double.valueOf(cell.getStringCellValue()))); } catch (NumberFormatException e) { results.add(null); errorMessages.put(new CellReference(cell), UtilProperties.getMessage(resource, "ErrorParseValueToNumeric", locale)); } - } else if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) { + } else if (cell.getCellTypeEnum() == CellType.NUMERIC) { try { results.add(BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding)); } catch (NumberFormatException e) { Modified: ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java?rev=1848026&r1=1848025&r2=1848026&view=diff ============================================================================== --- ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java (original) +++ ofbiz/ofbiz-plugins/branches/release17.12/pricat/src/main/java/org/apache/ofbiz/pricat/sample/SamplePricatParser.java Mon Dec 3 08:17:47 2018 @@ -42,8 +42,8 @@ import org.apache.ofbiz.order.finaccount import org.apache.ofbiz.pricat.AbstractPricatParser; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ServiceUtil; -import org.apache.poi.POIXMLException; import org.apache.poi.hssf.usermodel.HSSFDataFormatter; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.util.CellReference; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; @@ -87,10 +87,6 @@ public class SamplePricatParser extends report.println(e); report.println(UtilProperties.getMessage(resource, "PricatSuggestion", locale), InterfaceReport.FORMAT_ERROR); return; - } catch(POIXMLException e) { - report.println(e); - report.println(UtilProperties.getMessage(resource, "PricatSuggestion", locale), InterfaceReport.FORMAT_ERROR); - return; } // 3. only first sheet will be parsed @@ -478,54 +474,54 @@ public class SamplePricatParser extends private static List<Object[]> genExcelHeaderNamesV1_1() { List<Object[]> listHeaderName = new ArrayList<Object[]>(); listHeaderName.add(new Object[] {"Facility Name", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.TRUE}); listHeaderName.add(new Object[] {"FacilityId", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.TRUE}); listHeaderName.add(new Object[] {"Category L1", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.FALSE}); listHeaderName.add(new Object[] {"Category L2", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.FALSE}); listHeaderName.add(new Object[] {"Category L3", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.FALSE}); listHeaderName.add(new Object[] {"Category L4", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.FALSE}); listHeaderName.add(new Object[] {"Brand", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.TRUE}); listHeaderName.add(new Object[] {"Style No", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.TRUE}); listHeaderName.add(new Object[] {"Product Name", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.TRUE}); listHeaderName.add(new Object[] {"Color", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.FALSE}); listHeaderName.add(new Object[] {"Size", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.FALSE}); listHeaderName.add(new Object[] {"Barcode", - XSSFCell.CELL_TYPE_STRING, + CellType.STRING, Boolean.FALSE}); listHeaderName.add(new Object[] {"Stock Qty", - XSSFCell.CELL_TYPE_NUMERIC, + CellType.NUMERIC, Boolean.TRUE}); listHeaderName.add(new Object[] {"Average Cost", - XSSFCell.CELL_TYPE_NUMERIC, + CellType.NUMERIC, Boolean.TRUE, Boolean.TRUE}); listHeaderName.add(new Object[] {"List Price", - XSSFCell.CELL_TYPE_NUMERIC, + CellType.NUMERIC, Boolean.TRUE, Boolean.TRUE}); listHeaderName.add(new Object[] {"Member Price", - XSSFCell.CELL_TYPE_NUMERIC, + CellType.NUMERIC, Boolean.FALSE, Boolean.TRUE}); return listHeaderName; @@ -569,10 +565,10 @@ public class SamplePricatParser extends cell = row.createCell(i); } } - int cellType = cell.getCellType(); + CellType cellType = cell.getCellTypeEnum(); String cellValue = formatter.formatCellValue(cell); if (UtilValidate.isNotEmpty(cellValue) && UtilValidate.isNotEmpty(cellValue.trim())) { - if (cellType == XSSFCell.CELL_TYPE_FORMULA) { + if (cellType == CellType.FORMULA) { try { cellValue = BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding).toString(); } catch (IllegalStateException e) { @@ -596,17 +592,17 @@ public class SamplePricatParser extends results.add(null); continue; } - if (((Boolean) colNames.get(i)[2]).booleanValue() && cellType != (int) colNames.get(i)[1]) { + if ((Boolean) colNames.get(i)[2] && cellType != colNames.get(i)[1]) { // String warningMessage = ""; - if ((int) colNames.get(i)[1] == XSSFCell.CELL_TYPE_STRING) { + if (colNames.get(i)[1] == CellType.STRING) { if (UtilValidate.isNotEmpty(cellValue) && UtilValidate.isNotEmpty(cellValue.trim())) { results.add(cellValue); } else { results.add(null); } - } else if ((int) colNames.get(i)[1] == XSSFCell.CELL_TYPE_NUMERIC) { - if (cell.getCellType() != XSSFCell.CELL_TYPE_STRING) { - cell.setCellType(XSSFCell.CELL_TYPE_STRING); + } else if (colNames.get(i)[1] == CellType.NUMERIC) { + if (cell.getCellTypeEnum() != CellType.STRING) { + cell.setCellType(CellType.STRING); } try { results.add(BigDecimal.valueOf(Double.parseDouble(cell.getStringCellValue())).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding)); @@ -620,22 +616,22 @@ public class SamplePricatParser extends results.add(null); continue; } - if ((int) colNames.get(i)[1] == XSSFCell.CELL_TYPE_STRING) { - if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) { + if (colNames.get(i)[1] == CellType.STRING) { + if (cell.getCellTypeEnum() == CellType.STRING) { cellValue = cell.getStringCellValue().trim(); results.add(cellValue); } else { results.add(cellValue.trim()); } - } else if ((int) colNames.get(i)[1] == XSSFCell.CELL_TYPE_NUMERIC) { - if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) { + } else if (colNames.get(i)[1] == CellType.NUMERIC) { + if (cell.getCellTypeEnum() == CellType.STRING) { try { results.add(BigDecimal.valueOf(Double.valueOf(cell.getStringCellValue()))); } catch (NumberFormatException e) { results.add(null); errorMessages.put(new CellReference(cell), UtilProperties.getMessage(resource, "ErrorParseValueToNumeric", locale)); } - } else if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) { + } else if (cell.getCellTypeEnum() == CellType.NUMERIC) { try { results.add(BigDecimal.valueOf(cell.getNumericCellValue()).setScale(FinAccountHelper.decimals, FinAccountHelper.rounding)); } catch (NumberFormatException e) { |
Free forum by Nabble | Edit this page |