String rdfPrefix = rdfNamespaces.get(Annotation.URI_RDF_SYNTAX_NS);
String whiteSpace = createIndentationString(indent);
for (int i = 0; i < listOfCVTerms.size(); i++)
{
CVTerm cvTerm = listOfCVTerms.get(i);
String namespaceURI = null;
String prefix = null;
String elementName = null;
if (cvTerm == null || cvTerm.getResourceCount() == 0)
{
// No need to write a CVTerm without any resources/uris
continue;
}
if (cvTerm.getQualifierType().equals(CVTerm.Type.BIOLOGICAL_QUALIFIER)) {
namespaceURI = CVTerm.Type.BIOLOGICAL_QUALIFIER.getNamespaceURI();
prefix = rdfNamespaces.get(namespaceURI);
elementName = cvTerm.getBiologicalQualifierType()
.getElementNameEquivalent();
} else if (cvTerm.getQualifierType().equals(CVTerm.Type.MODEL_QUALIFIER)) {
namespaceURI = cvTerm.getQualifierType().getNamespaceURI();
prefix = rdfNamespaces.get(namespaceURI);
elementName = Annotation
.getElementNameEquivalentToQualifier(cvTerm
.getModelQualifierType());
}
if ((namespaceURI != null) && (elementName != null)
&& (prefix != null))
{
writer.writeCharacters(whiteSpace + createIndentationString(indentCount));
writer.writeStartElement(prefix, elementName, namespaceURI);
writer.writeCharacters("\n");
if (cvTerm.getResourceCount() > 0) {
writer.writeCharacters(whiteSpace + createIndentationString(2 * indentCount));
writer.writeStartElement(rdfPrefix, "Bag",
Annotation.URI_RDF_SYNTAX_NS);
writer.writeCharacters("\n");
for (int j = 0; j < cvTerm.getResourceCount(); j++) {
writer.writeCharacters(whiteSpace + createIndentationString(3 * indentCount));
writer.writeStartElement(rdfPrefix, "li",
Annotation.URI_RDF_SYNTAX_NS);
writer.writeAttribute(rdfPrefix,
Annotation.URI_RDF_SYNTAX_NS, "resource",
cvTerm.getResourceURI(j));
writer.writeEndElement();
writer.writeCharacters("\n");
}
writer.writeCharacters(whiteSpace + createIndentationString(2 * indentCount));
writer.writeEndElement();