@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; }
@Override public Pair<ICommand, Object> consolidateCommand(List<ICommand> commands, ICommand newCommand, Workspace workspace) { if (newCommand instanceof SubmitEditPythonTransformationCommand) { Iterator<ICommand> itr = commands.iterator(); String model = newCommand.getModel(); while(itr.hasNext()) { ICommand tmp = itr.next(); if (((Command)tmp).getOutputColumns().equals(((Command)newCommand).getOutputColumns()) && tmp instanceof SubmitPythonTransformationCommand && !(tmp instanceof SubmitEditPythonTransformationCommand) && model.equals(tmp.getModel())) { SubmitPythonTransformationCommand py = (SubmitPythonTransformationCommand)tmp; SubmitPythonTransformationCommand edit = (SubmitPythonTransformationCommand)newCommand; JSONArray inputJSON = new JSONArray(py.getInputParameterJson()); JSONArray oldInputJSON = new JSONArray(py.getInputParameterJson()); HistoryJsonUtil.setArgumentValue("transformationCode", edit.getTransformationCode(), inputJSON); py.setInputParameterJson(inputJSON.toString()); py.setTransformationCode(edit.getTransformationCode()); return new ImmutablePair<>(tmp, (Object)oldInputJSON); } } } return null; }
JSONArray placeAfterCmdInputJSON = new JSONArray(command.getInputParameterJson()); String placeHNodeId = HistoryJsonUtil.getStringValue("hNodeId", placeAfterCmdInputJSON); HistoryJsonUtil.setArgumentValue("hNodeId", placeHNodeId, inputJSON); command.setInputParameterJson(inputJSON.toString()); worksheetCommandHistory.insertCommandToHistoryAfterCommand(command, placeAfterCmd);
HistoryJsonUtil.setArgumentValue(Arguments.SemanticTypesArray.name(), typesArr, inputParams); this.setInputParameterJson(inputParams.toString());