Search in sources :

Example 1 with StreamFilterIterable

use of uk.gov.gchq.gaffer.operation.util.StreamFilterIterable in project Gaffer by gchq.

the class FilterHandler method doOperation.

public Iterable<? extends Element> doOperation(final Filter operation, final Schema schema) throws OperationException {
    if (null == operation.getInput()) {
        throw new OperationException("Filter operation has null iterable of elements");
    }
    // all elements should be used. This matches the way a View works.
    if (null == operation.getEntities() && null == operation.getEdges()) {
        final Map<String, ElementFilter> entityMap = new HashMap<>();
        schema.getEntityGroups().forEach(e -> entityMap.put(e, new ElementFilter()));
        operation.setEntities(entityMap);
        final Map<String, ElementFilter> edgeMap = new HashMap<>();
        schema.getEdgeGroups().forEach(e -> edgeMap.put(e, new ElementFilter()));
        operation.setEdges(edgeMap);
    }
    final ValidationResult result = validator.validate(operation, schema);
    if (!result.isValid()) {
        throw new OperationException("Filter operation is invalid. " + result.getErrorString());
    }
    return new StreamFilterIterable(operation);
}
Also used : StreamFilterIterable(uk.gov.gchq.gaffer.operation.util.StreamFilterIterable) HashMap(java.util.HashMap) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Aggregations

HashMap (java.util.HashMap)1 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)1 OperationException (uk.gov.gchq.gaffer.operation.OperationException)1 StreamFilterIterable (uk.gov.gchq.gaffer.operation.util.StreamFilterIterable)1 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)1