Class ProjectDao
- java.lang.Object
-
- ch.colabproject.colab.api.persistence.jpa.project.ProjectDao
-
public class ProjectDao extends Object
Project persistenceNote : Most of database operations are handled by managed entities and cascade.
- Author:
- maxence
-
-
Constructor Summary
Constructors Constructor Description ProjectDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteProject(Project project)
Delete the project from database.List<Project>
findAllGlobalModels()
Get the list of all global projectList<Project>
findAllProject()
Get the list of all projectboolean
findIfUsersHaveCommonProject(User a, User b)
Do two users work with a common project ?Project
findProject(Long id)
Find a project by idList<Project>
findProjectsByInstanceMaker(Long userId)
Get all projects the user is an instance maker forList<Project>
findProjectsByTeamMember(Long userId)
Get all projects the user is a team member ofList<Long>
findProjectsIdsByInstanceMaker(Long userId)
Get the ids of the models the user is an instance maker forList<Long>
findProjectsIdsByTeamMember(Long userId)
Get the ids of the projects the user is a team member ofProject
persistProject(Project project)
Persist a brand new project to databaseProject
updateProject(Project project)
Update project.
-
-
-
Method Detail
-
findProject
public Project findProject(Long id)
Find a project by id- Parameters:
id
- the id of the project to fetch- Returns:
- the project with the given id or null is such a project does not exist
-
findAllProject
public List<Project> findAllProject()
Get the list of all project- Returns:
- list of all projects
-
findAllGlobalModels
public List<Project> findAllGlobalModels()
Get the list of all global project- Returns:
- list of all global projects
-
findProjectsByTeamMember
public List<Project> findProjectsByTeamMember(Long userId)
Get all projects the user is a team member of- Parameters:
userId
- the id of the user- Returns:
- list of projects
-
findProjectsIdsByTeamMember
public List<Long> findProjectsIdsByTeamMember(Long userId)
Get the ids of the projects the user is a team member of- Parameters:
userId
- the id of the user- Returns:
- list of ids of projects
-
findProjectsByInstanceMaker
public List<Project> findProjectsByInstanceMaker(Long userId)
Get all projects the user is an instance maker for- Parameters:
userId
- the id of the user- Returns:
- list of projects
-
findProjectsIdsByInstanceMaker
public List<Long> findProjectsIdsByInstanceMaker(Long userId)
Get the ids of the models the user is an instance maker for- Parameters:
userId
- the id of the user- Returns:
- list of ids of models
-
findIfUsersHaveCommonProject
public boolean findIfUsersHaveCommonProject(User a, User b)
Do two users work with a common project ?- Parameters:
a
- a userb
- another user- Returns:
- true if both user are both member or instance maker of the same project
-
updateProject
public Project updateProject(Project project) throws ColabMergeException
Update project. Only fields which are editable by users will be impacted.- Parameters:
project
- the project as supplied by clients (ie not managed by JPA)- Returns:
- return updated managed project
- Throws:
ColabMergeException
- if the update failed
-
persistProject
public Project persistProject(Project project)
Persist a brand new project to database- Parameters:
project
- the new project to persist- Returns:
- the new persisted and managed project
-
deleteProject
public void deleteProject(Project project)
Delete the project from database. This can't be undone- Parameters:
project
- the project to delete
-
-