Search in sources :

Example 16 with GetElements

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

the class OperationChainTest method shouldBuildOperationChain.

@Test
public void shouldBuildOperationChain() {
    // Given
    final AddElements addElements = mock(AddElements.class);
    final GetElements getAdj1 = mock(GetElements.class);
    final GetElements getAdj2 = mock(GetElements.class);
    final GetElements<EntitySeed, Element> getRelElements = mock(GetElements.class);
    // When
    final OperationChain<CloseableIterable<Element>> opChain = new Builder().first(addElements).then(getAdj1).then(getAdj2).then(getRelElements).build();
    // Then
    assertArrayEquals(new Operation[] { addElements, getAdj1, getAdj2, getRelElements }, opChain.getOperationArray());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Test(org.junit.Test)

Example 17 with GetElements

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

the class OperationChainTest method shouldReturnReadableStringForToString.

@Test
public void shouldReturnReadableStringForToString() {
    // Given
    final AddElements addElements = new AddElements();
    final GetAdjacentEntitySeeds getAdj1 = new GetAdjacentEntitySeeds();
    final GetAdjacentEntitySeeds getAdj2 = new GetAdjacentEntitySeeds();
    final GetElements<EntitySeed, Element> getRelElements = new GetElements<>();
    final OperationChain<CloseableIterable<Element>> opChain = new Builder().first(addElements).then(getAdj1).then(getAdj2).then(getRelElements).build();
    // When
    final String toString = opChain.toString();
    // Then
    final String expectedToString = "OperationChain[AddElements->GetAdjacentEntitySeeds->GetAdjacentEntitySeeds->GetElements]";
    assertEquals(expectedToString, toString);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) GetAdjacentEntitySeeds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds) CloseableIterable(uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Test(org.junit.Test)

Example 18 with GetElements

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

the class AddNamedOperationHandlerTest method shouldNotAllowUpdateToNamedOperationIfItCausesRecursion.

@Test
public void shouldNotAllowUpdateToNamedOperationIfItCausesRecursion() throws OperationException {
    String innocentOpName = "innocent";
    OperationChain innocent = new OperationChain.Builder().first(new GetElements<>()).build();
    addNamedOperation.setOperationName(innocentOpName);
    addNamedOperation.setOperationChain(innocent);
    handler.doOperation(addNamedOperation, context, store);
    OperationChain parent = new OperationChain.Builder().first(new NamedOperation(innocentOpName, "call down to currently innocent named op")).build();
    addNamedOperation.setOperationChain(parent);
    addNamedOperation.setOperationName(OPERATION_NAME);
    handler.doOperation(addNamedOperation, context, store);
    OperationChain recursive = new OperationChain.Builder().first(new NamedOperation(OPERATION_NAME, "")).build();
    addNamedOperation.setOperationName(innocentOpName);
    addNamedOperation.setOperationChain(recursive);
    addNamedOperation.setOverwriteFlag(true);
    exception.expect(OperationException.class);
    handler.doOperation(addNamedOperation, context, store);
}
Also used : OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) AddNamedOperation(uk.gov.gchq.gaffer.named.operation.AddNamedOperation) ExtendedNamedOperation(uk.gov.gchq.gaffer.named.operation.ExtendedNamedOperation) NamedOperation(uk.gov.gchq.gaffer.named.operation.NamedOperation) Test(org.junit.Test)

Example 19 with GetElements

use of uk.gov.gchq.gaffer.operation.impl.get.GetElements 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 20 with GetElements

use of uk.gov.gchq.gaffer.operation.impl.get.GetElements 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)

Aggregations

GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)28 Element (uk.gov.gchq.gaffer.data.element.Element)19 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)19 User (uk.gov.gchq.gaffer.user.User)16 HashSet (java.util.HashSet)15 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)14 Test (org.junit.Test)12 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)12 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)8 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)7 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)5 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)4 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)4 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)3 Edge (uk.gov.gchq.gaffer.data.element.Edge)3 Entity (uk.gov.gchq.gaffer.data.element.Entity)3 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)3 GetAdjacentEntitySeeds (uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentEntitySeeds)3 ByteSequence (org.apache.accumulo.core.data.ByteSequence)2 Range (org.apache.accumulo.core.data.Range)2