public Result asResult() throws OpenRDFException { ObjectQuery qry = prepareObjectQuery(Object.class); return qry.evaluate(); }
private ObjectQuery createObjectQuery(TupleQuery query) { return new ObjectQuery(this, query); }
/** * Evaluates the query returning a result of Object or result of Object[], * if there is more than one binding. */ public Result<?> evaluate() throws QueryEvaluationException { TupleQueryResult result = query.evaluate(); List<String> bindings = result.getBindingNames(); return new ResultImpl(createCursor(result, bindings)); }
/** * Finds a single object of given concept and uri. */ public synchronized <T> T findObject(Class<T> concept, Resource resource) throws RepositoryException, QueryEvaluationException { try { ObjectQuery query = getObjectQuery(concept, 0); query.setBinding("subj", resource); return query.evaluate(concept).next(); } catch (MalformedQueryException e) { throw new AssertionError(e); } }
if (query.getDataset() != null) { logger.info("\nGRAPH CONTEXT = " + query.getDataset().getDefaultGraphs() + "\nFINAL QUERY :\n" + q); } else { logger.info("\nFINAL QUERY :\n" + q); return (List<T>) query.evaluate().asList();
/** * Binds the specified variable to the supplied object. Any value that was * previously bound to the specified value will be overwritten. * * @param name * variable name * @param value * datatype or concept implementation */ public void setObject(String name, Object value) { if (value == null) { setBinding(name, null); } else { setBinding(name, manager.getObjectFactory().createValue(value)); } }
ObjectQuery query = getObjectQuery(concept, size); if (size == 1) { query.setBinding(ObjectFactory.VAR_PREFIX, resources[0]); } else if (size > 1) { for (int i = 0; i < size; i++) { query.setBinding(ObjectFactory.VAR_PREFIX + i, resources[i]); list.addAll(Arrays.asList(resources)); CloseableIteration<T, QueryEvaluationException> iter; final Result<T> result = query.evaluate(concept); iter = new LookAheadIteration<T, QueryEvaluationException>() { @Override
/** * Binds the specified variable to the supplied object. Any value that was * previously bound to the specified value will be overwritten. * * @param name * variable name * @param value * datatype or concept implementation */ public void setObject(String name, Object value) { if (value == null) { setBinding(name, null); } else { setBinding(name, manager.getObjectFactory().createValue(value)); } }
public Result asResult() throws OpenRDFException { ObjectQuery qry = prepareObjectQuery(Object.class); return qry.evaluate(); }
ObjectQuery query = getObjectQuery(concept, size); if (size == 1) { query.setBinding(ObjectFactory.VAR_PREFIX, resources[0]); } else if (size > 1) { for (int i = 0; i < size; i++) { query.setBinding(ObjectFactory.VAR_PREFIX + i, resources[i]); list.addAll(Arrays.asList(resources)); CloseableIteration<T, QueryEvaluationException> iter; final Result<T> result = query.evaluate(concept); iter = new LookAheadIteration<T, QueryEvaluationException>() { @Override
/** * Creates a new query that returns object(s). */ public ObjectQuery prepareObjectQuery(String query) throws MalformedQueryException, RepositoryException { return new ObjectQuery(this, prepareTupleQuery(query)); }
/** * Binds the specified variable to the supplied concept. Any value that was * previously bound to the specified value will be overwritten. * * @param name * variable name * @param concept * a registered concept class or interface */ public void setType(String name, Class<?> concept) { URI type = manager.getObjectFactory().getNameOf(concept); if (concept != null && type == null) throw new IllegalArgumentException("Not a registered concept: " + concept); setBinding(name, type); }
/** * Evaluates the query returning a result of Object or result of Object[], * if there is more than one binding. */ public Result<?> evaluate() throws QueryEvaluationException { TupleQueryResult result = query.evaluate(); List<String> bindings = result.getBindingNames(); return new ResultImpl(createCursor(result, bindings)); }
/** * Matches objects that have the given concept rdf:type. This method will * include all objects that implement the given concept or a subclass of the * concept. The concept must be a named concept and cannot be mapped to * rdfs:Resource. The result of this method is not guaranteed to be unique * and may continue duplicates. Use the {@link Result#asSet()} method to * ensure uniqueness. * * @see #addDesignation(Object, Class) */ public synchronized <T> Result<T> getObjects(Class<T> concept) throws RepositoryException, QueryEvaluationException { try { return getObjectQuery(concept, 0).evaluate(concept); } catch (MalformedQueryException e) { throw new AssertionError(e); } }
@Override protected synchronized CloseableIteration<?, ?> getObjects() throws RepositoryException, QueryEvaluationException { if (creator == null || factory == null) { return super.getObjects(); } else if (binding == null) { ObjectQuery query = factory.createQuery(creator); if (query == null) return super.getObjects(); try { query.setBinding("self", getResource()); return query.evaluate(creator.getPropertyType()); } finally { factory.returnQuery(creator, query); } } else { CloseableIteratorIteration<BindingSet, QueryEvaluationException> result; result = new CloseableIteratorIteration<BindingSet, QueryEvaluationException>( bindings.iterator()); return new ObjectCursor(getObjectConnection(), result, binding); } }
/** * Creates a new query that returns object(s). */ public ObjectQuery prepareObjectQuery(QueryLanguage ql, String query, String baseURI) throws MalformedQueryException, RepositoryException { return new ObjectQuery(this, prepareTupleQuery(ql, query, baseURI)); }
/** * Binds the specified variable to the supplied concept. Any value that was * previously bound to the specified value will be overwritten. * * @param name * variable name * @param concept * a registered concept class or interface */ public void setType(String name, Class<?> concept) { URI type = manager.getObjectFactory().getNameOf(concept); if (concept != null && type == null) throw new IllegalArgumentException("Not a registered concept: " + concept); setBinding(name, type); }
/** * Matches objects that have the given concept rdf:type. This method will * include all objects that implement the given concept or a subclass of the * concept. The concept must be a named concept and cannot be mapped to * rdfs:Resource. The result of this method is not guaranteed to be unique * and may continue duplicates. Use the {@link Result#asSet()} method to * ensure uniqueness. * * @see #addDesignation(Object, Class) */ public synchronized <T> Result<T> getObjects(Class<T> concept) throws RepositoryException, QueryEvaluationException { try { return getObjectQuery(concept, 0).evaluate(concept); } catch (MalformedQueryException e) { throw new AssertionError(e); } }
@Override protected CloseableIteration<?, ?> getObjects() throws RepositoryException, QueryEvaluationException { if (creator == null || factory == null) { return super.getObjects(); } else if (binding == null) { ObjectQuery query = factory.createQuery(creator); if (query == null) return super.getObjects(); try { query.setBinding("self", getResource()); return query.evaluate(creator.getPropertyType()); } finally { factory.returnQuery(creator, query); } } else { CloseableIteratorIteration<BindingSet, QueryEvaluationException> result; result = new CloseableIteratorIteration<BindingSet, QueryEvaluationException>( bindings.iterator()); return new ObjectCursor(getObjectConnection(), result, binding); } }
/** * Creates a new query that returns object(s). */ public ObjectQuery prepareObjectQuery(QueryLanguage ql, String query) throws MalformedQueryException, RepositoryException { return new ObjectQuery(this, prepareTupleQuery(ql, query)); }