本文整理汇总了Java中org.openrdf.repository.Repository.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.initialize方法的具体用法?Java Repository.initialize怎么用?Java Repository.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.repository.Repository
的用法示例。
在下文中一共展示了Repository.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
Repository fromrepo = new SailRepository( new MemoryStore() );
Repository torepo = new SailRepository( new MemoryStore() );
fromrepo.initialize();
torepo.initialize();
from = fromrepo.getConnection();
to = torepo.getConnection();
from.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
new LiteralImpl( "test" ) ) );
from.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
new LiteralImpl( "test2" ) ) );
from.setNamespace( OWL.PREFIX, OWL.NAMESPACE );
}
示例2: testUpdateDate2
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Test
public void testUpdateDate2() throws Exception {
Repository repo = new SailRepository( new MemoryStore() );
repo.initialize();
RepositoryConnection rc = repo.getConnection();
URI base = Utility.getUniqueUri();
Date now = new Date();
rc.add( new StatementImpl( base, MetadataConstants.DCT_MODIFIED,
rc.getValueFactory().createLiteral( now ) ) );
AbstractSesameEngine.updateLastModifiedDate( rc, null );
List<Statement> stmts = Iterations.asList( eng.getRawConnection().
getStatements( eng.getBaseUri(), MetadataConstants.DCT_MODIFIED,
null, false ) );
Literal val = Literal.class.cast( stmts.get( 0 ).getObject() );
Date upd = getDate( val.calendarValue() );
rc.close();
repo.shutDown();
// the 100 is to remove the ms, which aren't always the same because
// they're not stored in the RDF
assertEquals( now.getTime(), upd.getTime(), 100 );
}
示例3: testAddStatement
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Ignore
@Test
public void testAddStatement() throws Exception {
SailRepositoryFactory f = new SailRepositoryFactory();
Repository r = f.getRepository(getConfig());
r.initialize();
RepositoryConnection rc = r.getConnection();
ValueFactory vf = rc.getValueFactory();
Statement s = vf.createStatement(vf.createURI("u:a"), vf.createURI("u:b"), vf.createURI("u:c"));
assertFalse(rc.hasStatement(s, false));
rc.add(s);
Assert.assertTrue(rc.hasStatement(s, false));
rc.close();
}
示例4: testGetRepository
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Test
public void testGetRepository() throws Exception {
MarkLogicRepositoryConfig config = new MarkLogicRepositoryConfig();
config.setHost(host);
config.setPort(port);
config.setUser(adminUser);
config.setPassword(adminPassword);
config.setAuth("DIGEST");
RepositoryFactory factory = new MarkLogicRepositoryFactory();
Assert.assertEquals("marklogic:MarkLogicRepository", factory.getRepositoryType());
Repository repo = factory.getRepository(config);
repo.initialize();
Assert.assertTrue(repo.getConnection() instanceof MarkLogicRepositoryConnection);
Repository otherrepo = factory.getRepository(config);
otherrepo.initialize();
RepositoryConnection oconn = otherrepo.getConnection();
Assert.assertTrue(oconn instanceof MarkLogicRepositoryConnection);
}
示例5: createRc
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Override
protected void createRc( Properties props ) throws RepositoryException {
String url = props.getProperty( REPOSITORY_KEY );
insightsloc = props.getProperty( INSIGHTS_KEY );
boolean remote = Boolean.parseBoolean( props.getProperty( REMOTE_KEY,
Boolean.FALSE.toString() ) );
if ( remote ) {
setProperty( Constants.SMSS_LOCATION, url );
}
Repository repo = getRawRepository( url );
repo.initialize();
data = repo.getConnection();
}
示例6: createRc
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Override
protected final void createRc( Properties p ) {
if ( null != rc ) {
// we've already have our rc created, so there's nothing to do here
return;
}
Security.getSecurity().associateUser( this, new LocalUserImpl() );
MemoryStore memstore = ( p.containsKey( MEMSTORE_DIR )
? new MemoryStore( new File( p.getProperty( MEMSTORE_DIR ) ) )
: new MemoryStore() );
if ( p.containsKey( SYNC_DELAY ) ) {
memstore.setSyncDelay( Long.parseLong( p.getProperty( SYNC_DELAY ) ) );
}
Sail sail = ( p.containsKey( INFER )
? new ForwardChainingRDFSInferencer( memstore )
: memstore );
Repository repo = new SailRepository( sail );
try {
repo.initialize();
rc = repo.getConnection();
}
catch ( Exception e ) {
try {
repo.shutDown();
}
catch ( Exception ex ) {
log.error( ex, ex );
}
}
setRepositoryConnection( rc, true );
}
示例7: testCreateFromRepository
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Test
public void testCreateFromRepository() throws Exception {
Repository repo = new SailRepository( new MemoryStore() );
repo.initialize();
RepositoryConnection rc = repo.getConnection();
rc.add( SRCFILE, null, RDFFormat.TURTLE );
rc.commit();
rc.close();
InsightManager imi = InsightManagerImpl.createFromRepository( repo );
repo.shutDown();
assertEquals( 1, imi.getPerspectives().size() );
}
示例8: createRepository
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
private ObjectRepository createRepository() throws Exception {
Sail sail = new MemoryStore();
sail = new AuditingSail(sail);
Repository repo = new OptimisticRepository(sail);
repo.initialize();
ObjectRepositoryFactory factory = new ObjectRepositoryFactory();
return factory.createRepository(config, repo);
}
示例9: main
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
public static void main(String[] args) throws OpenRDFException, IOException {
final Repository repo = createRepository();
registerCustomFunction(repo);
try{
repo.initialize();
/*
* Load data from resources
* src/main/resources/data.n3
*/
Utils.loadDataFromResources(repo, "data.n3", "");
final TupleQueryResult result = Utils.executeSelectQuery(repo, QUERY, QueryLanguage.SPARQL);
try {
while(result.hasNext()){
BindingSet bs = result.next();
log.info(bs);
}
} finally {
result.close();
}
} finally {
repo.shutDown();
}
}
示例10: testRDFSPlusInversesInferencer
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Test
public void testRDFSPlusInversesInferencer() throws RepositoryException {
// create a Sail stack
Sail sail = new MemoryStore();
sail = new ForwardChainingRDFSPlusInverseInferencer(sail);
// create a Repository
Repository repository = new SailRepository(sail);
try {
repository.initialize();
} catch (RepositoryException e) {
throw new RuntimeException(e);
}
URI a = new URIImpl("urn:test:a");
URI b = new URIImpl("urn:test:b");
URI c = new URIImpl("urn:test:c");
URI d = new URIImpl("urn:test:d");
URI nrlInverse = ForwardChainingRDFSPlusInverseInferencerConnection.NRL_InverseProperty;
repository.getConnection().add(a, b, c, new Resource[0]);
Assert.assertFalse(repository.getConnection().hasStatement(c, d, a,
true, new Resource[0]));
repository.getConnection().add(b, nrlInverse, d, new Resource[0]);
Assert.assertTrue(repository.getConnection().hasStatement(c, d, a,
true, new Resource[0]));
}
示例11: negativeTestRepo2
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Test
public void negativeTestRepo2()
throws Exception {
Repository rep = new MarkLogicRepository(host, port, user, password, "DIGEST");
rep.initialize();
rep.shutDown();
// should throw error as we shutdown repo
exception.expect(RepositoryException.class);
exception.expectMessage("MarkLogicRepository not initialized.");
@SuppressWarnings("unused")
RepositoryConnection conn = rep.getConnection();
}
示例12: testRepo
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Test
public void testRepo()
throws Exception {
Repository rep = new MarkLogicRepository(host, port, user, password, "DIGEST");
rep.initialize();
rep.shutDown();
rep.initialize();
Assert.assertTrue(rep.getDataDir() == null);
Assert.assertTrue(rep.isWritable());
Assert.assertTrue(rep.getValueFactory() instanceof ValueFactoryImpl);
Assert.assertTrue(rep.getConnection() instanceof MarkLogicRepositoryConnection);
}
示例13: TestRepoWithJavaAPIClientDatabaseClient
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Test
public void TestRepoWithJavaAPIClientDatabaseClient()
throws Exception {
DatabaseClient databaseClient = DatabaseClientFactory.newClient(host, port, user, password, DatabaseClientFactory.Authentication.valueOf("DIGEST"));
Repository rep = new MarkLogicRepository(databaseClient);
rep.initialize();
Assert.assertTrue(rep instanceof Repository);
RepositoryConnection conn = rep.getConnection();
Assert.assertTrue(conn instanceof RepositoryConnection);
conn.close();
rep.shutDown();
}
示例14: testRemoveAll
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Override
@Test
public void testRemoveAll() throws Exception {
Repository repo = new SailRepository(new MemoryStore());
repo.initialize();
RepositoryModelSet modelSet = new RepositoryModelSet(repo);
modelSet.open();
URI context1 = new URIImpl("uri:context1");
URI context2 = new URIImpl("uri:context2");
modelSet.addStatement(context1, new URIImpl("uri:r1"), new URIImpl(
"uri:p1"), new URIImpl("uri:r2"));
modelSet.addStatement(context1, new URIImpl("uri:r1"), new URIImpl(
"uri:p1"), new URIImpl("uri:r3"));
modelSet.addStatement(context2, new URIImpl("uri:r4"), new URIImpl(
"uri:p2"), new URIImpl("uri:r5"));
modelSet.addStatement(context2, new URIImpl("uri:r4"), new URIImpl(
"uri:p2"), new URIImpl("uri:r6"));
Model model1 = modelSet.getModel(context1);
model1.open();
Model model2 = modelSet.getModel(context2);
model2.open();
assertEquals(4, modelSet.size());
assertEquals(2, model1.size());
assertEquals(2, model2.size());
model2.removeAll();
assertEquals(2, modelSet.size());
assertEquals(2, model1.size());
assertEquals(0, model2.size());
model1.close();
model2.close();
}
示例15: testNestedConnections
import org.openrdf.repository.Repository; //导入方法依赖的package包/类
@Test
public void testNestedConnections()
throws OpenRDFException {
MarkLogicRepositoryConfig config = new MarkLogicRepositoryConfig();
config.setHost(host);
config.setPort(port);
config.setUser(user);
config.setPassword(password);
config.setAuth("DIGEST");
MarkLogicRepositoryFactory FACTORY = new MarkLogicRepositoryFactory();
ValueFactory vf = conn.getValueFactory();
URI tommy = vf.createURI("http://marklogicsparql.com/id#4444");
URI lname = vf.createURI("http://marklogicsparql.com/addressbook#lastName");
Literal tommylname = vf.createLiteral("Ramone");
Statement stmt = vf.createStatement(tommy, lname, tommylname);
conn.add(stmt);
conn.begin();
Repository repo2 = FACTORY.getRepository(config);
repo2.initialize();
RepositoryConnection conn2 = repo2.getConnection();
conn2.begin();
Assert.assertEquals("The size of repository must be zero", 1, conn.size());
conn2.commit();
conn2.close();
repo2.shutDown();
conn.commit();
}