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


Java Repository类代码示例

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


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

示例1: load

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
public static <T> Set<T> 
	load(
		Function<Model, Set<Resource>> resourceSelector, 
		Class<T> clazz,	
		Repository repository, 
		String sparqlQuery,
		UnaryOperator<Model> modelAdapter
	) {
	
	requireNonNull(repository, REPOSITORY_MSG);
	requireNonNull(sparqlQuery, SPARQL_QUERY_MSG);
	
	Model model = QueryUtils.getModelFromRepo(repository, sparqlQuery);
	
	return load(resourceSelector, clazz, model, modelAdapter, c -> {}, m -> {});		
}
 
开发者ID:carml,项目名称:carml,代码行数:17,代码来源:RdfObjectLoader.java

示例2: 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;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:22,代码来源:LdPathExecutor.java

示例3: getRepository

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
@Override
/**
 * Instantiate and return repository object.
 *
 */
public Repository getRepository(RepositoryImplConfig config) throws RepositoryConfigException {
    MarkLogicRepository repo = null;
    MarkLogicRepositoryConfig cfg = (MarkLogicRepositoryConfig) config;
    if (cfg.getHost() != null && cfg.getPort() != 0) {
        // init with MarkLogicRepositoryConfig
        repo = new MarkLogicRepository(cfg.getHost(),cfg.getPort(),cfg.getUser(),cfg.getPassword(),cfg.getAuth());
    } else if (cfg.getHost() == null) {
        // init with queryEndpoint as connection string
        try {
            repo = new MarkLogicRepository(new URL(cfg.getQueryEndpointUrl()));
        } catch (MalformedURLException e) {
            logger.debug(e.getMessage());
            throw new RepositoryConfigException(e.getMessage());
        }
    }else{
        throw new RepositoryConfigException("Invalid configuration class: " + config.getClass());
    }
    return repo;
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:25,代码来源:MarkLogicRepositoryFactory.java

示例4: 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);
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:22,代码来源:MarkLogicRepositoryFactoryTest.java

示例5: 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;
	}

}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:27,代码来源:MarkLogicRepositoryConnectionTest.java

示例6: persistSavesNewReportIntoUniqueContext

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
@Test
public void persistSavesNewReportIntoUniqueContext() throws Exception {
    final EntityManager em = emf.createEntityManager();
    RepositoryConnection connection = null;
    try {
        final Repository repository = em.unwrap(Repository.class);
        connection = repository.getConnection();
        assertFalse(connection.getContextIDs().hasNext());
        final OccurrenceReport report = OccurrenceReportGenerator.generateOccurrenceReportWithFactorGraph();
        report.getAuthor().generateUri();
        final Map<String, URI> ctx = dao.persist(report);
        assertTrue(connection.getContextIDs().hasNext());
        final Set<URI> contexts = getContexts(connection);
        assertTrue(ctx.containsKey(OccurrenceReportFormGenDao.REPORT_CONTEXT_NAME));
        assertTrue(contexts.contains(ctx.get(OccurrenceReportFormGenDao.REPORT_CONTEXT_NAME)));
    } finally {
        em.close();
        if (connection != null) {
            connection.close();
        }
    }
}
 
开发者ID:kbss-cvut,项目名称:reporting-tool,代码行数:23,代码来源:OccurrenceReportFormGenDaoTest.java

示例7: persistExportsE5xDataIntoSeparateContextAndReturnsItsUri

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
@Test
public void persistExportsE5xDataIntoSeparateContextAndReturnsItsUri() throws Exception {
    final EntityManager em = mainEmf.createEntityManager();
    RepositoryConnection sourceConnection = null;
    try {
        final Repository repository = em.unwrap(Repository.class);
        sourceConnection = repository.getConnection();
        final OccurrenceReport report = OccurrenceReportGenerator.generateOccurrenceReportWithFactorGraph();
        report.setUri(Generator.generateUri());
        final Collection<Statement> e5Data = persistE5Data(report.getUri(), sourceConnection);
        report.getAuthor().generateUri();
        final Map<String, URI> ctx = dao.persist(report);
        assertTrue(ctx.containsKey(OccurrenceReportFormGenDao.REPORT_CONTEXT_NAME));
        assertTrue(ctx.containsKey(OccurrenceReportFormGenDao.DATA_CONTEXT_NAME));
        verifyStatementPresence(e5Data, ctx.get(OccurrenceReportFormGenDao.DATA_CONTEXT_NAME));
    } finally {
        em.close();
        if (sourceConnection != null) {
            sourceConnection.close();
        }
    }
}
 
开发者ID:kbss-cvut,项目名称:reporting-tool,代码行数:23,代码来源:OccurrenceReportFormGenDaoTest.java

示例8: verifyStatementPresence

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
private void verifyStatementPresence(Collection<Statement> statements, URI contextUri) throws Exception {
    final EntityManager em = emf.createEntityManager();
    final Repository repo = em.unwrap(Repository.class);
    try (final RepositoryConnection connection = repo.getConnection()) {
        final ValueFactory vf = connection.getValueFactory();
        final org.eclipse.rdf4j.model.IRI context = vf.createIRI(contextUri.toString());
        for (Statement s : statements) {
            final RepositoryResult rr = connection
                    .getStatements(s.getSubject(), s.getPredicate(), s.getObject(), false, context);
            assertTrue(rr.hasNext());
            rr.close();
        }
    } finally {
        em.close();
    }
}
 
开发者ID:kbss-cvut,项目名称:reporting-tool,代码行数:17,代码来源:OccurrenceReportFormGenDaoTest.java

示例9: intitializeRepository

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
protected Repository intitializeRepository() throws RepositoryException {

		// Creates a triplestore if needed
		if (triplestoreInitializer != null) {
			LOG.debug("Initializing triplestore with {}", triplestoreInitializer.getClass().getSimpleName());
			triplestoreInitializer.initializeTriplestore();
		} else {
			LOG.debug("Skipping triplestore initialization, triplestoreInitializer was null.");
		}

		if (repository == null) {
			//Create connection to RDF4J DB
			HTTPRepository rmapHttpRepo = new HTTPRepository(
					rdf4jUrl, rdf4jReposName);
			rmapHttpRepo.setUsernameAndPassword(rdf4jUserName, rdf4jPassword);
			repository = rmapHttpRepo;
			repository.initialize();
		}

		return repository;
	}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:22,代码来源:Rdf4jHttpTriplestore.java

示例10: persistTestData

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
public void persistTestData(Collection<Triple> data, EntityManager em) throws Exception {
    final Repository repository = em.unwrap(Repository.class);
    try (final RepositoryConnection connection = repository.getConnection()) {
        final ValueFactory vf = connection.getValueFactory();
        connection.begin();
        for (Triple t : data) {
            if (t.getValue() instanceof URI) {
                connection.add(vf.createIRI(t.getSubject().toString()), vf.createIRI(t.getProperty().toString()),
                        vf.createIRI(t.getValue().toString()));
            } else {
                connection.add(vf.createIRI(t.getSubject().toString()), vf.createIRI(t.getProperty().toString()),
                        SesameUtils.createDataPropertyLiteral(t.getValue(), t.getLanguage(), vf));
            }

        }
        connection.commit();
    }
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:19,代码来源:SesameDataAccessor.java

示例11: verifyDataPresence

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
public void verifyDataPresence(Collection<Triple> data, EntityManager em) throws Exception {
    final Repository repository = em.unwrap(Repository.class);
    try (final RepositoryConnection connection = repository.getConnection()) {
        final ValueFactory vf = connection.getValueFactory();
        for (Triple t : data) {
            final boolean found;
            if (t.getValue() instanceof URI) {
                found = connection.hasStatement(vf.createIRI(t.getSubject().toString()),
                        vf.createIRI(t.getProperty().toString()), vf.createIRI(t.getValue().toString()), false);
            } else {
                found = connection.hasStatement(vf.createIRI(t.getSubject().toString()),
                        vf.createIRI(t.getProperty().toString()),
                        SesameUtils.createDataPropertyLiteral(t.getValue(), t.getLanguage(), vf), false);
            }
            assertTrue(found);
        }
    }
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:19,代码来源:SesameDataAccessor.java

示例12: createNativeRepository

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
/**
 * Creates native repository. </p>
 * <p>
 * This kind of repository stores data in files and is persistent after the VM shuts down.
 */
private Repository createNativeRepository(Configuration configuration, final URI localUri) {
    LOG.trace("Creating local native repository at " + localUri);
    final String[] tmp = localUri.toString().split(LOCAL_NATIVE_REPO);
    if (tmp.length != 2) {
        throw new RepositoryCreationException(
                "Unsupported local Sesame repository path. Expected file://path/repositories/id but got "
                        + localUri);
    }
    String repoId = tmp[1];
    if (repoId.charAt(repoId.length() - 1) == '/') {
        repoId = repoId.substring(0, repoId.length() - 1);
    }
    try {
        this.manager = RepositoryProvider.getRepositoryManagerOfRepository(localUri.toASCIIString());
        final RepositoryConfig cfg = createLocalNativeRepositoryConfig(repoId, configuration);
        manager.addRepositoryConfig(cfg);
        return manager.getRepository(repoId);
    } catch (RepositoryConfigException | RepositoryException e) {
        throw new RepositoryCreationException("Unable to create local repository at " + localUri, e);
    }
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:27,代码来源:StorageConnector.java

示例13: saveValueIntoContext

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
private Object saveValueIntoContext(String individual, Assertion property, String context) throws Exception {
    final RepositoryConnection conn = connector.unwrap(Repository.class).getConnection();
    conn.begin();
    final Object value;
    if (property.getType() == Assertion.AssertionType.DATA_PROPERTY) {
        value = new Date();
        conn.add(vf.createIRI(individual), vf.createIRI(property.getIdentifier().toString()),
                vf.createLiteral((Date) value), vf.createIRI(context));

    } else {
        value = NamedResource.create("http://krizik.felk.cvut.cz/individualInContext" + Generator.randomInt());
        conn.add(vf.createIRI(individual), vf.createIRI(property.getIdentifier().toString()),
                vf.createIRI(value.toString()), vf.createIRI(context));
    }
    conn.commit();
    conn.close();
    return value;
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:19,代码来源:AxiomLoaderTest.java

示例14: loadAxiomsSkipsPropertyValueOfInvalidType_OP

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
@Test
public void loadAxiomsSkipsPropertyValueOfInvalidType_OP() throws Exception {
    final String individual = generatedData.individuals.get(Generator.randomIndex(generatedData.individuals));
    final Assertion a = Assertion
            .createObjectPropertyAssertion(URI.create("http://krizik.felk.cvut.cz/objectProperty"), false);
    final RepositoryConnection conn = connector.unwrap(Repository.class).getConnection();
    conn.begin();
    conn.add(vf.createIRI(individual), vf.createIRI(a.getIdentifier().toString()), vf.createLiteral(false));
    conn.commit();
    conn.close();

    connector.begin();
    final AxiomDescriptor descOne = new AxiomDescriptor(NamedResource.create(individual));
    descOne.addAssertion(a);
    assertTrue(axiomLoader.loadAxioms(descOne).isEmpty());
    final AxiomDescriptor descTwo = new AxiomDescriptor(NamedResource.create(individual));
    descTwo.addAssertion(Assertion.createDataPropertyAssertion(a.getIdentifier(), false));
    assertFalse(axiomLoader.loadAxioms(descTwo).isEmpty());
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:20,代码来源:AxiomLoaderTest.java

示例15: loadAxiomsSkipsPropertyValueOfInvalidType_DP

import org.eclipse.rdf4j.repository.Repository; //导入依赖的package包/类
@Test
public void loadAxiomsSkipsPropertyValueOfInvalidType_DP() throws Exception {
    final String individual = generatedData.individuals.get(Generator.randomIndex(generatedData.individuals));
    final Assertion a = Assertion
            .createDataPropertyAssertion(URI.create("http://krizik.felk.cvut.cz/dataProperty"), false);
    final RepositoryConnection conn = connector.unwrap(Repository.class).getConnection();
    conn.begin();
    conn.add(vf.createIRI(individual), vf.createIRI(a.getIdentifier().toString()),
            vf.createIRI("http://krizik.felk.cvut.cz/individual"));
    conn.commit();
    conn.close();

    connector.begin();
    final AxiomDescriptor descOne = new AxiomDescriptor(NamedResource.create(individual));
    descOne.addAssertion(a);
    assertTrue(axiomLoader.loadAxioms(descOne).isEmpty());
    final AxiomDescriptor descTwo = new AxiomDescriptor(NamedResource.create(individual));
    descTwo.addAssertion(Assertion.createObjectPropertyAssertion(a.getIdentifier(), false));
    assertFalse(axiomLoader.loadAxioms(descTwo).isEmpty());
}
 
开发者ID:kbss-cvut,项目名称:jopa,代码行数:21,代码来源:AxiomLoaderTest.java


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