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

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

There is a newer version: 4.10.0
Show newest version
package org.vertexium.query;

import org.vertexium.*;
import org.vertexium.util.JoinIterable;

public class DefaultGraphQuery extends GraphQueryBase {
    public DefaultGraphQuery(Graph graph, String queryString, Authorizations authorizations) {
        super(graph, queryString, authorizations);
    }

    @Override
    public QueryResultsIterable vertices(FetchHints fetchHints) {
        return new DefaultGraphQueryIterableWithAggregations<>(
            getParameters(),
            this.getIterableFromElementType(ElementType.VERTEX, fetchHints),
            true,
            true,
            true,
            getAggregations()
        );
    }

    @Override
    public QueryResultsIterable edges(FetchHints fetchHints) {
        return new DefaultGraphQueryIterableWithAggregations<>(
            getParameters(),
            this.getIterableFromElementType(ElementType.EDGE, fetchHints),
            true,
            true,
            true,
            getAggregations()
        );
    }

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

    @Override
    protected QueryResultsIterable extendedData(FetchHints extendedDataFetchHints) {
        FetchHints extendedDataTableNamesFetchHints = FetchHints.builder()
            .setIncludeExtendedDataTableNames(true)
            .setIgnoreAdditionalVisibilities(extendedDataFetchHints.isIgnoreAdditionalVisibilities())
            .build();
        return extendedData(extendedDataFetchHints, new JoinIterable(
            getIterableFromElementType(ElementType.VERTEX, extendedDataTableNamesFetchHints),
            getIterableFromElementType(ElementType.EDGE, extendedDataTableNamesFetchHints)
        ));
    }

    @Override
    public boolean isAggregationSupported(Aggregation aggregation) {
        if (DefaultGraphQueryIterableWithAggregations.isAggregationSupported(aggregation)) {
            return true;
        }
        return super.isAggregationSupported(aggregation);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy