org.eclipse.rdf4j.model.vocabulary.RDFS Java Examples
The following examples show how to use
org.eclipse.rdf4j.model.vocabulary.RDFS.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoFreeTextIndexerIT.java From rya with Apache License 2.0 | 6 votes |
@Test public void testContextSearch() throws Exception { try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) { f.setConf(conf); f.init(); final ValueFactory vf = SimpleValueFactory.getInstance(); final IRI subject = vf.createIRI("foo:subj"); final IRI predicate = vf.createIRI(RDFS.COMMENT.toString()); final Value object = vf.createLiteral("this is a new hat"); final IRI context = vf.createIRI("foo:context"); final Statement statement = vf.createStatement(subject, predicate, object, context); f.storeStatement(RdfToRyaConversions.convertStatement(statement)); f.flush(); assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat", EMPTY_CONSTRAINTS))); assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat", new StatementConstraints().setContext(context)))); assertEquals(Sets.newHashSet(), getSet(f.queryText("hat", new StatementConstraints().setContext(vf.createIRI("foo:context2"))))); } }
Example #2
Source File: SPARQLUpdateTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testInsertDataInGraph2() throws Exception { logger.debug("executing testInsertDataInGraph2"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append( "INSERT DATA { GRAPH ex:graph1 { ex:Human rdfs:subClassOf ex:Mammal. ex:Mammal rdfs:subClassOf ex:Animal. ex:george a ex:Human. ex:ringo a ex:Human. } } "); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); IRI human = f.createIRI(EX_NS, "Human"); IRI mammal = f.createIRI(EX_NS, "Mammal"); IRI george = f.createIRI(EX_NS, "george"); operation.execute(); assertTrue(con.hasStatement(human, RDFS.SUBCLASSOF, mammal, true, graph1)); assertTrue(con.hasStatement(mammal, RDFS.SUBCLASSOF, null, true, graph1)); assertTrue(con.hasStatement(george, RDF.TYPE, human, true, graph1)); }
Example #3
Source File: InferredContextTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testInferrecContextNull() { SchemaCachingRDFSInferencer sail = new SchemaCachingRDFSInferencer(new MemoryStore()); sail.initialize(); sail.setAddInferredStatementsToDefaultContext(true); try (SchemaCachingRDFSInferencerConnection connection = sail.getConnection()) { connection.begin(); connection.addStatement(bNode, RDF.TYPE, type, context); connection.commit(); assertFalse(connection.hasStatement(bNode, RDF.TYPE, RDFS.RESOURCE, true, context)); assertTrue(connection.hasStatement(bNode, RDF.TYPE, RDFS.RESOURCE, true)); } }
Example #4
Source File: SPARQLUpdateTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testInsertWhereWith() throws Exception { logger.debug("executing testInsertWhereWith"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("WITH ex:graph1 INSERT {?x rdfs:label ?y . } WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.execute(); String message = "label should have been inserted in graph1 only, for ex:bob only"; assertTrue(message, con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true, graph1)); assertFalse(message, con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true, graph2)); assertFalse(message, con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true, graph2)); assertFalse(message, con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true, graph1)); }
Example #5
Source File: ModelNamespacesTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Test method for {@link org.eclipse.rdf4j.model.Model#getNamespace(java.lang.String)}. */ @Test public final void testGetNamespaceMultiple() { testModel.setNamespace(RDF.PREFIX, RDF.NAMESPACE); testModel.setNamespace(RDFS.PREFIX, RDFS.NAMESPACE); testModel.setNamespace(DC.PREFIX, DC.NAMESPACE); testModel.setNamespace(SKOS.PREFIX, SKOS.NAMESPACE); testModel.setNamespace(SESAME.PREFIX, SESAME.NAMESPACE); Set<Namespace> namespaces = testModel.getNamespaces(); assertNotNull("Namespaces set must not be null", namespaces); assertFalse(namespaces.isEmpty()); assertEquals(5, namespaces.size()); assertEquals(new SimpleNamespace(RDF.PREFIX, RDF.NAMESPACE), testModel.getNamespace(RDF.PREFIX).get()); assertEquals(new SimpleNamespace(RDFS.PREFIX, RDFS.NAMESPACE), testModel.getNamespace(RDFS.PREFIX).get()); assertEquals(new SimpleNamespace(DC.PREFIX, DC.NAMESPACE), testModel.getNamespace(DC.PREFIX).get()); assertEquals(new SimpleNamespace(SKOS.PREFIX, SKOS.NAMESPACE), testModel.getNamespace(SKOS.PREFIX).get()); assertEquals(new SimpleNamespace(SESAME.PREFIX, SESAME.NAMESPACE), testModel.getNamespace(SESAME.PREFIX).get()); }
Example #6
Source File: SPARQLConnectionTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testGroupingAddsInInsert() throws Exception { ArgumentCaptor<String> sparqlUpdateCaptor = ArgumentCaptor.forClass(String.class); subject.begin(); subject.add(FOAF.PERSON, RDF.TYPE, RDFS.CLASS); subject.add(FOAF.AGENT, RDF.TYPE, RDFS.CLASS); subject.commit(); verify(client).sendUpdate(any(), sparqlUpdateCaptor.capture(), any(), any(), anyBoolean(), anyInt(), any()); String sparqlUpdate = sparqlUpdateCaptor.getValue(); String expectedTriple1 = "<" + FOAF.PERSON + "> <" + RDF.TYPE + "> <" + RDFS.CLASS + ">"; String expectedTriple2 = "<" + FOAF.AGENT + "> <" + RDF.TYPE + "> <" + RDFS.CLASS + ">"; assertThat(sparqlUpdate).containsOnlyOnce("INSERT DATA").contains(expectedTriple1).contains(expectedTriple2); }
Example #7
Source File: KnowledgeBaseServiceImplIntegrationTest.java From inception with Apache License 2.0 | 6 votes |
@Test public void getChildConcepts_WithStreams_ReturnsOnlyImmediateChildren() throws Exception { sut.registerKnowledgeBase(kb, sut.getNativeConfig()); importKnowledgeBase("data/streams.ttl"); KBConcept concept = sut.readConcept(kb, "http://mrklie.com/schemas/streams#input", true).get(); setSchema(kb, RDFS.CLASS, RDFS.SUBCLASSOF, RDF.TYPE, RDFS.COMMENT, RDFS.LABEL, RDF.PROPERTY); Stream<String> childConcepts = sut.listChildConcepts(kb, concept.getIdentifier(), false) .stream() .map(KBHandle::getName); String[] expectedLabels = { "ByteArrayInputStream", "FileInputStream", "FilterInputStream", "ObjectInputStream", "PipedInputStream","SequenceInputStream", "StringBufferInputStream" }; assertThat(childConcepts) .as("Check that all immediate child concepts have been found") .containsExactlyInAnyOrder(expectedLabels); }
Example #8
Source File: DatatypeBenchmarkPrefilled.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Benchmark public void sparqlInsteadOfShacl() { try (SailRepositoryConnection connection = sparqlQueryMemoryStoreRepo.getConnection()) { connection.begin(); connection.commit(); } try (SailRepositoryConnection connection = sparqlQueryMemoryStoreRepo.getConnection()) { for (List<Statement> statements : allStatements) { connection.begin(); connection.add(statements); try (Stream<BindingSet> stream = connection .prepareTupleQuery("select * where {?a a <" + RDFS.RESOURCE + ">; <" + FOAF.AGE + "> ?age. FILTER(datatype(?age) != <http://www.w3.org/2001/XMLSchema#int>)}") .evaluate() .stream()) { stream.forEach(System.out::println); } connection.commit(); } } }
Example #9
Source File: ShaclValidationReportTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testAddingData() throws IOException { Repository systemRepo = new HTTPRepository( Protocol.getRepositoryLocation(TestServer.SERVER_URL, TestServer.TEST_SHACL_REPO_ID)); try (RepositoryConnection connection = systemRepo.getConnection()) { connection.begin(); connection.add(new StringReader(shacl), "", RDFFormat.TURTLE, RDF4J.SHACL_SHAPE_GRAPH); connection.commit(); try { connection.begin(); connection.add(vf.createBNode(), RDF.TYPE, RDFS.RESOURCE); connection.commit(); fail(); } catch (Exception e) { assertExceptionIsShaclReport(e); } } }
Example #10
Source File: RDFSchemaRepositoryConnectionTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test /** * See https://github.com/eclipse/rdf4j/issues/1685 */ public void testSubClassInferenceAfterRemoval() throws Exception { IRI mother = vf.createIRI("http://example.org/Mother"); testCon.begin(); testCon.add(FOAF.PERSON, RDFS.SUBCLASSOF, FOAF.AGENT); testCon.add(woman, RDFS.SUBCLASSOF, FOAF.PERSON); testCon.add(mother, RDFS.SUBCLASSOF, woman); testCon.commit(); assertTrue(testCon.hasStatement(mother, RDFS.SUBCLASSOF, FOAF.AGENT, true)); assertTrue(testCon.hasStatement(woman, RDFS.SUBCLASSOF, FOAF.AGENT, true)); testCon.begin(); testCon.remove(mother, RDFS.SUBCLASSOF, woman); testCon.commit(); assertFalse(testCon.hasStatement(mother, RDFS.SUBCLASSOF, FOAF.AGENT, true)); assertTrue(testCon.hasStatement(woman, RDFS.SUBCLASSOF, FOAF.AGENT, true)); }
Example #11
Source File: ElasticsearchStoreTransactionsTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testClear() { SailRepository elasticsearchStore = new SailRepository(this.elasticsearchStore); try (SailRepositoryConnection connection = elasticsearchStore.getConnection()) { BNode context = vf.createBNode(); connection.begin(IsolationLevels.READ_COMMITTED); connection.add(RDF.TYPE, RDF.TYPE, RDFS.RESOURCE); connection.add(RDF.TYPE, RDF.TYPE, RDF.PROPERTY, context); connection.commit(); connection.begin(IsolationLevels.NONE); connection.clear(); connection.commit(); } }
Example #12
Source File: QueryPlanRetrievalTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void addData(SailRepository sailRepository) { try (SailRepositoryConnection connection = sailRepository.getConnection()) { connection.add(RDFS.RESOURCE, RDF.TYPE, RDFS.RESOURCE); connection.add(RDF.PROPERTY, RDF.TYPE, RDFS.RESOURCE); connection.add(RDF.TYPE, RDF.TYPE, RDF.PROPERTY); connection.add(RDF.TYPE, RDF.TYPE, RDFS.RESOURCE); connection.add(vf.createBNode("01"), FOAF.KNOWS, vf.createBNode("02")); connection.add(vf.createBNode("03"), FOAF.KNOWS, vf.createBNode("04")); connection.add(vf.createBNode("05"), FOAF.KNOWS, vf.createBNode("06")); connection.add(vf.createBNode("07"), FOAF.KNOWS, vf.createBNode("08")); connection.add(vf.createBNode("09"), FOAF.KNOWS, vf.createBNode("10")); connection.add(vf.createBNode("11"), FOAF.KNOWS, vf.createBNode("12")); connection.add(vf.createBNode("13"), FOAF.KNOWS, vf.createBNode("14")); connection.add(vf.createBNode("15"), FOAF.KNOWS, vf.createBNode("16")); } }
Example #13
Source File: SPARQLQueryBuilderTest.java From inception with Apache License 2.0 | 6 votes |
@Category(SlowTests.class) @Ignore("#1522 - GND tests not running") @Test public void testWithLabelStartingWith_Fuseki_FTS() throws Exception { assertIsReachable(zbwGnd); kb.setType(REMOTE); kb.setFullTextSearchIri(FTS_FUSEKI); kb.setLabelIri(RDFS.LABEL); kb.setSubPropertyIri(RDFS.SUBPROPERTYOF); List<KBHandle> results = asHandles(zbwGnd, SPARQLQueryBuilder .forItems(kb) .withLabelStartingWith("Thom")); assertThat(results).extracting(KBHandle::getIdentifier).doesNotHaveDuplicates(); assertThat(results).isNotEmpty(); assertThat(results).extracting(KBHandle::getUiLabel) .allMatch(label -> label.toLowerCase().startsWith("thom")); }
Example #14
Source File: SpinParser.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Map<IRI, RuleProperty> parseRuleProperties(TripleSource store) throws RDF4JException { Map<IRI, RuleProperty> rules = new HashMap<>(); try (CloseableIteration<IRI, QueryEvaluationException> rulePropIter = TripleSources .getSubjectURIs(RDFS.SUBPROPERTYOF, SPIN.RULE_PROPERTY, store)) { while (rulePropIter.hasNext()) { IRI ruleProp = rulePropIter.next(); RuleProperty ruleProperty = new RuleProperty(ruleProp); List<IRI> nextRules = getNextRules(ruleProp, store); ruleProperty.setNextRules(nextRules); int maxIterCount = getMaxIterationCount(ruleProp, store); ruleProperty.setMaxIterationCount(maxIterCount); rules.put(ruleProp, ruleProperty); } } return rules; }
Example #15
Source File: RDFSchemaRepositoryConnectionTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testInferencerTransactionIsolation() throws Exception { if (IsolationLevels.NONE.isCompatibleWith(level)) { return; } testCon.begin(); testCon.add(bob, name, nameBob); assertTrue(testCon.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE, true)); assertFalse(testCon2.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE, true)); testCon.commit(); assertTrue(testCon.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE, true)); assertTrue(testCon2.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE, true)); }
Example #16
Source File: EvaluationStrategyTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testDatetimeSubtypesExtended() { ValueFactory vf = extendedRepo.getValueFactory(); try (RepositoryConnection conn = extendedRepo.getConnection()) { Literal l1 = vf.createLiteral("2009", XMLSchema.GYEAR); Literal l2 = vf.createLiteral("2009-01", XMLSchema.GYEARMONTH); IRI s1 = vf.createIRI("urn:s1"); IRI s2 = vf.createIRI("urn:s2"); conn.add(s1, RDFS.LABEL, l1); conn.add(s2, RDFS.LABEL, l2); String query = "SELECT * WHERE { ?s rdfs:label ?l . FILTER(?l >= \"2008\"^^xsd:gYear) }"; List<BindingSet> result = QueryResults.asList(conn.prepareTupleQuery(query).evaluate()); assertEquals(2, result.size()); } }
Example #17
Source File: SPARQLUpdateTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testDeleteInsertWhereWithBindings() throws Exception { logger.debug("executing test testDeleteInsertWhereWithBindings"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("DELETE { ?x foaf:name ?y } INSERT {?x rdfs:label ?y . } WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("x", bob); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bob"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); assertFalse(con.hasStatement(bob, FOAF.NAME, f.createLiteral("Bob"), true)); assertTrue(con.hasStatement(alice, FOAF.NAME, f.createLiteral("Alice"), true)); }
Example #18
Source File: TestFixtures.java From inception with Apache License 2.0 | 6 votes |
public KnowledgeBase buildKnowledgeBase(Project project, String name, Reification reification) { KnowledgeBase kb = new KnowledgeBase(); kb.setName(name); kb.setProject(project); kb.setType(RepositoryType.LOCAL); kb.setClassIri(RDFS.CLASS); kb.setSubclassIri(RDFS.SUBCLASSOF); kb.setTypeIri(RDF.TYPE); kb.setLabelIri(RDFS.LABEL); kb.setPropertyTypeIri(RDF.PROPERTY); kb.setDescriptionIri(RDFS.COMMENT); kb.setSubPropertyIri(RDFS.SUBPROPERTYOF); kb.setFullTextSearchIri(IriConstants.FTS_LUCENE); // Intentionally using different IRIs for label/description and property-label/description // to detect cases where we accidentally construct queries using the wrong mapping, e.g. // querying for properties with the class label. kb.setPropertyLabelIri(SKOS.PREF_LABEL); kb.setPropertyDescriptionIri(SKOS.DEFINITION); kb.setRootConcepts(new ArrayList<>()); kb.setReification(reification); kb.setMaxResults(1000); kb.setDefaultLanguage("en"); return kb; }
Example #19
Source File: RdfsSubClassOfReasoner.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
static RdfsSubClassOfReasoner createReasoner(ShaclSailConnection shaclSailConnection) { long before = 0; if (shaclSailConnection.sail.isPerformanceLogging()) { before = System.currentTimeMillis(); } RdfsSubClassOfReasoner rdfsSubClassOfReasoner = new RdfsSubClassOfReasoner(); try (Stream<? extends Statement> stream = shaclSailConnection.getStatements(null, RDFS.SUBCLASSOF, null, false) .stream()) { stream.forEach(rdfsSubClassOfReasoner::addSubClassOfStatement); } rdfsSubClassOfReasoner.calculateSubClassOf(rdfsSubClassOfReasoner.subClassOfStatements); if (shaclSailConnection.sail.isPerformanceLogging()) { logger.info("RdfsSubClassOfReasoner.createReasoner() took {} ms", System.currentTimeMillis() - before); } return rdfsSubClassOfReasoner; }
Example #20
Source File: InferredContextTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testInferrecContextNoNull() { SchemaCachingRDFSInferencer sail = new SchemaCachingRDFSInferencer(new MemoryStore()); sail.initialize(); sail.setAddInferredStatementsToDefaultContext(false); try (SchemaCachingRDFSInferencerConnection connection = sail.getConnection()) { connection.begin(); connection.addStatement(bNode, RDF.TYPE, type, context); connection.commit(); assertTrue(connection.hasStatement(bNode, RDF.TYPE, RDFS.RESOURCE, true, context)); try (CloseableIteration<? extends Statement, SailException> statements = connection.getStatements(bNode, RDF.TYPE, RDFS.RESOURCE, true)) { while (statements.hasNext()) { Statement next = statements.next(); assertEquals("Context should be equal", context, next.getContext()); } } } }
Example #21
Source File: NotUniqueLangBenchmarkEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Setup(Level.Iteration) public void setUp() { Logger root = (Logger) LoggerFactory.getLogger(ShaclSailConnection.class.getName()); root.setLevel(ch.qos.logback.classic.Level.INFO); SimpleValueFactory vf = SimpleValueFactory.getInstance(); allStatements = BenchmarkConfigs.generateStatements(((statements, i, j) -> { IRI iri = vf.createIRI("http://example.com/" + i + "_" + j); statements.add(vf.createStatement(iri, RDF.TYPE, RDFS.RESOURCE)); statements.add(vf.createStatement(iri, RDFS.LABEL, vf.createLiteral(i + "_" + j + "_en", "en"))); statements.add(vf.createStatement(iri, RDFS.LABEL, vf.createLiteral(i + "_" + j + "_no", "no"))); statements.add(vf.createStatement(iri, RDFS.LABEL, vf.createLiteral(i + "_" + j + "_dk", "dk"))); statements.add(vf.createStatement(iri, RDFS.LABEL, vf.createLiteral(i + "_" + j + "_es", "es"))); statements.add(vf.createStatement(iri, RDFS.LABEL, vf.createLiteral(i + "_" + j + "_es2", "es"))); })); System.gc(); }
Example #22
Source File: ConfigViewTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testRender() throws Exception { ConfigView configView = ConfigView.getInstance(); Model configData = new LinkedHashModelFactory().createEmptyModel(); configData.add(RDF.ALT, RDF.TYPE, RDFS.CLASS); Map<Object, Object> map = new LinkedHashMap<>(); map.put(ConfigView.HEADERS_ONLY, false); map.put(ConfigView.CONFIG_DATA_KEY, configData); map.put(ConfigView.FORMAT_KEY, RDFFormat.NTRIPLES); final MockHttpServletRequest request = new MockHttpServletRequest(); request.setMethod(HttpMethod.GET.name()); request.addHeader("Accept", RDFFormat.NTRIPLES.getDefaultMIMEType()); MockHttpServletResponse response = new MockHttpServletResponse(); configView.render(map, request, response); String ntriplesData = response.getContentAsString(); Model renderedData = Rio.parse(new StringReader(ntriplesData), "", RDFFormat.NTRIPLES); assertThat(renderedData).isNotEmpty(); }
Example #23
Source File: SPARQLUpdateTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testInsertWhereWithBindings2() throws Exception { logger.debug("executing test testInsertWhereWithBindings2"); StringBuilder update = new StringBuilder(); update.append(getNamespaceDeclarations()); update.append("INSERT {?x rdfs:label ?z . } WHERE {?x foaf:name ?y }"); Update operation = con.prepareUpdate(QueryLanguage.SPARQL, update.toString()); operation.setBinding("z", f.createLiteral("Bobbie")); operation.setBinding("x", bob); assertFalse(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bobbie"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, null, true)); operation.execute(); assertTrue(con.hasStatement(bob, RDFS.LABEL, f.createLiteral("Bobbie"), true)); assertFalse(con.hasStatement(alice, RDFS.LABEL, f.createLiteral("Alice"), true)); }
Example #24
Source File: InferenceTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void simpleInferenceTest() { ElasticsearchStore elasticsearchStore = new ElasticsearchStore(singletonClientProvider, "testindex"); SailRepository sailRepository = new SailRepository(new SchemaCachingRDFSInferencer(elasticsearchStore)); IRI graph1 = vf.createIRI("http://example.com/graph1"); try (SailRepositoryConnection connection = sailRepository.getConnection()) { connection.add(vf.createBNode(), RDFS.LABEL, vf.createLiteral("label"), graph1); long explicitStatements = connection.getStatements(null, null, null, false, graph1).stream().count(); assertEquals(1, explicitStatements); long inferredStatements = connection.getStatements(null, null, null, true, graph1).stream().count(); assertEquals(2, inferredStatements); } sailRepository.shutDown(); }
Example #25
Source File: TestNativeStoreUpgrade.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testDevel() throws IOException, SailException { NativeStore store = new NativeStore(dataDir); try { store.initialize(); try (NotifyingSailConnection con = store.getConnection()) { ValueFactory vf = store.getValueFactory(); con.begin(); con.addStatement(RDF.VALUE, RDFS.LABEL, vf.createLiteral("value")); con.commit(); } } finally { store.shutDown(); } new File(dataDir, "nativerdf.ver").delete(); assertValue(dataDir); assertTrue(new File(dataDir, "nativerdf.ver").exists()); }
Example #26
Source File: AbstractModelTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected Model getNewModelObjectSingleLiteralDoubleURI() { Model model = getNewEmptyModel(); model.add(uri1, RDFS.LABEL, literal1); model.add(uri1, RDFS.LABEL, uri2); model.add(uri1, RDFS.LABEL, uri3); assertEquals(3, model.size()); return model; }
Example #27
Source File: AbstractModelTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public final void testFilter_RemoveFromFilter() { Model model = getNewEmptyModel(); model.add(uri1, RDFS.LABEL, literal1, uri1); Model filter = model.filter(uri1, RDFS.LABEL, literal1, uri1); assertTrue(filter.contains(uri1, RDFS.LABEL, literal1)); filter.remove(uri1, RDFS.LABEL, literal1, uri1); assertFalse(model.contains(uri1, RDFS.LABEL, literal1)); assertFalse(filter.contains(uri1, RDFS.LABEL, literal1)); }
Example #28
Source File: DatatypeBenchmarkSerializableEmpty.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Benchmark public void sparqlInsteadOfShacl() { SailRepository repository = new SailRepository(new MemoryStore()); repository.init(); try (SailRepositoryConnection connection = repository.getConnection()) { connection.begin(IsolationLevels.SERIALIZABLE); connection.commit(); } try (SailRepositoryConnection connection = repository.getConnection()) { for (List<Statement> statements : allStatements) { connection.begin(IsolationLevels.SERIALIZABLE); connection.add(statements); try (Stream<BindingSet> stream = connection .prepareTupleQuery("select * where {?a a <" + RDFS.RESOURCE + ">; <" + FOAF.AGE + "> ?age. FILTER(datatype(?age) != <http://www.w3.org/2001/XMLSchema#int>)}") .evaluate() .stream()) { stream.forEach(System.out::println); } connection.commit(); } } repository.shutDown(); }
Example #29
Source File: SPARQLQueryBuilder.java From inception with Apache License 2.0 | 5 votes |
@Override public SPARQLQueryOptionalElements retrieveDomainAndRange() { projections.add(VAR_RANGE); projections.add(VAR_DOMAIN); addPattern(SECONDARY, optional(VAR_SUBJECT.has(RDFS.RANGE, VAR_RANGE))); addPattern(SECONDARY, optional(VAR_SUBJECT.has(RDFS.DOMAIN, VAR_DOMAIN))); return this; }
Example #30
Source File: AbstractModelTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected Model getNewModelObjectSingleBNodeDoubleLiteral() { Model model = getNewEmptyModel(); model.add(uri1, RDFS.LABEL, bnode1); model.add(uri1, RDFS.LABEL, literal1); model.add(uri1, RDFS.LABEL, literal2); assertEquals(3, model.size()); return model; }