Search in sources :

Example 6 with Entry

use of cbit.vcell.biomodel.meta.registry.Registry.Entry in project vcell by virtualcell.

the class VCMetaDataMiriamManager method queryAllMiriamRefGroups.

private Map<MiriamRefGroup, MIRIAMQualifier> queryAllMiriamRefGroups(Identifiable identifiable) {
    Entry entry = vcMetaData.getRegistry().getEntry(identifiable);
    if (entry.getResource() == null) {
        return null;
    }
    MIRIAMizer miriamizer = new MIRIAMizer();
    Map<RefGroup, MIRIAMQualifier> allRefGroups = miriamizer.getAllRefGroups(vcMetaData.getRdfData(), entry.getResource());
    Map<MiriamRefGroup, MIRIAMQualifier> wrappedRefGroups = new HashMap<MiriamRefGroup, MIRIAMQualifier>();
    for (RefGroup refGroup : allRefGroups.keySet()) {
        MiriamRefGroup miriamRefGroup = new VCMetaDataMiriamRefGroup(refGroup);
        MIRIAMQualifier miriamQualifier = allRefGroups.get(refGroup);
        wrappedRefGroups.put(miriamRefGroup, miriamQualifier);
    }
    return wrappedRefGroups;
}
Also used : Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) HashMap(java.util.HashMap) MIRIAMizer(org.vcell.sybil.models.miriam.MIRIAMizer) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) RefGroup(org.vcell.sybil.models.miriam.RefGroup)

Example 7 with Entry

use of cbit.vcell.biomodel.meta.registry.Registry.Entry 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)

Example 8 with Entry

use of cbit.vcell.biomodel.meta.registry.Registry.Entry in project vcell by virtualcell.

the class XMLMetaDataWriter method getElement.

public static Element getElement(VCMetaData metaData, IdentifiableProvider identifiableProvider) {
    Element element = new Element(XMLMetaData.VCMETADATA_TAG);
    Element elementRDF = metaData.createElement();
    // add RDF data
    if (elementRDF != null) {
        element.addContent(elementRDF);
    }
    Element elementNonRDFList = createNonRDFAnnotationElement(metaData, identifiableProvider);
    element.addContent(elementNonRDFList);
    // add resource binding table
    Element bindingListElement = new Element(XMLMetaData.URI_BINDING_LIST_TAG);
    Set<Registry.Entry> resources = metaData.getRegistry().getAllEntries();
    for (Registry.Entry entry : resources) {
        VCID vcid = identifiableProvider.getVCID(entry.getIdentifiable());
        Identifiable identifiable = identifiableProvider.getIdentifiableObject(vcid);
        if (identifiable != null && entry.getResource() != null) {
            Element entryElement = new Element(XMLMetaData.URI_BINDING_TAG);
            Resource resource = entry.getResource();
            if (resource != null) {
                entryElement.setAttribute(XMLMetaData.URI_ATTR_TAG, resource.stringValue());
            }
            entryElement.setAttribute(XMLMetaData.VCID_ATTR_TAG, vcid.toASCIIString());
            bindingListElement.addContent(entryElement);
        }
    }
    element.addContent(bindingListElement);
    return element;
}
Also used : VCID(cbit.vcell.biomodel.meta.VCID) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Element(org.jdom.Element) Resource(org.openrdf.model.Resource) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Registry(cbit.vcell.biomodel.meta.registry.Registry) Identifiable(org.vcell.util.document.Identifiable)

Example 9 with Entry

use of cbit.vcell.biomodel.meta.registry.Registry.Entry in project vcell by virtualcell.

the class VCMetaData method getOrCreateNonRDFAnnotation.

private NonRDFAnnotation getOrCreateNonRDFAnnotation(Identifiable identifiable) {
    Entry entry = registry.getEntry(identifiable);
    NonRDFAnnotation nonRDFAnnotation = nonRDFAnnotationMap.get(entry);
    if (nonRDFAnnotation == null) {
        nonRDFAnnotation = new NonRDFAnnotation();
        nonRDFAnnotationMap.put(entry, nonRDFAnnotation);
    }
    return nonRDFAnnotation;
}
Also used : Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry)

Example 10 with Entry

use of cbit.vcell.biomodel.meta.registry.Registry.Entry in project vcell by virtualcell.

the class VCMetaData method getExistingNonRDFAnnotation.

private NonRDFAnnotation getExistingNonRDFAnnotation(Identifiable identifiable) {
    Entry entry = registry.getEntry(identifiable);
    NonRDFAnnotation nonRDFAnnotation = nonRDFAnnotationMap.get(entry);
    return nonRDFAnnotation;
}
Also used : Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry)

Aggregations

Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)12 Identifiable (org.vcell.util.document.Identifiable)6 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Resource (org.openrdf.model.Resource)4 HashMap (java.util.HashMap)3 TreeMap (java.util.TreeMap)3 MIRIAMQualifier (org.vcell.sybil.models.miriam.MIRIAMQualifier)3 MIRIAMizer (org.vcell.sybil.models.miriam.MIRIAMizer)3 RefGroup (org.vcell.sybil.models.miriam.RefGroup)3 VCID (cbit.vcell.biomodel.meta.VCID)2 Registry (cbit.vcell.biomodel.meta.registry.Registry)2 Element (org.jdom.Element)2 Graph (org.openrdf.model.Graph)2 Literal (org.openrdf.model.Literal)2 MIRIAMRef (org.vcell.sybil.models.miriam.MIRIAMRef)2 MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)1 NonRDFAnnotation (cbit.vcell.biomodel.meta.NonRDFAnnotation)1 IdentityHashMap (java.util.IdentityHashMap)1 Set (java.util.Set)1