List of usage examples for org.apache.poi.ss.usermodel Row cellIterator
Iterator<Cell> cellIterator();
From source file:org.exist.xquery.corenlp.TrainClassifier.java
License:Open Source License
private Collection<List<CoreLabel>> readXLSXSpreadsheet(final String localFilePath, final InputDocType inputFormat) throws XPathException { Workbook workbook = null;//from ww w . j a va2 s . c o m Collection<List<CoreLabel>> documents = new ArrayList<>(); List<CoreLabel> document = new ArrayList<>(); String fileName = "localFilePath"; String extraSuffix = (inputFormat != InputDocType.XLSX) ? "" : "x"; //try (InputStream is = Files.newInputStream(tempInFile)) { try (InputStream is = uploadedFileBase64String == null ? uploadedFileBase64String.getInputStream() : new Resource(fileName + extraSuffix).getInputStream()) { if (inputFormat == InputDocType.XLSX) { workbook = new XSSFWorkbook(is); } else { workbook = new HSSFWorkbook(is); } } catch (FileNotFoundException fe) { LOG.error(fe); } catch (IOException ioe) { LOG.error(ioe); throw new XPathException(this, "Error while reading spreadsheet document: " + ioe.getMessage(), ioe); } org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(0); Row row; Cell cell; Iterator rows = sheet.rowIterator(); while (rows.hasNext()) { CoreLabel tok = new CoreLabel(); row = (Row) rows.next(); Iterator cells = row.cellIterator(); int cellPos = 0; while (cells.hasNext()) { cell = (Cell) cells.next(); //if (cell.getCellType() == Cell.CELL_TYPE_STRING) { switch (cellPos) { case 0: tok.setWord(cell.getStringCellValue()); break; case 1: tok.setNER(cell.getStringCellValue()); tok.set(CoreAnnotations.AnswerAnnotation.class, cell.getStringCellValue()); break; case 2: tok.setTag(cell.getStringCellValue()); break; default: break; } //} else if(cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { //LOG.error("Cell has numeric value:" + cell.getNumericCellValue()); //} cellPos++; } if (!"".equals(tok.word())) { document.add(tok); } else { documents.add(document); document = new ArrayList<>(); } } return documents; }
From source file:org.formiz.core.input.xls.RowUtils.java
License:Open Source License
/** * Get the number of columns in this row. * * @param ligneTitres//from w w w . j a v a2 s .co m * @return number of columns. */ public static int columnsCount(Row ligneTitres) { Cell cell; int count = 0; Iterator<Cell> cellIterator = ligneTitres.cellIterator(); while (cellIterator.hasNext()) { cell = cellIterator.next(); if (StringUtils.isNotBlank(cell.getStringCellValue())) { count++; } } return count; }
From source file:org.isource.util.CSVUtils.java
private static List<List> readWorkbook(HSSFWorkbook workbook) { List<List> lines = new ArrayList<List>(); workbook = evaluateFormulas(workbook); HSSFSheet sheet = workbook.getSheetAt(0); Iterator<Row> rowIterator = sheet.iterator(); while (rowIterator.hasNext()) { Row row = rowIterator.next(); List<String> line = new ArrayList<String>(); //For each row, iterate through each columns Iterator<Cell> cellIterator = row.cellIterator(); while (cellIterator.hasNext()) { Cell cell = cellIterator.next(); switch (cell.getCellType()) { case Cell.CELL_TYPE_BOOLEAN: line.add(new Boolean(cell.getBooleanCellValue()).toString()); break; case Cell.CELL_TYPE_NUMERIC: if (DateUtil.isCellDateFormatted(cell)) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy"); line.add(dateFormat.format(cell.getDateCellValue())); } else { line.add(new Double(cell.getNumericCellValue()).toString()); }/*from ww w .j av a2 s . c om*/ break; case Cell.CELL_TYPE_STRING: line.add(cell.getStringCellValue()); break; case Cell.CELL_TYPE_FORMULA: switch (cell.getCachedFormulaResultType()) { case Cell.CELL_TYPE_NUMERIC: line.add(new Double(cell.getNumericCellValue()).toString()); break; case Cell.CELL_TYPE_STRING: line.add(cell.getRichStringCellValue().toString()); break; } break; } } lines.add(line); } return lines; }
From source file:org.jeecgframework.poi.excel.imports.ExcelImportServer.java
License:Apache License
/** * ????/*from w ww . j ava 2 s . c o m*/ * * @param rows * @param params * @param excelCollection * @return */ private Map<Integer, String> getTitleMap(Iterator<Row> rows, ImportParams params, List<ExcelCollectionParams> excelCollection) { Map<Integer, String> titlemap = new HashMap<Integer, String>(); Iterator<Cell> cellTitle; String collectionName = null; ExcelCollectionParams collectionParams = null; Row row = null; for (int j = 0; j < params.getHeadRows(); j++) { row = rows.next(); if (row == null) { continue; } cellTitle = row.cellIterator(); while (cellTitle.hasNext()) { Cell cell = cellTitle.next(); String value = getKeyValue(cell); int i = cell.getColumnIndex(); // ???? if (StringUtils.isNotEmpty(value)) { if (titlemap.containsKey(i)) { collectionName = titlemap.get(i); collectionParams = getCollectionParams(excelCollection, collectionName); titlemap.put(i, collectionName + "_" + value); } else if (StringUtils.isNotEmpty(collectionName) && collectionParams.getExcelParams().containsKey(collectionName + "_" + value)) { titlemap.put(i, collectionName + "_" + value); } else { collectionName = null; collectionParams = null; } if (StringUtils.isEmpty(collectionName)) { titlemap.put(i, value); } } } } return titlemap; }
From source file:org.lisapark.octopus.util.json.JsonUtils.java
License:Open Source License
/** * /*from www .java 2 s .c o m*/ * @param row * @param cells * @throws JSONException */ private JSONArray jsonFromRow(Row row) throws JSONException { JSONArray cells = new JSONArray(); for (Iterator<Cell> cellsIT = row.cellIterator(); cellsIT.hasNext();) { Cell cell = cellsIT.next(); if (cell.getCellType() == Cell.CELL_TYPE_STRING || cell.getCellType() == Cell.CELL_TYPE_BLANK) { cells.put(cell.getStringCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { cells.put(cell.getNumericCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { cells.put(cell.getBooleanCellValue()); } else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) { cells.put(cell.getErrorCellValue()); } else { cells.put("N/A"); } } return cells; }
From source file:org.lisapark.octopus.util.json.JsonUtils.java
License:Open Source License
private String jsonFromRowAsString(Row row) throws JSONException { StringBuilder cells = new StringBuilder(); Boolean first = Boolean.TRUE; Boolean dirty = Boolean.FALSE; // cells.append("["); int i = 0;//from ww w .j a v a 2 s .c o m for (Iterator<Cell> cellsIT = row.cellIterator(); cellsIT.hasNext();) { if (dataFieldNames().size() <= i) break; Cell cell = cellsIT.next(); if (cell.getCellType() == Cell.CELL_TYPE_STRING) { if (first) { cells.append(key(dataFieldNames().get(i))).append(quotes(cell.getStringCellValue())); first = Boolean.FALSE; } else { cells.append(",").append(key(dataFieldNames().get(i))) .append(quotes(cell.getStringCellValue())); } dirty = Boolean.TRUE; } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) { if (first) { cells.append(key(dataFieldNames().get(i))).append(quotes(cell.getStringCellValue())); first = Boolean.FALSE; } else { cells.append(",").append(key(dataFieldNames().get(i))) .append(quotes(cell.getStringCellValue())); } } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { if (first) { cells.append(key(dataFieldNames().get(i))).append(cell.getNumericCellValue()); first = Boolean.FALSE; } else { cells.append(",").append(key(dataFieldNames().get(i))).append(cell.getNumericCellValue()); } dirty = Boolean.TRUE; } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { if (first) { cells.append(key(dataFieldNames().get(i))).append(cell.getBooleanCellValue()); first = Boolean.FALSE; } else { cells.append(",").append(key(dataFieldNames().get(i))).append(cell.getBooleanCellValue()); } dirty = Boolean.TRUE; } else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) { if (first) { cells.append(key(dataFieldNames().get(i))).append(cell.getErrorCellValue()); first = Boolean.FALSE; } else { cells.append(",").append(key(dataFieldNames().get(i))).append(cell.getErrorCellValue()); } dirty = Boolean.TRUE; } else { if (first) { cells.append(key(dataFieldNames().get(i))).append("N/A"); first = Boolean.FALSE; } else { cells.append(",").append(key(dataFieldNames().get(i))).append("N/A"); } dirty = Boolean.TRUE; } i++; } if (dirty) { return "{" + cells.append("}").toString(); } else { return ""; } }
From source file:org.lisapark.octopus.util.xml.XmlConverterUtils.java
License:Open Source License
/** * /*from www .j av a2 s.co m*/ * @param row * @return * @throws JSONException */ private static String tagAttributesAsString(Row row) throws JSONException { StringBuilder cells = new StringBuilder(); Boolean dirty = Boolean.FALSE; int i = 0; for (Iterator<Cell> cellsIT = row.cellIterator(); cellsIT.hasNext();) { if (dataFieldNames.size() <= i) { break; } Cell cell = cellsIT.next(); if (cell.getCellType() == Cell.CELL_TYPE_STRING) { cells.append(attribute(dataFieldNames.get(i), cell.getStringCellValue())); dirty = Boolean.TRUE; } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK) { // cells.append(attribute(dataFieldNames.get(i), cell.getStringCellValue())); } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { cells.append(attribute(dataFieldNames.get(i), cell.getNumericCellValue())); dirty = Boolean.TRUE; } else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { cells.append(attribute(dataFieldNames.get(i), cell.getBooleanCellValue())); dirty = Boolean.TRUE; } else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) { cells.append(attribute(dataFieldNames.get(i), cell.getErrorCellValue())); dirty = Boolean.TRUE; } else { cells.append(attribute(dataFieldNames.get(i), "N/A")); dirty = Boolean.TRUE; } i++; } if (dirty) { return cells.toString(); } else { return ""; } }
From source file:org.lisapark.octopus.util.xml.XmlConverterUtils.java
License:Open Source License
private static String tagNodesAsString(Row row, int dataRangeStart, int dataRangeLen) throws JSONException { StringBuilder nodeStringBuilder = new StringBuilder(); StringBuilder rowStringBuilder = new StringBuilder(); int start;/* w w w. j a v a2 s . co m*/ int end; // Define start and end points of cell range to be converted if (dataRangeStart == -1) { start = row.getFirstCellNum(); } else { start = row.getFirstCellNum() + dataRangeStart; } if (dataRangeLen == 0) { end = row.getPhysicalNumberOfCells(); } else { end = start + dataRangeLen; } int i = 0; int j = 0; // Itarate over cell range and build xml nodes for (Iterator<Cell> cellsIT = row.cellIterator(); cellsIT.hasNext();) { if (i >= end) { break; } Cell cell = cellsIT.next(); // Skip cells that are out of range if (i > 0 && i < start) { i++; continue; } // Build all nodes from Spreadsheet row with specified cell range rowStringBuilder = rowStringBuilder.append(buidNodeAsString(cell, i, j)); i++; j++; } return nodeStringBuilder.append(rowStringBuilder.toString()).toString(); }
From source file:org.meveo.admin.parse.xls.XLSFile.java
License:Open Source License
public void parse() throws IOException { Workbook w;/*www .j a va 2 s. c o m*/ try { w = WorkbookFactory.create(new FileInputStream(file)); // Get the first sheet Sheet sheet = w.getSheetAt(0); // Loop over first 10 column and lines Iterator<Row> rowIterator = sheet.rowIterator(); while (rowIterator.hasNext()) { Row row = rowIterator.next(); Iterator<Cell> cellIterator = row.cellIterator(); String[] strs = new String[row.getPhysicalNumberOfCells()]; int cellCtr = 0; while (cellIterator.hasNext()) { Cell cell = cellIterator.next(); strs[cellCtr++] = cell.getStringCellValue(); } contexts.add(strs); } } catch (InvalidFormatException e) { log.error("invalid file format ", e); } }
From source file:org.meveo.service.catalog.impl.PricePlanMatrixService.java
License:Open Source License
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void importExcelLine(Row row, User user, Provider provider) throws BusinessException { EntityManager em = getEntityManager(); Object[] cellsObj = IteratorUtils.toArray(row.cellIterator()); int rowIndex = row.getRowNum(); int i = 0;// ww w .ja v a 2 s. c o m String pricePlanCode = getCellAsString((Cell) cellsObj[i++]); PricePlanMatrix pricePlan = null; QueryBuilder qb = new QueryBuilder(PricePlanMatrix.class, "p"); qb.addCriterion("code", "=", pricePlanCode, false); qb.addCriterionEntity("provider", provider); @SuppressWarnings("unchecked") List<PricePlanMatrix> pricePlans = qb.getQuery(em).getResultList(); if (pricePlans == null || pricePlans.size() == 0) { pricePlan = new PricePlanMatrix(); pricePlan.setProvider(provider); pricePlan.setAuditable(new Auditable()); pricePlan.getAuditable().setCreated(new Date()); pricePlan.getAuditable().setCreator(user); } else if (pricePlans.size() == 1) { pricePlan = pricePlans.get(0); } else { throw new BusinessException( "More than one priceplan in line=" + rowIndex + "with code=" + pricePlanCode); } String pricePlanDescription = getCellAsString((Cell) cellsObj[i++]); String eventCode = getCellAsString((Cell) cellsObj[i++]); String sellerCode = getCellAsString((Cell) cellsObj[i++]); String countryCode = getCellAsString((Cell) cellsObj[i++]); String currencyCode = getCellAsString((Cell) cellsObj[i++]); try { pricePlan.setStartSubscriptionDate(getCellAsDate((Cell) cellsObj[i++])); } catch (Exception e) { throw new BusinessException("Invalid startAppli in line=" + rowIndex + " expected format:" + param.getProperty("excelImport.dateFormat", "dd/MM/yyyy") + ", you may change the property excelImport.dateFormat."); } try { pricePlan.setEndSubscriptionDate(getCellAsDate((Cell) cellsObj[i++])); } catch (Exception e) { throw new BusinessException("Invalid endAppli in line=" + rowIndex + " expected format:" + param.getProperty("excelImport.dateFormat", "dd/MM/yyyy") + ", you may change the property excelImport.dateFormat."); } String offerCode = getCellAsString((Cell) cellsObj[i++]); String priority = getCellAsString((Cell) cellsObj[i++]); String amountWOTax = getCellAsString((Cell) cellsObj[i++]); String amountWithTax = getCellAsString((Cell) cellsObj[i++]); String amountWOTaxEL = getCellAsString((Cell) cellsObj[i++]); String amountWithTaxEL = getCellAsString((Cell) cellsObj[i++]); String minQuantity = getCellAsString((Cell) cellsObj[i++]); String maxQuantity = getCellAsString((Cell) cellsObj[i++]); String criteria1 = getCellAsString((Cell) cellsObj[i++]); String criteria2 = getCellAsString((Cell) cellsObj[i++]); String criteria3 = getCellAsString((Cell) cellsObj[i++]); String criteriaEL = getCellAsString((Cell) cellsObj[i++]); try { pricePlan.setStartRatingDate(getCellAsDate((Cell) cellsObj[i++])); } catch (Exception e) { throw new BusinessException("Invalid startRating in line=" + rowIndex + " expected format:" + param.getProperty("excelImport.dateFormat", "dd/MM/yyyy") + ", you may change the property excelImport.dateFormat."); } try { pricePlan.setEndRatingDate(getCellAsDate((Cell) cellsObj[i++])); } catch (Exception e) { throw new BusinessException("Invalid endRating in line=" + rowIndex + " expected format:" + param.getProperty("excelImport.dateFormat", "dd/MM/yyyy") + ", you may change the property excelImport.dateFormat."); } String minSubAge = getCellAsString((Cell) cellsObj[i++]); String maxSubAge = getCellAsString((Cell) cellsObj[i++]); String validityCalendarCode = getCellAsString((Cell) cellsObj[i++]); log.debug( "priceplanCode={}, priceplanDescription= {}, chargeCode={} sellerCode={}, countryCode={}, currencyCode={}," + " startSub={}, endSub={}, offerCode={}, priority={}, amountWOTax={}, amountWithTax={},amountWOTaxEL={}, amountWithTaxEL={}," + " minQuantity={}, maxQuantity={}, criteria1={}, criteria2={}, criteria3={}, criteriaEL={}," + " startRating={}, endRating={}, minSubAge={}, maxSubAge={}, validityCalendarCode={}", new Object[] { pricePlanCode, pricePlanDescription, eventCode, sellerCode, countryCode, currencyCode, pricePlan.getStartSubscriptionDate(), pricePlan.getEndSubscriptionDate(), offerCode, priority, amountWOTax, amountWithTax, amountWOTaxEL, amountWithTaxEL, minQuantity, maxQuantity, criteria1, criteria2, criteria3, criteriaEL, pricePlan.getStartRatingDate(), pricePlan.getEndRatingDate(), minSubAge, maxSubAge, validityCalendarCode }); if (!StringUtils.isBlank(eventCode)) { qb = new QueryBuilder(ChargeTemplate.class, "p"); qb.addCriterion("code", "=", eventCode, false); qb.addCriterionEntity("provider", provider); @SuppressWarnings("unchecked") List<Seller> charges = qb.getQuery(em).getResultList(); if (charges.size() == 0) { throw new BusinessException("cannot find charge in line=" + rowIndex + " with code=" + eventCode); } else if (charges.size() > 1) { throw new BusinessException("more than one charge in line=" + rowIndex + " with code=" + eventCode); } pricePlan.setEventCode(eventCode); } else { throw new BusinessException("Empty chargeCode in line=" + rowIndex + ", code=" + eventCode); } // Seller if (!StringUtils.isBlank(sellerCode)) { qb = new QueryBuilder(Seller.class, "p"); qb.addCriterion("code", "=", sellerCode, false); qb.addCriterionEntity("provider", provider); @SuppressWarnings("unchecked") List<Seller> sellers = qb.getQuery(em).getResultList(); Seller seller = null; if (sellers == null || sellers.size() == 0) { throw new BusinessException("Invalid seller in line=" + rowIndex + ", code=" + sellerCode); } seller = sellers.get(0); pricePlan.setSeller(seller); } else { pricePlan.setSeller(null); } // Country if (!StringUtils.isBlank(countryCode)) { qb = new QueryBuilder(TradingCountry.class, "p"); qb.addCriterion("p.country.countryCode", "=", countryCode, false); qb.addCriterionEntity("provider", provider); @SuppressWarnings("unchecked") List<TradingCountry> countries = qb.getQuery(em).getResultList(); TradingCountry tradingCountry = null; if (countries == null || countries.size() == 0) { throw new BusinessException("Invalid country in line=" + rowIndex + ", code=" + countryCode); } tradingCountry = countries.get(0); pricePlan.setTradingCountry(tradingCountry); } else { pricePlan.setTradingCountry(null); } // Currency if (!StringUtils.isBlank(currencyCode)) { qb = new QueryBuilder(TradingCurrency.class, "p"); qb.addCriterion("p.currency.currencyCode", "=", currencyCode, false); qb.addCriterionEntity("provider", provider); @SuppressWarnings("unchecked") List<TradingCurrency> currencies = qb.getQuery(em).getResultList(); TradingCurrency tradingCurrency = null; if (currencies == null || currencies.size() == 0) { throw new BusinessException("Invalid currency in line=" + rowIndex + ", code=" + countryCode); } tradingCurrency = currencies.get(0); pricePlan.setTradingCurrency(tradingCurrency); } else { pricePlan.setTradingCurrency(null); } if (!StringUtils.isBlank(pricePlanCode)) { pricePlan.setCode(pricePlanCode); } else { throw new BusinessException("Invalid priceplan code in line=" + rowIndex + ", code=" + offerCode); } if (!StringUtils.isBlank(pricePlanDescription)) { pricePlan.setDescription(pricePlanDescription); } else { pricePlan.setDescription(pricePlanCode); } // OfferCode if (!StringUtils.isBlank(offerCode)) { qb = new QueryBuilder(OfferTemplate.class, "p"); qb.addCriterion("code", "=", offerCode, false); qb.addCriterionEntity("provider", provider); @SuppressWarnings("unchecked") List<OfferTemplate> offers = qb.getQuery(em).getResultList(); OfferTemplate offer = null; if (offers == null || offers.size() == 0) { throw new BusinessException("Invalid offer code in line=" + rowIndex + ", code=" + offerCode); } offer = offers.get(0); pricePlan.setOfferTemplate(offer); } else { pricePlan.setOfferTemplate(null); } if (!StringUtils.isBlank(validityCalendarCode)) { qb = new QueryBuilder(Calendar.class, "p"); qb.addCriterion("code", "=", validityCalendarCode, false); qb.addCriterionEntity("provider", provider); @SuppressWarnings("unchecked") List<Calendar> calendars = qb.getQuery(em).getResultList(); Calendar calendar = null; if (calendars == null || calendars.size() == 0) { throw new BusinessException( "Invalid calendars code in line=" + rowIndex + ", code=" + validityCalendarCode); } calendar = calendars.get(0); pricePlan.setValidityCalendar(calendar); } else { pricePlan.setValidityCalendar(null); } // Priority if (!StringUtils.isBlank(priority)) { try { pricePlan.setPriority(Integer.parseInt(priority)); } catch (Exception e) { throw new BusinessException("Invalid priority in line=" + rowIndex + ", priority=" + priority); } } else { pricePlan.setPriority(1); } // AmountWOTax if (!StringUtils.isBlank(amountWOTax)) { try { pricePlan.setAmountWithoutTax(new BigDecimal(amountWOTax)); } catch (Exception e) { throw new BusinessException( "Invalid amount wo tax in line=" + rowIndex + ", amountWOTax=" + amountWOTax); } } else { throw new BusinessException("Amount wo tax in line=" + rowIndex + " should not be empty"); } // AmountWithTax if (!StringUtils.isBlank(amountWithTax)) { try { pricePlan.setAmountWithTax(new BigDecimal(amountWithTax)); } catch (Exception e) { throw new BusinessException( "Invalid amount wo tax in line=" + rowIndex + ", amountWithTax=" + amountWithTax); } } else { pricePlan.setAmountWithTax(null); } if (!StringUtils.isBlank(amountWOTaxEL)) { pricePlan.setAmountWithoutTaxEL(amountWOTaxEL); } else { pricePlan.setAmountWithoutTaxEL(null); } if (!StringUtils.isBlank(amountWithTaxEL)) { pricePlan.setAmountWithTaxEL(amountWithTaxEL); } else { pricePlan.setAmountWithTaxEL(null); } // minQuantity if (!StringUtils.isBlank(minQuantity)) { try { pricePlan.setMinQuantity(new BigDecimal(minQuantity)); } catch (Exception e) { throw new BusinessException( "Invalid minQuantity in line=" + rowIndex + ", minQuantity=" + minQuantity); } } else { pricePlan.setMinQuantity(null); } // maxQuantity if (!StringUtils.isBlank(maxQuantity)) { try { pricePlan.setMaxQuantity(new BigDecimal(maxSubAge)); } catch (Exception e) { throw new BusinessException( "Invalid maxQuantity in line=" + rowIndex + ", maxQuantity=" + maxQuantity); } } else { pricePlan.setMaxQuantity(null); } // Criteria1 if (!StringUtils.isBlank(criteria1)) { try { pricePlan.setCriteria1Value(criteria1); } catch (Exception e) { throw new BusinessException("Invalid criteria1 in line=" + rowIndex + ", criteria1=" + criteria1); } } else { pricePlan.setCriteria1Value(null); } // Criteria2 if (!StringUtils.isBlank(criteria2)) { try { pricePlan.setCriteria2Value(criteria2); } catch (Exception e) { throw new BusinessException("Invalid criteria2 in line=" + rowIndex + ", criteria2=" + criteria2); } } else { pricePlan.setCriteria2Value(null); } // Criteria3 if (!StringUtils.isBlank(criteria3)) { try { pricePlan.setCriteria3Value(criteria3); } catch (Exception e) { throw new BusinessException("Invalid criteria3 in line=" + rowIndex + ", criteria3=" + criteria3); } } else { pricePlan.setCriteria3Value(null); } // CriteriaEL if (!StringUtils.isBlank(criteriaEL)) { try { pricePlan.setCriteriaEL(criteriaEL); ; } catch (Exception e) { throw new BusinessException( "Invalid criteriaEL in line=" + rowIndex + ", criteriaEL=" + criteriaEL); } } else { pricePlan.setCriteriaEL(null); } // minSubAge if (!StringUtils.isBlank(minSubAge)) { try { pricePlan.setMinSubscriptionAgeInMonth(Long.parseLong(minSubAge)); } catch (Exception e) { throw new BusinessException("Invalid minSubAge in line=" + rowIndex + ", minSubAge=" + minSubAge); } } else { pricePlan.setMinSubscriptionAgeInMonth(0L); } // maxSubAge if (!StringUtils.isBlank(maxSubAge)) { try { pricePlan.setMaxSubscriptionAgeInMonth(Long.parseLong(maxSubAge)); } catch (Exception e) { throw new BusinessException("Invalid maxSubAge in line=" + rowIndex + ", maxSubAge=" + maxSubAge); } } else { pricePlan.setMaxSubscriptionAgeInMonth(9999L); } if (pricePlan.getId() == null) { create(pricePlan, user); } else { pricePlan.updateAudit(user); updateNoCheck(pricePlan); } }