use of com.epam.ta.reportportal.core.events.activity.LaunchStartedEvent in project service-api by reportportal.
the class StartLaunchHandlerImpl method startLaunch.
@Override
@Transactional
public StartLaunchRS startLaunch(ReportPortalUser user, ReportPortalUser.ProjectDetails projectDetails, StartLaunchRQ request) {
validateRoles(projectDetails, request);
final Launch savedLaunch = Optional.of(request.isRerun()).filter(Boolean::booleanValue).map(rerun -> rerunHandler.handleLaunch(request, projectDetails.getProjectId(), user)).orElseGet(() -> {
Launch launch = new LaunchBuilder().addStartRQ(request).addAttributes(request.getAttributes()).addProject(projectDetails.getProjectId()).addUserId(user.getUserId()).get();
launchRepository.save(launch);
launchRepository.refresh(launch);
return launch;
});
eventPublisher.publishEvent(new StartLaunchEvent(savedLaunch.getId()));
messageBus.publishActivity(new LaunchStartedEvent(TO_ACTIVITY_RESOURCE.apply(savedLaunch), user.getUserId(), user.getUsername()));
StartLaunchRS response = new StartLaunchRS();
response.setId(savedLaunch.getUuid());
response.setNumber(savedLaunch.getNumber());
return response;
}
Aggregations