Skip to content

Commit

Permalink
Merge pull request #1146 from catenax-ng/chore/547-adaptions-screenre…
Browse files Browse the repository at this point in the history
…cording

Chore/547 adaptions screenrecording
  • Loading branch information
ds-mwesener authored Apr 4, 2024
2 parents 05a49ca + 95c2c4d commit 0c058bb
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
_**For better traceability add the corresponding GitHub issue number in each changelog entry, please.**_

## [UNRELEASED - DD.MM.YYYY]
### Removed
- #547 Removed classification check on alert / investigation update callback methods

## [10.8.1 - 04.04.2024]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import java.util.ArrayList;
import java.util.List;

import static org.apache.commons.collections4.ListUtils.emptyIfNull;

@RequiredArgsConstructor
@Component
public class NotificationMapper {
Expand All @@ -49,7 +51,7 @@ public class NotificationMapper {
public Notification toNotification(BPN bpn, String description, NotificationMessage notification, NotificationType notificationType) {

List<String> assetIds = new ArrayList<>();
notification.getAffectedParts().stream()
emptyIfNull(notification.getAffectedParts()).stream()
.map(NotificationAffectedPart::assetId)
.forEach(assetIds::add);
return Notification.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import java.time.LocalDateTime;
import java.util.UUID;

import static org.apache.commons.collections4.ListUtils.emptyIfNull;

@Component
@RequiredArgsConstructor
public class NotificationMessageMapper {
Expand All @@ -56,7 +58,7 @@ public NotificationMessage toNotification(EDCNotification edcNotification, Notif
.sendToName(getManufacturerName(edcNotification.getRecipientBPN()))
.description(edcNotification.getInformation())
.notificationStatus(edcNotification.convertNotificationStatus())
.affectedParts(edcNotification.getListOfAffectedItems())
.affectedParts(emptyIfNull(edcNotification.getListOfAffectedItems()))
.targetDate(edcNotification.getTargetDate())
.severity(NotificationSeverity.fromString(edcNotification.getSeverity()))
.edcNotificationId(edcNotification.getNotificationId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.util.List;
import java.util.Optional;

import static org.apache.commons.collections4.ListUtils.emptyIfNull;

@Data
@Builder(toBuilder = true)
@Slf4j
Expand Down Expand Up @@ -135,7 +137,7 @@ public void addNotificationMessage(NotificationMessage notification) {
notifications = Collections.unmodifiableList(updatedNotifications);

List<String> newAssetIds = new ArrayList<>(assetIds); // create a mutable copy of assetIds
notification.getAffectedParts().stream()
emptyIfNull(notification.getAffectedParts()).stream()
.map(NotificationAffectedPart::assetId)
.forEach(newAssetIds::add);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class NotificationMessage {
private final String createdByName;
private final String sendToName;
@Builder.Default
private final List<NotificationAffectedPart> affectedParts = new ArrayList<>();
private List<NotificationAffectedPart> affectedParts = new ArrayList<>();
private String notificationReferenceId;
private String createdBy;
private String sendTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.eclipse.tractusx.traceability.notification.domain.notification.repository.NotificationRepository;
import org.eclipse.tractusx.traceability.notification.infrastructure.edc.model.EDCNotification;

import static org.apache.commons.collections4.ListUtils.emptyIfNull;

@Slf4j
public abstract class AbstractNotificationReceiverService implements NotificationReceiverService {

Expand All @@ -53,9 +55,11 @@ public void handleReceive(EDCNotification edcNotification, NotificationType noti

@Override
public void handleUpdate(EDCNotification edcNotification, NotificationType notificationType) {
NotificationMessage notificationMessage = getNotificationMessageMapper().toNotification(edcNotification, notificationType);

Notification notification = getRepository().findByEdcNotificationId(edcNotification.getNotificationId())
.orElseThrow(() -> getNotFoundException(edcNotification.getNotificationId()));
NotificationMessage notificationMessage = getNotificationMessageMapper().toNotification(edcNotification, notificationType);
emptyIfNull(notification.getNotifications()).stream().findFirst().ifPresent(notificationMessage1 -> notificationMessage.setAffectedParts(notificationMessage1.getAffectedParts()));

switch (edcNotification.convertNotificationStatus()) {
case ACKNOWLEDGED -> notification.acknowledge();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public void investigationNotificationReceive(final @ValidEDCNotification @Valid
public void investigationNotificationUpdate(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) {
EDCNotification cleanEdcNotification = sanitize(edcNotification);
log.info("EdcController [investigationNotificationUpdate] notificationId:{}", cleanEdcNotification);
validateIsInvestigation(cleanEdcNotification);
notificationReceiverService.handleUpdate(cleanEdcNotification, NotificationType.INVESTIGATION);
}

Expand Down Expand Up @@ -288,7 +287,6 @@ public void alertNotificationReceive(final @ValidEDCNotification @Valid @Request
public void alertNotificationUpdate(final @ValidEDCNotification @Valid @RequestBody EDCNotification edcNotification) {
EDCNotification cleanEdcNotification = sanitize(edcNotification);
log.info("EdcController [alertNotificationUpdate] notificationId:{}", cleanEdcNotification);
validateIsAlert(cleanEdcNotification);
notificationReceiverService.handleUpdate(cleanEdcNotification, NotificationType.ALERT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import java.util.List;

import static org.apache.commons.collections4.ListUtils.emptyIfNull;

public class EDCNotificationFactory {

private EDCNotificationFactory() {
Expand Down Expand Up @@ -60,7 +62,7 @@ public static EDCNotification createEdcNotification(String senderEDC, Notificati


private static List<String> extractAssetIds(NotificationMessage notification) {
return notification.getAffectedParts().stream()
return emptyIfNull(notification.getAffectedParts()).stream()
.map(NotificationAffectedPart::assetId).toList();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@
"senderBPN" : "BPNL00000003AXS3",
"senderAddress" : "https://some-url.com",
"recipientBPN" : "BPNL00000003AXS3",
"classification" : "QM-Investigation",
"severity" : "CRITICAL",
"relatedNotificationId" : "REPLACE_ME",
"status" : "ACKNOWLEDGED",
"targetDate" : "2099-03-11T22:44:06.333826952Z"
},
"content" : {
"information" : "Some long description",
"listOfAffectedItems" : [
"urn:uuid:d387fa8e-603c-42bd-98c3-4d87fef8d2bb"
]
"information" : "Some long description"
}
}

0 comments on commit 0c058bb

Please sign in to comment.