final String jsonContextFileLocalPath = ServletContextParameterMap.getParameterValue(ContextParameter.JSON_PUBLISH_DIR) + contextName;
PrintWriter printWriter;
try {
printWriter = new PrintWriter(jsonFileLocalPath);
String baseURI = worksheet.getMetadataContainer().getWorksheetProperties().getPropertyValue(Property.baseURI);
JSONKR2RMLRDFWriter writer = new JSONKR2RMLRDFWriter(printWriter, baseURI);
if (contextJSON != null && !contextJSON.isEmpty()) {
JSONObject context = new JSONObject();
try {
context = new JSONObject(this.contextJSON);
}catch(Exception e)
{
}
PrintWriter pw = new PrintWriter(jsonContextFileLocalPath);
pw.println(context.toString(4));
pw.close();
StringBuilder url = new StringBuilder();
url.append(ServletContextParameterMap.getParameterValue(ContextParameter.JETTY_HOST));
url.append(":");
url.append(ServletContextParameterMap.getParameterValue(ContextParameter.JETTY_PORT));
url.append("/");
url.append(ServletContextParameterMap.getParameterValue(ContextParameter.JSON_PUBLISH_RELATIVE_DIR));
url.append(contextName);
writer.setGlobalContext(context, new ContextIdentifier(context.toString(), new URL(url.toString())));
}
writer.addPrefixes(mapping.getPrefixes());
RootStrategy strategy = new UserSpecifiedRootStrategy(rootTriplesMapId, new SteinerTreeRootStrategy(new WorksheetDepthRootStrategy()));
KR2RMLWorksheetRDFGenerator generator = new KR2RMLWorksheetRDFGenerator(worksheet, f, ontMgr, writer, false, strategy, mapping, errorReport, selection);
try {
generator.generateRDF(true);
logger.info("RDF written to file.");