本文整理了Java中org.eclipse.rdf4j.repository.RepositoryConnection.getStatements
方法的一些代码示例,展示了RepositoryConnection.getStatements
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryConnection.getStatements
方法的具体详情如下:
包路径:org.eclipse.rdf4j.repository.RepositoryConnection
类名称:RepositoryConnection
方法名:getStatements
[英]Gets all statements with a specific subject, predicate and/or object from the repository. The result is optionally restricted to the specified set of named contexts. If the repository supports inferencing, inferred statements will be included in the result.
[中]从存储库中获取具有特定主语、谓词和/或对象的所有语句。结果可以选择性地限制为指定的命名上下文集。如果存储库支持推断,则推断语句将包含在结果中。
代码示例来源:origin: joshsh/sesametools
@Override
public Set<Resource> subjects() {
Function<Statement, Resource> f = new Function<Statement, Resource>() {
@Override
public Resource apply(Statement statement) {
return statement.getSubject();
}
};
return toSet(rc.getStatements(null, null, null), f);
}
代码示例来源:origin: joshsh/sesametools
@Override
public Set<IRI> predicates() {
Function<Statement, IRI> f = new Function<Statement, IRI>() {
@Override
public IRI apply(Statement statement) {
return statement.getPredicate();
}
};
return toSet(rc.getStatements(null, null, null), f);
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
@Override
public RepositoryResult<Statement> getStatements(Resource subj, IRI pred, Value obj,
boolean includeInferred, Resource... contexts)
throws RepositoryException
{
return getDelegate().getStatements(subj, pred, obj, includeInferred, contexts);
}
代码示例来源:origin: eclipse/rdf4j
@Override
public RepositoryResult<Statement> getStatements(Resource subj, IRI pred, Value obj,
boolean includeInferred, Resource... contexts)
throws RepositoryException
{
return getDelegate().getStatements(subj, pred, obj, includeInferred, contexts);
}
代码示例来源:origin: joshsh/sesametools
@Override
public boolean contains(Resource resource, IRI iri, Value value, Resource... resources) {
try (CloseableIteration<Statement, RepositoryException> iter
= rc.getStatements(resource, iri, value, resources)) {
return iter.hasNext();
}
}
代码示例来源:origin: fr.lirmm.graphik/graal-store-rdf4j
@Override
public CloseableIterator<Atom> iterator() {
try {
return new AtomIterator(this.connection.getStatements(null, null, null, false), utils);
} catch (RepositoryException e) {
if (LOGGER.isErrorEnabled()) {
LOGGER.error("Error during iterator creation", e);
}
}
return null;
}
代码示例来源:origin: joshsh/sesametools
@Override
public Set<Value> objects() {
Function<Statement, Value> f = new Function<Statement, Value>() {
@Override
public Value apply(Statement statement) {
return statement.getObject();
}
};
return toSet(rc.getStatements(null, null, null), f);
}
代码示例来源:origin: com.powsybl/powsybl-triple-store-impl-rdf4j
private static int statementsCount(RepositoryConnection conn, Resource ctx) {
RepositoryResult<Statement> statements = conn.getStatements(null, null, null, ctx);
int counter = 0;
while (statements.hasNext()) {
counter++;
statements.next();
}
return counter;
}
代码示例来源:origin: joshsh/sesametools
protected CloseableIteration<? extends Statement, SailException> getStatementsInternal(
Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts)
throws SailException {
try {
return new RepositoryStatementIteration(
repoConnection.getStatements(subj, pred, obj, includeInferred && !inferenceDisabled, contexts));
} catch (RepositoryException e) {
throw new SailException(e);
}
}
代码示例来源:origin: joshsh/sesametools
@Override
public Iterator<Statement> match(Resource s, IRI p, Value o, Resource... c) {
RepositoryResult<Statement> result;
try {
result = rc.getStatements(s, p, o, INFER, c);
} catch (RepositoryException e) {
throw new RepositoryGraphRuntimeException(e);
}
return new RepositoryResultIterator(result);
}
代码示例来源:origin: inception-project/inception
private void delete(KnowledgeBase kb, String aIdentifier)
{
kbService.update(kb, (conn) -> {
ValueFactory vf = conn.getValueFactory();
IRI iri = vf.createIRI(aIdentifier);
try (RepositoryResult<Statement> subStmts = conn.getStatements(iri, null, null);
RepositoryResult<Statement> predStmts = conn.getStatements(null, iri, null);
RepositoryResult<Statement> objStmts = conn.getStatements(null, null, iri)) {
conn.remove(subStmts);
conn.remove(predStmts);
conn.remove(objStmts);
}
return null;
});
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-kb
private void delete(KnowledgeBase kb, String aIdentifier)
{
kbService.update(kb, (conn) -> {
ValueFactory vf = conn.getValueFactory();
IRI iri = vf.createIRI(aIdentifier);
try (RepositoryResult<Statement> subStmts = conn.getStatements(iri, null, null);
RepositoryResult<Statement> predStmts = conn.getStatements(null, iri, null);
RepositoryResult<Statement> objStmts = conn.getStatements(null, null, iri)) {
conn.remove(subStmts);
conn.remove(predStmts);
conn.remove(objStmts);
}
return null;
});
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-kb
@Override
public List<Statement> listStatementsWithPredicateOrObjectReference(KnowledgeBase kb,
String aIdentifier)
{
try (RepositoryConnection conn = getConnection(kb)) {
ValueFactory vf = conn.getValueFactory();
IRI iri = vf.createIRI(aIdentifier);
try (RepositoryResult<Statement> predStmts = conn.getStatements(null, iri, null);
RepositoryResult<Statement> objStmts = conn.getStatements(null, null, iri)) {
List<Statement> allStmts = new ArrayList<>();
Iterations.addAll(predStmts, allStmts);
Iterations.addAll(objStmts, allStmts);
return allStmts;
}
}
}
代码示例来源:origin: fr.lirmm.graphik/graal-store-rdf4j
@Override
public CloseableIterator<Atom> atomsByPredicate(Predicate p) throws AtomSetException {
try {
return new AtomIterator(this.connection.getStatements(null, utils.createURI(p), null, false), utils);
} catch (RepositoryException e) {
throw new AtomSetException(e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
private static Statement getIDStatement(RepositoryConnection con, String repositoryID)
throws RepositoryException, RepositoryConfigException
{
Literal idLiteral = con.getRepository().getValueFactory().createLiteral(repositoryID);
List<Statement> idStatementList = Iterations.asList(
con.getStatements(null, REPOSITORYID, idLiteral, true));
if (idStatementList.size() == 1) {
return idStatementList.get(0);
}
else if (idStatementList.isEmpty()) {
return null;
}
else {
throw new RepositoryConfigException("Multiple ID-statements for repository ID " + repositoryID);
}
}
}
代码示例来源:origin: eclipse/rdf4j
private String getRepositoryID(RepositoryConnection con, Resource context)
throws RepositoryException
{
String result = null;
try (RepositoryResult<Statement> idStatements = con.getStatements(null, REPOSITORYID, null, true,
context))
{
if (idStatements.hasNext()) {
Statement idStatement = idStatements.next();
result = idStatement.getObject().stringValue();
}
}
return result;
}
}
代码示例来源:origin: joshsh/sesametools
@Override
public boolean contains(Object o) {
if (o instanceof Statement) {
Statement st = (Statement) o;
try {
try (RepositoryResult<Statement> result = rc.getStatements(
st.getSubject(), st.getPredicate(), st.getObject(), INFER, st.getContext())) {
return result.hasNext();
}
} catch (Exception e) {
throw new RepositoryGraphRuntimeException(e);
}
} else {
return false;
}
}
代码示例来源:origin: franzinc/agraph-java-client
protected int getTotalStatementCount(RepositoryConnection connection)
throws RepositoryException {
CloseableIteration<? extends Statement, RepositoryException> iter = connection.getStatements(null,
null, null, true);
try {
int size = 0;
while (iter.hasNext()) {
iter.next();
++size;
}
return size;
} finally {
iter.close();
}
}
}
代码示例来源:origin: franzinc/agraph-java-client
@Override
public void handleSolution(BindingSet bindingSet)
throws TupleQueryResultHandlerException {
try {
RepositoryResult<Statement> statements = fconn.getStatements(fvf.createIRI(bindingSet.getValue("s").stringValue()), null, null, false);
Assert.assertNotNull(statements);
} catch (Exception e) {
e.printStackTrace();
throw new TupleQueryResultHandlerException(e);
}
}
代码示例来源:origin: franzinc/agraph-java-client
@Test
public void testRemoveStatementCollection()
throws Exception {
testCon.setAutoCommit(false);
testCon.add(alice, name, nameAlice);
testCon.add(bob, name, nameBob);
testCon.setAutoCommit(true);
assertTrue(testCon.hasStatement(bob, name, nameBob, false));
assertTrue(testCon.hasStatement(alice, name, nameAlice, false));
Collection<Statement> c = Iterations.addAll(testCon.getStatements(null, null, null, false),
new ArrayList<Statement>());
testCon.remove(c);
assertFalse(testCon.hasStatement(bob, name, nameBob, false));
assertFalse(testCon.hasStatement(alice, name, nameAlice, false));
}
内容来源于网络,如有侵权,请联系作者删除!