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