Search in sources :

Example 1 with LabelValueSelectOption

use of com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOption in project hub-alert by blackducksoftware.

the class VulnerabilityNotificationFilterCustomFunctionAction method createActionResponse.

@Override
public ActionResponse<LabelValueSelectOptions> createActionResponse(FieldModel fieldModel, HttpServletContentWrapper servletContentWrapper) {
    Optional<FieldValueModel> fieldValueModel = fieldModel.getFieldValueModel(ProviderDescriptor.KEY_NOTIFICATION_TYPES);
    Collection<String> selectedNotificationTypes = fieldValueModel.map(FieldValueModel::getValues).orElse(List.of());
    List<LabelValueSelectOption> options = List.of();
    if (isFilterableVulnerability(selectedNotificationTypes)) {
        options = retrieveBlackDuckVulnerabilityOptions();
    }
    LabelValueSelectOptions optionList = new LabelValueSelectOptions(options);
    return new ActionResponse<>(HttpStatus.OK, optionList);
}
Also used : LabelValueSelectOption(com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOption) LabelValueSelectOptions(com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOptions) FieldValueModel(com.synopsys.integration.alert.common.rest.model.FieldValueModel) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Example 2 with LabelValueSelectOption

use of com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOption in project hub-alert by blackducksoftware.

the class ProviderConfigSelectCustomFunctionAction method createActionResponse.

@Override
public ActionResponse<LabelValueSelectOptions> createActionResponse(FieldModel fieldModel, HttpServletContentWrapper servletContentWrapper) {
    String providerName = fieldModel.getDescriptorName();
    Optional<DescriptorKey> descriptorKey = descriptorMap.getDescriptorKey(providerName);
    List<LabelValueSelectOption> options = List.of();
    if (descriptorKey.isPresent()) {
        List<ConfigurationModel> configurationModels = configurationModelConfigurationAccessor.getConfigurationsByDescriptorKeyAndContext(descriptorKey.get(), ConfigContextEnum.GLOBAL);
        options = configurationModels.stream().map(this::createNameToIdOption).flatMap(Optional::stream).collect(Collectors.toList());
    }
    LabelValueSelectOptions optionList = new LabelValueSelectOptions(options);
    return new ActionResponse<>(HttpStatus.OK, optionList);
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) LabelValueSelectOption(com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOption) Optional(java.util.Optional) LabelValueSelectOptions(com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOptions) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Example 3 with LabelValueSelectOption

use of com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOption in project hub-alert by blackducksoftware.

the class ProcessingSelectCustomFunctionAction method createActionResponse.

@Override
public ActionResponse<LabelValueSelectOptions> createActionResponse(FieldModel fieldModel, HttpServletContentWrapper servletContentWrapper) {
    String channelName = fieldModel.getFieldValue(ChannelDescriptor.KEY_CHANNEL_NAME).orElse("");
    List<LabelValueSelectOption> options = Arrays.stream(ProcessingType.values()).filter(processingType -> this.shouldInclude(processingType, channelName)).map(processingType -> new LabelValueSelectOption(processingType.getLabel(), processingType.name())).collect(Collectors.toList());
    LabelValueSelectOptions optionList = new LabelValueSelectOptions(options);
    return new ActionResponse<>(HttpStatus.OK, optionList);
}
Also used : AuthorizationManager(com.synopsys.integration.alert.common.security.authorization.AuthorizationManager) Arrays(java.util.Arrays) LabelValueSelectOptions(com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOptions) AlertFieldStatus(com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus) Collection(java.util.Collection) ChannelDescriptor(com.synopsys.integration.alert.common.descriptor.ChannelDescriptor) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) CustomFunctionAction(com.synopsys.integration.alert.common.action.CustomFunctionAction) Collectors(java.util.stream.Collectors) HttpServletContentWrapper(com.synopsys.integration.alert.common.rest.HttpServletContentWrapper) HttpStatus(org.springframework.http.HttpStatus) LabelValueSelectOption(com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOption) List(java.util.List) Component(org.springframework.stereotype.Component) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse) ProcessingType(com.synopsys.integration.alert.common.enumeration.ProcessingType) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) IssueTrackerChannelKey(com.synopsys.integration.alert.descriptor.api.model.IssueTrackerChannelKey) LabelValueSelectOption(com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOption) LabelValueSelectOptions(com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOptions) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Aggregations

ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)3 LabelValueSelectOption (com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOption)3 LabelValueSelectOptions (com.synopsys.integration.alert.common.descriptor.config.field.LabelValueSelectOptions)3 CustomFunctionAction (com.synopsys.integration.alert.common.action.CustomFunctionAction)1 ChannelDescriptor (com.synopsys.integration.alert.common.descriptor.ChannelDescriptor)1 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)1 ProcessingType (com.synopsys.integration.alert.common.enumeration.ProcessingType)1 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)1 HttpServletContentWrapper (com.synopsys.integration.alert.common.rest.HttpServletContentWrapper)1 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)1 FieldValueModel (com.synopsys.integration.alert.common.rest.model.FieldValueModel)1 AuthorizationManager (com.synopsys.integration.alert.common.security.authorization.AuthorizationManager)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1 IssueTrackerChannelKey (com.synopsys.integration.alert.descriptor.api.model.IssueTrackerChannelKey)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1