Search in sources :

Example 1 with StartLaunchEvent

use of com.epam.reportportal.extension.event.StartLaunchEvent 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;
}
Also used : Primary(org.springframework.context.annotation.Primary) Launch(com.epam.ta.reportportal.entity.launch.Launch) Autowired(org.springframework.beans.factory.annotation.Autowired) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) StartLaunchEvent(com.epam.reportportal.extension.event.StartLaunchEvent) RerunHandler(com.epam.ta.reportportal.core.launch.rerun.RerunHandler) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) LaunchStartedEvent(com.epam.ta.reportportal.core.events.activity.LaunchStartedEvent) LaunchBuilder(com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) Service(org.springframework.stereotype.Service) TO_ACTIVITY_RESOURCE(com.epam.ta.reportportal.ws.converter.converters.LaunchConverter.TO_ACTIVITY_RESOURCE) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) Optional(java.util.Optional) StartLaunchHandler(com.epam.ta.reportportal.core.launch.StartLaunchHandler) Transactional(org.springframework.transaction.annotation.Transactional) LaunchStartedEvent(com.epam.ta.reportportal.core.events.activity.LaunchStartedEvent) StartLaunchRS(com.epam.ta.reportportal.ws.model.launch.StartLaunchRS) StartLaunchEvent(com.epam.reportportal.extension.event.StartLaunchEvent) Launch(com.epam.ta.reportportal.entity.launch.Launch) LaunchBuilder(com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

StartLaunchEvent (com.epam.reportportal.extension.event.StartLaunchEvent)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)1 LaunchStartedEvent (com.epam.ta.reportportal.core.events.activity.LaunchStartedEvent)1 StartLaunchHandler (com.epam.ta.reportportal.core.launch.StartLaunchHandler)1 RerunHandler (com.epam.ta.reportportal.core.launch.rerun.RerunHandler)1 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1 LaunchBuilder (com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder)1 TO_ACTIVITY_RESOURCE (com.epam.ta.reportportal.ws.converter.converters.LaunchConverter.TO_ACTIVITY_RESOURCE)1 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)1 StartLaunchRS (com.epam.ta.reportportal.ws.model.launch.StartLaunchRS)1 Optional (java.util.Optional)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)1 Primary (org.springframework.context.annotation.Primary)1 Service (org.springframework.stereotype.Service)1 Transactional (org.springframework.transaction.annotation.Transactional)1