diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialController.java index 94a733d7..cbf7cc7f 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialController.java @@ -56,7 +56,6 @@ public class MaterialController { @ApiResponse(responseCode = "409", description = "Material with the given ownMaterialNumber already exists."), @ApiResponse(responseCode = "500", description = "Internal Server error.") }) - @CrossOrigin public ResponseEntity createMaterial(@RequestBody MaterialEntityDto materialDto) { if (materialDto.getOwnMaterialNumber() == null || materialDto.getOwnMaterialNumber().isEmpty()) { // Cannot create material without ownMaterialNumber @@ -88,7 +87,6 @@ public ResponseEntity createMaterial(@RequestBody MaterialEntityDto materialD @ApiResponse(responseCode = "404", description = "No existing Material Entity found, no update was performed."), @ApiResponse(responseCode = "500", description = "Internal Server Error.") }) - @CrossOrigin public ResponseEntity updateMaterial(@RequestBody MaterialEntityDto materialDto) { if (materialDto.getOwnMaterialNumber() == null || materialDto.getOwnMaterialNumber().isEmpty()) { // Cannot update material without ownMaterialNumber @@ -120,7 +118,6 @@ public ResponseEntity updateMaterial(@RequestBody MaterialEntityDto materialD @ApiResponse(responseCode = "400", description = "Invalid parameter"), @ApiResponse(responseCode = "404", description = "Requested Material was not found.") }) - @CrossOrigin public ResponseEntity getMaterial(@Parameter(name = "ownMaterialNumber", description = "The Material Number that is used in your own company to identify the Material.", example = "MNR-7307-AU340474.002") @RequestParam String ownMaterialNumber) { @@ -138,7 +135,6 @@ public ResponseEntity getMaterial(@Parameter(name = "ownMater @GetMapping("/all") @Operation(description = "Returns a list of all Materials and Products.") - @CrossOrigin public ResponseEntity> listMaterials() { return new ResponseEntity<>(materialService.findAll(). stream().map(x -> modelMapper.map(x, MaterialEntityDto.class)).collect(Collectors.toList()), diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/PartnerController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/PartnerController.java index df7a8ac9..8e556f6e 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/PartnerController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/PartnerController.java @@ -35,10 +35,12 @@ import org.modelmapper.Conditions; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -61,7 +63,6 @@ public class PartnerController { @ApiResponse(responseCode = "400", description = "Request body was malformed, didn't meet the minimum constraints or wrongfully contained a UUID."), @ApiResponse(responseCode = "409", description = "The BPNL specified in the request body is already assigned. ") }) - @CrossOrigin public ResponseEntity createPartner(@RequestBody PartnerDto partnerDto) { modelMapper.getConfiguration().setPropertyCondition(Conditions.isNotNull()); // Any given UUID is wrong by default since we're creating a new Partner entity @@ -92,7 +93,6 @@ public ResponseEntity createPartner(@RequestBody PartnerDto partnerDto) { } @PutMapping("putAddress") - @CrossOrigin @Operation(description = "Updates an existing Partner by adding a new Address. If that Partner already has " + "an Address with the BPNA given in the request body, that existing Address will be overwritten. ") @ApiResponses(value = { @@ -138,7 +138,6 @@ public ResponseEntity addAddress( @ApiResponse(responseCode = "404", description = "Partner not found."), @ApiResponse(responseCode = "500", description = "Internal Server Error.") }) - @CrossOrigin public ResponseEntity addSite( @Parameter(description = "The unique BPNL that was assigned to that Partner.", example = "BPNL2222222222RR") @RequestParam() String partnerBpnl, @@ -168,8 +167,6 @@ public ResponseEntity addSite( return new ResponseEntity<>(HttpStatusCode.valueOf(200)); } - - @CrossOrigin @GetMapping @Operation(description = "Returns the requested PartnerDto.") @ApiResponses(value = { @@ -196,7 +193,6 @@ public ResponseEntity getPartner( } } - @CrossOrigin @GetMapping("/all") @Operation(description = "Returns a list of all Partners. ") public ResponseEntity> listPartners() { @@ -205,4 +201,20 @@ public ResponseEntity> listPartners() { HttpStatusCode.valueOf(200)); } + @GetMapping("/ownSites") + @Operation(description = "Returns all sites of the puris partner using the puris system.") + public ResponseEntity> getOwnSites() { + Partner ownPartnerEntity = partnerService.getOwnPartnerEntity(); + + if (ownPartnerEntity == null || ownPartnerEntity.getSites() == null || + ownPartnerEntity.getSites().isEmpty()) { + return new ResponseEntity<>(new ArrayList<>(), HttpStatus.OK); + } + + return new ResponseEntity<>(partnerService.getOwnPartnerEntity(). + getSites(). + stream().map(site -> modelMapper.map(site, SiteDto.class)).collect(Collectors.toList()), + HttpStatus.OK); + } + } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockViewController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockViewController.java index 4d8fb72f..58795d57 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockViewController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/controller/StockViewController.java @@ -95,7 +95,6 @@ public class StockViewController { @GetMapping("materials") @ResponseBody @Operation(description = "Returns a list of all materials (excluding products)") - @CrossOrigin public List getMaterials() { return materialService.findAllMaterials() .stream() @@ -112,7 +111,6 @@ public List getMaterials() { " \"BPNL1234567890ZZ\": \"MNR-8101-ID146955.001\"," + " \"BPNL4444444444XX\": \"MNR-7307-AU340474.002\"}")})), @ApiResponse(responseCode = "400", description = "Invalid parameter")}) - @CrossOrigin public ResponseEntity> getMaterialNumbers(@RequestParam String ownMaterialNumber) { if (!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); @@ -123,7 +121,6 @@ public ResponseEntity> getMaterialNumbers(@RequestParam Stri @GetMapping("products") @ResponseBody @Operation(description = "Returns a list of all products (excluding materials)") - @CrossOrigin public List getProducts() { return materialService.findAllProducts() .stream() @@ -131,7 +128,7 @@ public List getProducts() { .collect(Collectors.toList()); } - @CrossOrigin + @GetMapping("product-stocks") @ResponseBody @Operation(description = "Returns a list of all product-stocks") @@ -141,7 +138,6 @@ public List getProductStocks() { .collect(Collectors.toList()); } - @CrossOrigin @PostMapping("product-stocks") @ResponseBody @Operation(description = "Creates a new product-stock") @@ -160,7 +156,6 @@ public ProductStockDto createProductStocks(@RequestBody ProductStockDto productS return convertToDto(createdProductStock); } - @CrossOrigin @PutMapping("product-stocks") @ResponseBody @Operation(description = "Updates an existing product-stock") @@ -195,7 +190,6 @@ private ProductStock convertToEntity(ProductStockDto dto) { return productStock; } - @CrossOrigin @GetMapping("material-stocks") @ResponseBody @Operation(description = "Returns a list of all material-stocks") @@ -207,7 +201,6 @@ public List getMaterialStocks() { return allMaterialStocks; } - @CrossOrigin @PostMapping("material-stocks") @ResponseBody @Operation(description = "Creates a new material-stock") @@ -221,7 +214,6 @@ public MaterialStockDto createMaterialStocks(@RequestBody MaterialStockDto mater return convertToDto(createdMaterialStock); } - @CrossOrigin @PutMapping("material-stocks") @ResponseBody @Operation(description = "Updates an existing material-stock") @@ -253,7 +245,6 @@ private MaterialStock convertToEntity(MaterialStockDto dto) { return stock; } - @CrossOrigin @GetMapping("partner-product-stocks") @Operation(description = "Returns a list of all partner-product-stocks that refer to the given material number") @ApiResponses(value = { @@ -288,7 +279,6 @@ private PartnerProductStockDto convertToDto(PartnerProductStock entity) { @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid parameter") }) - @CrossOrigin public ResponseEntity> getCustomerPartnersOrderingMaterial(@RequestParam String ownMaterialNumber) { if(!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400)); @@ -308,7 +298,6 @@ public ResponseEntity> getCustomerPartnersOrderingMaterial(@Req @ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Invalid parameter") }) - @CrossOrigin public ResponseEntity> triggerPartnerProductStockUpdateForMaterial(@RequestParam String ownMaterialNumber) { if(!materialPattern.matcher(ownMaterialNumber).matches()) { return new ResponseEntity<>(HttpStatusCode.valueOf(400));