use of org.openrdf.model.Resource in project vcell by virtualcell.
the class RefGroup method remove.
public RefGroup remove(Graph graph, MIRIAMRef ref) {
Resource resourceRef = graph.getValueFactory().createURI(ref.urn());
Iterator<Statement> stmtIter = graph.match(getResource(), null, resourceRef);
while (stmtIter.hasNext()) {
stmtIter.next();
stmtIter.remove();
}
return this;
}
use of org.openrdf.model.Resource in project vcell by virtualcell.
the class RefGroup method contains.
public boolean contains(Graph graph, MIRIAMRef ref) {
Resource rRef = graph.getValueFactory().createURI(ref.urn());
Statement statement = graph.getValueFactory().createStatement(getResource(), RDF.LI, rRef);
return graph.contains(statement);
}
use of org.openrdf.model.Resource in project vcell by virtualcell.
the class RefGroup method add.
public RefGroup add(Graph graph, MIRIAMRef ref) {
Resource rRef = graph.getValueFactory().createURI(ref.urn());
graph.add(getResource(), RDF.LI, rRef);
return this;
}
use of org.openrdf.model.Resource in project vcell by virtualcell.
the class SBMLAnnotationUtil method writeAnnotation.
public void writeAnnotation(Identifiable identifiable, SBase sBase, Element vcellImportRelatedElement) throws XMLStreamException {
// Deal with RDF annotation
XMLNode rootAnnotation = new XMLNode(tripleAnnotation, new XMLAttributes());
Resource resource = metaData.getRegistry().getEntry(identifiable).getResource();
Graph rdfChunk = null;
if (resource != null) {
rdfChunk = chopper.getChops().get(resource);
}
if (identifiable == root && rdfChunk != null) {
rdfChunk.addAll(chopper.getRemains());
}
XMLNode rootRDF = null;
if (rdfChunk != null && metaData.getBaseURIExtended() != null) {
Element element = XMLRDFWriter.createElement(rdfChunk, nsSBML);
XMLNamespaces xmlnss = new XMLNamespaces();
xmlnss.add(DefaultNameSpaces.RDF.uri, DefaultNameSpaces.RDF.prefix);
rootRDF = XMLNode.convertStringToXMLNode(XmlUtil.xmlToString(element), xmlnss);
}
if (rootRDF != null && rootRDF.getNumChildren() > 0) {
rootAnnotation.addChild(rootRDF);
}
// Deal with the non-RDF; VCell free-text annotations
// get free text annotation from NonRDFAnnotation (associated with identifiable); create XMLNode
XMLNode rootVCellInfo = new XMLNode(tripleVCellInfo, new XMLAttributes());
rootVCellInfo.addNamespace(XMLTags.SBML_VCELL_NS, XMLTags.VCELL_NS_PREFIX);
String freeTextStr = metaData.getFreeTextAnnotation(identifiable);
if (freeTextStr != null && freeTextStr.length() > 0) {
XMLNode contentFreeText = new XMLNode(freeTextStr);
XMLNode rootFreeText = new XMLNode(tripleFreeText, new XMLAttributes());
rootFreeText.addChild(contentFreeText);
rootVCellInfo.addChild(rootFreeText);
}
// VCell specific info to be exported to SBML as annotation - used for import, not needed for metadata
if (vcellImportRelatedElement != null) {
XMLNode xn = elementToXMLNode(vcellImportRelatedElement);
if (xn != null) {
xn.removeNamespace(XMLTags.VCELL_NS_PREFIX);
rootVCellInfo.addChild(xn);
}
}
if (rootVCellInfo.getNumChildren() > 0) {
rootAnnotation.addChild(rootVCellInfo);
}
// Deal with the non-RDF (other tool-related?) annotation
Element[] elementsXML = metaData.getXmlAnnotations(identifiable);
if (elementsXML != null) {
for (Element elementXML : elementsXML) {
XMLTriple tripleXML = new XMLTriple(elementXML.getName(), elementXML.getNamespaceURI(), elementXML.getNamespacePrefix());
XMLNode contentXML = elementToXMLNode(elementXML);
XMLNode rootXML = new XMLNode(tripleXML, new XMLAttributes());
rootXML.addChild(contentXML);
rootAnnotation.addChild(rootXML);
}
}
if (rootAnnotation.getNumChildren() > 0) {
sBase.setAnnotation(rootAnnotation);
}
writeMetaID(identifiable, sBase);
}
use of org.openrdf.model.Resource in project vcell by virtualcell.
the class SBMLAnnotationUtil method writeMetaID.
public void writeMetaID(Identifiable identifiable, SBase sBase) {
Resource resource = metaData.getRegistry().getEntry(identifiable).getResource();
if (resource != null) {
Resource mappedResource = namespaceAssimilator.map(resource);
if (mappedResource instanceof URI) {
String metaID = ((URI) mappedResource).getLocalName();
sBase.setMetaId(metaID);
}
}
}
Aggregations