All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.securegraph.query.DefaultGraphQuery Maven / Gradle / Ivy

The newest version!
package org.securegraph.query;

import org.securegraph.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.EnumSet;
import java.util.Map;

public class DefaultGraphQuery extends GraphQueryBase {
    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultGraphQuery.class);

    public DefaultGraphQuery(Graph graph, String queryString, Map propertyDefinitions, Authorizations authorizations) {
        super(graph, queryString, propertyDefinitions, authorizations);
    }

    @Override
    public Iterable vertices(EnumSet fetchHints) {
        LOGGER.warn("scanning all vertices! create your own GraphQuery.");
        return new DefaultGraphQueryIterable(getParameters(), this.getIterableFromElementType(ElementType.VERTEX, fetchHints), true, true);
    }

    @Override
    public Iterable edges(EnumSet fetchHints) {
        LOGGER.warn("scanning all edges! create your own GraphQuery.");
        return new DefaultGraphQueryIterable(getParameters(), this.getIterableFromElementType(ElementType.EDGE, fetchHints), true, true);
    }

    @SuppressWarnings("unchecked")
    private  Iterable getIterableFromElementType(ElementType elementType, EnumSet fetchHints) throws SecureGraphException {
        switch (elementType) {
            case VERTEX:
                return (Iterable) getGraph().getVertices(fetchHints, getParameters().getAuthorizations());
            case EDGE:
                return (Iterable) getGraph().getEdges(fetchHints, getParameters().getAuthorizations());
            default:
                throw new SecureGraphException("Unexpected element type: " + elementType);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy