Java Code Examples for org.eclipse.rdf4j.model.vocabulary.RDF#NAMESPACE
The following examples show how to use
org.eclipse.rdf4j.model.vocabulary.RDF#NAMESPACE .
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: ForwardChainingRDFSInferencerConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private int applyRuleX1() throws SailException { int nofInferred = 0; String prefix = RDF.NAMESPACE + "_"; Iterable<Statement> iter = newThisIteration.getStatements(null, null, null); for (Statement st : iter) { IRI predNode = st.getPredicate(); String predURI = predNode.toString(); if (predURI.startsWith(prefix) && isValidPredicateNumber(predURI.substring(prefix.length()))) { boolean added = addInferredStatement(predNode, RDF.TYPE, RDFS.CONTAINERMEMBERSHIPPROPERTY); if (added) { nofInferred++; } } } return nofInferred; }
Example 2
Source File: RdfCloudTripleStoreConnectionTest.java From rya with Apache License 2.0 | 5 votes |
public void testEquivPropOf() throws Exception { if(internalInferenceEngine == null) { return; //infer not supported; } RepositoryConnection conn = repository.getConnection(); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "undergradDegreeFrom"), OWL.EQUIVALENTPROPERTY, VF.createIRI(litdupsNS, "ugradDegreeFrom"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "UgradA"), VF.createIRI(litdupsNS, "undergradDegreeFrom"), VF.createIRI(litdupsNS, "Harvard"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "GradB"), VF.createIRI(litdupsNS, "ugradDegreeFrom"), VF.createIRI(litdupsNS, "Harvard"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "GradC"), VF.createIRI(litdupsNS, "ugraduateDegreeFrom"), VF.createIRI(litdupsNS, "Harvard"))); conn.commit(); conn.close(); internalInferenceEngine.refreshGraph(); conn = repository.getConnection(); String query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:ugradDegreeFrom lit:Harvard.}"; TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); CountTupleHandler tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(2, tupleHandler.getCount()); conn.close(); }
Example 3
Source File: RdfCloudTripleStoreConnectionTest.java From rya with Apache License 2.0 | 5 votes |
public void testInverseOf() throws Exception { if(internalInferenceEngine == null) { return; //infer not supported; } RepositoryConnection conn = repository.getConnection(); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "degreeFrom"), OWL.INVERSEOF, VF.createIRI(litdupsNS, "hasAlumnus"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "UgradA"), VF.createIRI(litdupsNS, "degreeFrom"), VF.createIRI(litdupsNS, "Harvard"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "GradB"), VF.createIRI(litdupsNS, "degreeFrom"), VF.createIRI(litdupsNS, "Harvard"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "Harvard"), VF.createIRI(litdupsNS, "hasAlumnus"), VF.createIRI(litdupsNS, "AlumC"))); conn.commit(); conn.close(); internalInferenceEngine.refreshGraph(); conn = repository.getConnection(); String query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {lit:Harvard lit:hasAlumnus ?s.}"; TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); CountTupleHandler tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(3, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:degreeFrom lit:Harvard.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(3, tupleHandler.getCount()); conn.close(); }
Example 4
Source File: CustomFederationConnectionTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testAssertionErrorReproduction() { for (int i = 0; i < 1000; i++) { ValueFactory vf = SimpleValueFactory.getInstance(); BNode address = vf.createBNode(); BNode anotherAddress = vf.createBNode(); ModelBuilder builder = new ModelBuilder(); builder .setNamespace("ex", "http://example.org/") .subject("ex:Picasso") .add(RDF.TYPE, "ex:Artist") .add(FOAF.FIRST_NAME, "Pablo") .add("ex:homeAddress", address) .subject("ex:AnotherArtist") .add(RDF.TYPE, "ex:Artist") .add(FOAF.FIRST_NAME, "AnotherArtist") .add("ex:homeAddress", anotherAddress) .subject(address) .add("ex:street", "31 Art Gallery") .add("ex:city", "Madrid") .add("ex:country", "Spain") .subject(anotherAddress) .add("ex:street", "32 Art Gallery") .add("ex:city", "London") .add("ex:country", "UK"); Model model = builder.build(); Repository repo1 = new SailRepository(new MemoryStore()); repo1.init(); try (RepositoryConnection connection = repo1.getConnection()) { connection.add(model); } Repository repo2 = new SailRepository(new MemoryStore()); repo2.init(); Federation fed = new Federation(); fed.addMember(repo1); fed.addMember(repo2); String ex = "http://example.org/"; String queryString = "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX foaf: <" + FOAF.NAMESPACE + ">\n" + "PREFIX ex: <" + ex + ">\n" + "select (count(?persons) as ?count) {\n" + " ?persons rdf:type ex:Artist ;\n" + " ex:homeAddress ?country .\n" + " ?country ex:country \"Spain\" . }"; SailRepository fedRepo = new SailRepository(fed); fedRepo.init(); IntStream.range(0, 100).parallel().forEach(j -> { try (SailRepositoryConnection fedRepoConn = fedRepo.getConnection()) { fedRepoConn.begin(); TupleQuery query = fedRepoConn.prepareTupleQuery(QueryLanguage.SPARQL, queryString); try (TupleQueryResult eval = query.evaluate()) { if (eval.hasNext()) { Value next = eval.next().getValue("count"); assertEquals(1, ((Literal) next).intValue()); } else { fail("No result"); } } fedRepoConn.commit(); } }); fedRepo.shutDown(); } }
Example 5
Source File: IsTripleFunction.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public String getURI() { return RDF.NAMESPACE + "isTriple"; }
Example 6
Source File: SAXFilter.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 4 votes |
private void checkAndCopyAttributes(Attributes attributes, ElementInfo elInfo) throws SAXException, RDFParseException { Atts atts = new Atts(attributes.getLength()); int attCount = attributes.getLength(); for (int i = 0; i < attCount; i++) { String qName = attributes.getQName(i); String value = attributes.getValue(i); // attributes starting with "xml" should be ignored, except for the // ones that are handled by this parser (xml:lang and xml:base). if (qName.startsWith("xml")) { if (qName.equals("xml:lang")) { elInfo.xmlLang = value; } else if (qName.equals("xml:base")) { elInfo.setBaseURI(value); } } else { String namespace = attributes.getURI(i); String localName = attributes.getLocalName(i); // A limited set of unqualified attributes must be supported by // parsers, as is specified in section 6.1.4 of the spec if ("".equals(namespace)) { if (localName.equals("ID") || localName.equals("about") || localName.equals("resource") || localName.equals("parseType") || localName.equals("type")) { rdfParser.reportWarning("use of unqualified attribute " + localName + " has been deprecated"); namespace = RDF.NAMESPACE; } } if ("".equals(namespace)) { rdfParser.reportError("unqualified attribute '" + qName + "' not allowed", XMLParserSettings.FAIL_ON_INVALID_QNAME); } Att att = new Att(namespace, localName, qName, value); atts.addAtt(att); } } elInfo.atts = atts; }
Example 7
Source File: RdfCloudTripleStoreConnectionTest.java From rya with Apache License 2.0 | 4 votes |
public void testSubPropertyOf() throws Exception { if(internalInferenceEngine == null) { return; //infer not supported; } RepositoryConnection conn = repository.getConnection(); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "undergradDegreeFrom"), RDFS.SUBPROPERTYOF, VF.createIRI(litdupsNS, "degreeFrom"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "gradDegreeFrom"), RDFS.SUBPROPERTYOF, VF.createIRI(litdupsNS, "degreeFrom"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "degreeFrom"), RDFS.SUBPROPERTYOF, VF.createIRI(litdupsNS, "memberOf"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "memberOf"), RDFS.SUBPROPERTYOF, VF.createIRI(litdupsNS, "associatedWith"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "UgradA"), VF.createIRI(litdupsNS, "undergradDegreeFrom"), VF.createIRI(litdupsNS, "Harvard"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "GradB"), VF.createIRI(litdupsNS, "gradDegreeFrom"), VF.createIRI(litdupsNS, "Yale"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "ProfessorC"), VF.createIRI(litdupsNS, "memberOf"), VF.createIRI(litdupsNS, "Harvard"))); conn.commit(); conn.close(); internalInferenceEngine.refreshGraph(); conn = repository.getConnection(); String query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:degreeFrom lit:Harvard.}"; TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); CountTupleHandler tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(1, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:memberOf lit:Harvard.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(2, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:associatedWith ?o.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(3, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:gradDegreeFrom lit:Yale.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(1, tupleHandler.getCount()); conn.close(); }
Example 8
Source File: RdfCloudTripleStoreConnectionTest.java From rya with Apache License 2.0 | 4 votes |
public void testSymmPropOf() throws Exception { if(internalInferenceEngine == null) { return; //infer not supported; } RepositoryConnection conn = repository.getConnection(); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "friendOf"), RDF.TYPE, OWL.SYMMETRICPROPERTY)); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "Bob"), VF.createIRI(litdupsNS, "friendOf"), VF.createIRI(litdupsNS, "Jeff"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "James"), VF.createIRI(litdupsNS, "friendOf"), VF.createIRI(litdupsNS, "Jeff"))); conn.commit(); conn.close(); internalInferenceEngine.refreshGraph(); conn = repository.getConnection(); String query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:friendOf lit:Bob.}"; TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); CountTupleHandler tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(1, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:friendOf lit:James.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(1, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:friendOf lit:Jeff.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(2, tupleHandler.getCount()); conn.close(); }
Example 9
Source File: RdfCloudTripleStoreConnectionTest.java From rya with Apache License 2.0 | 4 votes |
public void testTransitiveProp() throws Exception { if(internalInferenceEngine == null) { return; //infer not supported; } RepositoryConnection conn = repository.getConnection(); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "subRegionOf"), RDF.TYPE, OWL.TRANSITIVEPROPERTY)); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "Queens"), VF.createIRI(litdupsNS, "subRegionOf"), VF.createIRI(litdupsNS, "NYC"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "NYC"), VF.createIRI(litdupsNS, "subRegionOf"), VF.createIRI(litdupsNS, "NY"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "NY"), VF.createIRI(litdupsNS, "subRegionOf"), VF.createIRI(litdupsNS, "US"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "US"), VF.createIRI(litdupsNS, "subRegionOf"), VF.createIRI(litdupsNS, "NorthAmerica"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "NorthAmerica"), VF.createIRI(litdupsNS, "subRegionOf"), VF.createIRI(litdupsNS, "World"))); conn.commit(); conn.close(); internalInferenceEngine.refreshGraph(); conn = repository.getConnection(); String query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:subRegionOf lit:NorthAmerica.}"; TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); CountTupleHandler tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(4, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s lit:subRegionOf lit:NY.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(2, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {lit:Queens lit:subRegionOf ?s.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(5, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {lit:NY lit:subRegionOf ?s.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(3, tupleHandler.getCount()); conn.close(); }
Example 10
Source File: RdfCloudTripleStoreConnectionTest.java From rya with Apache License 2.0 | 4 votes |
public void testSubClassOf() throws Exception { if(internalInferenceEngine == null) { return; //infer not supported; } RepositoryConnection conn = repository.getConnection(); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "UndergraduateStudent"), RDFS.SUBCLASSOF, VF.createIRI(litdupsNS, "Student"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "Student"), RDFS.SUBCLASSOF, VF.createIRI(litdupsNS, "Person"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "UgradA"), RDF.TYPE, VF.createIRI(litdupsNS, "UndergraduateStudent"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "StudentB"), RDF.TYPE, VF.createIRI(litdupsNS, "Student"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "PersonC"), RDF.TYPE, VF.createIRI(litdupsNS, "Person"))); conn.commit(); conn.close(); internalInferenceEngine.refreshGraph(); conn = repository.getConnection(); //simple api first RepositoryResult<Statement> person = conn.getStatements(null, RDF.TYPE, VF.createIRI(litdupsNS, "Person"), true); int count = 0; while (person.hasNext()) { count++; person.next(); } person.close(); assertEquals(3, count); String query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s rdf:type lit:Person.}"; TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); CountTupleHandler tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(3, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s rdf:type lit:Student.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(2, tupleHandler.getCount()); query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select * where {?s rdf:type lit:UndergraduateStudent.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(1, tupleHandler.getCount()); conn.close(); }
Example 11
Source File: RdfCloudTripleStoreConnectionTest.java From rya with Apache License 2.0 | 4 votes |
public void testSameAs() throws Exception { if(internalInferenceEngine == null) { return; //infer not supported; } RepositoryConnection conn = repository.getConnection(); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "StudentA1"), OWL.SAMEAS, VF.createIRI(litdupsNS, "StudentA2"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "StudentA2"), OWL.SAMEAS, VF.createIRI(litdupsNS, "StudentA3"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "StudentB1"), OWL.SAMEAS, VF.createIRI(litdupsNS, "StudentB2"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "StudentB2"), OWL.SAMEAS, VF.createIRI(litdupsNS, "StudentB3"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "StudentA1"), VF.createIRI(litdupsNS, "pred1"), VF.createIRI(litdupsNS, "StudentB3"))); conn.add(VF.createStatement(VF.createIRI(litdupsNS, "StudentB1"), VF.createIRI(litdupsNS, "pred2"), VF.createIRI(litdupsNS, "StudentA3"))); conn.commit(); conn.close(); internalInferenceEngine.refreshGraph(); conn = repository.getConnection(); // query where finds sameAs for obj, pred specified String query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select ?s where {?s lit:pred1 lit:StudentB2.}"; TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); CountTupleHandler tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(1, tupleHandler.getCount()); // query where finds sameAs for obj only specified query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select ?s where {?s ?p lit:StudentB2.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(3, tupleHandler.getCount()); // including sameAs assertions // query where finds sameAs for subj, pred specified query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select ?s where {lit:StudentB2 lit:pred2 ?s.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(1, tupleHandler.getCount()); // including sameAs assertions // query where finds sameAs for subj only specified query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select ?s where {lit:StudentB2 ?p ?s.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(3, tupleHandler.getCount()); // including sameAs assertions // query where finds sameAs for subj, obj specified query = "PREFIX rdfs: <" + RDFS.NAMESPACE + ">\n" + "PREFIX rdf: <" + RDF.NAMESPACE + ">\n" + "PREFIX lit: <" + litdupsNS + ">\n" + "select ?s where {lit:StudentB2 ?s lit:StudentA2.}"; tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleHandler = new CountTupleHandler(); tupleQuery.evaluate(tupleHandler); assertEquals(1, tupleHandler.getCount()); conn.close(); }