Skip to content

Commit

Permalink
Merge pull request eclipse-tractusx#563 from FraunhoferISST/fix/exclu…
Browse files Browse the repository at this point in the history
…de_partner_self_entity

fix: remove own partner from partner/all endpoint
  • Loading branch information
tom-rm-meyer-ISST authored Aug 26, 2024
2 parents e74e928 + 5acecf2 commit 719e7a8
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2023, 2024 Volkswagen AG
* Copyright (c) 2023, 2024 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
* Copyright (c) 2023 Volkswagen AG
* Copyright (c) 2023 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
* (represented by Fraunhofer ISST)
* Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation
*
Expand Down Expand Up @@ -29,6 +29,7 @@
import jakarta.validation.Validator;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.util.PatternStore;
import org.eclipse.tractusx.puris.backend.common.util.VariablesService;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Address;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
Expand Down Expand Up @@ -59,6 +60,9 @@ public class PartnerController {
@Autowired
private PartnerService partnerService;

@Autowired
private VariablesService variablesService;

@Autowired
private Validator validator;
private final ModelMapper modelMapper = new ModelMapper();
Expand Down Expand Up @@ -221,8 +225,11 @@ public ResponseEntity<PartnerDto> getPartner(
@GetMapping("/all")
@Operation(description = "Returns a list of all Partners. ")
public ResponseEntity<List<PartnerDto>> listPartners() {
return new ResponseEntity<>(partnerService.findAll().
stream().map(partner -> modelMapper.map(partner, PartnerDto.class)).collect(Collectors.toList()),
final String ownBpnl = variablesService.getOwnBpnl();
return new ResponseEntity<>(partnerService.findAll().stream()
.filter(partner -> !partner.getBpnl().equals(ownBpnl))
.map(partner -> modelMapper.map(partner, PartnerDto.class))
.collect(Collectors.toList()),
HttpStatusCode.valueOf(200));
}

Expand Down

0 comments on commit 719e7a8

Please sign in to comment.