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);
hc.removeUpdateByClass(AlignmentSVGVisualizationUpdate.class);
c.append(hc);
}
alignment = alignMgr.getAlignment(workspace.getId(), worksheetId);
if(alignment != null)
c.add(new AlignmentSVGVisualizationUpdate(worksheetId, alignment));
} catch (Exception e) {
String msg = "Error occured while applying history!";
logger.error(msg, e);