Small refactor on public api

This commit is contained in:
Thomas Georgios Giannos 2024-07-04 11:52:24 +03:00
parent 33a2bfeef4
commit 7b6eeee577
2 changed files with 6 additions and 6 deletions

View File

@ -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<DatasetPublicModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
}

View File

@ -101,10 +101,10 @@ public class PublicPlansDocumentation {
))
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<DataManagementPlanPublicListingModel>>> 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();