Search in sources :

Example 1 with NonRDFAnnotation

use of cbit.vcell.biomodel.meta.NonRDFAnnotation in project vcell by virtualcell.

the class XMLMetaDataWriter method createNonRDFAnnotationElement.

/**
 * creating XMLMetaData element for nonRDFAnnotation element here since nonRDFAnnotation was made package level
 *	this is similar to XMLRDFWriter.createElement(metaData)
 *
 * @return the created NonRDFAnnotationListElement
 */
private static Element createNonRDFAnnotationElement(VCMetaData metaData, IdentifiableProvider identifiableProvider) {
    Set<Map.Entry<Entry, NonRDFAnnotation>> allNonRdfAnnotations = metaData.getAllNonRDFAnnotations();
    Element nonRDFAnnotationListElement = new Element(XMLMetaData.NONRDF_ANNOTATION_LIST_TAG);
    Iterator<Map.Entry<Entry, NonRDFAnnotation>> iter = allNonRdfAnnotations.iterator();
    while (iter.hasNext()) {
        Map.Entry<Entry, NonRDFAnnotation> mapEntry = iter.next();
        Entry openEntry = mapEntry.getKey();
        NonRDFAnnotation nonRDFAnnotation = mapEntry.getValue();
        VCID vcid = identifiableProvider.getVCID(openEntry.getIdentifiable());
        Identifiable identifiable = identifiableProvider.getIdentifiableObject(vcid);
        // only write out nonRDF annotation if identifiable in identifiableProvider is not null
        if (identifiable != null) {
            if (!nonRDFAnnotation.isEmpty()) {
                Element nonRDFAnnotationElement = new Element(XMLMetaData.NONRDF_ANNOTATION_TAG);
                nonRDFAnnotationElement.setAttribute(XMLMetaData.VCID_ATTR_TAG, vcid.toASCIIString());
                nonRDFAnnotationListElement.addContent(nonRDFAnnotationElement);
                String freeTextAnnotation = nonRDFAnnotation.getFreeTextAnnotation();
                if (freeTextAnnotation != null && freeTextAnnotation.length() > 0) {
                    Element freeTextAnnotationElement = new Element(XMLMetaData.FREETEXT_TAG);
                    freeTextAnnotationElement.addContent(new Text(freeTextAnnotation));
                    nonRDFAnnotationElement.addContent(freeTextAnnotationElement);
                }
                Element xhtmlNotes = nonRDFAnnotation.getXhtmlNotes();
                if (xhtmlNotes != null) {
                    // Element notesElement = new Element(XMLMetaData.NOTES_TAG);
                    // notesElement.addContent(xhtmlNotes));
                    nonRDFAnnotationElement.addContent(xhtmlNotes.detach());
                }
                Element[] otherAnnotations = nonRDFAnnotation.getXmlAnnotations();
                if (otherAnnotations != null && otherAnnotations.length > 0) {
                    Element annotationListElement = new Element(XMLMetaData.ANNOTATION_LIST_TAG);
                    nonRDFAnnotationElement.addContent(annotationListElement);
                    for (int i = 0; i < otherAnnotations.length; i++) {
                        annotationListElement.addContent(otherAnnotations[i].detach());
                    }
                }
            }
        }
    }
    return nonRDFAnnotationListElement;
}
Also used : VCID(cbit.vcell.biomodel.meta.VCID) NonRDFAnnotation(cbit.vcell.biomodel.meta.NonRDFAnnotation) Element(org.jdom.Element) Text(org.jdom.Text) Identifiable(org.vcell.util.document.Identifiable) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Map(java.util.Map)

Aggregations

NonRDFAnnotation (cbit.vcell.biomodel.meta.NonRDFAnnotation)1 VCID (cbit.vcell.biomodel.meta.VCID)1 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)1 Map (java.util.Map)1 Element (org.jdom.Element)1 Text (org.jdom.Text)1 Identifiable (org.vcell.util.document.Identifiable)1