Java Code Examples for org.openrdf.model.vocabulary.RDF#TYPE
The following examples show how to use
org.openrdf.model.vocabulary.RDF#TYPE .
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: TestEncodeDecodeUnicodeIVs.java From database with GNU General Public License v2.0 | 6 votes |
/** * Unit test for inlining an entire URI using {@link FullyInlineURIIV}. The URI * is inlined as a Unicode component using {@link DTE#XSDString}. The * extension bit is NOT set since we are not factoring out the namespace * component of the URI. */ public void test_encodeDecode_Inline_URI() { final IV<?, ?>[] e = {// new FullyInlineURIIV<BigdataURI>(new URIImpl("http://www.bigdata.com")),// new FullyInlineURIIV<BigdataURI>(RDF.TYPE),// new FullyInlineURIIV<BigdataURI>(RDF.SUBJECT),// new FullyInlineURIIV<BigdataURI>(RDF.BAG),// new FullyInlineURIIV<BigdataURI>(RDF.OBJECT),// }; doEncodeDecodeTest(e); doComparatorTest(e); }
Example 2
Source File: TestBlobsWriteTask.java From database with GNU General Public License v2.0 | 6 votes |
public void test_add_various_toldBNodes() { // The values that we will be testing with. final Value[] valuesIn = new Value[] {// new LiteralImpl("abc"), // RDF.TYPE,// RDF.PROPERTY,// new LiteralImpl("test"),// new LiteralImpl("test", "en"),// new LiteralImpl("10", new URIImpl("http://www.w3.org/2001/XMLSchema#int")), new LiteralImpl("12", new URIImpl("http://www.w3.org/2001/XMLSchema#float")), new LiteralImpl("12.", new URIImpl("http://www.w3.org/2001/XMLSchema#float")), new LiteralImpl("12.0", new URIImpl("http://www.w3.org/2001/XMLSchema#float")), new LiteralImpl("12.00", new URIImpl("http://www.w3.org/2001/XMLSchema#float")), new BNodeImpl("a"),// new BNodeImpl("12"),// }; doAddTermsTest(valuesIn, true/* toldBNodes */); }
Example 3
Source File: TestBlobsWriteTask.java From database with GNU General Public License v2.0 | 6 votes |
/** * Note: Blank nodes are NOT included in this test since the test helper is * not smart enough to verify the blank nodes will not be unified when using * standard bnode semantics. However, {@link TestBlobsIndex} does verify * both standard and told bnode semantics. */ public void test_add_various_standardBNodes() { /* The values that we will be testing with. */ final Value[] valuesIn = new Value[] {// new LiteralImpl("abc"), // RDF.TYPE,// RDF.PROPERTY,// new LiteralImpl("test"),// new LiteralImpl("test", "en"),// new LiteralImpl("10", new URIImpl("http://www.w3.org/2001/XMLSchema#int")), new LiteralImpl("12", new URIImpl("http://www.w3.org/2001/XMLSchema#float")), new LiteralImpl("12.", new URIImpl("http://www.w3.org/2001/XMLSchema#float")), new LiteralImpl("12.0", new URIImpl("http://www.w3.org/2001/XMLSchema#float")), new LiteralImpl("12.00", new URIImpl("http://www.w3.org/2001/XMLSchema#float")), // new BNodeImpl("a"),// // new BNodeImpl("12"),// }; doAddTermsTest(valuesIn, false/* toldBNodes */); }
Example 4
Source File: BigdataRDFFactory.java From database with GNU General Public License v2.0 | 4 votes |
/** * Construct an instance with a simple Sesame ValueFactoryImpl. */ private BigdataRDFFactory() { super(new ValueFactoryImpl(), GRAPH_NAMESPACE, VERTEX_NAMESPACE, EDGE_NAMESPACE, RDF.TYPE, VERTEX, EDGE, RDFS.LABEL); }
Example 5
Source File: TestTruthMaintenance.java From database with GNU General Public License v2.0 | 4 votes |
/** * This test demonstrates an infinite loop in TM arising from owl:sameAs. */ public void test_infiniteloop() { // if(true) fail("re-enable this test"); final URI a = new URIImpl("http://www.bigdata.com/a"); final URI b = new URIImpl("http://www.bigdata.com/b"); final URI entity = new URIImpl("http://www.bigdata.com/Entity"); final URI sameAs = OWL.SAMEAS; // /* // * Note: not using rdf:type to avoid entailments about (x rdf:type // * Class) and (x rdfs:subClassOf y) that are not required by this test. // */ // URI rdfType = new URIImpl("http://www.bigdata.com/type"); final URI rdfType = RDF.TYPE; final AbstractTripleStore store = getStore(); try { final InferenceEngine inf = store.getInferenceEngine(); final TruthMaintenance tm = new TruthMaintenance(inf); // add some assertions and verify aspects of their closure. { final StatementBuffer assertionBuffer = new StatementBuffer(tm .newTempTripleStore(), store, 100/* capacity */, 10/*queueCapacity*/); // stmt a assertionBuffer.add(a, rdfType, entity ); // assertionBuffer.add(a, x, y ); // stmt b assertionBuffer.add(b, rdfType, entity ); // assert the sameas assertionBuffer.add(a, sameAs, b ); // flush statements to the tempStore. assertionBuffer.flush(); // perform closure and write on the database. tm.assertAll((TempTripleStore) assertionBuffer .getStatementStore()); // dump after closure. if (log.isInfoEnabled()) log.info("\ndump after closure:\n" + store.dumpStore(store, true, true, false, true)); } /* * retract stmt A and update the closure. * * then verify that the retracted statement is gone and that the * other explicit statements were not touched. */ { final StatementBuffer retractionBuffer = new StatementBuffer(tm .newTempTripleStore(), store, 100/* capacity */, 10/*queueCapacity*/); // retract the sameas retractionBuffer.add(a, sameAs, b); // flush statements to the tempStore. retractionBuffer.flush(); // update the closure. tm.retractAll((TempTripleStore) retractionBuffer .getStatementStore()); // dump after re-closure. if (log.isInfoEnabled()) log.info("\ndump after re-closure:\n" + store.dumpStore(store, true, true, false, true)); } } finally { store.__tearDownUnitTest(); } }
Example 6
Source File: TestRuleRdfs03.java From database with GNU General Public License v2.0 | 4 votes |
/** * Literals may not appear in the subject position, but an rdfs4b entailment * can put them there unless you explicitly filter it out. * <P> * Note: {@link RuleRdfs04b} is the other way that literals can be entailed * into the subject position. * * @throws Exception */ public void test_rdfs3_filterLiterals() throws Exception { final Properties properties = super.getProperties(); // override the default axiom model. properties.setProperty(Options.AXIOMS_CLASS, NoAxioms.class.getName()); final AbstractTripleStore store = getStore(properties); try { URI A = new URIImpl("http://www.foo.org/A"); URI X = new URIImpl("http://www.foo.org/X"); URI U = new URIImpl("http://www.foo.org/U"); Literal V1 = new LiteralImpl("V1"); // a literal. URI V2 = new URIImpl("http://www.foo.org/V2"); // not a literal. URI rdfRange = RDFS.RANGE; URI rdfType = RDF.TYPE; store.addStatement(A, rdfRange, X); store.addStatement(U, A, V1); store.addStatement(U, A, V2); assertTrue(store.hasStatement(A, rdfRange, X)); assertTrue(store.hasStatement(U, A, V1)); assertTrue(store.hasStatement(U, A, V2)); assertEquals(3,store.getStatementCount()); /* * Note: The rule computes the entailement but it gets whacked by * the DoNotAddFilter on the InferenceEngine, so it is counted here * but does not show in the database. */ final Vocabulary vocab = store.getVocabulary(); final Rule r = new RuleRdfs03( store.getSPORelation().getNamespace(), vocab); final IElementFilter<ISPO> filter = new DoNotAddFilter(vocab, store.getAxioms(), true/* forwardChainRdfTypeRdfsResource */); applyRule(store, r, filter/* , false justified */, -1/* solutionCount */, 1/* mutationCount*/); /* * validate the state of the primary store. */ assertTrue(store.hasStatement(A, rdfRange, X)); assertTrue(store.hasStatement(U, A, V1)); assertTrue(store.hasStatement(U, A, V2)); assertTrue(store.hasStatement(V2, rdfType, X)); assertEquals(4,store.getStatementCount()); } finally { store.__tearDownUnitTest(); } }
Example 7
Source File: TestStatementBuffer.java From database with GNU General Public License v2.0 | 4 votes |
/** * Test verifies detection of duplicate terms and their automatic * replacement with a canonicalizing term. */ public void test_handleStatement_distinctTerm() { final int capacity = 5; final AbstractTripleStore store = getStore(); try { final StatementBuffer<Statement> buffer = new StatementBuffer<Statement>( store, capacity); // assertTrue(buffer.distinct); /* * add a statement. */ final URI s1 = new URIImpl("http://www.foo.org"); final URI p1 = RDF.TYPE; final URI o1 = RDFS.RESOURCE; final URI c1 = null; // no context. buffer.handleStatement(s1, p1, o1, c1, StatementEnum.Explicit); assertEquals(8, buffer.numURIs); assertEquals(0, buffer.numLiterals); assertEquals(0, buffer.numBNodes); assertEquals(1, buffer.numStmts); /* * add another statement. */ final URI s2 = new URIImpl("http://www.foo.org"); // duplicate term! final URI p2 = RDFS.LABEL; final Literal o2 = new LiteralImpl("test lit."); final URI c2 = null; buffer.handleStatement(s2, p2, o2, c2, StatementEnum.Explicit); assertEquals(9, buffer.numURIs); // only 4 since one is duplicate. assertEquals(1, buffer.numLiterals); assertEquals(0, buffer.numBNodes); assertEquals(2, buffer.numStmts); /* * add a duplicate statement. */ final URI s3 = new URIImpl("http://www.foo.org"); // duplicate term final URI p3 = RDFS.LABEL; // duplicate term final Literal o3 = new LiteralImpl("test lit."); // duplicate term final URI c3 = null; buffer.handleStatement(s3, p3, o3, c3, StatementEnum.Explicit); assertEquals(9, buffer.numURIs); assertEquals(1, buffer.numLiterals); assertEquals(0, buffer.numBNodes); assertEquals(3, buffer.numStmts); /* * add a duplicate statement using the _same_ term objects. */ buffer.handleStatement(s3, p3, o3, c3, StatementEnum.Explicit); assertEquals(9, buffer.numURIs); assertEquals(1, buffer.numLiterals); assertEquals(0, buffer.numBNodes); assertEquals(4, buffer.numStmts); buffer.flush(); } finally { store.__tearDownUnitTest(); } }
Example 8
Source File: TestInlineValues.java From database with GNU General Public License v2.0 | 4 votes |
public void testInlineValuesLT() throws Exception { final BigdataSail sail = getSail(); sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); cxn.setAutoCommit(false); try { final ValueFactory vf = sail.getValueFactory(); URI A = vf.createURI("_:A"); URI B = vf.createURI("_:B"); URI X = vf.createURI("_:X"); URI AGE = vf.createURI("_:AGE"); Literal _25 = vf.createLiteral(25); Literal _45 = vf.createLiteral(45); cxn.add(A, RDF.TYPE, X); cxn.add(B, RDF.TYPE, X); cxn.add(A, AGE, _25); cxn.add(B, AGE, _45); /* * Note: The either flush() or commit() is required to flush the * statement buffers to the database before executing any operations * that go around the sail. */ cxn.flush();//commit(); if (log.isInfoEnabled()) { log.info(cxn.getTripleStore().dumpStore()); } { String query = "select ?s ?age " + "WHERE { " + " ?s <"+RDF.TYPE+"> <"+X+"> . " + " ?s <"+AGE+"> ?age . " + " FILTER( ?age < 35 ) . " + "}"; final TupleQuery tupleQuery = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); TupleQueryResult result = tupleQuery.evaluate(); Collection<BindingSet> solution = new LinkedList<BindingSet>(); solution.add(createBindingSet(new Binding[] { new BindingImpl("s", A), new BindingImpl("age", _25) })); compare(result, solution); } } finally { cxn.close(); sail.__tearDownUnitTest(); } }
Example 9
Source File: TestInlineValues.java From database with GNU General Public License v2.0 | 4 votes |
public void testInlineValuesGT() throws Exception { final BigdataSail sail = getSail(); sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); cxn.setAutoCommit(false); try { final ValueFactory vf = sail.getValueFactory(); URI A = vf.createURI("_:A"); URI B = vf.createURI("_:B"); URI X = vf.createURI("_:X"); URI AGE = vf.createURI("_:AGE"); Literal _25 = vf.createLiteral(25); Literal _45 = vf.createLiteral(45); cxn.add(A, RDF.TYPE, X); cxn.add(B, RDF.TYPE, X); cxn.add(A, AGE, _25); cxn.add(B, AGE, _45); /* * Note: The either flush() or commit() is required to flush the * statement buffers to the database before executing any operations * that go around the sail. */ cxn.flush();//commit(); if (log.isInfoEnabled()) { log.info(cxn.getTripleStore().dumpStore()); } { String query = "select ?s ?age " + "WHERE { " + " ?s <"+RDF.TYPE+"> <"+X+"> . " + " ?s <"+AGE+"> ?age . " + " FILTER( ?age > 35 ) . " + "}"; final TupleQuery tupleQuery = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); TupleQueryResult result = tupleQuery.evaluate(); Collection<BindingSet> solution = new LinkedList<BindingSet>(); solution.add(createBindingSet(new Binding[] { new BindingImpl("s", B), new BindingImpl("age", _45) })); compare(result, solution); } } finally { cxn.close(); sail.__tearDownUnitTest(); } }
Example 10
Source File: TestUnions.java From database with GNU General Public License v2.0 | 4 votes |
/** * Tests mapping of UNIONS in SPARQL onto unions in bigdata rules. * * @throws Exception */ public void testSesameFilters() throws Exception { final BigdataSail sail = getSail(); sail.initialize(); final BigdataSailRepository repo = new BigdataSailRepository(sail); final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo.getConnection(); cxn.setAutoCommit(false); try { final URI jack = new URIImpl("_:Jack"); final URI jill = new URIImpl("_:Jill"); final URI person = new URIImpl("_:Person"); final URI age = new URIImpl("_:age"); final URI integer = new URIImpl("http://www.w3.org/2001/XMLSchema#integer"); /**/ cxn.add( jack, RDF.TYPE, person ); cxn.add( jill, RDF.TYPE, person ); cxn.add( jack, age, new LiteralImpl("40", integer) ); cxn.add( jill, age, new LiteralImpl("30", integer) ); /**/ /* * Note: The either flush() or commit() is required to flush the * statement buffers to the database before executing any operations * that go around the sail. */ cxn.flush();//commit(); /**/ log.info("hello"); if (log.isInfoEnabled()) { log.info(cxn.getTripleStore().dumpStore()); } { String query = "SELECT * " + "WHERE { " + " { " + " ?x <"+RDF.TYPE+"> <"+person+"> . " + " ?x <"+age+"> ?age1 . " + " FILTER( ?age1 > 35 ) . " + " } " + " UNION " + " { " + " ?x <"+RDF.TYPE+"> <"+person+"> . " + " ?x <"+age+"> ?age2 . " + " FILTER( ?age2 > 25 ) . " + " } " + "}"; final StringWriter sw = new StringWriter(); final TupleQuery tupleQuery = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); tupleQuery.setIncludeInferred(true /* includeInferred */); tupleQuery.evaluate(new SPARQLResultsXMLWriter(new XMLWriter(sw))); if(log.isInfoEnabled())log.info(sw.toString()); } } finally { cxn.close(); sail.__tearDownUnitTest(); } }
Example 11
Source File: TestStatementBuffer.java From database with GNU General Public License v2.0 | 2 votes |
/** * Test verifies interpretation of triples by the {@link StatementBuffer} by * validating how the triples written onto the statement buffer are loaded * into the {@link AbstractTripleStore}. */ public void test_statementBuffer() { final int capacity = 5; final Properties properties = new Properties(getProperties()); // turn off entailments. properties.setProperty(AbstractTripleStore.Options.AXIOMS_CLASS, NoAxioms.class.getName()); final AbstractTripleStore store = getStore(properties); try { // store is empty. assertEquals(0,store.getStatementCount()); final BigdataValueFactory vf = store.getValueFactory(); final StatementBuffer<Statement> buffer = new StatementBuffer<Statement>( store, capacity); /* * add a statement. */ final URI s1 = new URIImpl("http://www.foo.org"); final URI p1 = RDF.TYPE; final URI o1 = RDFS.RESOURCE; final URI c1 = null; // no context. buffer.add(vf.createStatement(s1, p1, o1, c1, StatementEnum.Explicit)); /* * add another statement. */ final URI s2 = new URIImpl("http://www.foo.org"); // duplicate term! final URI p2 = RDFS.LABEL; final Literal o2 = new LiteralImpl("test lit."); final URI c2 = null; buffer.add(vf.createStatement(s2, p2, o2, c2, StatementEnum.Explicit)); /* * add a duplicate statement. */ final URI s3 = new URIImpl("http://www.foo.org"); // duplicate term final URI p3 = RDFS.LABEL; // duplicate term final Literal o3 = new LiteralImpl("test lit."); // duplicate term final URI c3 = null; buffer.handleStatement(s3, p3, o3, c3, StatementEnum.Explicit); // store is still empty (statements are buffered). assertEquals(0,store.getStatementCount()); // flush the buffer. buffer.flush(); // the statements are now in the store. assertEquals(2, store.getStatementCount()); assertTrue(store.hasStatement(s1, p1, o1)); assertTrue(store.hasStatement(s2, p2, o2)); assertFalse(store.hasStatement(s1, p2, o1)); } finally { store.__tearDownUnitTest(); } }