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;
}
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;
}
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);
}
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;
}
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;
}
Aggregations