本文整理了Java中edu.isi.karma.rep.Node.hasNestedTable()
方法的一些代码示例,展示了Node.hasNestedTable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.hasNestedTable()
方法的具体详情如下:
包路径:edu.isi.karma.rep.Node
类名称:Node
方法名:hasNestedTable
暂无
代码示例来源: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
@Override
public UpdateContainer undoIt(Workspace workspace) {
RepFactory factory = workspace.getFactory();
for (Map.Entry<String, String> stringStringEntry : oldRowValueMap.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 oldCellValue = stringStringEntry.getValue();
row.setValue(hNodeID, oldCellValue, factory);
}
return WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, SuperSelectionManager.DEFAULT_SELECTION, workspace.getContextId());
}
代码示例来源: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
@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
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 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
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
private static void computeHashValue(Row row, List<String> HNodeIds) {
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());
}
computeHashValue(nestedRow, ids);
}
}
else {
Map<String, String> tmp = hashTable.get(row.getId());
if (tmp == null)
tmp = new ConcurrentHashMap<>();
String value = n.getValue().asString();
value = DigestUtils.shaHex(value);
tmp.put(n.getId(), value);
hashTable.put(row.getId(), tmp);
}
}
}
代码示例来源:origin: usc-isi-i2/Web-Karma
for (Node node : nodes) {
if (!(coordinateHNodeIds.contains(node.getHNodeId()))
&& !(node.hasNestedTable())) {
point.addColumnToDescription(columnNameMap.get(node
.getHNodeId()), node.getValue().asString());
代码示例来源:origin: usc-isi-i2/Web-Karma
for (Node node : nodes) {
if (!(coordinateHNodeIds.contains(node.getHNodeId()))
&& !(node.hasNestedTable())) {
line.addColumnToDescription(columnNameMap.get(node
.getHNodeId()), node.getValue().asString());
代码示例来源:origin: usc-isi-i2/Web-Karma
Table t = null;
for (Node node : parentRow.getNodes()) {
if (node.hasNestedTable() && node.getNestedTable().getHTableId().compareTo(ht.getId()) == 0) {
t = node.getNestedTable();
break;
代码示例来源: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
Table t = null;
for (Node node : parentRow.getNodes()) {
if (node.hasNestedTable() && node.getNestedTable().getHTableId().compareTo(ht.getId()) == 0) {
t = node.getNestedTable();
break;
if (node.hasNestedTable()) {
Table tmpTable = node.getNestedTable();
if (tmpTable.getNumRows() == 0) {
代码示例来源:origin: usc-isi-i2/Web-Karma
Table t = null;
for (Node node : parentRow.getNodes()) {
if (node.hasNestedTable() && node.getNestedTable().getHTableId().compareTo(ht.getId()) == 0) {
t = node.getNestedTable();
break;
代码示例来源:origin: usc-isi-i2/Web-Karma
private void setCollectedNodeValues(HNodePath path, List<String> nodes,
List<Row> rows, int nodeIdx, RepFactory factory, SuperSelection sel) {
RowIterator: for (Row r : rows) {
if (sel.isSelected(r))
continue;
Node n = r.getNode(path.getFirst().getId());
if (n == null) {
continue RowIterator;
}
// Check if the path has only one HNode
if (path.getRest() == null || path.getRest().isEmpty()) {
n.setValue(nodes.get(nodeIdx++), NodeStatus.original, factory);
continue RowIterator;
}
// Check if the node has a nested table
if (n.hasNestedTable()) {
int numRows = n.getNestedTable().getNumRows();
if (numRows == 0)
continue RowIterator;
List<Row> rowsNestedTable = n.getNestedTable().getRows(0,
numRows, sel);
if (rowsNestedTable != null && !rowsNestedTable.isEmpty()) {
setCollectedNodeValues(path.getRest(), nodes,
rowsNestedTable, nodeIdx, factory, sel);
continue RowIterator;
}
}
}
}
代码示例来源:origin: usc-isi-i2/Web-Karma
if (node.hasNestedTable()) {
Table tmpTable = node.getNestedTable();
if (tmpTable.getNumRows() == 0) {
代码示例来源: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
if (n.hasNestedTable()) {
int numRows = n.getNestedTable().getNumRows();
if (numRows != 0)
代码示例来源:origin: usc-isi-i2/Web-Karma
public static Row cloneDataTable(Row oldRow, Table newDataTable, HTable newHTable, List<HNode> hNodes, RepFactory factory, SuperSelection sel) {
Row newRow = newDataTable.addRow(factory);
for (HNode hnode : hNodes) {
HNode newHNode = newHTable.getHNodeFromColumnName(hnode.getColumnName());
if (newHNode == null)
continue;
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);
}
}
return newRow;
}
代码示例来源:origin: usc-isi-i2/Web-Karma
public static void cloneDataTable(Table oldDataTable, Table newDataTable, HTable newHTable, List<HNode> hNodes, RepFactory factory, SuperSelection sel) {
ArrayList<Row> rows = oldDataTable.getRows(0, oldDataTable.getNumRows(), sel);
for (Row row : rows) {
Row newrow = newDataTable.addRow(factory);
for (HNode hnode : hNodes) {
HNode newHNode = newHTable.getHNodeFromColumnName(hnode.getColumnName());
Node oldNode = row.getNode(hnode.getId());
Node newNode = newrow.getNode(newHNode.getId());
if (!oldNode.hasNestedTable()) {
newNode.setValue(oldNode.getValue(), oldNode.getStatus(), factory);
}
else {
cloneDataTable(oldNode.getNestedTable(), newNode.getNestedTable(), newHNode.getNestedTable(), hnode.getNestedTable().getSortedHNodes(), factory, sel);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!