Search in sources :

Example 51 with Resource

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

the class OntologyInfo method writeSuperClasses.

public static void writeSuperClasses(Graph graph, PrintStream out, Resource resource) {
    Iterator<Statement> iter = graph.match(resource, RDFS.SUBCLASSOF, 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("  Is sub class of: " + resourcesToString(resources));
    }
}
Also used : Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource) Value(org.openrdf.model.Value) HashSet(java.util.HashSet)

Example 52 with Resource

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

the class OntSpecUtil method findMissingComment.

public static Set<Resource> findMissingComment(Graph schema) {
    Set<Resource> resources = new HashSet<Resource>();
    for (Statement statement : schema) {
        Resource subject = statement.getSubject();
        if (isMissingComment(schema, subject)) {
            resources.add(subject);
        }
        URI predicate = statement.getPredicate();
        if (isMissingComment(schema, predicate)) {
            resources.add(predicate);
        }
        ;
        Value object = statement.getObject();
        if (isMissingComment(schema, object)) {
            resources.add((Resource) object);
        }
    }
    return resources;
}
Also used : Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource) Value(org.openrdf.model.Value) URI(org.openrdf.model.URI) HashSet(java.util.HashSet)

Example 53 with Resource

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

the class Model2JDOM method addModel.

public void addModel(Graph model, String baseURI) {
    for (Statement statement : model) {
        Resource subject = statement.getSubject();
        Element elementS = addSubjectElement(model, subject, root);
        URI predicate = statement.getPredicate();
        Element elementP = createPredicateElement(predicate);
        Value object = statement.getObject();
        if (object instanceof Resource) {
            Resource objectR = (Resource) object;
            if (!isTypeSetAsName(elementS, subject, predicate, object)) {
                elementS.addContent(elementP);
                addObjectElement(model, objectR, elementP);
            }
        } else {
            elementS.addContent(elementP);
            Literal objectL = (Literal) object;
            elementP.addContent(new Text(objectL.stringValue()));
            URI dataTypeURI = objectL.getDatatype();
            if (dataTypeURI != null) {
                elementP.setAttribute("datatype", dataTypeURI.stringValue(), nsRDF);
            }
            String languageTag = objectL.getLanguage();
            if (languageTag != null) {
                elementP.setAttribute("lang", languageTag, Namespace.XML_NAMESPACE);
            }
        }
    }
}
Also used : Statement(org.openrdf.model.Statement) Element(org.jdom.Element) Literal(org.openrdf.model.Literal) Resource(org.openrdf.model.Resource) Value(org.openrdf.model.Value) Text(org.jdom.Text) URI(org.openrdf.model.URI)

Example 54 with Resource

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

the class MIRIAMizer method newRefGroup.

public RefGroup newRefGroup(Graph graph, Resource resource, MIRIAMQualifier qualifier) {
    Resource bag = graph.getValueFactory().createBNode();
    graph.add(bag, RDF.TYPE, RDF.BAG);
    graph.add(resource, qualifier.getProperty(), bag);
    RefGroup group = new RefGroup(bag);
    return group;
}
Also used : Resource(org.openrdf.model.Resource)

Example 55 with Resource

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

the class MIRIAMizer method getRefGroups.

public Set<RefGroup> getRefGroups(Graph graph, Resource resource, MIRIAMQualifier qualifier) {
    Set<RefGroup> groups = new HashSet<RefGroup>();
    Iterator<Statement> iter = graph.match(resource, qualifier.getProperty(), null);
    while (iter.hasNext()) {
        Statement statement = iter.next();
        Value node = statement.getObject();
        if (node instanceof Resource) {
            groups.add(new RefGroup((Resource) node));
        }
    }
    return groups;
}
Also used : Statement(org.openrdf.model.Statement) Value(org.openrdf.model.Value) Resource(org.openrdf.model.Resource) HashSet(java.util.HashSet)

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