Search in sources :

Example 11 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class TransformationIT method shouldCreateTransientEntityProperty.

@Test
@TraitRequirement(StoreTrait.TRANSFORMATION)
public void shouldCreateTransientEntityProperty() throws OperationException {
    // Given
    final GetEntities<EntitySeed> getEntities = new GetEntities.Builder<EntitySeed>().addSeed(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.STRING).execute(new Concat()).project(TestPropertyNames.TRANSIENT_1).build()).build()).build()).build();
    // When
    final List<Entity> results = Lists.newArrayList(graph.execute(getEntities, getUser()));
    assertNotNull(results);
    assertEquals(1, results.size());
    for (final Entity result : results) {
        assertEquals("A1,3", result.getProperty(TestPropertyNames.TRANSIENT_1));
    }
}
Also used : Concat(uk.gov.gchq.gaffer.function.transform.Concat) Entity(uk.gov.gchq.gaffer.data.element.Entity) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test) TraitRequirement(uk.gov.gchq.gaffer.integration.TraitRequirement)

Example 12 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class AccumuloAggregationIT method shouldOnlyAggregateVisibilityWhenGroupByIsNull.

@Test
public void shouldOnlyAggregateVisibilityWhenGroupByIsNull() throws OperationException, UnsupportedEncodingException {
    final Graph graph = createGraph();
    final Entity entity1 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "value 3a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "value 4").property(AccumuloPropertyNames.VISIBILITY, PUBLIC_VISIBILITY).build();
    final Entity entity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "value 3a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "value 4").property(AccumuloPropertyNames.VISIBILITY, PRIVATE_VISIBILITY).build();
    final Entity entity3 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "value 3b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "value 4").property(AccumuloPropertyNames.VISIBILITY, PRIVATE_VISIBILITY).build();
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2, entity3)), USER);
    // Given
    final GetEntities<EntitySeed> getElements = new GetEntities.Builder<EntitySeed>().addSeed(new EntitySeed(VERTEX)).view(new View()).build();
    // When
    final List<Entity> results = Lists.newArrayList(graph.execute(getElements, USER));
    // Then
    assertNotNull(results);
    assertEquals(2, results.size());
    final Entity expectedSummarisedEntity = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "value 3a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "value 4").property(AccumuloPropertyNames.VISIBILITY, PRIVATE_VISIBILITY + "," + PUBLIC_VISIBILITY).build();
    assertThat(results, IsCollectionContaining.hasItems(expectedSummarisedEntity, entity3));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test)

Example 13 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class AccumuloAggregationIT method shouldHandleAggregatationWithMultipleCombinations.

@Test
public void shouldHandleAggregatationWithMultipleCombinations() throws OperationException, UnsupportedEncodingException {
    final Graph graph = createGraphNoVisibility();
    final Entity entity1 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity entity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, null).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity entity3 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity entity4 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity entity5 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1a").build();
    final Entity entity6 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1b").build();
    final Entity entity7 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "test2a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").build();
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2, entity3, entity4, entity5, entity6, entity7)), USER);
    // Duplicate the entities to check they are aggregated properly
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2, entity3, entity4, entity5, entity6, entity7)), USER);
    // Given
    final GetEntities<EntitySeed> getElements = new GetEntities.Builder<EntitySeed>().addSeed(new EntitySeed(VERTEX)).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy(AccumuloPropertyNames.COLUMN_QUALIFIER, AccumuloPropertyNames.COLUMN_QUALIFIER_2).build()).build()).build();
    // When
    final List<Entity> results = Lists.newArrayList(graph.execute(getElements, USER));
    // Then
    assertNotNull(results);
    assertEquals(4, results.size());
    final Entity expectedEntity1 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity expectedEntity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity expectedEntity3 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "test1b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "test 4").build();
    final Entity expectedEntity4 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "test2a").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "test 3").build();
    assertThat(results, IsCollectionContaining.hasItems(expectedEntity1, expectedEntity2, expectedEntity3, expectedEntity4));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test)

Example 14 with GetEntities

use of uk.gov.gchq.gaffer.operation.impl.get.GetEntities in project Gaffer by gchq.

the class AccumuloAggregationIT method shouldAggregateOverAllPropertiesExceptForGroupByProperties.

@Test
public void shouldAggregateOverAllPropertiesExceptForGroupByProperties() throws OperationException, UnsupportedEncodingException {
    final Graph graph = createGraph();
    final Entity entity1 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "some value").property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "some value 2").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "some value 3").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "some value 4").property(AccumuloPropertyNames.VISIBILITY, PUBLIC_VISIBILITY).build();
    final Entity entity2 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "some value").property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "some value 2b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "some value 3b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "some value 4b").property(AccumuloPropertyNames.VISIBILITY, PRIVATE_VISIBILITY).build();
    final Entity entity3 = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "some value c").property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "some value 2c").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "some value 3c").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "some value 4c").property(AccumuloPropertyNames.VISIBILITY, PRIVATE_VISIBILITY).build();
    graph.execute(new AddElements(Arrays.asList((Element) entity1, entity2, entity3)), USER);
    // Given
    final GetEntities<EntitySeed> getElements = new GetEntities.Builder<EntitySeed>().addSeed(new EntitySeed(VERTEX)).view(new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().groupBy(AccumuloPropertyNames.COLUMN_QUALIFIER).build()).build()).build();
    // When
    final List<Entity> results = Lists.newArrayList(graph.execute(getElements, USER));
    // Then
    assertNotNull(results);
    assertEquals(2, results.size());
    final Entity expectedEntity = new Entity.Builder().vertex(VERTEX).group(TestGroups.ENTITY).property(AccumuloPropertyNames.COLUMN_QUALIFIER, "some value").property(AccumuloPropertyNames.COLUMN_QUALIFIER_2, "some value 2,some value 2b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_3, "some value 3,some value 3b").property(AccumuloPropertyNames.COLUMN_QUALIFIER_4, "some value 4,some value 4b").property(AccumuloPropertyNames.VISIBILITY, PUBLIC_VISIBILITY + "," + PRIVATE_VISIBILITY).build();
    assertThat(results, IsCollectionContaining.hasItems(expectedEntity, entity3));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Entity(uk.gov.gchq.gaffer.data.element.Entity) Graph(uk.gov.gchq.gaffer.graph.Graph) Builder(uk.gov.gchq.gaffer.graph.Graph.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetEntities(uk.gov.gchq.gaffer.operation.impl.get.GetEntities) Test(org.junit.Test)

Aggregations

GetEntities (uk.gov.gchq.gaffer.operation.impl.get.GetEntities)14 Test (org.junit.Test)10 Entity (uk.gov.gchq.gaffer.data.element.Entity)9 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)9 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)8 Graph (uk.gov.gchq.gaffer.graph.Graph)7 Builder (uk.gov.gchq.gaffer.graph.Graph.Builder)6 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)3 ArrayList (java.util.ArrayList)2 Concat (uk.gov.gchq.gaffer.function.transform.Concat)2 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)2 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)2 User (uk.gov.gchq.gaffer.user.User)2 HyperLogLogPlus (com.clearspring.analytics.stream.cardinality.HyperLogLogPlus)1 ExpectedException (org.junit.rules.ExpectedException)1 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)1 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)1 DataGenerator9 (uk.gov.gchq.gaffer.example.gettingstarted.generator.DataGenerator9)1