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


Java SailRepository类代码示例

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


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

示例1: SPARQLQuery

import org.openrdf.repository.sail.SailRepository; //导入依赖的package包/类
/**
 * Create a new SPARQL 1.1 query resource based on a repository.
 *
 * @param rep the repository this resources operates on
 */
public SPARQLQuery(SailRepository rep) {
	super(rep);
	// initialize additional result MIME-Types
	queryResultVariants = Variant.mediaTypes(
			MediaType.valueOf(RDFMediaType.SPARQL_RESULTS_JSON),
			MediaType.valueOf(RDFMediaType.SPARQL_RESULTS_XML),
			MediaType.valueOf(RDFMediaType.SPARQL_RESULTS_CSV),
			MediaType.valueOf(RDFMediaType.SPARQL_RESULTS_TSV)
	).add().build();
	booleanResultVariants = Variant.mediaTypes(
			MediaType.valueOf(RDFMediaType.SPARQL_RESULTS_JSON),
			MediaType.valueOf(RDFMediaType.SPARQL_RESULTS_XML),
			MediaType.valueOf(MediaType.TEXT_PLAIN)
	).add().build();
	// get reference to query rewriting component
	this.qwfactory = QueryRewriterFactory.getInstance(rep);
	// get query timeout from properties
	String sout = SPARQLExtensionProps.getProperty("query.timeout");
	this.timeout = Integer.parseInt(sout);
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:26,代码来源:SPARQLQuery.java

示例2: 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);
}
 
开发者ID:lszeremeta,项目名称:neo4j-sparql-extension-yars,代码行数:25,代码来源:SPARQLInferenceTest.java

示例3: setUp

import org.openrdf.repository.sail.SailRepository; //导入依赖的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 );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:18,代码来源:RepositoryCopierTest.java

示例4: testUpdateDate2

import org.openrdf.repository.sail.SailRepository; //导入依赖的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 );
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:27,代码来源:InMemorySesameEngineTest.java

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

示例6: 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();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:InferenceEngineTest.java

示例7: 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();
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:21,代码来源:RdfCloudTripleStoreTest.java

示例8: 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;
}
 
开发者ID:therelaxist,项目名称:spring-usc,代码行数:27,代码来源:Homework.java

示例9: ensureInEntityStore_Test

import org.openrdf.repository.sail.SailRepository; //导入依赖的package包/类
@Test
public void ensureInEntityStore_Test() throws Exception {
    final Sail sail = RyaSailFactory.getInstance(conf);
    SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    conn.begin();

    try(MongoEntityIndexer indexer = new MongoEntityIndexer()) {
        indexer.setConf(conf);
        indexer.init();

        setupTypes(indexer);
        addStatements(conn);

        final EntityStorage entities = indexer.getEntityStorage();
        final RyaURI subject = new RyaURI("urn:alice");
        final Optional<Entity> alice = entities.get(subject);
        assertTrue(alice.isPresent());
    } finally {
        conn.close();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:22,代码来源:MongoEntityIndexIT.java

示例10: near_invalidDistance

import org.openrdf.repository.sail.SailRepository; //导入依赖的package包/类
@Test(expected = MalformedQueryException.class)
public void near_invalidDistance() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    try {
        populateRya(conn);

        //Only captial
        final String query =
                "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
                        + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
                        + "SELECT * \n" //
                        + "WHERE { \n"
                        + "  <urn:geo> geo:asWKT ?point .\n"
                        + "  FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, distance))"
                        + "}";

        conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
    } finally {
        conn.close();
        sail.shutDown();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:24,代码来源:MongoGeoIndexerFilterIT.java

示例11: near_negativeDistance

import org.openrdf.repository.sail.SailRepository; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void near_negativeDistance() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    try {
        populateRya(conn);

        //Only captial
        final String query =
                "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
                        + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
                        + "SELECT * \n" //
                        + "WHERE { \n"
                        + "  <urn:geo> geo:asWKT ?point .\n"
                        + "  FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, -100))"
                        + "}";

        final TupleQueryResult rez = conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
        while(rez.hasNext()) {
            rez.next();
        }
    } finally {
        conn.close();
        sail.shutDown();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:27,代码来源:MongoGeoIndexerFilterIT.java

示例12: tooManyArgumentsTest

import org.openrdf.repository.sail.SailRepository; //导入依赖的package包/类
@Test(expected = QueryEvaluationException.class)
public void tooManyArgumentsTest() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepositoryConnection conn = new SailRepository(sail).getConnection();
    try {
        populateRya(conn);

        // Only captial
        final String query =
                "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
                        + "PREFIX geof: <http://www.opengis.net/def/function/geosparql/>\n"
                        + "SELECT * \n" //
                        + "WHERE { \n" + "  <urn:geo> geo:asWKT ?point .\n"
                        + "  FILTER(geof:sfNear(?point, \"POINT(38.8895 77.0353)\"^^geo:wktLiteral, 100, 1000, 10))"
                        + "}";

        conn.prepareTupleQuery(QueryLanguage.SPARQL, query).evaluate();
    } finally {
        conn.close();
        sail.shutDown();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:MongoGeoIndexerFilterIT.java

示例13: ensureInEventStore_Test

import org.openrdf.repository.sail.SailRepository; //导入依赖的package包/类
@Test
public void ensureInEventStore_Test() throws Exception {
    final Sail sail = GeoRyaSailFactory.getInstance(conf);
    final SailRepository repo = new SailRepository(sail);
    try(final MongoGeoTemporalIndexer indexer = new MongoGeoTemporalIndexer()) {
        indexer.setConf(conf);
        indexer.init();

        addStatements(repo.getConnection());
        final EventStorage events = indexer.getEventStorage();
        final RyaURI subject = new RyaURI("urn:event1");
        final Optional<Event> event = events.get(subject);
        assertTrue(event.isPresent());
    } finally {
        sail.shutDown();
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:18,代码来源:MongoGeoTemporalIndexIT.java

示例14: rep

import org.openrdf.repository.sail.SailRepository; //导入依赖的package包/类
/***
 * Starts up repository (which stores in rdfDBPath) and loads ontology into it.
 * @param rdfDBPath
 * @return  0 = success
	   		1 = Repository Exception - if something went wrong with connecting to rep (such as rep doesn't exist)
	        2 = if an error was found parsing the ontology (i.e wrong format)
	   	    3 = if data couldn't be written into rep (i.e rep not writable, data stream failed to write).
            4 = if connection couldn't close.
 */
public static int init(String rdfDBPath)
{
	/*input: receives rdfDBPath - a path to store ontologies.
	 * output: starts up the repository, and loads ontology into it. 
	 * 		   0 = success
	   		   1 = Repository Exception - if something went wrong with connecting to rep (such as rep doesn't exist)
	   		   2 = if an error was found parsing the ontology (i.e wrong format)
	   		   3 = if data couldn't be written into rep (i.e rep not writable, data stream failed to write).
	   		   4 = if connection couldn't close.
	   		   */
	
	int res = 0;
	File dataDir = new File (rdfDBPath);
	System.out.println(dataDir);
	try 
	{
		rep = new SailRepository(new NativeStore(dataDir));
		rep.initialize();			
	} catch (RepositoryException e) 
	{
		return 3;
	}
	return res;
}
 
开发者ID:matanso,项目名称:OASSIS,代码行数:34,代码来源:SPARQLQueryManager.java

示例15: setUp

import org.openrdf.repository.sail.SailRepository; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    generationConfig = new OntGenerationConfig();
    List<String> identifierLangPreference = Arrays.asList("en", "de", OntGenerationConfig.UNTYPED_LITERAL);
    List<String> javaDocLangPreference = Arrays.asList("de", "en", OntGenerationConfig.UNTYPED_LITERAL);
    generationConfig.setIdentifierLanguagePreference(identifierLangPreference);
    generationConfig.setJavaDocLanguagePreference(javaDocLangPreference);

    // Prevent persisting of schema information from other tests (would be rooted to ex:Vehicle):
    Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), new IDGeneratorAnno4jURN(), null, false);
    modelBuilder = new OWLJavaFileGenerator(anno4j);

    // Create a RDFS model builder instance:
    VehicleOntologyLoader.addVehicleOntology(modelBuilder);

    // Build the ontology model:
    modelBuilder.build();
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:19,代码来源:InterfaceTypeSpecTest.java


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