当前位置: 首页>>代码示例>>Java>>正文


Java SailRepository类代码示例

本文整理汇总了Java中org.eclipse.rdf4j.repository.sail.SailRepository的典型用法代码示例。如果您正苦于以下问题:Java SailRepository类的具体用法?Java SailRepository怎么用?Java SailRepository使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SailRepository类属于org.eclipse.rdf4j.repository.sail包,在下文中一共展示了SailRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createLdpath

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的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;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:22,代码来源:LdPathExecutor.java

示例2: setUp

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
@Before
public void setUp() {
  ConfigurationBackend configurationBackendMock = mock(ConfigurationBackend.class);
  ApplicationProperties applicationPropertiesMock = mock(ApplicationProperties.class);

  provider = new ParameterDefinitionResourceProvider(configurationBackendMock,
      applicationPropertiesMock, ImmutableList.of(parameterDefinitionFactoryMock));

  SailRepository sailRepositoryMock = mock(SailRepository.class);
  when(configurationBackendMock.getRepository()).thenReturn(sailRepositoryMock);

  SailRepositoryConnection sailRepositoryConnectionMock = mock(SailRepositoryConnection.class);
  when(sailRepositoryMock.getConnection()).thenReturn(sailRepositoryConnectionMock);
  when(sailRepositoryConnectionMock.prepareGraphQuery(anyString())).thenReturn(graphQueryMock);

  when(applicationPropertiesMock.getSystemGraph()).thenReturn(DBEERPEDIA.SYSTEM_GRAPH_IRI);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:18,代码来源:ParameterDefinitionResourceProviderTest.java

示例3: init

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
/**
 * Initialize repository and load triples
 * 
 * @throws IOException 
 */
public void init() throws IOException {
    LOG.debug("Initialize repository");
    repo = new SailRepository(new MemoryStore());
    repo.initialize();
    
    Optional<RDFFormat> fmt = Rio.getParserFormatForFileName(path.toString());
    if (!fmt.isPresent()) {
        throw new IOException("Could not determine file type");
    }
    
    LOG.debug("Adding triples");
    BufferedReader r = Files.newBufferedReader(path);
    
    Date start = new Date();
    RepositoryConnection con = repo.getConnection();
    try {
        con.add(r, BASE_URI, fmt.get());
    } catch (RepositoryException cve) {
        LOG.error("Error adding triples", cve);
    }
    LOG.info("{} triples loaded in {} ms", 
            con.size(), new Date().getTime() - start.getTime());
            
    if(con.isEmpty()) {
        LOG.error("No statements loaded");
        close();
    }
}
 
开发者ID:Fedict,项目名称:rdfvalidator,代码行数:34,代码来源:Validator.java

示例4: getService

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
@Override
public FederatedService getService(String serviceUrl) throws QueryEvaluationException {
		//provide a service to query over Halyard graphs. Remote service queries are not supported.
    if (serviceUrl.startsWith(HALYARD.NAMESPACE)) {
        String federatedTable = serviceUrl.substring(HALYARD.NAMESPACE.length());
        RepositoryFederatedService s = federatedServices.get(federatedTable);
        if (s == null) {
            s = new RepositoryFederatedService(new SailRepository(new HBaseSail(config, federatedTable, false, 0, true, evaluationTimeout, null, ticker)));
            federatedServices.put(federatedTable, s);
            s.initialize();
        }
        return s;
    } else {
        throw new QueryEvaluationException("Unsupported service URL: " + serviceUrl);
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:17,代码来源:HBaseSail.java

示例5: testEvaluate

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
@Test
public void testEvaluate() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertTrue(res.hasNext());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:18,代码来源:HBaseSailTest.java

示例6: testEvaluateWithContext

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
@Test
public void testEvaluateWithContext() throws Exception {
    ValueFactory vf = SimpleValueFactory.getInstance();
    Resource subj = vf.createIRI("http://whatever/subj/");
    IRI pred = vf.createIRI("http://whatever/pred/");
    Value obj = vf.createLiteral("whatever");
    IRI context = vf.createIRI("http://whatever/context/");
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    sail.addStatement(subj, pred, obj, context);
    sail.commit();
    TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o from named <http://whatever/context/> where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}");
    TupleQueryResult res = q.evaluate();
    assertFalse(res.hasNext());
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:19,代码来源:HBaseSailTest.java

示例7: run

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
void run(Configuration configuration) throws ExportException {
    try {
        SailRepository rep = new SailRepository(new HBaseSail(configuration, htableName, false, 0, true, 0, elasticIndexURL, null));
        rep.initialize();
        try {
            writer.initTimer();
            log.logStatus("Query execution started");
            Query q = rep.getConnection().prepareQuery(QueryLanguage.SPARQL, sparqlQuery);
            if (q instanceof TupleQuery) {
                writer.writeTupleQueryResult(((TupleQuery)q).evaluate());
            } else if (q instanceof GraphQuery) {
                writer.writeGraphQueryResult(((GraphQuery)q).evaluate());
            } else {
                throw new ExportException("Only SPARQL Tuple and Graph query types are supported.");
            }
            log.logStatus("Export finished");
        } finally {
            rep.shutDown();
        }
    } catch (RepositoryException | MalformedQueryException | QueryEvaluationException e) {
        throw new ExportException(e);
    } finally {
        writer.close();
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:26,代码来源:HalyardExport.java

示例8: configurationBackend

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
@Bean
public ConfigurationBackend configurationBackend(
    @Value("classpath:/model/elmo.trig") Resource elmoConfiguration,
    @Value("#{applicationProperties.resourcePath}") String resourcePath,
    @Value("classpath:/model/elmo-shapes.trig") Resource elmoShapes,
    ShaclValidator shaclValidator) {
  return new FileConfigurationBackend(elmoConfiguration, new SailRepository(new MemoryStore()),
      resourcePath, elmoShapes, shaclValidator);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:10,代码来源:ApplicationConfiguration.java

示例9: FileConfigurationBackend

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
public FileConfigurationBackend(@NonNull Resource elmoConfiguration,
    @NonNull SailRepository repository, @NonNull String resourcePath,
    @NonNull Resource elmoShapes, @NonNull ShaclValidator shaclValidator) {
  this.elmoConfiguration = elmoConfiguration;
  this.repository = repository;
  this.resourcePath = resourcePath;
  this.elmoShapes = elmoShapes;
  this.shaclValidator = shaclValidator;
  repository.initialize();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:11,代码来源:FileConfigurationBackend.java

示例10: FedXSailRepositoryConnection

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
FedXSailRepositoryConnection(SailRepository repository, FedXConnection sailConnection)
{
	super(repository, sailConnection);
	queryManager = new QueryManager(this);
	sailConnection.setQqueryManager(queryManager);
	
       Properties props = ((FedX)repository.getSail()).getPrefixDeclarations();
       if (props != null) {
           for (String ns : props.stringPropertyNames()) {
               queryManager.addPrefixDeclaration(ns, props.getProperty(ns)); // register namespace/prefix pair
           }
       }
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:14,代码来源:FedXSailRepositoryConnection.java

示例11: loadEndpoint

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
@Override
public Endpoint loadEndpoint(RepositoryInformation repoInfo) throws FedXException {
	
	File store = FileUtil.getFileLocation(config, repoInfo.getLocation());
	
	if (!store.exists()){
		throw new FedXRuntimeException("Store does not exist at '" + repoInfo.getLocation() + ": " + store.getAbsolutePath() + "'.");
	}
	
	try {
		NativeStore ns = new NativeStoreExt(store);
		SailRepository repo = new SailRepository(ns);
		repo.initialize();
		
		ProviderUtil.checkConnectionIfConfigured(config, repo);
		
		Endpoint res = new Endpoint(repoInfo.getId(), repoInfo.getName(), repoInfo.getLocation(), repoInfo.getType(), EndpointClassification.Local);
		res.setEndpointConfiguration(repoInfo.getEndpointConfiguration());
		res.setRepo(repo);
		
		/*
		// register a federated service manager to deal with this endpoint
		SAILFederatedService federatedService = new SAILFederatedService(res);
		federatedService.initialize();
		FederatedServiceManager.getInstance().registerService(repoInfo.getName(), federatedService);
		*/
		
		return res;
	} catch (RepositoryException e) {
		throw new FedXException("Repository " + repoInfo.getId() + " could not be initialized: " + e.getMessage(), e);
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:33,代码来源:NativeStoreProvider.java

示例12: timestampTest

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
@Test
public void timestampTest() throws Exception {
    CloseableIteration<? extends Statement, SailException> iter;
    HBaseSail sail = new TimeAwareHBaseSail(HBaseServerTestInstance.getInstanceConfig(), "timestamptable", true, 0, true, 0, null, null);
    SailRepository rep = new SailRepository(sail);
    rep.initialize();
    SailRepositoryConnection con = rep.getConnection();
    assertTrue(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(2 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    assertTrue(testUpdate(con, "delete {<http://whatever> <http://whatever> <http://whatever>} where {bind(1 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    assertFalse(testUpdate(con, "delete {<http://whatever> <http://whatever> <http://whatever>} where {bind(4 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    assertFalse(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(3 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    assertTrue(testUpdate(con, "insert {<http://whatever> <http://whatever> <http://whatever>} where {bind(4 as ?HALYARD_TIMESTAMP_SPECIAL_VARIABLE)}"));
    rep.shutDown();
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:15,代码来源:TimeAwareHBaseSailTest.java

示例13: repository

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
@Bean(name="repository", initMethod = "initialize",
        destroyMethod = "shutDown")
public Repository repository(final Environment env)
        throws RepositoryException, IOException, RDFParseException {
    // For tets we use only in memory
    Sail store = new MemoryStore();
    return new SailRepository(store);
}
 
开发者ID:DTL-FAIRData,项目名称:FAIRDataPoint,代码行数:9,代码来源:RestApiTestContext.java

示例14: createInMemoryRepository

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
/**
 * Creates a local in-memory Sesame repository which is disposed when the VM shuts down.
 */
private Repository createInMemoryRepository(Configuration configuration) {
    LOG.trace("Creating local in-memory repository.");
    final MemoryStore ms = new MemoryStore();
    if (configuration.is(SesameConfigParam.USE_INFERENCE)) {
        return new SailRepository(new ForwardChainingRDFSInferencer(ms));
    } else {
        return new SailRepository(ms);
    }
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:13,代码来源:StorageConnector.java

示例15: Storage

import org.eclipse.rdf4j.repository.sail.SailRepository; //导入依赖的package包/类
/**
 * RDF store
 * 
 * @param f file to be used as storage
 */
public Storage(File f) {
    logger.info("Opening RDF store " + f.getAbsolutePath());
    
    MemoryStore mem = new MemoryStore(f);
    mem.setPersist(false);
    repo = new SailRepository(mem);
}
 
开发者ID:Fedict,项目名称:dcattools,代码行数:13,代码来源:Storage.java


注:本文中的org.eclipse.rdf4j.repository.sail.SailRepository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。