Search in sources :

Example 1 with DateQualifier

use of org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier in project vcell by virtualcell.

the class MiriamTreeModel method createTree.

private void createTree() {
    MiriamManager miriamManager = vcMetaData.getMiriamManager();
    TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
    Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> dateMapMap = miriamManager.getDublinCoreDateMap();
    Set<Identifiable> identifiables = vcMetaData.getIdentifiableProvider().getAllIdentifiables();
    TreeSet<Identifiable> sortedIdentifiables = new TreeSet<Identifiable>(new IdentifiableComparator(vcMetaData.getIdentifiableProvider()));
    sortedIdentifiables.addAll(identifiables);
    ((DefaultMutableTreeNode) getRoot()).removeAllChildren();
    for (Identifiable identifiable : sortedIdentifiables) {
        Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
        Map<DateQualifier, Set<DublinCoreDate>> dateMap = dateMapMap.get(identifiable);
        VCID vcid = vcMetaData.getIdentifiableProvider().getVCID(identifiable);
        String modelComponentType = vcid.getClassName();
        String modelComponentName = vcid.getLocalName();
        IdentifiableNode modelComponentNode = new IdentifiableNode(identifiable, modelComponentType + " : " + modelComponentName);
        String freeTextAnnotation = vcMetaData.getFreeTextAnnotation(identifiable);
        if (freeTextAnnotation != null) {
            modelComponentNode.add(new BioModelNode(new Annotation(freeTextAnnotation), false));
        } else {
            modelComponentNode.add(new BioModelNode(new Annotation(""), false));
        }
        if (refGroupMap != null) {
            for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
                MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
                for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                    LinkNode linkNode = new LinkNode(qualifier, miriamResource);
                    modelComponentNode.add(linkNode);
                }
            }
        }
        if (dateMap != null) {
            for (DublinCoreQualifier.DateQualifier qualifier : dateMap.keySet()) {
                Set<DublinCoreDate> dates = dateMap.get(qualifier);
                for (DublinCoreDate date : dates) {
                    modelComponentNode.add(new DateNode(qualifier, date));
                }
            }
        }
        ((DefaultMutableTreeNode) getRoot()).add(modelComponentNode);
    }
}
Also used : IdentifiableComparator(cbit.vcell.biomodel.meta.IdentifiableComparator) MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) Set(java.util.Set) TreeSet(java.util.TreeSet) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) BioModelNode(cbit.vcell.desktop.BioModelNode) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) TreeSet(java.util.TreeSet) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) VCID(cbit.vcell.biomodel.meta.VCID) DublinCoreDate(org.vcell.sybil.models.dublincore.DublinCoreDate) Annotation(cbit.vcell.desktop.Annotation) Identifiable(org.vcell.util.document.Identifiable) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) DublinCoreQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier) TreeMap(java.util.TreeMap) Map(java.util.Map) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier)

Example 2 with DateQualifier

use of org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier in project vcell by virtualcell.

the class VCMetaDataMiriamManager method getDublinCoreDateMap.

// this is not yet cached.
public Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> getDublinCoreDateMap() {
    Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> map = new HashMap<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>>();
    Set<Entry> allEntries = vcMetaData.getRegistry().getAllEntries();
    Graph rdfData = vcMetaData.getRdfData();
    for (Entry entry : allEntries) {
        Resource resource = entry.getResource();
        if (resource != null) {
            Identifiable identifiable = entry.getIdentifiable();
            Map<DateQualifier, Set<DublinCoreDate>> qualifierDateMap = new HashMap<DateQualifier, Set<DublinCoreDate>>();
            for (DublinCoreQualifier.DateQualifier dateQualifier : AnnotationQualifiers.DC_date_all) {
                Set<DublinCoreDate> dateStrings = new HashSet<DublinCoreDate>();
                Iterator<Statement> stmtIter = rdfData.match(resource, dateQualifier.getProperty(), null);
                while (stmtIter.hasNext()) {
                    Statement statement = stmtIter.next();
                    Value dateObject = statement.getObject();
                    if (dateObject instanceof Literal) {
                        Literal dateLiteral = (Literal) dateObject;
                        String dateString = dateLiteral.stringValue();
                        dateStrings.add(new DublinCoreDate(dateString));
                    }
                }
                if (!dateStrings.isEmpty()) {
                    qualifierDateMap.put(dateQualifier, dateStrings);
                }
            }
            if (!qualifierDateMap.isEmpty()) {
                map.put(identifiable, qualifierDateMap);
            }
        }
    }
    return map;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) DublinCoreDate(org.vcell.sybil.models.dublincore.DublinCoreDate) HashMap(java.util.HashMap) Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) Identifiable(org.vcell.util.document.Identifiable) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Graph(org.openrdf.model.Graph) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) DublinCoreQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier) Literal(org.openrdf.model.Literal) Value(org.openrdf.model.Value) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) HashSet(java.util.HashSet)

Aggregations

Map (java.util.Map)2 Set (java.util.Set)2 TreeMap (java.util.TreeMap)2 DublinCoreDate (org.vcell.sybil.models.dublincore.DublinCoreDate)2 DublinCoreQualifier (org.vcell.sybil.models.dublincore.DublinCoreQualifier)2 DateQualifier (org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier)2 Identifiable (org.vcell.util.document.Identifiable)2 IdentifiableComparator (cbit.vcell.biomodel.meta.IdentifiableComparator)1 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)1 MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)1 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)1 VCID (cbit.vcell.biomodel.meta.VCID)1 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)1 Annotation (cbit.vcell.desktop.Annotation)1 BioModelNode (cbit.vcell.desktop.BioModelNode)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 Graph (org.openrdf.model.Graph)1