Search in sources :

Example 31 with NotificationEntity

use of com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity in project hub-alert by blackducksoftware.

the class NotificationManager method saveNotification.

public NotificationModel saveNotification(final NotificationModel notification) {
    final NotificationEntity notificationEntity = notificationRepository.save(notification.getNotificationEntity());
    List<VulnerabilityEntity> vulnerabilities = Collections.emptyList();
    if (notification.getVulnerabilityList() != null) {
        final Collection<VulnerabilityEntity> vulnerabilityList = notification.getVulnerabilityList();
        final List<VulnerabilityEntity> vulnerabilitiesToSave = vulnerabilityList.stream().map(vulnerability -> new VulnerabilityEntity(vulnerability.getVulnerabilityId(), vulnerability.getOperation(), notificationEntity.getId())).collect(Collectors.toList());
        vulnerabilities = vulnerabilityRepository.save(vulnerabilitiesToSave);
    }
    return new NotificationModel(notificationEntity, vulnerabilities);
}
Also used : AuditEntryRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper) VulnerabilityRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper) VulnerabilityEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity) Date(java.util.Date) Collection(java.util.Collection) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) AuditNotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper) List(java.util.List) Component(org.springframework.stereotype.Component) NotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) NotificationEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity) AuditNotificationRelation(com.blackducksoftware.integration.hub.alert.audit.repository.relation.AuditNotificationRelation) Collections(java.util.Collections) VulnerabilityEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity) NotificationModel(com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel) NotificationEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity)

Aggregations

NotificationEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.NotificationEntity)31 NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)21 Test (org.junit.Test)20 DatabaseConnectionTest (com.blackducksoftware.integration.test.annotation.DatabaseConnectionTest)18 Date (java.util.Date)17 VulnerabilityEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.VulnerabilityEntity)12 NotificationCategoryEnum (com.blackducksoftware.integration.hub.notification.NotificationCategoryEnum)8 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)6 ArrayList (java.util.ArrayList)6 AuditNotificationRelation (com.blackducksoftware.integration.hub.alert.audit.repository.relation.AuditNotificationRelation)4 LocalDateTime (java.time.LocalDateTime)4 AuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryEntity)3 ConfiguredProjectEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.ConfiguredProjectEntity)3 DistributionProjectRelation (com.blackducksoftware.integration.hub.alert.datasource.relation.DistributionProjectRelation)3 DigestTypeEnum (com.blackducksoftware.integration.hub.alert.enumeration.DigestTypeEnum)3 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)3 MockNotificationEntity (com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity)3 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)3 HipChatEvent (com.blackducksoftware.integration.hub.alert.channel.hipchat.HipChatEvent)2 VulnerabilityOperationEnum (com.blackducksoftware.integration.hub.alert.enumeration.VulnerabilityOperationEnum)2