Package edu.isi.karma.rep

Examples of edu.isi.karma.rep.Row


  public void addKeysAndValues(JSONTokener token, HTable nestedHTable,
      Table nestedTable) throws JSONException {
    if (maxNumLines > 0 && numObjects >= maxNumLines)
      return;

    Row nestedRow = null;
    if (nestedTable != null) {
      nestedRow = nestedTable.addRow(factory);
      numObjects++;
    }
    // if(maxNumLines > 0 && numObjects >= maxNumLines)
View Full Code Here


  public void addListElement(Object listValue, HTable headers,
      Table dataTable) throws JSONException {
    if (listValue instanceof JSONObject) {
      if (maxNumLines <= 0 || numObjects < maxNumLines) {
        Row row = dataTable.addRow(factory);
        numObjects++;

        JSONObject o = (JSONObject) listValue;
        Iterator<String> it = getSortedKeysIterator(o);
        while (it.hasNext()) {
          String key = it.next();
          addObjectElement(key, o.get(key), headers, row);
        }
      }
    } else if (isPrimitiveValue(listValue)) {
      HNode hNode = addHNode(headers, HTable.VALUES_COLUMN, DataStructure.PRIMITIVE, factory, worksheet);
      String hNodeId = hNode.getId();
      Row row = dataTable.addRow(factory);
      numObjects++;
      // TODO, conserve the types of the primitive types.
      String value = "";
      if (listValue instanceof String || listValue instanceof Boolean) {
        value = (String) listValue;
      } else if (listValue instanceof Double) {
        value = Double.toString((Double) listValue);
      } else if (listValue instanceof Integer) {
        value = Integer.toString((Integer) listValue);
      } else if (listValue instanceof Long) {
        value = Long.toString((Long) listValue);
      } else {
        // Pedro 2012/09/14
        logger.error("Unexpected value in JSON array:"
            + listValue.toString());
      }

      row.setValue(hNodeId, value, factory);
    } else if (listValue instanceof JSONArray) {
      if (maxNumLines <= 0 || numObjects < maxNumLines) {
        HNode hNode = addHNode(headers, "nested array", DataStructure.COLLECTION, factory, worksheet);
        String hNodeId = hNode.getId();
        Row row = dataTable.addRow(factory);
        numObjects++;
        if (maxNumLines > 0 && numObjects >= maxNumLines)
          return;
        HTable nestedHTable = addNestedHTable(hNode,
            "nested array values", row);
        Table nestedTable = row.getNode(hNodeId).getNestedTable();
        JSONArray a = (JSONArray) listValue;
        for (int i = 0; i < a.length(); i++) {
          addListElement(a.get(i), nestedHTable, nestedTable);
        }
      }
View Full Code Here

        token.back();
        HNode hNode = addHNode(headers, HTable.VALUES_COLUMN, DataStructure.PRIMITIVE, factory, worksheet);
        String hNodeId = hNode == null ? null : hNode.getId();
        String value = token.nextValue().toString();
        if (hNodeId != null) {
          Row row = dataTable.addRow(factory);
          numObjects++;
          row.setValue(hNodeId, value, factory);
        }
      }
      else if (c == '{') {
        if (maxNumLines <= 0 || numObjects < maxNumLines) {
          if (headers != null && dataTable != null)
            numObjects++;
          addKeysAndValues(token, headers, dataTable);
        }
      }
      else if (c == '[') {
        if (maxNumLines <= 0 || numObjects < maxNumLines) {
          HNode hNode = addHNode(headers, "nested array", DataStructure.COLLECTION, factory, worksheet);
          String hNodeId = hNode == null ? null : hNode.getId();
          if (hNodeId != null) {
            Row row = dataTable.addRow(factory);
            numObjects++;
            if (maxNumLines > 0 && numObjects >= maxNumLines)
              return;
            HTable nestedHTable = addNestedHTable(hNode,
                "nested array values", row);
            Table nestedTable = row.getNode(hNodeId).getNestedTable();
            addListElement(token, nestedHTable, nestedTable);
          }
          else
            addListElement(token, null, null);
        }
View Full Code Here

        }
      }
      int size = tablesToCross.size();
      int enumeration[] = new int[size + 1];
      while(enumeration[size] != 1) {
        Row r = nestedTable.addRow(factory);
        for (int i = 0; i < tablesToCross.size(); i++) {
          Row nestedRow = tablesToCross.get(i).get(enumeration[i]);
          HNode hnode = factory.getHNode(nestedRow.getBelongsToTable().getNestedTableInNode().getHNodeId());
          CloneTableUtils.cloneDataTableExistingRow(nestedRow, r, nestedTable, hnode.getNestedTable(), newht, childHNodes, factory, mapping, selection);
        }
        enumeration[0]++;
        for (int i = 0; i < tablesToCross.size(); i++) {
          if (enumeration[i] == tablesToCross.get(i).size()) {
View Full Code Here

       
      }
     
      /** Add the data **/
          Table dataTable = wk.getDataTable();
          Row row = dataTable.addRow(factory);
          for(int i=0; i<rowValues.size(); i++) {
            row.setValue(headersList.get(i), rowValues.get(i), factory);
          }
     
      counter++;
    }
   
View Full Code Here

      List<String> hNodeIdList, edu.isi.karma.rep.Table dataTable) {
   
    for (List<String> rowValues : tableValues) {
      if (rowValues == null || rowValues.size() == 0)
        continue;
      Row row = dataTable.addRow(factory);
      for (int i = 0; i < rowValues.size(); i++)
        row.setValue(hNodeIdList.get(i), rowValues.get(i), factory);
    }
   
  }
View Full Code Here

          continue;
        }
       
        addedRowsCount ++;
       
        Row row = null;
        if (addedRowsCount <= rowsCount)
          row = dataTable.getRows(addedRowsCount - 1, 1, sel).get(0);
        else
          row = dataTable.addRow(factory);
       
//        logger.debug(hNodeIdList.size());
        for (int j = 0; j < hNodeIdList.size(); j++) {
          // the first column in the table is the url column which should not be added to the table
//          logger.debug("j:" + j);
//          logger.debug(hNodeIdList.get(j));
//          logger.debug(rowValues.get(j + 1));
          row.setValue(hNodeIdList.get(j), rowValues.get(j), factory);
        }
       
        for (String id: oldHNodeIdList) {
          row.setValue(id, currentRow.get(id).toString(), factory);
        }
       
      }
     
    }
View Full Code Here

        if (rowValues == null || rowValues.length == 0) {
            reader.close();
            return false;
        }

        Row row = dataTable.addRow(fac);
        int size = hNodeIdMap.size();
        if (columnsJson != null)
          size = columnsJson.length();
        for (int i = 0; i < rowValues.length; i++) {
            if (i < size) {
              String hNodeId = hNodeIdMap.get(i);
              if (hNodeId != null)
                row.setValue(hNodeId, rowValues[i], fac);
            } else {
                // TODO Our model does not allow a value to be added to a row
                // without its associated HNode. In CSVs, there could be case
                // where values in rows are greater than number of column names.
                logger.error("More data elements detected in the row than number of headers!");
View Full Code Here

  public void updateSelection(){
    if (this.status == SelectionStatus.UP_TO_DATE)
      return;
    evalColumns.clear();
    for (Entry<Row, Boolean> entry : this.selectedRowsCache.entrySet()) {
      Row key = entry.getKey();
      PythonInterpreter interpreter = new PythonInterpreter();
      try {
        entry.setValue(evaluatePythonExpression(key, getCompiledCode(pythonCode, interpreter), interpreter));
      }catch(IOException e) {
        entry.setValue(false);
View Full Code Here

TOP

Related Classes of edu.isi.karma.rep.Row

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.