Search in sources :

Example 41 with EventBase

use of datawave.webservice.query.result.event.EventBase in project datawave by NationalSecurityAgency.

the class GroupingTestWithModel method digest.

// grab the relevant stuff from the events and do some formatting
private List<String> digest(List<List<EventBase>> in) {
    List<String> stringList = new ArrayList<>();
    for (List<EventBase> list : in) {
        StringBuilder builder = new StringBuilder();
        for (EventBase eb : list) {
            for (Object field : eb.getFields()) {
                FieldBase fieldBase = (FieldBase) field;
                builder.append(fieldBase.getName());
                builder.append(':');
                builder.append(fieldBase.getTypedValue().getValue());
                builder.append(',');
            }
        }
        stringList.add(builder.toString() + '\n');
    }
    return stringList;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) ArrayList(java.util.ArrayList) FieldBase(datawave.webservice.query.result.event.FieldBase)

Example 42 with EventBase

use of datawave.webservice.query.result.event.EventBase in project datawave by NationalSecurityAgency.

the class GroupingTest method testGroupingWithReducedResponse.

@Test
public void testGroupingWithReducedResponse() throws Exception {
    Map<String, String> extraParameters = new HashMap<>();
    Date startDate = format.parse("20091231");
    Date endDate = format.parse("20150101");
    String queryString = "UUID =~ '^[CS].*'";
    Map<String, Integer> expectedMap = ImmutableMap.of("MALE", 10, "FEMALE", 2);
    extraParameters.put("reduced.response", "true");
    extraParameters.put("group.fields", "GENDER");
    extraParameters.put("group.fields.batch.size", "0");
    for (RebuildingScannerTestHelper.TEARDOWN teardown : TEARDOWNS) {
        for (RebuildingScannerTestHelper.INTERRUPT interrupt : INTERRUPTS) {
            EventQueryResponseBase response = (EventQueryResponseBase) runTestQueryWithGrouping(expectedMap, queryString, startDate, endDate, extraParameters, teardown, interrupt);
            for (EventBase event : response.getEvents()) {
                // The event should have a collapsed columnVisibility
                String actualCV = event.getMarkings().get(COLVIS_MARKING).toString();
                Assert.assertEquals(EXPECTED_COLVIS, actualCV);
                // The fields should have no columnVisibility
                for (Object f : event.getFields()) {
                    FieldBase<?> field = (FieldBase<?>) f;
                    Assert.assertNull(field.getMarkings().get(COLVIS_MARKING));
                }
            }
        }
    }
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) HashMap(java.util.HashMap) Date(java.util.Date) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase) FieldBase(datawave.webservice.query.result.event.FieldBase) RebuildingScannerTestHelper(datawave.query.RebuildingScannerTestHelper) Test(org.junit.Test)

Example 43 with EventBase

use of datawave.webservice.query.result.event.EventBase in project datawave by NationalSecurityAgency.

the class GroupingTest method digest.

// grab the relevant stuff from the events and do some formatting
private List<String> digest(List<List<EventBase>> in) {
    List<String> stringList = new ArrayList<>();
    for (List<EventBase> list : in) {
        StringBuilder builder = new StringBuilder();
        for (EventBase eb : list) {
            for (Object field : eb.getFields()) {
                FieldBase fieldBase = (FieldBase) field;
                builder.append(fieldBase.getName());
                builder.append(':');
                builder.append(fieldBase.getTypedValue().getValue());
                builder.append(',');
            }
        }
        stringList.add(builder.toString() + '\n');
    }
    return stringList;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) ArrayList(java.util.ArrayList) FieldBase(datawave.webservice.query.result.event.FieldBase)

Aggregations

EventBase (datawave.webservice.query.result.event.EventBase)43 ArrayList (java.util.ArrayList)28 FieldBase (datawave.webservice.query.result.event.FieldBase)23 Metadata (datawave.webservice.query.result.event.Metadata)18 EventQueryResponseBase (datawave.webservice.result.EventQueryResponseBase)11 CacheableQueryRow (datawave.webservice.query.cachedresults.CacheableQueryRow)10 BaseQueryResponse (datawave.webservice.result.BaseQueryResponse)6 DefaultEventQueryResponse (datawave.webservice.result.DefaultEventQueryResponse)5 Map (java.util.Map)5 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)5 TransformIterator (org.apache.commons.collections4.iterators.TransformIterator)5 Exception (datawave.marking.MarkingFunctions.Exception)4 QueryImpl (datawave.webservice.query.QueryImpl)4 QueryException (datawave.webservice.query.exception.QueryException)4 HashMap (java.util.HashMap)4 CacheableQueryRowImpl (datawave.webservice.query.cachedresults.CacheableQueryRowImpl)3 GenericQueryConfiguration (datawave.webservice.query.configuration.GenericQueryConfiguration)3 DatawaveTransformIterator (datawave.webservice.query.iterator.DatawaveTransformIterator)3 DefaultEvent (datawave.webservice.query.result.event.DefaultEvent)3 Date (java.util.Date)3