Search in sources :

Example 46 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class VCMetaDataMiriamManager method setPrettyName.

public void setPrettyName(MiriamResource miriamResource, String prettyName) {
    ValueFactory valueFactory = vcMetaData.getRdfData().getValueFactory();
    Resource resource = valueFactory.createURI(miriamResource.getMiriamURN());
    Literal prettyNameLiteral = valueFactory.createLiteral(prettyName);
    vcMetaData.getRdfData().add(resource, ProtegeDC.description, prettyNameLiteral);
}
Also used : Literal(org.openrdf.model.Literal) Resource(org.openrdf.model.Resource) ValueFactory(org.openrdf.model.ValueFactory)

Example 47 with Resource

use of org.openrdf.model.Resource 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)

Example 48 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class Registry method compareEquals.

public boolean compareEquals(Registry other) {
    Set<Resource> resSet = resourceToEntry.keySet();
    Set<Resource> otherResSet = other.resourceToEntry.keySet();
    if (!resSet.equals(otherResSet)) {
        return false;
    }
    for (Resource res : resSet) {
        Entry oe = resourceToEntry.get(res);
        Entry otherOe = other.resourceToEntry.get(res);
        final VCID vcid = identifiableProvider.getVCID(oe.getIdentifiable());
        final VCID otherVcid = other.identifiableProvider.getVCID(otherOe.getIdentifiable());
        if (!vcid.toASCIIString().equals(otherVcid.toASCIIString())) {
            return false;
        }
    }
    return true;
}
Also used : VCID(cbit.vcell.biomodel.meta.VCID) Resource(org.openrdf.model.Resource)

Example 49 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class OntologyInfo method writeHasObjectProperty.

public static void writeHasObjectProperty(Graph graph, PrintStream out, Resource resource, URI property, String intro) {
    Iterator<Statement> iter = graph.match(resource, property, null);
    Set<Resource> resources = new HashSet<Resource>();
    while (iter.hasNext()) {
        Value superClassNode = iter.next().getObject();
        if (superClassNode instanceof Resource) {
            resources.add((Resource) superClassNode);
        }
    }
    if (resources.size() > 0) {
        out.println("  " + intro + ": " + resourcesToString(resources));
    }
}
Also used : Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource) Value(org.openrdf.model.Value) HashSet(java.util.HashSet)

Example 50 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class OntologyInfo method resourcesToString.

public static String resourcesToString(Set<Resource> resources) {
    String string = "";
    boolean isFirst = true;
    for (Resource resource : resources) {
        if (resource instanceof URI) {
            URI uri = (URI) resource;
            String localName = uri.getLocalName();
            if (localName != null && localName != "") {
                if (isFirst) {
                    string = localName;
                    isFirst = false;
                } else {
                    string = string + ", " + localName;
                }
            }
        }
    }
    return string;
}
Also used : Resource(org.openrdf.model.Resource) URI(org.openrdf.model.URI)

Aggregations

Resource (org.openrdf.model.Resource)60 Statement (org.openrdf.model.Statement)22 URI (org.openrdf.model.URI)20 Value (org.openrdf.model.Value)17 HashSet (java.util.HashSet)14 Graph (org.openrdf.model.Graph)7 Literal (org.openrdf.model.Literal)6 SailConnection (org.openrdf.sail.SailConnection)5 SailException (org.openrdf.sail.SailException)5 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 NotifyingSailConnection (org.openrdf.sail.NotifyingSailConnection)4 Map (java.util.Map)3 Set (java.util.Set)3 Element (org.jdom.Element)3 HashGraph (org.sbpax.impl.HashGraph)3 VCID (cbit.vcell.biomodel.meta.VCID)2 Registry (cbit.vcell.biomodel.meta.registry.Registry)2 Edge (com.tinkerpop.blueprints.Edge)2