Search in sources :

Example 61 with IsMoreThan

use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan 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 62 with IsMoreThan

use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan 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 63 with IsMoreThan

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

the class RoadTrafficTestQueries method checkRoadJunctionsInSouthWestHeavilyUsedByBusesIn2000.

@Test
public void checkRoadJunctionsInSouthWestHeavilyUsedByBusesIn2000() throws OperationException, ParseException {
    assumeTrue(this.graph.hasTrait(StoreTrait.QUERY_AGGREGATION), "Skipping test as the store does not implement required trait.");
    assumeTrue(this.graph.hasTrait(StoreTrait.TRANSFORMATION), "Skipping test as the store does not implement required trait.");
    assumeTrue(this.graph.hasTrait(StoreTrait.PRE_AGGREGATION_FILTERING), "Skipping test as the store does not implement required trait.");
    assumeTrue(this.graph.hasTrait(StoreTrait.POST_AGGREGATION_FILTERING), "Skipping test as the store does not implement required trait.");
    assertNotNull(this.graph, "graph is null");
    final Date JAN_01_2000 = new SimpleDateFormat("yyyy-MM-dd").parse("2000-01-01");
    final Date JAN_01_2001 = new SimpleDateFormat("yyyy-MM-dd").parse("2001-01-01");
    final OperationChain<Iterable<? extends String>> opChain = new OperationChain.Builder().first(new GetAdjacentIds.Builder().input(new EntitySeed("South West")).view(new View.Builder().edge("RegionContainsLocation").build()).build()).then(new GetAdjacentIds.Builder().view(new View.Builder().edge("LocationContainsRoad").build()).build()).then(new ToSet<>()).then(new GetAdjacentIds.Builder().view(new View.Builder().edge("RoadHasJunction").build()).build()).then(new GetElements.Builder().view(new View.Builder().globalElements(new GlobalViewElementDefinition.Builder().groupBy().build()).entity("JunctionUse", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("startDate").execute(new IsMoreThan(JAN_01_2000, true)).select("endDate").execute(new IsLessThan(JAN_01_2001, false)).build()).postAggregationFilter(new ElementFilter.Builder().select("countByVehicleType").execute(new PredicateMap<>("BUS", new IsMoreThan(1000L))).build()).transientProperty("busCount", Long.class).transformer(new ElementTransformer.Builder().select("countByVehicleType").execute(new FreqMapExtractor("BUS")).project("busCount").build()).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build()).then(new ToCsv.Builder().generator(new CsvGenerator.Builder().vertex("Junction").property("busCount", "Bus Count").build()).build()).build();
    Set<String> resultSet = new HashSet<>();
    final Iterable<? extends String> results = this.graph.execute(opChain, this.user);
    for (final String r : results) {
        resultSet.add(r);
    }
    assertEquals(SW_ROAD_JUNCTIONS_WITH_HEAVY_BUS_USAGE_IN_2000, resultSet);
}
Also used : CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) PredicateMap(uk.gov.gchq.koryphe.predicate.PredicateMap) GlobalViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.GlobalViewElementDefinition) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) GlobalViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.GlobalViewElementDefinition) IsLessThan(uk.gov.gchq.koryphe.impl.predicate.IsLessThan) HashSet(java.util.HashSet) FreqMapExtractor(uk.gov.gchq.gaffer.types.function.FreqMapExtractor) CsvGenerator(uk.gov.gchq.gaffer.data.generator.CsvGenerator) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Date(java.util.Date) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.jupiter.api.Test)

Example 64 with IsMoreThan

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

the class GetWalksIT method shouldGetPartialPaths.

@Test
@TraitRequirement(StoreTrait.POST_AGGREGATION_FILTERING)
public void shouldGetPartialPaths() throws Exception {
    // Given
    final GetElements operation = new GetElements.Builder().directedType(DirectedType.DIRECTED).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().properties(TestPropertyNames.COUNT).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build();
    final OperationChain operationChain = new OperationChain.Builder().first(new GetElements.Builder().view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().postAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new IsMoreThan(3)).build()).build()).build()).build()).then(operation).build();
    final GetWalks op = new GetWalks.Builder().input(seedA).operations(operation, operationChain).includePartial().build();
    // When
    final Iterable<Walk> results = graph.execute(op, getUser());
    // Then
    assertThat(getPaths(results)).isEqualTo("AED,AB");
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 65 with IsMoreThan

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

the class GetWalksIT method shouldReturnNoResultsWhenNoEntityResults.

@Test
public void shouldReturnNoResultsWhenNoEntityResults() throws Exception {
    // Given
    final GetWalks op = new GetWalks.Builder().input(seedA).operations(new GetElements.Builder().view(new View.Builder().edge(TestGroups.EDGE).build()).build(), new OperationChain.Builder().first(new GetElements.Builder().view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.INT).execute(new IsMoreThan(10000)).build()).build()).build()).build()).then(new GetElements()).build()).build();
    // When
    final Iterable<Walk> results = graph.execute(op, getUser());
    // Then
    assertThat(Lists.newArrayList(results)).isEmpty();
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Test(org.junit.Test)

Aggregations

IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)72 Test (org.junit.jupiter.api.Test)42 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)40 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)34 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)24 Element (uk.gov.gchq.gaffer.data.element.Element)22 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)22 Edge (uk.gov.gchq.gaffer.data.element.Edge)20 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)20 User (uk.gov.gchq.gaffer.user.User)20 Graph (uk.gov.gchq.gaffer.graph.Graph)19 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)19 ArrayList (java.util.ArrayList)18 HashSet (java.util.HashSet)16 Entity (uk.gov.gchq.gaffer.data.element.Entity)16 IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)13 IsLessThan (uk.gov.gchq.koryphe.impl.predicate.IsLessThan)13 Set (java.util.Set)12 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)12 OperationException (uk.gov.gchq.gaffer.operation.OperationException)12