org.eclipse.rdf4j.model.Resource Java Examples
The following examples show how to use
org.eclipse.rdf4j.model.Resource.
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: SpinRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void render(ParsedGraphQuery query, RDFHandler handler) throws RDFHandlerException { handler.startRDF(); Resource querySubj = valueFactory.createBNode(); handler.handleStatement(valueFactory.createStatement(querySubj, RDF.TYPE, SP.CONSTRUCT_CLASS)); if (output.text) { handler.handleStatement(valueFactory.createStatement(querySubj, SP.TEXT_PROPERTY, valueFactory.createLiteral(query.getSourceString()))); } if (output.rdf) { TupleExpr expr = query.getTupleExpr(); SpinVisitor visitor = new ConstructVisitor(handler, querySubj, query.getDataset()); expr.visit(visitor); visitor.end(); } handler.endRDF(); }
Example #2
Source File: PropertyShape.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
String describe(SailRepositoryConnection connection, Resource resource) { GraphQuery graphQuery = connection.prepareGraphQuery("describe ?a where {BIND(?resource as ?a)}"); graphQuery.setBinding("resource", resource); try (Stream<Statement> stream = graphQuery.evaluate().stream()) { LinkedHashModel statements = stream.collect(Collectors.toCollection(LinkedHashModel::new)); statements.setNamespace(SHACL.PREFIX, SHACL.NAMESPACE); WriterConfig config = new WriterConfig(); config.set(BasicWriterSettings.PRETTY_PRINT, true); config.set(BasicWriterSettings.INLINE_BLANK_NODES, true); StringWriter stringWriter = new StringWriter(); Rio.write(statements, stringWriter, RDFFormat.TURTLE, config); return stringWriter.toString(); } }
Example #3
Source File: RDFXMLPrettyWriterBackgroundTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void sequenceItemsAreAbbreviated() throws RDFHandlerException, IOException { StringWriter writer = new StringWriter(); RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer); rdfWriter.startRDF(); Resource res = vf.createIRI("http://example.com/#"); rdfWriter.handleStatement(vf.createStatement(res, RDF.TYPE, RDF.BAG)); rdfWriter.handleStatement( vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_1"), vf.createIRI("http://example.com/#1"))); rdfWriter.handleStatement( vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_2"), vf.createIRI("http://example.com/#2"))); rdfWriter.endRDF(); List<String> rdfLines = rdfOpenTags(writer.toString()); assertEquals(Arrays.asList("<rdf:RDF", "<rdf:Bag", "<rdf:li", "<rdf:li"), rdfLines); }
Example #4
Source File: SailSourceConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void clearInferred(Resource... contexts) throws SailException { verifyIsOpen(); verifyIsActive(); synchronized (datasets) { if (inferredOnlySink == null) { IsolationLevel level = getIsolationLevel(); SailSource branch = branch(IncludeInferred.inferredOnly); inferredOnlyDataset = branch.dataset(level); inferredOnlySink = branch.sink(level); explicitOnlyDataset = branch(IncludeInferred.explicitOnly).dataset(level); } if (this.hasConnectionListeners()) { remove(null, null, null, inferredOnlyDataset, inferredOnlySink, contexts); } inferredOnlySink.clear(contexts); } }
Example #5
Source File: RDFXMLPrettyWriterBackgroundTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void inSequenceItemsMixedWithOtherElementsAreAbbreviated() throws RDFHandlerException, IOException { StringWriter writer = new StringWriter(); RDFWriter rdfWriter = rdfWriterFactory.getWriter(writer); rdfWriter.startRDF(); Resource res = vf.createIRI("http://example.com/#"); rdfWriter.handleStatement(vf.createStatement(res, RDF.TYPE, RDF.BAG)); rdfWriter.handleStatement( vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_2"), vf.createIRI("http://example.com/#2"))); rdfWriter.handleStatement( vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_1"), vf.createIRI("http://example.com/#1"))); rdfWriter.handleStatement( vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_3"), vf.createIRI("http://example.com/#3"))); rdfWriter.handleStatement( vf.createStatement(res, vf.createIRI(RDF.NAMESPACE + "_2"), vf.createIRI("http://example.com/#2"))); rdfWriter.endRDF(); List<String> rdfLines = rdfOpenTags(writer.toString()); assertEquals(Arrays.asList("<rdf:RDF", "<rdf:Bag", "<rdf:_2", "<rdf:li", "<rdf:_3", "<rdf:li"), rdfLines); }
Example #6
Source File: AbstractCommandTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/*** * Add a new repository to the manager. * * @param configStream input stream of the repository configuration * @return ID of the repository as string * @throws IOException * @throws RDF4JException */ protected String addRepository(InputStream configStream) throws IOException, RDF4JException { RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE, SimpleValueFactory.getInstance()); Model graph = new LinkedHashModel(); rdfParser.setRDFHandler(new StatementCollector(graph)); rdfParser.parse( new StringReader(IOUtil.readString(new InputStreamReader(configStream, StandardCharsets.UTF_8))), RepositoryConfigSchema.NAMESPACE); configStream.close(); Resource repositoryNode = Models.subject(graph.filter(null, RDF.TYPE, RepositoryConfigSchema.REPOSITORY)) .orElseThrow(() -> new RepositoryConfigException("could not find subject resource")); RepositoryConfig repoConfig = RepositoryConfig.create(graph, repositoryNode); repoConfig.validate(); manager.addRepositoryConfig(repoConfig); String repId = Models.objectLiteral(graph.filter(repositoryNode, RepositoryConfigSchema.REPOSITORYID, null)) .orElseThrow(() -> new RepositoryConfigException("missing repository id")) .stringValue(); return repId; }
Example #7
Source File: SpinSailConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
private void checkConstraints(Resource subj, List<IRI> classHierarchy) throws RDF4JException { if (sail.isInitializing() || !sail.isValidateConstraints()) { return; } Map<IRI, List<Resource>> constraintsByClass = getConstraintsForSubject(subj, classHierarchy); if (!constraintsByClass.isEmpty()) { // check constraints logger.debug("checking constraints for resource {}", subj); for (Map.Entry<IRI, List<Resource>> clsEntry : constraintsByClass.entrySet()) { List<Resource> constraints = clsEntry.getValue(); for (Resource constraint : constraints) { checkConstraint(subj, constraint); } } } }
Example #8
Source File: StrictEvaluationStrategy.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public Value evaluate(ValueExprTripleRef node, BindingSet bindings) throws QueryEvaluationException { Value subj = evaluate(node.getSubjectVar(), bindings); if (!(subj instanceof Resource)) { throw new ValueExprEvaluationException("no subject value"); } Value pred = evaluate(node.getPredicateVar(), bindings); if (!(pred instanceof IRI)) { throw new ValueExprEvaluationException("no predicate value"); } Value obj = evaluate(node.getObjectVar(), bindings); if (obj == null) { throw new ValueExprEvaluationException("no object value"); } return tripleSource.getValueFactory().createTriple((Resource) subj, (IRI) pred, obj); }
Example #9
Source File: AbstractLuceneSailTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void assertQueryResult(String literal, IRI predicate, Resource resultUri) throws Exception { try (RepositoryConnection connection = repository.getConnection()) { // fire a query for all subjects with a given term String queryString = "SELECT Resource " + "FROM {Resource} <" + MATCHES + "> {} " + " <" + QUERY + "> {\"" + literal + "\"} "; TupleQuery query = connection.prepareTupleQuery(QueryLanguage.SERQL, queryString); try (TupleQueryResult result = query.evaluate()) { // check the result assertTrue("query for literal '" + literal + " did not return any results, expected was " + resultUri, result.hasNext()); BindingSet bindings = result.next(); assertEquals("query for literal '" + literal + " did not return the expected resource", resultUri, bindings.getValue("Resource")); assertFalse(result.hasNext()); } } }
Example #10
Source File: RDFWriterTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testListWithObject() throws Exception { Model input = new LinkedHashModel(); Resource _1 = vf.createBNode(); input.add(uri1, uri2, _1); input.add(_1, RDF.FIRST, bnode); input.add(bnode, RDF.TYPE, RDFS.RESOURCE); input.add(_1, RDF.REST, RDF.NIL); ByteArrayOutputStream outputWriter = new ByteArrayOutputStream(); RDFWriter rdfWriter = rdfWriterFactory.getWriter(outputWriter); setupWriterConfig(rdfWriter.getWriterConfig()); rdfWriter.startRDF(); for (Statement st : input) { rdfWriter.handleStatement(st); } rdfWriter.endRDF(); logger.debug(new String(outputWriter.toByteArray())); ByteArrayInputStream inputReader = new ByteArrayInputStream(outputWriter.toByteArray()); RDFParser rdfParser = rdfParserFactory.getParser(); setupParserConfig(rdfParser.getParserConfig()); Model parsedOutput = new LinkedHashModel(); rdfParser.setRDFHandler(new StatementCollector(parsedOutput)); rdfParser.parse(inputReader, ""); assertSameModel(input, parsedOutput); }
Example #11
Source File: ValueRdfConverterTest.java From Wikidata-Toolkit with Apache License 2.0 | 6 votes |
@Test public void testWriteGlobeCoordinatesValue() throws RDFHandlerException, RDFParseException, IOException { GlobeCoordinatesValueConverter valueConverter = new GlobeCoordinatesValueConverter( this.rdfWriter, this.propertyRegister, this.rdfConversionBuffer); GlobeCoordinatesValue value = this.objectFactory .getGlobeCoordinatesValue(51.033333333333, 13.733333333333, (GlobeCoordinatesValue.PREC_DECI_DEGREE), "http://www.wikidata.org/entity/Q2"); PropertyIdValue propertyIdValue = objectFactory.getPropertyIdValue( "P625", "http://www.wikidata.org/entity/"); Value valueURI = valueConverter.getRdfValue(value, propertyIdValue, false); valueConverter.writeValue(value, (Resource) valueURI); this.rdfWriter.finish(); Model model = RdfTestHelpers.parseRdf(this.out.toString()); assertEquals(model, RdfTestHelpers.parseRdf(RdfTestHelpers .getResourceFromFile("GlobeCoordinatesValue.rdf"))); }
Example #12
Source File: HalyardTableUtils.java From Halyard with Apache License 2.0 | 6 votes |
/** * Parser method returning Statement from a single HBase Result Cell * @param c HBase Result Cell * @param vf ValueFactory to construct Statement and its Values * @return Statements */ public static Statement parseStatement(Cell c, ValueFactory vf) { ByteBuffer bb = ByteBuffer.wrap(c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength()); byte[] sb = new byte[bb.getInt()]; byte[] pb = new byte[bb.getInt()]; byte[] ob = new byte[bb.getInt()]; bb.get(sb); bb.get(pb); bb.get(ob); byte[] cb = new byte[bb.remaining()]; bb.get(cb); Resource subj = readResource(sb, vf); IRI pred = readIRI(pb, vf); Value value = readValue(ob, vf); Statement stmt; if (cb.length == 0) { stmt = vf.createStatement(subj, pred, value); } else { Resource context = readResource(cb, vf); stmt = vf.createStatement(subj, pred, value, context); } return stmt; }
Example #13
Source File: LinkedHashModel.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public boolean remove(Resource subj, IRI pred, Value obj, Resource... contexts) { if (isEmpty()) { return false; } Iterator<ModelStatement> iter = matchPattern(subj, pred, obj, contexts); if (!iter.hasNext()) { return false; } while (iter.hasNext()) { iter.next(); iter.remove(); } return true; }
Example #14
Source File: HBaseSailTest.java From Halyard with Apache License 2.0 | 6 votes |
@Test public void testEvaluate() throws Exception { ValueFactory vf = SimpleValueFactory.getInstance(); Resource subj = vf.createIRI("http://whatever/subj/"); IRI pred = vf.createIRI("http://whatever/pred/"); Value obj = vf.createLiteral("whatever"); CloseableIteration<? extends Statement, SailException> iter; HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "whatevertable", true, 0, true, 0, null, null); SailRepository rep = new SailRepository(sail); rep.initialize(); sail.addStatement(subj, pred, obj); sail.commit(); TupleQuery q = rep.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, "select ?s ?p ?o where {<http://whatever/subj/> <http://whatever/pred/> \"whatever\"}"); TupleQueryResult res = q.evaluate(); assertTrue(res.hasNext()); rep.shutDown(); }
Example #15
Source File: ExploreServlet.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Gets whether this is the first time the result quad has been seen. * * @param patternPredicate the predicate asked for, or null if another quad element was asked for * @param patternObject the object asked for, or null if another quad element was asked for * @param result the result statement to determine if we've already seen * @param patternContext the context asked for, or null if another quad element was asked for * @return true, if this is the first time the quad has been seen, false otherwise */ private boolean isFirstTimeSeen(Statement result, IRI patternPredicate, Value patternObject, Resource... patternContext) { Resource resultSubject = result.getSubject(); IRI resultPredicate = result.getPredicate(); Value resultObject = result.getObject(); boolean firstTimeSeen; if (1 == patternContext.length) { // I.e., when context matches explore value. Resource ctx = patternContext[0]; firstTimeSeen = !(ctx.equals(resultSubject) || ctx.equals(resultPredicate) || ctx.equals(resultObject)); } else if (null != patternObject) { // I.e., when object matches explore value. firstTimeSeen = !(resultObject.equals(resultSubject) || resultObject.equals(resultPredicate)); } else if (null != patternPredicate) { // I.e., when predicate matches explore value. firstTimeSeen = !(resultPredicate.equals(resultSubject)); } else { // I.e., when subject matches explore value. firstTimeSeen = true; } return firstTimeSeen; }
Example #16
Source File: FedXRepositoryConfig.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public Resource export(Model m) { Resource implNode = super.export(m); m.setNamespace("fedx", NAMESPACE); if (getDataConfig() != null) { m.add(implNode, DATA_CONFIG, vf.createLiteral(getDataConfig())); } if (getMembers() != null) { Model members = getMembers(); Set<Resource> memberNodes = members.subjects(); for (Resource memberNode : memberNodes) { m.add(implNode, MEMBER, memberNode); m.addAll(members.filter(memberNode, null, null)); } } return implNode; }
Example #17
Source File: ContextAwareConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Removes the supplied statements from a specific context in this repository, ignoring any context information * carried by the statements themselves. * * @param statementIter The statements to remove. In case the iterator is a {@link CloseableIteration}, it will be * closed before this method returns. * @throws RepositoryException If the statements could not be removed from the repository, for example because the * repository is not writable. * @see #getRemoveContexts() */ @Override public <E extends Exception> void remove(Iteration<? extends Statement, E> statementIter, Resource... contexts) throws RepositoryException, E { final IRI[] removeContexts = getRemoveContexts(); if (isAllContext(contexts) && removeContexts.length == 1) { super.remove(new ConvertingIteration<Statement, Statement, E>(statementIter) { @Override protected Statement convert(Statement st) { if (st.getContext() == null) { return getValueFactory().createStatement(st.getSubject(), st.getPredicate(), st.getObject(), removeContexts[0]); } return st; } }); } else { super.remove(statementIter, contexts); } }
Example #18
Source File: ZeroLengthPathIterationTest.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Before public void setUp() { Model m = new LinkedHashModel(); m.add(RDF.ALT, RDF.TYPE, RDFS.CLASS); m.add(RDF.BAG, RDF.TYPE, RDFS.CLASS); TripleSource ts = new TripleSource() { @Override public CloseableIteration<? extends Statement, QueryEvaluationException> getStatements(Resource subj, IRI pred, Value obj, Resource... contexts) throws QueryEvaluationException { return new CloseableIteratorIteration<>(m.getStatements(subj, pred, obj, contexts).iterator()); } @Override public ValueFactory getValueFactory() { return vf; } }; evaluator = new StrictEvaluationStrategy(ts, null); }
Example #19
Source File: AbstractSailConnection.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public final CloseableIteration<? extends Statement, SailException> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException { flushPendingUpdates(); connectionLock.readLock().lock(); try { verifyIsOpen(); boolean registered = false; CloseableIteration<? extends Statement, SailException> iteration = getStatementsInternal(subj, pred, obj, includeInferred, contexts); try { CloseableIteration<? extends Statement, SailException> registeredIteration = registerIteration( iteration); registered = true; return registeredIteration; } finally { if (!registered) { iteration.close(); } } } finally { connectionLock.readLock().unlock(); } }
Example #20
Source File: SpinRenderer.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void meet(Union node) throws RDFHandlerException { listEntry(); handler.handleStatement(valueFactory.createStatement(subject, RDF.TYPE, SP.UNION_CLASS)); Resource elementsList = valueFactory.createBNode(); handler.handleStatement(valueFactory.createStatement(subject, SP.ELEMENTS_PROPERTY, elementsList)); ListContext elementsCtx = newList(elementsList); listEntry(); ListContext leftCtx = newList(subject); node.getLeftArg().visit(this); endList(leftCtx); listEntry(); ListContext rightCtx = newList(subject); node.getRightArg().visit(this); endList(rightCtx); endList(elementsCtx); }
Example #21
Source File: FederationEvalStrategy.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public FederationEvalStrategy(FederationContext federationContext) { super(new org.eclipse.rdf4j.query.algebra.evaluation.TripleSource() { @Override public CloseableIteration<? extends Statement, QueryEvaluationException> getStatements( Resource subj, IRI pred, Value obj, Resource... contexts) throws QueryEvaluationException { throw new FedXRuntimeException( "Federation Strategy does not support org.openrdf.query.algebra.evaluation.TripleSource#getStatements." + " If you encounter this exception, please report it."); } @Override public ValueFactory getValueFactory() { return SimpleValueFactory.getInstance(); } }, federationContext.getFederatedServiceResolver()); this.federationContext = federationContext; this.executor = federationContext.getManager().getExecutor(); this.cache = createSourceSelectionCache(); }
Example #22
Source File: GeoIndexerSfTest.java From rya with Apache License 2.0 | 6 votes |
private static Statement genericStatementGml(final Geometry geo, final IRI encodingMethod) { final Resource subject = VF.createIRI("uri:" + NAMES.get(geo)); final IRI predicate = GeoConstants.GEO_AS_GML; final String gml ; if (encodingMethod == USE_JTS_LIB_ENCODING) { gml = geoToGmlUseJtsLib(geo); } else if (encodingMethod == USE_ROUGH_ENCODING) { gml = geoToGmlRough(geo); } else { throw new Error("invalid encoding method: "+encodingMethod); // System.out.println("===created GML===="); // System.out.println(gml); // System.out.println("========== GML===="); } final Value object = VF.createLiteral(gml, GeoConstants.XMLSCHEMA_OGC_GML); return VF.createStatement(subject, predicate, object); }
Example #23
Source File: ObjectFunction.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public Value evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { QueryPreparer qp = getCurrentQueryPreparer(); if (args.length != 2) { throw new ValueExprEvaluationException( String.format("%s requires 2 arguments, got %d", getURI(), args.length)); } Value subj = args[0]; if (!(subj instanceof Resource)) { throw new ValueExprEvaluationException("First argument must be a subject"); } Value pred = args[1]; if (!(pred instanceof IRI)) { throw new ValueExprEvaluationException("Second argument must be a predicate"); } try { try (CloseableIteration<? extends Statement, QueryEvaluationException> stmts = qp.getTripleSource() .getStatements((Resource) subj, (IRI) pred, null)) { if (stmts.hasNext()) { return stmts.next().getObject(); } else { throw new ValueExprEvaluationException("No value"); } } } catch (QueryEvaluationException e) { throw new ValueExprEvaluationException(e); } }
Example #24
Source File: LinkedHashModel.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void writeObject(ObjectOutputStream s) throws IOException { // Write out any hidden serialization magic s.defaultWriteObject(); // Write in size s.writeInt(statements.size()); // Write in all elements for (ModelStatement st : statements) { Resource subj = st.getSubject(); IRI pred = st.getPredicate(); Value obj = st.getObject(); Resource ctx = st.getContext(); s.writeObject(new ContextStatement(subj, pred, obj, ctx)); } }
Example #25
Source File: InterceptingRepositoryConnectionWrapper.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void clear(Resource... contexts) throws RepositoryException { boolean denied = false; if (activated) { for (RepositoryConnectionInterceptor interceptor : interceptors) { denied = interceptor.clear(getDelegate(), contexts); if (denied) { break; } } } if (!denied) { getDelegate().clear(contexts); } }
Example #26
Source File: CombineContextsRdfInserter.java From rya with Apache License 2.0 | 5 votes |
@Override public void handleStatement(Statement st) throws RDFHandlerException { Resource subj = st.getSubject(); IRI pred = st.getPredicate(); Value obj = st.getObject(); Resource ctxt = st.getContext(); if (!preserveBNodeIDs) { if (subj instanceof BNode) { subj = mapBNode((BNode) subj); } if (obj instanceof BNode) { obj = mapBNode((BNode) obj); } if (!enforcesContext() && ctxt instanceof BNode) { ctxt = mapBNode((BNode) ctxt); } } try { if (enforcesContext()) { Resource[] ctxts = contexts; if (ctxt != null) { ctxts = combineContexts(contexts, ctxt); } con.add(subj, pred, obj, ctxts); } else { con.add(subj, pred, obj, ctxt); } } catch (RepositoryException e) { throw new RDFHandlerException(e); } }
Example #27
Source File: OrPropertyShape.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
OrPropertyShape(Resource id, SailRepositoryConnection connection, NodeShape nodeShape, boolean deactivated, PathPropertyShape parent, Resource path, List<List<PathPropertyShape>> or) { super(id, connection, nodeShape, deactivated, parent, path); this.or = or; }
Example #28
Source File: RepositoryConnectionWrapper.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public boolean hasStatement(Statement st, boolean includeInferred, Resource... contexts) throws RepositoryException { if (isDelegatingRead()) { return getDelegate().hasStatement(st, includeInferred, contexts); } return super.hasStatement(st, includeInferred, contexts); }
Example #29
Source File: SpinConstructRule.java From rya with Apache License 2.0 | 5 votes |
public TypeRequirementVisitor(String varName, Resource requiredType) { final Var typeVar = VarNameUtils.createUniqueConstVar(requiredType); typeVar.setConstant(true); this.varName = varName; if (BASE_TYPES.contains(requiredType)) { this.typeRequirement = null; } else { this.typeRequirement = new StatementPattern(new Var(varName), RDF_TYPE_VAR, typeVar); } }
Example #30
Source File: RDFInserter.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override protected void addStatement(Resource subj, IRI pred, Value obj, Resource ctxt) throws RDF4JException { if (enforcesContext()) { con.add(subj, pred, obj, contexts); } else { con.add(subj, pred, obj, ctxt); } }