Java 类com.hp.hpl.jena.rdf.model.Selector 实例源码

项目:CarbonDB-reasoner    文件:GroupRepo.java   
protected DimensionSet getGroupDimSet(Resource groupResource) throws EmptyDimensionException, NotFoundException {
    Selector selector = new SimpleSelector(groupResource, Datatype.hasDimension, (RDFNode) null);
    StmtIterator iter = model.listStatements( selector );

    DimensionSet dimSet = new DimensionSet();
    if (iter.hasNext()) {
        while (iter.hasNext()) {
            Statement s = iter.nextStatement();
            Resource dimensionResource = s.getObject().asResource();
            Dimension dim = CarbonOntology.getInstance().getDimension(getId(dimensionResource));
            dimSet.add(dim);
            if (groupResource.hasProperty(Datatype.hasHorizontalDimension, dimensionResource)) {
                dimSet.setDimensionOrientation(dim, Orientation.HORIZONTAL);
            }
            else if (groupResource.hasProperty(Datatype.hasVerticalDimension, dimensionResource)) {
                dimSet.setDimensionOrientation(dim, Orientation.VERTICAL);
            }
        }
    }
    return dimSet;
}
项目:CarbonDB-reasoner    文件:SingleElementRepo.java   
protected TreeSet<Keyword> getElementKeywords(Resource elementResource) throws MalformedOntologyException {
    Selector selector = new SimpleSelector(elementResource, Datatype.hasTag, (RDFNode) null);
    StmtIterator iter = model.listStatements(selector);

    TreeSet<Keyword> keywords = new TreeSet<>();
    if (iter.hasNext()) {
        while (iter.hasNext()) {
            Statement s = iter.nextStatement();
            keywords.add(RepoFactory.getKeywordRepo().getKeyword(s.getObject().asResource()));
        }
    }
    else {
        throw new MalformedOntologyException("The element " + elementResource + " has no keyword");
    }
    return keywords;
}
项目:redefer-rdf2svg    文件:RenderRDF.java   
private Model runInference(Model data, URL rules, int lineLength, int maxLineLength) throws IOException
{   
    Reasoner reasoner = new GenericRuleReasoner(Rule.rulesFromURL(rules.toString()));
    InfModel inf = ModelFactory.createInfModel(reasoner, data);

    // Break long literals (more than lineLength chars) using carriage returns
    Model remove = ModelFactory.createDefaultModel();
    Model add = ModelFactory.createDefaultModel();
    Selector sel = new SimpleSelector(null, null, (String)null);
    for(StmtIterator sIt = inf.listStatements(sel); sIt.hasNext();)
    {
        Statement s = sIt.nextStatement();
        if(!s.getObject().isLiteral())
            continue;
        String l = s.getString();

        String lp = paginate(l, lineLength, maxLineLength);
        if (lp.length() != l.length())
        {
            remove.add(s);
            add.add(s.getSubject(), s.getPredicate(), lp, s.getLanguage());
        }
    }

    inf.remove(remove);
    inf.add(add);

    return inf;
}
项目:CarbonDB-reasoner    文件:GroupRepo.java   
protected TreeSet<Keyword> getGroupCommonKeywords(Resource groupResource) {
    Selector selector = new SimpleSelector(groupResource, Datatype.hasCommonTag, (RDFNode) null);
    StmtIterator iter = model.listStatements( selector );

    TreeSet<Keyword> keywords = new TreeSet<>();
    if (iter.hasNext()) {
        while (iter.hasNext()) {
            Statement s = iter.nextStatement();
            keywords.add(RepoFactory.getKeywordRepo().getKeyword(s.getObject().asResource()));
        }
    }
    return keywords;
}
项目:CarbonDB-reasoner    文件:RelationRepo.java   
public HashSet<RelationType> getRelationTypes()
{
    Selector selector = new SimpleSelector(null, RDF.type, Datatype.RelationType);
    StmtIterator iter = model.listStatements(selector);

    HashSet<RelationType> types = new HashSet<>();
    if (iter.hasNext()) {
        while (iter.hasNext()) {
            Statement s = iter.nextStatement();
            types.add(getRelationType(s.getSubject()));
        }
    }
    return types;
}
项目:CarbonDB-reasoner    文件:ReferenceRepo.java   
public HashMap<String, Reference> getReferences() {
    Selector selector = new SimpleSelector(null, RDF.type, Datatype.Reference);
    StmtIterator iter = model.listStatements(selector);

    if (iter.hasNext()) {
        while (iter.hasNext()) {
            getReference(iter.next().getSubject());
        }
    }
    return refCache;
}
项目:oro-server    文件:OpenRobotsOntology.java   
@Override
public void update(Set<Statement> stmts) throws IllegalStatementException, InconsistentOntologyException, OntologyServerException {

    Set<Statement> stmtsToRemove = new HashSet<Statement>();

    for (Statement stmt : stmts) {
        if(functionalProperties.contains(stmt.getPredicate())) {
            Selector selector = new SimpleSelector(stmt.getSubject(), stmt.getPredicate(), (RDFNode)null);

            StmtIterator stmtsToRemoveIt = null;
            try {
                stmtsToRemoveIt = onto.listStatements(selector);
                stmtsToRemove.addAll(stmtsToRemoveIt.toSet());
            } catch (org.mindswap.pellet.exceptions.InconsistentOntologyException ioe) {
                Logger.log("The ontology is in an inconsistent state! I couldn't " +
                        "update any statements.\n ", VerboseLevel.WARNING);
                throw new InconsistentOntologyException("The ontology is in an inconsistent state! I couldn't " +
                        "update any statements.");
            }               
        }
    }

    remove(stmtsToRemove);

    add(stmts, MemoryProfile.DEFAULT, false);

}
项目:oro-server    文件:OpenRobotsOntology.java   
@Override
public void clear(PartialStatement partialStmt) throws OntologyServerException {
    Logger.log("Clearing statements matching ["+ partialStmt + "]\n");

    Selector selector = new SimpleSelector(partialStmt.getSubject(), partialStmt.getPredicate(), partialStmt.getObject());

    StmtIterator stmtsToRemove = null;
    Set<Statement> setToRemove = new HashSet<Statement>();

    stmtsToRemove = onto.listStatements(selector);
    if (stmtsToRemove != null) setToRemove = stmtsToRemove.toSet();


    remove(setToRemove);


}