Package org.trustdeck.service
Class ProjectDBService
java.lang.Object
org.trustdeck.service.ProjectDBService
This class encapsulates the database access for project objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateProject(ProjectDTO project, jakarta.servlet.http.HttpServletRequest request) Method to insert a new project into the database table.booleandeleteProject(ProjectDTO project, OffsetDateTime deleteDate, jakarta.servlet.http.HttpServletRequest request) Delete a project from the database using its name.getAllProjectNames(jakarta.servlet.http.HttpServletRequest request) This method retrieves all project names.getAllProjects(jakarta.servlet.http.HttpServletRequest request) This method retrieves all projects.getProjectByAbbreviation(String abbreviation, jakarta.servlet.http.HttpServletRequest request) This method retrieves a project by its abbreviation.getProjectByID(int id, jakarta.servlet.http.HttpServletRequest request) This method retrieves a project by its id.getProjectByName(String name, jakarta.servlet.http.HttpServletRequest request) This method retrieves a project by its name.updateProject(ProjectDTO oldProject, ProjectDTO updatedProject, jakarta.servlet.http.HttpServletRequest request) This method updates a project identified by its name.
-
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 informationrequest- the http request object containing information necessary for the audit trail- Returns:
- The inserted project object including the ID when the insertion was successful,
nullwhen 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 forrequest- the http request object containing information necessary for the audit trail- Returns:
- the project object or
nullif 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 forrequest- the http request object containing information necessary for the audit trail- Returns:
- the project object or
nullif 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 forrequest- the http request object containing information necessary for the audit trail- Returns:
- the project object or
nullif 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 deleteddeleteDate- the date which should be used for the end_daterequest- the http request object containing information necessary for the audit trail- Returns:
truewhen the deletion was successful,falsewhen 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 updatedupdatedProject- the project object containing the updated informationrequest- the http request object containing information necessary for the audit trail- Returns:
- the ID of the updated project, or
nullif 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
-