com.bigdata.rdf.model.StatementEnum Java Examples
The following examples show how to use
com.bigdata.rdf.model.StatementEnum.
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: BlazeGraphEmbedded.java From tinkerpop3 with GNU General Public License v2.0 | 6 votes |
/** * Changed events coming from bigdata. */ @Override public void changeEvent(final IChangeRecord record) { if (listeners.isEmpty()) return; /* * Watch out for history change events. */ if (record.getStatement().getStatementType() == StatementEnum.History) { return; } /* * Adds come in already materialized. Removes do not. We batch and * materialize removes in bulk. */ records.add(record); }
Example #2
Source File: AbstractDataAndSPARQLTestCase.java From database with GNU General Public License v2.0 | 6 votes |
@Override public void handleStatement(final Statement stmt) throws RDFHandlerException { final Resource s = stmt.getSubject(); final URI p = stmt.getPredicate(); final Value o = stmt.getObject(); final Resource c = stmt.getContext() == null ? this.context : stmt.getContext(); // if (log.isDebugEnabled()) // log.debug("<" + s + "," + p + "," + o + "," + c + ">"); buffer.add(s, p, o, c, StatementEnum.Explicit); n++; }
Example #3
Source File: TestSPOValueCoders.java From database with GNU General Public License v2.0 | 6 votes |
/** * Simple tests for {@link FastRDFValueCoder2}. * <P> * Note: this does not cover nulls or overrides, but the stress tests covers * both. */ public void test_FastRDFValueCoder2_001() { final IV<?,?> _0 = getTermId(0); doRoundTripTest(new SPO[] { new SPO(_0, _0, _0, StatementEnum.Axiom) }, new FastRDFValueCoder2(), false); doRoundTripTest(new SPO[] { new SPO(_0, _0, _0, StatementEnum.Explicit) }, new FastRDFValueCoder2(), false); doRoundTripTest(new SPO[] { new SPO(_0, _0, _0, StatementEnum.Inferred) }, new FastRDFValueCoder2(), false); doRoundTripTest(new SPO[] { new SPO(_0, _0, _0, StatementEnum.Axiom), new SPO(_0, _0, _0, StatementEnum.Inferred) }, new FastRDFValueCoder2(), false); doRoundTripTest(new SPO[] { new SPO(_0, _0, _0, StatementEnum.Explicit), new SPO(_0, _0, _0, StatementEnum.Axiom) }, new FastRDFValueCoder2(), false); }
Example #4
Source File: SPO.java From database with GNU General Public License v2.0 | 6 votes |
/** * Statement type is hiding in the 0 and 1 bits of the flags. */ private StatementEnum type() { // get just the 0 and 1 and 2 bits // final byte b = Bits.mask(flags, 0, 1, 2); byte b = 0; b |= (0x1 << TYPE_BIT); b |= (0x1 << (TYPE_BIT+1)); b |= (0x1 << (TYPE_BIT+2)); b &= flags; switch (b) { case 0: return null; case 1: return StatementEnum.Explicit; case 2: return StatementEnum.Axiom; case 3: return StatementEnum.Inferred; case 4: return StatementEnum.History; } throw new IllegalStateException(); }
Example #5
Source File: AsynchronousStatementBufferFactory.java From database with GNU General Public License v2.0 | 6 votes |
/** * Form the BigdataStatement object using the valueFactory now that we * bindings which were (a) allocated by the valueFactory and (b) are * canonical for the scope of this document. */ @SuppressWarnings("unchecked") private void _handleStatement(final Resource s, final URI p, final Value o, final Resource c, final StatementEnum type) { final BigdataStatement stmt = valueFactory.createStatement( (BigdataResource) s, (BigdataURI) p, (BigdataValue) o, (BigdataResource) c, type); if (statements == null) { statements = new UnsynchronizedUnboundedChunkBuffer<S>( producerChunkSize, (Class<? extends S>) BigdataStatement.class); } statements.add((S) stmt); // total #of statements accepted. statementCount++; if (log.isTraceEnabled()) log.trace("n=" + statementCount + ", added: " + stmt); }
Example #6
Source File: AbstractStatementBuffer.java From database with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") public void add(Resource s, URI p, Value o, Resource c, StatementEnum type) { final G stmt = (G) getValueFactory().createStatement(// (BigdataResource) convertValue(s), // (BigdataURI) convertValue(p), // convertValue(o), // (BigdataResource) convertValue(c), // type); add((F)stmt); }
Example #7
Source File: StatementBuffer.java From database with GNU General Public License v2.0 | 5 votes |
/** * Add a statement to the buffer (core impl, flushes on overflow). * * @param s * @param p * @param o * @param type */ @Override public void add(final Resource s, final URI p, final Value o, final Resource c, final StatementEnum type) { if (nearCapacity()) { // bulk insert the buffered data into the store. if (true) { // THIS IS THE CORRECT ACTION! incrementalWrite(); } else { /* * This will flush all blank nodes. It may be necessary on very * large files. It also resets the blank node and deferred * statement maps afterwards (since they are set to null by * reset()). */ flush(); bnodes = new HashMap<String, BigdataBNode>(bufferCapacity); deferredStmts = new HashSet<BigdataStatement>(stmts.length); } } // add to the buffer. handleStatement(s, p, o, c, type); }
Example #8
Source File: AsynchronousStatementBufferFactory.java From database with GNU General Public License v2.0 | 5 votes |
/** * Add a statement to the buffer (core impl). */ public void add(final Resource s, final URI p, final Value o, final Resource c, final StatementEnum type) { // add to the buffer. handleStatement(s, p, o, c, type); }
Example #9
Source File: TestUpdateExprBuilder.java From database with GNU General Public License v2.0 | 5 votes |
/** * <pre> * PREFIX dc: <http://purl.org/dc/elements/1.1/> * PREFIX ns: <http://example.org/ns#> * INSERT DATA * { GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } } * </pre> */ // @SuppressWarnings("rawtypes") public void test_insert_data_quads() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n" + "PREFIX ns: <http://example.org/ns#>\n" + "INSERT DATA\n" + "{ GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } }"; final UpdateRoot expected = new UpdateRoot(); { final InsertData op = new InsertData(); expected.addChild(op); final BigdataURI bookstore = valueFactory.createURI("http://example/bookStore"); final BigdataURI book1 = valueFactory.createURI("http://example/book1"); final BigdataURI price = valueFactory.createURI("http://example.org/ns#price"); final BigdataLiteral i42 = valueFactory.createLiteral("42",XSD.INTEGER); final BigdataStatement[] data = new BigdataStatement[] { // valueFactory.createStatement(// (BigdataResource)book1,// (BigdataURI)price, // (BigdataValue)i42, // (BigdataResource)bookstore, // StatementEnum.Explicit),// }; op.setData(data); } final UpdateRoot actual = parseUpdate(sparql, baseURI); assertSameAST(sparql, expected, actual); }
Example #10
Source File: TestUpdateExprBuilder.java From database with GNU General Public License v2.0 | 5 votes |
/** * <pre> * INSERT DATA { _:bnode a <http://example/Foo> . } * </pre> * @throws MalformedQueryException * * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/573"> * NullPointerException when attempting to INSERT DATA containing a * blank node </a> */ public void test_insert_data_ticket573() throws MalformedQueryException { final String sparql = "INSERT DATA { _:bnode a <http://example/Foo> . }"; final UpdateRoot expected = new UpdateRoot(); { final InsertData op = new InsertData(); expected.addChild(op); final BigdataBNode bnode = valueFactory.createBNode("-anon-1"); // final BigdataBNode bnode = valueFactory.createBNode("bnode"); final BigdataURI rdfType = valueFactory.createURI(RDF.TYPE.toString()); final BigdataURI foo = valueFactory.createURI("http://example/Foo"); final BigdataStatement[] data = new BigdataStatement[] { // valueFactory.createStatement(// bnode,// rdfType,// foo, // null,// c StatementEnum.Explicit),// }; op.setData(data); } final UpdateRoot actual = parseUpdate(sparql, baseURI); // no null pointer exception, but Sesame 2.7 Sparql parser will // not respect the bnode id, so we cannot assert same AST // assertSameAST(sparql, expected, actual); }
Example #11
Source File: BackchainTypeResourceIterator.java From database with GNU General Public License v2.0 | 5 votes |
public BackchainSTypeResourceIterator( final IChunkedOrderedIterator<ISPO> _src, final IAccessPath<ISPO> accessPath, final AbstractTripleStore db, final IV rdfType, final IV rdfsResource) { this._src = _src; this.accessPath = accessPath; this.db = db; this.rdfType = rdfType; this.rdfsResource = rdfsResource; this.s = (IV) accessPath.getPredicate().get(0).get(); SPO spo = new SPO(s, rdfType, rdfsResource, StatementEnum.Inferred); this.appender = new ChunkedArrayIterator<ISPO>(1, new SPO[] { spo }, SPOKeyOrder.SPO); }
Example #12
Source File: SPOTupleSerializer.java From database with GNU General Public License v2.0 | 5 votes |
/** * Set the statement type, bit flags, and optional sid based on the tuple * value. */ public ISPO decodeValue(final ISPO spo, final byte[] val) { final byte code = val[0]; final StatementEnum type = StatementEnum.decode(code); spo.setStatementType(type); spo.setOverride(StatementEnum.isOverride(code)); spo.setUserFlag(StatementEnum.isUserFlag(code)); // if (sids) { // // // SIDs only valid for triples. // assert keyOrder.getKeyArity() == 3; // // if (spo.isExplicit()) { // // spo.setStatementIdentifier(true); // // } // // } return spo; }
Example #13
Source File: SPOTupleSerializer.java From database with GNU General Public License v2.0 | 5 votes |
/** * Return the byte[] that would be written into a statement index for this * {@link SPO}, including the optional {@link StatementEnum#MASK_OVERRIDE} * bit. If the statement identifier is non-null then it will be included in * the returned byte[]. * * @param override * <code>true</code> iff you want the * {@link StatementEnum#MASK_OVERRIDE} bit set (this is only set * when serializing values for a remote procedure that will write * on the index, it is never set in the index itself). * @param userFlag * <code>true</code> iff you want the * {@link StatementEnum#MASK_USER_FLAG} bit set. * @param type * The {@link StatementEnum}. * * @return The value that would be written into a statement index for this * {@link SPO}. */ // * @param buf // * A buffer supplied by the caller. The buffer will be reset // * before the value is written on the buffer. public byte[] serializeVal(//final ByteArrayBuffer buf, final boolean override, final boolean userFlag, final StatementEnum type) { // buf.reset(); // optionally set the override and user flag bits on the value. final byte b = (byte) (type.code() | (override ? StatementEnum.MASK_OVERRIDE : 0x0) | (userFlag ? StatementEnum.MASK_USER_FLAG : 0x0) ); // buf.putByte(b); // // final byte[] a = buf.toByteArray(); // // assert a.length == 1 : "Expecting one byte, but have " // + BytesUtil.toString(a); return RDFValueFactory.getValue(b); }
Example #14
Source File: SPO.java From database with GNU General Public License v2.0 | 5 votes |
/** * Construct a triple. * <p> * Note: When the statement is {@link StatementEnum#Inferred} you MUST also * construct the appropriate {@link Justification}. * * @param s * @param p * @param o * @param type * The statement type. */ public SPO(final IV s, final IV p, final IV o, StatementEnum type) { if (type == null) throw new IllegalArgumentException(); this.s = s; this.p = p; this.o = o; this.c = null; type(type); }
Example #15
Source File: SPO.java From database with GNU General Public License v2.0 | 5 votes |
/** * Quads constructor with {@link StatementEnum}. * @param s * @param p * @param o * @param c * @param type */ public SPO(final IV s, final IV p, final IV o, final IV c, final StatementEnum type) { if (type == null) throw new IllegalArgumentException(); this.s = s; this.p = p; this.o = o; this.c = c; type(type); }
Example #16
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 #17
Source File: TestBulkFilter.java From database with GNU General Public License v2.0 | 4 votes |
/** * Simple test of bulk SPO completion (value lookup). */ public void testCompletion() { AbstractTripleStore store = getStore(); try { final URI A = new URIImpl("http://www.bigdata.com/A"); // final URI B = new URIImpl("http://www.bigdata.com/B"); // final URI C = new URIImpl("http://www.bigdata.com/C"); // final URI D = new URIImpl("http://www.bigdata.com/D"); // final URI E = new URIImpl("http://www.bigdata.com/E"); final URI V = new URIImpl("http://www.bigdata.com/V"); final URI W = new URIImpl("http://www.bigdata.com/W"); final URI X = new URIImpl("http://www.bigdata.com/X"); final URI Y = new URIImpl("http://www.bigdata.com/Y"); final URI Z = new URIImpl("http://www.bigdata.com/Z"); final IV a = store.addTerm(A); // final IV b = store.addTerm(B); // final IV c = store.addTerm(C); // final IV d = store.addTerm(D); // final IV e = store.addTerm(E); final IV v = store.addTerm(V); final IV w = store.addTerm(W); final IV x = store.addTerm(X); final IV y = store.addTerm(Y); final IV z = store.addTerm(Z); SPO[] stmts = new SPO[] { new SPO(x,a,y,StatementEnum.Explicit), new SPO(x,a,z,StatementEnum.Inferred) }; int numStmts = stmts.length; store.addStatements(stmts, numStmts); // store.commit(); if (log.isInfoEnabled()) log.info("\n" + store.dumpStore(true, true, false)); stmts = new SPO[] { new SPO(x,a,y), new SPO(x,a,z), new SPO(x,a,v), new SPO(x,a,w) }; numStmts = stmts.length; { // filter out and complete final IChunkedOrderedIterator<ISPO> itr = store .bulkCompleteStatements(stmts, numStmts); assertSameSPOsAnyOrder(store, new SPO[]{ new SPO(x,a,y, StatementEnum.Explicit), new SPO(x,a,z, StatementEnum.Inferred), new SPO(x,a,v, StatementEnum.Inferred), new SPO(x,a,w, StatementEnum.Inferred) }, itr, true // ignore axioms ); /* while(itr.hasNext()) { SPO spo = itr.next(); System.err.println(spo.toString(store)); } */ } } finally { store.__tearDownUnitTest(); } }
Example #18
Source File: TestStatementBuffer.java From database with GNU General Public License v2.0 | 4 votes |
/** * A unit test in which the translation of reified statements into inline * statements disabled. This test uses the same data as the test below. */ public void test_reificationDoneRight_disabled() { if (QueryHints.DEFAULT_REIFICATION_DONE_RIGHT) return; final int capacity = 20; final Properties properties = new Properties(getProperties()); // turn off entailments. properties.setProperty(AbstractTripleStore.Options.AXIOMS_CLASS, NoAxioms.class.getName()); final AbstractTripleStore store = getStore(properties); try { // * @prefix : <http://example.com/> . // * @prefix news: <http://example.com/news/> . // * @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . // * @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . // * @prefix dc: <http://purl.org/dc/terms/> . // * @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . // * // * :SAP :bought :sybase . // * _:s1 rdf:subject :SAP . // * _:s1 rdf:predicate :bought . // * _:s1 rdf:object :sybase . // * _:s1 rdf:type rdf:Statement . // * _:s1 dc:source news:us-sybase . // * _:s1 dc:created "2011-04-05T12:00:00Z"^^xsd:dateTime . final BigdataValueFactory vf = store.getValueFactory(); final BigdataURI SAP = vf.createURI("http://example.com/SAP"); final BigdataURI bought = vf.createURI("http://example.com/bought"); final BigdataURI sybase = vf.createURI("http://example.com/sybase"); final BigdataURI dcSource = vf.createURI("http://purl.org/dc/terms/source"); final BigdataURI dcCreated = vf.createURI("http://purl.org/dc/terms/created"); final BigdataURI newsSybase = vf.createURI("http://example.com/news/us-sybase"); final BigdataLiteral createdDate = vf.createLiteral("2011-04-05T12:00:00Z",XSD.DATETIME); final BigdataBNode s1 = vf.createBNode("s1"); // store is empty. assertEquals(0, store.getStatementCount()); final StatementBuffer<Statement> buffer = new StatementBuffer<Statement>( store, capacity); // ground statement. buffer.add(vf.createStatement(SAP, bought, sybase, null/* context */, StatementEnum.Explicit)); // model of that statement (RDF reification). buffer.add(vf.createStatement(s1, RDF.SUBJECT, SAP, null/* context */, StatementEnum.Explicit)); buffer.add(vf.createStatement(s1, RDF.PREDICATE, bought, null/* context */, StatementEnum.Explicit)); buffer.add(vf.createStatement(s1, RDF.OBJECT, sybase, null/* context */, StatementEnum.Explicit)); buffer.add(vf.createStatement(s1, RDF.TYPE, RDF.STATEMENT, null/* context */, StatementEnum.Explicit)); // metadata statements. buffer.add(vf.createStatement(s1, dcSource, newsSybase, null/* context */, StatementEnum.Explicit)); buffer.add(vf.createStatement(s1, dcCreated, createdDate, null/* context */, StatementEnum.Explicit)); // flush the buffer. buffer.flush(); // the statements are now in the store. assertEquals(7, store.getStatementCount()); assertTrue(store.hasStatement(SAP, bought, sybase)); assertTrue(store.hasStatement(s1, RDF.SUBJECT, SAP)); assertTrue(store.hasStatement(s1, RDF.PREDICATE, bought)); assertTrue(store.hasStatement(s1, RDF.OBJECT, sybase)); assertTrue(store.hasStatement(s1, RDF.TYPE, RDF.STATEMENT)); assertTrue(store.hasStatement(s1, dcSource, newsSybase)); assertTrue(store.hasStatement(s1, dcCreated, createdDate)); } finally { store.__tearDownUnitTest(); } }
Example #19
Source File: BaseAxioms.java From database with GNU General Public License v2.0 | 4 votes |
final public boolean isAxiom(final IV s, final IV p, final IV o) { if (axioms == null) throw new IllegalStateException(); // fast rejection. if (s == null || p == null || o == null) { return false; } final SPO spo = new SPO(s, p, o, StatementEnum.Axiom); if(axioms.contains(spo)) { return true; } return false; }
Example #20
Source File: TestUpdateExprBuilder.java From database with GNU General Public License v2.0 | 4 votes |
/** * <pre> * PREFIX dc: <http://purl.org/dc/elements/1.1/> * PREFIX ns: <http://example.org/ns#> * INSERT DATA * { * <http://example/book1> dc:title "A new book" . * <http://example/book1> dc:creator "A.N.Other" . * GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } * } * </pre> */ // @SuppressWarnings("rawtypes") public void test_insert_data_triples_then_quads() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n" + "PREFIX ns: <http://example.org/ns#>\n" + "INSERT DATA\n" + "{\n" + " <http://example/book1> dc:title \"A new book\" .\n" + " <http://example/book1> dc:creator \"A.N.Other\" .\n" // + " GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 }\n" + "}"; final UpdateRoot expected = new UpdateRoot(); { final InsertData op = new InsertData(); expected.addChild(op); final BigdataURI book1 = valueFactory.createURI("http://example/book1"); final BigdataURI dcCreator = valueFactory.createURI("http://purl.org/dc/elements/1.1/creator"); final BigdataURI dcTitle = valueFactory.createURI("http://purl.org/dc/elements/1.1/title"); final BigdataLiteral label1 = valueFactory.createLiteral("A new book"); final BigdataLiteral label2 = valueFactory.createLiteral("A.N.Other"); final BigdataURI bookstore = valueFactory.createURI("http://example/bookStore"); final BigdataURI price = valueFactory.createURI("http://example.org/ns#price"); final BigdataLiteral i42 = valueFactory.createLiteral("42",XSD.INTEGER); final BigdataStatement[] data = new BigdataStatement[] { // valueFactory.createStatement(// (BigdataResource)book1,// (BigdataURI)dcTitle,// (BigdataValue)label1,// null,// StatementEnum.Explicit),// valueFactory.createStatement(// (BigdataResource)book1,// (BigdataURI)dcCreator, // (BigdataValue)label2,// null,// StatementEnum.Explicit),// valueFactory.createStatement(// (BigdataResource)book1, // (BigdataURI)price, // (BigdataValue)i42, // (BigdataResource)bookstore,// StatementEnum.Explicit),// }; op.setData(data); } final UpdateRoot actual = parseUpdate(sparql, baseURI); assertSameAST(sparql, expected, actual); }
Example #21
Source File: TestUpdateExprBuilder.java From database with GNU General Public License v2.0 | 4 votes |
/** * <pre> * PREFIX dc: <http://purl.org/dc/elements/1.1/> * PREFIX ns: <http://example.org/ns#> * INSERT DATA * { * GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } * <http://example/book1> dc:title "A new book" . * <http://example/book1> dc:creator "A.N.Other" . * } * </pre> */ // @SuppressWarnings("rawtypes") public void test_insert_data_quads_then_triples() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n" + "PREFIX ns: <http://example.org/ns#>\n" + "INSERT DATA\n" + "{\n" + " GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 }\n" + " <http://example/book1> dc:title \"A new book\" .\n" + " <http://example/book1> dc:creator \"A.N.Other\" .\n" // + "}"; final UpdateRoot expected = new UpdateRoot(); { final InsertData op = new InsertData(); expected.addChild(op); final BigdataURI book1 = valueFactory.createURI("http://example/book1"); final BigdataURI dcCreator = valueFactory.createURI("http://purl.org/dc/elements/1.1/creator"); final BigdataURI dcTitle = valueFactory.createURI("http://purl.org/dc/elements/1.1/title"); final BigdataLiteral label1 = valueFactory.createLiteral("A new book"); final BigdataLiteral label2 = valueFactory.createLiteral("A.N.Other"); final BigdataURI bookstore = valueFactory.createURI("http://example/bookStore"); final BigdataURI price = valueFactory.createURI("http://example.org/ns#price"); final BigdataLiteral i42 = valueFactory.createLiteral("42",XSD.INTEGER); final BigdataStatement[] data = new BigdataStatement[] { // valueFactory.createStatement(// (BigdataResource)book1, // (BigdataURI)price, // (BigdataValue)i42, // (BigdataResource)bookstore,// StatementEnum.Explicit),// valueFactory.createStatement(// (BigdataResource)book1,// (BigdataURI)dcTitle,// (BigdataValue)label1,// null,// StatementEnum.Explicit),// valueFactory.createStatement(// (BigdataResource)book1, // (BigdataURI)dcCreator,// (BigdataValue)label2, // null,// StatementEnum.Explicit),// }; op.setData(data); } final UpdateRoot actual = parseUpdate(sparql, baseURI); assertSameAST(sparql, expected, actual); }
Example #22
Source File: TestUpdateExprBuilder.java From database with GNU General Public License v2.0 | 4 votes |
/** * <pre> * PREFIX dc: <http://purl.org/dc/elements/1.1/> * PREFIX ns: <http://example.org/ns#> * INSERT DATA * { * <http://example/book1> dc:title "A new book" . * GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } * <http://example/book1> dc:creator "A.N.Other" . * } * </pre> */ // @SuppressWarnings("rawtypes") public void test_insert_data_triples_quads_triples() throws MalformedQueryException, TokenMgrError, ParseException { final String sparql = "PREFIX dc: <http://purl.org/dc/elements/1.1/>\n" + "PREFIX ns: <http://example.org/ns#>\n" + "INSERT DATA\n" + "{\n" + " <http://example/book1> dc:title \"A new book\" . " + " GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 }\n" + " <http://example/book1> dc:creator \"A.N.Other\" .\n" // + "}"; final UpdateRoot expected = new UpdateRoot(); { final InsertData op = new InsertData(); expected.addChild(op); final BigdataURI book1 = valueFactory.createURI("http://example/book1"); final BigdataURI dcCreator = valueFactory.createURI("http://purl.org/dc/elements/1.1/creator"); final BigdataURI dcTitle = valueFactory.createURI("http://purl.org/dc/elements/1.1/title"); final BigdataLiteral label1 = valueFactory.createLiteral("A new book"); final BigdataLiteral label2 = valueFactory.createLiteral("A.N.Other"); final BigdataURI bookstore = valueFactory.createURI("http://example/bookStore"); final BigdataURI price = valueFactory.createURI("http://example.org/ns#price"); final BigdataLiteral i42 = valueFactory.createLiteral("42",XSD.INTEGER); final BigdataStatement[] data = new BigdataStatement[] { // valueFactory.createStatement(// (BigdataResource)book1,// (BigdataURI)dcTitle,// (BigdataValue)label1, // null, // StatementEnum.Explicit),// valueFactory.createStatement(// (BigdataResource)book1,// (BigdataURI)price,// (BigdataValue)i42,// (BigdataResource)bookstore,// StatementEnum.Explicit),// valueFactory.createStatement(// (BigdataResource)book1,// (BigdataURI)dcCreator,// (BigdataValue)label2,// null,// StatementEnum.Explicit),// }; op.setData(data); } final UpdateRoot actual = parseUpdate(sparql, baseURI); assertSameAST(sparql, expected, actual); }
Example #23
Source File: TestEncodeDecodeKeys.java From database with GNU General Public License v2.0 | 4 votes |
/** * Unit test for {@link SidIV}. */ public void test_encodeDecode_sids() { final IV<?,?> s1 = newTermId(VTE.URI); final IV<?,?> s2 = newTermId(VTE.URI); final IV<?,?> p1 = newTermId(VTE.URI); final IV<?,?> p2 = newTermId(VTE.URI); final IV<?,?> o1 = newTermId(VTE.URI); final IV<?,?> o2 = newTermId(VTE.BNODE); final IV<?,?> o3 = newTermId(VTE.LITERAL); final SPO spo1 = new SPO(s1, p1, o1, StatementEnum.Explicit); final SPO spo2 = new SPO(s1, p1, o2, StatementEnum.Explicit); final SPO spo3 = new SPO(s1, p1, o3, StatementEnum.Explicit); final SPO spo4 = new SPO(s1, p2, o1, StatementEnum.Explicit); final SPO spo5 = new SPO(s1, p2, o2, StatementEnum.Explicit); final SPO spo6 = new SPO(s1, p2, o3, StatementEnum.Explicit); final SPO spo7 = new SPO(s2, p1, o1, StatementEnum.Explicit); final SPO spo8 = new SPO(s2, p1, o2, StatementEnum.Explicit); final SPO spo9 = new SPO(s2, p1, o3, StatementEnum.Explicit); final SPO spo10 = new SPO(s2, p2, o1, StatementEnum.Explicit); final SPO spo11 = new SPO(s2, p2, o2, StatementEnum.Explicit); final SPO spo12 = new SPO(s2, p2, o3, StatementEnum.Explicit); // spo1.setStatementIdentifier(true); // spo2.setStatementIdentifier(true); // spo3.setStatementIdentifier(true); // spo6.setStatementIdentifier(true); final SPO spo13 = new SPO(spo1.getStatementIdentifier(), p1, o1, StatementEnum.Explicit); final SPO spo14 = new SPO(spo2.getStatementIdentifier(), p2, o2, StatementEnum.Explicit); final SPO spo15 = new SPO(s1, p1, spo3.getStatementIdentifier(), StatementEnum.Explicit); // spo15.setStatementIdentifier(true); final SPO spo16 = new SPO(s1, p1, spo6.getStatementIdentifier(), StatementEnum.Explicit); final SPO spo17 = new SPO(spo1.getStatementIdentifier(), p1, spo15 .getStatementIdentifier(), StatementEnum.Explicit); final IV<?, ?>[] e = {// new SidIV<BigdataBNode>(spo1),// new SidIV<BigdataBNode>(spo2),// new SidIV<BigdataBNode>(spo3),// new SidIV<BigdataBNode>(spo4),// new SidIV<BigdataBNode>(spo5),// new SidIV<BigdataBNode>(spo6),// new SidIV<BigdataBNode>(spo7),// new SidIV<BigdataBNode>(spo8),// new SidIV<BigdataBNode>(spo9),// new SidIV<BigdataBNode>(spo10),// new SidIV<BigdataBNode>(spo11),// new SidIV<BigdataBNode>(spo12),// new SidIV<BigdataBNode>(spo13),// new SidIV<BigdataBNode>(spo14),// new SidIV<BigdataBNode>(spo15),// new SidIV<BigdataBNode>(spo16),// new SidIV<BigdataBNode>(spo17),// }; doEncodeDecodeTest(e); doComparatorTest(e); }
Example #24
Source File: TestRuleFastClosure_11_13.java From database with GNU General Public License v2.0 | 4 votes |
/** * Tests {@link RuleFastClosure13} with the minimum data required to compute * a single entailment. * @throws Exception */ public void test_RuleFastForwardClosure13() throws Exception { AbstractTripleStore store = getStore(); try { final BigdataValueFactory f = store.getValueFactory(); final IV a = store.addTerm(f.createURI("http://www.bigdata.com/a")); final IV b = store.addTerm(f.createURI("http://www.bigdata.com/b")); final IV y = store.addTerm(f.createURI("http://www.bigdata.com/y")); final IV x = store.addTerm(f.createURI("http://www.bigdata.com/x")); final IV z = store.addTerm(f.createURI("http://www.bigdata.com/z")); final Vocabulary vocab = store.getVocabulary(); // told: { SPO[] told = new SPO[] { // new SPO(x, y, z, StatementEnum.Explicit), // new SPO(y, vocab.get(RDFS.SUBPROPERTYOF), a, StatementEnum.Explicit), // new SPO(a, vocab.get(RDFS.RANGE), b, StatementEnum.Explicit) }; store.addStatements(told, told.length); } // entails: // store.addStatement(z, inf.rdfType.get(), b); // store.commit(); if (log.isInfoEnabled()) log.info("\n" + store.dumpStore()); /* * (?x, ?y, ?z), (?y, rdfs:subPropertyOf, ?a), (?a, rdfs:domain, ?b) -> * (?z, rdf:type, ?b). */ RuleFastClosure13 rule = new RuleFastClosure13(store .getSPORelation().getNamespace(), vocab); /* * Test run the rule. */ applyRule(store, rule, 1/*solutionCount*/, 1/*mutationCount*/); // check entailments. assertTrue(store.hasStatement(z, vocab.get(RDF.TYPE), b)); // store.commit(); } finally { store.__tearDownUnitTest(); } }
Example #25
Source File: TestRuleFastClosure_11_13.java From database with GNU General Public License v2.0 | 4 votes |
/** * Tests {@link RuleFastClosure11} with the minimum data required to compute * a single entailment. */ public void test_RuleFastForwardClosure11() throws Exception { AbstractTripleStore store = getStore(); try { final BigdataValueFactory f = store.getValueFactory(); final IV a = store.addTerm(f.createURI("http://www.bigdata.com/a")); final IV b = store.addTerm(f.createURI("http://www.bigdata.com/b")); final IV y = store.addTerm(f.createURI("http://www.bigdata.com/y")); final IV x = store.addTerm(f.createURI("http://www.bigdata.com/x")); final IV z = store.addTerm(f.createURI("http://www.bigdata.com/z")); final Vocabulary vocab = store.getVocabulary(); // told: { SPO[] told = new SPO[] { // new SPO(x, y, z, StatementEnum.Explicit), // new SPO(y, vocab.get(RDFS.SUBPROPERTYOF), a, StatementEnum.Explicit), // new SPO(a, vocab.get(RDFS.DOMAIN), b, StatementEnum.Explicit) }; store.addStatements(told, told.length); } // entails: // store.addStatement(x, inf.rdfType.get(), b); // store.commit(); if (log.isInfoEnabled()) log.info("\n" + store.dumpStore()); /* * (?x, ?y, ?z), (?y, rdfs:subPropertyOf, ?a), (?a, rdfs:domain, ?b) -> * (?x, rdf:type, ?b). */ RuleFastClosure11 rule = new RuleFastClosure11(store .getSPORelation().getNamespace(), vocab); /* * Test run the rule. */ applyRule(store, rule, 1/*solutionCount*/, 1/*mutationCount*/); // check entailments. assertTrue(store.hasStatement(x, vocab.get(RDF.TYPE), b)); // store.commit(); } finally { store.__tearDownUnitTest(); } }
Example #26
Source File: SPORelation.java From database with GNU General Public License v2.0 | 4 votes |
/** * @todo This works for creating new SPOs licensed by inference against a * triple store. However, it does not allow us to specify the * statement type, which is always set to [inferred]. It also does not * capture the context if one exists, but that could be done by * inspection of the arity of the predicate. It might be better to * have an explicit "CONSTRUCT" operator rather than having this * implicit relationship between the head of a rule and the element * created from that rule. For example, that might let us capture the * distinction of inferred versus explicit within the CONSTRUCT * operator. */ @SuppressWarnings("unchecked") public SPO newElement(final List<BOp> a, final IBindingSet bindingSet) { if (a == null) throw new IllegalArgumentException(); if (bindingSet == null) throw new IllegalArgumentException(); final IV s = (IV) ((IVariableOrConstant<?>) a.get(0)).get(bindingSet); final IV p = (IV) ((IVariableOrConstant<?>) a.get(1)).get(bindingSet); final IV o = (IV) ((IVariableOrConstant<?>) a.get(2)).get(bindingSet); final SPO spo = new SPO(s, p, o, StatementEnum.Inferred); if(log.isDebugEnabled()) log.debug(spo.toString()); return spo; }
Example #27
Source File: TestReificationDoneRightEval.java From database with GNU General Public License v2.0 | 4 votes |
/** * Bootstrap test. The data are explicitly entered into the KB by hand. This * makes it possible to test evaluation without having to fix the RDF data * loader. The query is based on <code>rdf-02a</code>. */ public void test_reificationDoneRight_00a() throws Exception { final BigdataValueFactory vf = store.getValueFactory(); final BigdataURI SAP = vf.createURI("http://example.com/SAP"); final BigdataURI bought = vf.createURI("http://example.com/bought"); final BigdataURI sybase = vf.createURI("http://example.com/sybase"); final BigdataURI dcSource = vf.createURI(DCTermsVocabularyDecl.NAMESPACE+"source"); final BigdataURI dcCreated = vf.createURI(DCTermsVocabularyDecl.NAMESPACE+"created"); final BigdataURI newsSybase = vf.createURI("http://example.com/news/us-sybase"); final BigdataLiteral createdDate = vf.createLiteral("2011-04-05T12:00:00Z",XSD.DATETIME); final BigdataURI g1 = vf.createURI("http://example.com/g1"); // Add/resolve the terms against the lexicon. final BigdataValue[] terms = new BigdataValue[] { SAP, bought, sybase, dcSource, dcCreated, newsSybase, createdDate, g1 }; final BigdataURI context = store.isQuads() ? g1 : null; store.addTerms(terms); // ground statement. final BigdataStatement s0 = vf.createStatement(SAP, bought, sybase, context, StatementEnum.Explicit); // Setup blank node with SidIV for that Statement. final BigdataBNode s1 = vf.createBNode("s1"); s1.setStatementIdentifier(true); final ISPO spo = new SPO(SAP.getIV(), bought.getIV(), sybase.getIV(), null/* NO CONTEXT */, StatementEnum.Explicit); s1.setIV(new SidIV<BigdataBNode>(spo)); // metadata statements. final BigdataStatement mds1 = vf.createStatement(s1, dcSource, newsSybase, context, StatementEnum.Explicit); final BigdataStatement mds2 = vf.createStatement(s1, dcCreated, createdDate, context, StatementEnum.Explicit); final ISPO[] stmts = new ISPO[] { new SPO(s0), new SPO(mds1), new SPO(mds2) }; store.addStatements(stmts, stmts.length); /* * Now that we have populated the database, we can go ahead and compile * the query. (If we compile the query first then it will not find any * matching lexical items.) */ new TestHelper(TEST_RESOURCE_PREFIX + "rdr-00a", // testURI, TEST_RESOURCE_PREFIX + "rdr-02a.rq",// queryFileURL TEST_RESOURCE_PREFIX + "empty.ttl",// dataFileURL TEST_RESOURCE_PREFIX + "rdr-02a.srx"// resultFileURL ).runTest(); }
Example #28
Source File: TestReificationDoneRightEval.java From database with GNU General Public License v2.0 | 4 votes |
/** * Bootstrap test. The data are explicitly entered into the KB by hand. This * makes it possible to test evaluation without having to fix the RDF data * loader. The query is based on <code>rdf-02</code>. */ public void test_reificationDoneRight_00() throws Exception { final BigdataValueFactory vf = store.getValueFactory(); final BigdataURI SAP = vf.createURI("http://example.com/SAP"); final BigdataURI bought = vf.createURI("http://example.com/bought"); final BigdataURI sybase = vf.createURI("http://example.com/sybase"); final BigdataURI dcSource = vf.createURI(DCTermsVocabularyDecl.NAMESPACE+"source"); final BigdataURI dcCreated = vf.createURI(DCTermsVocabularyDecl.NAMESPACE+"created"); final BigdataURI newsSybase = vf.createURI("http://example.com/news/us-sybase"); final BigdataLiteral createdDate = vf.createLiteral("2011-04-05T12:00:00Z",XSD.DATETIME); final BigdataURI g1 = vf.createURI("http://example.com/g1"); // Add/resolve the terms against the lexicon. final BigdataValue[] terms = new BigdataValue[] { SAP, bought, sybase, dcSource, dcCreated, newsSybase, createdDate, g1 }; final BigdataURI context = store.isQuads() ? g1 : null; store.addTerms(terms); // ground statement. final BigdataStatement s0 = vf.createStatement(SAP, bought, sybase, context, StatementEnum.Explicit); // Setup blank node with SidIV for that Statement. final BigdataBNode s1 = vf.createBNode("s1"); s1.setStatementIdentifier(true); final ISPO spo = new SPO(s0);//SAP.getIV(), bought.getIV(), sybase.getIV(), // null/* NO CONTEXT */, StatementEnum.Explicit); s1.setIV(new SidIV<BigdataBNode>(spo)); // metadata statements. final BigdataStatement mds1 = vf.createStatement(s1, dcSource, newsSybase, context, StatementEnum.Explicit); final BigdataStatement mds2 = vf.createStatement(s1, dcCreated, createdDate, context, StatementEnum.Explicit); final ISPO[] stmts = new ISPO[] { new SPO(s0), new SPO(mds1), new SPO(mds2) }; store.addStatements(stmts, stmts.length); /* * Now that we have populated the database, we can go ahead and compile * the query. (If we compile the query first then it will not find any * matching lexical items.) */ final TestHelper h = new TestHelper(TEST_RESOURCE_PREFIX + "rdr-00", // testURI, TEST_RESOURCE_PREFIX + "rdr-02.rq",// queryFileURL TEST_RESOURCE_PREFIX + "empty.ttl",// dataFileURL TEST_RESOURCE_PREFIX + "rdr-02.srx"// resultFileURL ); h.runTest(); }
Example #29
Source File: OwlAxioms.java From database with GNU General Public License v2.0 | 4 votes |
protected void addAxioms(final Collection<BigdataStatement> axioms) { super.addAxioms(axioms); final BigdataValueFactory valueFactory = getValueFactory(); // axioms for owl:equivalentClass axioms.add( valueFactory.createStatement( OWL.EQUIVALENTCLASS, RDFS.SUBPROPERTYOF, RDFS.SUBCLASSOF, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.EQUIVALENTCLASS, RDFS.SUBPROPERTYOF, OWL.EQUIVALENTCLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.EQUIVALENTCLASS, RDF.TYPE, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.EQUIVALENTCLASS, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); // axioms for owl:equivalentProperty axioms.add( valueFactory.createStatement( OWL.EQUIVALENTPROPERTY, RDFS.SUBPROPERTYOF, RDFS.SUBPROPERTYOF, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.EQUIVALENTPROPERTY, RDFS.SUBPROPERTYOF, OWL.EQUIVALENTPROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.EQUIVALENTPROPERTY, RDF.TYPE, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.EQUIVALENTPROPERTY, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); // axioms for owl:sameAs axioms.add( valueFactory.createStatement( OWL.SAMEAS, RDF.TYPE, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.SAMEAS, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.SAMEAS, RDFS.SUBPROPERTYOF, OWL.SAMEAS, null, StatementEnum.Axiom)); // axioms for owl:inverseOf axioms.add( valueFactory.createStatement( OWL.INVERSEOF, RDF.TYPE, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.INVERSEOF, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.INVERSEOF, RDFS.SUBPROPERTYOF, OWL.INVERSEOF, null, StatementEnum.Axiom)); // axioms for owl:onProperty axioms.add( valueFactory.createStatement( OWL.ONPROPERTY, RDF.TYPE, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.ONPROPERTY, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.ONPROPERTY, RDFS.SUBPROPERTYOF, OWL.ONPROPERTY, null, StatementEnum.Axiom)); // axioms for owl:hasValue axioms.add( valueFactory.createStatement( OWL.HASVALUE, RDF.TYPE, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.HASVALUE, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.HASVALUE, RDFS.SUBPROPERTYOF, OWL.HASVALUE, null, StatementEnum.Axiom)); // axioms for owl:Restriction axioms.add( valueFactory.createStatement( OWL.RESTRICTION, RDFS.SUBCLASSOF, RDFS.CLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.RESTRICTION, RDFS.SUBCLASSOF, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.RESTRICTION, RDFS.SUBCLASSOF, OWL.RESTRICTION, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.RESTRICTION, RDF.TYPE, RDFS.CLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.RESTRICTION, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); // axioms for owl:Class, owl:ObjectProperty, owl:TransitiveProperty, and owl:DatatypeProperty axioms.add( valueFactory.createStatement( OWL.CLASS, RDFS.SUBCLASSOF, RDFS.CLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.CLASS, RDFS.SUBCLASSOF, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.CLASS, RDFS.SUBCLASSOF, OWL.CLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.CLASS, RDF.TYPE, RDFS.CLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.CLASS, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.OBJECTPROPERTY, RDFS.SUBCLASSOF, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.OBJECTPROPERTY, RDFS.SUBCLASSOF, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.OBJECTPROPERTY, RDFS.SUBCLASSOF, OWL.OBJECTPROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.OBJECTPROPERTY, RDF.TYPE, RDFS.CLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.OBJECTPROPERTY, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.TRANSITIVEPROPERTY, RDFS.SUBCLASSOF, OWL.OBJECTPROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.TRANSITIVEPROPERTY, RDFS.SUBCLASSOF, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.TRANSITIVEPROPERTY, RDFS.SUBCLASSOF, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.TRANSITIVEPROPERTY, RDFS.SUBCLASSOF, OWL.TRANSITIVEPROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.TRANSITIVEPROPERTY, RDF.TYPE, RDFS.CLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.TRANSITIVEPROPERTY, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.DATATYPEPROPERTY, RDFS.SUBCLASSOF, RDF.PROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.DATATYPEPROPERTY, RDFS.SUBCLASSOF, RDFS.RESOURCE, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.DATATYPEPROPERTY, RDFS.SUBCLASSOF, OWL.DATATYPEPROPERTY, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.DATATYPEPROPERTY, RDF.TYPE, RDFS.CLASS, null, StatementEnum.Axiom)); axioms.add( valueFactory.createStatement( OWL.DATATYPEPROPERTY, RDF.TYPE, RDFS.RESOURCE, null, StatementEnum.Axiom)); }
Example #30
Source File: TestSPOValueCoders.java From database with GNU General Public License v2.0 | 4 votes |
/** * Return an array of {@link SPO}s. * * @param n * The #of elements in the array. * @param SIDs * If statement identifiers should be generated. * @param inference * if {@link StatementEnum}s should be assigned. * * @return The array. */ protected SPO[] getData(final int n, final boolean SIDs, final boolean inference) { final SPO[] a = new SPO[n]; for (int i = 0; i < n; i++) { /* * Note: Only the {s,p,o} are assigned. The statement type and the * statement identifier are not part of the key for the statement * indices. */ final SPO spo; if (SIDs && !inference) { // only explicit statements can have SIDs. spo = new SPO(getTermId(), getTermId(), getTermId(), StatementEnum.Explicit); // spo.setStatementIdentifier(getSID()); // spo.setStatementIdentifier(true); } else if (inference) { final int tmp = r.nextInt(100); final StatementEnum type; if (tmp < 4) { type = StatementEnum.Axiom; } else if (tmp < 60) { type = StatementEnum.Explicit; } else { type = StatementEnum.Inferred; } spo = new SPO(getTermId(), getTermId(), getTermId(), type); if (SIDs && type == StatementEnum.Explicit && r.nextInt(100) < 20) { // explicit statement with SID. // spo.setStatementIdentifier(getSID()); // spo.setStatementIdentifier(true); } } else { // Explicit statement (no inference, no SIDs). spo = new SPO(getTermId(), getTermId(), getTermId(), StatementEnum.Explicit); } a[i] = spo; } return a; }