Search in sources :

Example 1 with ProviderMessageContent

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();
}
Also used : ProviderMessageContent(com.synopsys.integration.alert.channel.email.attachment.compatibility.ProviderMessageContent) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with ProviderMessageContent

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;
}
Also used : ComponentItem(com.synopsys.integration.alert.channel.email.attachment.compatibility.ComponentItem) ProviderMessageContent(com.synopsys.integration.alert.channel.email.attachment.compatibility.ProviderMessageContent) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with ProviderMessageContent

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;
}
Also used : ComponentItem(com.synopsys.integration.alert.channel.email.attachment.compatibility.ComponentItem) ProviderMessageContent(com.synopsys.integration.alert.channel.email.attachment.compatibility.ProviderMessageContent) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) MessageContentGroup(com.synopsys.integration.alert.channel.email.attachment.compatibility.MessageContentGroup) LinkedList(java.util.LinkedList) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) BomComponentDetails(com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)

Aggregations

ProviderMessageContent (com.synopsys.integration.alert.channel.email.attachment.compatibility.ProviderMessageContent)3 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)3 ComponentItem (com.synopsys.integration.alert.channel.email.attachment.compatibility.ComponentItem)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 MessageContentGroup (com.synopsys.integration.alert.channel.email.attachment.compatibility.MessageContentGroup)1 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)1 LinkedList (java.util.LinkedList)1