use of org.sbml.jsbml.xml.XMLAttributes 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);
}
Aggregations