Class ProjectServiceImpl

    • Field Detail

      • VALID_LOCAL_SETTINGS

        public java.util.List<java.lang.String> VALID_LOCAL_SETTINGS
    • Method Detail

      • readMultiple

        @Transactional(readOnly=true)
        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#idents, \'canReadProject\')")
        public java.lang.Iterable<Project> readMultiple​(java.lang.Iterable<java.lang.Long> idents)
        Read multiple objects by the given collection of identifiers
        Specified by:
        readMultiple in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        readMultiple in class CRUDServiceImpl<java.lang.Long,​Project>
        Parameters:
        idents - The unique identifiers of the objects to read
        Returns:
        A collection of the requested objects
      • findRevisions

        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#id, \'canReadProject\')")
        public org.springframework.data.history.Revisions<java.lang.Integer,​Project> findRevisions​(java.lang.Long id)
        Find all of the revisions for the specified identifier.
        Specified by:
        findRevisions in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        findRevisions in class CRUDServiceImpl<java.lang.Long,​Project>
        Parameters:
        id - the identifier to find revisions for.
        Returns:
        the collection of revisions for the identifier.
      • findRevisions

        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#id, \'canReadProject\')")
        public org.springframework.data.domain.Page<org.springframework.data.history.Revision<java.lang.Integer,​Project>> findRevisions​(java.lang.Long id,
                                                                                                                                              org.springframework.data.domain.Pageable pageable)
        Returns a Page of revisions for the entity with the given id.
        Specified by:
        findRevisions in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        findRevisions in class CRUDServiceImpl<java.lang.Long,​Project>
        Parameters:
        id - the identifier to find revisions for.
        pageable - the page specification.
        Returns:
        the page of revisions for the specified resource.
      • findAll

        @PreAuthorize("hasAnyRole(\'ROLE_USER\', \'ROLE_SEQUENCER\')")
        @PostFilter("hasPermission(filterObject, \'canReadProject\')")
        public java.lang.Iterable<Project> findAll()
        List all objects of Type in the database.
        Specified by:
        findAll in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        findAll in class CRUDServiceImpl<java.lang.Long,​Project>
        Returns:
        All objects of the specified Type in the database.
      • read

        @PreAuthorize("hasAnyRole(\'ROLE_ADMIN\', \'ROLE_SEQUENCER\') or hasPermission(#id, \'canReadProject\')")
        public Project read​(java.lang.Long id)
        Read the object type by unique identifier.
        Specified by:
        read in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        read in class CRUDServiceImpl<java.lang.Long,​Project>
        Parameters:
        id - The unique identifier for this object.
        Returns:
        The object corresponding to the unique identifier.
      • create

        @Transactional
        @PreAuthorize("hasAnyRole(\'ROLE_USER\')")
        public Project create​(Project p)
        Create a new object in the persistence store.
        Specified by:
        create in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        create in class CRUDServiceImpl<java.lang.Long,​Project>
        Parameters:
        p - The object to persist.
        Returns:
        The object as it was persisted in the database. May modify the identifier of the object when returned.
      • update

        @Transactional
        @PreAuthorize("hasPermission(#object, \'isProjectOwner\')")
        public Project update​(Project object)
        Update an object
        Specified by:
        update in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        update in class CRUDServiceImpl<java.lang.Long,​Project>
        Parameters:
        object - The object to update
        Returns:
        The updated object
      • updateFields

        @Transactional
        @PreAuthorize("hasPermission(#id, \'isProjectOwner\')")
        public Project updateFields​(java.lang.Long id,
                                    java.util.Map<java.lang.String,​java.lang.Object> updatedFields)
                             throws javax.validation.ConstraintViolationException,
                                    EntityExistsException,
                                    InvalidPropertyException
        Update properties of the given object by given fields. The object must have a valid identifier prior to being passed to this method.
        Specified by:
        updateFields in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        updateFields in class CRUDServiceImpl<java.lang.Long,​Project>
        Parameters:
        id - The identifier of the object to update.
        updatedFields - the object properties that should be updated.
        Returns:
        The object as it was persisted in the database. May modify the identifier of the object when returned.
        Throws:
        javax.validation.ConstraintViolationException - If the object being persisted cannot be validated by validation rules associated with the object.
        EntityExistsException - If the object being persisted violates uniqueness constraints in the database.
        InvalidPropertyException - If the updated properties map contains a property name that does not exist on the domain model.
      • updateProjectSettings

        @PreAuthorize("hasPermission(#project, \'canManageLocalProjectSettings\')")
        public Project updateProjectSettings​(Project project,
                                             java.util.Map<java.lang.String,​java.lang.Object> updates)
        Update select Project settings
        Specified by:
        updateProjectSettings in interface ProjectService
        Parameters:
        project - the project to update
        updates - a map of fields to update
        Returns:
        the updated Project
      • delete

        @Transactional
        @PreAuthorize("hasAnyRole(\'ROLE_ADMIN\') or hasPermission(#id, \'canManageLocalProjectSettings\')")
        public void delete​(java.lang.Long id)
        Delete the object with the specified identifier from the database.
        Specified by:
        delete in interface CRUDService<java.lang.Long,​Project>
        Overrides:
        delete in class CRUDServiceImpl<java.lang.Long,​Project>
        Parameters:
        id - The identifier of the object to delete.
      • addUserToProject

        @Transactional
        @PreAuthorize("hasPermission(#project, \'canManageLocalProjectSettings\')")
        public Join<Project,​User> addUserToProject​(Project project,
                                                         User user,
                                                         ProjectRole role,
                                                         ProjectMetadataRole metadataRole)
        Add the specified User to the Project with a Role . If the User is a manager for the Project, then the User should be added to the Project with the 'ROLE_MANAGER' Role.
        Specified by:
        addUserToProject in interface ProjectService
        Parameters:
        project - the Project to add the user to.
        user - the user to add to the Project.
        role - the role that the user plays on the Project.
        metadataRole - the access level the user has on the metadata in the project
        Returns:
        a reference to the relationship resource created between the two entities.
      • addSampleToProject

        @Transactional
        @PreAuthorize("hasAnyRole(\'ROLE_ADMIN\', \'ROLE_SEQUENCER\') or (hasPermission(#project, \'isProjectOwner\'))")
        public ProjectSampleJoin addSampleToProject​(Project project,
                                                    Sample sample,
                                                    boolean owner)
        Add the specified Sample to the Project.
        Specified by:
        addSampleToProject in interface ProjectService
        Parameters:
        project - the Project to add the Sample to.
        sample - the Sample to add to the Project. If the Sample has not previously been persisted, the service will persist the Sample.
        owner - Whether the project will have modification access for this sample
        Returns:
        a reference to the relationship resource created between the two entities.
      • shareSamples

        @Transactional
        @PreAuthorize("hasPermission(#source, \'canManageLocalProjectSettings\') and hasPermission(#destination, \'isProjectOwner\') and hasPermission(#samples, \'canReadSample\') and ((not #giveOwner) or hasPermission(#samples, \'canUpdateSample\'))")
        public java.util.List<ProjectSampleJoin> shareSamples​(Project source,
                                                              Project destination,
                                                              java.util.Collection<Sample> samples,
                                                              boolean giveOwner)
        Share a list of Samples between two Projects.
        Specified by:
        shareSamples in interface ProjectService
        Parameters:
        source - the source Project
        destination - the Project being shared into
        samples - a collection of Sample
        giveOwner - whether to give ownership rights to the destination Project
        Returns:
        a list of new ProjectSampleJoin
      • removeSampleFromProject

        @Transactional
        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#project, \'canManageLocalProjectSettings\')")
        public void removeSampleFromProject​(Project project,
                                            Sample sample)
        Remove the specified Sample from the Project. The Sample will also be deleted from the system because Samples cannot exist outside of a Project.
        Specified by:
        removeSampleFromProject in interface ProjectService
        Parameters:
        project - the Project to remove the Sample from.
        sample - the Sample to remove.
      • removeSamplesFromProject

        @Transactional
        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#project, \'canManageLocalProjectSettings\')")
        public void removeSamplesFromProject​(Project project,
                                             java.lang.Iterable<Sample> samples)
        Remove a collection of Samples from a Project
        Specified by:
        removeSamplesFromProject in interface ProjectService
        Parameters:
        project - the Project to remove the Samples from.
        samples - the Samples to remove.
      • getProjectsForUser

        @Transactional(readOnly=true)
        @PreAuthorize("hasRole(\'ROLE_USER\')")
        public java.util.List<Join<Project,​User>> getProjectsForUser​(User user)
        Get all Projects associated with a particular User.
        Specified by:
        getProjectsForUser in interface ProjectService
        Parameters:
        user - the user to get projects for.
        Returns:
        the projects associated with the user.
      • getProjectsForUserUnique

        @Transactional(readOnly=true)
        @PreAuthorize("hasRole(\'ROLE_USER\')")
        public java.util.List<Project> getProjectsForUserUnique​(User user)
        Get all Projects associated with a particular User.
        Specified by:
        getProjectsForUserUnique in interface ProjectService
        Parameters:
        user - the user to get the unique projects for.
        Returns:
        the projects associated with the user.
      • userHasProjectRole

        @PreAuthorize("hasPermission(#project, \'canReadProject\')")
        public boolean userHasProjectRole​(User user,
                                          Project project,
                                          ProjectRole projectRole)
        Check if a User has a given ProjectRole on a Project
        Specified by:
        userHasProjectRole in interface ProjectService
        Parameters:
        user - The user to test
        project - The project to test
        projectRole - The project role to test
        Returns:
        true/false whether the user has the given role
      • addRelatedProject

        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#subject,\'isProjectOwner\') and hasPermission(#relatedProject,\'canReadProject\')")
        public RelatedProjectJoin addRelatedProject​(Project subject,
                                                    Project relatedProject)
        Add a related Project to the given Project
        Specified by:
        addRelatedProject in interface ProjectService
        Parameters:
        subject - The parent project
        relatedProject - The project to be added to the parent
        Returns:
        a RelatedProjectJoin describing the relationship
      • removeRelatedProject

        @Transactional
        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#subject,\'isProjectOwner\')")
        public void removeRelatedProject​(Project subject,
                                         Project relatedProject)
        Remove a RelatedProjectJoin for the given project and related project
        Specified by:
        removeRelatedProject in interface ProjectService
        Parameters:
        subject - the owning project
        relatedProject - The related project
      • getProjectsForSample

        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#sample, \'canReadSample\')")
        @PostFilter("hasPermission(filterObject.subject, \'canReadProject\')")
        public java.util.List<Join<Project,​Sample>> getProjectsForSample​(Sample sample)
        Get the projects that a given sample is on
        Specified by:
        getProjectsForSample in interface ProjectService
        Parameters:
        sample - The sample to get projects for
        Returns:
        All the projects a sample exists in
      • getUnassociatedProjects

        @PreAuthorize("hasRole(\'ROLE_ADMIN\') or hasPermission(#p, \'canManageLocalProjectSettings\')")
        public org.springframework.data.domain.Page<Project> getUnassociatedProjects​(Project p,
                                                                                     java.lang.String searchName,
                                                                                     java.lang.Integer page,
                                                                                     java.lang.Integer count,
                                                                                     org.springframework.data.domain.Sort.Direction sortDirection,
                                                                                     java.lang.String... sortedBy)
        Get a page of projects eligible to be marked as associated projects for the specified project.
        Specified by:
        getUnassociatedProjects in interface ProjectService
        Parameters:
        p - the project to get eligible associated projects.
        searchName - the name of projects to filter on.
        page - the requested page of results.
        count - the number of results on the page.
        sortDirection - the direction the results should be sorted by.
        sortedBy - the property to be used to sort the results.
        Returns:
        a page of projects eligible to be marked as associated projects.
      • findProjectsForUser

        @PreAuthorize("hasRole(\'ROLE_USER\')")
        public org.springframework.data.domain.Page<Project> findProjectsForUser​(java.lang.String search,
                                                                                 java.lang.Integer page,
                                                                                 java.lang.Integer count,
                                                                                 org.springframework.data.domain.Sort sort)
        Find a list of projects (for a user or admin) using the specified search criteria
        Specified by:
        findProjectsForUser in interface ProjectService
        Parameters:
        search - String generic string to search terms for
        page - Integer current page viewed.
        count - Integer length of current page.
        sort - Sort Current table sort properties.
        Returns:
        Page of Project
      • findAllProjects

        @PreAuthorize("hasRole(\'ROLE_ADMIN\')")
        public org.springframework.data.domain.Page<Project> findAllProjects​(java.lang.String searchValue,
                                                                             int currentPage,
                                                                             int length,
                                                                             org.springframework.data.domain.Sort sort)
        Find a paged list of all projects (for admin) using the specified search criteria.
        Specified by:
        findAllProjects in interface ProjectService
        Parameters:
        searchValue - String generic string to search terms for
        currentPage - Integer current page viewed.
        length - Integer length of current page.
        sort - Sort Current table sort properties.
        Returns:
        Page of Project
      • createProjectWithSamples

        @Transactional
        @PreAuthorize("hasPermission(#sampleIds, \'canUpdateSample\')")
        public Project createProjectWithSamples​(Project project,
                                                java.util.List<java.lang.Long> sampleIds,
                                                boolean owner)
        Create a Project with the given Samples contained
        Specified by:
        createProjectWithSamples in interface ProjectService
        Parameters:
        project - the Project to create
        sampleIds - IDs of the Samples
        owner - whether to lock Sample modification from new project
        Returns:
        the created Project
      • getProjectsCreated

        @PreAuthorize("hasRole(\'ROLE_ADMIN\')")
        public java.lang.Long getProjectsCreated​(java.util.Date createdDate)
        Get count of projects created in the time period
        Specified by:
        getProjectsCreated in interface ProjectService
        Parameters:
        createdDate - the minimum date for projects created
        Returns:
        An Long count of projects created
      • getProjectsCreatedGrouped

        @PreAuthorize("hasRole(\'ROLE_ADMIN\')")
        public java.util.List<GenericStatModel> getProjectsCreatedGrouped​(java.util.Date createdDate,
                                                                          StatisticTimePeriod statisticTimePeriod)
        Get list of GenericStatModel of projects created in the past n time period and grouped by the format provided.
        Specified by:
        getProjectsCreatedGrouped in interface ProjectService
        Parameters:
        createdDate - the minimum date for projects created
        statisticTimePeriod - the enum containing format for which to group the results by
        Returns:
        An GenericStatModel list