From 96b24ccf6a508621f4719a8008d1c2e9d97a914e Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Thu, 2 Nov 2023 16:18:34 +0000 Subject: [PATCH 01/15] Validation Bug --- .../FederatedStoreViewAggregationTest.java | 31 ++++++++++++++++++ .../basicEntityValidateLess100Schema.json | 32 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 store-implementation/federated-store/src/test/resources/schema/basicEntityValidateLess100Schema.json diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java index 4b542d41e55..4be34d02117 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java @@ -132,6 +132,37 @@ public void shouldOnlyReturn1EntitySmallerThanViewFilter() throws Exception { .hasSize(1); } + @Test + public void shouldOnlyReturn1EntitySmallerThanSchemaValidationLimit() throws Exception { + + //given + addGraphToAccumuloStore(federatedStore, GRAPH_ID_A, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); + addGraphToAccumuloStore(federatedStore, GRAPH_ID_B, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); + + addEntity(GRAPH_ID_A, entity1); + addEntity(GRAPH_ID_B, entity99); + addEntity(GRAPH_ID_B, entityOther); + + //when + final Iterable elementsWithPropertyLessThan100 = federatedStore.execute(new GetAllElements(), contextTestUser()); + + //then + assertThat(elementsWithPropertyLessThan100) + .isNotNull() + .withFailMessage("should return entity \"basicVertexOther\" with property 99, which is less than view filter 100") + .contains(entityOther) + .withFailMessage("should not return entity \"basicVertex\" with un-aggregated property 1 or 99") + .doesNotContain(entity1, entity99) + .withFailMessage("should not return entity \"basicVertex\" with an aggregated property 100, which is less than view filter 100") + .doesNotContain(new Entity.Builder() + .group(GROUP_BASIC_ENTITY) + .vertex(BASIC_VERTEX) + .property(PROPERTY_1, 100) + .build()) + .hasSize(1); + } + + private void addEntity(final String graphIdA, final Entity entity) throws OperationException { federatedStore.execute(new FederatedOperation.Builder() .op(new AddElements.Builder() diff --git a/store-implementation/federated-store/src/test/resources/schema/basicEntityValidateLess100Schema.json b/store-implementation/federated-store/src/test/resources/schema/basicEntityValidateLess100Schema.json new file mode 100644 index 00000000000..12ee02ab4f5 --- /dev/null +++ b/store-implementation/federated-store/src/test/resources/schema/basicEntityValidateLess100Schema.json @@ -0,0 +1,32 @@ +{ + "entities": { + "BasicEntity": { + "vertex": "vertex.string", + "properties": { + "property1": "simpleProperty" + } + } + }, + "types": { + "vertex.string": { + "class": "java.lang.String" + }, + "simpleProperty": { + "class": "java.lang.Integer", + "aggregateFunction": { + "class": "uk.gov.gchq.koryphe.impl.binaryoperator.Sum" + }, + "validateFunctions": [ + { + "class": "uk.gov.gchq.koryphe.impl.predicate.IsLessThan", + "value": { + "java.lang.Integer": 100 + } + } + ], + "serialiser": { + "class": "uk.gov.gchq.gaffer.serialisation.implementation.raw.CompactRawIntegerSerialiser" + } + } + } +} \ No newline at end of file From 5d4b3e92ba0bdfb96cb09e9d535b137c6005a5ec Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Fri, 3 Nov 2023 13:11:35 +0000 Subject: [PATCH 02/15] gh-3059 Updaed ApplyViewToElementsFunction to merge the Schema validation into view. --- .../util/ApplyViewToElementsFunction.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java index a6a9d6ac48a..6d9611fb11c 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java @@ -25,6 +25,7 @@ import uk.gov.gchq.gaffer.core.exception.GafferRuntimeException; import uk.gov.gchq.gaffer.data.element.Element; import uk.gov.gchq.gaffer.data.elementdefinition.view.View; +import uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; import uk.gov.gchq.gaffer.mapstore.MapStoreProperties; @@ -33,10 +34,15 @@ import uk.gov.gchq.gaffer.operation.impl.get.GetAllElements; import uk.gov.gchq.gaffer.store.Context; import uk.gov.gchq.gaffer.store.schema.Schema; +import uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition; +import uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition; +import uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition; import uk.gov.gchq.gaffer.user.User; +import uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate; import java.io.Closeable; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -77,6 +83,9 @@ public ApplyViewToElementsFunction(final Map context) throws Gaf } // Validate the supplied context before using validate(context); + + updateViewWithValidationFromSchema(context); + this.context = Collections.unmodifiableMap(context); } catch (final Exception e) { throw new GafferCheckedException("Unable to create TemporaryResultsGraph", e); @@ -84,6 +93,20 @@ public ApplyViewToElementsFunction(final Map context) throws Gaf } + private static void updateViewWithValidationFromSchema(final Map context) { + //Update View with + { + final View view = (View) context.get(VIEW); + final Schema schema = (Schema) context.get(SCHEMA); + final View.Builder updatedView = new View.Builder(view); + + updateEdgesViewFilterWithSchemaValidation(schema, view, updatedView); + updateEntitiesViewFilterWithSchemaValidation(schema, view, updatedView); + + context.put(VIEW, updatedView.build()); + } + } + @Override public ApplyViewToElementsFunction createFunctionWithContext(final HashMap context) throws GafferCheckedException { return new ApplyViewToElementsFunction(context); @@ -120,6 +143,58 @@ private static void validate(final Map context) { } } + private static void updateEntitiesViewFilterWithSchemaValidation(final Schema schema, final View view, final View.Builder updatedView) { + final Map elements = schema.getEntities(); + for (final Map.Entry schemaElement : elements.entrySet()) { + + final String elementKey = schemaElement.getKey(); + final SchemaElementDefinition schemaElementDef = schemaElement.getValue(); + if (schemaElementDef.hasValidation()) { + final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(schemaElementDef, view, elementKey); + + updatedView.entity(elementKey, updatedViewElementDef); + } + } + } + + private static void updateEdgesViewFilterWithSchemaValidation(final Schema schema, final View view, final View.Builder updatedView) { + final Map elements = schema.getEdges(); + for (final Map.Entry schemaElement : elements.entrySet()) { + + final String elementKey = schemaElement.getKey(); + final SchemaElementDefinition schemaElementDef = schemaElement.getValue(); + if (schemaElementDef.hasValidation()) { + final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(schemaElementDef, view, elementKey); + + updatedView.edge(elementKey, updatedViewElementDef); + } + } + } + + private static ViewElementDefinition getUpdatedViewElementDef(final SchemaElementDefinition schemaElementDef, final View view, final String elementKey) { + final ViewElementDefinition.Builder updatePreAggregationFiler; + final ArrayList> updatedFilterFunctions = new ArrayList<>(); + + //Add Schema Validation + updatedFilterFunctions.addAll(schemaElementDef.getValidator().getComponents()); + + if (view != null) { + final ViewElementDefinition viewElementDef = view.getElement(elementKey); + //Add View Validation + updatedFilterFunctions.addAll(viewElementDef.getPreAggregationFilter().getComponents()); + + //Init Builder with contents of the view. + updatePreAggregationFiler = new ViewElementDefinition.Builder(viewElementDef); + } else { + updatePreAggregationFiler = new ViewElementDefinition.Builder(); + } + + //override + updatePreAggregationFiler.preAggregationFilterFunctions(updatedFilterFunctions); + + return updatePreAggregationFiler.build(); + } + @Override @JsonIgnore public Set getRequiredContextValues() { From b4d5b9d7ab03d4dfb61808a76171be8b4a4dd6a4 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Fri, 3 Nov 2023 13:11:35 +0000 Subject: [PATCH 03/15] gh-3059 Updated ApplyViewToElementsFunction to merge the Schema validation into view POST Aggregation to work after a groupBy aggregation change. --- .../util/ApplyViewToElementsFunction.java | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java index a6a9d6ac48a..e852f2101d9 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java @@ -25,6 +25,7 @@ import uk.gov.gchq.gaffer.core.exception.GafferRuntimeException; import uk.gov.gchq.gaffer.data.element.Element; import uk.gov.gchq.gaffer.data.elementdefinition.view.View; +import uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; import uk.gov.gchq.gaffer.mapstore.MapStoreProperties; @@ -33,10 +34,15 @@ import uk.gov.gchq.gaffer.operation.impl.get.GetAllElements; import uk.gov.gchq.gaffer.store.Context; import uk.gov.gchq.gaffer.store.schema.Schema; +import uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition; +import uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition; +import uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition; import uk.gov.gchq.gaffer.user.User; +import uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate; import java.io.Closeable; import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -77,6 +83,9 @@ public ApplyViewToElementsFunction(final Map context) throws Gaf } // Validate the supplied context before using validate(context); + + updateViewWithValidationFromSchema(context); + this.context = Collections.unmodifiableMap(context); } catch (final Exception e) { throw new GafferCheckedException("Unable to create TemporaryResultsGraph", e); @@ -84,6 +93,20 @@ public ApplyViewToElementsFunction(final Map context) throws Gaf } + private static void updateViewWithValidationFromSchema(final Map context) { + //Update View with + { + final View view = (View) context.get(VIEW); + final Schema schema = (Schema) context.get(SCHEMA); + final View.Builder updatedView = new View.Builder(view); + + updateEdgesViewFilterWithSchemaValidation(schema, view, updatedView); + updateEntitiesViewFilterWithSchemaValidation(schema, view, updatedView); + + context.put(VIEW, updatedView.build()); + } + } + @Override public ApplyViewToElementsFunction createFunctionWithContext(final HashMap context) throws GafferCheckedException { return new ApplyViewToElementsFunction(context); @@ -120,6 +143,58 @@ private static void validate(final Map context) { } } + private static void updateEntitiesViewFilterWithSchemaValidation(final Schema schema, final View view, final View.Builder updatedView) { + final Map elements = schema.getEntities(); + for (final Map.Entry schemaElement : elements.entrySet()) { + + final String elementKey = schemaElement.getKey(); + final SchemaElementDefinition schemaElementDef = schemaElement.getValue(); + if (schemaElementDef.hasValidation()) { + final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(schemaElementDef, view, elementKey); + + updatedView.entity(elementKey, updatedViewElementDef); + } + } + } + + private static void updateEdgesViewFilterWithSchemaValidation(final Schema schema, final View view, final View.Builder updatedView) { + final Map elements = schema.getEdges(); + for (final Map.Entry schemaElement : elements.entrySet()) { + + final String elementKey = schemaElement.getKey(); + final SchemaElementDefinition schemaElementDef = schemaElement.getValue(); + if (schemaElementDef.hasValidation()) { + final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(schemaElementDef, view, elementKey); + + updatedView.edge(elementKey, updatedViewElementDef); + } + } + } + + private static ViewElementDefinition getUpdatedViewElementDef(final SchemaElementDefinition schemaElementDef, final View view, final String elementKey) { + final ViewElementDefinition.Builder updatePreAggregationFiler; + final ArrayList> updatedFilterFunctions = new ArrayList<>(); + + //Add Schema Validation + updatedFilterFunctions.addAll(schemaElementDef.getValidator().getComponents()); + + if (view != null) { + final ViewElementDefinition viewElementDef = view.getElement(elementKey); + //Add View Validation + updatedFilterFunctions.addAll(viewElementDef.getPostAggregationFilter().getComponents()); + + //Init Builder with contents of the view. + updatePreAggregationFiler = new ViewElementDefinition.Builder(viewElementDef); + } else { + updatePreAggregationFiler = new ViewElementDefinition.Builder(); + } + + //override + updatePreAggregationFiler.postAggregationFilterFunctions(updatedFilterFunctions); + + return updatePreAggregationFiler.build(); + } + @Override @JsonIgnore public Set getRequiredContextValues() { From a3f25972bc52b35a276c15d577fd12d9baccb207 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Fri, 3 Nov 2023 13:53:32 +0000 Subject: [PATCH 04/15] gh-3059 Updated ApplyViewToElementsFunction to merge the Schema validation should only be done for the TemporaryStore of type MapStore --- .../federatedstore/util/ApplyViewToElementsFunction.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java index e852f2101d9..37b4b427331 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java @@ -28,6 +28,7 @@ import uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; +import uk.gov.gchq.gaffer.mapstore.MapStore; import uk.gov.gchq.gaffer.mapstore.MapStoreProperties; import uk.gov.gchq.gaffer.operation.OperationException; import uk.gov.gchq.gaffer.operation.impl.add.AddElements; @@ -94,8 +95,9 @@ public ApplyViewToElementsFunction(final Map context) throws Gaf } private static void updateViewWithValidationFromSchema(final Map context) { - //Update View with - { + //Only do this for MapStore, not required for other stores. + if (MapStore.class.getName().equals(((Graph) context.get(TEMP_RESULTS_GRAPH)).getStoreProperties().getStoreClass())) { + //Update View with final View view = (View) context.get(VIEW); final Schema schema = (Schema) context.get(SCHEMA); final View.Builder updatedView = new View.Builder(view); From 11f406e329433478b7bd16a57cb8931fed3e7650 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Fri, 3 Nov 2023 15:09:42 +0000 Subject: [PATCH 05/15] gh-3059 Nullpointers and Test cache clearing --- .../federatedstore/util/ApplyViewToElementsFunction.java | 5 +++-- .../federatedstore/FederatedStoreViewAggregationTest.java | 5 ++++- .../handler/impl/FederatedOperationChainHandlerTest.java | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java index 37b4b427331..1ef5f42380e 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java @@ -183,8 +183,9 @@ private static ViewElementDefinition getUpdatedViewElementDef(final SchemaElemen if (view != null) { final ViewElementDefinition viewElementDef = view.getElement(elementKey); //Add View Validation - updatedFilterFunctions.addAll(viewElementDef.getPostAggregationFilter().getComponents()); - + if (viewElementDef != null && viewElementDef.hasPostAggregationFilters()) { + updatedFilterFunctions.addAll(viewElementDef.getPostAggregationFilter().getComponents()); + } //Init Builder with contents of the view. updatePreAggregationFiler = new ViewElementDefinition.Builder(viewElementDef); } else { diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java index 4be34d02117..4417609de3d 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Crown Copyright + * Copyright 2022-2023 Crown Copyright * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,6 +42,7 @@ import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.addGraphToAccumuloStore; import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.contextTestUser; import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.loadSchemaFromJson; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.resetForFederatedTests; public class FederatedStoreViewAggregationTest { @@ -50,6 +51,8 @@ public class FederatedStoreViewAggregationTest { @BeforeEach public void before() throws Exception { + resetForFederatedTests(); + federatedStore = new FederatedStore(); federatedStore.initialise(GRAPH_ID_TEST_FEDERATED_STORE, new Schema(), new FederatedStoreProperties()); diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java index c614dc903ac..f61a3669ca4 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2022 Crown Copyright + * Copyright 2016-2023 Crown Copyright * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.GRAPH_ID_ACCUMULO_WITH_EDGES; import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.GRAPH_ID_ACCUMULO_WITH_ENTITIES; import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.GRAPH_ID_TEST_FEDERATED_STORE; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.resetForFederatedTests; import static uk.gov.gchq.gaffer.federatedstore.util.FederatedStoreUtil.getDefaultMergeFunction; import static uk.gov.gchq.gaffer.federatedstore.util.FederatedStoreUtil.getFederatedOperation; @@ -91,8 +92,7 @@ public class FederatedOperationChainHandlerTest { @BeforeEach @AfterEach public void after() { - HashMapGraphLibrary.clear(); - CacheServiceLoader.shutdown(); + resetForFederatedTests(); } @SuppressWarnings({"unchecked", "rawtypes"}) From bffc015f7f11fd0f894832b62e8186478fe6d3b9 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:02:39 +0000 Subject: [PATCH 06/15] gh-3059 test fixes --- .../util/ApplyViewToElementsFunction.java | 30 ++++++++----------- .../FederatedOperationChainHandlerTest.java | 2 ++ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java index 1ef5f42380e..df01e66c215 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java @@ -150,12 +150,9 @@ private static void updateEntitiesViewFilterWithSchemaValidation(final Schema sc for (final Map.Entry schemaElement : elements.entrySet()) { final String elementKey = schemaElement.getKey(); - final SchemaElementDefinition schemaElementDef = schemaElement.getValue(); - if (schemaElementDef.hasValidation()) { - final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(schemaElementDef, view, elementKey); + final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(elementKey, schemaElement.getValue(), view); - updatedView.entity(elementKey, updatedViewElementDef); - } + updatedView.entity(elementKey, updatedViewElementDef); } } @@ -164,21 +161,20 @@ private static void updateEdgesViewFilterWithSchemaValidation(final Schema schem for (final Map.Entry schemaElement : elements.entrySet()) { final String elementKey = schemaElement.getKey(); - final SchemaElementDefinition schemaElementDef = schemaElement.getValue(); - if (schemaElementDef.hasValidation()) { - final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(schemaElementDef, view, elementKey); + final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(elementKey, schemaElement.getValue(), view); - updatedView.edge(elementKey, updatedViewElementDef); - } + updatedView.edge(elementKey, updatedViewElementDef); } } - private static ViewElementDefinition getUpdatedViewElementDef(final SchemaElementDefinition schemaElementDef, final View view, final String elementKey) { - final ViewElementDefinition.Builder updatePreAggregationFiler; + private static ViewElementDefinition getUpdatedViewElementDef(final String elementKey, final SchemaElementDefinition schemaElementDef, final View view) { + final ViewElementDefinition.Builder updatePreAggregationFilter; final ArrayList> updatedFilterFunctions = new ArrayList<>(); //Add Schema Validation - updatedFilterFunctions.addAll(schemaElementDef.getValidator().getComponents()); + if (schemaElementDef.hasValidation()) { + updatedFilterFunctions.addAll(schemaElementDef.getValidator().getComponents()); + } if (view != null) { final ViewElementDefinition viewElementDef = view.getElement(elementKey); @@ -187,15 +183,15 @@ private static ViewElementDefinition getUpdatedViewElementDef(final SchemaElemen updatedFilterFunctions.addAll(viewElementDef.getPostAggregationFilter().getComponents()); } //Init Builder with contents of the view. - updatePreAggregationFiler = new ViewElementDefinition.Builder(viewElementDef); + updatePreAggregationFilter = new ViewElementDefinition.Builder(viewElementDef); } else { - updatePreAggregationFiler = new ViewElementDefinition.Builder(); + updatePreAggregationFilter = new ViewElementDefinition.Builder(); } //override - updatePreAggregationFiler.postAggregationFilterFunctions(updatedFilterFunctions); + updatePreAggregationFilter.postAggregationFilterFunctions(updatedFilterFunctions); - return updatePreAggregationFiler.build(); + return updatePreAggregationFilter.build(); } @Override diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java index f61a3669ca4..c5c86659d18 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java @@ -159,6 +159,8 @@ public void shouldHandleChainWithNoOutput() throws OperationException { final Iterable result = (Iterable) store.execute(opChain, context); // Then + assertThat(result).isNullOrEmpty(); + final Iterable allElements = (Iterable) store.execute(new GetAllElements(), context); assertThat(allElements) From eb03f100ba68291dc56aed5b28caabd588d0459d Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:21:07 +0000 Subject: [PATCH 07/15] checkstyle --- .../handler/impl/FederatedOperationChainHandlerTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java index c5c86659d18..fa5f32c7d4b 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/impl/FederatedOperationChainHandlerTest.java @@ -20,7 +20,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import uk.gov.gchq.gaffer.cache.CacheServiceLoader; import uk.gov.gchq.gaffer.commonutil.StreamUtil; import uk.gov.gchq.gaffer.commonutil.TestGroups; import uk.gov.gchq.gaffer.data.element.Edge; @@ -40,7 +39,6 @@ import uk.gov.gchq.gaffer.store.Store; import uk.gov.gchq.gaffer.store.StoreProperties; import uk.gov.gchq.gaffer.store.TestTypes; -import uk.gov.gchq.gaffer.store.library.HashMapGraphLibrary; import uk.gov.gchq.gaffer.store.schema.Schema; import uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition; import uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition; From 33a5721263ed9c86471b5f1a61b8fcb918ef7c33 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:36:14 +0000 Subject: [PATCH 08/15] gh-3059 map improvements. --- .../util/ApplyViewToElementsFunction.java | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java index df01e66c215..71c51fd92bf 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java @@ -35,9 +35,7 @@ import uk.gov.gchq.gaffer.operation.impl.get.GetAllElements; import uk.gov.gchq.gaffer.store.Context; import uk.gov.gchq.gaffer.store.schema.Schema; -import uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition; import uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition; -import uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition; import uk.gov.gchq.gaffer.user.User; import uk.gov.gchq.koryphe.tuple.predicate.TupleAdaptedPredicate; @@ -101,9 +99,8 @@ private static void updateViewWithValidationFromSchema(final Map final View view = (View) context.get(VIEW); final Schema schema = (Schema) context.get(SCHEMA); final View.Builder updatedView = new View.Builder(view); - - updateEdgesViewFilterWithSchemaValidation(schema, view, updatedView); - updateEntitiesViewFilterWithSchemaValidation(schema, view, updatedView); + updatedView.addEdges(getUpdatedViewDefsFromSchemaDefs(view, schema.getEdges())); + updatedView.addEntities(getUpdatedViewDefsFromSchemaDefs(view, schema.getEntities())); context.put(VIEW, updatedView.build()); } @@ -145,29 +142,20 @@ private static void validate(final Map context) { } } - private static void updateEntitiesViewFilterWithSchemaValidation(final Schema schema, final View view, final View.Builder updatedView) { - final Map elements = schema.getEntities(); - for (final Map.Entry schemaElement : elements.entrySet()) { - - final String elementKey = schemaElement.getKey(); - final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(elementKey, schemaElement.getValue(), view); - - updatedView.entity(elementKey, updatedViewElementDef); - } - } + private static HashMap getUpdatedViewDefsFromSchemaDefs(final View view, final Map elements) { + final HashMap rtn = new HashMap<>(); - private static void updateEdgesViewFilterWithSchemaValidation(final Schema schema, final View view, final View.Builder updatedView) { - final Map elements = schema.getEdges(); for (final Map.Entry schemaElement : elements.entrySet()) { - final String elementKey = schemaElement.getKey(); - final ViewElementDefinition updatedViewElementDef = getUpdatedViewElementDef(elementKey, schemaElement.getValue(), view); + final String groupName = schemaElement.getKey(); + final ViewElementDefinition updatedViewElementDef = getUpdatedViewDefFromSchemaDef(groupName, schemaElement.getValue(), view); - updatedView.edge(elementKey, updatedViewElementDef); + rtn.put(groupName, updatedViewElementDef); } + return rtn; } - private static ViewElementDefinition getUpdatedViewElementDef(final String elementKey, final SchemaElementDefinition schemaElementDef, final View view) { + private static ViewElementDefinition getUpdatedViewDefFromSchemaDef(final String groupName, final SchemaElementDefinition schemaElementDef, final View view) { final ViewElementDefinition.Builder updatePreAggregationFilter; final ArrayList> updatedFilterFunctions = new ArrayList<>(); @@ -177,7 +165,7 @@ private static ViewElementDefinition getUpdatedViewElementDef(final String eleme } if (view != null) { - final ViewElementDefinition viewElementDef = view.getElement(elementKey); + final ViewElementDefinition viewElementDef = view.getElement(groupName); //Add View Validation if (viewElementDef != null && viewElementDef.hasPostAggregationFilters()) { updatedFilterFunctions.addAll(viewElementDef.getPostAggregationFilter().getComponents()); From 8e07f1891b2b8b64ecba65c8edfbd1f22235b410 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Mon, 6 Nov 2023 13:28:38 +0000 Subject: [PATCH 09/15] gh-3059 stream improvements. --- .../util/ApplyViewToElementsFunction.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java index 71c51fd92bf..4022e744892 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java @@ -41,6 +41,7 @@ import java.io.Closeable; import java.io.IOException; +import java.util.AbstractMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -49,6 +50,7 @@ import java.util.Map; import java.util.Random; import java.util.Set; +import java.util.stream.Stream; public class ApplyViewToElementsFunction implements ContextSpecificMergeFunction, Iterable> { private static final Logger LOGGER = LoggerFactory.getLogger(ApplyViewToElementsFunction.class); @@ -99,8 +101,12 @@ private static void updateViewWithValidationFromSchema(final Map final View view = (View) context.get(VIEW); final Schema schema = (Schema) context.get(SCHEMA); final View.Builder updatedView = new View.Builder(view); - updatedView.addEdges(getUpdatedViewDefsFromSchemaDefs(view, schema.getEdges())); - updatedView.addEntities(getUpdatedViewDefsFromSchemaDefs(view, schema.getEntities())); + + //getUpdatedDefs and add to new view. + getUpdatedViewDefsFromSchemaDefs(schema.getEdges(), view) + .forEach(e -> updatedView.edge(e.getKey(), e.getValue())); + getUpdatedViewDefsFromSchemaDefs(schema.getEntities(), view) + .forEach(e -> updatedView.entity(e.getKey(), e.getValue())); context.put(VIEW, updatedView.build()); } @@ -142,17 +148,9 @@ private static void validate(final Map context) { } } - private static HashMap getUpdatedViewDefsFromSchemaDefs(final View view, final Map elements) { - final HashMap rtn = new HashMap<>(); - - for (final Map.Entry schemaElement : elements.entrySet()) { - - final String groupName = schemaElement.getKey(); - final ViewElementDefinition updatedViewElementDef = getUpdatedViewDefFromSchemaDef(groupName, schemaElement.getValue(), view); - - rtn.put(groupName, updatedViewElementDef); - } - return rtn; + private static Stream> getUpdatedViewDefsFromSchemaDefs(final Map groupDefs, final View view) { + return groupDefs.entrySet().stream() + .map(e -> new AbstractMap.SimpleImmutableEntry<>(e.getKey(), getUpdatedViewDefFromSchemaDef(e.getKey(), e.getValue(), view))); } private static ViewElementDefinition getUpdatedViewDefFromSchemaDef(final String groupName, final SchemaElementDefinition schemaElementDef, final View view) { From abd495087e2987ddb05d75e78de4c44adde241c7 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Mon, 6 Nov 2023 15:10:31 +0000 Subject: [PATCH 10/15] gh-3059 rename. --- .../gchq/gaffer/federatedstore/FederatedStore.java | 6 +++--- ...Function.java => FederatedElementFunction.java} | 14 +++++++------- .../federatedstore/util/FederatedStoreUtil.java | 6 +++--- .../federatedstore/FederatedStoreSchemaTest.java | 12 ++++++------ .../handler/FederatedOperationHandlerTest.java | 4 ++-- ...Test.java => FederatedElementFunctionTest.java} | 12 ++++++------ .../src/test/resources/withConfigMergeMapping.json | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) rename store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/{ApplyViewToElementsFunction.java => FederatedElementFunction.java} (93%) rename store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/{ApplyViewToElementsFunctionTest.java => FederatedElementFunctionTest.java} (94%) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/FederatedStore.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/FederatedStore.java index 76a38bdde97..1851130eca9 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/FederatedStore.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/FederatedStore.java @@ -54,7 +54,7 @@ import uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedRemoveGraphAndDeleteAllDataHandler; import uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedRemoveGraphHandler; import uk.gov.gchq.gaffer.federatedstore.schema.FederatedViewValidator; -import uk.gov.gchq.gaffer.federatedstore.util.ApplyViewToElementsFunction; +import uk.gov.gchq.gaffer.federatedstore.util.FederatedElementFunction; import uk.gov.gchq.gaffer.federatedstore.util.MergeSchema; import uk.gov.gchq.gaffer.graph.GraphSerialisable; import uk.gov.gchq.gaffer.operation.Operation; @@ -156,8 +156,8 @@ public FederatedStore(@JsonProperty("customPropertiesAuths") final Set c this.storeConfiguredMergeFunctions = (null == storeConfiguredMergeFunctions) ? new HashMap<>() : new HashMap<>(storeConfiguredMergeFunctions); this.storeConfiguredMergeFunctions.putIfAbsent(GetTraits.class.getCanonicalName(), new CollectionIntersect<>()); - this.storeConfiguredMergeFunctions.putIfAbsent(GetAllElements.class.getCanonicalName(), new ApplyViewToElementsFunction()); - this.storeConfiguredMergeFunctions.putIfAbsent(GetElements.class.getCanonicalName(), new ApplyViewToElementsFunction()); + this.storeConfiguredMergeFunctions.putIfAbsent(GetAllElements.class.getCanonicalName(), new FederatedElementFunction()); + this.storeConfiguredMergeFunctions.putIfAbsent(GetElements.class.getCanonicalName(), new FederatedElementFunction()); this.storeConfiguredMergeFunctions.putIfAbsent(GetSchema.class.getCanonicalName(), new MergeSchema()); } diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java similarity index 93% rename from store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java rename to store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java index 4022e744892..e6eac541093 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java @@ -52,8 +52,8 @@ import java.util.Set; import java.util.stream.Stream; -public class ApplyViewToElementsFunction implements ContextSpecificMergeFunction, Iterable> { - private static final Logger LOGGER = LoggerFactory.getLogger(ApplyViewToElementsFunction.class); +public class FederatedElementFunction implements ContextSpecificMergeFunction, Iterable> { + private static final Logger LOGGER = LoggerFactory.getLogger(FederatedElementFunction.class); public static final String VIEW = "view"; public static final String SCHEMA = "schema"; public static final String USER = "user"; @@ -63,16 +63,16 @@ public class ApplyViewToElementsFunction implements ContextSpecificMergeFunction @JsonProperty("context") private Map context; - public ApplyViewToElementsFunction() { + public FederatedElementFunction() { } - public ApplyViewToElementsFunction(final Map context) throws GafferCheckedException { + public FederatedElementFunction(final Map context) throws GafferCheckedException { this(); try { // Check if results graph, hasn't already be supplied, otherwise make a default results graph. if (!context.containsKey(TEMP_RESULTS_GRAPH)) { final Graph resultsGraph = new Graph.Builder() - .config(new GraphConfig(String.format("%s%s%d", TEMP_RESULTS_GRAPH, ApplyViewToElementsFunction.class.getSimpleName(), RANDOM.nextInt(Integer.MAX_VALUE)))) + .config(new GraphConfig(String.format("%s%s%d", TEMP_RESULTS_GRAPH, FederatedElementFunction.class.getSimpleName(), RANDOM.nextInt(Integer.MAX_VALUE)))) .addSchema((Schema) context.get(SCHEMA)) //MapStore easy in memory Store. Large results size may not be suitable, a graph could be provided via Context. .addStoreProperties(new MapStoreProperties()) @@ -113,8 +113,8 @@ private static void updateViewWithValidationFromSchema(final Map } @Override - public ApplyViewToElementsFunction createFunctionWithContext(final HashMap context) throws GafferCheckedException { - return new ApplyViewToElementsFunction(context); + public FederatedElementFunction createFunctionWithContext(final HashMap context) throws GafferCheckedException { + return new FederatedElementFunction(context); } /** diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedStoreUtil.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedStoreUtil.java index 716daa0b8b1..6bb76c119f3 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedStoreUtil.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedStoreUtil.java @@ -66,9 +66,9 @@ import static java.util.Objects.isNull; import static java.util.Objects.nonNull; -import static uk.gov.gchq.gaffer.federatedstore.util.ApplyViewToElementsFunction.SCHEMA; -import static uk.gov.gchq.gaffer.federatedstore.util.ApplyViewToElementsFunction.USER; -import static uk.gov.gchq.gaffer.federatedstore.util.ApplyViewToElementsFunction.VIEW; +import static uk.gov.gchq.gaffer.federatedstore.util.FederatedElementFunction.SCHEMA; +import static uk.gov.gchq.gaffer.federatedstore.util.FederatedElementFunction.USER; +import static uk.gov.gchq.gaffer.federatedstore.util.FederatedElementFunction.VIEW; public final class FederatedStoreUtil { private static final Logger LOGGER = LoggerFactory.getLogger(FederatedStoreUtil.class); diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreSchemaTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreSchemaTest.java index 38957ba4c42..231e7cce42f 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreSchemaTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreSchemaTest.java @@ -221,7 +221,7 @@ public void shouldBeAbleToGetElementsWithOverlappingSchemas() throws OperationEx addEdgeBasicWith(DEST_2, 1, 2); // When - // No merge function specified - ApplyViewToElementsFunction is used + // No merge function specified - FederatedElementFunction is used final Iterable results = federatedStore.execute(new GetElements.Builder() .input(new EntitySeed(SOURCE_BASIC)) .view(new View.Builder() @@ -432,7 +432,7 @@ public void shouldValidateCorrectlyWithOverlappingSchemas() throws OperationExce // When addEdgeBasicWith(DEST_2, 1, 2); - // No merge function specified - ApplyViewToElementsFunction is used + // No merge function specified - FederatedElementFunction is used // An exception is raised because the aggregated results are missing a validated property assertThatExceptionOfType(OperationException.class) .isThrownBy(() -> { @@ -521,7 +521,7 @@ public void shouldBeAbleToIngestAggregateWithOverlappingSchemas() throws Operati .build(), testContext); // When - // No merge function specified - ApplyViewToElementsFunction is used + // No merge function specified - FederatedElementFunction is used final Iterable results = federatedStore.execute(new GetElements.Builder() .input(new EntitySeed(SOURCE_BASIC)) .view(new View.Builder() @@ -607,7 +607,7 @@ public void shouldBeAbleToIngestAggregateMissingPropertyWithOverlappingSchemas() addEdgeBasicWith(DEST_BASIC, 1); // When - // No merge function specified - ApplyViewToElementsFunction is used + // No merge function specified - FederatedElementFunction is used final Iterable elements = federatedStore.execute(new GetElements.Builder() .input(new EntitySeed(SOURCE_BASIC)) .view(new View.Builder() @@ -711,7 +711,7 @@ public void shouldBeAbleToViewPropertyWithOverlappingSchemas() throws OperationE // When - // No merge function specified - ApplyViewToElementsFunction is used + // No merge function specified - FederatedElementFunction is used final Iterable results = federatedStore.execute(new GetElements.Builder() .input(new EntitySeed(SOURCE_BASIC)) .view(new View.Builder() @@ -877,7 +877,7 @@ public void shouldBeAbleToQueryAggregatePropertyWithOverlappingSchemas() throws // When - // No merge function specified - ApplyViewToElementsFunction is used + // No merge function specified - FederatedElementFunction is used final Iterable results = federatedStore.execute(new GetElements.Builder() .input(new EntitySeed(SOURCE_BASIC)) .view(new View.Builder() diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/FederatedOperationHandlerTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/FederatedOperationHandlerTest.java index 9a02e6d9718..7e69434874b 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/FederatedOperationHandlerTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/FederatedOperationHandlerTest.java @@ -36,7 +36,7 @@ import uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperation; import uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds; import uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedOperationHandler; -import uk.gov.gchq.gaffer.federatedstore.util.ApplyViewToElementsFunction; +import uk.gov.gchq.gaffer.federatedstore.util.FederatedElementFunction; import uk.gov.gchq.gaffer.federatedstore.util.ConcatenateMergeFunction; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; @@ -180,7 +180,7 @@ public final void shouldGetDefaultedMergeForOperation() throws Exception { assertThat(getElementsMerge) .isNotSameAs(traitsMerge) .isNotSameAs(graphsIdsMerge) - .isInstanceOf(ApplyViewToElementsFunction.class); + .isInstanceOf(FederatedElementFunction.class); } @Test diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunctionTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunctionTest.java similarity index 94% rename from store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunctionTest.java rename to store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunctionTest.java index 642e84667fa..9b082a6ee32 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/ApplyViewToElementsFunctionTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunctionTest.java @@ -54,7 +54,7 @@ import static uk.gov.gchq.gaffer.user.StoreUser.blankUser; import static uk.gov.gchq.gaffer.user.StoreUser.testUser; -class ApplyViewToElementsFunctionTest { +class FederatedElementFunctionTest { public static final Schema SCHEMA = loadSchemaFromJson(SCHEMA_EDGE_BASIC_JSON); public static final AccumuloProperties ACCUMULO_PROPERTIES = loadAccumuloStoreProperties(ACCUMULO_STORE_SINGLE_USE_PROPERTIES); @@ -89,7 +89,7 @@ public void shouldAggregateEdgesFromMultipleRetrievers() throws Exception { final AccumuloStore accumuloStore = getTestStore("shouldAggregateEdgesFromMultipleRetrievers"); addEdgeBasic(accumuloStore); AccumuloAllElementsRetriever[] retrievers = getRetrievers(accumuloStore); - final ApplyViewToElementsFunction function = new ApplyViewToElementsFunction().createFunctionWithContext( + final FederatedElementFunction function = new FederatedElementFunction().createFunctionWithContext( makeContext( new View.Builder().edge(GROUP_BASIC_EDGE).build(), SCHEMA.clone())); @@ -122,7 +122,7 @@ public void shouldApplyViewToAggregatedEdgesFromMultipleRetrievers() throws Exce final AccumuloStore accumuloStore = getTestStore("shouldApplyViewToAggregatedEdgesFromMultipleRetrievers"); addEdgeBasic(accumuloStore); AccumuloAllElementsRetriever[] retrievers = getRetrievers(accumuloStore); - final ApplyViewToElementsFunction function = new ApplyViewToElementsFunction().createFunctionWithContext( + final FederatedElementFunction function = new FederatedElementFunction().createFunctionWithContext( makeContext( //Update View to filter OUT greater than 2. new View.Builder().edge(GROUP_BASIC_EDGE, @@ -168,9 +168,9 @@ private static AccumuloStore getTestStore(final String instanceName) throws Stor private static HashMap makeContext(final View view, final Schema schema) { final HashMap map = new HashMap<>(); - map.put(ApplyViewToElementsFunction.VIEW, view); - map.put(ApplyViewToElementsFunction.SCHEMA, schema); - map.put(ApplyViewToElementsFunction.USER, testUser()); + map.put(FederatedElementFunction.VIEW, view); + map.put(FederatedElementFunction.SCHEMA, schema); + map.put(FederatedElementFunction.USER, testUser()); return map; } } diff --git a/store-implementation/federated-store/src/test/resources/withConfigMergeMapping.json b/store-implementation/federated-store/src/test/resources/withConfigMergeMapping.json index 4b4f1e4e5f9..c0e3f656244 100644 --- a/store-implementation/federated-store/src/test/resources/withConfigMergeMapping.json +++ b/store-implementation/federated-store/src/test/resources/withConfigMergeMapping.json @@ -6,7 +6,7 @@ "class" : "uk.gov.gchq.gaffer.federatedstore.util.ConcatenateMergeFunction" }, "uk.gov.gchq.gaffer.operation.impl.get.GetAllElements" : { - "class" : "uk.gov.gchq.gaffer.federatedstore.util.ApplyViewToElementsFunction" + "class" : "uk.gov.gchq.gaffer.federatedstore.util.FederatedElementFunction" } } } \ No newline at end of file From 7906716fe1b617ab582f1d1706740097470cedc5 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Mon, 6 Nov 2023 15:31:35 +0000 Subject: [PATCH 11/15] gh-3059 Graph or GraphSerialisable. --- .../util/FederatedElementFunction.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java index e6eac541093..989610009f9 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java @@ -28,6 +28,7 @@ import uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; +import uk.gov.gchq.gaffer.graph.GraphSerialisable; import uk.gov.gchq.gaffer.mapstore.MapStore; import uk.gov.gchq.gaffer.mapstore.MapStoreProperties; import uk.gov.gchq.gaffer.operation.OperationException; @@ -52,6 +53,12 @@ import java.util.Set; import java.util.stream.Stream; +/** + * This class is used to address some of the issues with having the elements distributes amongst multiple graphs. + * Such as the re-application of View filter or Schema Validation after the local aggregation of results from multiple graphs. + * By default, a local in memory MapStore is used for local aggregation, + * but a Graph or {@link GraphSerialisable} of any kind could be supplied via the {@link #context} with the key {@link #TEMP_RESULTS_GRAPH}. + */ public class FederatedElementFunction implements ContextSpecificMergeFunction, Iterable> { private static final Logger LOGGER = LoggerFactory.getLogger(FederatedElementFunction.class); public static final String VIEW = "view"; @@ -96,7 +103,7 @@ public FederatedElementFunction(final Map context) throws Gaffer private static void updateViewWithValidationFromSchema(final Map context) { //Only do this for MapStore, not required for other stores. - if (MapStore.class.getName().equals(((Graph) context.get(TEMP_RESULTS_GRAPH)).getStoreProperties().getStoreClass())) { + if (MapStore.class.getName().equals(getGraph(context).getStoreProperties().getStoreClass())) { //Update View with final View view = (View) context.get(VIEW); final Schema schema = (Schema) context.get(SCHEMA); @@ -139,7 +146,8 @@ private static void validate(final Map context) { if (!context.containsKey(TEMP_RESULTS_GRAPH)) { throw new IllegalStateException("Error: context invalid, did not contain a Temporary Results Graph."); - } else if (!(context.get(TEMP_RESULTS_GRAPH) instanceof Graph)) { + } else if (!(context.get(TEMP_RESULTS_GRAPH) instanceof Graph) + || !(context.get(TEMP_RESULTS_GRAPH) instanceof GraphSerialisable)) { throw new IllegalArgumentException(String.format("Error: context invalid, value for %s was not a Graph, found: %s", TEMP_RESULTS_GRAPH, context.get(TEMP_RESULTS_GRAPH))); } @@ -197,7 +205,7 @@ public Iterable apply(final Object update, final Iterable state) } } - final Graph resultsGraph = (Graph) context.get(TEMP_RESULTS_GRAPH); + final Graph resultsGraph = getGraph(context); final Context userContext = new Context((User) context.get(USER)); try { // The update object might be a lazy AccumuloElementRetriever and might be MASSIVE. @@ -212,4 +220,12 @@ public Iterable apply(final Object update, final Iterable state) throw new GafferRuntimeException("Error getting all elements from temporary graph, due to:" + e.getMessage(), e); } } + + private static Graph getGraph(final Map context) { + final Object g = context.get(TEMP_RESULTS_GRAPH); + final Graph resultsGraph = g instanceof GraphSerialisable + ? ((GraphSerialisable) g).getGraph() + : (Graph) g; + return resultsGraph; + } } From cd313313021b5524f04820d6d719e7969809393f Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:23:15 +0000 Subject: [PATCH 12/15] gh-3059 test move. --- ...nctionAggregationSchemaValidationTest.java | 145 ++++++++++++++++++ ...entFunctionAggregationViewFilterTest.java} | 41 +---- 2 files changed, 149 insertions(+), 37 deletions(-) create mode 100644 store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedElementFunctionAggregationSchemaValidationTest.java rename store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/{FederatedStoreViewAggregationTest.java => FederatedElementFunctionAggregationViewFilterTest.java} (79%) diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedElementFunctionAggregationSchemaValidationTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedElementFunctionAggregationSchemaValidationTest.java new file mode 100644 index 00000000000..a897bfc8a56 --- /dev/null +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedElementFunctionAggregationSchemaValidationTest.java @@ -0,0 +1,145 @@ +/* + * Copyright 2023 Crown Copyright + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package uk.gov.gchq.gaffer.federatedstore; + + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import uk.gov.gchq.gaffer.data.element.Entity; +import uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperation; +import uk.gov.gchq.gaffer.operation.OperationException; +import uk.gov.gchq.gaffer.operation.impl.add.AddElements; +import uk.gov.gchq.gaffer.operation.impl.get.GetAllElements; +import uk.gov.gchq.gaffer.store.schema.Schema; + +import static org.assertj.core.api.Assertions.assertThat; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.BASIC_VERTEX; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.GRAPH_ID_A; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.GRAPH_ID_B; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.GRAPH_ID_C; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.GRAPH_ID_TEST_FEDERATED_STORE; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.GROUP_BASIC_ENTITY; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.PROPERTY_1; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.addGraphToAccumuloStore; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.contextTestUser; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.loadSchemaFromJson; +import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.resetForFederatedTests; + +public class FederatedElementFunctionAggregationSchemaValidationTest { + + private FederatedStore federatedStore; + private Entity entity1, entity99, entityOther; + + @BeforeEach + public void before() throws Exception { + resetForFederatedTests(); + + federatedStore = new FederatedStore(); + federatedStore.initialise(GRAPH_ID_TEST_FEDERATED_STORE, new Schema(), new FederatedStoreProperties()); + + entity1 = new Entity.Builder() + .group(GROUP_BASIC_ENTITY) + .vertex(BASIC_VERTEX) + .property(PROPERTY_1, 1) + .build(); + + entity99 = new Entity.Builder() + .group(GROUP_BASIC_ENTITY) + .vertex(BASIC_VERTEX) + .property(PROPERTY_1, 99) + .build(); + + entityOther = new Entity.Builder() + .group(GROUP_BASIC_ENTITY) + .vertex("basicVertexOther") + .property(PROPERTY_1, 99) + .build(); + } + + @Test + public void shouldOnlyReturn1EntitySmallerThanSchemaValidationLimit() throws Exception { + + //given + addGraphToAccumuloStore(federatedStore, GRAPH_ID_A, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); + addGraphToAccumuloStore(federatedStore, GRAPH_ID_B, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); + + addEntity(GRAPH_ID_A, entity1); + addEntity(GRAPH_ID_B, entity99); + addEntity(GRAPH_ID_B, entityOther); + + //when + final Iterable elementsWithPropertyLessThan100 = federatedStore.execute(new GetAllElements(), contextTestUser()); + + //then + assertThat(elementsWithPropertyLessThan100) + .isNotNull() + .withFailMessage("should not return entity \"basicVertex\" with un-aggregated property 1 or 99") + .doesNotContain(entity1, entity99) + .withFailMessage("should not return entity \"basicVertex\" with an aggregated property 100, which is less than view filter 100") + .doesNotContain(new Entity.Builder() + .group(GROUP_BASIC_ENTITY) + .vertex(BASIC_VERTEX) + .property(PROPERTY_1, 100) + .build()) + .withFailMessage("should return entity \"basicVertexOther\" with property 99, which is less than view filter 100") + .containsExactly(entityOther); + } + + @Test + public void shouldNotReturnAnyElementsAfterInValidationInTemporaryMap() throws Exception { + + //given + addGraphToAccumuloStore(federatedStore, GRAPH_ID_A, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); + addGraphToAccumuloStore(federatedStore, GRAPH_ID_B, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); + addGraphToAccumuloStore(federatedStore, GRAPH_ID_C, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); + + addEntity(GRAPH_ID_A, entity99); // 99 is valid + addEntity(GRAPH_ID_B, entity1); // 100 is not valid. + addEntity(GRAPH_ID_C, entity1); // correct behavior 100 & 1 is invalid. returning 1 would be incorrect if 100 had been deleted. + addEntity(GRAPH_ID_B, entityOther); + + //when + final Iterable elementsWithPropertyLessThan100 = federatedStore.execute(new GetAllElements(), contextTestUser()); + + //then + assertThat(elementsWithPropertyLessThan100) + .isNotNull() + .withFailMessage("should not return entity \"basicVertex\" with un-aggregated property 1 or 99") + .doesNotContain(entity1, entity99) + .withFailMessage("should not return entity \"basicVertex\" with an aggregated property 100, which is less than view filter 100") + .doesNotContain(new Entity.Builder() + .group(GROUP_BASIC_ENTITY) + .vertex(BASIC_VERTEX) + .property(PROPERTY_1, 100) + .build()) + .withFailMessage("should return entity \"basicVertexOther\" with property 99, which is less than view filter 100") + .containsExactly(entityOther) + .hasSize(1); + } + + + private void addEntity(final String graphIdA, final Entity entity) throws OperationException { + federatedStore.execute(new FederatedOperation.Builder() + .op(new AddElements.Builder() + .input(entity) + .build()) + .graphIdsCSV(graphIdA) + .build(), contextTestUser()); + } + +} diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedElementFunctionAggregationViewFilterTest.java similarity index 79% rename from store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java rename to store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedElementFunctionAggregationViewFilterTest.java index 4417609de3d..8520958d8d4 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedStoreViewAggregationTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/FederatedElementFunctionAggregationViewFilterTest.java @@ -44,7 +44,7 @@ import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.loadSchemaFromJson; import static uk.gov.gchq.gaffer.federatedstore.FederatedStoreTestUtil.resetForFederatedTests; -public class FederatedStoreViewAggregationTest { +public class FederatedElementFunctionAggregationViewFilterTest { private FederatedStore federatedStore; private Entity entity1, entity99, entityOther; @@ -113,17 +113,14 @@ public void shouldOnlyReturn1EntitySmallerThanViewFilter() throws Exception { //then assertThat(elementsWithPropertyLessThan2) .isNotNull() - .withFailMessage("should return entity with property 1 which is less than view filter 2") - .contains(entity1) .withFailMessage("should not return entity with property 99 which is more than view filter 2") .doesNotContain(entity99) .withFailMessage("should contain only 1") - .hasSize(1); + .withFailMessage("should return entity with property 1 which is less than view filter 2") + .containsExactly(entity1); assertThat(elementsWithPropertyLessThan100) .isNotNull() - .withFailMessage("should return entity \"basicVertexOther\" with property 99, which is less than view filter 100") - .contains(entityOther) .withFailMessage("should not return entity \"basicVertex\" with un-aggregated property 1 or 99") .doesNotContain(entity1, entity99) .withFailMessage("should not return entity \"basicVertex\" with an aggregated property 100, which is less than view filter 100") @@ -132,40 +129,10 @@ public void shouldOnlyReturn1EntitySmallerThanViewFilter() throws Exception { .vertex(BASIC_VERTEX) .property(PROPERTY_1, 100) .build()) - .hasSize(1); - } - - @Test - public void shouldOnlyReturn1EntitySmallerThanSchemaValidationLimit() throws Exception { - - //given - addGraphToAccumuloStore(federatedStore, GRAPH_ID_A, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); - addGraphToAccumuloStore(federatedStore, GRAPH_ID_B, true, loadSchemaFromJson("/schema/basicEntityValidateLess100Schema.json")); - - addEntity(GRAPH_ID_A, entity1); - addEntity(GRAPH_ID_B, entity99); - addEntity(GRAPH_ID_B, entityOther); - - //when - final Iterable elementsWithPropertyLessThan100 = federatedStore.execute(new GetAllElements(), contextTestUser()); - - //then - assertThat(elementsWithPropertyLessThan100) - .isNotNull() .withFailMessage("should return entity \"basicVertexOther\" with property 99, which is less than view filter 100") - .contains(entityOther) - .withFailMessage("should not return entity \"basicVertex\" with un-aggregated property 1 or 99") - .doesNotContain(entity1, entity99) - .withFailMessage("should not return entity \"basicVertex\" with an aggregated property 100, which is less than view filter 100") - .doesNotContain(new Entity.Builder() - .group(GROUP_BASIC_ENTITY) - .vertex(BASIC_VERTEX) - .property(PROPERTY_1, 100) - .build()) - .hasSize(1); + .containsExactly(entityOther); } - private void addEntity(final String graphIdA, final Entity entity) throws OperationException { federatedStore.execute(new FederatedOperation.Builder() .op(new AddElements.Builder() From 48942f77abfcc5dac6c8750b226107124e0af3ac Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Mon, 6 Nov 2023 19:44:24 +0000 Subject: [PATCH 13/15] gh-3059 tidy up --- .../operation/handler/FederatedOperationHandlerTest.java | 4 ++-- .../federatedstore/util/FederatedElementFunctionTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/FederatedOperationHandlerTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/FederatedOperationHandlerTest.java index 7e69434874b..b3aa45948b0 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/FederatedOperationHandlerTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/operation/handler/FederatedOperationHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 Crown Copyright + * Copyright 2017-2023 Crown Copyright * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +36,8 @@ import uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperation; import uk.gov.gchq.gaffer.federatedstore.operation.GetAllGraphIds; import uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedOperationHandler; -import uk.gov.gchq.gaffer.federatedstore.util.FederatedElementFunction; import uk.gov.gchq.gaffer.federatedstore.util.ConcatenateMergeFunction; +import uk.gov.gchq.gaffer.federatedstore.util.FederatedElementFunction; import uk.gov.gchq.gaffer.graph.Graph; import uk.gov.gchq.gaffer.graph.GraphConfig; import uk.gov.gchq.gaffer.graph.GraphSerialisable; diff --git a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunctionTest.java b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunctionTest.java index 9b082a6ee32..59ff4ef0d61 100644 --- a/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunctionTest.java +++ b/store-implementation/federated-store/src/test/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunctionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Crown Copyright + * Copyright 2022-2023 Crown Copyright * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 5dba0fe2ff5677c267dc224407506e6f9e557291 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Tue, 7 Nov 2023 10:44:32 +0000 Subject: [PATCH 14/15] gh-3059 logic typo --- .../gaffer/federatedstore/util/FederatedElementFunction.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java index 989610009f9..f8d27c532db 100644 --- a/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java +++ b/store-implementation/federated-store/src/main/java/uk/gov/gchq/gaffer/federatedstore/util/FederatedElementFunction.java @@ -147,7 +147,7 @@ private static void validate(final Map context) { if (!context.containsKey(TEMP_RESULTS_GRAPH)) { throw new IllegalStateException("Error: context invalid, did not contain a Temporary Results Graph."); } else if (!(context.get(TEMP_RESULTS_GRAPH) instanceof Graph) - || !(context.get(TEMP_RESULTS_GRAPH) instanceof GraphSerialisable)) { + && !(context.get(TEMP_RESULTS_GRAPH) instanceof GraphSerialisable)) { throw new IllegalArgumentException(String.format("Error: context invalid, value for %s was not a Graph, found: %s", TEMP_RESULTS_GRAPH, context.get(TEMP_RESULTS_GRAPH))); } From bfae736f0fe22e16463752683e9c000cf438e650 Mon Sep 17 00:00:00 2001 From: GCHQDev404 <45399082+GCHQDev404@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:49:15 +0000 Subject: [PATCH 15/15] gh-3065 pom java version improvement --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 444e0bf4635..7e404224d24 100644 --- a/pom.xml +++ b/pom.xml @@ -48,6 +48,8 @@ 1.8 + 1.8 + 1.8 5.9.3