Search in sources :

Example 1 with DistributionJobModelBuilder

use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModelBuilder in project hub-alert by blackducksoftware.

the class StaticJobAccessor method convertToDistributionJobModel.

private DistributionJobModel convertToDistributionJobModel(DistributionJobEntity jobEntity, DistributionJobDetailsModel jobDetailsModel) {
    UUID jobId = jobEntity.getJobId();
    ChannelKey channelKey = ChannelKeys.getChannelKey(jobEntity.getChannelDescriptorName());
    BlackDuckJobDetailsEntity blackDuckJobDetails = jobEntity.getBlackDuckJobDetails();
    List<String> notificationTypes = blackDuckJobDetailsAccessor.retrieveNotificationTypesForJob(jobId);
    List<BlackDuckProjectDetailsModel> projectDetails = blackDuckJobDetailsAccessor.retrieveProjectDetailsForJob(jobId);
    List<String> policyNames = blackDuckJobDetailsAccessor.retrievePolicyNamesForJob(jobId);
    List<String> vulnerabilitySeverityNames = blackDuckJobDetailsAccessor.retrieveVulnerabilitySeverityNamesForJob(jobId);
    return new DistributionJobModelBuilder().jobId(jobId).name(jobEntity.getName()).enabled(jobEntity.getEnabled()).distributionFrequency(jobEntity.getDistributionFrequency()).processingType(jobEntity.getProcessingType()).channelDescriptorName(channelKey.getUniversalKey()).channelGlobalConfigId(jobEntity.getChannelGlobalConfigId()).createdAt(jobEntity.getCreatedAt()).lastUpdated(jobEntity.getLastUpdated()).blackDuckGlobalConfigId(blackDuckJobDetails.getGlobalConfigId()).filterByProject(blackDuckJobDetails.getFilterByProject()).projectNamePattern(blackDuckJobDetails.getProjectNamePattern()).projectVersionNamePattern(blackDuckJobDetails.getProjectVersionNamePattern()).notificationTypes(notificationTypes).projectFilterDetails(projectDetails).policyFilterPolicyNames(policyNames).vulnerabilityFilterSeverityNames(vulnerabilitySeverityNames).distributionJobDetails(jobDetailsModel).createdAt(jobEntity.getCreatedAt()).lastUpdated(jobEntity.getLastUpdated()).build();
}
Also used : DistributionJobModelBuilder(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModelBuilder) BlackDuckProjectDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.BlackDuckProjectDetailsModel) ChannelKey(com.synopsys.integration.alert.descriptor.api.model.ChannelKey) UUID(java.util.UUID) BlackDuckJobDetailsEntity(com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity)

Example 2 with DistributionJobModelBuilder

use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModelBuilder in project hub-alert by blackducksoftware.

the class DistributionJobModelExtractor method convertToJobModel.

public final DistributionJobModel convertToJobModel(UUID jobId, Map<String, ConfigurationFieldModel> configuredFieldsMap, OffsetDateTime createdAt, @Nullable OffsetDateTime lastUpdated, List<BlackDuckProjectDetailsModel> projectFilterDetails) {
    String channelDescriptorName = distributionJobFieldExtractor.extractFieldValueOrEmptyString(ChannelDescriptor.KEY_CHANNEL_NAME, configuredFieldsMap);
    DistributionJobModelBuilder builder = DistributionJobModel.builder().jobId(jobId).enabled(distributionJobFieldExtractor.extractFieldValue(ChannelDescriptor.KEY_ENABLED, configuredFieldsMap).map(Boolean::valueOf).orElse(true)).name(distributionJobFieldExtractor.extractFieldValueOrEmptyString(ChannelDescriptor.KEY_NAME, configuredFieldsMap)).distributionFrequency(distributionJobFieldExtractor.extractFieldValueOrEmptyString(ChannelDescriptor.KEY_FREQUENCY, configuredFieldsMap)).processingType(distributionJobFieldExtractor.extractFieldValueOrEmptyString(ProviderDescriptor.KEY_PROCESSING_TYPE, configuredFieldsMap)).channelDescriptorName(channelDescriptorName).channelGlobalConfigId(distributionJobFieldExtractor.extractFieldValue(ChannelDescriptor.KEY_CHANNEL_GLOBAL_CONFIG_ID, configuredFieldsMap).map(UUID::fromString).orElse(null)).createdAt(createdAt).lastUpdated(lastUpdated).blackDuckGlobalConfigId(distributionJobFieldExtractor.extractFieldValue(ProviderDescriptor.KEY_COMMON_CONFIG_ID, configuredFieldsMap).map(Long::valueOf).orElse(-1L)).filterByProject(distributionJobFieldExtractor.extractFieldValue(ProviderDescriptor.KEY_FILTER_BY_PROJECT, configuredFieldsMap).map(Boolean::valueOf).orElse(false)).projectNamePattern(distributionJobFieldExtractor.extractFieldValue(ProviderDescriptor.KEY_PROJECT_NAME_PATTERN, configuredFieldsMap).orElse(null)).projectVersionNamePattern(distributionJobFieldExtractor.extractFieldValue(ProviderDescriptor.KEY_PROJECT_VERSION_NAME_PATTERN, configuredFieldsMap).orElse(null)).notificationTypes(distributionJobFieldExtractor.extractFieldValues(ProviderDescriptor.KEY_NOTIFICATION_TYPES, configuredFieldsMap)).policyFilterPolicyNames(distributionJobFieldExtractor.extractFieldValues("blackduck.policy.notification.filter", configuredFieldsMap)).vulnerabilityFilterSeverityNames(distributionJobFieldExtractor.extractFieldValues("blackduck.vulnerability.notification.filter", configuredFieldsMap)).projectFilterDetails(projectFilterDetails);
    DistributionJobDetailsExtractor extractor = jobDetailsExtractorMap.findRequiredAction(channelDescriptorName);
    DistributionJobDetailsModel distributionJobDetailsModel = extractor.extractDetails(jobId, configuredFieldsMap);
    builder.distributionJobDetails(distributionJobDetailsModel);
    return builder.build();
}
Also used : DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) DistributionJobModelBuilder(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModelBuilder) UUID(java.util.UUID) DistributionJobDetailsExtractor(com.synopsys.integration.alert.common.persistence.model.job.details.processor.DistributionJobDetailsExtractor)

Example 3 with DistributionJobModelBuilder

use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModelBuilder in project hub-alert by blackducksoftware.

the class ProcessedNotificationDetailsTest method fromDistributionJobTest.

@Test
public void fromDistributionJobTest() {
    DistributionJobModel distributionJobModel = new DistributionJobModelBuilder().jobId(uuid).channelDescriptorName(CHANNEL_NAME).name(JOB_NAME).distributionFrequency(FrequencyType.REAL_TIME).processingType(ProcessingType.DEFAULT).createdAt(OffsetDateTime.now().minusMinutes(1L)).lastUpdated(OffsetDateTime.now()).blackDuckGlobalConfigId(10L).notificationTypes(List.of("notificationTypes")).build();
    ProcessedNotificationDetails processedNotificationDetails = ProcessedNotificationDetails.fromDistributionJob(distributionJobModel);
    assertEquals(uuid, processedNotificationDetails.getJobId());
    assertEquals(CHANNEL_NAME, processedNotificationDetails.getChannelName());
    assertEquals(JOB_NAME, processedNotificationDetails.getJobName());
}
Also used : DistributionJobModelBuilder(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModelBuilder) DistributionJobModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel) Test(org.junit.jupiter.api.Test)

Aggregations

DistributionJobModelBuilder (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModelBuilder)3 UUID (java.util.UUID)2 BlackDuckProjectDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.BlackDuckProjectDetailsModel)1 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)1 DistributionJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel)1 DistributionJobDetailsExtractor (com.synopsys.integration.alert.common.persistence.model.job.details.processor.DistributionJobDetailsExtractor)1 BlackDuckJobDetailsEntity (com.synopsys.integration.alert.database.job.blackduck.BlackDuckJobDetailsEntity)1 ChannelKey (com.synopsys.integration.alert.descriptor.api.model.ChannelKey)1 Test (org.junit.jupiter.api.Test)1