Search in sources :

Example 1 with UserGroupRemovedProjectEvent

use of ca.corefacility.bioinformatics.irida.model.enums.UserGroupRemovedProjectEvent in project irida by phac-nml.

the class ProjectEventHandler method handleUserGroupRemovedEvent.

/**
 * Create a {@link UserRemovedProjectEvent}. The method arguments must
 * contain a {@link Project} and {@link User}
 *
 * @param event
 *            The {@link MethodEvent} that this event is being launched from
 */
private ProjectEvent handleUserGroupRemovedEvent(MethodEvent event) {
    final Optional<Object> user = Arrays.stream(event.getArgs()).filter(e -> e instanceof UserGroup).findAny();
    final Optional<Object> project = Arrays.stream(event.getArgs()).filter(e -> e instanceof Project).findAny();
    if (!user.isPresent() || !project.isPresent()) {
        throw new IllegalArgumentException("Project or user group cannot be found on method annotated with @LaunchesProjectEvent(UserGroupRemovedProjectEvent.class)");
    }
    return eventRepository.save(new UserGroupRemovedProjectEvent((Project) project.get(), (UserGroup) user.get()));
}
Also used : ProjectSampleJoinRepository(ca.corefacility.bioinformatics.irida.repositories.joins.project.ProjectSampleJoinRepository) Arrays(java.util.Arrays) UserGroupRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.enums.UserGroupRemovedProjectEvent) ProjectEventRepository(ca.corefacility.bioinformatics.irida.repositories.ProjectEventRepository) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) SampleRepository(ca.corefacility.bioinformatics.irida.repositories.sample.SampleRepository) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ArrayList(java.util.ArrayList) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) LaunchesProjectEvent(ca.corefacility.bioinformatics.irida.events.annotations.LaunchesProjectEvent) ProjectRepository(ca.corefacility.bioinformatics.irida.repositories.ProjectRepository) Logger(org.slf4j.Logger) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Collection(java.util.Collection) DataAddedToSampleProjectEvent(ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) UserGroup(ca.corefacility.bioinformatics.irida.model.user.group.UserGroup) SampleRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleRemovedProjectEvent) UserGroupRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserGroupRoleSetProjectEvent) Project(ca.corefacility.bioinformatics.irida.model.project.Project) List(java.util.List) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) UserGroupProjectJoin(ca.corefacility.bioinformatics.irida.model.user.group.UserGroupProjectJoin) Optional(java.util.Optional) User(ca.corefacility.bioinformatics.irida.model.user.User) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) UserGroupRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.enums.UserGroupRemovedProjectEvent) Project(ca.corefacility.bioinformatics.irida.model.project.Project) UserGroup(ca.corefacility.bioinformatics.irida.model.user.group.UserGroup)

Aggregations

LaunchesProjectEvent (ca.corefacility.bioinformatics.irida.events.annotations.LaunchesProjectEvent)1 UserGroupRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.enums.UserGroupRemovedProjectEvent)1 DataAddedToSampleProjectEvent (ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent)1 ProjectEvent (ca.corefacility.bioinformatics.irida.model.event.ProjectEvent)1 SampleAddedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent)1 SampleRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.SampleRemovedProjectEvent)1 UserGroupRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserGroupRoleSetProjectEvent)1 UserRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent)1 UserRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent)1 Join (ca.corefacility.bioinformatics.irida.model.joins.Join)1 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)1 ProjectUserJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin)1 Project (ca.corefacility.bioinformatics.irida.model.project.Project)1 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)1 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)1 User (ca.corefacility.bioinformatics.irida.model.user.User)1 UserGroup (ca.corefacility.bioinformatics.irida.model.user.group.UserGroup)1 UserGroupProjectJoin (ca.corefacility.bioinformatics.irida.model.user.group.UserGroupProjectJoin)1 ProjectEventRepository (ca.corefacility.bioinformatics.irida.repositories.ProjectEventRepository)1 ProjectRepository (ca.corefacility.bioinformatics.irida.repositories.ProjectRepository)1