/** * Create instance * * @param hg associated graph * @param query query instance to be wrapped */ public HistoricGraphQuery(HistoricVersionedGraph<?, V> hg, GraphQuery query) { super(query.has(VEProps.HISTORIC_ELEMENT_PROP_KEY, true)); this.hg = hg; }
public GraphQuery has(final String key, final Object value) { this.query = this.query.has(key, value); return this; }
public FramedGraphQuery has(String key, Object value) { graphQuery = graphQuery.has(key, value); return this; }
public <T extends Comparable<T>> FramedGraphQuery has(String key, T value, Compare compare) { graphQuery = graphQuery.has(key, value, compare); return this; }
public <T extends Comparable<T>> FramedGraphQuery has(String key, T value, Compare compare) { graphQuery = graphQuery.has(key, value, compare); return this; }
public GraphQuery has(final String key, final Predicate compare, final Object value) { this.query = this.query.has(key, compare, value); return this; }
public GraphQuery getQuery() { return this.query.has(VEProps.HISTORIC_ELEMENT_PROP_KEY, false); } };
public FramedGraphQuery has(String key, Predicate predicate, Object value) { graphQuery = graphQuery.has(key, predicate, value); return this; }
public FramedGraphQuery has(String key) { graphQuery = graphQuery.has(key); return this; }
public FramedGraphQuery has(String key, Predicate predicate, Object value) { graphQuery = graphQuery.has(key, predicate, value); return this; }
@Override public boolean contains(Atom atom) { GraphQuery query = this.graph.query(); query.has("class", "atom"); query.has("predicate", predicateToString(atom.getPredicate())); int i = 0; for (Term t : atom) { query.has("term" + i++, termToString(t)); } return query.vertices().iterator().hasNext(); }
@Override public CloseableIterator<Term> termsByPredicatePosition(Predicate p, int position) throws AtomSetException { GraphQuery query = this.graph.query(); query.has("class", "atom"); query.has("predicate", predicateToString(p)); Set<Term> terms = new TreeSet<Term>(); Iterator<Term> it = new AtomToTermIterator(query.vertices().iterator(), position); while (it.hasNext()) { terms.add(it.next()); } return new CloseableIteratorAdapter<Term>(terms.iterator()); }
@Override public Iterable<Vertex> vertices() { return new PartitionVertexIterable(this.query.has(partitionKey, Contains.IN, readPartitions).vertices(), partitionGraph); } };
@Override public Iterable<Vertex> getVertices(final String key, final Object value) { // We need to make Query to filter by key/value first to get a tinest // scope. // See DefaultQuery#hasContainers return query().has(key, value).vertices(); }
@Override public Iterable<Edge> getEdges(final String key, final Object value) { // TODO: Consider forbidding retrieving edges by internal keys // (especially NATURAL_EDGE_ID_PROP_KEY), otherwise throw exception. // We need to make Query to filter by key/value first to get a tinest // scope. // See DefaultQuery#hasContainers return query().has(key, value).edges(); }
@Override public Iterable<Vertex> getVertices(String key, Object value) { // NOTE: This methods returns *ALL* vertices (including all revisions) // in the entire graph. if (key != null) { return query().has(key, value).vertices(); } else { return query().vertices(); } }
private PartitionGraph getPartitionRW(String farmID) { PartitionGraph part = new PartitionGraph(rawGraph, PARTITION_KEY, farmID); //TODO: apply user roles and permissions on farms Query farmIDsQuery = part.query().has(AgroEntity.PROP_ITEM_ID_TYPE, FARM_ID_TYPE); if (farmIDsQuery.vertices() != null) { for (Vertex v : farmIDsQuery.vertices()) { String uri = v.getProperty(Farm.PROP_URI); if (uri != null && !uri.isEmpty()) { part.addReadPartition(uri); } } } return part; }