Example usage for org.apache.poi.xssf.usermodel XSSFSheet getRow

List of usage examples for org.apache.poi.xssf.usermodel XSSFSheet getRow

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFSheet getRow.

Prototype

@Override
public XSSFRow getRow(int rownum) 

Source Link

Document

Returns the logical row ( 0-based).

Usage

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 a va 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 ww  .  j  a  v a 2 s  .c om*/

    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  w  ww  .j a v  a2  s .c o m*/

    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();/*from w  w w .ja  va  2s  . co m*/
    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  ww. j  av 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  v  a2s.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. ja va  2s  .  c  o  m*/
            agentName = row.getCell(8).getStringCellValue();
            uploadSynonyms();
        }
    });
}

From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.ExcelLogic.java

private void addOldHigherTaxonSynonyms(XSSFSheet sheet) {
    logger.info("addOldHigherTaxonSynonyms");

    XSSFRow row = sheet.getRow(3);

    genus = row.getCell(0).getStringCellValue().trim();
    scientificName = genus;/*ww w.j a v a  2  s. com*/
    species = genus;
    author = row.getCell(2).getStringCellValue().trim();
    synonymOf = row.getCell(3).getStringCellValue().trim();
    agentName = "Ida Li";
    theRank = "Genus";

    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();//  www .  j  a v a2  s .co m
        }
    });
}

From source file:se.nrm.dina.dina.inventory.logic.dyntaxa.ExcelLogic.java

private void collectionsToDyntaxa(XSSFSheet sheet) {
    logger.info("collectionsToDyntaxa");

    int rankId = Util.getInstance().getRankId("Species");
    item = (Taxontreedefitem) smtpDao.getEntityByJPQL(
            QueryStringBuilder.getInstance().buildGetTaxonTreeDefItem(TAXON_TREE_DEF_ID, rankId));
    IntStream.range(15, 22).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(3).getStringCellValue().trim();
            source = row.getCell(4).getStringCellValue().trim();
            agentName = row.getCell(5).getStringCellValue().trim();
            comment = row.getCell(6).getStringCellValue().trim();
            parent = genus;/*from   w  w  w  . j av a2 s  .co m*/
            rankOfParent = "Genus";
            strIsManuscript = "no";
            uploadTaxon(rankId);
        }
    });

    IntStream.range(26, 32).filter(n -> sheet.getRow(n) != null).forEach(nbr -> {
        XSSFRow row = sheet.getRow(nbr);
        if (row.getCell(0) != null) {
            scientificName = row.getCell(3).getStringCellValue().trim();
            comment = row.getCell(6).getStringCellValue().trim();
            rankOfParent = "Genus";
            synonymOf = row.getCell(4).getStringCellValue().trim();
            agentName = "Ida Li";

            Taxon synonymOfTaxon = getTaxon(synonymOf, true);
            Taxon theTaxon = getTaxon(scientificName, false);

            theTaxon.setIsAccepted(Boolean.FALSE);
            theTaxon.setRemarks(comment);
            theTaxon.setAcceptedID(synonymOfTaxon);
            theTaxon.setModifiedByAgentID(getAgentFromDB(agentName));
            theTaxon.setTimestampModified(timestamp);

            smtpDao.merge(theTaxon);
        }
    });
}