public void saveAlignment(Alignment alignment, JSONArray history, String modelFilename, boolean onlyHistory) throws Exception {
long start = System.currentTimeMillis();
String workspaceId = AlignmentManager.Instance().getWorkspaceId(alignment);
String worksheetId = AlignmentManager.Instance().getWorksheetId(alignment);
Worksheet worksheet = workspace.getWorksheet(worksheetId);
if(modelFilename == null && worksheet != null) {
modelFilename = getHistoryFilepath(worksheetId);
}
long end1 = System.currentTimeMillis();
logger.info("Time to get alignment info for saving: " + (end1-start) + "msec");
if (worksheet != null)
alignmentMappingGenerator = new KR2RMLMappingGenerator(workspace, worksheet, alignment,
worksheet.getSemanticTypes(), prefix, namespace, false, history, onlyHistory);
long end2 = System.currentTimeMillis();
logger.info("Time to generate mappings:" + (end2-end1) + "msec");
if (modelFilename != null && !modelFilename.trim().isEmpty())
writeModel(workspace, workspace.getOntologyManager(), alignmentMappingGenerator, worksheet, modelFilename);
logger.info("Alignment for " + workspaceId + ":" + worksheetId + " saved to file: " + modelFilename);
long end3 = System.currentTimeMillis();
logger.info("Time to write to file:" + (end3-end2) + "msec");
}