From 7113fb36d2af55d8c27290adfcebbe5b5aee32b7 Mon Sep 17 00:00:00 2001 From: p013570 Date: Mon, 18 Nov 2019 16:59:14 +0000 Subject: [PATCH 01/43] Added ReduceRelatedElementsFunction --- .../function/ReduceRelatedElements.java | 255 ++++++++++++++++++ .../function/ReduceRelatedElementsTest.java | 186 +++++++++++++ 2 files changed, 441 insertions(+) create mode 100644 core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java create mode 100644 core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java new file mode 100644 index 00000000000..f7bfe35fdf8 --- /dev/null +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java @@ -0,0 +1,255 @@ +/* + * Copyright 2017-2019 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.data.element.function; + + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import org.apache.commons.lang3.StringUtils; + +import uk.gov.gchq.gaffer.data.element.Edge; +import uk.gov.gchq.gaffer.data.element.Element; +import uk.gov.gchq.gaffer.data.element.Entity; +import uk.gov.gchq.koryphe.Since; +import uk.gov.gchq.koryphe.Summary; +import uk.gov.gchq.koryphe.function.KorypheFunction; +import uk.gov.gchq.koryphe.impl.binaryoperator.First; +import uk.gov.gchq.koryphe.util.IterableUtil; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.BinaryOperator; + +import static java.util.Objects.isNull; +import static java.util.Objects.nonNull; + +// TODO: add javadoc +@Since("1.10.4") +@Summary("Reduces related elements") +public class ReduceRelatedElements extends KorypheFunction, Iterable> { + private BinaryOperator vertexAggregator = new First(); + + private BinaryOperator visibilityAggregator; + private String visibilityProperty; + + private Set relatedVertexGroups; + + @Override + public Iterable apply(final Iterable elements) { + if (isNull(elements)) { + return null; + } + + // If no related vertex groups are provided then there is nothing to reduce + if (isNull(relatedVertexGroups) || relatedVertexGroups.isEmpty()) { + return elements; + } + + final Map relatedVertices = new HashMap<>(); + final List edges = new ArrayList<>(); + final List entities = new ArrayList<>(); + for (final Element element : elements) { + if (nonNull(element)) { + if (element instanceof Edge) { + final Edge edge = (Edge) element; + if (relatedVertexGroups.contains(edge.getGroup())) { + updateRelatedVertices(edge, relatedVertices); + } else { + edges.add(edge); + } + } else { + final Entity entity = (Entity) element; + entities.add(entity); + } + } + } + + for (final Edge edge : edges) { + final Object source = edge.getSource(); + final Object dest = edge.getDestination(); + + final RelatedVertices srcVertices = relatedVertices.get(source); + final Object srcCombinedVertex = getCombinedVertex(source, relatedVertices.get(source)); + + final RelatedVertices destVertices = relatedVertices.get(dest); + final Object destCombinedVertex = getCombinedVertex(dest, relatedVertices.get(dest)); + + edge.setIdentifiers(srcCombinedVertex, destCombinedVertex, edge.isDirected(), edge.getMatchedVertex()); + + addRelatedVertexProperties(edge, srcVertices, "source", srcCombinedVertex); + addRelatedVertexProperties(edge, destVertices, "destination", destCombinedVertex); + } + + for (final Entity entity : entities) { + final Object vertex = entity.getVertex(); + final RelatedVertices vertices = relatedVertices.get(vertex); + final Object combinedVertex = getCombinedVertex(vertex, relatedVertices.get(vertex)); + entity.setVertex(combinedVertex); + addRelatedVertexProperties(entity, vertices, "", combinedVertex); + } + + return IterableUtil.concat(Arrays.asList(edges, entities)); + } + + private void addRelatedVertexProperties(final Element element, final RelatedVertices relatedVertices, final String prefix, final Object combinedVertex) { + if (nonNull(relatedVertices)) { + if (relatedVertices.size() > 1) { + String propertyName; + if (StringUtils.isNotEmpty(prefix)) { + propertyName = prefix + "RelatedVertices"; + } else { + propertyName = "relatedVertices"; + } + + Collection propertyValue = (Collection) element.getProperty(propertyName); + if (isNull(propertyValue)) { + propertyValue = new HashSet<>(relatedVertices); + element.putProperty(propertyName, propertyValue); + } else { + propertyValue.addAll(relatedVertices); + } + propertyValue.remove(combinedVertex); + } + if (nonNull(visibilityProperty)) { + final Object aggVisibility = combineVisibilities(element.getProperty(visibilityProperty), relatedVertices.getVisibility()); + relatedVertices.setVisibility(aggVisibility); + } + } + } + + private Object getCombinedVertex(final Object source, final RelatedVertices relatedVertices) { + if (isNull(relatedVertices) || relatedVertices.isEmpty()) { + return source; + } + + Object combinedVertex = source; + for (final Object relatedVertex : relatedVertices) { + combinedVertex = vertexAggregator.apply(combinedVertex, relatedVertex); + } + + return combinedVertex; + } + + private void updateRelatedVertices(final Edge edge, final Map relatedVertices) { + final Object source = edge.getSource(); + final Object dest = edge.getDestination(); + final Object visibility = edge.getProperty(visibilityProperty); + + RelatedVertices srcVertices = relatedVertices.get(source); + RelatedVertices destVertices = relatedVertices.get(source); + if (nonNull(srcVertices) && nonNull(destVertices)) { + if (srcVertices != destVertices) { // check if the objects are the same (has the same address) + srcVertices.add(dest); + srcVertices.addAll(destVertices); + for (final Object vertex : srcVertices) { + relatedVertices.put(vertex, srcVertices); + } + } + } else if (nonNull(srcVertices)) { + srcVertices.add(dest); + relatedVertices.put(dest, srcVertices); + } else if (nonNull(destVertices)) { + srcVertices = destVertices; + srcVertices.add(source); + srcVertices.add(dest); + relatedVertices.put(source, srcVertices); + relatedVertices.put(dest, srcVertices); + } else { + srcVertices = new RelatedVertices(); + srcVertices.add(source); + srcVertices.add(dest); + relatedVertices.put(source, srcVertices); + relatedVertices.put(dest, srcVertices); + } + + if (nonNull(visibility)) { + final Object aggVisibility = combineVisibilities(visibility, srcVertices.getVisibility()); + srcVertices.setVisibility(aggVisibility); + } + } + + private Object combineVisibilities(final Object visibility1, final Object visibility2) { + if (isNull(visibility1)) { + return visibility2; + } + + if (isNull(visibility2)) { + return visibility1; + } + + if (visibility1.equals(visibility2)) { + return visibility1; + } + + if (isNull(visibilityAggregator)) { + throw new IllegalArgumentException("No visibility aggregator provided, so visibilities cannot be combined."); + } + + return visibilityAggregator.apply(visibility1, visibility2); + } + + private static final class RelatedVertices extends HashSet { + private static final long serialVersionUID = 2778585598526500913L; + private Object visibility; + + public Object getVisibility() { + return visibility; + } + + public void setVisibility(final Object visibility) { + this.visibility = visibility; + } + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class") + public BinaryOperator getVisibilityAggregator() { + return visibilityAggregator; + } + + public void setVisibilityAggregator(final BinaryOperator visibilityAggregator) { + this.visibilityAggregator = (BinaryOperator) visibilityAggregator; + } + + public String getVisibilityProperty() { + return visibilityProperty; + } + + public void setVisibilityProperty(final String visibilityProperty) { + this.visibilityProperty = visibilityProperty; + } + + @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "class") + public BinaryOperator getVertexAggregator() { + return vertexAggregator; + } + + public void setVertexAggregator(final BinaryOperator vertexAggregator) { + this.vertexAggregator = (BinaryOperator) vertexAggregator; + } + + public Set getRelatedVertexGroups() { + return relatedVertexGroups; + } + + public void setRelatedVertexGroups(final Set relatedVertexGroups) { + this.relatedVertexGroups = relatedVertexGroups; + } +} diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java new file mode 100644 index 00000000000..b30581d7561 --- /dev/null +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java @@ -0,0 +1,186 @@ +/* + * Copyright 2017-2019 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.data.element.function; + +import com.google.common.collect.Sets; +import org.junit.Test; + +import uk.gov.gchq.gaffer.commonutil.JsonAssert; +import uk.gov.gchq.gaffer.commonutil.TestGroups; +import uk.gov.gchq.gaffer.data.element.Edge; +import uk.gov.gchq.gaffer.data.element.Element; +import uk.gov.gchq.gaffer.data.element.Entity; +import uk.gov.gchq.gaffer.data.util.ElementUtil; +import uk.gov.gchq.gaffer.exception.SerialisationException; +import uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser; +import uk.gov.gchq.koryphe.binaryoperator.KorypheBinaryOperator; +import uk.gov.gchq.koryphe.function.FunctionTest; +import uk.gov.gchq.koryphe.impl.binaryoperator.CollectionConcat; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class ReduceRelatedElementsTest extends FunctionTest { + public static final String RELATES_TO = "relatesTo"; + public static final String VISIBILITY = "visibility"; + + @Test + public void shouldReturnNullForNullValue() { + // Given + final ReduceRelatedElements function = getInstance(); + + // When + final Object result = function.apply(null); + + // Then + assertNull(result); + } + + @Test + public void shouldReduceRelatedElements() { + Object vertex1a = "vertex1a longest"; + Object vertex1b = "vertex1b"; + Object vertex2a = "vertex2a"; + Object vertex2b = "vertex2b longest"; + Object vertex3a = "vertex3a"; + Object vertex3b = "vertex3b longest"; + + // Given + final ReduceRelatedElements function = getInstance(); + final List elements = Arrays.asList( + new Edge.Builder() + .source(vertex1a) + .dest(vertex2a) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex1b) + .dest(vertex3a) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Entity.Builder() + .vertex(vertex2a) + .group(TestGroups.ENTITY) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex1a) + .dest(vertex1b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex2a) + .dest(vertex2b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex3a) + .dest(vertex3b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("private")) + .build() + + ); + + // When + final Iterable result = function.apply(elements); + + // Then + final List expectedElements = Arrays.asList( + new Edge.Builder() + .source(vertex1a) + .dest(vertex2b) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .property("sourceRelatedVertices", Sets.newHashSet(vertex1b)) + .property("destinationRelatedVertices", Sets.newHashSet(vertex2a)) + .build(), + new Edge.Builder() + .source(vertex1a) + .dest(vertex3b) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public", "private")) + .property("sourceRelatedVertices", Sets.newHashSet(vertex1b)) + .property("destinationRelatedVertices", Sets.newHashSet(vertex3a)) + .build(), + new Entity.Builder() + .vertex(vertex2b) + .group(TestGroups.ENTITY) + .property(VISIBILITY, Sets.newHashSet("public")) + .property("relatedVertices", Sets.newHashSet(vertex2a)) + .build() + ); + ElementUtil.assertElementEquals(expectedElements, result); + } + + @Override + protected ReduceRelatedElements getInstance() { + final ReduceRelatedElements function = new ReduceRelatedElements(); + function.setVisibilityProperty(VISIBILITY); + function.setVisibilityAggregator(new CollectionConcat<>()); + function.setVertexAggregator(new Longest()); + function.setRelatedVertexGroups(Collections.singleton(RELATES_TO)); + return function; + } + + @Override + protected Class getFunctionClass() { + return ReduceRelatedElements.class; + } + + @Override + public void shouldJsonSerialiseAndDeserialise() throws SerialisationException { + // Given + final ReduceRelatedElements function = getInstance(); + + // When + final byte[] json = JSONSerialiser.serialise(function); + final ReduceRelatedElements deserialisedObj = JSONSerialiser.deserialise(json, ReduceRelatedElements.class); + + // Then + JsonAssert.assertEquals( + "{\"class\":\"uk.gov.gchq.gaffer.data.element.function.ReduceRelatedElements\",\"vertexAggregator\":{\"class\":\"uk.gov.gchq.gaffer.data.element.function.ReduceRelatedElementsTest$Longest\"},\"visibilityAggregator\":{\"class\":\"uk.gov.gchq.koryphe.impl.binaryoperator.CollectionConcat\"},\"visibilityProperty\":\"visibility\",\"relatedVertexGroups\":[\"relatesTo\"]}\n", + new String(json) + ); + assertNotNull(deserialisedObj); + } + + private static final class Longest extends KorypheBinaryOperator { + @Override + protected String _apply(final String s, final String t) { + if (s.length() > t.length()) { + return s; + } + + return t; + } + } +} From 4aa51bc497aa9fb4af938eec65182fb0b963b65f Mon Sep 17 00:00:00 2001 From: p013570 Date: Mon, 20 Jan 2020 13:58:29 +0000 Subject: [PATCH 02/43] Implemented additional functions and added tests --- .../function/ReduceRelatedElements.java | 14 +- .../function/TypeSubTypeValueToTuple.java | 37 +++ .../function/TypeSubTypeValueTuple.java | 70 +++++ .../element/function/TypeValueToTuple.java | 38 +++ .../data/element/function/TypeValueTuple.java | 65 +++++ .../function/ReduceRelatedElementsTest.java | 255 +++++++++++++++++- .../function/TypeSubTypeValueToTupleTest.java | 116 ++++++++ .../function/TypeValueToTupleTest.java | 116 ++++++++ core/operation/pom.xml | 7 + .../function/ToTrailingWildcardPair.java | 56 ++++ .../function/ToTrailingWildcardPairTest.java | 85 ++++++ 11 files changed, 852 insertions(+), 7 deletions(-) create mode 100644 core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java create mode 100644 core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueTuple.java create mode 100644 core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java create mode 100644 core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueTuple.java create mode 100644 core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTupleTest.java create mode 100644 core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTupleTest.java create mode 100644 core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java create mode 100644 core/operation/src/test/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPairTest.java diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java index f7bfe35fdf8..92da3ba3679 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java @@ -40,9 +40,13 @@ import static java.util.Objects.isNull; import static java.util.Objects.nonNull; +import static org.apache.commons.collections.CollectionUtils.isEmpty; -// TODO: add javadoc -@Since("1.10.4") +/** + * A {@code ReduceRelatedElements} is a {@link KorypheFunction} which takes an {@link Iterable} or {@link Element}s and + * combines all related elements using the provided aggregator functions. + */ +@Since("9.9.9") @Summary("Reduces related elements") public class ReduceRelatedElements extends KorypheFunction, Iterable> { private BinaryOperator vertexAggregator = new First(); @@ -59,7 +63,7 @@ public Iterable apply(final Iterable elements) { } // If no related vertex groups are provided then there is nothing to reduce - if (isNull(relatedVertexGroups) || relatedVertexGroups.isEmpty()) { + if (isEmpty(relatedVertexGroups)) { return elements; } @@ -136,7 +140,7 @@ private void addRelatedVertexProperties(final Element element, final RelatedVert } private Object getCombinedVertex(final Object source, final RelatedVertices relatedVertices) { - if (isNull(relatedVertices) || relatedVertices.isEmpty()) { + if (isEmpty(relatedVertices)) { return source; } @@ -154,7 +158,7 @@ private void updateRelatedVertices(final Edge edge, final Map> { + @Override + public Tuple apply(final TypeSubTypeValue input) { + if (null == input) { + return null; + } + return new TypeSubTypeValueTuple(input); + } +} diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueTuple.java new file mode 100644 index 00000000000..b737fcb432a --- /dev/null +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueTuple.java @@ -0,0 +1,70 @@ +/* + * Copyright 2020 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.data.element.function; + +import uk.gov.gchq.gaffer.types.TypeSubTypeValue; +import uk.gov.gchq.koryphe.tuple.Tuple; + +import java.util.Arrays; + +import static java.util.Objects.isNull; + +public class TypeSubTypeValueTuple implements Tuple { + private TypeSubTypeValue tsv; + + public TypeSubTypeValueTuple() { + this(null); + } + + public TypeSubTypeValueTuple(final TypeSubTypeValue tsv) { + if (isNull(tsv)) { + this.tsv = new TypeSubTypeValue(); + } else { + this.tsv = tsv; + } + } + + @Override + public void put(final String key, final Object value) { + final String stringValue = isNull(value) ? null : value.toString(); + if ("type".equalsIgnoreCase(key)) { + tsv.setType(stringValue); + } else if ("subType".equalsIgnoreCase(key)) { + tsv.setSubType(stringValue); + } else if ("value".equalsIgnoreCase(key)) { + tsv.setValue(stringValue); + } + } + + @Override + public Object get(final String key) { + if ("type".equalsIgnoreCase(key)) { + return tsv.getType(); + } + if ("subType".equalsIgnoreCase(key)) { + return tsv.getSubType(); + } + if ("value".equalsIgnoreCase(key)) { + return tsv.getValue(); + } + return null; + } + + @Override + public Iterable values() { + return Arrays.asList(tsv.getType(), tsv.getSubType(), tsv.getValue()); + } +} diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java new file mode 100644 index 00000000000..8e2faa2fc62 --- /dev/null +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java @@ -0,0 +1,38 @@ +/* + * Copyright 2019 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.data.element.function; + +import uk.gov.gchq.gaffer.types.TypeValue; +import uk.gov.gchq.koryphe.Since; +import uk.gov.gchq.koryphe.Summary; +import uk.gov.gchq.koryphe.function.KorypheFunction; +import uk.gov.gchq.koryphe.tuple.Tuple; + +/** + * A {@code TypeValueToTuple} is a {@link KorypheFunction} that converts an {@link TypeValue} into a {@link Tuple}. + */ +@Since("9.9.9") +@Summary("Converts an TypeValue into a Tuple") +public class TypeValueToTuple extends KorypheFunction> { + @Override + public Tuple apply(final TypeValue input) { + if (null == input) { + return null; + } + + return new TypeValueTuple(input); + } +} diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueTuple.java new file mode 100644 index 00000000000..a03eb6ba821 --- /dev/null +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueTuple.java @@ -0,0 +1,65 @@ +/* + * Copyright 2020 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.data.element.function; + +import uk.gov.gchq.gaffer.types.TypeValue; +import uk.gov.gchq.koryphe.tuple.Tuple; + +import java.util.Arrays; + +import static java.util.Objects.isNull; + +public class TypeValueTuple implements Tuple { + private TypeValue tv; + + public TypeValueTuple() { + this(null); + } + + public TypeValueTuple(final TypeValue tv) { + if (isNull(tv)) { + this.tv = new TypeValue(); + } else { + this.tv = tv; + } + } + + @Override + public void put(final String key, final Object value) { + final String stringValue = isNull(value) ? null : value.toString(); + if ("type".equalsIgnoreCase(key)) { + tv.setType(stringValue); + } else if ("value".equalsIgnoreCase(key)) { + tv.setValue(stringValue); + } + } + + @Override + public Object get(final String key) { + if ("type".equalsIgnoreCase(key)) { + return tv.getType(); + } + if ("value".equalsIgnoreCase(key)) { + return tv.getValue(); + } + return null; + } + + @Override + public Iterable values() { + return Arrays.asList(tv.getType(), tv.getValue()); + } +} diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java index b30581d7561..25a981e71cf 100644 --- a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java @@ -23,7 +23,6 @@ import uk.gov.gchq.gaffer.data.element.Edge; import uk.gov.gchq.gaffer.data.element.Element; import uk.gov.gchq.gaffer.data.element.Entity; -import uk.gov.gchq.gaffer.data.util.ElementUtil; import uk.gov.gchq.gaffer.exception.SerialisationException; import uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser; import uk.gov.gchq.koryphe.binaryoperator.KorypheBinaryOperator; @@ -36,6 +35,9 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static uk.gov.gchq.gaffer.data.util.ElementUtil.assertElementEquals; public class ReduceRelatedElementsTest extends FunctionTest { public static final String RELATES_TO = "relatesTo"; @@ -105,7 +107,125 @@ public void shouldReduceRelatedElements() { .group(RELATES_TO) .property(VISIBILITY, Sets.newHashSet("private")) .build() + ); + + // When + final Iterable result = function.apply(elements); + // Then + final List expectedElements = Arrays.asList( + new Edge.Builder() + .source(vertex1a) + .dest(vertex2b) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .property("sourceRelatedVertices", Sets.newHashSet(vertex1b)) + .property("destinationRelatedVertices", Sets.newHashSet(vertex2a)) + .build(), + new Edge.Builder() + .source(vertex1a) + .dest(vertex3b) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public", "private")) + .property("sourceRelatedVertices", Sets.newHashSet(vertex1b)) + .property("destinationRelatedVertices", Sets.newHashSet(vertex3a)) + .build(), + new Entity.Builder() + .vertex(vertex2b) + .group(TestGroups.ENTITY) + .property(VISIBILITY, Sets.newHashSet("public")) + .property("relatedVertices", Sets.newHashSet(vertex2a)) + .build() + ); + assertElementEquals(expectedElements, result); + } + + @Test + public void shouldReduceRelatedElementsWithManyRelationships() { + Object vertex1a = "vertex1a longest"; + Object vertex1b = "vertex1b"; + Object vertex2a = "vertex2a"; + Object vertex2b = "vertex2b longest"; + Object vertex3a = "vertex3a"; + Object vertex3b = "vertex3b longest"; + Object vertex4a = "vertex4a"; + Object vertex4b = "vertex4b longest"; + Object vertex5a = "vertex5a"; + Object vertex5b = "vertex5b longest"; + + // Given + final ReduceRelatedElements function = getInstance(); + final List elements = Arrays.asList( + new Edge.Builder() + .source(vertex1a) + .dest(vertex2a) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex1b) + .dest(vertex3a) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Entity.Builder() + .vertex(vertex2a) + .group(TestGroups.ENTITY) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex1a) + .dest(vertex1b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex2a) + .dest(vertex2b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex3a) + .dest(vertex3b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("private")) + .build(), + new Edge.Builder() + .source(vertex2a) + .dest(vertex3b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("private")) + .build(), + new Edge.Builder() + .source(vertex2b) + .dest(vertex3a) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex3a) + .dest(vertex4b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("private")) + .build(), + new Edge.Builder() + .source(vertex5b) + .dest(vertex4a) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build() ); // When @@ -138,7 +258,138 @@ public void shouldReduceRelatedElements() { .property("relatedVertices", Sets.newHashSet(vertex2a)) .build() ); - ElementUtil.assertElementEquals(expectedElements, result); +// assertElementEquals(expectedElements, result); + } + + @Test + public void shouldReturnInputIfNoRelatedVertexGroups() { + Object vertex1a = "vertex1a longest"; + Object vertex1b = "vertex1b"; + Object vertex2a = "vertex2a"; + Object vertex2b = "vertex2b longest"; + Object vertex3a = "vertex3a"; + Object vertex3b = "vertex3b longest"; + + // Given + final ReduceRelatedElements function = new ReduceRelatedElements(); + final List elements = Arrays.asList( + new Edge.Builder() + .source(vertex1a) + .dest(vertex2a) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex1b) + .dest(vertex3a) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Entity.Builder() + .vertex(vertex2a) + .group(TestGroups.ENTITY) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex1a) + .dest(vertex1b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex2a) + .dest(vertex2b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex3a) + .dest(vertex3b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("private")) + .build() + ); + + // When + final Iterable result = function.apply(elements); + + // Then + assertElementEquals(elements, result); + } + + @Test + public void shouldFailIfNoVisibilityAggregatorProvided() { + Object vertex1a = "vertex1a longest"; + Object vertex1b = "vertex1b"; + Object vertex2a = "vertex2a"; + Object vertex2b = "vertex2b longest"; + Object vertex3a = "vertex3a"; + Object vertex3b = "vertex3b longest"; + + // Given + final ReduceRelatedElements function = new ReduceRelatedElements(); + function.setVisibilityProperty(VISIBILITY); + function.setVisibilityAggregator(null); + function.setVertexAggregator(new Longest()); + function.setRelatedVertexGroups(Collections.singleton(RELATES_TO)); + + final List elements = Arrays.asList( + new Edge.Builder() + .source(vertex1a) + .dest(vertex2a) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex1b) + .dest(vertex3a) + .directed(true) + .group(TestGroups.EDGE) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Entity.Builder() + .vertex(vertex2a) + .group(TestGroups.ENTITY) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex1a) + .dest(vertex1b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex2a) + .dest(vertex2b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("public")) + .build(), + new Edge.Builder() + .source(vertex3a) + .dest(vertex3b) + .directed(true) + .group(RELATES_TO) + .property(VISIBILITY, Sets.newHashSet("private")) + .build() + ); + + // When + try { + function.apply(elements); + + fail(); + } catch (final IllegalArgumentException e) { + // Then + assertTrue(e.getMessage().contains("No visibility aggregator provided, so visibilities cannot be combined.")); + } } @Override diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTupleTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTupleTest.java new file mode 100644 index 00000000000..9cd2174a66a --- /dev/null +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTupleTest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2019 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.data.element.function; + +import com.google.common.collect.Lists; +import org.junit.Test; + +import uk.gov.gchq.gaffer.commonutil.JsonAssert; +import uk.gov.gchq.gaffer.exception.SerialisationException; +import uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser; +import uk.gov.gchq.gaffer.types.TypeSubTypeValue; +import uk.gov.gchq.koryphe.function.FunctionComposite; +import uk.gov.gchq.koryphe.function.FunctionTest; +import uk.gov.gchq.koryphe.impl.function.Length; +import uk.gov.gchq.koryphe.impl.function.ToString; +import uk.gov.gchq.koryphe.tuple.Tuple; +import uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite; + +import java.util.Arrays; +import java.util.function.Function; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class TypeSubTypeValueToTupleTest extends FunctionTest { + + @Test + public void shouldHandleNullInput() { + // Given + final TypeSubTypeValueToTuple function = getInstance(); + + // When + final Tuple result = function.apply(null); + + // Then + assertNull(result); + } + + @Test + public void shouldConvertTypeSubTypeValueToTuple() { + // Given + final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue("type", "subType", "value"); + final TypeSubTypeValueToTuple function = getInstance(); + + // When + final Tuple result = function.apply(typeSubTypeValue); + + // Then + assertEquals("type", result.get("type")); + assertEquals("value", result.get("value")); + } + + @Test + public void shouldGetAndSetUsingCompositeFunction() { + // Given + final TypeSubTypeValue typeSubTypeValue = new TypeSubTypeValue("type", "subType", "value"); + final Function compositeFunction = new FunctionComposite(Lists.newArrayList( + new TypeSubTypeValueToTuple(), + new TupleAdaptedFunctionComposite.Builder() + .select(new String[]{"value"}) + .execute(new FunctionComposite(Arrays.asList( + new Length(), + new ToString() + ))) + .project(new String[]{"type"}) + .build() + )); + + // When + compositeFunction.apply(typeSubTypeValue); + + // Then + assertEquals(new TypeSubTypeValue("5", "subType", "value"), typeSubTypeValue); + } + + @Override + protected TypeSubTypeValueToTuple getInstance() { + return new TypeSubTypeValueToTuple(); + } + + @Override + protected Class getFunctionClass() { + return TypeSubTypeValueToTuple.class; + } + + @Override + public void shouldJsonSerialiseAndDeserialise() throws SerialisationException { + // Given + final TypeSubTypeValueToTuple function = getInstance(); + + // When + final byte[] json = JSONSerialiser.serialise(function); + final TypeSubTypeValueToTuple deserialisedObj = JSONSerialiser.deserialise(json, TypeSubTypeValueToTuple.class); + + // Then + JsonAssert.assertEquals( + "{\"class\":\"uk.gov.gchq.gaffer.data.element.function.TypeSubTypeValueToTuple\"}", + new String(json) + ); + assertNotNull(deserialisedObj); + } +} diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTupleTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTupleTest.java new file mode 100644 index 00000000000..9875175beda --- /dev/null +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTupleTest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2019 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.data.element.function; + +import com.google.common.collect.Lists; +import org.junit.Test; + +import uk.gov.gchq.gaffer.commonutil.JsonAssert; +import uk.gov.gchq.gaffer.exception.SerialisationException; +import uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser; +import uk.gov.gchq.gaffer.types.TypeValue; +import uk.gov.gchq.koryphe.function.FunctionComposite; +import uk.gov.gchq.koryphe.function.FunctionTest; +import uk.gov.gchq.koryphe.impl.function.Length; +import uk.gov.gchq.koryphe.impl.function.ToString; +import uk.gov.gchq.koryphe.tuple.Tuple; +import uk.gov.gchq.koryphe.tuple.function.TupleAdaptedFunctionComposite; + +import java.util.Arrays; +import java.util.function.Function; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class TypeValueToTupleTest extends FunctionTest { + + @Test + public void shouldHandleNullInput() { + // Given + final TypeValueToTuple function = getInstance(); + + // When + final Tuple result = function.apply(null); + + // Then + assertNull(result); + } + + @Test + public void shouldConvertTypeValueToTuple() { + // Given + final TypeValue typeValue = new TypeValue("type", "value"); + final TypeValueToTuple function = getInstance(); + + // When + final Tuple result = function.apply(typeValue); + + // Then + assertEquals("type", result.get("type")); + assertEquals("value", result.get("value")); + } + + @Test + public void shouldGetAndSetUsingCompositeFunction() { + // Given + final TypeValue typeValue = new TypeValue("type", "value"); + final Function compositeFunction = new FunctionComposite(Lists.newArrayList( + new TypeValueToTuple(), + new TupleAdaptedFunctionComposite.Builder() + .select(new String[]{"value"}) + .execute(new FunctionComposite(Arrays.asList( + new Length(), + new ToString() + ))) + .project(new String[]{"type"}) + .build() + )); + + // When + compositeFunction.apply(typeValue); + + // Then + assertEquals(new TypeValue("5", "value"), typeValue); + } + + @Override + protected TypeValueToTuple getInstance() { + return new TypeValueToTuple(); + } + + @Override + protected Class getFunctionClass() { + return TypeValueToTuple.class; + } + + @Override + public void shouldJsonSerialiseAndDeserialise() throws SerialisationException { + // Given + final TypeValueToTuple function = getInstance(); + + // When + final byte[] json = JSONSerialiser.serialise(function); + final TypeValueToTuple deserialisedObj = JSONSerialiser.deserialise(json, TypeValueToTuple.class); + + // Then + JsonAssert.assertEquals( + "{\"class\":\"uk.gov.gchq.gaffer.data.element.function.TypeValueToTuple\"}", + new String(json) + ); + assertNotNull(deserialisedObj); + } +} diff --git a/core/operation/pom.xml b/core/operation/pom.xml index a4cd8c61aae..d43c85afd77 100644 --- a/core/operation/pom.xml +++ b/core/operation/pom.xml @@ -50,6 +50,13 @@ test-jar test + + uk.gov.gchq.koryphe + core + ${koryphe.version} + test-jar + test + diff --git a/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java b/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java new file mode 100644 index 00000000000..f4a4826b31a --- /dev/null +++ b/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java @@ -0,0 +1,56 @@ +/* + * Copyright 2019 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.operation.function; + +import uk.gov.gchq.gaffer.commonutil.pair.Pair; +import uk.gov.gchq.gaffer.data.element.id.EntityId; +import uk.gov.gchq.gaffer.operation.data.EntitySeed; +import uk.gov.gchq.koryphe.Since; +import uk.gov.gchq.koryphe.Summary; +import uk.gov.gchq.koryphe.function.KorypheFunction; + +/** + * A {@code ToTrailingWildcardPair} is a {@link KorypheFunction} that takes an input value to use as the starting value + * for a range and creates a value to use as the end point. Note that the both of the vertex values must first be converted + * to {@link String}s. These values are then wrapped up as {@link EntitySeed}s. + */ +@Since("9.9.9") +@Summary("Converts an input value into a pair of EntityIds representing a range.") +public class ToTrailingWildcardPair extends KorypheFunction> { + + private String endOfRange = "~"; + + @Override + public Pair apply(final String input) { + if (null == input) { + return null; + } + + return createPair(input); + } + + public String getEndOfRange() { + return endOfRange; + } + + public void setEndOfRange(final String endOfRange) { + this.endOfRange = endOfRange; + } + + private Pair createPair(final String vertex) { + return new Pair<>(new EntitySeed(vertex), new EntitySeed(vertex + getEndOfRange())); + } +} diff --git a/core/operation/src/test/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPairTest.java b/core/operation/src/test/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPairTest.java new file mode 100644 index 00000000000..e7407b3c57d --- /dev/null +++ b/core/operation/src/test/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPairTest.java @@ -0,0 +1,85 @@ +/* + * Copyright 2019 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.operation.function; + +import org.junit.Test; + +import uk.gov.gchq.gaffer.commonutil.JsonAssert; +import uk.gov.gchq.gaffer.commonutil.pair.Pair; +import uk.gov.gchq.gaffer.data.element.id.EntityId; +import uk.gov.gchq.gaffer.exception.SerialisationException; +import uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser; +import uk.gov.gchq.koryphe.function.FunctionTest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class ToTrailingWildcardPairTest extends FunctionTest { + + @Test + public void shouldHandleNullInput() { + // Given + final ToTrailingWildcardPair function = new ToTrailingWildcardPair(); + + // When + final Pair result = function.apply(null); + + // Then + assertNull(result); + } + + @Test + public void shouldCreateEntityIdPair() { + // Given + final ToTrailingWildcardPair function = new ToTrailingWildcardPair(); + + // When + final Pair result = function.apply("value1"); + + // Then + assertEquals("value1", result.getFirst().getVertex()); + assertEquals("value1~", result.getSecond().getVertex()); + } + + @Override + protected ToTrailingWildcardPair getInstance() { + return new ToTrailingWildcardPair(); + } + + @Override + protected Class getFunctionClass() { + return ToTrailingWildcardPair.class; + } + + @Override + public void shouldJsonSerialiseAndDeserialise() throws SerialisationException { + // Given + final ToTrailingWildcardPair function = getInstance(); + function.setEndOfRange("*"); + + // When + final byte[] json = JSONSerialiser.serialise(function); + final ToTrailingWildcardPair deserialisedObj = JSONSerialiser.deserialise(json, ToTrailingWildcardPair.class); + + // Then + JsonAssert.assertEquals( + "{\"class\":\"uk.gov.gchq.gaffer.operation.function.ToTrailingWildcardPair\", \"endOfRange\":\"*\"}", + new String(json) + ); + assertNotNull(deserialisedObj); + } +} From 8df72146afe7237eb55e9af08118053756217930 Mon Sep 17 00:00:00 2001 From: p013570 Date: Tue, 28 Jan 2020 10:45:11 +0000 Subject: [PATCH 03/43] Updated the version of the new functions --- .../gaffer/data/element/function/ReduceRelatedElements.java | 2 +- .../gaffer/data/element/function/TypeSubTypeValueToTuple.java | 2 +- .../gov/gchq/gaffer/data/element/function/TypeValueToTuple.java | 2 +- .../gchq/gaffer/operation/function/ToTrailingWildcardPair.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java index 92da3ba3679..d219820bf81 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java @@ -46,7 +46,7 @@ * A {@code ReduceRelatedElements} is a {@link KorypheFunction} which takes an {@link Iterable} or {@link Element}s and * combines all related elements using the provided aggregator functions. */ -@Since("9.9.9") +@Since("1.10.6") @Summary("Reduces related elements") public class ReduceRelatedElements extends KorypheFunction, Iterable> { private BinaryOperator vertexAggregator = new First(); diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java index 563ac0cc670..1c395352671 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java @@ -24,7 +24,7 @@ /** * A {@code TypeSubTypeValueToTuple} is a {@link KorypheFunction} that converts an {@link TypeSubTypeValue} into a {@link Tuple}. */ -@Since("9.9.9") +@Since("1.10.6") @Summary("Converts an TypeSubTypeValue into a Tuple") public class TypeSubTypeValueToTuple extends KorypheFunction> { @Override diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java index 8e2faa2fc62..5d1f51e66c0 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java @@ -24,7 +24,7 @@ /** * A {@code TypeValueToTuple} is a {@link KorypheFunction} that converts an {@link TypeValue} into a {@link Tuple}. */ -@Since("9.9.9") +@Since("1.10.6") @Summary("Converts an TypeValue into a Tuple") public class TypeValueToTuple extends KorypheFunction> { @Override diff --git a/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java b/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java index f4a4826b31a..76256cfa8c0 100644 --- a/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java +++ b/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java @@ -27,7 +27,7 @@ * for a range and creates a value to use as the end point. Note that the both of the vertex values must first be converted * to {@link String}s. These values are then wrapped up as {@link EntitySeed}s. */ -@Since("9.9.9") +@Since("1.10.6") @Summary("Converts an input value into a pair of EntityIds representing a range.") public class ToTrailingWildcardPair extends KorypheFunction> { From 9d9487d3dafcd70427d887903c75ba5835b46826 Mon Sep 17 00:00:00 2001 From: p013570 Date: Thu, 28 May 2020 11:21:24 +0100 Subject: [PATCH 04/43] Updated copyright date --- .../gaffer/data/element/function/ReduceRelatedElements.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java index d219820bf81..e1ff30919a7 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 Crown Copyright + * Copyright 2017-2020 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 ca95bff42a90cfe35368750cdc41ea2160148723 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:41:09 +0100 Subject: [PATCH 05/43] updated copyright dates --- .../gaffer/data/element/function/ReduceRelatedElements.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java index e1ff30919a7..01658940828 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElements.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2020 Crown Copyright + * Copyright 2017-2021 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 4441561d960d58524e34194e07547c1a03def558 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:42:31 +0100 Subject: [PATCH 06/43] Updated copyright date --- .../gaffer/data/element/function/TypeSubTypeValueToTuple.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java index 1c395352671..815207bd579 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTuple.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Crown Copyright + * Copyright 2021 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 f2caffa128851f0e60fc5abf09d75ad3a68ddbf6 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:44:44 +0100 Subject: [PATCH 07/43] Updated copyright date --- .../gaffer/data/element/function/TypeSubTypeValueTuple.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueTuple.java index b737fcb432a..4248e932148 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueTuple.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueTuple.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 Crown Copyright + * Copyright 2021 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 76999bc6ea8d131efcea0610cb2cab5ec6c0f2a3 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:45:43 +0100 Subject: [PATCH 08/43] Updated copyright date --- .../gov/gchq/gaffer/data/element/function/TypeValueToTuple.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java index 5d1f51e66c0..c17cbcf4225 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTuple.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Crown Copyright + * Copyright 2021 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 cd7a6943a4d5cae1764186155ebde3601dbe1daf Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:46:11 +0100 Subject: [PATCH 09/43] Updated copyright date --- .../gov/gchq/gaffer/data/element/function/TypeValueTuple.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueTuple.java b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueTuple.java index a03eb6ba821..55788dacb7f 100644 --- a/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueTuple.java +++ b/core/data/src/main/java/uk/gov/gchq/gaffer/data/element/function/TypeValueTuple.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 Crown Copyright + * Copyright 2021 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 de38d5bf507d4abe67a0fd2ea4bd946e00ff9826 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:47:25 +0100 Subject: [PATCH 10/43] Updated copyright date --- .../gaffer/data/element/function/ReduceRelatedElementsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java index 25a981e71cf..2b004268a54 100644 --- a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/ReduceRelatedElementsTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 Crown Copyright + * Copyright 2017-2021 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 8a17ef1aa12c32e2b3ebde4167e951a25c7c2514 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:47:40 +0100 Subject: [PATCH 11/43] Updated copyright date --- .../data/element/function/TypeSubTypeValueToTupleTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTupleTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTupleTest.java index 9cd2174a66a..f122e8e5f68 100644 --- a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTupleTest.java +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeSubTypeValueToTupleTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Crown Copyright + * Copyright 2021 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 d5357b58239a965828786eea72c638db5dea0c08 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:47:58 +0100 Subject: [PATCH 12/43] Update TypeValueToTupleTest.java --- .../gchq/gaffer/data/element/function/TypeValueToTupleTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTupleTest.java b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTupleTest.java index 9875175beda..7e1d53ba1a9 100644 --- a/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTupleTest.java +++ b/core/data/src/test/java/uk/gov/gchq/gaffer/data/element/function/TypeValueToTupleTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Crown Copyright + * Copyright 2021 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 0eda007018f75ab3f516db926520e8a351e656c2 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:48:16 +0100 Subject: [PATCH 13/43] Updated copyright date --- .../gaffer/operation/function/ToTrailingWildcardPairTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/operation/src/test/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPairTest.java b/core/operation/src/test/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPairTest.java index e7407b3c57d..19340fa2280 100644 --- a/core/operation/src/test/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPairTest.java +++ b/core/operation/src/test/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPairTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Crown Copyright + * Copyright 2021 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 24f9e4de7d7d18b86f62064259b5bbe956d3ddd4 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:49:03 +0100 Subject: [PATCH 14/43] Updated copyright date --- .../gchq/gaffer/operation/function/ToTrailingWildcardPair.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java b/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java index 76256cfa8c0..411c4484546 100644 --- a/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java +++ b/core/operation/src/main/java/uk/gov/gchq/gaffer/operation/function/ToTrailingWildcardPair.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Crown Copyright + * Copyright 2021 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 278a35bf179a854334bac1969bb66ef80b9a7f73 Mon Sep 17 00:00:00 2001 From: p3430233 <61738524+p3430233@users.noreply.github.com> Date: Wed, 21 Apr 2021 09:49:24 +0100 Subject: [PATCH 15/43] Updated copyright date --- core/operation/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/operation/pom.xml b/core/operation/pom.xml index a5f8705421d..a5a871f8c38 100644 --- a/core/operation/pom.xml +++ b/core/operation/pom.xml @@ -1,6 +1,6 @@