}
@Override
public UpdateContainer undoIt(Workspace workspace) {
UpdateContainer c = new UpdateContainer();
Worksheet worksheet = workspace.getWorksheet(worksheetId);
OntologyManager ontologyManager = workspace.getOntologyManager();
if(ontologyManager.isEmpty())
return new UpdateContainer(new ErrorUpdate("No ontology loaded."));
String alignmentId = AlignmentManager.Instance().constructAlignmentId(workspace.getId(), worksheetId);
Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
if (alignment == null) {
logger.info("Alignment is NULL for " + worksheetId);
return new UpdateContainer(new ErrorUpdate(
"Please align the worksheet before generating R2RML Model!"));
}
// Set<ColumnNode> alignmentColumnNodes = alignment.getSourceColumnNodes();
// if (alignmentColumnNodes != null) {
// for (ColumnNode cn : alignmentColumnNodes) {
// if (!cn.hasUserType())
// worksheet.getSemanticTypes().unassignColumnSemanticType(cn.getHNodeId());
// }
// }
alignment = initialAlignment;
alignment.setGraph(initialGraph);
if(!this.isExecutedInBatch())
alignment.align();
AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment);
try {
// Save the semantic types in the input parameter JSON
saveSemanticTypesInformation(worksheet, workspace, worksheet.getSemanticTypes().getListOfTypes());
// Add the visualization update
c.add(new SemanticTypesUpdate(worksheet, worksheetId, alignment));
c.add(new AlignmentSVGVisualizationUpdate(
worksheetId, alignment));
} catch (Exception e) {
logger.error("Error occured while generating the model Reason:.", e);
return new UpdateContainer(new ErrorUpdate(
"Error occured while generating the model for the source."));
}
c.add(new TagsUpdate());
return c;
}