public JSONArray getCommandsJSON() { JSONArray commandsArray = new JSONArray(); for (Command command : commands) { commandsArray.put(workspace.getCommandHistory().getCommandJSON(workspace, command)); } return commandsArray; }
public UpdateContainer replayHistory() { JSONArray redoCommandsArray = new JSONArray(); for (Command refined : commands) { redoCommandsArray.put(workspace.getCommandHistory().getCommandJSON(workspace, refined)); } return replayHistory(redoCommandsArray); }
private List<Command> gatherAllOperateSelectionCommands(List<Command> commands, Workspace workspace) { List<Command> operationCommands = new ArrayList<>(); for (Command c : commands) { if (c instanceof OperateSelectionCommand) { OperateSelectionCommand t = (OperateSelectionCommand)c; if (isSamehTableId(t.getHNodeId(), hNodeId, workspace)) { JSONObject obj = workspace.getCommandHistory().getCommandJSON(workspace, t); Command tmp = generateCommandFromJSON(workspace, obj); if (tmp != null) operationCommands.add(tmp); } } } return operationCommands; }
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); } }
JSONArray oldCommandsArray = new JSONArray(); for (Command refined : oldCommands) oldCommandsArray.put(workspace.getCommandHistory().getCommandJSON(workspace, refined)); worksheet.getMetadataContainer().getWorksheetProperties().setPropertyValue( Property.oldCommandHistory, oldCommandsArray.toString());
List<Command> commands = workspace.getCommandHistory().getCommandsFromWorksheetId(volatileWorksheetId); for (Command command : commands) { historyCommandsBackup.put(workspace.getCommandHistory().getCommandJSON(workspace, command));