Search in sources :

Example 1 with Builder

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.

the class AbstractLoaderIT method shouldGetElementsWithMatchedVertex.

@TraitRequirement({ StoreTrait.MATCHED_VERTEX, StoreTrait.QUERY_AGGREGATION })
@Test
public void shouldGetElementsWithMatchedVertex() throws Exception {
    // Then
    final View view = new Builder().edge(TestGroups.EDGE).build();
    final GetElements op = new GetElements.Builder().input(new EntitySeed(SOURCE_DIR_1), new EntitySeed(DEST_DIR_2), new EntitySeed(SOURCE_DIR_3)).view(view).build();
    final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
    assertElementEquals(getQuerySummarisedEdges(view).stream().filter(Edge::isDirected).filter(edge -> {
        final List<String> vertices = Lists.newArrayList(SOURCE_DIR_1, SOURCE_DIR_2, SOURCE_DIR_3);
        return vertices.contains(edge.getMatchedVertexValue());
    }).collect(toList()), results);
}
Also used : Builder(uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 2 with Builder

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.

the class AbstractLoaderIT method shouldGetElementsWithMatchedVertexFilter.

@TraitRequirement({ StoreTrait.MATCHED_VERTEX, StoreTrait.QUERY_AGGREGATION })
@Test
public void shouldGetElementsWithMatchedVertexFilter() throws Exception {
    // Then
    final View view = new Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(IdentifierType.ADJACENT_MATCHED_VERTEX.name()).execute(new IsIn(DEST_DIR_1, DEST_DIR_2, DEST_DIR_3)).build()).build()).build();
    final GetElements op = new GetElements.Builder().input(new EntitySeed(SOURCE_DIR_1), new EntitySeed(DEST_DIR_2), new EntitySeed(SOURCE_DIR_3)).view(view).build();
    // When
    final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
    // Then
    assertElementEquals(getQuerySummarisedEdges(view).stream().filter(Edge::isDirected).filter(edge -> {
        final List<String> vertices = Lists.newArrayList(SOURCE_DIR_1, DEST_DIR_2, SOURCE_DIR_3);
        return vertices.contains(edge.getMatchedVertexValue());
    }).filter(edge -> {
        final List<String> vertices = Lists.newArrayList(DEST_DIR_1, DEST_DIR_2, DEST_DIR_3);
        return vertices.contains(edge.getAdjacentMatchedVertexValue());
    }).collect(toList()), results);
}
Also used : Iterables(com.google.common.collect.Iterables) Arrays(java.util.Arrays) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Element(uk.gov.gchq.gaffer.data.element.Element) ArrayList(java.util.ArrayList) JsonUtil(uk.gov.gchq.gaffer.commonutil.JsonUtil) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Lists(com.google.common.collect.Lists) ElementUtil.assertElementEquals(uk.gov.gchq.gaffer.data.util.ElementUtil.assertElementEquals) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Builder(uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder) Edge(uk.gov.gchq.gaffer.data.element.Edge) TestGroups(uk.gov.gchq.gaffer.commonutil.TestGroups) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) DirectedType(uk.gov.gchq.gaffer.data.element.id.DirectedType) IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn) TestPropertyNames(uk.gov.gchq.gaffer.commonutil.TestPropertyNames) EmptyClosableIterable(uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable) Test(org.junit.Test) Entity(uk.gov.gchq.gaffer.data.element.Entity) Collectors(java.util.stream.Collectors) AbstractStoreIT(uk.gov.gchq.gaffer.integration.AbstractStoreIT) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement) VisibilityUser(uk.gov.gchq.gaffer.integration.VisibilityUser) Consumer(java.util.function.Consumer) IdentifierType(uk.gov.gchq.gaffer.data.element.IdentifierType) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Operation(uk.gov.gchq.gaffer.operation.Operation) Schema(uk.gov.gchq.gaffer.store.schema.Schema) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) OperationException(uk.gov.gchq.gaffer.operation.OperationException) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Builder(uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 3 with Builder

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.

the class AbstractStoreIT method getQuerySummarisedEntities.

public List<Entity> getQuerySummarisedEntities() {
    final Schema schema = null != graph ? graph.getSchema() : getStoreSchema();
    final View view = new Builder().entities(schema.getEntityGroups()).edges(schema.getEdgeGroups()).build();
    return getQuerySummarisedEntities(view);
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) Builder(uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View)

Example 4 with Builder

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.

the class AbstractStoreIT method getQuerySummarisedEdges.

public List<Edge> getQuerySummarisedEdges() {
    final Schema schema = null != graph ? graph.getSchema() : getStoreSchema();
    final View view = new Builder().entities(schema.getEntityGroups()).edges(schema.getEdgeGroups()).build();
    return getQuerySummarisedEdges(view);
}
Also used : Schema(uk.gov.gchq.gaffer.store.schema.Schema) Builder(uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View)

Example 5 with Builder

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder in project Gaffer by gchq.

the class AbstractLoaderIT method shouldGetAllElementsWithExcludedProperties.

@Test
@TraitRequirement(StoreTrait.QUERY_AGGREGATION)
public void shouldGetAllElementsWithExcludedProperties() throws Exception {
    // Given
    final View view = new Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().excludeProperties(TestPropertyNames.COUNT).build()).build();
    final GetAllElements op = new GetAllElements.Builder().view(view).build();
    final CloseableIterable<? extends Element> results = graph.execute(op, getUser());
    // When
    final List<Element> expected = getQuerySummarisedEdges(view).stream().map(edge -> {
        edge.getProperties().remove(TestPropertyNames.COUNT);
        return edge;
    }).collect(toList());
    // Then
    assertElementEquals(expected, results);
}
Also used : Iterables(com.google.common.collect.Iterables) Arrays(java.util.Arrays) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Element(uk.gov.gchq.gaffer.data.element.Element) ArrayList(java.util.ArrayList) JsonUtil(uk.gov.gchq.gaffer.commonutil.JsonUtil) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Lists(com.google.common.collect.Lists) ElementUtil.assertElementEquals(uk.gov.gchq.gaffer.data.util.ElementUtil.assertElementEquals) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Builder(uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder) Edge(uk.gov.gchq.gaffer.data.element.Edge) TestGroups(uk.gov.gchq.gaffer.commonutil.TestGroups) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) DirectedType(uk.gov.gchq.gaffer.data.element.id.DirectedType) IsIn(uk.gov.gchq.koryphe.impl.predicate.IsIn) TestPropertyNames(uk.gov.gchq.gaffer.commonutil.TestPropertyNames) EmptyClosableIterable(uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable) Test(org.junit.Test) Entity(uk.gov.gchq.gaffer.data.element.Entity) Collectors(java.util.stream.Collectors) AbstractStoreIT(uk.gov.gchq.gaffer.integration.AbstractStoreIT) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement) VisibilityUser(uk.gov.gchq.gaffer.integration.VisibilityUser) Consumer(java.util.function.Consumer) IdentifierType(uk.gov.gchq.gaffer.data.element.IdentifierType) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Operation(uk.gov.gchq.gaffer.operation.Operation) Schema(uk.gov.gchq.gaffer.store.schema.Schema) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) OperationException(uk.gov.gchq.gaffer.operation.OperationException) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Builder(uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder) Element(uk.gov.gchq.gaffer.data.element.Element) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Aggregations

View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)5 Builder (uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder)5 Schema (uk.gov.gchq.gaffer.store.schema.Schema)4 Test (org.junit.Test)3 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)3 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)3 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)3 Iterables (com.google.common.collect.Iterables)2 Lists (com.google.common.collect.Lists)2 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 Collectors (java.util.stream.Collectors)2 Collectors.toList (java.util.stream.Collectors.toList)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 JsonUtil (uk.gov.gchq.gaffer.commonutil.JsonUtil)2 TestGroups (uk.gov.gchq.gaffer.commonutil.TestGroups)2 TestPropertyNames (uk.gov.gchq.gaffer.commonutil.TestPropertyNames)2 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)2