org.sbml.jsbml.xml.parsers
public class SBMLRDFAnnotationParser extends java.lang.Object implements AnnotationReader, AnnotationWriter
Modifier and Type | Class and Description |
---|---|
(package private) static class |
SBMLRDFAnnotationParser.NODE_COLOR |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CUSTOM_RDF
A Constant
String that is used to store any remaining children
or attributes after having removed the standard SBML RDF elements and attributes. |
private org.apache.log4j.Logger |
logger
Logger to be able to send informative, debug, warning or error messages.
|
static java.lang.String |
RDF_NODE_COLOR
A Constant
String that is used to store a XMLNode
color in the user objects map. |
Constructor and Description |
---|
SBMLRDFAnnotationParser() |
Modifier and Type | Method and Description |
---|---|
private SBMLRDFAnnotationParser.NODE_COLOR |
addColor(SBMLRDFAnnotationParser.NODE_COLOR color1,
SBMLRDFAnnotationParser.NODE_COLOR color2)
Adds the given colors and return the resulting color.
|
private SBMLRDFAnnotationParser.NODE_COLOR |
areValidModifiedDates(java.util.List<XMLNode> modifiedNodes)
Returns a
SBMLRDFAnnotationParser.NODE_COLOR corresponding to the validity of the modified Date s. |
private void |
checkAbout(SBase contextObject)
Checks and Sets about
String , that correspond to the value of the
rdf:about attribute. |
private int |
findFirstNonEmptyTextElementIndex(XMLNode xmlNode)
Return the first child element of type text that is not empty.
|
private int |
getLastIndexOf(XMLNode xmlNode,
java.lang.String elementName,
java.lang.String elementURI) |
private XMLNode |
getOrCreate(XMLNode parent,
int index,
java.lang.String elementName,
java.lang.String elementNamespaceURI,
java.lang.String prefix) |
private XMLNode |
getOrCreate(XMLNode parent,
java.lang.String elementName,
java.lang.String elementNamespaceURI,
java.lang.String prefix) |
private XMLNode |
getOrCreateAfter(XMLNode parent,
java.lang.String elementName,
java.lang.String elementNamespaceURI,
java.lang.String prefix,
java.lang.String precedingElementName,
java.lang.String precedingElementNamespaceURI) |
private XMLNode |
getOrCreateCVTerm(XMLNode parent,
int precedingTermIndex,
java.lang.String elementName,
java.lang.String cvtermURI,
java.lang.String cvtermPrefix,
java.lang.Object customRDFXMLNode) |
private XMLNode |
getOrCreateDescription(XMLNode rdfNode) |
private int |
getTrueIndexOf(XMLNode xmlNode,
java.lang.String elementName,
java.lang.String elementURI,
int index) |
private SBMLRDFAnnotationParser.NODE_COLOR |
isValidCreatedDate(XMLNode createdNode)
Returns a
SBMLRDFAnnotationParser.NODE_COLOR corresponding to the validity of the created Date . |
private SBMLRDFAnnotationParser.NODE_COLOR |
isValidCreator(XMLNode creatorNode)
Returns a
SBMLRDFAnnotationParser.NODE_COLOR corresponding to the validity of the Creator elements
compared to the SBML specifications. |
private SBMLRDFAnnotationParser.NODE_COLOR |
isValidRDF(XMLNode annotationXMLNode)
Returns a
SBMLRDFAnnotationParser.NODE_COLOR corresponding to the validity of the RDF block
compared to the SBML specifications. |
private SBMLRDFAnnotationParser.NODE_COLOR |
isValidRDFDescription(XMLNode rdfNode)
Returns a
SBMLRDFAnnotationParser.NODE_COLOR corresponding to the validity of the RDF Description element
compared to the SBML specifications. |
private SBMLRDFAnnotationParser.NODE_COLOR |
isValidRDFHistory(XMLNode xmlNode)
Returns a
SBMLRDFAnnotationParser.NODE_COLOR corresponding to the validity of the History elements
compared to the SBML specifications. |
private SBMLRDFAnnotationParser.NODE_COLOR |
isValidRDFURIs(XMLNode rdfNode)
Returns a
SBMLRDFAnnotationParser.NODE_COLOR corresponding to the validity of the first bqmodel and bqbiol CVTerm . |
private boolean |
isValidSBMLRDF(SBase contextObject)
Returns true if the SBML RDF block is recognized as valid or partially valid.
|
private SBMLRDFAnnotationParser.NODE_COLOR |
isValidVCard(XMLNode xmlNode)
Returns
SBMLRDFAnnotationParser.NODE_COLOR.GREEN if at least one of these three nodes is present: vCard:N, vCard:EMAIL or vCard:ORG,
meaning that we consider that the VCard is at least partially defined. |
void |
processAnnotation(SBase contextObject)
Process the annotation of the given
SBase object. |
private void |
readCreatedDate(SBase contextSBase,
XMLNode createdNode)
Reads the 'dcterms:created' part of the SBML RDF annotation into a java
Date . |
private void |
readCreator(SBase contextSBase,
XMLNode creatorNode)
Reads the 'dc:creator' part of the SBML RDF annotation into
Creator s. |
private void |
readModifiedDate(SBase contextSBase,
XMLNode modifiedNode)
Reads the 'dcterms:modified' part of the SBML RDF annotation into java
Date (s). |
private void |
readRDFHistory(SBase contextSBase,
XMLNode descriptionNode)
Reads the 'rdf:Description' to extract the
History part of the SBML RDF annotation. |
private void |
readRDFURIs(SBase contextSBase,
XMLNode descriptionNode)
Reads the relation elements part of the SBML RDF annotation into
CVTerm s. |
private void |
readSBMLRDF(SBase contextObject)
Reads the 'rdf:RDF' block, if present in the
Annotation , to extract the History and the
CVTerm (s) as defined in the SBML specifications, section 6: 'A standard format for the annotation element'. |
private boolean |
removeXmlNodeIfEmpty(XMLNode xmlNode)
Removes an
XMLNode from its parent if it has no child elements, no attributes
and no namespaces declared any more. |
XMLNode |
writeAnnotation(SBase contextObject,
XMLNode xmlNode)
|
private void |
writeCreators(History history,
XMLNode descriptionNode) |
private void |
writeDates(History history,
XMLNode descriptionNode) |
private void |
writeHistory(SBase contextObject,
XMLNode descriptionNode) |
private XMLNode |
writeSBMLRDF(SBase contextObject,
XMLNode annotationXMLNode) |
private void |
writeURIs(SBase contextObject,
XMLNode descriptionNode) |
public static final java.lang.String RDF_NODE_COLOR
String
that is used to store a XMLNode
color in the user objects map.public static final java.lang.String CUSTOM_RDF
String
that is used to store any remaining children
or attributes after having removed the standard SBML RDF elements and attributes.
It is stored as an XMLNode
in the user objects map.
private org.apache.log4j.Logger logger
public XMLNode writeAnnotation(SBase contextObject, XMLNode xmlNode)
AnnotationWriter
SBase
object into the given
XMLNode
.
This method can change the content of the XMLNode
by
removing or adding nodes.
writeAnnotation
in interface AnnotationWriter
public void processAnnotation(SBase contextObject)
AnnotationReader
SBase
object.
This method can change the content of the annotation XMLNode
by
removing or adding nodes.processAnnotation
in interface AnnotationReader
private boolean isValidSBMLRDF(SBase contextObject)
Additional elements are allowed but
what is defined in the SBML specifications should be there as well. It means that the
RDF element needs to have the color SBMLRDFAnnotationParser.NODE_COLOR.GREEN
or SBMLRDFAnnotationParser.NODE_COLOR.ORANGE
.
contextObject
- - the SBase
where we want to check the Annotation
.private SBMLRDFAnnotationParser.NODE_COLOR isValidRDF(XMLNode annotationXMLNode)
SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the RDF block
compared to the SBML specifications.annotationXMLNode
- - the top level XMLNode
from the Annotation
.SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the RDF block.private SBMLRDFAnnotationParser.NODE_COLOR isValidRDFDescription(XMLNode rdfNode)
SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the RDF Description element
compared to the SBML specifications.rdfNode
- - the rdf:RDF XMLNode
from the Annotation
.SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the RDF Description element.private SBMLRDFAnnotationParser.NODE_COLOR addColor(SBMLRDFAnnotationParser.NODE_COLOR color1, SBMLRDFAnnotationParser.NODE_COLOR color2)
color1
- - the first SBMLRDFAnnotationParser.NODE_COLOR
color2
- - the second SBMLRDFAnnotationParser.NODE_COLOR
private SBMLRDFAnnotationParser.NODE_COLOR isValidRDFHistory(XMLNode xmlNode)
SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the History
elements
compared to the SBML specifications.rdfNode
- - the rdf:RDF XMLNode
from the Annotation
.SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the History
elements.private SBMLRDFAnnotationParser.NODE_COLOR isValidCreator(XMLNode creatorNode)
SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the Creator
elements
compared to the SBML specifications.creatorNode
- - the dc:Creator XMLNode
from the RDF block.SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the Creator
elements.private SBMLRDFAnnotationParser.NODE_COLOR isValidVCard(XMLNode xmlNode)
SBMLRDFAnnotationParser.NODE_COLOR.GREEN
if at least one of these three nodes is present: vCard:N, vCard:EMAIL or vCard:ORG,
meaning that we consider that the VCard is at least partially defined.
The color is never SBMLRDFAnnotationParser.NODE_COLOR.ORANGE
as we do not check at the moment for any additional elements
or attributes or for the proper structure of the vCard:N or vCard:ORG elements.
The reading and writing should work fine whatever the content of the rdf:li element.
xmlNode
- - the rdf:li XMLNode
from the dc:creator block.SBMLRDFAnnotationParser.NODE_COLOR.GREEN
if at least one of these three nodes is present: vCard:N, vCard:EMAIL or vCard:ORG.private SBMLRDFAnnotationParser.NODE_COLOR areValidModifiedDates(java.util.List<XMLNode> modifiedNodes)
SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the modified Date
s.
The color of one dcterms:modified element is never SBMLRDFAnnotationParser.NODE_COLOR.ORANGE
as we do not check at
the moment for any additional elements or attributes. If the dcterms:modified element contain the dcterms:W3CDTF
child element then it's color is SBMLRDFAnnotationParser.NODE_COLOR.GREEN
, otherwise it is SBMLRDFAnnotationParser.NODE_COLOR.WHITE
.
The reading and writing should work fine whatever the content of the dcterms:modified elements.
modifiedNodes
- - the dcterms:modified XMLNode
s from the rdf:Description block.SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the modified Date
s.private SBMLRDFAnnotationParser.NODE_COLOR isValidCreatedDate(XMLNode createdNode)
SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the created Date
.
The color of the dcterms:created element is never SBMLRDFAnnotationParser.NODE_COLOR.ORANGE
as we do not check at
the moment for any additional elements or attributes. If the dcterms:created element contain the dcterms:W3CDTF
child element then it's color is SBMLRDFAnnotationParser.NODE_COLOR.GREEN
, otherwise it is SBMLRDFAnnotationParser.NODE_COLOR.WHITE
.
The reading and writing should work fine whatever the content of the dcterms:created element.
createdNode
- - the dcterms:created XMLNode
from the rdf:Description block.SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the created Date
private SBMLRDFAnnotationParser.NODE_COLOR isValidRDFURIs(XMLNode rdfNode)
SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the first bqmodel and bqbiol CVTerm
.
The color of the relation elements is never SBMLRDFAnnotationParser.NODE_COLOR.ORANGE
as we do not check at
the moment for any additional elements or attributes. If the bqmodel:* or bqbiol:* elements
contain a rdf:Bag that contain at least one rdf:li, then we consider the XMLNode to be
at least partially valid and return SBMLRDFAnnotationParser.NODE_COLOR.GREEN
. Otherwise we return SBMLRDFAnnotationParser.NODE_COLOR.WHITE
.
The reading and writing should work fine whatever the content of the bqmodel:* or bqbiol:* element.
rdfNode
- - the rdf:Description XMLNode
from the RDF block.SBMLRDFAnnotationParser.NODE_COLOR
corresponding to the validity of the first bqmodel and bqbiol CVTerm
.private void readSBMLRDF(SBase contextObject)
Annotation
, to extract the History
and the
CVTerm
(s) as defined in the SBML specifications, section 6: 'A standard format for the annotation element'.
This method will remove, from the XMLNode tree, all known elements and attributes. Any additional attributes or
elements inside the RDF block are stored as a userObject with the key CUSTOM_RDF
.
Different parts of the XMLNode tree are stored in different objects. The additional XML from dc:creator/rdf:Bag/rdf:li
are stored in each corresponding Creator
. The additional XML from any of the relation elements (bqmodel:* and bqbiol:*)
are stored in each corresponding CVTerm
. All the rest is stored on the Annotation
object.
private void readRDFHistory(SBase contextSBase, XMLNode descriptionNode)
History
part of the SBML RDF annotation.private void readModifiedDate(SBase contextSBase, XMLNode modifiedNode)
Date
(s).private int findFirstNonEmptyTextElementIndex(XMLNode xmlNode)
xmlNode
- private void readCreatedDate(SBase contextSBase, XMLNode createdNode)
Date
.private void readCreator(SBase contextSBase, XMLNode creatorNode)
Creator
s.private void readRDFURIs(SBase contextSBase, XMLNode descriptionNode)
CVTerm
s.private boolean removeXmlNodeIfEmpty(XMLNode xmlNode)
XMLNode
from its parent if it has no child elements, no attributes
and no namespaces declared any more.xmlNode
- private XMLNode writeSBMLRDF(SBase contextObject, XMLNode annotationXMLNode)
contextObject
- private void checkAbout(SBase contextObject)
String
, that correspond to the value of the
rdf:about attribute.
A metaid is created and set if it was not set before.
contextObject
- private XMLNode getOrCreateDescription(XMLNode rdfNode)
annotationXMLNode
- private XMLNode getOrCreate(XMLNode parent, java.lang.String elementName, java.lang.String elementNamespaceURI, java.lang.String prefix)
parent
- elementName
- elementNamespaceURI
- prefix
- private XMLNode getOrCreateAfter(XMLNode parent, java.lang.String elementName, java.lang.String elementNamespaceURI, java.lang.String prefix, java.lang.String precedingElementName, java.lang.String precedingElementNamespaceURI)
parent
- elementName
- elementNamespaceURI
- prefix
- precedingElementName
- precedingElementNamespaceURI
- private XMLNode getOrCreate(XMLNode parent, int index, java.lang.String elementName, java.lang.String elementNamespaceURI, java.lang.String prefix)
parent
- elementName
- elementNamespaceURI
- prefix
- private XMLNode getOrCreateCVTerm(XMLNode parent, int precedingTermIndex, java.lang.String elementName, java.lang.String cvtermURI, java.lang.String cvtermPrefix, java.lang.Object customRDFXMLNode)
parent
- precedingTermIndex
- elementName
- cvtermURI
- cvtermPrefix
- customRDFXMLNode
- private int getLastIndexOf(XMLNode xmlNode, java.lang.String elementName, java.lang.String elementURI)
xmlNode
- elementName
- elementURI
- private int getTrueIndexOf(XMLNode xmlNode, java.lang.String elementName, java.lang.String elementURI, int index)
xmlNode
- elementName
- elementURI
- index
- private void writeHistory(SBase contextObject, XMLNode descriptionNode)
contextObject
- descriptionNode
- private void writeDates(History history, XMLNode descriptionNode)
contextObject
- descriptionNode
- private void writeCreators(History history, XMLNode descriptionNode)
history
- descriptionNode
-