Example usage for org.apache.poi.hssf.usermodel HSSFRow getRowNum

List of usage examples for org.apache.poi.hssf.usermodel HSSFRow getRowNum

Introduction

In this page you can find the example usage for org.apache.poi.hssf.usermodel HSSFRow getRowNum.

Prototype

@Override
public int getRowNum() 

Source Link

Document

get row number this row represents

Usage

From source file:com.verticon.treatment.poi.handlers.NamingImportHandler.java

License:Open Source License

static String getStringValue(HSSFRow row, int index) throws Exception {
    String result = null;/*  w w w.j  a  va 2s  .co m*/

    if (index != -1) {

        HSSFCell cellContents = row.getCell(index);
        if (cellContents != null) {
            switch (cellContents.getCellType()) {
            case HSSFCell.CELL_TYPE_STRING:
                result = cellContents.getStringCellValue();
                break;

            default:
                throw new Exception(
                        "The string value in a critical spreadsheet cell has the wrong data type. Please make sure your spreadsheet column number "
                                + index + " is set to the string datatype. Row: " + row.getRowNum()
                                + " Column Index: " + index);

            }

        }

    }
    return result;
}

From source file:com.verticon.treatment.poi.handlers.PersonProcreator.java

License:Open Source License

@Override
/*//from  w  w w  .  j a v a 2 s . c o m
 * (non-Javadoc)
 * 
 * @see
 * com.verticon.treatment.poi.importWizards.Procreator#process(com.verticon
 * .treatment.Program, org.apache.poi.hssf.usermodel.HSSFRow,
 * org.eclipse.emf.ecore.EObject, boolean,
 * org.eclipse.emf.edit.domain.EditingDomain,
 * org.eclipse.emf.common.command.CompoundCommand)
 */
public void process(Program program, HSSFRow row, EObject parent, boolean parentWasCreated,
        EditingDomain editingDomain, CompoundCommand compoundCommand) throws MissingCriticalDataException {

    String account = getAccount(row);

    Person person = cachedInstance(account);

    boolean personWasCreated = false;
    // Program is the container for the Person.
    if (person == null) {
        person = getPersonInProgram(program, account);

        if (person != null) {// person is in the program
            System.out.printf("Row=%s person %s is already in Program.%n", row.getRowNum(), account);
            // logger.info(bundleMarker,"Row={} person {} is already in Fair.",
            // row
            // .getRowNum(), personName);

        } else {// Person is not in the program, Create it.
            person = newInstance(account, program, editingDomain, compoundCommand);
            personWasCreated = true;

        }
    } else {
        System.out.printf("Row=%s person %s is already created.%n", row.getRowNum(), account);
        // logger.info(bundleMarker,"Row={} found previously created Person {}.",
        // row
        // .getRowNum(), personName);
    }

    if (child != null) {
        child.process(program, row, person, personWasCreated, editingDomain, compoundCommand);
    }
}

From source file:com.verticon.treatment.poi.handlers.PoiUtils.java

License:Open Source License

static String getCriticalStringValue(HSSFRow row, EStructuralFeature feature, int index)
        throws MissingCriticalDataException {
    String result = getStringValue(row, feature, index);
    if (result == null || result.trim().length() < 1) {
        throw new MissingCriticalDataException(
                "The data value in a critical spreadsheet cell is empty. Please remove all blank rows and fill in values for all critical cells.",
                index, feature, row.getRowNum());
    }/*  w  ww .ja  va 2  s. c  om*/
    return result;
}

From source file:com.verticon.treatment.poi.handlers.PoiUtils.java

License:Open Source License

static String getStringValue(HSSFRow row, EStructuralFeature feature, int index)
        throws MissingCriticalDataException {
    String result = null;//from   www .  j  a  va2  s. co m

    if (index != -1) {
        try {
            HSSFCell cellContents = row.getCell(index);
            if (cellContents != null) {
                switch (cellContents.getCellType()) {
                case HSSFCell.CELL_TYPE_STRING:
                    result = cellContents.getStringCellValue();
                    break;
                case HSSFCell.CELL_TYPE_NUMERIC:
                    result = Double.toString(cellContents.getNumericCellValue());
                    result = result.replace(".0", "");
                    break;
                default:
                    throw new MissingCriticalDataException(
                            "The string value in a critical spreadsheet cell has the wrong data type (id: "
                                    + cellContents.getCellType()
                                    + "). Please make sure your spreadsheet column number " + index
                                    + " is set to the string datatype.",
                            index, feature, row.getRowNum());

                }

            }
        } catch (RuntimeException e) {
            // just fall through and return a null
        }
    }
    return result;
}

From source file:com.verticon.treatment.poi.handlers.PoiUtils.java

License:Open Source License

static BigDecimal getCriticalDecimalValue(HSSFRow row, EAttribute feature, int index)
        throws MissingCriticalDataException {
    BigDecimal result = getDecimalValue(row, feature, index);
    if (result == null) {
        throw new MissingCriticalDataException(
                "The decimal value in a critical spreadsheet cell is empty. Please remove all blank rows and fill in values for all critical cells.",
                index, feature, row.getRowNum());
    }// w  w w. j a  v a  2  s. co m
    return result;
}

From source file:com.verticon.treatment.poi.handlers.PoiUtils.java

License:Open Source License

public static Date getCriticalDateValue(HSSFRow row, EAttribute feature, int index)
        throws MissingCriticalDataException {
    Date result = getDateValue(row, feature, index);
    if (result == null) {
        throw new MissingCriticalDataException(
                "The date value in a critical spreadsheet cell is empty. Please remove all blank rows and fill in values for all critical cells.",
                index, feature, row.getRowNum());
    }//from w w w . j a  v a2s  . c o  m
    return result;
}

From source file:com.verticon.treatment.poi.handlers.TestEventProcreator.java

License:Open Source License

@Override
public void process(Program program, HSSFRow row, EObject parent, boolean newParent,
        EditingDomain editingDomain, CompoundCommand compoundCommand) throws MissingCriticalDataException {

    Event proposedEvent = buildProposedEvent(row);

    Event eventInCache = cachedInstance(proposedEvent);

    if (eventInCache == null) {
        Event eventInPerson = getEventInPerson((Person) parent, proposedEvent);

        if (eventInPerson != null) {// event is in the program
            System.out.printf("Row=%s event %s is already in the Person %s.%n", row.getRowNum(), eventInPerson,
                    eventInPerson.getPerson());
            // logger.info(bundleMarker,"Row={} person {} is already in Fair.",
            // row
            // .getRowNum(), personName);

        } else {// Event is not in the program, Create it.

            addCommand(parent, proposedEvent, editingDomain, compoundCommand);

        }/*ww w  .jav a2s . c o m*/
    } else {
        System.out.printf("Row=%s event %s is already created.%n", row.getRowNum(), eventInCache);

    }

}

From source file:com.verticon.treatment.poi.handlers.TestEventProcreator.java

License:Open Source License

private String getTestType(HSSFRow row) throws MissingCriticalDataException {
    String value = getCriticalStringValue(row, TreatmentPackage.Literals.PERSON__EVENTS, TEST_COL);
    if ((TEST_PBT.equals(value)) || (TEST_UA.equals(value))) {
        return value;
    }/*from   ww  w. j a  v a 2 s  . co  m*/
    throw new MissingCriticalDataException(
            "Unknown value =" + value + " Should be " + TEST_PBT + " or " + TEST_UA, TEST_COL,
            TreatmentPackage.Literals.PERSON__EVENTS, row.getRowNum());
}

From source file:com.verticon.treatment.poi.handlers.TreatmentEventProcreator.java

License:Open Source License

@Override
public void process(Program program, HSSFRow row, EObject parent, boolean newParent,
        EditingDomain editingDomain, CompoundCommand compoundCommand) throws MissingCriticalDataException {

    Treatment proposedEvent = buildProposedTreatmentEvent(row);

    Treatment eventInCache = cachedInstance(proposedEvent);

    if (eventInCache == null) {
        Treatment eventInPerson = (Treatment) getEventInPerson((Person) parent, proposedEvent);

        if (eventInPerson != null) {// event is in the program
            System.out.printf("Row=%s event %s is already in the Person %s.%n", row.getRowNum(), eventInPerson,
                    eventInPerson.getPerson());
            // logger.info(bundleMarker,"Row={} person {} is already in Fair.",
            // row
            // .getRowNum(), personName);

        } else {// Event is not in the program, Create it.

            addCommand(parent, proposedEvent, editingDomain, compoundCommand);

        }/*from   w w w  .  j a  v  a  2 s  . c o  m*/
    } else {
        System.out.printf("Row=%s event %s is already created.%n", row.getRowNum(), eventInCache);

    }

}

From source file:com.verticon.treatment.poi.handlers.TreatmentEventProcreator.java

License:Open Source License

private String getEventType(HSSFRow row) throws MissingCriticalDataException {
    String value = getCriticalStringValue(row, TreatmentPackage.Literals.PERSON__EVENTS, TREATMENT_COL);
    if (TREATMENT_INDV.equals(value) || TREATMENT_GRP.equals(value) || TREATMENT_SELF.equals(value)) {
        return value;
    }//from www .  ja  v a2s.  com
    throw new MissingCriticalDataException("Unknown value =" + value + " Should be " + TREATMENT_INDV + " or "
            + TREATMENT_GRP + " or " + TREATMENT_SELF, TREATMENT_COL, TreatmentPackage.Literals.PERSON__EVENTS,
            row.getRowNum());
}