From bfbc63ca6d60597b35ed6079afb0090114215ffc Mon Sep 17 00:00:00 2001 From: Gelli Samson Date: Fri, 24 Apr 2020 22:37:02 +0800 Subject: [PATCH 1/5] Fix errors: parameters must have required: true and should be equal to one of the allowed valued allowedValue: true. IBP-3625-FixSwaggerHubErrors --- .../org/ibp/api/rest/germplasmlist/GermplasmListResource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/ibp/api/rest/germplasmlist/GermplasmListResource.java b/src/main/java/org/ibp/api/rest/germplasmlist/GermplasmListResource.java index 6aca9fbee5..8daa9a2ccd 100644 --- a/src/main/java/org/ibp/api/rest/germplasmlist/GermplasmListResource.java +++ b/src/main/java/org/ibp/api/rest/germplasmlist/GermplasmListResource.java @@ -28,7 +28,7 @@ public class GermplasmListResource { @RequestMapping(value = "/crops/{crop}/germplasm-lists/tree", method = RequestMethod.GET) @ResponseBody public ResponseEntity> getGermplasmListByParentFolderId( - @ApiParam("The crop type") @PathVariable final String crop, + @ApiParam(value = "The crop type", required = true) @PathVariable final String crop, @ApiParam("The program UUID") @RequestParam(required = false) final String programUUID, @ApiParam(value = "The id of the parent folder") @RequestParam(required = false) final String parentFolderId, @ApiParam(value = "Only folders") @RequestParam(required = true) final Boolean onlyFolders) { From 61969dafb2ebb2db06048361f181f63efb4dc372 Mon Sep 17 00:00:00 2001 From: Gelli Samson Date: Tue, 28 Apr 2020 10:14:42 +0800 Subject: [PATCH 2/5] Changing the name of the parameter crop to fix issue if 'Equivalent paths are not allowed' IBP-3625-FixSwaggerHubErrors --- .../java/org/ibp/api/rest/inventory/manager/LotResource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java b/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java index 646580e2e3..7f6bee99b1 100644 --- a/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java +++ b/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java @@ -181,10 +181,10 @@ public ResponseEntity updateLots( @ApiOperation(value = "Create list of lots with an initial balance", notes = "Create list of lots with an initial balance") @RequestMapping( - value = "/crops/{crop}/lot-lists", + value = "/crops/{cropName}/lot-lists", method = RequestMethod.POST) @PreAuthorize(HAS_MANAGE_LOTS + " or hasAnyAuthority('IMPORT_LOTS')") - public ResponseEntity importLotsWithInitialBalance(@PathVariable final String crop, + public ResponseEntity importLotsWithInitialBalance(@PathVariable final String cropName, @RequestBody final LotImportRequestDto lotImportRequestDto) { this.lotService.importLotsWithInitialTransaction(lotImportRequestDto); return new ResponseEntity<>(HttpStatus.OK); From 3ccd20a128b8c2c27f106b12dda4a6c5f4bf87db Mon Sep 17 00:00:00 2001 From: Gelli Samson Date: Tue, 28 Apr 2020 10:17:10 +0800 Subject: [PATCH 3/5] Clean up: add this to local variables IBP-3625-FixSwaggerHubErrors --- .../ibp/api/rest/inventory/manager/LotResource.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java b/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java index 7f6bee99b1..bce00019d4 100644 --- a/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java +++ b/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java @@ -147,7 +147,7 @@ public ResponseEntity createLot( @PathVariable final String cropName, @ApiParam("Lot to be created") @RequestBody final LotGeneratorInputDto lotGeneratorInputDto) { - return new ResponseEntity<>(lotService.saveLot(lotGeneratorInputDto), HttpStatus.CREATED); + return new ResponseEntity<>(this.lotService.saveLot(lotGeneratorInputDto), HttpStatus.CREATED); } @ApiOperation(value = "Update Lots", notes = "Update one or more Lots") @@ -166,7 +166,7 @@ public ResponseEntity updateLots( searchRequestId = searchCompositeDto.getSearchRequestId(); lotIds = searchCompositeDto.getItemIds(); } - final LotsSearchDto searchDTO = validateSearchComposite(searchRequestId, lotIds, errors); + final LotsSearchDto searchDTO = this.validateSearchComposite(searchRequestId, lotIds, errors); final List extendedLotDtos = this.lotService.searchLots(searchDTO, null); if (extendedLotDtos == null || (searchRequestId == null && lotIds != null && extendedLotDtos.size() != lotIds.size())) { @@ -200,7 +200,7 @@ public ResponseEntity getTemplate(@PathVariable final String final VariableFilter variableFilter = new VariableFilter(); variableFilter.addPropertyId(TermId.INVENTORY_AMOUNT_PROPERTY.getId()); final List units = this.variableService.getVariablesByFilter(variableFilter); - final List locations = locationService.getLocations(LotResource.STORAGE_LOCATION_TYPE, null, false, null); + final List locations = this.locationService.getLocations(LotResource.STORAGE_LOCATION_TYPE, null, false, null); final File file = this.lotTemplateExportServiceImpl.export(locations, units); final HttpHeaders headers = new HttpHeaders(); @@ -218,7 +218,7 @@ public ResponseEntity getLotSearchMetadata(@PathVariable fina @RequestParam(required = false) final Integer searchRequestId, @RequestParam(required = false) final Set lotIds) { final BindingResult errors = new MapBindingResult(new HashMap(), Integer.class.getName()); - final LotsSearchDto searchDTO = validateSearchComposite(searchRequestId, lotIds, errors); + final LotsSearchDto searchDTO = this.validateSearchComposite(searchRequestId, lotIds, errors); if (searchRequestId == null) { final List extendedLotDtos = this.lotService.searchLots(searchDTO, null); @@ -228,7 +228,7 @@ public ResponseEntity getLotSearchMetadata(@PathVariable fina } } - return new ResponseEntity<>(lotService.getLotsSearchMetadata(searchDTO), HttpStatus.OK); + return new ResponseEntity<>(this.lotService.getLotsSearchMetadata(searchDTO), HttpStatus.OK); } // TODO Use SearchComposito.isValid From 3cd710c2cdeb42a6ddba680e5d89c3328d13cc31 Mon Sep 17 00:00:00 2001 From: Gelli Samson Date: Tue, 28 Apr 2020 10:39:27 +0800 Subject: [PATCH 4/5] Resolve conflicts. Re-apply fix for the error 'Equivalent paths are not allowed' IBP-3625-FixSwaggerHubErrors --- .../java/org/ibp/api/rest/inventory/manager/LotResource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java b/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java index e3b7162e54..f939140f55 100644 --- a/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java +++ b/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java @@ -184,10 +184,10 @@ public ResponseEntity updateLots( @ApiOperation(value = "Create list of lots with an initial balance", notes = "Create list of lots with an initial balance") @RequestMapping( - value = "/crops/{crop}/lot-lists", + value = "/crops/{cropName}/lot-lists", method = RequestMethod.POST) @PreAuthorize(HAS_MANAGE_LOTS + " or hasAnyAuthority('IMPORT_LOTS')") - public ResponseEntity importLotsWithInitialBalance(@PathVariable final String crop, + public ResponseEntity importLotsWithInitialBalance(@PathVariable final String cropName, @RequestBody final LotImportRequestDto lotImportRequestDto) { this.lotService.importLotsWithInitialTransaction(lotImportRequestDto); return new ResponseEntity<>(HttpStatus.OK); From 07b284be68f91e47bfe4c6ffc37832b7c4055554 Mon Sep 17 00:00:00 2001 From: Gelli Samson Date: Tue, 28 Apr 2020 10:41:14 +0800 Subject: [PATCH 5/5] Code clean up: Add this to instance variables/methods IBP-3625-FixSwaggerHubErrors --- .../ibp/api/rest/inventory/manager/LotResource.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java b/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java index f939140f55..2d6179ab51 100644 --- a/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java +++ b/src/main/java/org/ibp/api/rest/inventory/manager/LotResource.java @@ -157,7 +157,7 @@ public ResponseEntity createLot( @PathVariable final String cropName, @ApiParam("Lot to be created") @RequestBody final LotGeneratorInputDto lotGeneratorInputDto) { - return new ResponseEntity<>(lotService.saveLot(lotGeneratorInputDto), HttpStatus.CREATED); + return new ResponseEntity<>(this.lotService.saveLot(lotGeneratorInputDto), HttpStatus.CREATED); } @ApiOperation(value = "Update Lots", notes = "Update one or more Lots") @@ -170,7 +170,7 @@ public ResponseEntity updateLots( final BindingResult errors = new MapBindingResult(new HashMap(), Integer.class.getName()); this.inventoryCommonValidator.validateSearchCompositeDto(lotRequest.getSearchComposite(), errors); - final LotsSearchDto searchDTO = searchRequestDtoResolver.getLotsSearchDto(lotRequest.getSearchComposite()); + final LotsSearchDto searchDTO = this.searchRequestDtoResolver.getLotsSearchDto(lotRequest.getSearchComposite()); final List extendedLotDtos = this.lotService.searchLots(searchDTO, null); if (lotRequest.getSearchComposite().getSearchRequestId() == null) { @@ -203,7 +203,7 @@ public ResponseEntity getTemplate(@PathVariable final String final VariableFilter variableFilter = new VariableFilter(); variableFilter.addPropertyId(TermId.INVENTORY_AMOUNT_PROPERTY.getId()); final List units = this.variableService.getVariablesByFilter(variableFilter); - final List locations = locationService.getLocations(LotResource.STORAGE_LOCATION_TYPE, null, false, null); + final List locations = this.locationService.getLocations(LotResource.STORAGE_LOCATION_TYPE, null, false, null); final File file = this.lotTemplateExportServiceImpl.export(locations, units); final HttpHeaders headers = new HttpHeaders(); @@ -223,14 +223,14 @@ public ResponseEntity getLotSearchMetadata(@PathVariable fina final BindingResult errors = new MapBindingResult(new HashMap(), Integer.class.getName()); this.inventoryCommonValidator.validateSearchCompositeDto(searchCompositeDto, errors); - final LotsSearchDto searchDTO = searchRequestDtoResolver.getLotsSearchDto(searchCompositeDto); + final LotsSearchDto searchDTO = this.searchRequestDtoResolver.getLotsSearchDto(searchCompositeDto); if (searchCompositeDto.getSearchRequestId() == null) { final List extendedLotDtos = this.lotService.searchLots(searchDTO, null); this.extendedLotListValidator.validateAllProvidedLotIdsExist(extendedLotDtos, searchCompositeDto.getItemIds()); } - return new ResponseEntity<>(lotService.getLotsSearchMetadata(searchDTO), HttpStatus.OK); + return new ResponseEntity<>(this.lotService.getLotsSearchMetadata(searchDTO), HttpStatus.OK); } @ApiOperation(value = "Close Lots", notes = "Close a collection of lots") @@ -244,7 +244,7 @@ public ResponseEntity closeLots( final BindingResult errors = new MapBindingResult(new HashMap(), LotService.class.getName()); this.inventoryCommonValidator.validateSearchCompositeDto(searchCompositeDto, errors); - final LotsSearchDto searchDTO = searchRequestDtoResolver.getLotsSearchDto(searchCompositeDto); + final LotsSearchDto searchDTO = this.searchRequestDtoResolver.getLotsSearchDto(searchCompositeDto); if (searchCompositeDto.getSearchRequestId() == null) { final List extendedLotDtos = this.lotService.searchLots(searchDTO, null);