From 7b6eeee57791b86dba62cbfe83738278577b6ef8 Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Thu, 4 Jul 2024 11:52:24 +0300 Subject: [PATCH] Small refactor on public api --- .../publicapi/PublicDatasetsDescriptionDocumentation.java | 8 ++++---- .../controllers/publicapi/PublicPlansDocumentation.java | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java index 0415d2cfe..ace5bb0c9 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicDatasetsDescriptionDocumentation.java @@ -132,11 +132,11 @@ public class PublicDatasetsDescriptionDocumentation { if (model == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{id, Description.class.getSimpleName()}, LocaleContextHolder.getLocale())); - DmpQuery dmpQuery = this.queryFactory.query(DmpQuery.class).disableTracking().ids(model.getDmp().getId()).isActive(IsActive.Active); - DmpLookup dmpLookup = getDmpLookup(); - Dmp dmp = this.builderFactory.builder(DmpBuilder.class).build(dmpLookup.getProject(), dmpQuery.firstAs(dmpLookup.getProject())); + DmpQuery planQuery = this.queryFactory.query(DmpQuery.class).disableTracking().ids(model.getDmp().getId()).isActive(IsActive.Active); + DmpLookup planLookup = getDmpLookup(); + Dmp plan = this.builderFactory.builder(DmpBuilder.class).build(planLookup.getProject(), planQuery.firstAs(planLookup.getProject())); - DatasetPublicModel dataset = this.descriptionToPublicApiDatasetMapper.toPublicModel(model, this.planToPublicApiPlanListingMapper.toPublicListingModel(dmp, this.config.getReferenceTypeMap()), this.config.getReferenceTypeMap()); + DatasetPublicModel dataset = this.descriptionToPublicApiDatasetMapper.toPublicModel(model, this.planToPublicApiPlanListingMapper.toPublicListingModel(plan, this.config.getReferenceTypeMap()), this.config.getReferenceTypeMap()); return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataset)); } diff --git a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicPlansDocumentation.java b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicPlansDocumentation.java index 1f1eb1093..73c256508 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicPlansDocumentation.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/publicapi/PublicPlansDocumentation.java @@ -101,10 +101,10 @@ public class PublicPlansDocumentation { )) @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public @ResponseBody ResponseEntity>> getPaged( - @Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Plan.getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest dmpTableRequest, + @Valid @RequestBody @io.swagger.v3.oas.annotations.parameters.RequestBody(description = PublicApiStaticHelpers.Plan.getPagedRequestBodyDescription) DataManagmentPlanPublicTableRequest planTableRequest, @RequestParam @Parameter(description = PublicApiStaticHelpers.Plan.getPagedRequestParamDescription, example = "listing") String fieldsGroup ) throws Exception { - DmpLookup lookup = getPlanLookup(fieldsGroup, dmpTableRequest); + DmpLookup lookup = getPlanLookup(fieldsGroup, planTableRequest); DmpQuery query = lookup.enrich(this.queryFactory).authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active); long count = this.queryFactory.query(DmpQuery.class).disableTracking().authorize(EnumSet.of(AuthorizationFlags.Public)).isActive(IsActive.Active).count();