List of usage examples for org.apache.poi.xssf.usermodel XSSFSheet getLastRowNum
@Override public int getLastRowNum()
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.DyntaxaDumpLogic.java
public void uploadSpeciesOnGenus() { logger.info("uploadSubgenus - excel file path : {}", EXCEL_FILE_PATH); List<Taxon> list = new ArrayList(); initBaseData();/*from w ww .j a va 2 s .co m*/ speciesTreeDefItem = initData(RANK_SPECIES_ID); XSSFSheet sheet = getExcelSheet(); int rowEndNumber = sheet.getLastRowNum(); IntStream.range(1, rowEndNumber + 1).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); String theRank = row.getCell(1).getStringCellValue(); if (theRank.equals("Genus") || theRank.equals("Subgenus")) { currentRankId = getRankId(theRank); if (currentRankId == RANK_GENUS_ID) { taxonName = row.getCell(2).getStringCellValue().trim(); } } else if (theRank.equals("Species")) { if (currentRankId == RANK_GENUS_ID) { if (genusTaxon == null || !genusTaxon.getFullName().equals(taxonName)) { genusTaxon = getTaxon(taxonName, RANK_GENUS_ID); } list.add(createTaxon(row, genusTaxon, RANK_SPECIES_ID, speciesTreeDefItem)); if (list.size() % 1000 == 0) { smtpDao.bacthCreate(list); list.clear(); } } } }); logger.info("list size : {}", list.size()); if (!list.isEmpty()) { smtpDao.bacthCreate(list); } logger.info("Number of rows : {}", rowEndNumber); }
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.DyntaxaDumpLogic.java
public void uploadSynonmys() { logger.info("uploadSubgenus - excel file path : {}", EXCEL_FILE_PATH); List<Taxon> list = new ArrayList(); initData();//from w w w .j ava 2 s . c om XSSFSheet sheet = getExcelSheet(); int rowEndNumber = sheet.getLastRowNum(); IntStream.range(1, rowEndNumber + 1).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); cell = row.getCell(8); if (cell != null) { synonmys = cell.getStringCellValue().trim(); if (!synonmys.isEmpty()) { rankId = getRankId(row.getCell(1).getStringCellValue().trim()); if (rankId < 220) { taxonName = row.getCell(2).getStringCellValue().trim(); List<String> synomyList = new ArrayList<>(); if (synonmys.contains(";")) { synomyList = Arrays.asList(StringUtils.split(synonmys, ";")); } else { synomyList.add(synonmys.trim()); } synomyList.stream().forEach(s -> { if (theTaxon == null || !theTaxon.getFullName().equals(taxonName)) { theTaxon = getTaxon(taxonName, rankId); } list.add(createSynonmyTaxon(s)); if (list.size() % 1000 == 0) { smtpDao.bacthCreate(list); list.clear(); } }); } } } }); logger.info("list size : {}", list.size()); if (!list.isEmpty()) { smtpDao.bacthCreate(list); } logger.info("Number of rows : {}", rowEndNumber); }
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.DyntaxaDumpLogic.java
public void uploadSpeciesSynonmys1() { logger.info("uploadSubgenus - excel file path : {}", EXCEL_FILE_PATH); List<Taxon> list = new ArrayList(); initData();/*from w w w . j a v a 2 s . c o m*/ XSSFSheet sheet = getExcelSheet(); int rowEndNumber = sheet.getLastRowNum(); IntStream.range(1, 24007).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); cell = row.getCell(8); if (cell != null) { synonmys = cell.getStringCellValue().trim(); if (!synonmys.isEmpty()) { rankId = getRankId(row.getCell(1).getStringCellValue().trim()); if (rankId == 220) { taxonName = row.getCell(2).getStringCellValue().trim(); List<String> synomyList = new ArrayList<>(); if (synonmys.contains(";")) { synomyList = Arrays.asList(StringUtils.split(synonmys, ";")); } else { synomyList.add(synonmys.trim()); } synomyList.stream().forEach(s -> { if (theTaxon == null || !theTaxon.getFullName().equals(taxonName)) { theTaxon = getTaxon(taxonName, rankId); } list.add(createSynonmyTaxon(s)); if (list.size() % 1000 == 0) { smtpDao.bacthCreate(list); list.clear(); } }); } } } }); logger.info("list size : {}", list.size()); if (!list.isEmpty()) { smtpDao.bacthCreate(list); } logger.info("Number of rows : {}", rowEndNumber); }
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.DyntaxaDumpLogic.java
public void uploadSpeciesSynonmys() { logger.info("uploadSubgenus - excel file path : {}", EXCEL_FILE_PATH); List<Taxon> list = new ArrayList(); initData();/*from ww w . j a va2 s . com*/ XSSFSheet sheet = getExcelSheet(); int rowEndNumber = sheet.getLastRowNum(); IntStream.range(24007, rowEndNumber + 1).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); cell = row.getCell(8); if (cell != null) { synonmys = cell.getStringCellValue().trim(); if (!synonmys.isEmpty()) { rankId = getRankId(row.getCell(1).getStringCellValue().trim()); if (rankId == 220) { taxonName = row.getCell(2).getStringCellValue().trim(); List<String> synomyList = new ArrayList<>(); if (synonmys.contains(";")) { synomyList = Arrays.asList(StringUtils.split(synonmys, ";")); } else { synomyList.add(synonmys.trim()); } synomyList.stream().forEach(s -> { if (theTaxon == null || !theTaxon.getFullName().equals(taxonName)) { theTaxon = getTaxon(taxonName, rankId); } list.add(createSynonmyTaxon(s)); if (list.size() % 1000 == 0) { smtpDao.bacthCreate(list); list.clear(); } }); } } } }); logger.info("list size : {}", list.size()); if (!list.isEmpty()) { smtpDao.bacthCreate(list); } logger.info("Number of rows : {}", rowEndNumber); }
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.DyntaxaDumpLogic.java
public void uploadSubspeciesSynonmys() { logger.info("uploadSubspeciesSynonmys - excel file path : {}", EXCEL_FILE_PATH); List<Taxon> list = new ArrayList(); initBaseData();//w ww . jav a 2 s. c om subspeciesTreeDefItem = initData(RANK_SUBSPECIES_ID); XSSFSheet sheet = getExcelSheet(); int rowEndNumber = sheet.getLastRowNum(); IntStream.range(1, rowEndNumber + 1).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); cell = row.getCell(8); if (cell != null) { synonmys = cell.getStringCellValue().trim(); if (!synonmys.isEmpty()) { rankId = getRankId(row.getCell(1).getStringCellValue().trim()); if (rankId == 230) { taxonName = row.getCell(2).getStringCellValue().trim(); List<String> synomyList = new ArrayList<>(); if (synonmys.contains(";")) { synomyList = Arrays.asList(StringUtils.split(synonmys, ";")); } else { synomyList.add(synonmys.trim()); } synomyList.stream().forEach(s -> { if (theTaxon == null || !theTaxon.getFullName().equals(taxonName)) { theTaxon = getTaxon(taxonName, rankId); } list.add(createSynonmyTaxon(s)); if (list.size() % 1000 == 0) { smtpDao.bacthCreate(list); list.clear(); } }); } } } }); logger.info("list size : {}", list.size()); if (!list.isEmpty()) { smtpDao.bacthCreate(list); } logger.info("Number of rows : {}", rowEndNumber); }
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.ExcelLogic.java
private void uploadNewHighTaxa(XSSFSheet sheet) { item = (Taxontreedefitem) smtpDao.getEntityByJPQL(QueryStringBuilder.getInstance() .buildGetTaxonTreeDefItem(TAXON_TREE_DEF_ID, Util.getInstance().getRankId("Genus"))); int numOfRows = sheet.getLastRowNum(); IntStream.range(3, numOfRows + 1).forEach(nbr -> { uploadHighTaxon(sheet.getRow(nbr)); });//from w w w.j a v a 2 s. c o m }
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.ExcelLogic.java
private void uploadNewSpecies(XSSFSheet sheet) { int rankId = Util.getInstance().getRankId("Species"); item = (Taxontreedefitem) smtpDao.getEntityByJPQL( QueryStringBuilder.getInstance().buildGetTaxonTreeDefItem(TAXON_TREE_DEF_ID, rankId)); int numOfRows = sheet.getLastRowNum() + 1; IntStream.range(3, numOfRows).filter(n -> sheet.getRow(n) != null).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); if (row.getCell(0) != null && !row.getCell(0).getStringCellValue().isEmpty()) { genus = row.getCell(0).getStringCellValue(); species = row.getCell(1).getStringCellValue(); if (row.getCell(2) != null) { author = row.getCell(2).getStringCellValue(); }// w w w . ja va 2s . c o m scientificName = row.getCell(3).getStringCellValue(); source = row.getCell(4).getStringCellValue(); parent = row.getCell(5).getStringCellValue(); rankOfParent = row.getCell(6).getStringCellValue(); agentName = row.getCell(7).getStringCellValue(); strIsManuscript = row.getCell(9).getStringCellValue(); if (row.getCell(10) != null) { comment = row.getCell(10).getStringCellValue(); } uploadTaxon(rankId); } }); }
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.ExcelLogic.java
private void uploadNewSynonyms(XSSFSheet sheet) { int numOfRows = sheet.getLastRowNum(); theRank = "Species"; IntStream.range(4, numOfRows + 1).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); if (row.getCell(0) != null) { genus = row.getCell(0).getStringCellValue().trim(); species = row.getCell(1).getStringCellValue().trim(); author = row.getCell(2).getStringCellValue().trim(); scientificName = row.getCell(5).getStringCellValue().trim(); synonymOf = row.getCell(6).getStringCellValue().trim(); source = row.getCell(7).getStringCellValue(); if (source.length() > 64) { source = StringUtils.substring(source, 0, 63); }/*from w w w . j ava 2 s.co m*/ agentName = row.getCell(8).getStringCellValue(); uploadSynonyms(); } }); }
From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.ExcelLogic.java
public void oldSpeciesSynonyms(XSSFSheet sheet) { logger.info("oldSpeciesSynonyms"); theRank = "Species"; int numOfRows = sheet.getLastRowNum(); IntStream.range(3, numOfRows + 1).filter(n -> sheet.getRow(n) != null).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); if (row.getCell(0) != null) { genus = row.getCell(0).getStringCellValue().trim(); species = row.getCell(1).getStringCellValue().trim(); author = row.getCell(2).getStringCellValue().trim(); scientificName = row.getCell(5).getStringCellValue().trim(); synonymOf = row.getCell(6).getStringCellValue().trim(); source = row.getCell(7).getStringCellValue().trim(); agentName = row.getCell(8).getStringCellValue().trim(); uploadSynonyms();//from ww w .ja v a 2s .c om } }); }
From source file:se.nrm.dina.dyntaxa.dump.logic.ExcelReader.java
public void readNewTaxonExcel() { try (FileInputStream file = new FileInputStream(new File(NEW_TAXAN_EXCEL_FILE_PATH))) { XSSFWorkbook workbook = new XSSFWorkbook(file); XSSFSheet sheet = workbook.getSheetAt(6); int numOfRows = sheet.getLastRowNum(); IntStream.range(3, numOfRows + 1).forEach(nbr -> { XSSFRow row = sheet.getRow(nbr); String scientificName = row.getCell(0).getStringCellValue(); String rank = row.getCell(1).getStringCellValue(); String author = row.getCell(2).getStringCellValue(); String parent = row.getCell(3).getStringCellValue(); String source = row.getCell(4).getStringCellValue(); String agent = row.getCell(5).getStringCellValue(); String isManuscript = row.getCell(7).getStringCellValue(); System.out.println("isManuscript : " + Boolean.valueOf(isManuscript) + isManuscript); if (agent.contains(" ")) { int index = agent.indexOf(" "); System.out.println("last name : " + agent.substring(index + 1)); System.out.println("first name : " + agent.split(" ")[0]); }/*from ww w . ja v a2 s. c o m*/ }); } catch (IOException ex) { logger.error(ex.getMessage()); } }