edu.isi.karma.rep.Node类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中edu.isi.karma.rep.Node类的一些代码示例,展示了Node类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node类的具体详情如下:
包路径:edu.isi.karma.rep.Node
类名称:Node

Node介绍

暂无

代码示例

代码示例来源:origin: usc-isi-i2/Web-Karma

public static void cloneDataTableExistingRow(Row oldRow, Row newRow, List<HNode> hNodes, RepFactory factory, Map<String, String> mapping, SuperSelection sel) {
  for (HNode hnode : hNodes) {
    HNode newHNode = factory.getHNode(mapping.get(hnode.getId()));
    Node oldNode = oldRow.getNode(hnode.getId());
    Node newNode = newRow.getNode(newHNode.getId());
    if (oldNode == null)
      continue;
    if (!oldNode.hasNestedTable()) {
      newNode.setValue(oldNode.getValue(), oldNode.getStatus(), factory);
    }
    else {					
      cloneDataTable(oldNode.getNestedTable(), newNode.getNestedTable(), newHNode.getNestedTable(), hnode.getNestedTable().getSortedHNodes(), factory, sel);
    }
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

private static String getHashValueRecurse(Row row, List<String> HNodeIds) {
  List<String> hashString = new ArrayList<>();
  for (String HNodeid : HNodeIds) {
    Node n = row.getNode(HNodeid);
    if (n.hasNestedTable()) {
      Table nestedTable = n.getNestedTable();
      for (Row nestedRow : nestedTable.getRows(0, nestedTable.getNumRows(), SuperSelectionManager.DEFAULT_SELECTION)) {
        List<String> ids = new ArrayList<>();
        for (Node node : nestedRow.getNodes()) {
          ids.add(node.getHNodeId());
        }
        hashString.add(getHashValue(nestedRow, ids));                
      }
    }
    else {
      Map<String, String> tmp = hashTable.get(row.getId());
      
      hashString.add(tmp.get(n.getId()));
    }
  }
  Collections.sort(hashString);
  String hash = "";
  for (String t : hashString) {
    hash += t; 
  }
  return hash;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

protected Map<String, String> gatherTransformedResults(Workspace workspace, String hNodeId) {
  Map<String, String> rowToValueMapping = new HashMap<>();
  HNodePath hNodePath = workspace.getFactory().getHNode(hNodeId).getHNodePath(workspace.getFactory());
  List<Node> nodes = new ArrayList<>();
  workspace.getWorksheet(worksheetId).getDataTable().collectNodes(hNodePath, nodes, getSuperSelection(workspace));
  for (Node node : nodes) {
    rowToValueMapping.put(node.getBelongsToRow().getId(), node.getValue().asString());
    node.clearValue(NodeStatus.original);
    affectedNodes.add(node);
  }
  return rowToValueMapping;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

void addNode(Node node) {
  nodes.put(node.getHNodeId(), node);
  // mariam
  node.setBelongsToRow(this);
}

代码示例来源:origin: usc-isi-i2/Web-Karma

Node createNode(String id, String hNodeId, String worksheetId) {
  Node n = new Node(id, hNodeId);
  nodes.put(id, n);
  HNode hn = hNodes.get(hNodeId);
  HTable nestedHTable = hn.getNestedTable();
  if (nestedHTable != null) {
    n.setNestedTable(createTable(nestedHTable.getId(), worksheetId), this);
  }
  return n;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

private void removeDataTableRecursive(Table table) {
  for (Row r : table.getRows(0, table.getNumRows(), SuperSelectionManager.DEFAULT_SELECTION)) {
    for (Node n : r.getNodes()) {
      if (n.hasNestedTable()) {
        removeDataTableRecursive(n.getNestedTable());
      }
      nodes.remove(n.id);
    }
    rows.remove(r.id);
  }
  tables.remove(table.id);
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public static String getHashValue(Worksheet worksheet, String NodeId, RepFactory factory) {
  Node node = factory.getNode(NodeId);
  if (node != null) {
    return DigestUtils.shaHex(node.getValue().asString());
  }
  return null;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

private void populatePolygons(List<String> coordinateHNodeIds,
    ArrayList<Row> rows, Map<String, String> columnNameMap) {
  for (Row row : rows) {
    try {
      String posList = row.getNode(coordinateHNodeIds.get(0))
          .getValue().asString();
      WKTReader reader = new WKTReader();
      Polygon JTSPolygon = (Polygon)reader.read(posList);
      if(JTSPolygon == null) continue;
      polygons.add(JTSPolygon);
      FeatureTable featureTable = new FeatureTable();
      Collection<Node> nodes = row.getNodes();
      for (Node node : nodes) {
        if (!(coordinateHNodeIds.contains(node.getHNodeId()))
            && !(node.hasNestedTable())) {
          featureTable.addColumnToDescription(columnNameMap.get(node
              .getHNodeId()), node.getValue().asString());
        }
      }
      polygonTable.add(featureTable);
    } catch (Exception e) {
      logger.error("Error creating line! Skipping it.", e);
      continue;
    }
  }
}
private void populateLines(List<String> coordinateHNodeIds,

代码示例来源:origin: usc-isi-i2/Web-Karma

@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
  Node node = workspace.getFactory().getNode(nodeIdArg);
  SuperSelection sel = getSuperSelection(workspace);
  inputColumns.clear();
  outputColumns.clear();
  inputColumns.add(node.getHNodeId());
  outputColumns.add(node.getHNodeId());
  previousValue = node.getValue();
  previousStatus = node.getStatus();
  if (node.hasNestedTable()) {
    throw new CommandException(this, "Cell " + nodeIdArg
        + " has a nested table. It cannot be edited.");
  }        
  node.setValue(newValueArg, Node.NodeStatus.edited,
      workspace.getFactory());
  WorksheetUpdateFactory.detectSelectionStatusChange(worksheetId, workspace, this);
  UpdateContainer uc = WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(worksheetId, sel, workspace.getContextId());
  uc.add(new NodeChangedUpdate(worksheetId,
      nodeIdArg, newValueArg, Node.NodeStatus.edited));
  return uc;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

continue;
if(n.getValue() == null || n.getValue().asString() == null || n.getValue().isEmptyValue() || n.getValue().asString().trim().isEmpty())
if(useNodeValue)
  uri.append(n.getValue().asString());
  String value = n.getValue().asString();
  value = DigestUtils.shaHex(value);
  uri.append(value);
  uri.append("_" + n.getId());

代码示例来源:origin: usc-isi-i2/Web-Karma

public void addNestedTableToDataTable(HNode hNode, Table table,
    RepFactory factory) {
  Node node = getNode(hNode.getId());
  if (node != null) {
    // This table does contain this hNode.
    Table nestedTable = factory.createTable(hNode.getNestedTable()
        .getId(), getWorksheetId());
    node.setNestedTable(nestedTable, factory);
    // If the node has a value, we have to move the value to the
    // nestedTable given that we cannot have both.
    if (!node.getValue().isEmptyValue()) {
      logger.info("While adding nested table, found that column '"
          + factory.getColumnName(hNode.getId())
          + "' has a value: '" + node.getValue().asString()
          + "'.");
      logger.info("Emptying value in node and trying to move it to the nested table.");
      nestedTable.addOrphanValue(node.getValue(), node.getHNodeId(),
          factory);
    }
  } else {
    // The node may be in one of the nested tables. We have to look for
    // it.
    for (Node n : nodes.values()) {
      Table nestedTable = n.getNestedTable();
      if (nestedTable != null) {
        nestedTable.addNestedTableToDataTable(hNode, factory);
      }
    }
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public Object serializeToJSON(SuperSelection selection, RepFactory factory) {
  if (this.hasNestedTable()) {
    JSONArray array = new JSONArray();
    Table t = this.getNestedTable();
    HTable ht = factory.getHTable(t.getHTableId());
    for (Row r : t.getRows(0, t.getNumRows(), selection)) {
      JSONObject obj = new JSONObject();
      for (HNode hNode : ht.getHNodes()) {
        obj.put(hNode.getColumnName(), r.getNeighbor(hNode.getId()).serializeToJSON(selection, factory));			
      }
      array.put(obj);
    }
    return array;
  }
  else {
    return this.getValue().asString();
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

nodeObj.put(JsonKeys.columnClass.name(), 
    WorksheetHeadersUpdate.getColumnClass(vNode.getId()));
nodeObj.put(JsonKeys.nodeId.name(), rowNode.getId());
  Table nestedTable = rowNode.getNestedTable();
  JSONArray nestedTableRows = getRowsUsingPager( 
      vWorksheet.getNestedTablePager(nestedTable), 
      maxDataDisplayLength);
  nodeObj.put(JsonKeys.nestedRows.name(), nestedTableRows);
  nodeObj.put(JsonKeys.tableId.name(), rowNode.getNestedTable().getId());
  String nodeVal = rowNode.getValue().asString();
  nodeVal = (nodeVal == null) ? "" : nodeVal;
  String displayVal = (nodeVal.length() > maxDataDisplayLength)

代码示例来源:origin: usc-isi-i2/Web-Karma

@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
  RepFactory factory = workspace.getFactory();
  for (Map.Entry<String, String> stringStringEntry : newRowValueMap.entrySet()) {
    Row row = factory.getRow(stringStringEntry.getKey());
    Node existingNode = row.getNode(hNodeID);
    if (existingNode.hasNestedTable()) {
      logger.error("Existing node has a nested table. Cannot overwrite such node with new value. NodeID: " + existingNode.getId());
      continue;
    }
    String existingCellValue = existingNode.getValue().asString();
    oldRowValueMap.put(stringStringEntry.getKey(), existingCellValue);
    String newCellValue = stringStringEntry.getValue();
    row.setValue(hNodeID, newCellValue, factory);
  }
  return WorksheetUpdateFactory.createWorksheetHierarchicalAndCleaningResultsUpdates(this.worksheetId, SuperSelectionManager.DEFAULT_SELECTION, workspace.getContextId());
}

代码示例来源:origin: usc-isi-i2/Web-Karma

oldNodeValueMap.put(node, node.getValue());
if (oldNodeStatusMap != null)
  oldNodeStatusMap.put(node, node.getStatus());
node.clearValue(NodeStatus.edited);
    Table table = node.getNestedTable();
  node.clearValue(NodeStatus.edited);

代码示例来源:origin: usc-isi-i2/Web-Karma

public static Object cloneNodeToJSON(HNode hNode, Node node, SuperSelection sel) {
  if (node.hasNestedTable()) {
    HTable nestHT = hNode.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));
      }
      array.put(obj);
    }
    return array;
  }
  else
    return node.getValue().asString();
}

代码示例来源:origin: usc-isi-i2/Web-Karma

public void removeNode(String hNodeId) {
  nodes.remove(hNodeId);
  for (Node n : nodes.values()) {
    Table nestedTable = n.getNestedTable();
    if (nestedTable != null) {
      nestedTable.removeNodeFromDataTable(hNodeId);
    }
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

private boolean addValues(Node node, String value, RepFactory factory, Table table) {
  Worksheet worksheet = factory.getWorksheet(worksheetId);
  SuperSelection selection = getSuperSelection(worksheet);
  boolean flag = true;
  if (table != null) {
    for (Row r : table.getRows(0, table.getNumRows(), selection)) {
      Node n = r.getNeighbor(node.getHNodeId());
      if (n.getValue() != null && n.getValue().asString().compareTo(value) == 0) { 
        flag = false;
        break;
      }
    }
  }
  if (flag)
    node.setValue(value, NodeStatus.original, factory);
  return flag;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

for (Table t : tables) {
  for (Row r : t.getRows(0, t.getNumRows(), selection)) {
    String orgValue = r.getNeighbor(hNodeId).getValue().asString();
    String[] rowValues;
    int startIndex = 0;
      Node newNode = r.getNeighbor(newhNodeId);
      for (int i = startIndex; i < rowValues.length; i++) {
        Row dest = newNode.getNestedTable().addRow(factory);
        Node destNode = dest.getNeighborByColumnName("Values", factory);
        destNode.setValue(rowValues[i], NodeStatus.original, factory);

代码示例来源:origin: usc-isi-i2/Web-Karma

pw.print(str.substring(1, str.length()-3));
Table nestedTable = rowNode.getNestedTable();
generateRowsUsingPager( 
    vWorksheet.getNestedTablePager(nestedTable), 
if(columnName == null || columnName.length() == 0)
  continue;
nodeObj.put(columnName, rowNode.getValue().asString());
String str = nodeObj.toString();
pw.print(rowSep);

相关文章