Search in sources :

Example 1 with StreamTransformIterable

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

the class TransformHandler method doOperation.

public Iterable<? extends Element> doOperation(final Transform operation, final Schema schema) throws OperationException {
    if (null == operation.getInput()) {
        throw new OperationException("Transform 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, ElementTransformer> entityMap = new HashMap<>();
        schema.getEntityGroups().forEach(e -> entityMap.put(e, new ElementTransformer()));
        operation.setEntities(entityMap);
        final Map<String, ElementTransformer> edgeMap = new HashMap<>();
        schema.getEdgeGroups().forEach(e -> edgeMap.put(e, new ElementTransformer()));
        operation.setEdges(edgeMap);
    }
    final ValidationResult result = validator.validate(operation, schema);
    if (!result.isValid()) {
        throw new OperationException("Transform operation is invalid. " + result.getErrorString());
    }
    return new StreamTransformIterable(operation);
}
Also used : StreamTransformIterable(uk.gov.gchq.gaffer.store.operation.util.StreamTransformIterable) HashMap(java.util.HashMap) ElementTransformer(uk.gov.gchq.gaffer.data.element.function.ElementTransformer) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) OperationException(uk.gov.gchq.gaffer.operation.OperationException)

Aggregations

HashMap (java.util.HashMap)1 ElementTransformer (uk.gov.gchq.gaffer.data.element.function.ElementTransformer)1 OperationException (uk.gov.gchq.gaffer.operation.OperationException)1 StreamTransformIterable (uk.gov.gchq.gaffer.store.operation.util.StreamTransformIterable)1 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)1