Search in sources :

Example 16 with EventBase

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

the class ContentQueryTransformer method createResponse.

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

Example 17 with EventBase

use of datawave.webservice.query.result.event.EventBase 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 18 with EventBase

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

the class LookupUUIDUtil method mergeNextUUIDLookups.

private void mergeNextUUIDLookups(final EventQueryResponseBase mergedResponse) {
    // Get the query ID in order to perform the next(queryID) operations
    final String queryId = mergedResponse.getQueryId();
    // Initialize a list to collect all queried events
    final List<EventBase> mergedEvents = new LinkedList<>(mergedResponse.getEvents());
    // Get each set of next events, remove irrelevant information, and merge them into the main response
    try {
        EventQueryResponseBase eventResponse = null;
        do {
            final BaseQueryResponse nextResponse = this.queryExecutor.next(queryId);
            eventResponse = this.validatePagedResponse(nextResponse);
            final List<EventBase> nextEvents = this.removeIrrelevantEventInformation(eventResponse.getEvents());
            mergedEvents.addAll(nextEvents);
        } while (null != eventResponse);
    } catch (final NoResultsException e) {
    // No op
    } finally {
        try {
            this.queryExecutor.close(queryId);
        } catch (final Exception e) {
            final String message = "Unable to close UUID lookup query " + queryId + " while performing a content lookup";
            log.error(message, e);
        }
    }
    // Apply the merged fields back to the merged response
    mergedResponse.setEvents(mergedEvents);
}
Also used : NoResultsException(datawave.webservice.common.exception.NoResultsException) EventBase(datawave.webservice.query.result.event.EventBase) BaseQueryResponse(datawave.webservice.result.BaseQueryResponse) LinkedList(java.util.LinkedList) EventQueryResponseBase(datawave.webservice.result.EventQueryResponseBase) NoResultsException(datawave.webservice.common.exception.NoResultsException) DatawaveWebApplicationException(datawave.webservice.common.exception.DatawaveWebApplicationException) PreConditionFailedException(datawave.webservice.common.exception.PreConditionFailedException) ParseException(java.text.ParseException) EJBException(javax.ejb.EJBException) DateTimeParseException(java.time.format.DateTimeParseException)

Example 19 with EventBase

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

the class DiscoveryTransformer method createResponse.

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

Example 20 with EventBase

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

the class DiscoveryTransformer method transform.

@Override
public EventBase transform(DiscoveredThing thing) {
    Preconditions.checkNotNull(thing, "Received a null object to transform!");
    EventBase event = this.responseObjectFactory.getEvent();
    Map<String, String> markings;
    try {
        markings = this.markingFunctions.translateFromColumnVisibility(new ColumnVisibility(thing.getColumnVisibility()));
    } catch (Exception e) {
        throw new RuntimeException("could not parse to markings: " + thing.getColumnVisibility());
    }
    event.setMarkings(markings);
    List<FieldBase> fields = new ArrayList<>();
    fields.add(this.makeField("VALUE", markings, "", 0L, thing.getTerm()));
    /**
     * Added query model to alias FIELD
     */
    fields.add(this.makeField("FIELD", markings, "", 0L, myQueryModel.aliasFieldNameReverseModel(thing.getField())));
    fields.add(this.makeField("DATE", markings, "", 0L, thing.getDate()));
    fields.add(this.makeField("DATA TYPE", markings, "", 0L, thing.getType()));
    // If requested return counts separated by colvis, all counts by colvis could be > total record count
    if (thing.getCountsByColumnVisibility() != null && !thing.getCountsByColumnVisibility().isEmpty()) {
        for (Map.Entry<Writable, Writable> entry : thing.getCountsByColumnVisibility().entrySet()) {
            try {
                Map<String, String> eMarkings = this.markingFunctions.translateFromColumnVisibility(new ColumnVisibility(entry.getKey().toString()));
                fields.add(this.makeField("RECORD COUNT", new HashMap<>(), entry.getKey().toString(), 0L, entry.getValue().toString()));
            } catch (Exception e) {
                throw new RuntimeException("could not parse to markings: " + thing.getColumnVisibility());
            }
        }
    } else {
        fields.add(this.makeField("RECORD COUNT", markings, "", 0L, Long.toString(thing.getCount())));
    }
    event.setFields(fields);
    Metadata metadata = new Metadata();
    // there is no UUID for a single index pointer
    metadata.setInternalId("");
    // duplicate
    metadata.setDataType(thing.getType());
    // duplicate
    metadata.setRow(thing.getTerm());
    metadata.setTable(logic.getTableName());
    event.setMetadata(metadata);
    return event;
}
Also used : EventBase(datawave.webservice.query.result.event.EventBase) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Metadata(datawave.webservice.query.result.event.Metadata) Writable(org.apache.hadoop.io.Writable) QueryException(datawave.webservice.query.exception.QueryException) Exception(datawave.marking.MarkingFunctions.Exception) FieldBase(datawave.webservice.query.result.event.FieldBase) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) HashMap(java.util.HashMap) Map(java.util.Map)

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