final Worksheet worksheet = workspace.getWorksheet(worksheetId);
UpdateContainer c = new UpdateContainer();
try {
JSONArray historyJson = extractHistoryFromModel(workspace, c);
HistoryJSONEditor editor = new HistoryJSONEditor(new JSONArray(historyJson.toString()), workspace, worksheetId);
if (null == historyJson || historyJson.length() == 0) {
return new UpdateContainer(new ErrorUpdate("No history found in R2RML Model!"));
}
WorksheetCommandHistoryExecutor histExecutor = new WorksheetCommandHistoryExecutor(
worksheetId, workspace);
AlignmentManager alignMgr = AlignmentManager.Instance();
Alignment alignment = alignMgr.getAlignment(workspace.getId(), worksheetId);
if (override || alignment == null || alignment.GetTreeRoot() == null) {
String alignmentId = alignMgr.constructAlignmentId(workspace.getId(), worksheetId);
alignMgr.removeAlignment(alignmentId);
alignMgr.getAlignmentOrCreateIt(workspace.getId(), worksheetId, workspace.getOntologyManager());
editor.deleteExistingTransformationCommands();
historyJson = editor.getHistoryJSON();
}
else {
editor.deleteExistingTransformationAndModelingCommands();
historyJson = editor.getHistoryJSON();
}
System.out.println(editor.getHistoryJSON().toString(4));
UpdateContainer hc = histExecutor.executeAllCommands(historyJson);
if(hc != null) {
hc.removeUpdateByClass(HistoryAddCommandUpdate.class);
hc.removeUpdateByClass(InfoUpdate.class);
hc.removeUpdateByClass(ErrorUpdate.class);