use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class JiraIssueSearchResultCreator method createResultFromProjectIssue.
public ProjectIssueSearchResult<String> createResultFromProjectIssue(JiraSearcherResponseModel issue, ProviderDetails providerDetails, LinkableItem project) throws AlertException {
JiraIssueSearchProperties issueProperties = issuePropertiesManager.retrieveIssueProperties(issue.getIssueKey());
String nullableSubComponentName = issueProperties.getSubComponentName();
String nullableSubComponentValue = issueProperties.getSubComponentValue();
LinkableItem componentVersion = null;
if (StringUtils.isNotBlank(nullableSubComponentName) && StringUtils.isNotBlank(nullableSubComponentValue)) {
componentVersion = new LinkableItem(nullableSubComponentName, nullableSubComponentValue);
}
LinkableItem projectVersion = new LinkableItem(issueProperties.getSubTopicName(), issueProperties.getSubTopicValue());
IssueBomComponentDetails bomComponentDetails = IssueBomComponentDetails.fromSearchResults(new LinkableItem(issueProperties.getComponentName(), issueProperties.getComponentValue()), componentVersion);
ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(providerDetails, project, projectVersion, bomComponentDetails);
return createIssueResult(issue, projectIssueModel);
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class ProjectMessageSummarizer method constructMessageDetails.
private List<LinkableItem> constructMessageDetails(ProjectMessage projectMessage) {
List<LinkableItem> details = new LinkedList<>();
details.add(projectMessage.getProject());
projectMessage.getProjectVersion().ifPresent(details::add);
Map<ComponentConcernSummaryGrouping, Integer> groupedConcernCounts = new LinkedHashMap<>();
for (BomComponentDetails bomComponent : projectMessage.getBomComponents()) {
for (ComponentConcern concern : bomComponent.getComponentConcerns()) {
ComponentConcernSummaryGrouping concernKey = new ComponentConcernSummaryGrouping(concern.getType(), concern.getOperation(), concern.getSeverity());
int currentCount = groupedConcernCounts.getOrDefault(concernKey, 0);
Number concernNumericValue = concern.getNumericValue();
int concernCount = (concernNumericValue != null) ? concernNumericValue.intValue() : 1;
groupedConcernCounts.put(concernKey, currentCount + concernCount);
}
}
Map<ComponentConcernSummaryGrouping, Integer> sortedGroupedConcernCountsBySeverity = groupedConcernCounts.entrySet().stream().sorted(Map.Entry.comparingByKey(ComponentConcernSummaryGrouping.getComparator())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, // Merge operation is equivalent to Map::putIfAbsent
(old, newIgnored) -> old, LinkedHashMap::new));
for (Map.Entry<ComponentConcernSummaryGrouping, Integer> groupedConcernCount : sortedGroupedConcernCountsBySeverity.entrySet()) {
ComponentConcernSummaryGrouping concernGrouping = groupedConcernCount.getKey();
String severityLabel = ComponentConcernType.POLICY.equals(concernGrouping.type) ? concernGrouping.severity.getPolicyLabel() : concernGrouping.severity.getVulnerabilityLabel();
String stateTypeString = convertToUppercasePlural(concernGrouping.type);
String stateAdjective = convertToAdjective(concernGrouping.type, concernGrouping.operation);
String label = String.format("(%s) %s %s count", severityLabel, stateTypeString, stateAdjective);
LinkableItem concernDetail = new LinkableItem(label, groupedConcernCount.getValue().toString());
concernDetail.setNumericValueFlag(true);
details.add(concernDetail);
}
return details;
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class ProjectMessageSummarizer method summarize.
public ProcessedProviderMessage<SimpleMessage> summarize(ProcessedProviderMessage<ProjectMessage> digestedProjectMessage) {
ProjectMessage projectMessage = digestedProjectMessage.getProviderMessage();
Pair<String, String> summaryAndDescription = constructSummaryAndDescription(projectMessage);
List<LinkableItem> details = constructMessageDetails(projectMessage);
SimpleMessage derivedSimpleMessage = SimpleMessage.derived(summaryAndDescription.getLeft(), summaryAndDescription.getRight(), details, projectMessage);
return new ProcessedProviderMessage<>(digestedProjectMessage.getNotificationIds(), derivedSimpleMessage);
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class ProjectMessageDigesterTest method createProcessedProviderMessage.
private ProcessedProviderMessage<ProjectMessage> createProcessedProviderMessage(String projectName, ProjectOperation operation) {
LinkableItem project1 = new LinkableItem("proj", projectName, "https://" + projectName);
ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(PROVIDER_DETAILS, project1, operation);
return new ProcessedProviderMessage<>(Set.of(), projectMessage1);
}
use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.
the class ProviderMessageDistributorTest method createProcessedProviderMessageHolder.
private ProcessedProviderMessageHolder createProcessedProviderMessageHolder(int numberOfProjectMessages, int numberOfSimpleMessages) {
List<ProcessedProviderMessage<ProjectMessage>> processedProjectMessages = new ArrayList<>();
List<ProcessedProviderMessage<SimpleMessage>> processedSimpleMessages = new ArrayList<>();
LinkableItem commonProject = new LinkableItem("Project", "Common Project");
ProjectOperation commonOperation = ProjectOperation.CREATE;
for (long i = 1; i < numberOfProjectMessages + 1; i++) {
LinkableItem provider = new LinkableItem("Provider", "Provider " + i);
ProviderDetails providerDetails = new ProviderDetails(i, provider);
ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, commonProject, commonOperation);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage = ProcessedProviderMessage.singleSource(i, projectMessage);
processedProjectMessages.add(processedProviderMessage);
}
for (long i = 1; i < numberOfSimpleMessages + 1; i++) {
LinkableItem provider = new LinkableItem("Details", "Detail " + i);
ProviderDetails providerDetails = new ProviderDetails(i, provider);
SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "Summary " + i, "Description " + i, List.of(commonProject));
ProcessedProviderMessage<SimpleMessage> processedSimpleMessage = ProcessedProviderMessage.singleSource(i, simpleMessage);
processedSimpleMessages.add(processedSimpleMessage);
}
return new ProcessedProviderMessageHolder(processedProjectMessages, processedSimpleMessages);
}
Aggregations