private Command generateCommandFromJSON(Workspace workspace, JSONObject obj) { JSONArray inputParamArr = (JSONArray) obj.get(HistoryArguments.inputParameters.name()); String commandName = (String)obj.get(HistoryArguments.commandName.name()); WorksheetCommandHistoryExecutor ex = new WorksheetCommandHistoryExecutor(worksheetId, workspace); ex.normalizeCommandHistoryJsonInput(workspace, worksheetId, inputParamArr, commandName, true); try { String model = Command.NEW_MODEL; if(obj.has(HistoryArguments.model.name())) model = obj.getString(HistoryArguments.model.name()); Command c = new OperateSelectionCommandFactory().createCommand(inputParamArr, model, workspace); return c; } catch (Exception e) { return null; } }
public UpdateContainer executeCommandsByTags( List<CommandTag> tagsToAdd, List<CommandTag> tagsToRemove, JSONArray historyJson) throws JSONException, KarmaException, CommandException { JSONArray filteredCommands = HistoryJsonUtil.filterCommandsByTag(tagsToAdd, historyJson); filteredCommands = HistoryJsonUtil.removeCommandsByTag(tagsToRemove, filteredCommands); return executeAllCommands(filteredCommands); }
public UpdateContainer executeAllCommands(JSONArray historyJson) throws JSONException, KarmaException, CommandException { UpdateContainer uc =new UpdateContainer(); boolean saveToHistory = false; for (int i = 0; i< historyJson.length(); i++) { JSONObject commObject = (JSONObject) historyJson.get(i); if(i == historyJson.length() - 1) saveToHistory = true; UpdateContainer update = executeCommand(commObject, saveToHistory); if(update != null) uc.append(update); } return uc; }
protected void applyHistoryToWorksheet(Workspace workspace, Worksheet worksheet, KR2RMLMapping mapping) throws JSONException { WorksheetCommandHistoryExecutor wchr = new WorksheetCommandHistoryExecutor(worksheet.getId(), workspace); try { List<CommandTag> tags = new ArrayList<>(); tags.add(CommandTag.Selection); tags.add(CommandTag.Transformation); List<CommandTag> ignoreTags = new ArrayList<>(); ignoreTags.add(CommandTag.IgnoreInBatch); wchr.executeCommandsByTags(tags, ignoreTags, new JSONArray(mapping.getWorksheetHistoryString())); } catch (CommandException | KarmaException e) { logger.error("Unable to execute column transformations", e); } }
WorksheetCommandHistoryExecutor histExecutor = new WorksheetCommandHistoryExecutor( worksheetId, workspace); histExecutor.executeAllCommands(historyJson);
@SuppressWarnings("unchecked") @Override public UpdateContainer doIt(Workspace workspace) throws CommandException { Alignment alignment = AlignmentManager.Instance().getAlignment( alignmentId); Worksheet worksheet = workspace.getWorksheet(worksheetId); OntologyManager ontMgr = workspace.getOntologyManager(); // Save the original alignment for undo oldAlignment = alignment.getAlignmentClone(); oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment .getGraph().clone(); UpdateContainer uc = new UpdateContainer(); WorksheetCommandHistoryExecutor histExecutor = new WorksheetCommandHistoryExecutor( worksheetId, workspace); // First delete the links that are not present in newEdges and present // in intialEdges try { refineInitialEdges(alignment); uc.append(deleteLinks(histExecutor, workspace, worksheet, alignment)); uc.append(addNewLinks(histExecutor, workspace, alignment, ontMgr)); } catch (JSONException e) { e.printStackTrace(); } return uc; }
subjectHNodeId = generateHNodeId((JSONArray)subject, hTable, addIfNonExist, uc); } else { subjectHNodeId = subject.toString(); objectHNodeId = generateHNodeId((JSONArray)object, hTable, addIfNonExist, uc); } else { objectHNodeId = object.toString(); JSONObject hnodeJSON = hNodes.getJSONObject(k); JSONArray hNodeJSONRep = new JSONArray(hnodeJSON.get(ClientJsonKeys.id.name()).toString()); processHNodeId(hNodeJSONRep, hTable, commandName, hnodeJSON); if (hnodeJSON.has(ClientJsonKeys.children.name())) { JSONArray children = new JSONArray(hnodeJSON.get(ClientJsonKeys.children.name()).toString()); hnodeJSON.put(ClientJsonKeys.children.name(), processChildren(children, hTable, commandName));
UpdateContainer uc = normalizeCommandHistoryJsonInput(workspace, worksheetId, inputParamArr, commandName, true);
if(!r2rmlModelFile.getProtocol().equals("file")) editor.updateModelUrlInCommands(r2rmlModelFile.toString()); WorksheetCommandHistoryExecutor histExecutor = new WorksheetCommandHistoryExecutor( worksheetId, workspace); AlignmentManager alignMgr = AlignmentManager.Instance(); UpdateContainer hc = histExecutor.executeAllCommands(historyJson); if(hc != null) { hc.removeUpdateByClass(InfoUpdate.class);
WorksheetCommandHistoryExecutor histExecutor = new WorksheetCommandHistoryExecutor( worksheetId, workspace); UpdateContainer hc = histExecutor.executeAllCommands(redoCommandsArray); uc.append(hc);
for (int i = 0; i < historyJSON.length(); i++) { JSONArray inputParamArr = new JSONArray(historyJSON.getJSONObject(i).get(HistoryArguments.inputParameters.name()).toString()); WorksheetCommandHistoryExecutor ex = new WorksheetCommandHistoryExecutor(worksheetId, workspace); String commandName = (String)historyJSON.getJSONObject(i).get(HistoryArguments.commandName.name()); JSONArray commandTag = (JSONArray)historyJSON.getJSONObject(i).get(HistoryArguments.tags.name()); ex.normalizeCommandHistoryJsonInput(workspace, worksheetId, inputParamArr, commandName, false); String tmp = CommandInputJSONUtil.getStringValue("outputColumns", inputParamArr);
WorksheetCommandHistoryExecutor ex = new WorksheetCommandHistoryExecutor(worksheetId, workspace); String commandName = (String)historyJSON.getJSONObject(i).get(HistoryArguments.commandName.name()); continue; ex.normalizeCommandHistoryJsonInput(workspace, worksheetId, inputParamArr, commandName, false); String tmp = CommandInputJSONUtil.getStringValue("outputColumns", inputParamArr); if (tmp == null) {