@Override public InferenceOptions getInferenceOptions() { return connections[0].getInferenceOptions(); }
public RDFQueryBuilder(RDFConnection connection, Session session, Configuration configuration, Ontology ontology, QueryMetadata metadata) { this.connection = connection; this.session = session; this.configuration = configuration; this.ontology = ontology; this.queryOptions = connection.getQueryOptions(); this.inferenceOptions = connection.getInferenceOptions(); this.metadata = metadata; this.projection = new ArrayList<Expression<?>>(); }
private List<STMT> findStatements(@Nullable ID subject, @Nullable UID predicate, @Nullable NODE object, @Nullable UID context, boolean includeInferred) { if (logger.isDebugEnabled()) { logger.debug("findStatements " + subject + " " + predicate + " " + object + " " + context); } // rdf type inference if (RDF.type.equals(predicate) && subject == null && object != null && connection.getInferenceOptions().subClassOf()) { Collection<UID> types = ontology.getSubtypes(object.asURI()); if (types.size() > 1) { RDFQuery query = new RDFQueryImpl(connection); CloseableIterator<STMT> stmts = query.where( Blocks.SPOC, QNODE.o.in(types)) .set(QNODE.p, predicate) .construct(Blocks.SPOC); return IteratorAdapter.asList(stmts); } } return IteratorAdapter.asList(connection.findStatements(subject, predicate, object, context, includeInferred)); }
private RDFQuery createQuery(MappedClass mappedClass, @Nullable UID type, boolean polymorphic) { RDFQuery query = new RDFQueryImpl(connection); if (type != null) { query.where(Blocks.S_TYPE); if (mappedClass.getContext() != null) { query.set(QNODE.typeContext, mappedClass.getContext()); } if (polymorphic) { Collection<UID> types = ontology.getSubtypes(type); if (types.size() > 1 && connection.getInferenceOptions().subClassOf()) { query.where(QNODE.type.in(types)); } else { query.set(QNODE.type, type); } } else { query.set(QNODE.type, type); } } query.where(Blocks.SPOC); if (!polymorphic && mappedClass.getDynamicProperties().isEmpty() && mappedClass.getMappedPredicates().size() < 5) { query.where(QNODE.p.in(mappedClass.getMappedPredicates())); } return query; }