Search in sources :

Example 46 with ElementId

use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.

the class GetElementsIT method shouldGetRelatedElements.

private void shouldGetRelatedElements(final boolean includeEntities, final boolean includeEdges, final DirectedType directedType, final IncludeIncomingOutgoingType inOutType) throws Exception {
    final Set<ElementId> expectedElementIds = new HashSet<>();
    final Set<Element> expectedElements = new HashSet<>();
    if (includeEntities) {
        for (final Object identifier : ALL_SEED_VERTICES) {
            final EntityId entityId = new EntitySeed(identifier);
            expectedElementIds.add(entityId);
        }
    }
    if (includeEdges) {
        expectedElementIds.addAll(EDGE_SEEDS_BOTH);
        if (DirectedType.UNDIRECTED != directedType) {
            expectedElementIds.add(new EdgeSeed(SOURCE_DIR_1, DEST_DIR_1, true));
            if (null == inOutType || IncludeIncomingOutgoingType.EITHER == inOutType || IncludeIncomingOutgoingType.OUTGOING == inOutType) {
                expectedElementIds.add(new EdgeSeed(SOURCE_DIR_2, DEST_DIR_2, true));
            }
            if (null == inOutType || IncludeIncomingOutgoingType.EITHER == inOutType || IncludeIncomingOutgoingType.INCOMING == inOutType) {
                expectedElementIds.add(new EdgeSeed(SOURCE_DIR_3, DEST_DIR_3, true, EdgeId.MatchedVertex.DESTINATION));
            }
        }
        if (DirectedType.DIRECTED != directedType) {
            expectedElementIds.add(new EdgeSeed(SOURCE_1, DEST_1, false));
            expectedElementIds.add(new EdgeSeed(SOURCE_2, DEST_2, false));
            expectedElementIds.add(new EdgeSeed(SOURCE_3, DEST_3, false, EdgeId.MatchedVertex.DESTINATION));
        }
    }
    expectedElements.addAll(getElements(expectedElementIds, null));
    if (DirectedType.DIRECTED == directedType) {
        expectedElements.removeIf(e -> e instanceof Edge && ((Edge) e).isUndirected());
    }
    if (DirectedType.UNDIRECTED == directedType) {
        expectedElements.removeIf(e -> e instanceof Edge && ((Edge) e).isDirected());
    }
    shouldGetElements(expectedElements, SeedMatchingType.RELATED, directedType, includeEntities, includeEdges, inOutType, ALL_SEEDS);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) Element(uk.gov.gchq.gaffer.data.element.Element) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) HashSet(java.util.HashSet)

Example 47 with ElementId

use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.

the class ExamplesService method getRelatedElements.

@Override
public GetElements getRelatedElements() {
    final GetElements op = new GetElements();
    final List<ElementId> seeds = new ArrayList<>();
    if (hasEntities()) {
        seeds.add(getEntityId(1));
    } else if (hasEdges()) {
        seeds.add(new EntitySeed(getEdgeId(1, 2).getSource()));
    }
    if (hasEdges()) {
        seeds.add(getEdgeId(1, 2));
    }
    op.setInput(seeds);
    populateOperation(op);
    return op;
}
Also used : ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId)

Example 48 with ElementId

use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.

the class ExamplesService method getElements.

@Override
public GetElements getElements() {
    final GetElements op = new GetElements();
    final List<ElementId> seeds = new ArrayList<>();
    if (hasEntities()) {
        seeds.add(getEntityId(1));
    } else if (hasEdges()) {
        seeds.add(new EntitySeed(getEdgeId(1, 2).getSource()));
    }
    if (hasEdges()) {
        seeds.add(getEdgeId(1, 2));
    }
    op.setInput(seeds);
    populateOperation(op);
    return op;
}
Also used : ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId)

Example 49 with ElementId

use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.

the class ExamplesService method getElementsBySeed.

@Override
public GetElements getElementsBySeed() {
    final GetElements op = new GetElements();
    final List<ElementId> seeds = new ArrayList<>();
    if (hasEntities()) {
        seeds.add(getEntityId(1));
    }
    if (hasEdges()) {
        seeds.add(getEdgeId(1, 2));
    }
    op.setInput(seeds);
    populateOperation(op);
    return op;
}
Also used : ArrayList(java.util.ArrayList) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId)

Example 50 with ElementId

use of uk.gov.gchq.gaffer.data.element.id.ElementId in project Gaffer by gchq.

the class AbstractExamplesFactoryTest method shouldUseSchemaToCreateGetAdjacentIdsInput.

@Test
public void shouldUseSchemaToCreateGetAdjacentIdsInput() throws InstantiationException, IllegalAccessException {
    // Given
    TestExamplesFactory examplesFactory = new TestExamplesFactory(SCHEMA);
    // When
    GetAdjacentIds operation = (GetAdjacentIds) examplesFactory.generateExample(GetAdjacentIds.class);
    // Then
    int size = 0;
    for (ElementId e : operation.getInput()) {
        size++;
        if (e instanceof EntityId) {
            assertEquals(String.class, ((EntityId) e).getVertex().getClass());
        } else {
            throw new RuntimeException("Expected operation only to contain entity ids");
        }
    }
    assertEquals(1, size);
}
Also used : EntityId(uk.gov.gchq.gaffer.data.element.id.EntityId) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Aggregations

ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)58 Test (org.junit.jupiter.api.Test)32 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)29 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)19 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)19 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)17 Edge (uk.gov.gchq.gaffer.data.element.Edge)14 Element (uk.gov.gchq.gaffer.data.element.Element)14 EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)14 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)14 HashSet (java.util.HashSet)11 Entity (uk.gov.gchq.gaffer.data.element.Entity)9 User (uk.gov.gchq.gaffer.user.User)9 ArrayList (java.util.ArrayList)7 IteratorSettingException (uk.gov.gchq.gaffer.accumulostore.key.exception.IteratorSettingException)7 OperationTest (uk.gov.gchq.gaffer.operation.OperationTest)7 Test (org.junit.Test)6 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)6 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)5 Key (org.apache.accumulo.core.data.Key)4