List<String> resultSubjects = results.get("resultSubjects");
List<String> resultPredicates = results.get("resultPredicates");
List<String> resultObjects = results.get("resultObjects");
List<String> resultClass = results.get("resultClasses");
AddValuesCommandFactory addFactory = new AddValuesCommandFactory();
for (int i = 0; i < resultPredicates.size(); i++) {
String subject = incoming ? resultObjects.get(i) : resultSubjects.get(i);
List<String> rowIds = SubjectURIToRowId.get(subject);
boolean isNewNode = false;
for (String RowId : rowIds) {
String predicate = resultPredicates.get(i);
String otherClass = resultClass.get(i);
JSONArray array = new JSONArray();
JSONObject obj = new JSONObject();
JSONObject obj2 = new JSONObject();
if (otherClass != null && !otherClass.trim().isEmpty())
obj.put("URIs", incoming ? resultSubjects.get(i) : resultObjects.get(i));
else
obj.put("values", incoming ? resultSubjects.get(i) : resultObjects.get(i));
obj2.put("rowId", RowId);
obj2.put("rowIdHash", "");
obj2.put("values", obj);
array.put(obj2);
JSONArray input = new JSONArray();
JSONObject obj3 = new JSONObject();
obj3.put("name", "AddValues");
obj3.put("value", array.toString());
obj3.put("type", "other");
input.put(obj3);
try {
OntologyManager ontMgr = workspace.getOntologyManager();
Label label = ontMgr.getUriLabel(incoming ? otherClass : predicate);
AddValuesCommand command = (AddValuesCommand) addFactory.createCommand(input, workspace, hNodeId, worksheetId, hnode.getHTableId(), label.getDisplayName(), HNodeType.AugmentData, selection.getName());
command.doIt(workspace);
outputColumns.addAll(command.getOutputColumns());
isNewNode |= command.isNewNode();
if (command.isNewNode())
appliedCommands.push(command);