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()); if (isCommandTag(commandTag, CommandTag.Transformation)) { if(CommandInputJSONUtil.getStringValue("orderedColumns", inputParamArr) != null) {
public JSONObject getCommandJSON(Workspace workspace, ICommand comm) { JSONObject commObj = new JSONObject(); commObj.put(HistoryArguments.commandName.name(), comm.getCommandName()); commObj.put(HistoryArguments.model.name(), comm.getModel()); for (CommandTag tag : comm.getTags()) tagsArr.put(tag.name()); commObj.put(HistoryArguments.tags.name(), tagsArr); commObj.put(HistoryArguments.inputParameters.name(), inputArr);
JSONArray tags = commObject.getJSONArray(HistoryArguments.tags.name()); if(null == tags || tags.length() == 0) if(null != tag && tag.equals(CommandTag.Transformation.name())) JSONArray inputParamArr = (JSONArray) commObject.get(HistoryArguments.inputParameters.name()); CommandFactory cf = commandFactoryMap.get(commObject.get(HistoryArguments.commandName.name())); if(cf != null && cf instanceof JSONInputCommandFactory) { try { String model = Command.NEW_MODEL; if(commObject.has(HistoryArguments.model.name())) model = commObject.getString(HistoryArguments.model.name()); comm = scf.createCommand(inputParamArr, model, workspace); } catch (JSONException | KarmaException e) {
HashMap<String, CommandFactory> commandFactoryMap = ctrl.getCommandFactoryMap(); JSONArray inputParamArr = (JSONArray) commObject.get(HistoryArguments.inputParameters.name()); String commandName = (String)commObject.get(HistoryArguments.commandName.name()); logger.debug("Command in history: " + commandName); uc = new UpdateContainer(); CommandFactory cf = commandFactoryMap.get(commObject.get(HistoryArguments.commandName.name())); if(cf != null) { try { // This is sort of a hack the way I did this, but could not think of a better way to get rid of the dependency String model = Command.NEW_MODEL; if(commObject.has(HistoryArguments.model.name())) model = commObject.getString(HistoryArguments.model.name()); Command comm = cf.createCommand(inputParamArr, model, workspace); if(comm != null){ + commObject.get(HistoryArguments.commandName.name())); return new UpdateContainer(new TrivialErrorUpdate("Error executing command " + commandName + " from history"));
Object organizeCommand = null; 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()); if (isCommandTag(commandTag, CommandTag.Transformation)) { if(commandName.equals("OrganizeColumnsCommand")) {
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 tags = commObject.getJSONArray(HistoryArguments.tags.name()); boolean match = false; for (int j=0; j< tags.length(); j++) {
JSONArray tags = commObject.getJSONArray(HistoryArguments.tags.name()); boolean match = false; for (int j=0; j< tags.length(); j++) {
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 void updateModelUrlInCommands(String modelUrl) { for (int i = 0; i < historyJSON.length(); i++) { historyJSON.getJSONObject(i).put(HistoryArguments.model.name(), modelUrl); } }