Search in sources :

Example 16 with EdgeId

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

the class VisibilitySchemaLoader method createEdges.

@Override
public Map<EdgeId, Edge> createEdges() {
    final Map<EdgeId, Edge> edges = new HashMap<>();
    for (int i = 0; i <= 10; i++) {
        for (int j = 0; j < VERTEX_PREFIXES.length; j++) {
            final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(VERTEX_PREFIXES[0] + i).dest(VERTEX_PREFIXES[j] + i).directed(false).property(TestPropertyNames.COUNT, 1L).property(TestPropertyNames.VISIBILITY, "public").build();
            addToMap(edge, edges);
            final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(VERTEX_PREFIXES[0] + i).dest(VERTEX_PREFIXES[j] + i).directed(true).property(TestPropertyNames.COUNT, 1L).property(TestPropertyNames.VISIBILITY, "private").build();
            addToMap(edgeDir, edges);
        }
        final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source(SOURCE + i).dest(DEST + i).directed(false).property(TestPropertyNames.COUNT, 1L).property(TestPropertyNames.VISIBILITY, "private").build();
        addToMap(edge, edges);
        final Edge edgeDir = new Edge.Builder().group(TestGroups.EDGE).source(SOURCE_DIR + i).dest(DEST_DIR + i).directed(true).property(TestPropertyNames.COUNT, 1L).property(TestPropertyNames.VISIBILITY, "public").build();
        addToMap(edgeDir, edges);
    }
    return edges;
}
Also used : HashMap(java.util.HashMap) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Edge(uk.gov.gchq.gaffer.data.element.Edge)

Example 17 with EdgeId

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

the class AccumuloEdgeValueLoader method loadIdentifiers.

@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "element provided should always be an Edge")
@Override
public void loadIdentifiers(final Element edge) {
    final EdgeId edgeId = (EdgeId) elementConverter.getElementId(key, includeMatchedVertex);
    ((Edge) edge).setIdentifiers(edgeId.getSource(), edgeId.getDestination(), edgeId.isDirected(), edgeId.getMatchedVertex());
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) Edge(uk.gov.gchq.gaffer.data.element.Edge) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 18 with EdgeId

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

the class GetAdjacentIdsDeletedElementsIT method assertElements.

@Override
protected void assertElements(final Iterable<ElementId> expected, final CloseableIterable<? extends EntityId> actual) {
    final List<ElementId> expectedIds = new ArrayList<>();
    for (final ElementId element : expected) {
        if (element instanceof EdgeId) {
            expectedIds.add(new EntitySeed(((EdgeId) element).getDestination()));
        }
    }
    super.assertElements(expectedIds, actual);
}
Also used : EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) ArrayList(java.util.ArrayList) EntitySeed(uk.gov.gchq.gaffer.operation.data.EntitySeed) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId)

Example 19 with EdgeId

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

the class AbstractAccumuloElementConverterTest method shouldDeserialiseEdgeIdWithQueriedDestVertex.

@Test
public void shouldDeserialiseEdgeIdWithQueriedDestVertex() {
    // Given
    final EdgeId expectedElementId = new EdgeSeed("vertex1", "vertex2", true, EdgeId.MatchedVertex.DESTINATION);
    final Edge edge = new Edge.Builder().source("vertex1").dest("vertex2").directed(true).group(TestGroups.ENTITY).property(TestPropertyNames.PROP_1, new FreqMap()).property(TestPropertyNames.PROP_2, new FreqMap()).build();
    final Key key = converter.getKeysFromEdge(edge).getSecond();
    // When
    final ElementId elementId = converter.getElementId(key, false);
    // Then
    assertEquals(expectedElementId, elementId);
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Example 20 with EdgeId

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

the class AbstractAccumuloElementConverterTest method shouldDeserialiseEdgeIdWithQueriedSourceVertex.

@Test
public void shouldDeserialiseEdgeIdWithQueriedSourceVertex() {
    // Given
    final EdgeId expectedElementId = new EdgeSeed("source1", "dest1", true);
    final Edge edge = new Edge.Builder().source("source1").dest("dest1").directed(true).group(TestGroups.ENTITY).property(TestPropertyNames.PROP_1, new FreqMap()).property(TestPropertyNames.PROP_2, new FreqMap()).build();
    final Key key = converter.getKeysFromEdge(edge).getSecond();
    // When
    final ElementId elementId = converter.getElementId(key, false);
    // Then
    assertEquals(expectedElementId, elementId);
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) EdgeId(uk.gov.gchq.gaffer.data.element.id.EdgeId) EdgeSeed(uk.gov.gchq.gaffer.operation.data.EdgeSeed) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) ElementId(uk.gov.gchq.gaffer.data.element.id.ElementId) Test(org.junit.jupiter.api.Test)

Aggregations

EdgeId (uk.gov.gchq.gaffer.data.element.id.EdgeId)40 Test (org.junit.jupiter.api.Test)27 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)18 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)15 Edge (uk.gov.gchq.gaffer.data.element.Edge)14 ElementId (uk.gov.gchq.gaffer.data.element.id.ElementId)14 EdgeSeed (uk.gov.gchq.gaffer.operation.data.EdgeSeed)8 HashMap (java.util.HashMap)5 Key (org.apache.accumulo.core.data.Key)4 FreqMap (uk.gov.gchq.gaffer.types.FreqMap)4 ArrayList (java.util.ArrayList)3 DirectedType (uk.gov.gchq.gaffer.data.element.id.DirectedType)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 HashSet (java.util.HashSet)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 Entity (uk.gov.gchq.gaffer.data.element.Entity)2 SeedMatching (uk.gov.gchq.gaffer.operation.SeedMatching)2 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)2 Schema (uk.gov.gchq.gaffer.store.schema.Schema)2 Collection (java.util.Collection)1