use of com.synopsys.integration.alert.common.persistence.accessor.JobDetailsAccessor2 in project hub-alert by blackducksoftware.
the class StaticJobAccessor method createJobWithId.
private DistributionJobModel createJobWithId(UUID jobId, DistributionJobRequestModel requestModel, OffsetDateTime createdAt, @Nullable OffsetDateTime lastUpdated) {
String channelDescriptorName = requestModel.getChannelDescriptorName();
DistributionJobEntity jobToSave = new DistributionJobEntity(jobId, requestModel.getName(), requestModel.isEnabled(), requestModel.getDistributionFrequency().name(), requestModel.getProcessingType().name(), channelDescriptorName, requestModel.getChannelGlobalConfigId(), createdAt, lastUpdated);
DistributionJobEntity savedJobEntity = distributionJobRepository.save(jobToSave);
UUID savedJobId = savedJobEntity.getJobId();
BlackDuckJobDetailsEntity savedBlackDuckJobDetails = blackDuckJobDetailsAccessor.saveBlackDuckJobDetails(savedJobId, requestModel);
savedJobEntity.setBlackDuckJobDetails(savedBlackDuckJobDetails);
DistributionJobDetailsModel distributionJobDetails = requestModel.getDistributionJobDetails();
if (distributionJobDetails.isA(ChannelKeys.AZURE_BOARDS)) {
AzureBoardsJobDetailsEntity savedAzureBoardsJobDetails = azureBoardsJobDetailsAccessor.saveAzureBoardsJobDetails(savedJobId, distributionJobDetails.getAs(DistributionJobDetailsModel.AZURE));
savedJobEntity.setAzureBoardsJobDetails(savedAzureBoardsJobDetails);
} else if (distributionJobDetails.isA(ChannelKeys.JIRA_CLOUD)) {
JiraCloudJobDetailsEntity savedJiraCloudJobDetails = jiraCloudJobDetailsAccessor.saveJiraCloudJobDetails(savedJobId, distributionJobDetails.getAs(DistributionJobDetailsModel.JIRA_CLOUD));
savedJobEntity.setJiraCloudJobDetails(savedJiraCloudJobDetails);
} else if (distributionJobDetails.isA(ChannelKeys.MS_TEAMS)) {
MSTeamsJobDetailsEntity savedMSTeamsJobDetails = msTeamsJobDetailsAccessor.saveMSTeamsJobDetails(savedJobId, distributionJobDetails.getAs(DistributionJobDetailsModel.MS_TEAMS));
savedJobEntity.setMsTeamsJobDetails(savedMSTeamsJobDetails);
} else if (distributionJobDetails.isA(ChannelKeys.SLACK)) {
SlackJobDetailsEntity savedSlackJobDetails = slackJobDetailsAccessor.saveSlackJobDetails(savedJobId, distributionJobDetails.getAs(DistributionJobDetailsModel.SLACK));
savedJobEntity.setSlackJobDetails(savedSlackJobDetails);
} else {
// In the future the contents of this else case should be the complete implementation of this method
ChannelKey channelKey = ChannelKeys.getChannelKey(channelDescriptorName);
if (jobDetailsAccessorMap.containsKey(channelKey) && distributionJobDetails.isA(channelKey)) {
JobDetailsAccessor2<? extends DistributionJobDetailsModel> accessor = jobDetailsAccessorMap.get(channelKey);
DistributionJobDetailsModel savedJobDetails = accessor.saveJobDetails(savedJobId, distributionJobDetails);
return convertToDistributionJobModel(savedJobEntity, savedJobDetails);
}
}
return convertToDistributionJobModel(savedJobEntity);
}
Aggregations