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