Class EntityTypeRESTController

java.lang.Object
org.trustdeck.controller.EntityTypeRESTController

@RestController @EnableMethodSecurity @RequestMapping("/api") public class EntityTypeRESTController extends Object
This class offers a REST API for interacting with project entity types.
Author:
Armin Müller
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<?>
    createBaseEntityType(EntityTypeDTO entityTypeDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to create base entity types in the system.
    org.springframework.http.ResponseEntity<?>
    createProjectEntityType(String projectAbbreviation, EntityTypeDTO entityTypeDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to create a new type in the system.
    org.springframework.http.ResponseEntity<?>
    deleteProjectEntityType(String projectAbbreviation, String entityTypeName, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to delete entity types with.
    org.springframework.http.ResponseEntity<?>
    getBaseEntityType(String entityTypeName, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to retrieve a base entity type given it's name.
    org.springframework.http.ResponseEntity<?>
    getProjectEntityType(String projectAbbreviation, String entityTypeName, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to retrieve an entity type given it's name.
    org.springframework.http.ResponseEntity<?>
    searchProjectEntityType(String projectAbbreviation, String query, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to search for entity types in a project.
    org.springframework.http.ResponseEntity<?>
    updateEntityType(String projectAbbreviation, String oldEntityTypeName, EntityTypeDTO newEntityTypeDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Endpoint to update entity types.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EntityTypeRESTController

      public EntityTypeRESTController()
  • Method Details

    • createBaseEntityType

      @PostMapping("/entities/base-types") @PreAuthorize("hasRole(\'base-entity-type-create\')") public org.springframework.http.ResponseEntity<?> createBaseEntityType(@RequestBody EntityTypeDTO entityTypeDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to create base entity types in the system. These will be used as blueprints for creating other entity types, which are only allowed to extend an already existing base entity type.
      Parameters:
      entityTypeDTO - the DTO containing the type definition and some meta data
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status with the base entity type when it was already existing
    • a 201-CREATED status with the created base entity type on success
    • a 400-BAD_REQUEST status when the name/version is invalid or the type definition fails validation
    • a 422-UNPROCESSABLE_ENTITY status when creation failed
    • createProjectEntityType

      @PostMapping("/projects/{projectAbbreviation}/entities/config") @PreAuthorize("hasRole(\'project-entity-type-create\')") public org.springframework.http.ResponseEntity<?> createProjectEntityType(@PathVariable("projectAbbreviation") String projectAbbreviation, @RequestBody EntityTypeDTO entityTypeDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to create a new type in the system. This needs to be an extension from the base type that is mentioned in the given DTO.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the request is scoped to
      entityTypeDTO - the DTO containing the type definition and some meta data
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 201-CREATED status with the created project-specific entity type on success
    • a 400-BAD_REQUEST status when required fields are missing, name/version is invalid
    • a 404-NOT_FOUND status when the project or referenced base type does not exist
    • a 410-GONE status when the project has already ended/is marked as deleted
    • a 422-UNPROCESSABLE_ENTITY status when creation failed or the type definition is invalid/not a valid extension of the base type
    • getBaseEntityType

      @GetMapping("/entities/base-types/{entityTypeName}") @PreAuthorize("hasRole(\'base-entity-type-read\')") public org.springframework.http.ResponseEntity<?> getBaseEntityType(@PathVariable("entityTypeName") String entityTypeName, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to retrieve a base entity type given it's name.
      Parameters:
      entityTypeName - the name of the base entity type the user wants to retrieve
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status with the requested entity type on success
    • a 404-NOT_FOUND status when the project or the entity type does not exist
    • a 410-GONE status when the project has already ended/is marked as deleted
    • getProjectEntityType

      @GetMapping("/projects/{projectAbbreviation}/entities/config/{entityTypeName}") @PreAuthorize("hasRole(\'project-entity-type-read\')") public org.springframework.http.ResponseEntity<?> getProjectEntityType(@PathVariable("projectAbbreviation") String projectAbbreviation, @PathVariable("entityTypeName") String entityTypeName, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to retrieve an entity type given it's name.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the request is scoped to
      entityTypeName - the name of the entity type the user wants to retrieve
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status with the requested entity type on success
    • a 404-NOT_FOUND status when the project or the entity type does not exist
    • a 410-GONE status when the project has already ended/is marked as deleted
    • updateEntityType

      @PutMapping("/projects/{projectAbbreviation}/entities/config/{entityTypeName}") @PreAuthorize("hasRole(\'project-entity-type-update\')") public org.springframework.http.ResponseEntity<?> updateEntityType(@PathVariable("projectAbbreviation") String projectAbbreviation, @PathVariable("entityTypeName") String oldEntityTypeName, @RequestBody EntityTypeDTO newEntityTypeDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to update entity types. Updates are allowed on empty types only. Updatable attributes are: name, version, type definition, and the associated domain. Null-values in the given update DTO indicate that the old value will be kept.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the request is scoped to
      oldEntityTypeName - the name of the entity type the user wants to update
      newEntityTypeDTO - the DTO containing the updated information
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status with the updated entity type on success
    • a 400-BAD_REQUEST status when no updatable attributes are provided, name/version is invalid
    • a 404-NOT_FOUND status when the project, the old entity type, or the base type cannot be found
    • a 410-GONE status when the project has already ended/is marked as deleted
    • a 422-UNPROCESSABLE_ENTITY status when the update failed or the updated type definition is invalid/not a valid extension of the base type
    • deleteProjectEntityType

      @DeleteMapping("/projects/{projectAbbreviation}/entities/config/{entityTypeName}") @PreAuthorize("hasRole(\'project-entity-type-delete\')") public org.springframework.http.ResponseEntity<?> deleteProjectEntityType(@PathVariable("projectAbbreviation") String projectAbbreviation, @PathVariable("entityTypeName") String entityTypeName, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to delete entity types with. The deletion is done by tombstoning (setting the is_deprecated flag) rather than actually removing the entry.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the request is scoped to
      entityTypeName - the name of the entity type the user wants to delete
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 204-NO_CONTENT status when the entity type was successfully tombstoned
    • a 404-NOT_FOUND status when the project or the entity type does not exist
    • a 410-GONE status when the project has already ended/is marked as deleted
    • a 422-UNPROCESSABLE_ENTITY status when the deletion could not be performed
    • searchProjectEntityType

      @GetMapping("/projects/{projectAbbreviation}/entities") @PreAuthorize("hasRole(\'project-entity-type-search\')") public org.springframework.http.ResponseEntity<?> searchProjectEntityType(@PathVariable("projectAbbreviation") String projectAbbreviation, @RequestParam(name="query",required=true) String query, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Endpoint to search for entity types in a project. the search supports multi-word search and searches in the type's name, version, and type definition.
      Parameters:
      projectAbbreviation - the abbreviation of the project to which the request is scoped to
      query - the search string that should be used to find entity types
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status with the list of matching entity types on success
    • a 404-NOT_FOUND status when no entity types match the query or the project does not exist
    • a 410-GONE status when the project has already ended/is marked as deleted