Search in sources :

Example 6 with Concat

use of uk.gov.gchq.koryphe.impl.function.Concat in project gaffer-doc by gchq.

the class GetElementsExample method getEntitiesAndExcludeProperties.

public CloseableIterable<? extends Element> getEntitiesAndExcludeProperties() {
    // ---------------------------------------------------------
    final Concat concat = new Concat();
    concat.setSeparator("|");
    final GetElements operation = new GetElements.Builder().input(new EntitySeed(2)).view(new View.Builder().edge("edge", new ViewElementDefinition.Builder().transientProperty("vertex|count", String.class).excludeProperties("count").transformer(new ElementTransformer.Builder().select(IdentifierType.SOURCE.name(), "count").execute(concat).project("vertex|count").build()).build()).build()).build();
    return runExample(operation, null);
}
Also used : Concat(uk.gov.gchq.koryphe.impl.function.Concat) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements)

Example 7 with Concat

use of uk.gov.gchq.koryphe.impl.function.Concat in project Gaffer by gchq.

the class TransformationIT method shouldCreateTransientEntityProperty.

@Test
@TraitRequirement(StoreTrait.TRANSFORMATION)
public void shouldCreateTransientEntityProperty() throws OperationException {
    // Given
    final GetElements getEntities = new GetElements.Builder().input(new EntitySeed("A1")).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.TRANSIENT_1, String.class).transformer(new ElementTransformer.Builder().select(IdentifierType.VERTEX.name(), TestPropertyNames.SET).execute(new Concat()).project(TestPropertyNames.TRANSIENT_1).build()).build()).build()).build();
    // When
    final List<Element> results = Lists.newArrayList(graph.execute(getEntities, getUser()));
    assertThat(results).hasSize(1);
    for (final Element result : results) {
        assertThat(result.getProperty(TestPropertyNames.TRANSIENT_1)).isEqualTo("A1,[3]");
    }
}
Also used : Concat(uk.gov.gchq.koryphe.impl.function.Concat) Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 8 with Concat

use of uk.gov.gchq.koryphe.impl.function.Concat in project Gaffer by gchq.

the class TransformationIT method shouldTransformVertex.

@Test
@TraitRequirement(StoreTrait.TRANSFORMATION)
public void shouldTransformVertex() throws OperationException {
    // Given
    final GetElements getEntities = new GetElements.Builder().input(new EntitySeed("A1")).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().transformer(new ElementTransformer.Builder().select(IdentifierType.VERTEX.name(), TestPropertyNames.SET).execute(new Concat()).project(IdentifierType.VERTEX.name()).build()).build()).build()).build();
    // When
    final List<Element> results = Lists.newArrayList(graph.execute(getEntities, getUser()));
    assertThat(results).hasSize(1);
    for (final Element result : results) {
        assertThat(((Entity) result).getVertex()).isEqualTo("A1,[3]");
    }
}
Also used : Concat(uk.gov.gchq.koryphe.impl.function.Concat) Entity(uk.gov.gchq.gaffer.data.element.Entity) Element(uk.gov.gchq.gaffer.data.element.Element) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 9 with Concat

use of uk.gov.gchq.koryphe.impl.function.Concat in project Gaffer by gchq.

the class GetAllElementsIT method shouldGetAllTransformedFilteredElements.

@Test
@TraitRequirement({ StoreTrait.TRANSFORMATION, StoreTrait.PRE_AGGREGATION_FILTERING })
public void shouldGetAllTransformedFilteredElements() throws Exception {
    final GetAllElements op = new GetAllElements.Builder().view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(IdentifierType.VERTEX.name()).execute(new IsEqual("A1")).build()).transientProperty(TestPropertyNames.TRANSIENT_1, String.class).transformer(new ElementTransformer.Builder().select(IdentifierType.VERTEX.name(), TestPropertyNames.SET).execute(new Concat()).project(TestPropertyNames.TRANSIENT_1).build()).build()).build()).build();
    // When
    final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
    // Then
    final List<Element> resultList = Lists.newArrayList(results);
    assertThat(resultList).hasSize(1);
    assertThat(resultList.get(0).getProperties()).containsEntry(TestPropertyNames.TRANSIENT_1, "A1,[3]");
}
Also used : Concat(uk.gov.gchq.koryphe.impl.function.Concat) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Element(uk.gov.gchq.gaffer.data.element.Element) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Aggregations

Concat (uk.gov.gchq.koryphe.impl.function.Concat)9 Element (uk.gov.gchq.gaffer.data.element.Element)6 Test (org.junit.Test)5 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)5 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)3 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)3 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)3 List (java.util.List)2 Sets (com.google.common.collect.Sets)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1