Search in sources :

Example 6 with IsIn

use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project gaffer-doc by gchq.

the class IsInExample method isInSet.

public void isInSet() {
    // ---------------------------------------------------------
    final IsIn function = new IsIn(5, 5L, "5", '5');
    // ---------------------------------------------------------
    runExample(function, null, 5, 5L, "5", '5', 1, 1L, "1", '1');
}
Also used : IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn)

Example 7 with IsIn

use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project Gaffer by gchq.

the class FilterHandlerTest method shouldFilterBasedOnMatchedVertex.

@Test
public void shouldFilterBasedOnMatchedVertex() throws OperationException {
    // Given
    final Schema schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").property(TestPropertyNames.COUNT, "count.long").build()).type("vertex", new TypeDefinition(String.class)).type("count.long", new TypeDefinition(Long.class)).build();
    given(store.getSchema()).willReturn(schema);
    final Filter filter = new Filter.Builder().input(new Edge.Builder().group(TestGroups.EDGE).source("srcVal1").dest("destVal1").matchedVertex(EdgeId.MatchedVertex.SOURCE).build(), new Edge.Builder().group(TestGroups.EDGE).source("srcVal2").dest("destVal2").matchedVertex(EdgeId.MatchedVertex.SOURCE).build(), new Edge.Builder().group(TestGroups.EDGE).source("srcVal3").dest("destVal3").matchedVertex(EdgeId.MatchedVertex.DESTINATION).build(), new Edge.Builder().group(TestGroups.EDGE).source("srcVal4").dest("destVal4").matchedVertex(EdgeId.MatchedVertex.DESTINATION).build()).edge(TestGroups.EDGE, new ElementFilter.Builder().select(IdentifierType.MATCHED_VERTEX.name()).execute(new IsIn("srcVal1", "destVal3")).build()).build();
    // When
    final Iterable<? extends Element> results = handler.doOperation(filter, context, store);
    // Then
    ElementUtil.assertElementEquals(Arrays.asList(new Edge.Builder().group(TestGroups.EDGE).source("srcVal1").dest("destVal1").matchedVertex(EdgeId.MatchedVertex.SOURCE).build(), new Edge.Builder().group(TestGroups.EDGE).source("srcVal3").dest("destVal3").matchedVertex(EdgeId.MatchedVertex.SOURCE).build()), results);
}
Also used : Filter(uk.gov.gchq.gaffer.operation.impl.function.Filter) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Schema(uk.gov.gchq.gaffer.store.schema.Schema) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn) Edge(uk.gov.gchq.gaffer.data.element.Edge) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) Test(org.junit.jupiter.api.Test)

Example 8 with IsIn

use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project Gaffer by gchq.

the class UpdateViewHookTest method shouldMergeAndApplyWhiteList.

@Test
public void shouldMergeAndApplyWhiteList() throws Exception {
    updateViewHook.setViewToMerge(viewToMerge);
    updateViewHook.setWithOpAuth(Sets.newHashSet("opA"));
    updateViewHook.setWhiteListElementGroups(Sets.newHashSet("white2", "white1", "testGroup"));
    opChain = new OperationChain.Builder().first(new GetAllElements.Builder().view(new View.Builder().entity("wrong1").entity("white1").entity("white2").edge("testGroup", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new Exists()).build()).build()).build()).build()).build();
    updateViewHook.preExecute(opChain, new Context(new User.Builder().opAuth("opA").build()));
    GetAllElements op = (GetAllElements) opChain.getOperations().get(0);
    JsonAssert.assertEquals(new View.Builder().entity("white1", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new IsIn("value1", "value2")).build()).build()).entity("white2").edge("testGroup", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new Exists()).select("count").execute(new IsMoreThan(10)).build()).build()).build().toJson(true), op.getView().toJson(true));
    assertTrue(op.getView().getGroups().contains("testGroup"));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Builder(uk.gov.gchq.gaffer.user.User.Builder) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Test(org.junit.jupiter.api.Test)

Example 9 with IsIn

use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project Gaffer by gchq.

the class UpdateViewHookTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    userAuths.clear();
    validAuths.clear();
    updateViewHook = new UpdateViewHook();
    viewToMerge = new View.Builder().entity("white1", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new IsIn("value1", "value2")).build()).build()).edge("testGroup", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("count").execute(new IsMoreThan(10)).build()).build()).build();
    userOpAuths.clear();
    userDataAuths.clear();
    opAuths.clear();
    dataAuths.clear();
    userBuilder = new Builder();
}
Also used : Builder(uk.gov.gchq.gaffer.user.User.Builder) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with IsIn

use of uk.gov.gchq.koryphe.impl.predicate.IsIn in project Gaffer by gchq.

the class AggregationIT method shouldGetAllElementsWithFilterSummarisation.

@Test
@TraitRequirement({ StoreTrait.PRE_AGGREGATION_FILTERING, StoreTrait.QUERY_AGGREGATION })
public void shouldGetAllElementsWithFilterSummarisation() throws Exception {
    final Edge edge1 = getEdges().get(new EdgeSeed(SOURCE_1, DEST_1, false)).emptyClone();
    edge1.putProperty(TestPropertyNames.INT, 100);
    edge1.putProperty(TestPropertyNames.COUNT, 1L);
    final Edge edge2 = edge1.emptyClone();
    edge2.putProperty(TestPropertyNames.INT, 101);
    edge2.putProperty(TestPropertyNames.COUNT, 1L);
    graph.execute(new AddElements.Builder().input(edge1, edge2).build(), getUser());
    final GetAllElements op = new GetAllElements.Builder().view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsIn(Arrays.asList(100, 101))).build()).groupBy().aggregator(new ElementAggregator.Builder().select(TestPropertyNames.INT).execute(new Product()).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);
    // aggregation is has been replaced with Product
    assertThat(resultList.get(0).getProperty(TestPropertyNames.INT)).isEqualTo(10100);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Element(uk.gov.gchq.gaffer.data.element.Element) Product(uk.gov.gchq.koryphe.impl.binaryoperator.Product) IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) Edge(uk.gov.gchq.gaffer.data.element.Edge) ElementAggregator(uk.gov.gchq.gaffer.data.element.function.ElementAggregator) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Aggregations

IsIn (uk.gov.gchq.koryphe.impl.predicate.IsIn)11 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)8 Edge (uk.gov.gchq.gaffer.data.element.Edge)6 Test (org.junit.Test)5 Element (uk.gov.gchq.gaffer.data.element.Element)4 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)4 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)4 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)4 Test (org.junit.jupiter.api.Test)3 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)3 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)3 Schema (uk.gov.gchq.gaffer.store.schema.Schema)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)2 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)2 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)2 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)2 Builder (uk.gov.gchq.gaffer.user.User.Builder)2 IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)2