Search in sources :

Example 11 with LaunchesProjectEvent

use of ca.corefacility.bioinformatics.irida.events.annotations.LaunchesProjectEvent in project irida by phac-nml.

the class ProjectServiceImpl method updateUserProjectRole.

/**
 * {@inheritDoc}
 */
@Override
@Transactional
@LaunchesProjectEvent(UserRoleSetProjectEvent.class)
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#project,'canManageLocalProjectSettings')")
public Join<Project, User> updateUserProjectRole(Project project, User user, ProjectRole projectRole) throws ProjectWithoutOwnerException {
    ProjectUserJoin projectJoinForUser = pujRepository.getProjectJoinForUser(project, user);
    if (projectJoinForUser == null) {
        throw new EntityNotFoundException("Join between this project and user does not exist. User: " + user + " Project: " + project);
    }
    if (!allowRoleChange(projectJoinForUser.getSubject(), projectJoinForUser.getProjectRole())) {
        throw new ProjectWithoutOwnerException("This role change would leave the project without an owner");
    }
    projectJoinForUser.setProjectRole(projectRole);
    return pujRepository.save(projectJoinForUser);
}
Also used : ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) ProjectWithoutOwnerException(ca.corefacility.bioinformatics.irida.exceptions.ProjectWithoutOwnerException) EntityNotFoundException(ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException) LaunchesProjectEvent(ca.corefacility.bioinformatics.irida.events.annotations.LaunchesProjectEvent) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with LaunchesProjectEvent

use of ca.corefacility.bioinformatics.irida.events.annotations.LaunchesProjectEvent in project irida by phac-nml.

the class SequencingObjectServiceImpl method createSequencingObjectInSample.

/**
 * {@inheritDoc}
 */
@Override
@Transactional
@PreAuthorize("hasPermission(#sample, 'canUpdateSample')")
@LaunchesProjectEvent(DataAddedToSampleProjectEvent.class)
public SampleSequencingObjectJoin createSequencingObjectInSample(SequencingObject seqObject, Sample sample) {
    // create the sequencing object
    seqObject = create(seqObject);
    // save the new join
    SampleSequencingObjectJoin sampleSequencingObjectJoin = new SampleSequencingObjectJoin(sample, seqObject);
    return ssoRepository.save(sampleSequencingObjectJoin);
}
Also used : SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) LaunchesProjectEvent(ca.corefacility.bioinformatics.irida.events.annotations.LaunchesProjectEvent) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

LaunchesProjectEvent (ca.corefacility.bioinformatics.irida.events.annotations.LaunchesProjectEvent)12 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)10 Transactional (org.springframework.transaction.annotation.Transactional)10 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)6 ProjectWithoutOwnerException (ca.corefacility.bioinformatics.irida.exceptions.ProjectWithoutOwnerException)4 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)4 ArrayList (java.util.ArrayList)4 ProjectUserJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin)3 UserGroupProjectJoin (ca.corefacility.bioinformatics.irida.model.user.group.UserGroupProjectJoin)3 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)2 UserGroupRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.enums.UserGroupRemovedProjectEvent)2 DataAddedToSampleProjectEvent (ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent)2 ProjectEvent (ca.corefacility.bioinformatics.irida.model.event.ProjectEvent)2 SampleAddedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent)2 SampleRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.SampleRemovedProjectEvent)2 UserGroupRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserGroupRoleSetProjectEvent)2 UserRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent)2 UserRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent)2 Project (ca.corefacility.bioinformatics.irida.model.project.Project)2 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)2