Examples of OdfTable


Examples of org.odftoolkit.odfdom.doc.table.OdfTable

            List<OdfTable> tables = odfDoc.getTableList();
            int sheetCount = tables.size();

            boolean hasData = false;
            for (int i = 0; i < sheetCount; i++) {
                OdfTable sheet = tables.get(i);
                int rows = sheet.getRowCount();

                JSONObject sheetRecord = new JSONObject();
                JSONUtilities.safePut(sheetRecord, "name", sheet.getTableName());
                JSONUtilities.safePut(sheetRecord, "rows", rows);
                if (hasData) {
                    JSONUtilities.safePut(sheetRecord, "selected", false);
                } else if (rows > 0) {
                    JSONUtilities.safePut(sheetRecord, "selected", true);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

        List<OdfTable> tables = odfDoc.getTableList();

        int[] sheets = JSONUtilities.getIntArray(options, "sheets");
        for (int sheetIndex : sheets) {
            final OdfTable table = tables.get(sheetIndex);
            final int lastRow = table.getRowCount();

            TableDataReader dataReader = new TableDataReader() {
                int nextRow = 0;
                Map<String, Recon> reconMap = new HashMap<String, Recon>();

                @Override
                public List<Object> getNextRowOfCells() throws IOException {
                    if (nextRow > lastRow) {
                        return null;
                    }

                    List<Object> cells = new ArrayList<Object>();
                    OdfTableRow row = table.getRowByIndex(nextRow++);
                    if (row != null) {
                        int lastCell = row.getCellCount();
                        for (int cellIndex = 0; cellIndex <= lastCell; cellIndex++) {
                            Cell cell = null;

                            OdfTableCell sourceCell = row.getCellByIndex(cellIndex);
                            if (sourceCell != null) {
                                cell = extractCell(sourceCell, reconMap);
                            }
                            cells.add(cell);
                        }
                    }
                    return cells;
                }
            };

            TabularImportingParserBase.readTable(
                    project,
                    metadata,
                    job,
                    dataReader,
                    fileSource + "#" + table.getTableName(),
                    limit,
                    options,
                    exceptions
            );
        }
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

  /* (non-Javadoc)
   * @see org.odftoolkit.odfdom.dom.DefaultElementVisitor#visit(org.odftoolkit.odfdom.dom.element.text.TextTabElement)
   */
  @Override
  public void visit(TableTableElement ele) {
    OdfTable table = OdfTable.getInstance(ele);
    List<OdfTableRow> rowlist = table.getRowList();
    for (int i = 0; i < rowlist.size(); i++) {
      OdfTableRow row = rowlist.get(i);
      for (int j = 0; j < row.getCellCount(); j++) {
        mTextBuilder.append(row.getCellByIndex(j).getDisplayText()).append(TabChar);
      }
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

  //private static Map<String, Pool<Plate<LinkedList<Library>, Library>>> process384PlateInputODS(OdfSpreadsheetDocument oDoc, User u, RequestManager manager, MisoNamingScheme<Library> libraryNamingScheme) throws Exception {
  private static Map<String, PlatePool> process384PlateInputODS(OdfSpreadsheetDocument oDoc, User u, RequestManager manager, MisoNamingScheme<Library> libraryNamingScheme) throws Exception {
    ((RequestManagerAwareNamingScheme) libraryNamingScheme).setRequestManager(manager);

    List<Sample> samples = new ArrayList<Sample>();
    OdfTable oTable = oDoc.getTableList().get(0);

    //process global headers
    OdfTableCell pairedCell = oTable.getCellByPosition("A2");
    boolean paired = false;
    if (pairedCell.getBooleanValue() != null) {
      paired = pairedCell.getBooleanValue();
      log.info("Got paired: " + paired);
    }

    OdfTableCell platformCell = oTable.getCellByPosition("B2");
    PlatformType pt = null;
    if (!"".equals(platformCell.getStringValue())) {
      pt = PlatformType.get(platformCell.getStringValue());
    }
    if (pt == null) {
      throw new InputFormException("Cannot resolve Platform type from: '" + platformCell.getStringValue() + "'");
    }
    else {
      log.info("Got platform type: " + pt.getKey());
    }

    OdfTableCell typeCell = oTable.getCellByPosition("C2");
    LibraryType lt = null;
    if (!"".equals(typeCell.getStringValue())) {
      String[] split = typeCell.getStringValue().split("-");
      String plat = split[0];
      String type = split[1];
      if (platformCell.getStringValue().equals(plat)) {
        lt = manager.getLibraryTypeByDescriptionAndPlatform(type, pt);
      }
      else {
        throw new InputFormException("Selected library type '" + typeCell.getStringValue() + "' doesn't match platform type: '" + platformCell.getStringValue() + "'");
      }
    }
    if (lt == null) {
      throw new InputFormException("Cannot resolve Library type from: '" + typeCell.getStringValue() + "'");
    }
    else {
      log.info("Got library type: " + lt.getDescription());
    }

    OdfTableCell selectionCell = oTable.getCellByPosition("D2");
    LibrarySelectionType ls = null;
    if (!"".equals(selectionCell.getStringValue())) {
      ls = manager.getLibrarySelectionTypeByName(selectionCell.getStringValue());
    }
    if (ls == null) {
      throw new InputFormException("Cannot resolve Library Selection type from: '" + selectionCell.getStringValue() + "'");
    }
    else {
      log.info("Got library selection type: " + ls.getName());
    }

    OdfTableCell strategyCell = oTable.getCellByPosition("E2");
    LibraryStrategyType lst = null;
    if (!"".equals(strategyCell.getStringValue())) {
      lst = manager.getLibraryStrategyTypeByName(strategyCell.getStringValue());
    }
    if (lst == null) {
      throw new InputFormException("Cannot resolve Library Strategy type from: '" + strategyCell.getStringValue() + "'");
    }
    else {
      log.info("Got library strategy type: " + lst.getName());
    }

    OdfTableCell plateBarcodeCell = oTable.getCellByPosition("F2");
    String plateBarcode = null;
    if (!"".equals(plateBarcodeCell.getStringValue())) {
      plateBarcode = plateBarcodeCell.getStringValue();
    }
    if (plateBarcode == null) {
      throw new InputFormException("Cannot resolve plate barcode from: '" + plateBarcodeCell.getStringValue() + "'");
    }
    else {
      log.info("Got plate parcode: " + plateBarcode);
    }

    //process entries
    Simple384WellPlate libraryPlate = null;
    //Map<String, Pool<Plate<LinkedList<Library>, Library>>> pools = new HashMap<String, Pool<Plate<LinkedList<Library>, Library>>>();
    Map<String, PlatePool> pools = new HashMap<String, PlatePool>();
    for (OdfTableRow row : oTable.getRowList()) {
      int ri = row.getRowIndex();
      if (ri > 3) {
        // Ax - plate position
        OdfTableCell platePosCell = oTable.getCellByPosition(0, ri);
        if (!"".equals(platePosCell.getStringValue()) && libraryPlate == null) {
          //plated libraries - process as plate
          libraryPlate = new Simple384WellPlate();
          libraryPlate.setIdentificationBarcode(plateBarcode);
          libraryPlate.setCreationDate(new Date());
        }

        //cell defs
        OdfTableCell sampleAliasCell = oTable.getCellByPosition(1, ri);

        Sample s = null;
        if (!"".equals(sampleAliasCell.getStringValue())) {
          Collection<Sample> ss = manager.listSamplesByAlias(sampleAliasCell.getStringValue());
          if (!ss.isEmpty()) {
            if (ss.size() == 1) {
              s = ss.iterator().next();
              log.info("Got sample: " + s.getAlias());
            }
            else {
              throw new InputFormException("Multiple samples retrieved with this alias: '" + sampleAliasCell.getStringValue() + "'. Cannot process.");
            }
          }
          else {
            throw new InputFormException("No such sample '" + sampleAliasCell.getStringValue() + "'in database. Samples need to be created before using the form input functionality");
          }
        }
        else {
          log.info("Blank sample row found. Ending import.");
          break;
        }

        //sample OK - good to go
        if (s != null) {
          OdfTableCell entityIDCell = oTable.getCellByPosition(2, ri);
          OdfTableCell poolNumberCell = oTable.getCellByPosition(3, ri);
          OdfTableCell sampleQcCell = oTable.getCellByPosition(4, ri);
          //OdfTableCell sampleAmountCell = oTable.getCellByPosition(5, ri);
          //OdfTableCell sampleWaterAmountCell = oTable.getCellByPosition(6, ri);
          OdfTableCell barcodeKitCell = oTable.getCellByPosition(7, ri);
          OdfTableCell barcodeTagsCell = oTable.getCellByPosition(8, ri);
          OdfTableCell libraryQcCell = oTable.getCellByPosition(9, ri);
          OdfTableCell libraryQcInsertSizeCell = oTable.getCellByPosition(10, ri);
          OdfTableCell libraryQcMolarityCell = oTable.getCellByPosition(11, ri);
          OdfTableCell libraryQcPassFailCell = oTable.getCellByPosition(12, ri);
          //OdfTableCell libraryAmountCell = oTable.getCellByPosition(13, ri);
          //OdfTableCell libraryWaterAmountCell = oTable.getCellByPosition(14, ri);
          //OdfTableCell dilutionQcCell = oTable.getCellByPosition(15, ri);
          OdfTableCell dilutionMolarityCell = oTable.getCellByPosition(16, ri);
          //OdfTableCell dilutionAmountCell = oTable.getCellByPosition(17, ri);
          //OdfTableCell dilutionWaterAmountCell = oTable.getCellByPosition(18, ri);
          OdfTableCell poolQcCell = oTable.getCellByPosition(19, ri);
          //OdfTableCell poolAverageInsertSizeCell = oTable.getCellByPosition(20, ri);
          OdfTableCell poolConvertedMolarityCell = oTable.getCellByPosition(21, ri);

          //add pool, if any
          if (!"".equals(poolNumberCell.getStringValue())) {
            if (!pools.containsKey(poolNumberCell.getStringValue())) {
              PlatePool pool = new PlatePool();
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

  private static List<Sample> processSampleInputODS(OdfSpreadsheetDocument oDoc, User u, RequestManager manager, MisoNamingScheme<Library> libraryNamingScheme) throws Exception {
    ((RequestManagerAwareNamingScheme) libraryNamingScheme).setRequestManager(manager);

    List<Sample> samples = new ArrayList<Sample>();
    OdfTable oTable = oDoc.getTableList().get(0);

    //process global headers
    OdfTableCell pairedCell = oTable.getCellByPosition("A2");
    boolean paired;
    if (pairedCell != null && pairedCell.getBooleanValue() != null) {
      paired = pairedCell.getBooleanValue();
      log.info("Got paired: " + paired);
    }
    else {
      throw new InputFormException("'Paired' cell is empty. Please specify TRUE or FALSE.");
    }

    OdfTableCell platformCell = oTable.getCellByPosition("B2");
    PlatformType pt = null;
    if (!"".equals(platformCell.getStringValue())) {
      pt = PlatformType.get(platformCell.getStringValue());
    }
    if (pt == null) {
      throw new InputFormException("Cannot resolve Platform type from: '" + platformCell.getStringValue() + "'");
    }
    else {
      log.info("Got platform type: " + pt.getKey());
    }

    OdfTableCell typeCell = oTable.getCellByPosition("C2");
    LibraryType lt = null;
    if (!"".equals(typeCell.getStringValue())) {
      String[] split = typeCell.getStringValue().split("-");
      String plat = split[0];
      String type = split[1];
      if (platformCell.getStringValue().equals(plat)) {
        lt = manager.getLibraryTypeByDescriptionAndPlatform(type, pt);
      }
      else {
        throw new InputFormException("Selected library type '" + typeCell.getStringValue() + "' doesn't match platform type: '" + platformCell.getStringValue() + "'");
      }
    }
    if (lt == null) {
      throw new InputFormException("Cannot resolve Library type from: '" + typeCell.getStringValue() + "'");
    }
    else {
      log.info("Got library type: " + lt.getDescription());
    }

    OdfTableCell selectionCell = oTable.getCellByPosition("D2");
    LibrarySelectionType ls = null;
    if (!"".equals(selectionCell.getStringValue())) {
      ls = manager.getLibrarySelectionTypeByName(selectionCell.getStringValue());
    }
    if (ls == null) {
      throw new InputFormException("Cannot resolve Library Selection type from: '" + selectionCell.getStringValue() + "'");
    }
    else {
      log.info("Got library selection type: " + ls.getName());
    }

    OdfTableCell strategyCell = oTable.getCellByPosition("E2");
    LibraryStrategyType lst = null;
    if (!"".equals(strategyCell.getStringValue())) {
      lst = manager.getLibraryStrategyTypeByName(strategyCell.getStringValue());
    }
    if (lst == null) {
      throw new InputFormException("Cannot resolve Library Strategy type from: '" + strategyCell.getStringValue() + "'");
    }
    else {
      log.info("Got library strategy type: " + lst.getName());
    }

    //process entries
    Plate<LinkedList<Sample>, Sample> samplePlate = null;
    Map<String, Pool<Dilution>> pools = new HashMap<String, Pool<Dilution>>();
    for (OdfTableRow row : oTable.getRowList()) {
      int ri = row.getRowIndex();
      if (ri > 3) {
        // Ax - plate position
        OdfTableCell platePosCell = oTable.getCellByPosition(0, ri);
        if (!"".equals(platePosCell.getStringValue())) {
          //plated samples - process as plate
          samplePlate = new PlateImpl<Sample>();
        }

        //cell defs
        OdfTableCell sampleAliasCell = oTable.getCellByPosition(2, ri);

        Sample s = null;
        if (!"".equals(sampleAliasCell.getStringValue())) {
          Collection<Sample> ss = manager.listSamplesByAlias(sampleAliasCell.getStringValue());
          if (!ss.isEmpty()) {
            if (ss.size() == 1) {
              s = ss.iterator().next();
              log.info("Got sample: " + s.getAlias());
            }
            else {
              throw new InputFormException("Multiple samples retrieved with this alias: '" + sampleAliasCell.getStringValue() + "'. Cannot process.");
            }
          }
          else {
            throw new InputFormException("No such sample '" + sampleAliasCell.getStringValue() + "'in database. Samples need to be created before using the form input functionality");
          }
        }
        else {
          log.info("Blank sample row found. Ending import.");
          break;
        }

        //sample OK - good to go
        if (s != null) {
          String projectAliasCell = oTable.getCellByPosition(1, ri).getStringValue();
          String poolNumberCell = oTable.getCellByPosition(3, ri).getStringValue();
          String sampleQcCell = oTable.getCellByPosition(4, ri).getStringValue();
          //String sampleAmountCell = oTable.getCellByPosition(5, ri).getStringValue();
          //String sampleWaterAmountCell = oTable.getCellByPosition(6, ri).getStringValue();
          String libraryDescriptionCell = oTable.getCellByPosition(7, ri).getStringValue();
          String barcodeKitCell = oTable.getCellByPosition(8, ri).getStringValue();
          String barcodeTagsCell = oTable.getCellByPosition(9, ri).getStringValue();
          String libraryQcCell = oTable.getCellByPosition(10, ri).getStringValue();
          String libraryQcInsertSizeCell = oTable.getCellByPosition(11, ri).getStringValue();
          String libraryQcMolarityCell = oTable.getCellByPosition(12, ri).getStringValue();
          String libraryQcPassFailCell = oTable.getCellByPosition(13, ri).getStringValue();
          //String libraryAmountCell = oTable.getCellByPosition(14, ri).getStringValue();
          //String libraryWaterAmountCell = oTable.getCellByPosition(15, ri).getStringValue();
          //String dilutionQcCell = oTable.getCellByPosition(16, ri).getStringValue();
          String dilutionMolarityCell = oTable.getCellByPosition(17, ri).getStringValue();
          //String dilutionAmountCell = oTable.getCellByPosition(18, ri).getStringValue();
          //String dilutionWaterAmountCell = oTable.getCellByPosition(19, ri).getStringValue();
          String poolQcCell = oTable.getCellByPosition(20, ri).getStringValue();
          //String poolAverageInsertSizeCell = oTable.getCellByPosition(21, ri).getStringValue().getStringValue();
          String poolConvertedMolarityCell = oTable.getCellByPosition(22, ri).getStringValue();

          //add pool, if any
          processPool(poolNumberCell, poolConvertedMolarityCell, pools);
          processSampleQC(sampleQcCell, s, u, manager);
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

          ctc0.getOdfElement().appendChild(ctcp0);
        }
      }
      */

      OdfTable oTable = oDoc.getTableByName("SamplesTable");

      for (Sample s : samples) {
        OdfTableRow row = oTable.appendRow();

        OdfTableCell cell0 = row.getCellByIndex(0);
        OdfTextParagraph cp0 = new OdfTextParagraph(contentDom);
        cp0.setTextContent(s.getAlias());
        cp0.setProperty(StyleTextPropertiesElement.FontSize, "8pt");
        cell0.getOdfElement().appendChild(cp0);

        OdfTableCell cell1 = row.getCellByIndex(1);
        OdfTextParagraph cp1 = new OdfTextParagraph(contentDom);
        cp1.setTextContent(s.getScientificName());
        cp1.setProperty(StyleTextPropertiesElement.FontSize, "8pt");
        cell1.getOdfElement().appendChild(cp1);

        OdfTableCell cell2 = row.getCellByIndex(2);
        OdfTextParagraph cp2 = new OdfTextParagraph(contentDom);
        cp2.setTextContent(s.getIdentificationBarcode());
        cp2.setProperty(StyleTextPropertiesElement.FontSize, "8pt");
        cell2.getOdfElement().appendChild(cp2);

        OdfTableCell cell3 = row.getCellByIndex(3);
        OdfTextParagraph cp3 = new OdfTextParagraph(contentDom);
        cp3.setTextContent(s.getSampleType());
        cp3.setProperty(StyleTextPropertiesElement.FontSize, "8pt");
        cell3.getOdfElement().appendChild(cp3);
      }

      int count = 0;
      for (OdfTableRow row : oTable.getRowList()) {
        if (count % 2 != 0) {
          for (int i = 0; i < row.getCellCount(); i++) {
            row.getCellByIndex(i).setCellBackgroundColor("#EEEEEE");
          }
        }
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

  }

  public static List<Sample> importSampleDeliveryForm(File inPath) throws Exception {
    List<Sample> samples = new ArrayList<Sample>();
    OdfTextDocument oDoc = (OdfTextDocument) OdfDocument.loadDocument(inPath);
    OdfTable sampleTable = oDoc.getTableList().get(1);

    if (sampleTable != null) {
      DataObjectFactory df = new TgacDataObjectFactory();
      for (OdfTableRow row : sampleTable.getRowList()) {
        if (row.getRowIndex() != 0) {
          TableTableRowElement ttre = row.getOdfElement();

          Sample s = df.getSample();
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

  /* (non-Javadoc)
   * @see org.odftoolkit.odfdom.dom.DefaultElementVisitor#visit(org.odftoolkit.odfdom.dom.element.text.TextTabElement)
   */
  @Override
  public void visit(TableTableElement ele) {
    OdfTable table = OdfTable.getInstance(ele);
    List<OdfTableRow> rowlist = table.getRowList();
    for (int i = 0; i < rowlist.size(); i++) {
      OdfTableRow row = rowlist.get(i);
      for (int j = 0; j < row.getCellCount(); j++) {
        mTextBuilder.append(row.getCellByIndex(j).getDisplayText()).append(TabChar);
      }
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

      addFrameForEmbeddedDoc(contentA, lastPara, "DOCB");
      OdfDocument docB = odtRootDoc.loadSubDocument("DOCB/");
      Assert.assertNotNull(docB);
      Assert.assertNull(odtRootDoc.loadSubDocument("DOCA/DOCB/"));
      docB.newImage(ResourceUtilities.getURI(TEST_PIC_ANOTHER));
      OdfTable table1 = docB.getTableList().get(0);
      table1.setTableName("NewTable");
      updateFrameForEmbeddedDoc(contentA, "./DOCB", "DOCA/DOCB");
      //if user want to save the docA with the side by side embedded document
      //he has to insert it to the sub document of docA and update the xlink:href link
      docA.insertDocument(docB, "DOCB/");
      //save
View Full Code Here

Examples of org.odftoolkit.odfdom.doc.table.OdfTable

      XPath xpath = contentA.getXPath();
      TextPElement lastPara = (TextPElement) xpath.evaluate("//text:p[last()]", contentA, XPathConstants.NODE);
      addFrameForEmbeddedDoc(contentA, lastPara, "./DOCB");
      OdfDocument docB = odtDoc1.loadSubDocument("DOCA/DOCB/");
      docB.newImage(ResourceUtilities.getURI(TEST_PIC_ANOTHER));
      OdfTable table1 = docB.getTableList().get(0);
      table1.setTableName("NewTable");
      Assert.assertNotNull(docB);
      Assert.assertNull(odtDoc1.loadSubDocument("DOCB/"));
      docA.save(TEST_FILE_FOLDER + TEST_FILE_EMBEDDED_INCLUDED_SAVE_OUT);
      OdfDocument testLoad = OdfDocument.loadDocument(TEST_FILE_FOLDER + TEST_FILE_EMBEDDED_INCLUDED_SAVE_OUT);
      OdfFileEntry imageEntry = testLoad.getPackage().getFileEntry(OdfPackage.OdfFile.IMAGE_DIRECTORY.getPath() + SLASH + TEST_PIC);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.