Search in sources :

Example 1 with PatternDeletedEvent

use of com.epam.ta.reportportal.core.events.activity.PatternDeletedEvent in project service-api by reportportal.

the class DeleteProjectSettingsHandlerImpl method deletePatternTemplate.

@Override
public OperationCompletionRS deletePatternTemplate(String projectName, ReportPortalUser user, Long id) {
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
    PatternTemplate patternTemplate = patternTemplateRepository.findByIdAndProjectId(id, project.getId()).orElseThrow(() -> new ReportPortalException(ErrorType.PATTERN_TEMPLATE_NOT_FOUND_IN_PROJECT, id, project.getName()));
    PatternTemplateActivityResource before = PatternTemplateConverter.TO_ACTIVITY_RESOURCE.apply(patternTemplate);
    patternTemplateRepository.deleteById(patternTemplate.getId());
    messageBus.publishActivity(new PatternDeletedEvent(user.getUserId(), user.getUsername(), before));
    return new OperationCompletionRS(Suppliers.formattedSupplier("Pattern template with id = '{}' has been successfully removed.", id).get());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) PatternDeletedEvent(com.epam.ta.reportportal.core.events.activity.PatternDeletedEvent) PatternTemplateActivityResource(com.epam.ta.reportportal.ws.model.activity.PatternTemplateActivityResource) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) PatternTemplate(com.epam.ta.reportportal.entity.pattern.PatternTemplate) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

PatternDeletedEvent (com.epam.ta.reportportal.core.events.activity.PatternDeletedEvent)1 PatternTemplate (com.epam.ta.reportportal.entity.pattern.PatternTemplate)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 PatternTemplateActivityResource (com.epam.ta.reportportal.ws.model.activity.PatternTemplateActivityResource)1