Package org.jopendocument.dom.spreadsheet

Examples of org.jopendocument.dom.spreadsheet.Sheet


   
    File file = new File(metadataPath);
    SpreadSheet metadata = SpreadSheet.createFromFile(file);
   
    // App
    Sheet sheet = metadata.getSheet("App");
    App app = new App();
    app.setGroupId(getText(sheet, "A2"));
    app.setArtifactId(getText(sheet, "B2"));
    app.setName(getText(sheet, "C2"));
    app.setRestricted(getBoolean(sheet, "D2"));
    app.setDatePattern(getText(sheet, "E2"));
    app.setDateTimePattern(getText(sheet, "F2"));
    app.setTimePattern(getText(sheet, "G2"));
    app.setDb(getText(sheet, "H2"));
    app.setDbUser(getText(sheet, "I2"));
    app.setDbPassword(getText(sheet, "J2"));
    app.setEmailHost(getText(sheet, "K2"));
    app.setEmailId(getText(sheet, "L2"));
    app.setEmailPassword(getText(sheet, "M2"));
    app.setMaxUploadSize(Integer.parseInt(sheet.getCellAt("N2").getTextValue().trim()));
    app.setPageSize(getByte(sheet, "O2"));

    // Properties
    sheet = metadata.getSheet("Properties");
    Property property;
    for (int i = 2; !getText(sheet, "A" + i).equals(""); i++) {
      property = new Property();
      property.setName(sheet.getCellAt("A" + i).getTextValue().trim());
      property.setValue(sheet.getCellAt("B" + i).getTextValue().trim());
      property.setDataType(sheet.getCellAt("C" + i).getTextValue().trim());
      app.addProperty(property);
    }
   
    // Messages
    sheet = metadata.getSheet("Messages");
    Message message;
    for (int i = 2; !getText(sheet, "A" + i).equals(""); i++) {
      message = new Message();
      message.setName(sheet.getCellAt("A" + i).getTextValue().trim());
      message.setMessage(sheet.getCellAt("B" + i).getTextValue().trim());
      app.addMessage(message);
    }

    // Entities
    sheet = metadata.getSheet("Entities");
    BizEntity entity;
    for (int i = 2; !getText(sheet, "A" + i).equals(""); i++) {
      entity = new BizEntity();
      entity.setName(sheet.getCellAt("A" + i).getTextValue().trim());
      entity.setPlural(sheet.getCellAt("B" + i).getTextValue().trim());
      entity.setTableName(sheet.getCellAt("C" + i).getTextValue().trim());
      entity.setTitle(sheet.getCellAt("D" + i).getTextValue().trim());
      // Identifier column is set later
      entity.setOrderBy(sheet.getCellAt("F" + i).getTextValue().trim());
      entity.setCustomView(getBoolean(sheet, "G" + i));
      entity.setCustomEdit(getBoolean(sheet, "H" + i));
      entity.setCustomList(getBoolean(sheet, "I" + i));
      entity.setModule(sheet.getCellAt("J" + i).getTextValue().trim());
      app.addModule(entity.getModule()); // Adds distinct module names
     
      app.addEntity(entity);
    }
   
    // Unique Keys
    sheet = metadata.getSheet("UniqueKeys");
    UniqueKey uniqueKey;
    for (int i = 2; !getText(sheet, "A" + i).equals(""); i++) {
     
      uniqueKey = new UniqueKey();
      entity = app.getEntity(sheet.getCellAt("A" + i).getTextValue().trim());
      entity.addUniqueKey(uniqueKey);
     
      uniqueKey.setColumns(getText(sheet, "B" + i));
    }

    // Operations
    sheet = metadata.getSheet("Operations");
    Operation operation;
    for (int i = 2; !getText(sheet, "A" + i).equals(""); i++) {
     
      operation = new Operation();
      entity = app.getEntity(sheet.getCellAt("A" + i).getTextValue().trim());
      entity.addOperation(operation);
     
      operation.setName(sheet.getCellAt("B" + i).getTextValue().trim());
      operation.setLabel(sheet.getCellAt("C" + i).getTextValue().trim());
      operation.setVisibleInList(getBoolean(sheet, "D" + i));
    }

    // Attributes
    sheet = metadata.getSheet("Attributes");
    Attribute attribute;
    for (int i = 2; !getText(sheet, "A" + i).equals(""); i++) {
     
      attribute = new Attribute();
      entity = app.getEntity(sheet.getCellAt("A" + i).getTextValue().trim());
      entity.addAttribute(attribute);
     
      attribute.setName(sheet.getCellAt("B" + i).getTextValue().trim());
      attribute.setDataType(sheet.getCellAt("C" + i).getTextValue().trim());
      attribute.setDefaultValue(getText(sheet, "D" + i));
      attribute.setNullable(getBoolean(sheet, "E" + i));
      attribute.setUnigue(getBoolean(sheet, "F" + i));
      attribute.setPattern(sheet.getCellAt("G" + i).getTextValue().trim());
      attribute.setMin(getBigInteger(sheet, "H" + i));
      attribute.setMax(getBigInteger(sheet, "I" + i));
      attribute.setRelatedEntity(app.getEntity(sheet.getCellAt("J" + i).getTextValue().trim()));
      attribute.setFetchType(sheet.getCellAt("K" + i).getTextValue().trim());
      attribute.setCascadeType(sheet.getCellAt("L" + i).getTextValue().trim());
      attribute.setMappedBy(sheet.getCellAt("M" + i).getTextValue().trim());
      attribute.setOrderBy(sheet.getCellAt("N" + i).getTextValue().trim());
      attribute.setVisible(getBoolean(sheet, "O" + i));
      attribute.setSensitive(getBoolean(sheet, "P" + i));
      attribute.setVisibleInList(getBoolean(sheet, "Q" + i));
      attribute.setSearchable(getBoolean(sheet, "R" + i));
      attribute.setEditable(getBoolean(sheet, "S" + i));
      attribute.setBlankNull(getBoolean(sheet, "T" + i));
      attribute.setComputed(getBoolean(sheet, "U" + i));
      attribute.setLabel(sheet.getCellAt("V" + i).getTextValue().trim());
      attribute.setListLabel(sheet.getCellAt("W" + i).getTextValue());
      attribute.setHelpText(sheet.getCellAt("X" + i).getTextValue().trim());
      attribute.setYearRange(sheet.getCellAt("Y" + i).getTextValue().trim());
      attribute.setRows(getByte(sheet, "Z" + i));
      attribute.setCols(getByte(sheet, "AA" + i));
      attribute.setColumnName(sheet.getCellAt("AB" + i).getTextValue().trim());
     
      if (attribute.getRelatedEntity() != null &&
        attribute.getDataType().equals("ManyToOneSelect") &&
         (attribute.getEditable() || attribute.getSearchable())) {
        entity.addSelectableEntity(attribute.getRelatedEntity());
        if (attribute.getEditable())
          entity.addSelectableEditableEntity(attribute.getRelatedEntity());
        if (attribute.getSearchable())
          entity.addSelectableSearchableEntity(attribute.getRelatedEntity());
      }
       
    }
   
    // Set identifier column of entities
    sheet = metadata.getSheet("Entities");
    for (int i = 2; !getText(sheet, "A" + i).equals(""); i++) {
      String identifierColumn = sheet.getCellAt("E" + i).getTextValue().trim();
      if (!identifierColumn.equals("")) {
        entity = app.getEntity(sheet.getCellAt("A" + i).getTextValue().trim());
        attribute = entity.getAttribute(identifierColumn);
        entity.setIdentifierColumn(attribute);
      }
    }
   
    // Set select options of entities
    sheet = metadata.getSheet("SelOptions");
    SelOption selOption;
    for (int i = 2; !getText(sheet, "A" + i).equals(""); i++) {
     
      selOption = new SelOption();
      entity = app.getEntity(sheet.getCellAt("A" + i).getTextValue().trim());
      attribute = entity.getAttribute(sheet.getCellAt("B" + i).getTextValue().trim());
      attribute.addSelOption(selOption);

      selOption.setValue(sheet.getCellAt("C" + i).getTextValue().trim());
      selOption.setLabel(sheet.getCellAt("D" + i).getTextValue().trim());
    }
   
    App.setApp(app);
  }
View Full Code Here


        String pathname = home + "/Dropbox/Plot/plotfiles/" + basename + ".ods";

        // Load the file.
        File file = new File( pathname );
        final Sheet sheet = SpreadSheet.createFromFile(file).getSheet(0);

        String first = sheet.getCellAt(0,0).getValue().toString();
        int technicalColumn=0;
        for ( int index=1;index< 100; index++ ) {
            String tech = sheet.getCellAt(index,0).getValue().toString();
            if ( tech.equals("Technical")) {
                technicalColumn = index;
                break;
            }
            if (tech.isEmpty())
            {
                break;
            }
        }
        Integer rows = sheet.getRowCount();
        Integer columns = sheet.getColumnCount();

//        System.out.println( "First: " + first +
//                ".  Rows: "+ rows+
//                ".  Columns: "+ columns+
//                ".  Technical starts with column "+technicalColumn);

        int eventColumn=0;
        for (int index=1; index< rows; index++ ) {
            String sessionName = sheet.getCellAt( eventColumn, index).getValue().toString();
            if ( null==sessionName || sessionName.equals("") ) {
                break;
            }
            Session session = new Session( sessionName );

//            System.out.print( "Session: " + sessionName + ".  ");

            for (int column=technicalColumn; column < columns; column++) {
                Object contents = sheet.getCellAt( column, index ).getValue();
                if (null == contents) {
                    break;
                }
                String requirement = contents.toString();
View Full Code Here

        // Load the file.
        File file = new File( pathname );


//        System.out.println("Got file");
        final Sheet sheet = SpreadSheet.createFromFile(file).getSheet(0);
//        System.out.println("Got spreadsheet");

        String requirementsTitle = sheet.getCellAt(0,0).getValue().toString();
        if ( !requirementsTitle.equals( "Requirement")) {
            throw new ConfigurationException(
                    "Expected first column of inference data to be named \"Requirement\". ");
        }

        String impliesTitle = sheet.getCellAt(1,0).getValue().toString();
        if ( !impliesTitle.equals( "Implies")) {
            throw new ConfigurationException(
                    "Expected second column of inference data to be named \"Implies\". ");
        }

        Integer rows = sheet.getRowCount();
        Integer columns = sheet.getColumnCount();

//        System.out.println( "Rows: "+ rows+
//                ".  Columns: "+ columns );

        int requirementColumn=0;
        int impliesColumn=1;
        for (int index=1; index< rows; index++ ) {
            String requirement = sheet.getCellAt( requirementColumn, index).getValue().toString();
            if ( null==requirement || requirement.equals("") ) {
                break;
            }
            String implication = sheet.getCellAt( impliesColumn, index).getValue().toString();
            if ( null==implication || implication.equals("") ) {
                break;
            }
            Inference.Add(requirement,implication);
//            System.out.println(requirement+"/"+implication);
View Full Code Here

        this.dataContext = dataContext;
        output = parse();
    }

    private File parse() {
        Sheet sheet = null;
        try {
            sheet = SpreadSheet.createFromFile(source).getSheet(0);
        } catch (IOException e) {
            e.printStackTrace();
        }
        for (int row = 0; row < sheet.getRowCount(); row++)
            for (int column = 0; column < sheet.getColumnCount(); column++) {
                String value = sheet.getValueAt(column, row).toString();
                if (value != "" && value.charAt(0) == '&') {
                    value = value.substring(1);
                    value += ";";
                    try {
                        ExpressionTree eTree = new ExpressionTree(value);
                        Operation op = new Operation(eTree, dataContext);
                        sheet.getCellAt(column, row).setValue(op.getAnswer());
                    } catch (Exception e) {
                        sheet.getCellAt(column, row).setValue("#ERROR");
                    }
                }
            }
        File tempFile = new File(tempOutputPath);
        tempFile.deleteOnExit();
        try {
            OOUtils.open(sheet.getSpreadSheet().saveAs(tempFile));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
View Full Code Here

TOP

Related Classes of org.jopendocument.dom.spreadsheet.Sheet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.