org.vertexium.query.DefaultGraphQuery Maven / Gradle / Ivy
package org.vertexium.query;
import org.vertexium.*;
import org.vertexium.util.JoinIterable;
import java.util.EnumSet;
public class DefaultGraphQuery extends GraphQueryBase {
public DefaultGraphQuery(Graph graph, String queryString, Authorizations authorizations) {
super(graph, queryString, authorizations);
}
@Override
public QueryResultsIterable vertices(EnumSet fetchHints) {
return new DefaultGraphQueryIterableWithAggregations<>(
getParameters(),
this.getIterableFromElementType(ElementType.VERTEX, fetchHints),
true,
true,
true,
getAggregations()
);
}
@Override
public QueryResultsIterable edges(EnumSet fetchHints) {
return new DefaultGraphQueryIterableWithAggregations<>(
getParameters(),
this.getIterableFromElementType(ElementType.EDGE, fetchHints),
true,
true,
true,
getAggregations()
);
}
@SuppressWarnings("unchecked")
private Iterable getIterableFromElementType(ElementType elementType, EnumSet 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 extends VertexiumObject> extendedData(EnumSet extendedDataFetchHints) {
EnumSet extendedDataTableNamesFetchHints = EnumSet.of(FetchHint.EXTENDED_DATA_TABLE_NAMES);
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