本文整理了Java中org.eclipse.rdf4j.repository.RepositoryConnection.getValueFactory
方法的一些代码示例,展示了RepositoryConnection.getValueFactory
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryConnection.getValueFactory
方法的具体详情如下:
包路径:org.eclipse.rdf4j.repository.RepositoryConnection
类名称:RepositoryConnection
方法名:getValueFactory
[英]Gets a ValueFactory for this RepositoryConnection.
[中]获取此RepositoryConnection的ValueFactory。
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Creates a new RDFInserter object that preserves bnode IDs and that does not enforce any context upon
* statements that are reported to it.
*
* @param con
* The connection to use for the add operations.
*/
public RDFInserter(RepositoryConnection con) {
super(con.getValueFactory());
this.con = con;
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-sail
@Override
public ValueFactory getValueFactory() {
return repo.getValueFactory();
}
}
代码示例来源:origin: eclipse/rdf4j
/**
* Creates a new RDFInserter object that preserves bnode IDs and that does not enforce any context upon
* statements that are reported to it.
*
* @param con
* The connection to use for the add operations.
*/
public RDFInserter(RepositoryConnection con) {
super(con.getValueFactory());
this.con = con;
}
代码示例来源:origin: joshsh/sesametools
@Override
public ValueFactory getValueFactory() {
return rc.getValueFactory();
}
代码示例来源:origin: com.powsybl/powsybl-triple-store-impl-rdf4j
private Resource context(RepositoryConnection conn, String contextName) {
// Remove the namespaceForContexts from contextName if it already starts with it
String name1 = contextName.replace(namespaceForContexts(), "");
return conn.getValueFactory().createIRI(namespaceForContexts(), name1);
}
代码示例来源:origin: inception-project/inception
private String generateIdentifier(RepositoryConnection conn, KnowledgeBase kb)
{
ValueFactory vf = conn.getValueFactory();
// default value of basePrefix is IriConstants.INCEPTION_NAMESPACE
String basePrefix = kb.getBasePrefix();
return basePrefix + vf.createBNode().getID();
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-kb
private String generateIdentifier(RepositoryConnection conn, KnowledgeBase kb)
{
ValueFactory vf = conn.getValueFactory();
// default value of basePrefix is IriConstants.INCEPTION_NAMESPACE
String basePrefix = kb.getBasePrefix();
return basePrefix + vf.createBNode().getID();
}
代码示例来源:origin: streampipes/streampipes-ce
public boolean deleteContext(String contextId)
{
try {
RepositoryConnection conn = getConnection();
{
conn.clear(conn.getValueFactory().createURI(contextId));
}
closeConnection(conn);
return true;
} catch (Exception e)
{
e.printStackTrace();
return false;
}
}
代码示例来源:origin: org.streampipes/streampipes-storage-rdf4j
public boolean deleteContext(String contextId)
{
try {
RepositoryConnection conn = getConnection();
{
conn.clear(conn.getValueFactory().createURI(contextId));
}
closeConnection(conn);
return true;
} catch (Exception e)
{
e.printStackTrace();
return false;
}
}
代码示例来源: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: inception-project/inception
@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: de.tudarmstadt.ukp.inception.app/inception-kb
public List<KBHandle> getSubProperty(KnowledgeBase aKB, String aIdentifier, boolean aAll)
throws QueryEvaluationException
{
List<KBHandle> resultList = read(aKB, (conn) -> {
ValueFactory vf = conn.getValueFactory();
String QUERY = SPARQLQueryStore.getSubProperty(aKB);
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, QUERY);
tupleQuery.setBinding("oItem", vf.createIRI(aIdentifier));
tupleQuery.setBinding("pSUBPROPERTY", aKB.getSubPropertyIri());
tupleQuery.setIncludeInferred(true);
return evaluateListQuery(aKB, tupleQuery, aAll, "s");
});
resultList.sort(Comparator.comparing(KBObject::getUiLabel));
return resultList;
}
代码示例来源:origin: inception-project/inception
public List<KBHandle> getSubProperty(KnowledgeBase aKB, String aIdentifier, boolean aAll)
throws QueryEvaluationException
{
List<KBHandle> resultList = read(aKB, (conn) -> {
ValueFactory vf = conn.getValueFactory();
String QUERY = SPARQLQueryStore.getSubProperty(aKB);
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, QUERY);
tupleQuery.setBinding("oItem", vf.createIRI(aIdentifier));
tupleQuery.setBinding("pSUBPROPERTY", aKB.getSubPropertyIri());
tupleQuery.setIncludeInferred(true);
return evaluateListQuery(aKB, tupleQuery, aAll, "s");
});
resultList.sort(Comparator.comparing(KBObject::getUiLabel));
return resultList;
}
代码示例来源:origin: org.streampipes/streampipes-storage-rdf4j
private boolean addResource(Resource resource, org.eclipse.rdf4j.model.URI object)
{
try {
RepositoryConnection conn = repo.getConnection();
ValueFactory factory = conn.getValueFactory();
String elementName = resource.getElementName().replaceAll(" ", "_");
org.eclipse.rdf4j.model.Statement st = factory.createStatement(factory.createURI(resource.getNamespace()
+elementName), RDF.TYPE, object);
conn.add(st);
conn.close();
return true;
} catch (RepositoryException e) {
return false;
}
}
代码示例来源:origin: streampipes/streampipes-ce
private boolean addResource(Resource resource, org.eclipse.rdf4j.model.URI object)
{
try {
RepositoryConnection conn = repo.getConnection();
ValueFactory factory = conn.getValueFactory();
String elementName = resource.getElementName().replaceAll(" ", "_");
org.eclipse.rdf4j.model.Statement st = factory.createStatement(factory.createURI(resource.getNamespace()
+elementName), RDF.TYPE, object);
conn.add(st);
conn.close();
return true;
} catch (RepositoryException e) {
return false;
}
}
代码示例来源: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: 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: org.streampipes/streampipes-storage-rdf4j
@Override
public boolean addIndividual(Resource resource) {
try {
RepositoryConnection conn = repo.getConnection();
ValueFactory factory = conn.getValueFactory();
String elementName = resource.getElementName().replaceAll(" ", "_");
org.eclipse.rdf4j.model.Statement st;
if (resource.getInstanceOf() != null ) st = factory.createStatement(factory.createURI(resource.getNamespace() +elementName), RDF.TYPE, factory.createURI(resource.getInstanceOf()));
else st = factory.createStatement(factory.createURI(resource.getNamespace() +elementName), RDF.TYPE, RDFS.RESOURCE);
conn.add(st);
conn.close();
return true;
} catch (RepositoryException e) {
return false;
}
}
代码示例来源:origin: inception-project/inception
@Override
public boolean statementsMatchSPO(KnowledgeBase akb, KBStatement mockStatement)
{
try (RepositoryConnection conn = kbService.getConnection(akb)) {
ValueFactory vf = conn.getValueFactory();
String QUERY = "SELECT * WHERE { ?s ?p ?o . }";
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, QUERY);
tupleQuery.setBinding("s", vf.createIRI(mockStatement.getInstance().getIdentifier()));
tupleQuery.setBinding("p", vf.createIRI(mockStatement.getProperty().getIdentifier()));
InceptionValueMapper mapper = new InceptionValueMapper();
tupleQuery.setBinding("o", mapper.mapStatementValue(mockStatement, vf));
try (TupleQueryResult result = tupleQuery.evaluate()) {
return result.hasNext();
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-kb
@Override
public boolean statementsMatchSPO(KnowledgeBase akb, KBStatement mockStatement)
{
try (RepositoryConnection conn = kbService.getConnection(akb)) {
ValueFactory vf = conn.getValueFactory();
String QUERY = "SELECT * WHERE { ?s ?p ?o . }";
TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, QUERY);
tupleQuery.setBinding("s", vf.createIRI(mockStatement.getInstance().getIdentifier()));
tupleQuery.setBinding("p", vf.createIRI(mockStatement.getProperty().getIdentifier()));
InceptionValueMapper mapper = new InceptionValueMapper();
tupleQuery.setBinding("o", mapper.mapStatementValue(mockStatement, vf));
try (TupleQueryResult result = tupleQuery.evaluate()) {
return result.hasNext();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!