Search in sources :

Example 1 with EventQueryResponseBase

use of datawave.webservice.result.EventQueryResponseBase in project datawave by NationalSecurityAgency.

the class GroupingDocumentTransformer method createGroupedResponse.

protected BaseQueryResponse createGroupedResponse(Multiset<Collection<FieldBase<?>>> multiset) {
    Map<String, String> markings = Maps.newHashMap();
    EventQueryResponseBase response = this.responseObjectFactory.getEventQueryResponse();
    List<EventBase> events = new ArrayList<>();
    for (Collection<FieldBase<?>> entry : multiset.elementSet()) {
        EventBase event = this.responseObjectFactory.getEvent();
        event.setMarkings(markings);
        List<FieldBase<?>> fields = new ArrayList(entry);
        FieldBase<?> counter = this.responseObjectFactory.getField();
        counter.setName("COUNT");
        counter.setMarkings(markings);
        counter.setValue(multiset.count(entry));
        counter.setTimestamp(0L);
        fields.add(counter);
        event.setFields(fields);
        events.add(event);
    }
    response.setEvents(events);
    response.setTotalEvents((long) events.size());
    response.setReturnedEvents((long) events.size());
    return response;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) ArrayList(java.util.ArrayList) FieldBase(datawave.webservice.query.result.event.FieldBase) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase)

Example 2 with EventQueryResponseBase

use of datawave.webservice.result.EventQueryResponseBase in project datawave by NationalSecurityAgency.

the class EventQueryTransformerSupport method createResponse.

@Override
public BaseQueryResponse createResponse(List<Object> resultList) {
    EventQueryResponseBase response = this.responseObjectFactory.getEventQueryResponse();
    List<EventBase> eventList = new ArrayList<>();
    Set<String> fieldSet = new TreeSet<>();
    for (Object o : resultList) {
        EventBase<?, ?> e = (EventBase<?, ?>) o;
        for (FieldBase<?> f : e.getFields()) {
            fieldSet.add(f.getName());
        }
        eventList.add(e);
    }
    response.setFields(Lists.newArrayList(fieldSet));
    response.setEvents(eventList);
    response.setReturnedEvents((long) eventList.size());
    return response;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase)

Example 3 with EventQueryResponseBase

use of datawave.webservice.result.EventQueryResponseBase in project datawave by NationalSecurityAgency.

the class FieldIndexCountQueryTransformer method createResponse.

@Override
public BaseQueryResponse createResponse(List<Object> resultList) {
    EventQueryResponseBase response = responseObjectFactory.getEventQueryResponse();
    List<EventBase> eventList = new ArrayList<>();
    for (Object o : resultList) {
        EventBase<?, ?> e = (EventBase<?, ?>) o;
        eventList.add(e);
    }
    response.setFields(variableFieldList);
    response.setEvents(eventList);
    response.setReturnedEvents((long) eventList.size());
    return (BaseQueryResponse) response;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) ArrayList(java.util.ArrayList) BaseQueryResponse(datawave.webservice.result.BaseQueryResponse) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase)

Example 4 with EventQueryResponseBase

use of datawave.webservice.result.EventQueryResponseBase in project datawave by NationalSecurityAgency.

the class DocumentTransformerSupport method createResponse.

@Override
public BaseQueryResponse createResponse(List<Object> resultList) {
    EventQueryResponseBase response = this.responseObjectFactory.getEventQueryResponse();
    List<EventBase> eventList = Lists.newArrayListWithCapacity(resultList.size());
    Set<String> fieldSet = Sets.newTreeSet();
    for (Object o : resultList) {
        EventBase<?, ?> e = (EventBase<?, ?>) o;
        for (FieldBase<?> f : e.getFields()) {
            fieldSet.add(f.getName());
        }
        eventList.add(e);
    }
    response.setFields(Lists.newArrayList(fieldSet));
    response.setEvents(eventList);
    response.setReturnedEvents((long) eventList.size());
    return response;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase)

Example 5 with EventQueryResponseBase

use of datawave.webservice.result.EventQueryResponseBase in project datawave by NationalSecurityAgency.

the class LookupUUIDUtil method validatePagedResponse.

private EventQueryResponseBase validatePagedResponse(final BaseQueryResponse response) {
    final EventQueryResponseBase pagedResponse;
    if (response instanceof EventQueryResponseBase) {
        pagedResponse = (EventQueryResponseBase) response;
    } else {
        final EventQueryResponseBase er = responseObjectFactory.getEventQueryResponse();
        er.addMessage("Unhandled response type from Query/createQueryAndNext");
        throw new PreConditionFailedException(null, er);
    }
    return pagedResponse;
}
Also used : PreConditionFailedException(datawave.webservice.common.exception.PreConditionFailedException) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase)

Aggregations

EventQueryResponseBase (datawave.webservice.result.EventQueryResponseBase)17 EventBase (datawave.webservice.query.result.event.EventBase)11 ArrayList (java.util.ArrayList)8 BaseQueryResponse (datawave.webservice.result.BaseQueryResponse)6 Date (java.util.Date)4 NoResultsException (datawave.webservice.common.exception.NoResultsException)3 PreConditionFailedException (datawave.webservice.common.exception.PreConditionFailedException)3 FieldBase (datawave.webservice.query.result.event.FieldBase)3 File (java.io.File)3 ParseException (java.text.ParseException)3 DateTimeParseException (java.time.format.DateTimeParseException)3 JCommander (com.beust.jcommander.JCommander)2 ParameterException (com.beust.jcommander.ParameterException)2 QueryMetricFactoryImpl (datawave.microservice.querymetric.QueryMetricFactoryImpl)2 DatawaveWebApplicationException (datawave.webservice.common.exception.DatawaveWebApplicationException)2 QueryImpl (datawave.webservice.query.QueryImpl)2 EdgeQueryResponseBase (datawave.webservice.query.result.EdgeQueryResponseBase)2 RunningQuery (datawave.webservice.query.runner.RunningQuery)2 VoidResponse (datawave.webservice.result.VoidResponse)2 FileInputStream (java.io.FileInputStream)2