use of com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity in project cloudbreak by hortonworks.
the class CDPStructuredEventDBService method getEventsOfResource.
@Override
public <T extends CDPStructuredEvent> List<T> getEventsOfResource(List<StructuredEventType> eventTypes, String resourceCrn) {
LOGGER.debug("Gathering events for type: '{}' and resource CRN: '{}'", eventTypes, resourceCrn);
List<StructuredEventType> types = getAllEventTypeIfEmpty(eventTypes);
try {
List<CDPStructuredEventEntity> events = structuredEventRepository.findByEventTypeInAndResourceCrn(types, resourceCrn);
return (List<T>) Optional.ofNullable(events).orElse(new ArrayList<>()).stream().map(event -> cdpStructuredEventEntityToCDPStructuredEventConverter.convert(event)).collect(Collectors.toList());
} catch (Exception ex) {
String msg = String.format("Failed get events for types: '%s' and resource CRN: '%s'", types, resourceCrn);
LOGGER.warn(msg, ex);
throw new CloudbreakServiceException(msg, ex);
}
}
use of com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity in project cloudbreak by hortonworks.
the class CDPStructuredEventDBService method getEventsOfResources.
@Override
public <T extends CDPStructuredEvent> List<T> getEventsOfResources(List<StructuredEventType> eventTypes, List<String> resourceCrns) {
LOGGER.debug("Gathering events for type: '{}' and resource CRN's: '{}'", eventTypes, resourceCrns);
List<StructuredEventType> types = getAllEventTypeIfEmpty(eventTypes);
try {
List<CDPStructuredEventEntity> events = structuredEventRepository.findByEventTypeInAndResourceCrnIn(types, resourceCrns);
return (List<T>) Optional.ofNullable(events).orElse(new ArrayList<>()).stream().map(event -> cdpStructuredEventEntityToCDPStructuredEventConverter.convert(event)).collect(Collectors.toList());
} catch (Exception ex) {
String msg = String.format("Failed get events for types: '%s' and resource CRNs: '%s'", types, resourceCrns);
LOGGER.warn(msg, ex);
throw new CloudbreakServiceException(msg, ex);
}
}
use of com.sequenceiq.cloudbreak.structuredevent.domain.CDPStructuredEventEntity in project cloudbreak by hortonworks.
the class CDPStructuredEventDBService method getPagedEventsOfResource.
@Override
public <T extends CDPStructuredEvent> Page<T> getPagedEventsOfResource(List<StructuredEventType> eventTypes, String resourceCrn, Pageable pageable) {
LOGGER.debug("Gathering pageable events for types: '{}' and resource CRN: '{}'", eventTypes, resourceCrn);
List<StructuredEventType> types = getAllEventTypeIfEmpty(eventTypes);
try {
Page<CDPStructuredEventEntity> events = pagingStructuredEventRepository.findByEventTypeInAndResourceCrn(types, resourceCrn, pageable);
return (Page<T>) Optional.ofNullable(events).orElse(Page.empty()).map(event -> cdpStructuredEventEntityToCDPStructuredEventConverter.convert(event));
} catch (Exception ex) {
String msg = String.format("Failed get pageable events for types: '%s' and resource CRN: '%s'", types, resourceCrn);
LOGGER.warn(msg, ex);
throw new CloudbreakServiceException(msg, ex);
}
}
Aggregations