Search in sources :

Example 1 with ProcessorType

use of com.redhat.service.smartevents.infra.models.processors.ProcessorType in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorDAO method getProcessorIds.

private ProcessorResults getProcessorIds(String customerId, String bridgeId, QueryProcessorResourceInfo queryInfo, Set<ProcessorType> restrictTypes) {
    Parameters parameters = Parameters.with("customerId", customerId).and("bridgeId", bridgeId);
    PanacheQuery<Processor> query = find("#PROCESSOR.findByBridgeIdAndCustomerIdNoFilter", parameters);
    // filter by name
    String filterName = queryInfo.getFilterInfo().getFilterName();
    if (Objects.nonNull(filterName)) {
        query.filter("byName", Parameters.with("name", filterName + "%"));
    }
    // filter by status
    Set<ManagedResourceStatus> filterStatus = queryInfo.getFilterInfo().getFilterStatus();
    if (Objects.nonNull(filterStatus) && !filterStatus.isEmpty()) {
        query.filter("byStatus", Parameters.with("status", filterStatus));
    }
    // filter by type, considering onlyUserVisible flag
    ProcessorType filterType = queryInfo.getFilterInfo().getFilterType();
    if (restrictTypes != null) {
        if (Objects.isNull(filterType)) {
            query.filter(BY_TYPE_FILTER_NAME, Parameters.with(BY_TYPE_FILTER_PARAM, restrictTypes));
        } else {
            if (restrictTypes.contains(filterType)) {
                query.filter(BY_TYPE_FILTER_NAME, Parameters.with(BY_TYPE_FILTER_PARAM, Set.of(filterType)));
            } else {
                return new ProcessorResults(emptyList(), 0);
            }
        }
    } else {
        if (Objects.nonNull(filterType)) {
            query.filter(BY_TYPE_FILTER_NAME, Parameters.with(BY_TYPE_FILTER_PARAM, Set.of(filterType)));
        }
    }
    long total = query.count();
    List<Processor> processors = query.page(queryInfo.getPageNumber(), queryInfo.getPageSize()).list();
    List<String> ids = processors.stream().map(Processor::getId).collect(Collectors.toList());
    return new ProcessorResults(ids, total);
}
Also used : Parameters(io.quarkus.panache.common.Parameters) Processor(com.redhat.service.smartevents.manager.models.Processor) ProcessorType(com.redhat.service.smartevents.infra.models.processors.ProcessorType) ManagedResourceStatus(com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus)

Example 2 with ProcessorType

use of com.redhat.service.smartevents.infra.models.processors.ProcessorType in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.

the class ProcessorServiceImpl method createErrorHandlerProcessor.

@Override
@Transactional
public Processor createErrorHandlerProcessor(String bridgeId, String customerId, String owner, ProcessorRequest processorRequest) {
    Bridge bridge = bridgesService.getBridge(bridgeId, customerId);
    ProcessorType processorType = processorRequest.getType();
    if (processorType != ProcessorType.SINK) {
        throw new InternalPlatformException("Unable to configure error handler");
    }
    return doCreateProcessor(bridge, customerId, owner, ProcessorType.ERROR_HANDLER, processorRequest);
}
Also used : ProcessorType(com.redhat.service.smartevents.infra.models.processors.ProcessorType) InternalPlatformException(com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException) Bridge(com.redhat.service.smartevents.manager.models.Bridge) Transactional(javax.transaction.Transactional)

Aggregations

ProcessorType (com.redhat.service.smartevents.infra.models.processors.ProcessorType)2 InternalPlatformException (com.redhat.service.smartevents.infra.exceptions.definitions.platform.InternalPlatformException)1 ManagedResourceStatus (com.redhat.service.smartevents.infra.models.dto.ManagedResourceStatus)1 Bridge (com.redhat.service.smartevents.manager.models.Bridge)1 Processor (com.redhat.service.smartevents.manager.models.Processor)1 Parameters (io.quarkus.panache.common.Parameters)1 Transactional (javax.transaction.Transactional)1