Class ProjectDao


  • public class ProjectDao
    extends Object
    Project persistence

    Note : Most of database operations are handled by managed entities and cascade.

    Author:
    maxence
    • Constructor Detail

      • ProjectDao

        public ProjectDao()
    • 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 user
        b - 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