public JSONArray readCommandsByTag(List<CommandTag> tag) { JSONArray filteredHistoryJson = new JSONArray(); try { String filename = CommandHistory.getHistorySaver(workspace.getId()).getHistoryFilepath(worksheetId); JSONArray historyJson = CommandHistory.getHistorySaver(workspace.getId()).loadHistory(filename); filteredHistoryJson = HistoryJsonUtil.filterCommandsByTag(tag, historyJson); } catch (JSONException e) { logger.error("Error occured while working with JSON!", e); } catch(Exception e) { logger.error("Error reading from history file!", e); } return filteredHistoryJson; }
public static boolean historyExists(String workspaceId, String worksheetId) { String filename = CommandHistory.getHistorySaver(workspaceId).getHistoryFilepath(worksheetId); File file = new File(filename); return file.exists(); }
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); } }
String linebreak = System.getProperty("line.separator"); String historyFile = CommandHistory.getHistorySaver(workspace.getId()).getHistoryFilepath(worksheetId); try { JSONArray history = CommandHistory.getHistorySaver(workspace.getId()).loadHistory(historyFile);
String linebreak = System.getProperty("line.separator"); String historyFile = CommandHistory.getHistorySaver(workspace.getId()).getHistoryFilepath(worksheetId); try { JSONArray history = CommandHistory.getHistorySaver(workspace.getId()).loadHistory(historyFile);
String historyFile = CommandHistory.getHistorySaver(workspace.getId()).getHistoryFilepath(worksheetId); try { JSONArray history = CommandHistory.getHistorySaver(workspace.getId()).loadHistory(historyFile);
String linebreak = System.getProperty("line.separator"); String historyFile = CommandHistory.getHistorySaver(workspace.getId()).getHistoryFilepath(worksheetId); try { JSONArray history = CommandHistory.getHistorySaver(workspace.getId()).loadHistory(historyFile);
private void addWorksheetHistory(JSONArray history) { if(history != null) { r2rmlMapping.setWorksheetHistory(history); } else { String filename = CommandHistory.getHistorySaver(workspace.getId()).getHistoryFilepath(worksheet.getId()); if(!HistoryJsonUtil.historyExists(workspace.getId(), worksheet.getId())) { logger.error("Worksheet history file not found! Can't write worksheet history " + "into R2RML model. Path:" + filename); return; } try { JSONArray historyArr = CommandHistory.getHistorySaver(workspace.getId()).loadHistory(filename); r2rmlMapping.setWorksheetHistory(historyArr); } catch(Exception e) { logger.error("Unable to read worksheet history from file: " + filename); } } }