Package edu.isi.karma.rep

Examples of edu.isi.karma.rep.Table


      }

      /**
       * Add the data *
       */
      Table dataTable = getWorksheet().getDataTable();
      for (int i = 1; i < data.size(); i++)
      {
        Row row = dataTable.addRow(getFactory());
        ArrayList<String> rowData = data.get(i);
        for (int j = 0; j < rowData.size(); j++)
        {
          row.setValue(headersList.get(j), rowData.get(j), getFactory());
        }
View Full Code Here


          String[] rowValues = reader.readNext();
          if (rowValues == null || rowValues.length == 0)
            continue;

          // Get the nested table for the node
          Table table = node.getNestedTable();

          // Add the row one by one
          for (int i = 0; i < rowValues.length; i++) {
            String rowVal = rowValues[i];
            if (!rowVal.trim().equals("")) {
              Row row = table.addRow(factory);
              row.setValue(splitValueHNodeId, rowVal,
                  NodeStatus.edited, factory);
            }
          }
          reader.close();
View Full Code Here

    HNode ndid = htable.getHNode(newHNodeId);
    HTable nestedHTable = ndid.getNestedTable();
    if (nestedHTable == null)
      nestedHTable = ndid.addNestedTable("Table for test",
          worksheet, factory);
    Table nestedTable = row.getNode(newHNodeId).getNestedTable();
    Row r = nestedTable.addRow(factory);
    boolean flag = false;
    for (Object key : new TreeSet<Object>(obj.keySet())) {
      Object value = obj.get(key.toString());
      HNode h = nestedHTable.getHNodeFromColumnName(key.toString());
      if ( h == null) {   
        h = nestedHTable.addHNode(key.toString(), type, worksheet, factory);
      }
      outputColumns.add(h.getId());
      //
      if (value instanceof String)
        flag |= addValues(r.getNode(h.getId()), (String)value, factory, nestedTable);
      if (value instanceof JSONObject)
        flag |= addJSONObjectValues((JSONObject)value, worksheet, nestedHTable, factory, r, h.getId());
      if (value instanceof JSONArray)
        flag |= addJSONArrayValues((JSONArray) value, worksheet, nestedHTable, factory,r, h.getId());
    }
    if (!flag)
      nestedTable.removeRow(r);
    return flag;
  }
View Full Code Here

    pythonCode.append("   return True \n");
    Selection sel = new MiniSelection(workspace, worksheet.getId(),
        worksheet.getHeaders().getId(), workspace.getFactory().getNewId("SEL"), null,
        pythonCode.toString(), true);
    assertEquals(sel != null, true);
    Table t = worksheet.getDataTable();
    for (Row r : t.getRows(0, t.getNumRows(), SuperSelectionManager.DEFAULT_SELECTION)) {
      boolean t1 = sel.isSelected(r);
      if (r.getNeighborByColumnName("title", workspace.getFactory()).getValue().asString().equals("Prof"))
        assertTrue(t1);
      else
        assertFalse(t1);
View Full Code Here

      //System.out.println("key: " + hash.get(key));
      ArrayList<String> r = hash.get(key);
      Row lastRow = CloneTableUtils.cloneDataTable(factory.getRow(r.get(0)), newws.getDataTable(), oldws.getHeaders(), newht, keyhnodes, factory, selection);
      for (String rowid : r) {
        Row cur = factory.getRow(rowid);
        Table dataTable = lastRow.getNeighborByColumnName("Values", factory).getNestedTable();
        CloneTableUtils.cloneDataTable(cur, dataTable, oldws.getHeaders(), newValueTable, valuehnodes, factory, selection);
      }
    }
    newWorksheetId = newws.getId();
    return newws;
View Full Code Here

    HTable newValueTable = newht.getHNodeFromColumnName("Values").addNestedTable("Table for values", oldws, factory);
    for (Entry<String, String> entry : CloneTableUtils.cloneHTable(ht, newValueTable, oldws, factory, valuehnodes, selection).entrySet()) {
      outputColumns.add(entry.getValue());
    }
    for (Row parentRow : parentRows) {
      Table t = null;
      for (Node node : parentRow.getNodes()) {
        if (node.hasNestedTable() && node.getNestedTable().getHTableId().compareTo(ht.getId()) == 0) {
          t = node.getNestedTable();
          break;
       
      }
      ArrayList<Row> rows = t.getRows(0, t.getNumRows(), selection);
      Map<String, ArrayList<String>> hash = new TreeMap<String, ArrayList<String>>();
      for (Row row : rows) {
        String hashValue = HashValueManager.getHashValue(row, hnodeIDs);
        ArrayList<String> ids = hash.get(hashValue);
        if (ids == null)
          ids = new ArrayList<String>();
        ids.add(row.getId());
        hash.put(hashValue, ids);
     
     
      for (String key : hash.keySet()) {
        ArrayList<String> r = hash.get(key);
        Node node = parentRow.getNeighbor(newNode.getId());
        Row lastRow = CloneTableUtils.cloneDataTable(factory.getRow(r.get(0)), node.getNestedTable(), ht, newht, keyhnodes, factory, selection);
        for (String rowid : r) {
          Row cur = factory.getRow(rowid);
          Table dataTable = lastRow.getNeighborByColumnName("Values", factory).getNestedTable();
          CloneTableUtils.cloneDataTable(cur, dataTable, ht, newValueTable, valuehnodes, factory, selection);
        }
      }
    }
  }
View Full Code Here

    for (Entry<String, String> entry : CloneTableUtils.cloneHTable(ht, newHT, oldws, factory, hnodes, selection).entrySet()) {
      outputColumns.add(entry.getValue());
    }
    List<Row> resultRows = new ArrayList<Row>();
    for (Row parentRow: parentRows) {
      Table t = null;
      for (Node node : parentRow.getNodes()) {
        if (node.hasNestedTable() && node.getNestedTable().getHTableId().compareTo(ht.getId()) == 0) {
          t = node.getNestedTable();
          break;
       
      }
      Map<String, String> keyMapping = new HashMap<String, String>();
      Map<String, String> HNodeidMapping = new HashMap<String, String>();
      ArrayList<Row> rows = t.getRows(0, t.getNumRows(), selection);
      for (Row row : rows) {
        Node n = row.getNode(key.getId());
        keyMapping.put(HashValueManager.getHashValue(oldws, n.getId(), factory), n.getValue().asString());
      }
      for (String mapkey : keyMapping.keySet()) {
        HNode hn = newHT.getHNodeFromColumnName(keyMapping.get(mapkey).toLowerCase().replace('/', '_'));
        if (hn == null) {
          HNode n = newHT.addHNode(keyMapping.get(mapkey).toLowerCase().replace('/', '_'), HNodeType.Transformation, oldws, factory);
          outputColumns.add(n.getId());
          HTable htt = n.addNestedTable("values", oldws, factory);
          outputColumns.add(htt.addHNode("Values", HNodeType.Transformation, oldws, factory).getId());
          HNodeidMapping.put(keyMapping.get(mapkey), n.getId());
        }
        else
          HNodeidMapping.put(keyMapping.get(mapkey), hn.getId());
      }
      Map<String, ArrayList<String>> hash = new HashMap<String, ArrayList<String>>();
      for (Row row : rows) {
        String hashValue = HashValueManager.getHashValue(row, hnodeIds);
        ArrayList<String> ids = hash.get(hashValue);
        if (ids == null)
          ids = new ArrayList<String>();
        ids.add(row.getId());
        hash.put(hashValue, ids);
        //System.out.println("Hash: " + HashValueManager.getHashValue(row, hnodeIDs));
      }

      for (String hashKey : hash.keySet()) {
        ArrayList<String> r = hash.get(hashKey);
        Node node = parentRow.getNeighbor(newNode.getId());
        Row lastRow = CloneTableUtils.cloneDataTable(factory.getRow(r.get(0)), node.getNestedTable(),
            parentHT, newHT, hnodes, factory, selection);
        for (String rowid : r) {
          Row cur = factory.getRow(rowid);
          String newId = HNodeidMapping.get(cur.getNode(key.getId()).getValue().asString());
          Node newnode = lastRow.getNode(newId);
          Node oldnode = cur.getNode(value.getId());
          Row tmprow = newnode.getNestedTable().addRow(factory);
          tmprow.getNeighborByColumnName("Values", factory).setValue(oldnode.getValue().asString(), oldnode.getStatus(), factory);
          //newnode.setValue(oldnode.getValue().asString(), oldnode.getStatus(), factory);
        }
        resultRows.add(lastRow);
      }
    }
    for (Row tmpRow : resultRows) {
      for (Node node : tmpRow.getNodes()) {
        if (node.hasNestedTable()) {
          Table tmpTable = node.getNestedTable();
          if (tmpTable.getNumRows() == 0) {
            tmpTable.addRow(factory);
          }
        }
      }
    }
View Full Code Here

      resultRows.add(lastRow);
    }
    for (Row tmpRow : resultRows) {
      for (Node node : tmpRow.getNodes()) {
        if (node.hasNestedTable()) {
          Table tmpTable = node.getNestedTable();
          if (tmpTable.getNumRows() == 0) {
            tmpTable.addRow(factory);
          }
        }
      }
    }
    return newws;
View Full Code Here

  }

  public static Object cloneNodeToJSON(HNode hn, Node node, SuperSelection sel) {
    if (node.hasNestedTable()) {
      HTable nestHT = hn.getNestedTable();
      Table dataTable = node.getNestedTable();
      JSONArray array = new JSONArray();
      for (Row row : dataTable.getRows(0, dataTable.getNumRows(), sel)) {
        JSONObject obj = new JSONObject();
        for (HNode hnode : nestHT.getHNodes()) {
          Node n = row.getNode(hnode.getId());
          obj.put(hnode.getColumnName(),cloneNodeToJSON(hnode, n, sel));
        }
View Full Code Here

        for (Row row : tmp.getRows(0, tmp.getNumRows(), selection)) {
          parentRows.add(row);
        }
      }
      for (Row parentRow : parentRows) {
        Table t = null;
        for (Node node : parentRow.getNodes()) {
          if (node.hasNestedTable() && node.getNestedTable().getHTableId().compareTo(htable.getId()) == 0) {
            t = node.getNestedTable();
            break;
         
        }
        ArrayList<Row> tmpRows = t.getRows(0, t.getNumRows(), selection);
        for (Row r : tmpRows) {
          rows.add(r);
        }
      }
    }
    //System.out.println("HNodeID: " + htable.getHNodeIdFromColumnName("homeworks"));
    //HNodeIds.add(htable.getHNodeIdFromColumnName("homeworks"));
   
    //HashValueManager.getHashValue(rows.get(0), HNodeIds);
    //hnodes.add(htable.getHNode("HN5"));
    //hnodes.add(htable.getHNode("HN7"));
    JSONArray array = new JSONArray();
    JSONArray input = new JSONArray();
    for (Row row : rows) {
      String id = row.getId();
      JSONArray t = new JSONArray();
      for (HNode hnode : hnodes) {
        Node node = row.getNode(hnode.getId());
        String name = hnode.getColumnName();
        Object value = CloneTableUtils.cloneNodeToJSON(hnode, node, selection);
        JSONObject obj = new JSONObject();
        JSONObject obj2 = new JSONObject();
        if (value instanceof String)
          obj2.put("values", value);
        else
          obj2.put(worksheet.getHeaders().getNewColumnName("nested"), value);
        obj.put("values", obj2);
        obj.put("names", name);
        t.put(obj);     
      }
      JSONObject obj = new JSONObject();
      obj.put("rowId", id);
      obj.put("rowIdHash", "");
      obj.put("values", t);
View Full Code Here

TOP

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

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.