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()));
}
Aggregations