Class ProjectDBService

java.lang.Object
org.trustdeck.service.ProjectDBService

@Service public class ProjectDBService extends Object
This class encapsulates the database access for project objects.
  • Constructor Details

    • ProjectDBService

      public ProjectDBService()
  • Method Details

    • createProject

      @Transactional public ProjectDTO createProject(ProjectDTO project, jakarta.servlet.http.HttpServletRequest request) throws DuplicateProjectException
      Method to insert a new project into the database table.
      Parameters:
      project - the project object containing the necessary information
      request - the http request object containing information necessary for the audit trail
      Returns:
      The inserted project object including the ID when the insertion was successful, null when the insertion failed or would create a duplicate.
      Throws:
      DuplicateProjectException - when the project (identified by the name) is already in the database
    • getProjectByName

      @Transactional public ProjectDTO getProjectByName(String name, jakarta.servlet.http.HttpServletRequest request)
      This method retrieves a project by its name.
      Parameters:
      name - the name of the project to search for
      request - the http request object containing information necessary for the audit trail
      Returns:
      the project object or null if nothing was found
    • getProjectByAbbreviation

      @Transactional public ProjectDTO getProjectByAbbreviation(String abbreviation, jakarta.servlet.http.HttpServletRequest request)
      This method retrieves a project by its abbreviation.
      Parameters:
      abbreviation - the abbreviation of the project to search for
      request - the http request object containing information necessary for the audit trail
      Returns:
      the project object or null if nothing was found
    • getProjectByID

      @Transactional public ProjectDTO getProjectByID(int id, jakarta.servlet.http.HttpServletRequest request)
      This method retrieves a project by its id.
      Parameters:
      id - the id of the project to search for
      request - the http request object containing information necessary for the audit trail
      Returns:
      the project object or null if nothing was found
    • deleteProject

      @Transactional public boolean deleteProject(ProjectDTO project, OffsetDateTime deleteDate, jakarta.servlet.http.HttpServletRequest request) throws UnexpectedResultSizeException
      Delete a project from the database using its name. The deletion is a tombstoning operation where the end_date is set and no real deletion is performed.
      Parameters:
      project - the DTO containing information about the project that should be deleted
      deleteDate - the date which should be used for the end_date
      request - the http request object containing information necessary for the audit trail
      Returns:
      true when the deletion was successful, false when the project object that should be deleted was not found
      Throws:
      UnexpectedResultSizeException - whenever the deletion would not exactly affect one project entry
    • updateProject

      @Transactional public ProjectDTO updateProject(ProjectDTO oldProject, ProjectDTO updatedProject, jakarta.servlet.http.HttpServletRequest request)
      This method updates a project identified by its name.
      Parameters:
      oldProject - the project object containing information of the project that should be updated
      updatedProject - the project object containing the updated information
      request - the http request object containing information necessary for the audit trail
      Returns:
      the ID of the updated project, or null if an error occurred
    • getAllProjects

      @Transactional(readOnly=true) public List<ProjectDTO> getAllProjects(jakarta.servlet.http.HttpServletRequest request)
      This method retrieves all projects.
      Parameters:
      request - the http request object containing information necessary for the audit trail
      Returns:
      all projects as a list
    • getAllProjectNames

      @Transactional(readOnly=true) public List<String> getAllProjectNames(jakarta.servlet.http.HttpServletRequest request)
      This method retrieves all project names.
      Parameters:
      request - the http request object containing information necessary for the audit trail
      Returns:
      the names of all projects as a list