use of org.hl7.fhir.definitions.generators.specification.W5TurtleGenerator in project kindling by HL7.
the class Publisher method processRDF.
private void processRDF() throws Exception, FileNotFoundException {
// first, process the RIM file
String rim = TextFile.fileToString(Utilities.path(page.getFolders().rootDir, "tools", "tx", "v3", "rim.ttl"));
ByteArrayOutputStream tmp = new ByteArrayOutputStream();
FhirTurtleGenerator ttl = new FhirTurtleGenerator(tmp, page.getDefinitions(), page.getWorkerContext(), page.getValidationErrors());
ttl.executeV3(page.getValueSets(), page.getCodeSystems());
rim = rim + tmp.toString();
TextFile.stringToFile(rim, Utilities.path(page.getFolders().dstDir, "rim.ttl"));
ttl = new FhirTurtleGenerator(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "fhir.ttl")), page.getDefinitions(), page.getWorkerContext(), page.getValidationErrors());
ttl.executeMain();
W5TurtleGenerator w5 = new W5TurtleGenerator(new FileOutputStream(Utilities.path(page.getFolders().dstDir, "w5.ttl")), page.getDefinitions(), page.getWorkerContext(), page.getValidationErrors());
w5.executeMain();
RDFValidator val = new RDFValidator();
val.validate(Utilities.path(page.getFolders().dstDir, "fhir.ttl"));
val.validate(Utilities.path(page.getFolders().dstDir, "rim.ttl"));
val.validate(Utilities.path(page.getFolders().dstDir, "w5.ttl"));
ZipGenerator zip = new ZipGenerator(Utilities.path(page.getFolders().dstDir, "fhir.rdf.ttl.zip"));
zip.addFileName("fhir.ttl", Utilities.path(page.getFolders().dstDir, "fhir.ttl"), false);
zip.addFileName("rim.ttl", Utilities.path(page.getFolders().dstDir, "rim.ttl"), false);
zip.addFileName("w5.ttl", Utilities.path(page.getFolders().dstDir, "w5.ttl"), false);
zip.close();
// now that the RDF is generated, run any sparql rules that have been defined
Element test = loadDom(new FileInputStream(Utilities.path(page.getFolders().srcDir, "sparql-rules.xml")), false).getDocumentElement();
test = XMLUtil.getFirstChild(test);
while (test != null) {
if (test.getNodeName().equals("assertion")) {
String sparql = test.getTextContent();
page.getValidationErrors().addAll(val.assertion(sparql, test.getAttribute("id"), test.getAttribute("rowtype"), test.getAttribute("message"), test.getAttribute("description"), IssueSeverity.fromCode(test.getAttribute("level"))));
}
test = XMLUtil.getNextSibling(test);
}
checkAllOk();
}
Aggregations