@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
if(isDeprecated())
{
return new UpdateContainer(new ErrorUpdate("PublishRDFCellCommand is currently not supported"));
}
//Worksheet worksheet = workspace.getWorksheet(worksheetId);
// Get the alignment for this worksheet
Alignment alignment = AlignmentManager.Instance().getAlignment(
AlignmentManager.Instance().constructAlignmentId(workspace.getId(),
worksheetId));
if (alignment == null || alignment.isEmpty()) {
logger.info("Alignment is NULL for " + worksheetId);
return new UpdateContainer(
new ErrorUpdate("Worksheet not modeled!"));
}
try {
// Generate the KR2RML data structures for the RDF generation
/*final ErrorReport errorReport = new ErrorReport();
KR2RMLMappingGenerator mappingGen = new KR2RMLMappingGenerator(
workspace, worksheet,
alignment, worksheet.getSemanticTypes(), rdfSourcePrefix, rdfSourceNamespace,
false, errorReport);
KR2RMLMapping mapping = mappingGen.getKR2RMLMapping();
KR2RMLWorksheetRDFGenerator rdfGen = new KR2RMLWorksheetRDFGenerator(worksheet,
workspace.getFactory(), workspace.getOntologyManager(),
pw, mapping, errorReport, false);
// Create empty data structures
Set<String> existingTopRowTriples = new HashSet<String>();
Set<String> predicatesCovered = new HashSet<String>();
Map<String, ReportMessage> predicatesFailed = new HashMap<String, ReportMessage>();
Set<String> predicatesSuccessful = new HashSet<String>();
Node node = workspace.getFactory().getNode(nodeId);
rdfGen.generateTriplesForCell(node, existingTopRowTriples, node.getHNodeId(),
predicatesCovered, predicatesFailed, predicatesSuccessful);*/
return new UpdateContainer(new AbstractUpdate() {
@Override
public void generateJson(String prefix, PrintWriter pw,
VWorkspace vWorkspace) {
JSONObject outputObject = new JSONObject();
try {
outputObject.put(JsonKeys.updateType.name(),
"PublishCellRDFUpdate");
String rdfCellEscapeString = StringEscapeUtils
.escapeHtml(outRdf.toString());
outputObject.put(JsonKeys.cellRdf.name(),
rdfCellEscapeString.replaceAll("\\n", "<br />"));
outputObject.put(JsonKeys.worksheetId.name(),
worksheetId);
pw.println(outputObject.toString(4));
} catch (JSONException e) {
logger.error("Error occured while generating JSON!");
}
}
});
} catch (Exception e) {
return new UpdateContainer(new ErrorUpdate(e.getMessage()));
}
}