if (newCommand instanceof AddLinkCommand) { String model = newCommand.getModel(); JSONArray inputParams = new JSONArray(newCommand.getInputParameterJson()); JSONObject newEdge = HistoryJsonUtil.getJSONObjectWithName( Arguments.edge.name(), inputParams).getJSONObject("value"); if (tmp.getModel().equals(model) && (tmp instanceof AddLinkCommand)) { JSONArray tmpParams = new JSONArray(tmp.getInputParameterJson()); JSONObject tmpEdge = HistoryJsonUtil.getJSONObjectWithName( Arguments.edge.name(), tmpParams).getJSONObject("value");
@Override public Pair<ICommand, Object> consolidateCommand(List<ICommand> commands, ICommand newCommand, Workspace workspace) { if (newCommand instanceof SubmitPythonTransformationCommand) { String model = newCommand.getModel(); Iterator<ICommand> itr = commands.iterator(); while(itr.hasNext()) { ICommand tmp = itr.next(); if (((Command)tmp).getOutputColumns().equals(((Command)newCommand).getOutputColumns()) && tmp.getModel().equals(model) && (tmp instanceof AddColumnCommand)) { SubmitPythonTransformationCommand py = ((SubmitPythonTransformationCommand)newCommand); JSONArray inputJSON = new JSONArray(py.getInputParameterJson()); JSONArray tmpInputJSON = new JSONArray(tmp.getInputParameterJson()); String hNodeId = HistoryJsonUtil.getStringValue("hNodeId", tmpInputJSON); HistoryJsonUtil.setArgumentValue("hNodeId", hNodeId, inputJSON); py.setInputParameterJson(inputJSON.toString()); return new ImmutablePair<>(tmp, (Object)py); } } } return null; }
if (newCommand instanceof DeleteLinkCommand) { String model = newCommand.getModel(); JSONArray inputParams = new JSONArray(newCommand.getInputParameterJson()); JSONObject newEdge = HistoryJsonUtil.getJSONObjectWithName( Arguments.edge.name(), inputParams).getJSONObject("value"); if (tmp.getModel().equals(model) && (tmp instanceof AddLinkCommand)) { JSONArray tmpParams = new JSONArray(tmp.getInputParameterJson()); JSONObject tmpEdge = HistoryJsonUtil.getJSONObjectWithName( Arguments.edge.name(), tmpParams).getJSONObject("value");
private void writeHistoryPerWorksheet(Workspace workspace, IHistorySaver historySaver) throws Exception { String workspaceId = workspace.getId(); Map<String, JSONArray> comMap = new HashMap<>(); for(ICommand command : _getHistory()) { if(command.isSavedInHistory() && (command.hasTag(CommandTag.Modeling) || command.hasTag(CommandTag.Transformation) || command.hasTag(CommandTag.Selection) || command.hasTag(CommandTag.SemanticType) )) { JSONArray json = new JSONArray(command.getInputParameterJson()); String worksheetId = HistoryJsonUtil.getStringValue(HistoryArguments.worksheetId.name(), json); if(workspace.getWorksheet(worksheetId) != null) { try { if(comMap.get(worksheetId) == null) comMap.put(worksheetId, new JSONArray()); comMap.get(worksheetId).put(getCommandJSON(workspace, command)); } catch(Exception e) { logger.error("Error serializing command {} to history, Input:{}", command.getCommandName(), command.getInputParameterJson()); } } } } for(Map.Entry<String, JSONArray> stringJSONArrayEntry : comMap.entrySet()) { JSONArray comms = stringJSONArrayEntry.getValue(); historySaver.saveHistory(workspaceId, stringJSONArrayEntry.getKey(), comms); } }
@Override public UpdateContainer doIt(Workspace workspace) throws CommandException { HNode columnNode = workspace.getFactory().getHNode(hNodeId); oldColumnName = columnNode.getColumnName(); // Change the column name columnNode.setColumnName(newColumnName); newColumnAbsoluteName = columnNode.getAbsoluteColumnName(workspace.getFactory()); CommandHistory history = workspace.getCommandHistory(); List<ICommand> allCommands = history._getHistory(); for(ICommand command : allCommands) { String json = command.getInputParameterJson(); if(json != null && json.length() > 0) { JSONArray inputs = new JSONArray(json); for(int i=0; i<inputs.length(); i++) { JSONObject input = inputs.getJSONObject(i); replaceColumnName(input); } command.setInputParameterJson(inputs.toString()); } } // Prepare the output to be sent UpdateContainer c = WorksheetUpdateFactory.createRegenerateWorksheetUpdates(worksheetId, SuperSelectionManager.DEFAULT_SELECTION, workspace.getContextId()); c.append(computeAlignmentAndSemanticTypesAndCreateUpdates(workspace)); return c; }
commObj.put(HistoryArguments.tags.name(), tagsArr); JSONArray inputArr = new JSONArray(comm.getInputParameterJson() == null ? "[]" : comm.getInputParameterJson()); for (int i = 0; i < inputArr.length(); i++) { JSONObject inpP = inputArr.getJSONObject(i);