Search in sources :

Example 1 with GetAllElements

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

the class ClassicIteratorSettingsFactory method getEdgeEntityDirectionFilterIteratorSetting.

@Override
public IteratorSetting getEdgeEntityDirectionFilterIteratorSetting(final GetElementsOperation<?, ?> operation) {
    final boolean includeEntities = operation.isIncludeEntities();
    final IncludeEdgeType includeEdgeType = operation.getIncludeEdges();
    final IncludeIncomingOutgoingType includeIncomingOutgoingType = operation.getIncludeIncomingOutGoing();
    final boolean deduplicateUndirectedEdges = operation instanceof GetAllElements;
    if (includeIncomingOutgoingType == IncludeIncomingOutgoingType.BOTH && includeEdgeType == IncludeEdgeType.ALL && !deduplicateUndirectedEdges) {
        return null;
    }
    return new IteratorSettingBuilder(AccumuloStoreConstants.EDGE_ENTITY_DIRECTED_UNDIRECTED_INCOMING_OUTGOING_FILTER_ITERATOR_PRIORITY, AccumuloStoreConstants.EDGE_ENTITY_DIRECTED_UNDIRECTED_INCOMING_OUTGOING_FILTER_ITERATOR_NAME, EDGE_DIRECTED_UNDIRECTED_FILTER).includeIncomingOutgoing(includeIncomingOutgoingType).includeEdges(includeEdgeType).includeEntities(includeEntities).deduplicateUndirectedEdges(deduplicateUndirectedEdges).build();
}
Also used : IncludeEdgeType(uk.gov.gchq.gaffer.operation.GetOperation.IncludeEdgeType) IncludeIncomingOutgoingType(uk.gov.gchq.gaffer.operation.GetOperation.IncludeIncomingOutgoingType) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) IteratorSettingBuilder(uk.gov.gchq.gaffer.accumulostore.utils.IteratorSettingBuilder)

Example 2 with GetAllElements

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

the class OperationServiceIT method shouldReturnChunkedElements.

@Test
public void shouldReturnChunkedElements() throws IOException {
    // Given
    RestApiTestUtil.addElements(DEFAULT_ELEMENTS);
    // When
    final Response response = RestApiTestUtil.executeOperationChainChunked(new OperationChain<>(new GetAllElements<>()));
    // Then
    final List<Element> results = readChunkedElements(response);
    verifyElements(DEFAULT_ELEMENTS, results);
}
Also used : Response(javax.ws.rs.core.Response) Element(uk.gov.gchq.gaffer.data.element.Element) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) Test(org.junit.Test)

Example 3 with GetAllElements

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

the class OperationServiceIT method shouldReturnNoChunkedElementsWhenNoElementsInGraph.

@Test
public void shouldReturnNoChunkedElementsWhenNoElementsInGraph() throws IOException {
    // When
    final Response response = RestApiTestUtil.executeOperationChainChunked(new OperationChain<>(new GetAllElements<>()));
    // Then
    final List<Element> results = readChunkedElements(response);
    assertEquals(0, results.size());
}
Also used : Response(javax.ws.rs.core.Response) Element(uk.gov.gchq.gaffer.data.element.Element) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) Test(org.junit.Test)

Example 4 with GetAllElements

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

the class OperationServiceIT method shouldReturnGroupCounts.

@Test
public void shouldReturnGroupCounts() throws IOException {
    // Given
    RestApiTestUtil.addElements(DEFAULT_ELEMENTS);
    // When
    final Response response = RestApiTestUtil.executeOperationChainChunked(new OperationChain.Builder().first(new GetAllElements<>()).then(new CountGroups()).build());
    // Then
    final GroupCounts groupCounts = response.readEntity(new GenericType<GroupCounts>() {
    });
    verifyGroupCounts(groupCounts);
}
Also used : Response(javax.ws.rs.core.Response) CountGroups(uk.gov.gchq.gaffer.operation.impl.CountGroups) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GroupCounts(uk.gov.gchq.gaffer.data.GroupCounts) Test(org.junit.Test)

Example 5 with GetAllElements

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

the class CountGroupsIT method shouldCountGroupsOfElementsWhenMoreElementsThanLimit.

@Test
public void shouldCountGroupsOfElementsWhenMoreElementsThanLimit() throws OperationException, InterruptedException {
    // Given
    final User user = new User();
    final int limit = 5;
    final Entity entity = new Entity(TestGroups.ENTITY_2, VERTEX);
    entity.putProperty(TestPropertyNames.INT, 100);
    // When
    final GroupCounts counts = graph.execute(new Builder().first(new GetAllElements<>()).then(new CountGroups(limit)).build(), user);
    // Then
    int totalCount = (null != counts.getEntityGroups().get(TestGroups.ENTITY) ? counts.getEntityGroups().get(TestGroups.ENTITY) : 0);
    totalCount += (null != counts.getEdgeGroups().get(TestGroups.EDGE) ? counts.getEdgeGroups().get(TestGroups.EDGE) : 0);
    assertEquals(limit, totalCount);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) User(uk.gov.gchq.gaffer.user.User) CountGroups(uk.gov.gchq.gaffer.operation.impl.CountGroups) Builder(uk.gov.gchq.gaffer.operation.OperationChain.Builder) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) GroupCounts(uk.gov.gchq.gaffer.data.GroupCounts) Test(org.junit.Test)

Aggregations

GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)11 Test (org.junit.Test)8 GroupCounts (uk.gov.gchq.gaffer.data.GroupCounts)5 CountGroups (uk.gov.gchq.gaffer.operation.impl.CountGroups)5 Response (javax.ws.rs.core.Response)4 Element (uk.gov.gchq.gaffer.data.element.Element)4 Entity (uk.gov.gchq.gaffer.data.element.Entity)4 Builder (uk.gov.gchq.gaffer.operation.OperationChain.Builder)3 User (uk.gov.gchq.gaffer.user.User)3 IteratorSettingBuilder (uk.gov.gchq.gaffer.accumulostore.utils.IteratorSettingBuilder)2 IncludeEdgeType (uk.gov.gchq.gaffer.operation.GetOperation.IncludeEdgeType)2 IncludeIncomingOutgoingType (uk.gov.gchq.gaffer.operation.GetOperation.IncludeIncomingOutgoingType)2 ArrayList (java.util.ArrayList)1 ChunkedInput (org.glassfish.jersey.client.ChunkedInput)1 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)1 TraitRequirement (uk.gov.gchq.gaffer.integration.TraitRequirement)1 ElementSeed (uk.gov.gchq.gaffer.operation.data.ElementSeed)1