本文整理汇总了Java中org.eclipse.rdf4j.repository.Repository.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.initialize方法的具体用法?Java Repository.initialize怎么用?Java Repository.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.rdf4j.repository.Repository
的用法示例。
在下文中一共展示了Repository.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLdpath
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
private LDPath<Value> createLdpath(Model model) {
Repository repository = new SailRepository(new MemoryStore());
Rdf4jRepositoryBackend repositoryBackend;
try {
repository.initialize();
repositoryBackend = new Rdf4jRepositoryBackend(repository);
final RepositoryConnection connection = repository.getConnection();
connection.add(model);
connection.close();
} catch (RepositoryException re) {
throw new LdPathExecutorRuntimeException("Unable to initialize RDF4JRepository.", re);
}
LDPath<Value> result = new LDPath<>(repositoryBackend, LD_PATH_CONFIG);
result.registerFunction(new SortByPropertyFunction<>(ldpathNamespaces));
return result;
}
示例2: testGetRepository
import org.eclipse.rdf4j.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);
}
示例3: createRepconn
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
private void createRepconn() throws Exception {
RepositoryConnection repConn1 = null;
Repository tempRep2 = null;
try {
MarkLogicRepositoryConfig tempConfig2 = new MarkLogicRepositoryConfig();
tempConfig2.setHost(host);
tempConfig2.setAuth("DIGEST");
tempConfig2.setUser("admin");
tempConfig2.setPassword("admin");
tempConfig2.setPort(restPort);
tempRep2 = new MarkLogicRepositoryFactory().getRepository(tempConfig2);
tempRep2.initialize();
repConn1 = tempRep2.getConnection();
assertThat(repConn1.hasStatement(john, fname, johnfname, false), is(equalTo(false)));
} catch (Exception e) {
logger.debug(e.getMessage());
} finally {
if (repConn1.isActive())
repConn1.rollback();
tempRep2.shutDown();
repConn1.close();
repConn1 = null;
tempRep2 = null;
}
}
示例4: connectorIsAbleToConnectToAlreadyInitializedLocalNativeStorage
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Test
public void connectorIsAbleToConnectToAlreadyInitializedLocalNativeStorage() throws Exception {
final String repoId = "repositoryTest";
final URI repoUri = URI
.create("file://" + getProjectRootPath() + File.separator + "repositories" + File.separator + repoId);
this.repositoryFolder = new File(getProjectRootPath() + File.separator + "repositories");
SailImplConfig backend = new NativeStoreConfig();
final SailRepositoryConfig repoType = new SailRepositoryConfig(backend);
final RepositoryConfig config = new RepositoryConfig(repoId, repoType);
final RepositoryManager repoManager = RepositoryProvider.getRepositoryManagerOfRepository(repoUri.toString());
repoManager.addRepositoryConfig(config);
final Repository repo = repoManager.getRepository(repoId);
repo.initialize();
final OntologyStorageProperties storageProperties = OntologyStorageProperties.driver(DRIVER)
.physicalUri(repoUri).build();
final StorageConnector connector = new StorageConnector(new Configuration(storageProperties));
assertTrue(connector.isOpen());
connector.close();
}
示例5: getConnection
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
public RepositoryConnection getConnection(URL endpoint) throws RepositoryException {
Repository repo = null;
if (!repoMap.containsKey(endpoint)) {
repo = new SPARQLRepository(endpoint.toString());
repoMap.put(endpoint,repo);
} else {
repo = repoMap.get(endpoint);
}
if (!repo.isInitialized())
repo.initialize();
RepositoryConnection conn = repo.getConnection();
logger.info("Open [{}] (currently open={})", conn, countconn);
synchronized(this) { countconn++; }
return conn;
}
示例6: initializeMetadata
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
public void initializeMetadata(Repository metadata, String filename)
throws RepositoryException, IOException, RDFParseException
{
RepositoryConnection conn = null;
try {
File file = new File(filename);
metadata.initialize();
conn = metadata.getConnection();
RDFFormat fileFormat = RDFFormat.matchFileName(file.getAbsolutePath(), RDFParserRegistry.getInstance().getKeys()).orElse(RDFFormat.NTRIPLES);
conn.add(file, file.toURI().toString(), fileFormat);
} finally {
if (conn != null)
conn.close();
}
}
示例7: getRepository
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Override
public Repository getRepository(String s)
throws RepositoryException, RepositoryConfigException
{
RepositoryImplConfig repoConfig = getConfig();
RepositoryFactory repoFactory = RepositoryRegistry.getInstance().get(repoConfig.getType()).get();
Repository repository = repoFactory.getRepository(repoConfig);
repository.initialize();
// remove CSV and TSV format due to bug: literals are recognized as URIs if they contain a substring parsable as URI.
TupleQueryResultParserRegistry registry = TupleQueryResultParserRegistry.getInstance();
registry.get(TupleQueryResultFormat.CSV).ifPresent(f -> registry.remove(f));
registry.get(TupleQueryResultFormat.TSV).ifPresent(f -> registry.remove(f));
registry.get(TupleQueryResultFormat.JSON).ifPresent(f -> registry.remove(f));
BooleanQueryResultParserRegistry booleanRegistry = BooleanQueryResultParserRegistry.getInstance();
booleanRegistry.get(BooleanQueryResultFormat.JSON).ifPresent(f -> booleanRegistry.remove(f));
return repository;
}
示例8: negativeTestRepo2
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Test
public void negativeTestRepo2()
throws Exception {
Repository rep = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
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();
}
示例9: testRepo
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Test
public void testRepo()
throws Exception {
Repository rep = new MarkLogicRepository(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
rep.initialize();
rep.shutDown();
rep.initialize();
Assert.assertTrue(rep.getDataDir() == null);
Assert.assertTrue(rep.isWritable());
Assert.assertTrue(rep.getValueFactory() instanceof SimpleValueFactory);
Assert.assertTrue(rep.getConnection() instanceof MarkLogicRepositoryConnection);
}
示例10: TestRepoWithJavaAPIClientDatabaseClient
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Test
public void TestRepoWithJavaAPIClientDatabaseClient()
throws Exception {
DatabaseClient databaseClient = DatabaseClientFactory.newClient(host, port, new DatabaseClientFactory.DigestAuthContext(user, password));
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();
}
示例11: testGetRepositoryWithAllInOneConstructor
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Test
public void testGetRepositoryWithAllInOneConstructor() throws Exception {
MarkLogicRepositoryConfig config = new MarkLogicRepositoryConfig(host, port, user, password, "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();
Assert.assertTrue(otherrepo.getConnection() instanceof RepositoryConnection);
}
示例12: testNestedConnections
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Test
public void testNestedConnections()
throws RDF4JException {
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();
IRI tommy = vf.createIRI("http://marklogicsparql.com/id#4444");
IRI lname = vf.createIRI("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();
}
示例13: testIsolationLevel
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Test
public void testIsolationLevel() throws Exception {
RepositoryConnection repConn = null;
Repository tempRep1 = null;
try {
MarkLogicRepositoryConfig tempConfig1 = new MarkLogicRepositoryConfig();
tempConfig1.setHost(host);
tempConfig1.setAuth("DIGEST");
tempConfig1.setUser("admin");
tempConfig1.setPassword("admin");
tempConfig1.setPort(restPort);
tempRep1 = new MarkLogicRepositoryFactory().getRepository(tempConfig1);
tempRep1.initialize();
repConn = tempRep1.getConnection();
repConn.begin();
repConn.add(john, fname, johnfname);
createRepconn();
assertThat(repConn.hasStatement(john, fname, johnfname, false), is(equalTo(true)));
repConn.commit();
} catch (Exception e) {
logger.debug(e.getMessage());
} finally {
if (repConn.isActive())
repConn.rollback();
tempRep1.shutDown();
repConn.close();
repConn = null;
tempRep1 = null;
}
}
示例14: loadEndpoint
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
@Override
public Endpoint loadEndpoint(RepositoryInformation repoInfo) throws FedXException {
String repositoryServer = repoInfo.get("repositoryServer");
String repositoryName = repoInfo.get("repositoryName");
if (repositoryServer==null || repositoryName==null)
throw new FedXException("Invalid configuration, repositoryServer and repositoryName are required for " + repoInfo.getName());
try {
Repository repo = new HTTPRepository(repositoryServer, repositoryName);
repo.initialize();
ProviderUtil.checkConnectionIfConfigured(config, repo);
String location = repositoryServer + "/" + repositoryName;
EndpointClassification epc = EndpointClassification.Remote;
/*
// register a federated service manager to deal with this endpoint
SPARQLFederatedService federatedService = new SPARQLFederatedService(Protocol.getRepositoryLocation(repositoryServer, repositoryName));
federatedService.initialize();
FederatedServiceManager.getInstance().registerService(repoInfo.getName(), federatedService);
*/
Endpoint res = new Endpoint(repoInfo.getId(), repoInfo.getName(), location, repoInfo.getType(), epc);
res.setEndpointConfiguration(repoInfo.getEndpointConfiguration());
res.setRepo(repo);
return res;
} catch (Exception e) {
throw new FedXException("Repository " + repoInfo.getId() + " could not be initialized: " + e.getMessage(), e);
}
}
示例15: main
import org.eclipse.rdf4j.repository.Repository; //导入方法依赖的package包/类
/**
* Main program
*
* @param args
*/
public static void main(String[] args) {
logger.info("-- START --");
if (args.length < 2) {
logger.error("No input or output file");
System.exit(-1);
}
Optional<RDFFormat> fmtin = Rio.getParserFormatForFileName(args[0]);
if(!fmtin.isPresent()) {
logger.error("No parser for input {}", args[0]);
System.exit(-2);
}
int code = 0;
Repository repo = new SailRepository(new MemoryStore());
repo.initialize();
Serializer s = getSerializer();
s.setOutputFile(new File(args[1]));
try (RepositoryConnection con = repo.getConnection()) {
con.add(new File(args[0]), "http://data.gov.be", fmtin.get());
XMLStreamWriter w = s.getXMLStreamWriter();
w.writeStartDocument();
writeCatalog(w, con);
w.writeEndDocument();
w.close();
} catch (IOException|XMLStreamException|SaxonApiException ex) {
logger.error("Error converting", ex);
System.exit(-1);
} finally {
repo.shutDown();
}
}