Search in sources :

Example 1 with FederatedTransformHandler

use of uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler in project Gaffer by gchq.

the class FederatedStore method addAdditionalOperationHandlers.

@Override
protected void addAdditionalOperationHandlers() {
    // Override the Operations that don't have an output
    getSupportedOperations().stream().filter(op -> !Output.class.isAssignableFrom(op) && !AddElements.class.equals(op) && !AddNamedOperation.class.equals(op) && !AddNamedView.class.equals(op)).forEach(op -> addOperationHandler(op, new FederatedOperationHandler()));
    addOperationHandler(GetSchema.class, new FederatedGetSchemaHandler());
    addOperationHandler(Filter.class, new FederatedFilterHandler());
    addOperationHandler(Aggregate.class, new FederatedAggregateHandler());
    addOperationHandler(Transform.class, new FederatedTransformHandler());
    addOperationHandler(Validate.class, new FederatedValidateHandler());
    addOperationHandler(GetAllGraphIds.class, new FederatedGetAllGraphIDHandler());
    addOperationHandler(AddGraph.class, new FederatedAddGraphHandler());
    addOperationHandler(AddGraphWithHooks.class, new FederatedAddGraphWithHooksHandler());
    addOperationHandler(RemoveGraph.class, new FederatedRemoveGraphHandler());
    addOperationHandler(FederatedOperationChain.class, new FederatedOperationChainHandler());
    addOperationHandler(GetTraits.class, new FederatedGetTraitsHandler());
    addOperationHandler(GetAllGraphInfo.class, new FederatedGetAllGraphInfoHandler());
    addOperationHandler(ChangeGraphAccess.class, new FederatedChangeGraphAccessHandler());
    addOperationHandler(ChangeGraphId.class, new FederatedChangeGraphIdHandler());
}
Also used : StorageException(uk.gov.gchq.gaffer.federatedstore.exception.StorageException) FederatedAddGraphWithHooksHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedAddGraphWithHooksHandler) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) FederatedOperationChainValidator(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChainValidator) FederatedOperationChain(uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain) Element(uk.gov.gchq.gaffer.data.element.Element) AccessPredicate(uk.gov.gchq.gaffer.access.predicate.AccessPredicate) Filter(uk.gov.gchq.gaffer.operation.impl.function.Filter) Graph(uk.gov.gchq.gaffer.graph.Graph) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Map(java.util.Map) RemoveGraph(uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph) FederatedGetAllElementsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllElementsHandler) Objects.isNull(java.util.Objects.isNull) GetAllGraphInfo(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphInfo) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) FederatedChangeGraphIdHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedChangeGraphIdHandler) FederatedGetAdjacentIdsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAdjacentIdsHandler) FederatedGetAllGraphInfoHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllGraphInfoHandler) GetTraits(uk.gov.gchq.gaffer.store.operation.GetTraits) Collection(java.util.Collection) FederatedAddGraphHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedAddGraphHandler) Set(java.util.Set) FederatedChangeGraphAccessHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedChangeGraphAccessHandler) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) FederatedViewValidator(uk.gov.gchq.gaffer.federatedstore.schema.FederatedViewValidator) Store(uk.gov.gchq.gaffer.store.Store) FederatedStoreUtil.getCleanStrings(uk.gov.gchq.gaffer.federatedstore.util.FederatedStoreUtil.getCleanStrings) List(java.util.List) Context(uk.gov.gchq.gaffer.store.Context) IS_PUBLIC_ACCESS_ALLOWED_DEFAULT(uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties.IS_PUBLIC_ACCESS_ALLOWED_DEFAULT) FederatedTransformHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler) FederatedRemoveGraphHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedRemoveGraphHandler) FederatedOperationChainHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedOperationChainHandler) FederatedAggregateHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedAggregateHandler) AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) FederatedGetTraitsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandler) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) OutputOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OutputOperationHandler) Objects.nonNull(java.util.Objects.nonNull) FederatedOperationHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedOperationHandler) FederatedGetSchemaHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedGetSchemaHandler) FederatedFilterHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedFilterHandler) StoreException(uk.gov.gchq.gaffer.store.StoreException) Serialiser(uk.gov.gchq.gaffer.serialisation.Serialiser) User(uk.gov.gchq.gaffer.user.User) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) HashMap(java.util.HashMap) FederatedGetElementsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetElementsHandler) FederatedStoreUtil(uk.gov.gchq.gaffer.federatedstore.util.FederatedStoreUtil) ArrayList(java.util.ArrayList) Strings(com.google.common.base.Strings) FederatedValidateHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedValidateHandler) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) Transform(uk.gov.gchq.gaffer.operation.impl.function.Transform) Output(uk.gov.gchq.gaffer.operation.io.Output) Validate(uk.gov.gchq.gaffer.operation.impl.Validate) Aggregate(uk.gov.gchq.gaffer.operation.impl.function.Aggregate) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) ChangeGraphAccess(uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphAccess) EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Logger(org.slf4j.Logger) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) AddGraphWithHooks(uk.gov.gchq.gaffer.federatedstore.operation.AddGraphWithHooks) ChangeGraphId(uk.gov.gchq.gaffer.federatedstore.operation.ChangeGraphId) FederatedGetAllGraphIDHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllGraphIDHandler) GraphSerialisable(uk.gov.gchq.gaffer.graph.GraphSerialisable) Operation(uk.gov.gchq.gaffer.operation.Operation) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetAllGraphIds(uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) OperationChainValidator(uk.gov.gchq.gaffer.store.operation.OperationChainValidator) OperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OperationHandler) AddNamedView(uk.gov.gchq.gaffer.named.view.AddNamedView) Collections(java.util.Collections) FederatedRemoveGraphHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedRemoveGraphHandler) FederatedGetSchemaHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedGetSchemaHandler) FederatedValidateHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedValidateHandler) FederatedGetTraitsHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandler) FederatedChangeGraphIdHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedChangeGraphIdHandler) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) FederatedChangeGraphAccessHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedChangeGraphAccessHandler) FederatedAddGraphHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedAddGraphHandler) FederatedTransformHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler) FederatedAddGraphWithHooksHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedAddGraphWithHooksHandler) FederatedOperationChainHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedOperationChainHandler) FederatedGetAllGraphIDHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllGraphIDHandler) FederatedOperationHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedOperationHandler) FederatedFilterHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedFilterHandler) FederatedAggregateHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedAggregateHandler) FederatedGetAllGraphInfoHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetAllGraphInfoHandler)

Example 2 with FederatedTransformHandler

use of uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler in project Gaffer by gchq.

the class FederatedTransformHandlerTest method shouldDelegateToHandler.

@Test
public void shouldDelegateToHandler() throws OperationException {
    // Given
    final FederatedStore store = mock(FederatedStore.class);
    final TransformHandler handler = mock(TransformHandler.class);
    final Transform op = mock(Transform.class);
    final Context context = mock(Context.class);
    final Iterable expectedResult = mock(Iterable.class);
    final Schema schema = mock(Schema.class);
    given(store.getSchema(op, context)).willReturn(schema);
    given(handler.doOperation(op, schema)).willReturn(expectedResult);
    final FederatedTransformHandler federatedHandler = new FederatedTransformHandler(handler);
    // When
    final Object result = federatedHandler.doOperation(op, context, store);
    // Then
    assertSame(expectedResult, result);
    verify(handler).doOperation(op, schema);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) FederatedTransformHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler) TransformHandler(uk.gov.gchq.gaffer.store.operation.handler.function.TransformHandler) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Transform(uk.gov.gchq.gaffer.operation.impl.function.Transform) FederatedTransformHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Aggregations

FederatedTransformHandler (uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler)2 Transform (uk.gov.gchq.gaffer.operation.impl.function.Transform)2 Context (uk.gov.gchq.gaffer.store.Context)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 Strings (com.google.common.base.Strings)1 Sets (com.google.common.collect.Sets)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects.isNull (java.util.Objects.isNull)1 Objects.nonNull (java.util.Objects.nonNull)1 Random (java.util.Random)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.jupiter.api.Test)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1