本文整理汇总了Java中org.openrdf.repository.sail.SailRepository.getConnection方法的典型用法代码示例。如果您正苦于以下问题:Java SailRepository.getConnection方法的具体用法?Java SailRepository.getConnection怎么用?Java SailRepository.getConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.repository.sail.SailRepository
的用法示例。
在下文中一共展示了SailRepository.getConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: before
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
@Before
public void before()
throws RepositoryException, IOException, RDFParseException,
MalformedQueryException, QueryResultParseException,
QueryResultHandlerException {
repo = new SailRepository(new MemoryStore());
repo.initialize();
conn = repo.getConnection();
vf = conn.getValueFactory();
conn.add(getResource(data), "file://", RDFFormat.TURTLE);
SPARQLResultsXMLParserFactory factory =
new SPARQLResultsXMLParserFactory();
parser = factory.getParser();
parser.setValueFactory(vf);
List<Rule> rules;
rules = Rules.fromOntology(getResource(data));
QueryRewriter rewriter = new QueryRewriter(conn, rules);
query = (TupleQuery) rewriter.rewrite(QueryLanguage.SPARQL, queryString);
nonInfQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
System.out.println("== QUERY (" + this.name + ") ==");
System.out.println(nonInfQuery);
System.out.println("== REWRITTEN QUERY (" + this.name + ") ==");
System.out.println(query);
}
示例2: setUp
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
dao = new AccumuloRyaDAO();
connector = new MockInstance().getConnector("", new PasswordToken(""));
dao.setConnector(connector);
conf = new AccumuloRdfConfiguration();
dao.setConf(conf);
dao.init();
store = new RdfCloudTripleStore();
store.setConf(conf);
store.setRyaDAO(dao);
inferenceEngine = new InferenceEngine();
inferenceEngine.setRyaDAO(dao);
store.setInferenceEngine(inferenceEngine);
inferenceEngine.refreshGraph();
store.initialize();
repository = new SailRepository(store);
conn = repository.getConnection();
}
示例3: setUp
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
connector = new MockInstance().getConnector("", "");
RdfCloudTripleStore sail = new RdfCloudTripleStore();
AccumuloRdfConfiguration conf = new AccumuloRdfConfiguration();
conf.setTablePrefix("lubm_");
sail.setConf(conf);
AccumuloRyaDAO crdfdao = new AccumuloRyaDAO();
crdfdao.setConnector(connector);
crdfdao.setConf(conf);
sail.setRyaDAO(crdfdao);
repository = new SailRepository(sail);
repository.initialize();
connection = repository.getConnection();
loadData();
}
示例4: setUp
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
/**
* Setup fixture for this test case.
*
* @throws Exception never, otherwise the test fails.
*/
@BeforeClass
public static void setUp() throws Exception {
_repository = new SailRepository(new MemoryStore());
_repository.initialize();
_tripleStore = newTripleStore();
_tripleStore.enableRangeIndexesSupport();
_tripleStore.open();
assertTrue("Ranges have not been enabled for this triple store!", _tripleStore.isRangeIndexesSupportEnabled());
_tripleStore.bulkLoad(DATA, RDFFormat.NTRIPLES);
_repositoryConnection = _repository.getConnection();
_repositoryConnection.add(new File(DATA), "http://nb-base-uri-not-actually-used", RDFFormat.NTRIPLES);
}
示例5: loadHistory
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
@Override
public JSONArray loadHistory(String filename) throws Exception {
File file = new File(filename);
// String encoding = EncodingDetector.detect(file);
// String contents = EncodingDetector.getString(file, encoding);
SailRepository myRepository = new SailRepository(new MemoryStore());
myRepository.initialize();
SailRepositoryConnection con = myRepository.getConnection();
con.add(file, "", RDFFormat.TURTLE);
RepositoryResult<Statement> result = con.getStatements(null, new URIImpl("http://isi.edu/integration/karma/dev#hasWorksheetHistory"), null, false);
if(result.hasNext()) {
Statement stmt = result.next();
String history = stmt.getObject().stringValue();
return new JSONArray(history);
}
return new JSONArray();
}
示例6: question7
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
public static Map<String, Repository> question7(Repository rep) {
RepositoryConnection conn = null;
RepositoryConnection fc_conn = null;
SailRepository fc_rep = new SailRepository(
new ForwardChainingRDFSInferencer(new MemoryStore()));
try {
conn = rep.getConnection();
fc_rep.initialize();
fc_conn = fc_rep.getConnection();
RepositoryResult<Statement> statements = conn.getStatements(null,
null, null, true);
fc_conn.add(statements);
conn.clear();
conn.add(fc_conn.getStatements(null, null, null, true));
} catch (RepositoryException e) {
e.printStackTrace();
} finally {
closeRepositoryConnection(fc_conn);
closeRepositoryConnection(conn);
}
question4(fc_rep, "8");
Map<String, Repository> map = new HashMap<String, Repository>();
map.put("fc_rep", fc_rep);
map.put("rep", rep);
return map;
}
示例7: createOwlRc
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
protected RepositoryConnection createOwlRc() throws RepositoryException {
ForwardChainingRDFSInferencer inferencer
= new ForwardChainingRDFSInferencer( new MemoryStore() );
SailRepository owlRepo = new SailRepository( inferencer );
owlRepo.initialize();
return owlRepo.getConnection();
}
示例8: createRc
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
@Override
protected void createRc( Properties props ) {
ForwardChainingRDFSInferencer inferencer
= new ForwardChainingRDFSInferencer( new MemoryStore() );
SailRepository repo = new SailRepository( inferencer );
try {
repo.initialize();
rc = repo.getConnection();
}
catch ( Exception e ) {
log.error( e, e );
}
}
示例9: getExpectedGraph
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
private static Model getExpectedGraph( File rdf, RDFFormat fmt ) {
SailRepository repo = new SailRepository( new MemoryStore() );
RepositoryConnection expectedrc = null;
List<Statement> stmts = new ArrayList<>();
try {
repo.initialize();
expectedrc = repo.getConnection();
expectedrc.add( rdf, null, fmt );
stmts.addAll( Iterations.asList( expectedrc.getStatements( null, null,
null, true ) ) );
}
catch ( RepositoryException | IOException | RDFParseException e ) {
}
finally {
if ( null != expectedrc ) {
try {
expectedrc.close();
}
catch ( Exception ex ) {
// don't care
}
try {
repo.shutDown();
}
catch ( Exception exc ) {
// don't care
}
}
}
return new LinkedHashModel( stmts );
}
示例10: getExpectedGraph
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
private static Model getExpectedGraph( File rdf ) {
SailRepository repo = new SailRepository( new MemoryStore() );
RepositoryConnection expectedrc = null;
List<Statement> stmts = new ArrayList<>();
try {
repo.initialize();
expectedrc = repo.getConnection();
expectedrc.add( rdf, null, RDFFormat.TURTLE );
stmts.addAll( Iterations.asList( expectedrc.getStatements( null, null,
null, true ) ) );
}
catch ( RepositoryException | IOException | RDFParseException e ) {
}
finally {
if ( null != expectedrc ) {
try {
expectedrc.close();
}
catch ( Exception ex ) {
// don't care
}
try {
repo.shutDown();
}
catch ( Exception exc ) {
// don't care
}
}
}
return new LinkedHashModel( stmts );
}
示例11: testGraphConfiguration
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
@Test
public void testGraphConfiguration() throws Exception {
// build a connection
RdfCloudTripleStore store = new RdfCloudTripleStore();
store.setConf(conf);
store.setRyaDAO(ryaDAO);
InferenceEngine inferenceEngine = new InferenceEngine();
inferenceEngine.setRyaDAO(ryaDAO);
store.setInferenceEngine(inferenceEngine);
inferenceEngine.refreshGraph();
store.initialize();
SailRepository repository = new SailRepository(store);
SailRepositoryConnection conn = repository.getConnection();
String query = "INSERT DATA\n"//
+ "{ GRAPH <http://updated/test> {\n"//
+ " <urn:greatMother> owl:propertyChainAxiom <urn:12342> . " +
" <urn:12342> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:node1atjakcvbx15023 . " +
" _:node1atjakcvbx15023 <http://www.w3.org/2002/07/owl#inverseOf> <urn:isChildOf> . " +
" <urn:12342> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:node1atjakcvbx15123 . " +
" _:node1atjakcvbx15123 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> . " +
" _:node1atjakcvbx15123 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <urn:MotherOf> . }}";
Update update = conn.prepareUpdate(QueryLanguage.SPARQL, query);
update.execute();
inferenceEngine.refreshGraph();
List<URI> chain = inferenceEngine.getPropertyChain(vf.createURI("urn:greatMother"));
Assert.assertEquals(chain.size(), 2);
Assert.assertEquals(chain.get(0), new InverseURI(vf.createURI("urn:isChildOf")));
Assert.assertEquals(chain.get(1), vf.createURI("urn:MotherOf"));
}
示例12: setUp
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
@Override
public void setUp() throws Exception {
super.setUp();
dao = new AccumuloRyaDAO();
connector = new MockInstance().getConnector("", new PasswordToken(""));
dao.setConnector(connector);
conf = new AccumuloRdfConfiguration();
conf.setInfer(true);
dao.setConf(conf);
dao.init();
store = new RdfCloudTripleStore();
store.setConf(conf);
store.setRyaDAO(dao);
inferenceEngine = new InferenceEngine();
inferenceEngine.setRyaDAO(dao);
store.setInferenceEngine(inferenceEngine);
inferenceEngine.refreshGraph();
store.initialize();
repository = new SailRepository(store);
conn = repository.getConnection();
solutions = new LinkedList<>();
resultHandler = new TupleQueryResultHandler() {
@Override
public void endQueryResult() throws TupleQueryResultHandlerException { }
@Override
public void handleBoolean(final boolean value) throws QueryResultHandlerException { }
@Override
public void handleLinks(final List<String> linkUrls) throws QueryResultHandlerException { }
@Override
public void handleSolution(final BindingSet bindingSet) throws TupleQueryResultHandlerException {
if (bindingSet != null && bindingSet.iterator().hasNext()) {
solutions.add(bindingSet);
}
}
@Override
public void startQueryResult(final List<String> bindingNames) throws TupleQueryResultHandlerException {
solutions.clear();
}
};
}
示例13: StatementMetadataExample
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
public StatementMetadataExample(AccumuloRdfConfiguration conf) throws Exception {
Connector aConn = ConfigUtils.getConnector(conf);
dao = new AccumuloRyaDAO();
dao.setConnector(aConn);
dao.init();
sail = RyaSailFactory.getInstance(conf);
repository = new SailRepository(sail);
conn = repository.getConnection();
}
示例14: initialize
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
/**
* Connect to the Rya SAIL. If a DAO wasn't provided, instantiate one from
* the configuration.
* @throws ForwardChainException if connecting fails.
*/
@Override
public void initialize() throws ForwardChainException {
try {
if (dao == null) {
dao = getDAO();
}
repo = new SailRepository(RyaSailFactory.getInstance(conf));
conn = repo.getConnection();
initialized = true;
} catch (Exception e) {
shutDown();
throw new ForwardChainException("Error connecting to SAIL", e);
}
}
示例15: testSensorObservationQueryRewriter
import org.openrdf.repository.sail.SailRepository; //导入方法依赖的package包/类
@Test
@FileParameters("src/test/resources/SensorObservationQueryRewriterTest.csv")
public void testSensorObservationQueryRewriter(
String kb,
@ConvertParam(value = ParamsConverterTest.StringToURIConverter.class) URI sensorId,
@ConvertParam(value = ParamsConverterTest.StringToURIConverter.class) URI propertyId,
@ConvertParam(value = ParamsConverterTest.StringToURIConverter.class) URI featureId,
@ConvertParam(value = ParamsConverterTest.StringToDateTimeConverter.class) DateTime timeFrom,
@ConvertParam(value = ParamsConverterTest.StringToDateTimeConverter.class) DateTime timeTo,
@ConvertParam(value = ParamsConverterTest.StringToSensorObservationQueryCollection.class) Set<SensorObservationQuery> e,
String assertType) throws RepositoryException, RDFParseException,
IOException {
SailRepository rp = new SailRepository(new MemoryStore());
rp.initialize();
RepositoryConnection rc = rp.getConnection();
rc.add(new File(kb), null, RDFFormat.RDFXML);
SensorObservationQueryRewriter rw = new SensorObservationQueryRewriter(
new SesameKnowledgeStore(rp));
Set<SensorObservationQuery> a = rw.rewrite(SensorObservationQuery
.create(sensorId, propertyId, featureId, timeFrom, timeTo));
if (assertType.equals("assertEquals")) {
assertEquals(e, a);
return;
}
assertNotEquals(e, a);
rc.close();
}