From c294b7366428cd2b585006468395955f7f6a3af6 Mon Sep 17 00:00:00 2001 From: Thomas Georgios Giannos Date: Thu, 6 Jun 2024 16:14:21 +0300 Subject: [PATCH] Refactoring swagger constants --- .../controllers/DescriptionController.java | 197 +--- .../opencdmp/controllers/DmpController.java | 262 ++--- .../controllers/swagger/SwaggerHelpers.java | 1047 +++++++++++++++++ 3 files changed, 1135 insertions(+), 371 deletions(-) create mode 100644 backend/web/src/main/java/org/opencdmp/controllers/swagger/SwaggerHelpers.java diff --git a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java index 26b146928..40985a172 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DescriptionController.java @@ -23,6 +23,7 @@ import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.enums.DmpAccessType; import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.controllers.swagger.SwaggerHelpers; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.StorageFileEntity; import org.opencdmp.model.DescriptionValidationResult; @@ -151,16 +152,16 @@ public class DescriptionController { @PostMapping("query") @Operation( summary = "Query all descriptions", - description = SwaggerHelpers.endpoint_query, + description = SwaggerHelpers.Description.endpoint_query, requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( - description = SwaggerHelpers.endpoint_query_request_body, + description = SwaggerHelpers.Description.endpoint_query_request_body, content = { @Content( examples = { @ExampleObject( name = "Pagination and projection", description = "Simple paginated request using a property projection list and pagination info", - value = SwaggerHelpers.endpoint_query_request_body_example + value = SwaggerHelpers.Description.endpoint_query_request_body_example ) } ) @@ -184,7 +185,7 @@ public class DescriptionController { @Operation(summary = "Fetch a specific description by id") public Description get( @Parameter(name = "id", description = "The id of a description to fetch", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, - @Parameter(name = "fieldSet", description = SwaggerHelpers.fieldset_description, required = true) FieldSet fieldSet + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException { logger.debug(new MapLogEntry("retrieving" + Description.class.getSimpleName()).And("id", id).And("fields", fieldSet)); fieldSet = this.fieldSetExpanderService.expand(fieldSet); @@ -210,7 +211,7 @@ public class DescriptionController { @ValidationFilterAnnotation(validator = DescriptionPersist.DescriptionPersistValidator.ValidatorName, argumentName = "model") public Description persist( @RequestBody DescriptionPersist model, - @Parameter(name = "fieldSet", description = SwaggerHelpers.fieldset_description, required = true) FieldSet fieldSet + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException { logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); fieldSet = this.fieldSetExpanderService.expand(fieldSet); @@ -231,7 +232,7 @@ public class DescriptionController { @ValidationFilterAnnotation(validator = DescriptionStatusPersist.DescriptionStatusPersistValidator.ValidatorName, argumentName = "model") public Description persistStatus( @RequestBody DescriptionStatusPersist model, - @Parameter(name = "fieldSet", description = SwaggerHelpers.fieldset_description, required = true) FieldSet fieldSet + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException, InvalidApplicationException { logger.debug(new MapLogEntry("persisting" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); fieldSet = this.fieldSetExpanderService.expand(fieldSet); @@ -309,7 +310,7 @@ public class DescriptionController { public StorageFile uploadFieldFiles( @RequestParam("file") MultipartFile file, @RequestParam("model") DescriptionFieldFilePersist model, - @Parameter(name = "fieldSet", description = SwaggerHelpers.fieldset_description, required = true) FieldSet fieldSet + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet ) throws IOException { logger.debug(new MapLogEntry("uploadFieldFiles" + Description.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); fieldSet = this.fieldSetExpanderService.expand(fieldSet); @@ -380,186 +381,4 @@ public class DescriptionController { return response; } - protected static class SwaggerHelpers { - static final String endpoint_query = - """ - This endpoint is used to fetch all the available descriptions.
- It also allows to restrict the results using a query object passed in the request body.
- """; - - static final String endpoint_query_request_body = - """ - Let's explore the options this object gives us. - - ### General query parameters: - - - - For example, if we want the third page, and our pages to contain 15 elements, we would pass the following object: - - ```JSON - { - "offset": 30, - "size": 15 - } - ``` - - - - For example, if we wanted to order based on the field 'createdAt' in descending order, we would pass the following object: - - ```JSON - { - "items": [ - "-createdAt" - ], - } - ``` - - - - ### Description specific query parameters: - - - """; - - static final String endpoint_query_request_body_example = - """ - { - "project":{ - "fields":[ - "id", - "label", - "status", - "updatedAt", - "belongsToCurrentTenant", - "finalizedAt", - "descriptionTemplate.id", - "descriptionTemplate.label", - "descriptionTemplate.groupId", - "dmp.id", - "dmp.label", - "dmp.status", - "dmp.accessType", - "dmp.blueprint.id", - "dmp.blueprint.label", - "dmp.blueprint.definition.sections.id", - "dmp.blueprint.definition.sections.label", - "dmp.blueprint.definition.sections.hasTemplates", - "dmp.dmpReferences.id", - "dmp.dmpReferences.reference.id", - "dmp.dmpReferences.reference.label", - "dmp.dmpReferences.reference.type.id", - "dmp.dmpReferences.reference.reference", - "dmp.dmpReferences.isActive", - "dmpDescriptionTemplate.id", - "dmpDescriptionTemplate.dmp.id", - "dmpDescriptionTemplate.descriptionTemplateGroupId", - "dmpDescriptionTemplate.sectionId" - ] - }, - "page":{ - "size":5, - "offset":0 - }, - "order":{ - "items":[ - "-updatedAt" - ] - }, - "metadata":{ - "countAll":true - }, - "isActive":[ - 1 - ] - } - """; - - static final String fieldset_description = - """ - This is an object containing a list of the properties you wish to include in the response, similar to the 'project' attribute on queries. - """; - - static final String endpoint_get = - """ - - """; - } - } diff --git a/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java b/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java index 99c15180f..08c00e7d5 100644 --- a/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java +++ b/backend/web/src/main/java/org/opencdmp/controllers/DmpController.java @@ -11,9 +11,12 @@ import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.validation.ValidationFilterAnnotation; +import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.xml.bind.JAXBException; import org.opencdmp.audit.AuditableAction; @@ -21,6 +24,7 @@ import org.opencdmp.authorization.AuthorizationFlags; import org.opencdmp.commons.enums.DmpAccessType; import org.opencdmp.commons.enums.DmpStatus; import org.opencdmp.commons.enums.IsActive; +import org.opencdmp.controllers.swagger.SwaggerHelpers; import org.opencdmp.model.DescriptionsToBeFinalized; import org.opencdmp.model.DmpUser; import org.opencdmp.model.DmpValidationResult; @@ -99,6 +103,7 @@ public class DmpController { @PostMapping("public/query") @Operation(summary = "Query public published plans") + @Hidden public QueryResult publicQuery(@RequestBody DmpLookup lookup) throws MyApplicationException, MyForbiddenException { logger.debug("querying {}", Dmp.class.getSimpleName()); @@ -114,6 +119,7 @@ public class DmpController { @GetMapping("public/{id}") @Operation(summary = "Fetch a specific public published plan by id") + @Hidden public PublicDmp publicGet(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { logger.debug(new MapLogEntry("retrieving" + Dmp.class.getSimpleName()).And("id", id).And("fields", fieldSet)); @@ -136,21 +142,38 @@ public class DmpController { @PostMapping("query") @Operation( summary = "Query all plans", - description = SwaggerHelpers.endpoint_query, + description = SwaggerHelpers.Dmp.endpoint_query, requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( - description = SwaggerHelpers.endpoint_query_request_body, + description = SwaggerHelpers.Dmp.endpoint_query_request_body, content = { @Content( examples = { @ExampleObject( name = "Pagination and projection", description = "Simple paginated request using a property projection list and pagination info", - value = SwaggerHelpers.endpoint_query_request_body_example + value = SwaggerHelpers.Dmp.endpoint_query_request_body_example ) } ) } - ) + ), + responses = { + @ApiResponse( + description = "OK", + responseCode = "200", + content = { + @Content( + examples = { + @ExampleObject( + name = "First page", + description = "Example with the first page of paginated results", + value = SwaggerHelpers.Dmp.endpoint_query_response_example + ) + } + ) + } + ) + } ) public QueryResult Query(@RequestBody DmpLookup lookup) throws MyApplicationException, MyForbiddenException { logger.debug("querying {}", Dmp.class.getSimpleName()); @@ -166,7 +189,11 @@ public class DmpController { @GetMapping("{id}") @Operation(summary = "Fetch a specific plan by id") - public Dmp Get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { + public Dmp Get( + @Parameter(name = "id", description = "The id of a plan to fetch", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet, + Locale locale + ) throws MyApplicationException, MyForbiddenException, MyNotFoundException { logger.debug(new MapLogEntry("retrieving" + Dmp.class.getSimpleName()).And("id", id).And("fields", fieldSet)); this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); @@ -188,7 +215,10 @@ public class DmpController { @Operation(summary = "Create a new or update an existing plan") @Transactional @ValidationFilterAnnotation(validator = DmpPersist.DmpPersistValidator.ValidatorName, argumentName = "model") - public Dmp Persist(@RequestBody DmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException { + public Dmp Persist( + @RequestBody DmpPersist model, + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet + ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException { logger.debug(new MapLogEntry("persisting" + Dmp.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); Dmp persisted = this.dmpService.persist(model, fieldSet); @@ -204,7 +234,9 @@ public class DmpController { @DeleteMapping("{id}") @Operation(summary = "Delete a plan by id") @Transactional - public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException, IOException { + public void Delete( + @Parameter(name = "id", description = "The id of a plan to delete", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id + ) throws MyForbiddenException, InvalidApplicationException, IOException { logger.debug(new MapLogEntry("retrieving" + Dmp.class.getSimpleName()).And("id", id)); this.dmpService.deleteAndSave(id); @@ -215,7 +247,10 @@ public class DmpController { @PostMapping("finalize/{id}") @Operation(summary = "Finalize a plan by id") @Transactional - public boolean finalize(@PathVariable("id") UUID id, @RequestBody DescriptionsToBeFinalized descriptions) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException { + public boolean finalize( + @Parameter(name = "id", description = "The id of a plan to finalize", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, + @RequestBody DescriptionsToBeFinalized descriptions + ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException { logger.debug(new MapLogEntry("finalizing" + Dmp.class.getSimpleName()).And("id", id).And("descriptionIds", descriptions.getDescriptionIds())); this.dmpService.finalize(id, descriptions.getDescriptionIds()); @@ -231,7 +266,10 @@ public class DmpController { @GetMapping("undo-finalize/{id}") @Operation(summary = "Undo the finalization of a plan by id (only possible if it is not already deposited)") @Transactional - public boolean undoFinalize(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException { + public boolean undoFinalize( + @Parameter(name = "id", description = "The id of a plan to revert the finalization", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet + ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException, IOException, JAXBException { logger.debug(new MapLogEntry("undo-finalizing" + Dmp.class.getSimpleName()).And("id", id)); this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); @@ -247,6 +285,7 @@ public class DmpController { @GetMapping("validate/{id}") @Operation(summary = "Validate if a plan is ready for finalization by id") + @Hidden public DmpValidationResult validate(@PathVariable("id") UUID id) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException { logger.debug(new MapLogEntry("validating" + Dmp.class.getSimpleName()).And("id", id)); @@ -265,7 +304,10 @@ public class DmpController { @Operation(summary = "Create a clone of an existing plan") @Transactional @ValidationFilterAnnotation(validator = CloneDmpPersist.CloneDmpPersistValidator.ValidatorName, argumentName = "model") - public Dmp buildClone(@RequestBody CloneDmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException, InvalidApplicationException { + public Dmp buildClone( + @RequestBody CloneDmpPersist model, + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet + ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, IOException, InvalidApplicationException { logger.debug(new MapLogEntry("clone" + Dmp.class.getSimpleName()).And("model", model).And("fields", fieldSet)); this.censorFactory.censor(DmpCensor.class).censor(fieldSet, null); @@ -284,7 +326,10 @@ public class DmpController { @Operation(summary = "Create a new version of an existing plan") @Transactional @ValidationFilterAnnotation(validator = NewVersionDmpPersist.NewVersionDmpPersistValidator.ValidatorName, argumentName = "model") - public Dmp createNewVersion(@RequestBody NewVersionDmpPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, IOException, TransformerException, InvalidApplicationException, ParserConfigurationException { + public Dmp createNewVersion( + @RequestBody NewVersionDmpPersist model, + @Parameter(name = "fieldSet", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fieldSet + ) throws MyApplicationException, MyForbiddenException, MyNotFoundException, JAXBException, IOException, TransformerException, InvalidApplicationException, ParserConfigurationException { logger.debug(new MapLogEntry("persisting" + NewVersionDmpPersist.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); Dmp persisted = this.dmpService.createNewVersion(model, fieldSet); @@ -301,6 +346,7 @@ public class DmpController { @Operation(summary = "Assign users to the plan by id") @Transactional @ValidationFilterAnnotation(validator = DmpUserPersist.DmpUserPersistValidator.ValidatorName, argumentName = "model") + @Hidden public QueryResult assignUsers(@PathVariable("id") UUID id, @RequestBody List model, FieldSet fieldSet) throws InvalidApplicationException, IOException { logger.debug(new MapLogEntry("assigning users to dmp").And("model", model).And("fieldSet", fieldSet)); @@ -318,6 +364,7 @@ public class DmpController { @Operation(summary = "Remove a user association with the plan") @Transactional @ValidationFilterAnnotation(validator = DmpUserRemovePersist.DmpUserRemovePersistValidator.ValidatorName, argumentName = "model") + @Hidden public QueryResult removeUser(@RequestBody DmpUserRemovePersist model, FieldSet fieldSet) throws InvalidApplicationException, IOException { logger.debug(new MapLogEntry("remove user from dmp").And("model", model).And("fieldSet", fieldSet)); @@ -333,7 +380,11 @@ public class DmpController { @GetMapping("{id}/export/{transformerId}/{type}") @Operation(summary = "Export a plan in various formats by id") - public ResponseEntity export(@PathVariable("id") UUID id, @PathVariable("transformerId") String transformerId, @PathVariable("type") String exportType) throws InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { + public ResponseEntity export( + @Parameter(name = "id", description = "The id of a plan to export", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable("id") UUID id, + @PathVariable("transformerId") String transformerId, + @PathVariable("type") String exportType + ) throws InvalidApplicationException, IOException, InvalidAlgorithmParameterException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { logger.debug(new MapLogEntry("exporting dmp").And("id", id).And("transformerId", transformerId).And("exportType", exportType)); ResponseEntity bytes = this.dmpService.export(id, transformerId, exportType); @@ -349,6 +400,7 @@ public class DmpController { @Operation(summary = "Send user invitations for the plan by id") @Transactional @ValidationFilterAnnotation(validator = DmpUserInvitePersist.DmpUserInvitePersistValidator.ValidatorName, argumentName = "model") + @Hidden public boolean inviteUsers(@PathVariable("id") UUID id, @RequestBody DmpUserInvitePersist model) throws InvalidApplicationException, JAXBException, IOException { logger.debug(new MapLogEntry("inviting users to dmp").And("model", model)); @@ -364,6 +416,7 @@ public class DmpController { @GetMapping("{id}/token/{token}/invite-accept") @Operation(summary = "Accept an invitation token for a plan by id") @Transactional + @Hidden public boolean acceptInvitation(@PathVariable("id") UUID id, @PathVariable("token") String token) throws InvalidApplicationException, JAXBException, IOException { logger.debug(new MapLogEntry("inviting users to dmp").And("id", id)); @@ -378,7 +431,9 @@ public class DmpController { @RequestMapping(method = RequestMethod.GET, value = "/xml/export/{id}", produces = "application/xml") @Operation(summary = "Export a plan in xml format by id") - public @ResponseBody ResponseEntity getXml(@PathVariable UUID id) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { + public @ResponseBody ResponseEntity getXml( + @Parameter(name = "id", description = "The id of a plan to export", example = "c0c163dc-2965-45a5-9608-f76030578609", required = true) @PathVariable UUID id + ) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException { logger.debug(new MapLogEntry("export" + Dmp.class.getSimpleName()).And("id", id)); ResponseEntity response = this.dmpService.exportXml(id); @@ -392,7 +447,11 @@ public class DmpController { @RequestMapping(method = RequestMethod.POST, value = "/xml/import") @Operation(summary = "Import a plan from an xml file") @Transactional - public Dmp importXml(@RequestParam("file") MultipartFile file, @RequestParam("label") String label, FieldSet fields) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException, TransformerException { + public Dmp importXml( + @RequestParam("file") MultipartFile file, + @RequestParam("label") String label, + @Parameter(name = "fields", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fields + ) throws JAXBException, ParserConfigurationException, IOException, InstantiationException, IllegalAccessException, SAXException, InvalidApplicationException, TransformerException { logger.debug(new MapLogEntry("import xml" + Dmp.class.getSimpleName()).And("file", file).And("label", label)); Dmp model = this.dmpService.importXml(file.getBytes(), label, fields); @@ -407,7 +466,13 @@ public class DmpController { @PostMapping("json/import") @Operation(summary = "Import a plan from an json file") @Transactional - public Dmp importJson(@RequestParam("file") MultipartFile file, @RequestParam("label") String label, @RequestParam("repositoryId") String repositoryId, @RequestParam("format") String format, FieldSet fields) throws InvalidAlgorithmParameterException, JAXBException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, IOException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { + public Dmp importJson( + @RequestParam("file") MultipartFile file, + @RequestParam("label") String label, + @RequestParam("repositoryId") String repositoryId, + @RequestParam("format") String format, + @Parameter(name = "fields", description = SwaggerHelpers.Commons.fieldset_description, required = true) FieldSet fields + ) throws InvalidAlgorithmParameterException, JAXBException, NoSuchPaddingException, IllegalBlockSizeException, InvalidApplicationException, IOException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { logger.debug(new MapLogEntry("import json" + Dmp.class.getSimpleName()).And("transformerId", repositoryId).And("file", file).And("label", label)); Dmp model = this.dmpService.importJson(file, label, repositoryId, format, fields); @@ -421,171 +486,4 @@ public class DmpController { return model; } - protected static class SwaggerHelpers { - - static final String endpoint_query = - """ - This endpoint is used to fetch all the available plans.
- It also allows to restrict the results using a query object passed in the request body.
- """; - - static final String endpoint_query_request_body = - """ - Let's explore the options this object gives us. - - ### General query parameters: - -
    -
  • page: - This is an object controlling the pagination of the results. It contains two properties. -
  • -
      -
    • offset: - How many records to omit. -
    • -
    • size: - How many records to include in each page. -
    • -
    -
- - For example, if we want the third page, and our pages to contain 15 elements, we would pass the following object: - - ```JSON - { - "offset": 30, - "size": 15 - } - ``` - -
    -
  • order: - This is an object controlling the ordering of the results. - It contains a list of strings called items with the names of the properties to use. -
    If the name of the property is prefixed with a '-', the ordering direction is DESC. Otherwise, it is ASC. -
  • -
- - For example, if we wanted to order based on the field 'createdAt' in descending order, we would pass the following object: - - ```JSON - { - "items": [ - "-createdAt" - ], - } - ``` - -
    -
  • metadata: - This is an object containing metadata for the request. There is only one available option. -
      -
    • countAll: - If this is set to true, the count property included in the response will account for all the records regardless the pagination, - with all the rest of filtering options applied of course. - Otherwise, if it is set to false or not present, only the returned results will be counted. -
      The first option is useful for the UI clients to calculate how many result pages are available. -
    • -
    -
  • -
  • project: - This is an object controlling the data projection of the results. - It contains a list of strings called fields with the names of the properties to project. -
    You can also include properties that are deeper in the object tree by prefixing them with dots. -
  • -
- - ### Plan specific query parameters: - -
    -
  • like: - If there is a like parameter present in the query, only the description entities that include the contents of the parameter either in their labels or the descriptions will be in the response. -
  • -
  • ids: - This is a list and contains the ids we want to include in the response.
    If empty, every record is included. -
  • -
  • excludedIds: - This is a list and contains the ids we want to exclude from the response.
    If empty, no record gets excluded. -
  • -
  • groupIds: - This is a list and contains the group ids we want the plans to have. Every plan and all its versions, have the same groupId.
    If empty, every record is included. -
  • -
  • isActive: - This is a list and determines which records we want to include in the response, based on if they are deleted or not. - This filter works like this. If we want to view only the active records we pass [1] and for only the deleted records we pass [0]. -
    If not present or if we pass [0,1], every record is included. -
  • -
  • statuses: - This is a list and determines which records we want to include in the response, based on their status. - The status can be Draft or Finalized. We add 0 or 1 to the list respectively. -
    If not present, every record is included. -
  • -
  • versionStatuses: - This is a list and determines which records we want to include in the response, based on their version status. - The status can be Current, Previous or NotFinalized. We add 0, 1 or 2 to the list respectively. -
    If not present, every record is included. -
  • -
  • accessTypes: - This is a list and determines which records we want to include in the response, based on their access type. - The access type can be Public or Restricted. We add 0 or 1 to the list respectively. -
    If not present, every record is included. -
  • -
- """; - - static final String endpoint_query_request_body_example = - """ - { - "project":{ - "fields":[ - "id", - "label", - "description", - "status", - "accessType", - "version", - "versionStatus", - "groupId", - "updatedAt", - "belongsToCurrentTenant", - "finalizedAt", - "hash", - "descriptions.id", - "descriptions.label", - "descriptions.status", - "descriptions.descriptionTemplate.groupId", - "descriptions.isActive", - "blueprint.id", - "blueprint.label", - "blueprint.definition.sections.id" - ] - }, - "page":{ - "size":5, - "offset":0 - }, - "order":{ - "items":[ - "-updatedAt" - ] - }, - "metadata":{ - "countAll":true - }, - "isActive":[ - 1 - ], - "versionStatuses":[ - 0, - 2 - ] - } - """; - - static final String endpoint_ = - """ - - """; - } - } diff --git a/backend/web/src/main/java/org/opencdmp/controllers/swagger/SwaggerHelpers.java b/backend/web/src/main/java/org/opencdmp/controllers/swagger/SwaggerHelpers.java new file mode 100644 index 000000000..55dc8a1e8 --- /dev/null +++ b/backend/web/src/main/java/org/opencdmp/controllers/swagger/SwaggerHelpers.java @@ -0,0 +1,1047 @@ +package org.opencdmp.controllers.swagger; + +public class SwaggerHelpers { + + public static class Commons { + public static final String fieldset_description = + """ + This is an object containing a list of the properties you wish to include in the response, similar to the 'project' attribute on queries. + """; + } + + public static class Dmp { + public static final String endpoint_query = + """ + This endpoint is used to fetch all the available plans.
+ It also allows to restrict the results using a query object passed in the request body.
+ """; + + public static final String endpoint_query_request_body = + """ + Let's explore the options this object gives us. + + ### General query parameters: + +
    +
  • page: + This is an object controlling the pagination of the results. It contains two properties. +
  • +
      +
    • offset: + How many records to omit. +
    • +
    • size: + How many records to include in each page. +
    • +
    +
+ + For example, if we want the third page, and our pages to contain 15 elements, we would pass the following object: + + ```JSON + { + "offset": 30, + "size": 15 + } + ``` + +
    +
  • order: + This is an object controlling the ordering of the results. + It contains a list of strings called items with the names of the properties to use. +
    If the name of the property is prefixed with a '-', the ordering direction is DESC. Otherwise, it is ASC. +
  • +
+ + For example, if we wanted to order based on the field 'createdAt' in descending order, we would pass the following object: + + ```JSON + { + "items": [ + "-createdAt" + ], + } + ``` + +
    +
  • metadata: + This is an object containing metadata for the request. There is only one available option. +
      +
    • countAll: + If this is set to true, the count property included in the response will account for all the records regardless the pagination, + with all the rest of filtering options applied of course. + Otherwise, if it is set to false or not present, only the returned results will be counted. +
      The first option is useful for the UI clients to calculate how many result pages are available. +
    • +
    +
  • +
  • project: + This is an object controlling the data projection of the results. + It contains a list of strings called fields with the names of the properties to project. +
    You can also include properties that are deeper in the object tree by prefixing them with dots. +
  • +
+ + ### Plan specific query parameters: + +
    +
  • like: + If there is a like parameter present in the query, only the description entities that include the contents of the parameter either in their labels or the descriptions will be in the response. +
  • +
  • ids: + This is a list and contains the ids we want to include in the response.
    If empty, every record is included. +
  • +
  • excludedIds: + This is a list and contains the ids we want to exclude from the response.
    If empty, no record gets excluded. +
  • +
  • groupIds: + This is a list and contains the group ids we want the plans to have. Every plan and all its versions, have the same groupId.
    If empty, every record is included. +
  • +
  • isActive: + This is a list and determines which records we want to include in the response, based on if they are deleted or not. + This filter works like this. If we want to view only the active records we pass [1] and for only the deleted records we pass [0]. +
    If not present or if we pass [0,1], every record is included. +
  • +
  • statuses: + This is a list and determines which records we want to include in the response, based on their status. + The status can be Draft or Finalized. We add 0 or 1 to the list respectively. +
    If not present, every record is included. +
  • +
  • versionStatuses: + This is a list and determines which records we want to include in the response, based on their version status. + The status can be Current, Previous or NotFinalized. We add 0, 1 or 2 to the list respectively. +
    If not present, every record is included. +
  • +
  • accessTypes: + This is a list and determines which records we want to include in the response, based on their access type. + The access type can be Public or Restricted. We add 0 or 1 to the list respectively. +
    If not present, every record is included. +
  • +
+ """; + + public static final String endpoint_query_request_body_example = + """ + { + "project":{ + "fields":[ + "id", + "label", + "description", + "status", + "accessType", + "version", + "versionStatus", + "groupId", + "updatedAt", + "belongsToCurrentTenant", + "finalizedAt", + "hash", + "descriptions.id", + "descriptions.label", + "descriptions.status", + "descriptions.descriptionTemplate.groupId", + "descriptions.isActive", + "blueprint.id", + "blueprint.label", + "blueprint.definition.sections.id" + ] + }, + "page":{ + "size":5, + "offset":0 + }, + "order":{ + "items":[ + "-updatedAt" + ] + }, + "metadata":{ + "countAll":true + }, + "isActive":[ + 1 + ], + "versionStatuses":[ + 0, + 2 + ] + } + """; + + public static final String endpoint_query_response_example = + """ + { + "items":[ + { + "id":"dbc5057b-d33e-4a2c-8963-e882da6765a0", + "label":"blueprint test with deleted description template", + "version":1, + "status":0, + "versionStatus":2, + "groupId":"dae2fd0b-74a4-4bde-b021-9ea44e033866", + "description":"blueprint test with deleted description template", + "updatedAt":"2024-06-06T12:35:57.293416Z", + "blueprint":{ + "id":"6fbfd40a-b41a-4928-b4b5-67d28bdba2ce", + "label":"test_for_plan_manager_role_new_v2 new ", + "definition":{ + "sections":[ + { + "id":"843c4181-dbe2-4e18-a1e4-cf178199947c", + "label":"1", + "hasTemplates":true, + "descriptionTemplates":[ + { + "descriptionTemplateGroupId":"3689bcce-405a-4d55-9854-669597b79c0a" + }, + { + "descriptionTemplateGroupId":"2a38d018-8e81-4ba2-80b2-4395a1d1b238" + } + ] + } + ] + } + }, + "hash":"1717677357", + "dmpUsers":[ + { + "id":"a61fdc31-fb1e-4cee-9c0a-a0a317b27b62", + "dmp":{ + "id":"dbc5057b-d33e-4a2c-8963-e882da6765a0" + }, + "user":{ + "id":"e60876ed-87f8-4a8e-8081-e5620ec839cf" + }, + "role":0, + "isActive":1 + } + ], + "dmpDescriptionTemplates":[ + { + "dmp":{ + \s + }, + "sectionId":"843c4181-dbe2-4e18-a1e4-cf178199947c", + "descriptionTemplateGroupId":"2a38d018-8e81-4ba2-80b2-4395a1d1b238", + "isActive":1 + }, + { + "dmp":{ + \s + }, + "sectionId":"843c4181-dbe2-4e18-a1e4-cf178199947c", + "descriptionTemplateGroupId":"3689bcce-405a-4d55-9854-669597b79c0a", + "isActive":0 + } + ], + "authorizationFlags":[ + "InviteDmpUsers", + "CreateNewVersionDmp", + "AssignDmpUsers", + "DeleteDmp", + "FinalizeDmp", + "CloneDmp", + "ExportDmp", + "EditDmp" + ], + "belongsToCurrentTenant":true + }, + { + "id":"d3d5cba3-50d0-4dcd-9660-b7bcfac51316", + "label":"description_template_delete_plan_New_v2.xml", + "version":1, + "status":0, + "versionStatus":2, + "groupId":"5ab5d0ca-5c8e-4450-bf3b-a701ceadfabb", + "description":"description template delete plan", + "updatedAt":"2024-06-06T12:30:24.936458Z", + "accessType":0, + "blueprint":{ + "id":"86635178-36a6-484f-9057-a934e4eeecd5", + "label":"Dmp Default Blueprint", + "definition":{ + "sections":[ + { + "id":"f94e50e0-cb97-4c65-8b88-e5db6badd41d", + "label":"Main Info", + "hasTemplates":false + }, + { + "id":"3c2608e5-9320-4d94-9ed7-1eab9500d84b", + "label":"Funding", + "hasTemplates":false + }, + { + "id":"2a77e1f6-9989-4aeb-acd9-48e911a92abd", + "label":"License", + "hasTemplates":false + }, + { + "id":"0db7845b-0e7c-41df-8d91-cbca97995fd5", + "label":"Templates", + "hasTemplates":true + } + ] + } + }, + "hash":"1717677024", + "dmpReferences":[ + { + "id":"0c470488-14ba-4c7e-8cf2-0f6f849ee56e", + "dmp":{ + \s + }, + "reference":{ + "id":"08577246-b50b-44ea-9bed-641ea4e40fe7", + "label":"unidentified", + "type":{ + "id":"5b9c284f-f041-4995-96cc-fad7ad13289c" + } + }, + "isActive":1 + }, + { + "id":"62211794-787c-407c-9512-05c2d60d410b", + "dmp":{ + \s + }, + "reference":{ + "id":"32c87599-e375-4294-a7cf-3db8722bd675", + "label":"APC Microbiome Institute||", + "type":{ + "id":"538928bb-c7c6-452e-b66d-08e539f5f082" + } + }, + "isActive":1 + } + ], + "dmpUsers":[ + { + "id":"313865d6-6a72-449f-ac04-1834d2f03b02", + "dmp":{ + "id":"d3d5cba3-50d0-4dcd-9660-b7bcfac51316" + }, + "user":{ + "id":"7d6e54b6-31e8-48df-9c3f-1e5b3eb48404" + }, + "role":0, + "isActive":1 + } + ], + "descriptions":[ + { + "id":"1dc4e3e8-c125-4db8-a937-041405aaf5ec", + "label":"description template test", + "status":0, + "isActive":0, + "descriptionTemplate":{ + "groupId":"fab932b2-4285-44a2-b9ab-1a4306bd3e0e" + }, + "dmp":{ + \s + } + }, + { + "id":"0059fa07-5698-42ba-958a-428b226ddcab", + "label":"test3v2 description template", + "status":0, + "isActive":1, + "descriptionTemplate":{ + "groupId":"2a38d018-8e81-4ba2-80b2-4395a1d1b238" + }, + "dmp":{ + \s + } + } + ], + "dmpDescriptionTemplates":[ + { + "dmp":{ + \s + }, + "sectionId":"0db7845b-0e7c-41df-8d91-cbca97995fd5", + "descriptionTemplateGroupId":"fab932b2-4285-44a2-b9ab-1a4306bd3e0e", + "isActive":0 + }, + { + "dmp":{ + \s + }, + "sectionId":"0db7845b-0e7c-41df-8d91-cbca97995fd5", + "descriptionTemplateGroupId":"2a38d018-8e81-4ba2-80b2-4395a1d1b238", + "isActive":1 + } + ], + "authorizationFlags":[ + "InviteDmpUsers", + "CreateNewVersionDmp", + "AssignDmpUsers", + "DeleteDmp", + "FinalizeDmp", + "CloneDmp", + "ExportDmp", + "EditDmp" + ], + "belongsToCurrentTenant":true + }, + { + "id":"2ebbb8ac-742d-413a-a3e2-1cb21d555b3f", + "label":"description template delete plan New v2", + "version":2, + "status":0, + "versionStatus":2, + "groupId":"cf177996-f68c-4375-bf53-161953dadfc2", + "description":"description template delete plan", + "updatedAt":"2024-06-06T11:59:21.396453Z", + "accessType":0, + "blueprint":{ + "id":"86635178-36a6-484f-9057-a934e4eeecd5", + "label":"Dmp Default Blueprint", + "definition":{ + "sections":[ + { + "id":"f94e50e0-cb97-4c65-8b88-e5db6badd41d", + "label":"Main Info", + "hasTemplates":false + }, + { + "id":"3c2608e5-9320-4d94-9ed7-1eab9500d84b", + "label":"Funding", + "hasTemplates":false + }, + { + "id":"2a77e1f6-9989-4aeb-acd9-48e911a92abd", + "label":"License", + "hasTemplates":false + }, + { + "id":"0db7845b-0e7c-41df-8d91-cbca97995fd5", + "label":"Templates", + "hasTemplates":true + } + ] + } + }, + "hash":"1717675161", + "dmpReferences":[ + { + "id":"5cd1a1c3-bd9b-4a89-9329-ab3f152eebc7", + "dmp":{ + \s + }, + "reference":{ + "id":"32c87599-e375-4294-a7cf-3db8722bd675", + "label":"APC Microbiome Institute||", + "type":{ + "id":"538928bb-c7c6-452e-b66d-08e539f5f082" + } + }, + "isActive":1 + }, + { + "id":"0e5d165f-b8ae-44a2-8d90-5e8e1037caa7", + "dmp":{ + \s + }, + "reference":{ + "id":"08577246-b50b-44ea-9bed-641ea4e40fe7", + "label":"unidentified", + "type":{ + "id":"5b9c284f-f041-4995-96cc-fad7ad13289c" + } + }, + "isActive":1 + } + ], + "dmpUsers":[ + { + "id":"83b1680d-3d9a-4610-82d5-8fe0132f2a0b", + "dmp":{ + "id":"2ebbb8ac-742d-413a-a3e2-1cb21d555b3f" + }, + "user":{ + "id":"7d6e54b6-31e8-48df-9c3f-1e5b3eb48404" + }, + "role":0, + "isActive":1 + } + ], + "descriptions":[ + { + "id":"2620507c-cb8b-4d67-bb42-64a702932b0a", + "label":"description template test", + "status":0, + "isActive":1, + "descriptionTemplate":{ + "groupId":"fab932b2-4285-44a2-b9ab-1a4306bd3e0e" + }, + "dmp":{ + \s + } + } + ], + "dmpDescriptionTemplates":[ + { + "dmp":{ + \s + }, + "sectionId":"0db7845b-0e7c-41df-8d91-cbca97995fd5", + "descriptionTemplateGroupId":"fab932b2-4285-44a2-b9ab-1a4306bd3e0e", + "isActive":1 + } + ], + "authorizationFlags":[ + "InviteDmpUsers", + "CreateNewVersionDmp", + "AssignDmpUsers", + "DeleteDmp", + "FinalizeDmp", + "CloneDmp", + "ExportDmp", + "EditDmp" + ], + "belongsToCurrentTenant":true + }, + { + "id":"68e9aae2-f2f9-4d51-b5f4-9a0216efb00c", + "label":"description template delete plan New", + "version":1, + "status":1, + "versionStatus":0, + "groupId":"cf177996-f68c-4375-bf53-161953dadfc2", + "description":"description template delete plan", + "updatedAt":"2024-06-06T11:27:32.988143Z", + "finalizedAt":"2024-06-06T11:27:32.988143Z", + "accessType":0, + "blueprint":{ + "id":"86635178-36a6-484f-9057-a934e4eeecd5", + "label":"Dmp Default Blueprint", + "definition":{ + "sections":[ + { + "id":"f94e50e0-cb97-4c65-8b88-e5db6badd41d", + "label":"Main Info", + "hasTemplates":false + }, + { + "id":"3c2608e5-9320-4d94-9ed7-1eab9500d84b", + "label":"Funding", + "hasTemplates":false + }, + { + "id":"2a77e1f6-9989-4aeb-acd9-48e911a92abd", + "label":"License", + "hasTemplates":false + }, + { + "id":"0db7845b-0e7c-41df-8d91-cbca97995fd5", + "label":"Templates", + "hasTemplates":true + } + ] + } + }, + "hash":"1717673252", + "dmpReferences":[ + { + "id":"c1510688-4a70-4a70-abc0-9778d5db5d7f", + "dmp":{ + \s + }, + "reference":{ + "id":"32c87599-e375-4294-a7cf-3db8722bd675", + "label":"APC Microbiome Institute||", + "type":{ + "id":"538928bb-c7c6-452e-b66d-08e539f5f082" + } + }, + "isActive":1 + }, + { + "id":"f9755a49-c305-4afe-889f-3ec1834b139a", + "dmp":{ + \s + }, + "reference":{ + "id":"08577246-b50b-44ea-9bed-641ea4e40fe7", + "label":"unidentified", + "type":{ + "id":"5b9c284f-f041-4995-96cc-fad7ad13289c" + } + }, + "isActive":1 + } + ], + "dmpUsers":[ + { + "id":"dd48a20d-5166-453b-9a25-bc5ec49ade1f", + "dmp":{ + "id":"68e9aae2-f2f9-4d51-b5f4-9a0216efb00c" + }, + "user":{ + "id":"7d6e54b6-31e8-48df-9c3f-1e5b3eb48404" + }, + "role":0, + "isActive":1 + } + ], + "descriptions":[ + { + "id":"18820f0b-8222-49fa-a997-86a171c41092", + "label":"description template test", + "status":1, + "isActive":1, + "descriptionTemplate":{ + "groupId":"fab932b2-4285-44a2-b9ab-1a4306bd3e0e" + }, + "dmp":{ + \s + } + } + ], + "dmpDescriptionTemplates":[ + { + "dmp":{ + \s + }, + "sectionId":"0db7845b-0e7c-41df-8d91-cbca97995fd5", + "descriptionTemplateGroupId":"fab932b2-4285-44a2-b9ab-1a4306bd3e0e", + "isActive":1 + } + ], + "authorizationFlags":[ + "InviteDmpUsers", + "CreateNewVersionDmp", + "AssignDmpUsers", + "DeleteDmp", + "FinalizeDmp", + "CloneDmp", + "ExportDmp", + "EditDmp" + ], + "belongsToCurrentTenant":true + }, + { + "id":"f2e807f1-7fd4-48db-b781-e9c972057447", + "label":"user3 plan", + "version":1, + "status":0, + "versionStatus":2, + "groupId":"df98fefc-6213-450d-aea7-594b43421c3f", + "description":"test", + "updatedAt":"2024-06-06T11:03:56.668426Z", + "blueprint":{ + "id":"fc83c102-8c3c-4298-8e64-02bdd0fb7275", + "label":"blueprint with users", + "definition":{ + "sections":[ + { + "id":"44e6e93b-a6e0-6036-bda5-b33fe1df2f02", + "label":"Main info", + "hasTemplates":true, + "descriptionTemplates":[ + { + "descriptionTemplateGroupId":"11559a4f-d6f4-4dc9-8e6b-d1879700ac12" + } + ] + }, + { + "id":"109ceb1e-9703-2a03-462b-8bf93f993a53", + "label":"Section2", + "hasTemplates":true + } + ] + } + }, + "hash":"1717671836", + "dmpUsers":[ + { + "id":"fcce59eb-8e9e-4768-92fe-e772886836f2", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"7d6e54b6-31e8-48df-9c3f-1e5b3eb48404" + }, + "role":0, + "isActive":1 + }, + { + "id":"8f698ad7-69e4-4fcf-b9b3-563b1b05ac45", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":3, + "isActive":0 + }, + { + "id":"0b26b2eb-5346-463c-b0f4-fa22d9a4c964", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":3, + "isActive":0 + }, + { + "id":"5154ec6e-912d-4b4f-8f1e-cc2a34069344", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":1, + "isActive":0 + }, + { + "id":"9ec5f356-43a3-462d-bbf2-27476931892f", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":1, + "isActive":0 + }, + { + "id":"e4e6a68c-408e-47fa-8b40-cb8c155f9eda", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":2, + "isActive":0 + }, + { + "id":"f1de4a02-137f-48d9-bd31-5904b2ba504a", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":3, + "isActive":0 + }, + { + "id":"9e444526-94c4-4e50-9c35-adf73fab5f8c", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":3, + "isActive":0 + }, + { + "id":"c92686d2-b434-44e3-b8fb-ef0d6a30582d", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":3, + "isActive":1 + }, + { + "id":"42f9c224-8704-4c41-8a2d-71b5c78d7690", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":2, + "isActive":1 + }, + { + "id":"be5836f4-842a-4a74-b852-c4bb4212adb0", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":2, + "isActive":0 + }, + { + "id":"18bb660a-638c-4def-90da-0c83368f7c1e", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":2, + "isActive":1 + }, + { + "id":"e5a8f9d1-30a3-4ee0-8ca6-f74c5e73ba53", + "dmp":{ + "id":"f2e807f1-7fd4-48db-b781-e9c972057447" + }, + "user":{ + "id":"391252ba-926d-4bf9-8c28-a921036f6c39" + }, + "role":2, + "isActive":1 + } + ], + "descriptions":[ + { + "id":"49b4c2df-0bad-4173-85d4-c5b416a7125a", + "label":"user3 description", + "status":0, + "isActive":1, + "descriptionTemplate":{ + "groupId":"11559a4f-d6f4-4dc9-8e6b-d1879700ac12" + }, + "dmp":{ + \s + } + }, + { + "id":"546a6195-17b6-4d1e-bad2-fa322fbad3f1", + "label":"user3 description - to delete", + "status":0, + "isActive":1, + "descriptionTemplate":{ + "groupId":"33dc4612-32bf-46a3-b040-12e32a06b3c7" + }, + "dmp":{ + \s + } + } + ], + "dmpDescriptionTemplates":[ + { + "dmp":{ + \s + }, + "sectionId":"44e6e93b-a6e0-6036-bda5-b33fe1df2f02", + "descriptionTemplateGroupId":"11559a4f-d6f4-4dc9-8e6b-d1879700ac12", + "isActive":1 + }, + { + "dmp":{ + \s + }, + "sectionId":"44e6e93b-a6e0-6036-bda5-b33fe1df2f02", + "descriptionTemplateGroupId":"33dc4612-32bf-46a3-b040-12e32a06b3c7", + "isActive":0 + } + ], + "authorizationFlags":[ + "InviteDmpUsers", + "CreateNewVersionDmp", + "AssignDmpUsers", + "DeleteDmp", + "FinalizeDmp", + "CloneDmp", + "ExportDmp", + "EditDmp" + ], + "belongsToCurrentTenant":true + } + ], + "count":2912 + } + """; + + public static final String endpoint_ = + """ + + """; + } + + public static class Description { + public static final String endpoint_query = + """ + This endpoint is used to fetch all the available descriptions.
+ It also allows to restrict the results using a query object passed in the request body.
+ """; + + public static final String endpoint_query_request_body = + """ + Let's explore the options this object gives us. + + ### General query parameters: + +
    +
  • page: + This is an object controlling the pagination of the results. It contains two properties. +
  • +
      +
    • offset: + How many records to omit. +
    • +
    • size: + How many records to include in each page. +
    • +
    +
+ + For example, if we want the third page, and our pages to contain 15 elements, we would pass the following object: + + ```JSON + { + "offset": 30, + "size": 15 + } + ``` + +
    +
  • order: + This is an object controlling the ordering of the results. + It contains a list of strings called items with the names of the properties to use. +
    If the name of the property is prefixed with a '-', the ordering direction is DESC. Otherwise, it is ASC. +
  • +
+ + For example, if we wanted to order based on the field 'createdAt' in descending order, we would pass the following object: + + ```JSON + { + "items": [ + "-createdAt" + ], + } + ``` + +
    +
  • metadata: + This is an object containing metadata for the request. There is only one available option. +
      +
    • countAll: + If this is set to true, the count property included in the response will account for all the records regardless the pagination, + with all the rest of filtering options applied of course. + Otherwise, if it is set to false or not present, only the returned results will be counted. +
      The first option is useful for the UI clients to calculate how many result pages are available. +
    • +
    +
  • +
  • project: + This is an object controlling the data projection of the results. + It contains a list of strings called fields with the names of the properties to project. +
    You can also include properties that are deeper in the object tree by prefixing them with dots. +
  • +
+ + ### Description specific query parameters: + +
    +
  • like: + If there is a like parameter present in the query, only the description entities that include the contents of the parameter either in their labels or the descriptions will be in the response. +
  • +
  • ids: + This is a list and contains the ids we want to include in the response.
    If empty, every record is included. +
  • +
  • excludedIds: + This is a list and contains the ids we want to exclude from the response.
    If empty, no record gets excluded. +
  • +
  • isActive: + This is a list and determines which records we want to include in the response, based on if they are deleted or not. + This filter works like this. If we want to view only the active records we pass [1] and for only the deleted records we pass [0]. +
    If not present or if we pass [0,1], every record is included. +
  • +
  • statuses: + This is a list and determines which records we want to include in the response, based on their status. + The status can be Draft, Finalized or Canceled. We add 0, 1 or 2 to the list respectively. +
    If not present, every record is included. +
  • +
  • createdAfter: + This is a date and determines which records we want to include in the response, based on their creation date. + Specifically, only the records created after the given date are included. +
    If not present, every record is included. +
  • +
  • createdBefore: + This is a date and determines which records we want to include in the response, based on their creation date. + Specifically, only the records created before the given date are included. +
    If not present, every record is included. +
  • +
  • finalizedAfter: + This is a date and determines which records we want to include in the response, based on their finalization date. + Specifically, only the records finalized after the given date are included. +
    If not present, every record is included. +
  • +
  • finalizedBefore: + This is a date and determines which records we want to include in the response, based on their finalization date. + Specifically, only the records finalized before the given date are included. +
    If not present, every record is included. +
  • +
+ """; + + public static final String endpoint_query_request_body_example = + """ + { + "project":{ + "fields":[ + "id", + "label", + "status", + "updatedAt", + "belongsToCurrentTenant", + "finalizedAt", + "descriptionTemplate.id", + "descriptionTemplate.label", + "descriptionTemplate.groupId", + "dmp.id", + "dmp.label", + "dmp.status", + "dmp.accessType", + "dmp.blueprint.id", + "dmp.blueprint.label", + "dmp.blueprint.definition.sections.id", + "dmp.blueprint.definition.sections.label", + "dmp.blueprint.definition.sections.hasTemplates", + "dmp.dmpReferences.id", + "dmp.dmpReferences.reference.id", + "dmp.dmpReferences.reference.label", + "dmp.dmpReferences.reference.type.id", + "dmp.dmpReferences.reference.reference", + "dmp.dmpReferences.isActive", + "dmpDescriptionTemplate.id", + "dmpDescriptionTemplate.dmp.id", + "dmpDescriptionTemplate.descriptionTemplateGroupId", + "dmpDescriptionTemplate.sectionId" + ] + }, + "page":{ + "size":5, + "offset":0 + }, + "order":{ + "items":[ + "-updatedAt" + ] + }, + "metadata":{ + "countAll":true + }, + "isActive":[ + 1 + ] + } + """; + + public static final String endpoint_get = + """ + + """; + } + +}