in taverna-scufl2-annotation/src/main/java/org/apache/taverna/scufl2/annotation/AnnotationTools.java [67:111]
public Dataset annotationDatasetFor(Child<?> workflowBean) {
Dataset dataset = DatasetFactory.createMem();
for (Annotation ann : scufl2Tools.annotationsFor(workflowBean)) {
WorkflowBundle bundle = ann.getParent();
URI annUri = uritools.uriForBean(ann);
String bodyUri = bundle.getGlobalBaseURI().resolve(ann.getBody())
.toASCIIString();
if (ann.getBody().isAbsolute()) {
logger.info("Skipping absolute annotation body URI: "
+ ann.getBody());
// TODO: Optional loading of external annotation bodies
continue;
}
String path = ann.getBody().getPath();
ResourceEntry resourceEntry = bundle.getResources()
.getResourceEntry(path);
if (resourceEntry == null) {
logger.warning("Can't find annotation body: " + path);
continue;
}
String contentType = resourceEntry.getMediaType();
Lang lang = RDFLanguages.contentTypeToLang(contentType);
if (lang == null) {
lang = RDFLanguages.filenameToLang(path);
}
if (lang == null) {
logger.warning("Can't find media type of annotation body: "
+ ann.getBody());
continue;
}
Model model = ModelFactory.createDefaultModel();
try (InputStream inStream = bundle.getResources()
.getResourceAsInputStream(path)) {
RDFDataMgr.read(model, inStream, bodyUri, lang);
} catch (IOException e) {
logger.warning("Can't read annotation body: " + path);
continue;
}
dataset.addNamedModel(annUri.toString(), model);
}
return dataset;
}