use of com.synopsys.integration.alert.channel.email.attachment.compatibility.ProviderMessageContent in project hub-alert by blackducksoftware.
the class MessageContentGroupCsvCreator method createCsvString.
public String createCsvString(MessageContentGroup messageContentGroup) {
LinkableItem commonProvider = messageContentGroup.getCommonProvider();
LinkableItem commonProject = messageContentGroup.getCommonTopic();
List<ProviderMessageContent> contents = messageContentGroup.getSubContent();
StringBuilder csvBuilder = new StringBuilder();
List<String> columnNames = createColumnNames(commonProject, contents);
appendLine(csvBuilder, columnNames);
List<List<String>> rowValues = createRowValues(commonProvider, commonProject, contents);
for (List<String> row : rowValues) {
appendLine(csvBuilder, row);
}
return csvBuilder.toString();
}
use of com.synopsys.integration.alert.channel.email.attachment.compatibility.ProviderMessageContent in project hub-alert by blackducksoftware.
the class MessageContentGroupCsvCreator method createRowValues.
private List<List<String>> createRowValues(LinkableItem commonProvider, LinkableItem commonTopic, List<ProviderMessageContent> contents) {
List<List<String>> rows = new ArrayList<>();
for (ProviderMessageContent message : contents) {
String subTopicValue = createOptionalValueString(message.getSubTopic(), LinkableItem::getValue);
Set<ComponentItem> componentItems = extractComponentItemsOrDefault(message);
for (ComponentItem componentItem : componentItems) {
List<String> columnValues = createColumnValues(commonProvider.getLabel(), commonProvider.getValue(), commonTopic.getValue(), subTopicValue, componentItem);
rows.add(columnValues);
}
}
return rows;
}
use of com.synopsys.integration.alert.channel.email.attachment.compatibility.ProviderMessageContent in project hub-alert by blackducksoftware.
the class ProjectMessageToMessageContentGroupConversionUtils method toMessageContentGroup.
public static MessageContentGroup toMessageContentGroup(ProjectMessage projectMessage) {
ProviderMessageContent.Builder providerMessageContentBuilder = new ProviderMessageContent.Builder();
LinkableItem provider = projectMessage.getProvider();
providerMessageContentBuilder.applyProvider(provider.getLabel(), -1L, provider.getValue(), provider.getUrl().orElse(null));
LinkableItem project = projectMessage.getProject();
providerMessageContentBuilder.applyTopic(project.getLabel(), project.getValue(), project.getUrl().orElse(null));
Optional<LinkableItem> optionalProjectVersion = projectMessage.getProjectVersion();
if (optionalProjectVersion.isPresent()) {
LinkableItem projectVersion = optionalProjectVersion.get();
providerMessageContentBuilder.applySubTopic(projectVersion.getLabel(), projectVersion.getValue(), projectVersion.getUrl().orElse(null));
}
projectMessage.getOperation().map(ProjectMessageToMessageContentGroupConversionUtils::convertToItemOperation).ifPresent(providerMessageContentBuilder::applyAction);
MessageContentGroup messageContentGroup = new MessageContentGroup();
List<ComponentItem> componentItems = new LinkedList<>();
for (BomComponentDetails bomComponent : projectMessage.getBomComponents()) {
List<ComponentItem> bomComponentItems = convertToComponentItems(bomComponent);
componentItems.addAll(bomComponentItems);
}
providerMessageContentBuilder.applyAllComponentItems(componentItems);
try {
ProviderMessageContent providerMessageContent = providerMessageContentBuilder.build();
messageContentGroup.add(providerMessageContent);
} catch (AlertException e) {
// Ignore for feature parity
}
return messageContentGroup;
}
Aggregations