Skip to content

Commit

Permalink
Merge branch 'main' into feat/itemstock
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-rm-meyer-ISST committed Dec 20, 2023
2 parents 903b2a9 + 2aca97c commit 7299ab9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<MaterialEntityDto> 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) {
Expand All @@ -138,7 +135,6 @@ public ResponseEntity<MaterialEntityDto> getMaterial(@Parameter(name = "ownMater

@GetMapping("/all")
@Operation(description = "Returns a list of all Materials and Products.")
@CrossOrigin
public ResponseEntity<List<MaterialEntityDto>> listMaterials() {
return new ResponseEntity<>(materialService.findAll().
stream().map(x -> modelMapper.map(x, MaterialEntityDto.class)).collect(Collectors.toList()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -168,8 +167,6 @@ public ResponseEntity<?> addSite(
return new ResponseEntity<>(HttpStatusCode.valueOf(200));
}


@CrossOrigin
@GetMapping
@Operation(description = "Returns the requested PartnerDto.")
@ApiResponses(value = {
Expand All @@ -196,7 +193,6 @@ public ResponseEntity<PartnerDto> getPartner(
}
}

@CrossOrigin
@GetMapping("/all")
@Operation(description = "Returns a list of all Partners. ")
public ResponseEntity<List<PartnerDto>> listPartners() {
Expand All @@ -205,4 +201,20 @@ public ResponseEntity<List<PartnerDto>> listPartners() {
HttpStatusCode.valueOf(200));
}

@GetMapping("/ownSites")
@Operation(description = "Returns all sites of the puris partner using the puris system.")
public ResponseEntity<List<SiteDto>> 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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public class StockViewController {
@GetMapping("materials")
@ResponseBody
@Operation(description = "Returns a list of all materials (excluding products)")
@CrossOrigin
public List<FrontendMaterialDto> getMaterials() {
return materialService.findAllMaterials()
.stream()
Expand All @@ -112,7 +111,6 @@ public List<FrontendMaterialDto> getMaterials() {
" \"BPNL1234567890ZZ\": \"MNR-8101-ID146955.001\"," +
" \"BPNL4444444444XX\": \"MNR-7307-AU340474.002\"}")})),
@ApiResponse(responseCode = "400", description = "Invalid parameter")})
@CrossOrigin
public ResponseEntity<Map<String, String>> getMaterialNumbers(@RequestParam String ownMaterialNumber) {
if (!materialPattern.matcher(ownMaterialNumber).matches()) {
return new ResponseEntity<>(HttpStatusCode.valueOf(400));
Expand All @@ -123,15 +121,14 @@ public ResponseEntity<Map<String, String>> getMaterialNumbers(@RequestParam Stri
@GetMapping("products")
@ResponseBody
@Operation(description = "Returns a list of all products (excluding materials)")
@CrossOrigin
public List<FrontendMaterialDto> getProducts() {
return materialService.findAllProducts()
.stream()
.map(mat -> new FrontendMaterialDto(mat.getOwnMaterialNumber(), mat.getName()))
.collect(Collectors.toList());
}

@CrossOrigin

@GetMapping("product-stocks")
@ResponseBody
@Operation(description = "Returns a list of all product-stocks")
Expand All @@ -141,7 +138,6 @@ public List<ProductStockDto> getProductStocks() {
.collect(Collectors.toList());
}

@CrossOrigin
@PostMapping("product-stocks")
@ResponseBody
@Operation(description = "Creates a new product-stock")
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -207,7 +201,6 @@ public List<MaterialStockDto> getMaterialStocks() {
return allMaterialStocks;
}

@CrossOrigin
@PostMapping("material-stocks")
@ResponseBody
@Operation(description = "Creates a new material-stock")
Expand All @@ -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")
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -288,7 +279,6 @@ private PartnerProductStockDto convertToDto(PartnerProductStock entity) {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Invalid parameter")
})
@CrossOrigin
public ResponseEntity<List<PartnerDto>> getCustomerPartnersOrderingMaterial(@RequestParam String ownMaterialNumber) {
if(!materialPattern.matcher(ownMaterialNumber).matches()) {
return new ResponseEntity<>(HttpStatusCode.valueOf(400));
Expand All @@ -308,7 +298,6 @@ public ResponseEntity<List<PartnerDto>> getCustomerPartnersOrderingMaterial(@Req
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Invalid parameter")
})
@CrossOrigin
public ResponseEntity<List<PartnerDto>> triggerPartnerProductStockUpdateForMaterial(@RequestParam String ownMaterialNumber) {
if(!materialPattern.matcher(ownMaterialNumber).matches()) {
return new ResponseEntity<>(HttpStatusCode.valueOf(400));
Expand Down

0 comments on commit 7299ab9

Please sign in to comment.