Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(chore):962 fixed sentToBpn. #1100

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,896 changes: 948 additions & 948 deletions docs/api/traceability-foss-backend.json

Large diffs are not rendered by default.

1,896 changes: 948 additions & 948 deletions tx-backend/openapi/traceability-foss-backend.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,4 @@ public interface BpnRepository {

BpnEntity save(BusinessPartnerResponse businessPartner);

List<BpnEdcMapping> findAllByIdIn(List<String> bpns);

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ public BpnEntity save(BusinessPartnerResponse businessPartner) {
return repository.save(entity);
}

@Override
public List<BpnEdcMapping> findAllByIdIn(List<String> bpns) {
return this.toDTOList(repository.findAllById(bpns));
}

@Override
public List<BpnEdcMapping> saveAll(List<BpnMappingRequest> bpnEdcMappings) {
List<BpnEntity> bpnEdcMappingEntities = bpnEdcMappings.stream().map(this::toEntity).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.tractusx.traceability.common.model.PageResult;
import org.eclipse.tractusx.traceability.notification.domain.base.model.Notification;
import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationMessage;
import org.eclipse.tractusx.traceability.notification.domain.base.model.NotificationSide;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
Expand All @@ -46,7 +47,7 @@ public static NotificationResponse from(Notification notification) {
.id(notification.getNotificationId().value())
.status(NotificationMessageMapper.from(notification.getNotificationStatus()))
.description(notification.getDescription())
.createdBy(getSenderBPN(notification.getNotifications()))
.createdBy(getSenderBPN(notification))
.createdByName(getSenderName(notification.getNotifications()))
.createdDate(notification.getCreatedAt().toString())
.assetIds(Collections.unmodifiableList(notification.getAffectedPartIds()))
Expand All @@ -73,11 +74,8 @@ public static PageResult<NotificationResponse> fromAsPageResult(PageResult<Notif
return new PageResult<>(investigationDataPage);
}

private static String getSenderBPN(Collection<NotificationMessage> notifications) {
return notifications.stream()
.findFirst()
.map(NotificationMessage::getSentBy)
.orElse(null);
private static String getSenderBPN(Notification notification) {
return notification.getNotificationSide().equals(NotificationSide.SENDER) ? notification.getBpn() : notification.getSendTo();
}

private static String getSenderName(Collection<NotificationMessage> notifications) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public static NotificationMessage create(BPN applicationBpn, String receiverBpn,
.sentByName(creator)
.sentTo(StringUtils.isBlank(receiverBpn) ? asset.getKey() : receiverBpn)
.sendToName(sendToName)
.message(description)
.notificationStatus(NotificationStatus.SENT)
.affectedParts(asset.getValue().stream().map(AssetBase::getId).map(NotificationAffectedPart::new).toList())
.edcNotificationId(notificationId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ private void createMessages(Notification notification, BPN applicationBPN, Asset
.entrySet()
.stream()
.map(it -> {
String creator = getManufacturerNameByBpn(applicationBPN.value());

String firstReceiverBpn = notification.getInitialReceiverBpns().stream()
.findFirst()
.orElseThrow(() -> new NotificationNotFoundException("Initial receiver BPNs not found"));
String sendToName = getManufacturerNameByBpn(firstReceiverBpn);
String creator = getManufacturerNameByBpn(applicationBPN.value());
return NotificationMessage.create(
applicationBPN,
firstReceiverBpn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ void givenNotification_whenFrom_thenConstructProperAlertResponse() {
.hasFieldOrPropertyWithValue("id", notification.getNotificationId().value())
.hasFieldOrPropertyWithValue("status", NotificationStatusResponse.ACCEPTED)
.hasFieldOrPropertyWithValue("description", notification.getDescription())
.hasFieldOrPropertyWithValue("createdBy", notification.getNotifications().stream()
.findFirst()
.map(NotificationMessage::getSentBy)
.orElse(null))
.hasFieldOrPropertyWithValue("createdBy", notification.getBpn())
.hasFieldOrPropertyWithValue("createdByName", notification.getNotifications().stream()
.findFirst()
.map(NotificationMessage::getSentByName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ void givenRequest_whenGetAlert_thenProperResponse() {
.hasFieldOrPropertyWithValue("id", notification.getNotificationId().value())
.hasFieldOrPropertyWithValue("status", NotificationStatusResponse.ACCEPTED)
.hasFieldOrPropertyWithValue("description", notification.getDescription())
.hasFieldOrPropertyWithValue("createdBy", notification.getNotifications().stream()
.findFirst()
.map(NotificationMessage::getSentBy)
.orElse(null))
.hasFieldOrPropertyWithValue("createdBy", notification.getBpn())
.hasFieldOrPropertyWithValue("createdByName", notification.getNotifications().stream()
.findFirst()
.map(NotificationMessage::getSentByName)
Expand Down
Loading