Search in sources :

Example 81 with View

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

the class ProxyStoreBasicIT method shouldAddElementsViaAJob.

@Test
public void shouldAddElementsViaAJob() throws Exception {
    // Add elements
    final AddElements add = new AddElements.Builder().elements(DEFAULT_ELEMENTS).build();
    JobDetail jobDetail = graph.executeJob(new OperationChain<>(add), USER);
    // Wait until the job status is not RUNNING
    while (JobStatus.RUNNING.equals(jobDetail.getStatus())) {
        jobDetail = graph.execute(new GetJobDetails.Builder().jobId(jobDetail.getJobId()).build(), USER);
        Thread.sleep(100);
    }
    // Get elements
    final GetElements<EntitySeed, Element> getElements = new GetElements.Builder<EntitySeed, Element>().view(new View.Builder().entity(TestGroups.ENTITY).build()).addSeed(new EntitySeed("1")).build();
    CloseableIterable<Element> results = graph.execute(getElements, USER);
    // Then
    assertEquals(2, Iterables.size(results));
    assertThat(results, hasItem(DEFAULT_ELEMENTS[0]));
    assertThat(results, hasItem(DEFAULT_ELEMENTS[2]));
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) JobDetail(uk.gov.gchq.gaffer.jobtracker.JobDetail) 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) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Example 82 with View

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

the class BloomFilter18IT method seek.

private void seek(final FileSKVIterator reader, final EntitySeed seed, final RangeFactory rangeFactory) throws IOException, RangeFactoryException {
    final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
    final GetElements<ElementSeed, ?> operation = new GetElements<>(view);
    final List<Range> range = rangeFactory.getRange(seed, operation);
    for (final Range ran : range) {
        reader.seek(ran, new ArrayList<ByteSequence>(), false);
    }
}
Also used : GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) Range(org.apache.accumulo.core.data.Range) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ByteSequence(org.apache.accumulo.core.data.ByteSequence)

Example 83 with View

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

the class BloomFilterIT method seek.

private void seek(final FileSKVIterator reader, final EntitySeed seed, final RangeFactory rangeFactory) throws IOException, RangeFactoryException {
    final View view = new View.Builder().edge(TestGroups.EDGE).entity(TestGroups.ENTITY).build();
    final GetElements<ElementSeed, ?> operation = new GetElements<>(view);
    final List<Range> range = rangeFactory.getRange(seed, operation);
    for (final Range ran : range) {
        reader.seek(ran, new ArrayList<ByteSequence>(), false);
    }
}
Also used : GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ElementSeed(uk.gov.gchq.gaffer.operation.data.ElementSeed) Range(org.apache.accumulo.core.data.Range) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ByteSequence(org.apache.accumulo.core.data.ByteSequence)

Example 84 with View

use of uk.gov.gchq.gaffer.data.elementdefinition.view.View 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 85 with View

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

the class StoreTest method shouldThrowExceptionIfOperationViewIsInvalid.

@Test
public void shouldThrowExceptionIfOperationViewIsInvalid() throws OperationException, StoreException {
    // Given
    // Given
    final Schema schema = createSchemaMock();
    final StoreProperties properties = mock(StoreProperties.class);
    final AddElements addElements = new AddElements();
    final View view = mock(View.class);
    final ViewValidator viewValidator = mock(ViewValidator.class);
    final StoreImpl store = new StoreImpl(viewValidator);
    addElements.setView(view);
    given(schema.validate()).willReturn(true);
    given(viewValidator.validate(view, schema, true)).willReturn(false);
    store.initialise(schema, properties);
    // When / Then
    try {
        store.execute(addElements, user);
        fail("Exception expected");
    } catch (final SchemaException e) {
        verify(viewValidator).validate(view, schema, true);
        assertTrue(e.getMessage().contains("View"));
    }
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) SchemaException(uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException) ViewValidator(uk.gov.gchq.gaffer.store.schema.ViewValidator) Schema(uk.gov.gchq.gaffer.store.schema.Schema) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.Test)

Aggregations

View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)107 Test (org.junit.Test)70 Element (uk.gov.gchq.gaffer.data.element.Element)42 User (uk.gov.gchq.gaffer.user.User)38 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)32 HashSet (java.util.HashSet)29 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)28 Graph (uk.gov.gchq.gaffer.graph.Graph)20 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)19 ArrayList (java.util.ArrayList)16 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)14 Edge (uk.gov.gchq.gaffer.data.element.Edge)13 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)13 Schema (uk.gov.gchq.gaffer.store.schema.Schema)13 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)12 IsLessThan (uk.gov.gchq.gaffer.function.filter.IsLessThan)11 SQLContext (org.apache.spark.sql.SQLContext)10 ExampleTransformFunction (uk.gov.gchq.gaffer.function.ExampleTransformFunction)9 IsMoreThan (uk.gov.gchq.gaffer.function.filter.IsMoreThan)9 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)8