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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations