From d830777e1398ba25e326dd645efa2fe82ca7b0d8 Mon Sep 17 00:00:00 2001 From: p013570 Date: Thu, 2 Nov 2017 11:47:13 +0000 Subject: [PATCH 1/3] gh-1491 - graph now updates op views before hooks --- .../java/uk/gov/gchq/gaffer/graph/Graph.java | 1 + .../uk/gov/gchq/gaffer/graph/GraphTest.java | 34 ++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/core/graph/src/main/java/uk/gov/gchq/gaffer/graph/Graph.java b/core/graph/src/main/java/uk/gov/gchq/gaffer/graph/Graph.java index b985c840915..6f58d5afaf8 100644 --- a/core/graph/src/main/java/uk/gov/gchq/gaffer/graph/Graph.java +++ b/core/graph/src/main/java/uk/gov/gchq/gaffer/graph/Graph.java @@ -203,6 +203,7 @@ private O _execute(final StoreExecuter storeExecuter, final OperationChai final OperationChain clonedOpChain = operationChain.shallowClone(); O result = null; try { + updateOperationChainView(clonedOpChain); for (final GraphHook graphHook : config.getHooks()) { graphHook.preExecute(clonedOpChain, context); } diff --git a/core/graph/src/test/java/uk/gov/gchq/gaffer/graph/GraphTest.java b/core/graph/src/test/java/uk/gov/gchq/gaffer/graph/GraphTest.java index e323117adb3..7ac724196ce 100644 --- a/core/graph/src/test/java/uk/gov/gchq/gaffer/graph/GraphTest.java +++ b/core/graph/src/test/java/uk/gov/gchq/gaffer/graph/GraphTest.java @@ -55,6 +55,7 @@ import uk.gov.gchq.gaffer.operation.Operation; import uk.gov.gchq.gaffer.operation.OperationChain; import uk.gov.gchq.gaffer.operation.OperationException; +import uk.gov.gchq.gaffer.operation.graph.OperationView; import uk.gov.gchq.gaffer.operation.impl.Limit; import uk.gov.gchq.gaffer.operation.impl.add.AddElements; import uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds; @@ -995,10 +996,15 @@ public void shouldSetGraphViewOnOperationAndDelegateDoOperationToStore() final Store store = mock(Store.class); given(store.getSchema()).willReturn(new Schema()); given(store.getProperties()).willReturn(new StoreProperties()); - final View view = mock(View.class); + final View view = new View.Builder() + .entity(TestGroups.ENTITY) + .edge(TestGroups.EDGE) + .build(); + final GraphHook hook = new ViewCheckerGraphHook(); final Graph graph = new Graph.Builder() .config(new GraphConfig.Builder() .graphId(GRAPH_ID) + .addHook(hook) .view(view) .build()) .store(store) @@ -1008,8 +1014,7 @@ public void shouldSetGraphViewOnOperationAndDelegateDoOperationToStore() given(context.getUser()).willReturn(user); given(store.createContext(user)).willReturn(context); final Integer expectedResult = 5; - final GetElements operation = mock(GetElements.class); - given(operation.getView()).willReturn(null); + final GetElements operation = new GetElements(); final OperationChain opChain = mock(OperationChain.class); final OperationChain clonedOpChain = mock(OperationChain.class); @@ -1023,7 +1028,7 @@ public void shouldSetGraphViewOnOperationAndDelegateDoOperationToStore() // Then assertEquals(expectedResult, result); verify(store).execute(clonedOpChain, context); - verify(operation).setView(view); + JsonAssert.assertEquals(view.toJson(false), operation.getView().toJson(false)); } @Test @@ -1978,4 +1983,25 @@ public InputStream getInput() throws IOException { return StreamUtil.openStream(getClass(), "/schema/" + schemaFile); } } + + private static class ViewCheckerGraphHook implements GraphHook { + @Override + public void preExecute(final OperationChain opChain, final Context context) { + for (Operation operation : opChain.getOperations()) { + if (operation instanceof OperationView && null == ((OperationView) operation).getView()) { + throw new IllegalArgumentException("View should not be null"); + } + } + } + + @Override + public T postExecute(final T result, final OperationChain opChain, final Context context) { + return result; + } + + @Override + public T onFailure(final T result, final OperationChain opChain, final Context context, final Exception e) { + return result; + } + } } \ No newline at end of file From d10a2441c30c11e586143b296c64d2ee931b4f08 Mon Sep 17 00:00:00 2001 From: m55624 Date: Fri, 3 Nov 2017 11:35:42 +0000 Subject: [PATCH 2/3] gh-1422 - removed second duplicate title --- .../gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java | 2 +- .../gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java index f0dd1342e93..58aa281f603 100644 --- a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java +++ b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java @@ -34,7 +34,7 @@ info = @Info( description = "The Gaffer REST service.", version = "v1", - title = "Gaffer REST API", + title = "", contact = @Contact( name = "Gaffer Developers", url = "https://github.com/gchq/Gaffer" diff --git a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java index c3c373c212f..0b99660fb83 100644 --- a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java +++ b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java @@ -34,7 +34,7 @@ info = @Info( description = "The Gaffer REST service.", version = "v2", - title = "Gaffer REST API", + title = "", contact = @Contact( name = "Gaffer Developers", url = "https://github.com/gchq/Gaffer" From 0e03ee2e9a3628812ddb080ab141122bca5429aa Mon Sep 17 00:00:00 2001 From: p013570 Date: Mon, 6 Nov 2017 11:50:26 +0000 Subject: [PATCH 3/3] gh-1422 - all properties are now fetched in one go --- example/basic/basic-rest/pom.xml | 9 ++++ example/federated-demo/pom.xml | 9 ++++ .../gchq/gaffer/rest/ServiceConstants.java | 3 ++ .../service/v1/SwaggerDefinitionConfig.java | 6 +-- .../service/v2/SwaggerDefinitionConfigV2.java | 6 +-- rest-api/core-rest/src/main/webapp/index.html | 6 +-- .../core-rest/src/main/webapp/lib/gaffer.js | 46 +++++++++++++------ 7 files changed, 62 insertions(+), 23 deletions(-) diff --git a/example/basic/basic-rest/pom.xml b/example/basic/basic-rest/pom.xml index 11d07c52b8f..0ae9f31b226 100644 --- a/example/basic/basic-rest/pom.xml +++ b/example/basic/basic-rest/pom.xml @@ -112,6 +112,15 @@ /${standalone-path} ${standalone-port} + + gaffer.properties.app.description,gaffer.properties.app.title + + + Basic Gaffer Example + + + Example using a very basic schema + ${standalone-path} diff --git a/example/federated-demo/pom.xml b/example/federated-demo/pom.xml index 22d99add3dc..8463ba615c6 100644 --- a/example/federated-demo/pom.xml +++ b/example/federated-demo/pom.xml @@ -127,6 +127,15 @@ /${standalone-path} ${standalone-port} + + gaffer.properties.app.description,gaffer.properties.app.title + + + Federated Gaffer Example + + + Example of a Gaffer Federated Store + ${standalone-path} diff --git a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/ServiceConstants.java b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/ServiceConstants.java index 2d5cd1d2414..8682a943978 100644 --- a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/ServiceConstants.java +++ b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/ServiceConstants.java @@ -42,6 +42,9 @@ public final class ServiceConstants { public static final String JOB_SERVICE_UNAVAILABLE = "The job service is not available"; // REST - Other + public static final String DESCRIPTION_DEFAULT = "The Gaffer REST service."; + public static final String CONTACT_DEFAULT = "Gaffer Developers"; + public static final String CONTACT_URL_DEFAULT = "https://github.com/gchq/Gaffer"; public static final String GAFFER_DOCUMENTATION_URL = "https://gchq.github.io/gaffer-doc/"; static { diff --git a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java index 58aa281f603..2d59b00f869 100644 --- a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java +++ b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v1/SwaggerDefinitionConfig.java @@ -32,12 +32,12 @@ */ @SwaggerDefinition( info = @Info( - description = "The Gaffer REST service.", + description = ServiceConstants.DESCRIPTION_DEFAULT, version = "v1", title = "", contact = @Contact( - name = "Gaffer Developers", - url = "https://github.com/gchq/Gaffer" + name = ServiceConstants.CONTACT_DEFAULT, + url = ServiceConstants.CONTACT_URL_DEFAULT ), license = @License( name = "Apache 2.0", diff --git a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java index 0b99660fb83..57c349dafc6 100644 --- a/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java +++ b/rest-api/core-rest/src/main/java/uk/gov/gchq/gaffer/rest/service/v2/SwaggerDefinitionConfigV2.java @@ -32,12 +32,12 @@ */ @SwaggerDefinition( info = @Info( - description = "The Gaffer REST service.", + description = ServiceConstants.DESCRIPTION_DEFAULT, version = "v2", title = "", contact = @Contact( - name = "Gaffer Developers", - url = "https://github.com/gchq/Gaffer" + name = ServiceConstants.CONTACT_DEFAULT, + url = ServiceConstants.CONTACT_URL_DEFAULT ), license = @License( name = "Apache 2.0", diff --git a/rest-api/core-rest/src/main/webapp/index.html b/rest-api/core-rest/src/main/webapp/index.html index c0db103c7b5..8a940dceb14 100644 --- a/rest-api/core-rest/src/main/webapp/index.html +++ b/rest-api/core-rest/src/main/webapp/index.html @@ -1,9 +1,9 @@ - + - Gaffer REST API + Gaffer REST @@ -40,7 +40,7 @@