Search in sources :

Example 1 with DefectTypeUpdatedEvent

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

the class UpdateProjectSettingsHandlerImpl method updateProjectIssueSubType.

@Override
public OperationCompletionRS updateProjectIssueSubType(String projectName, ReportPortalUser user, UpdateIssueSubTypeRQ updateIssueSubTypeRQ) {
    expect(updateIssueSubTypeRQ.getIds().size() > 0, equalTo(true)).verify(FORBIDDEN_OPERATION, "Please specify at least one item data for update.");
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName));
    List<IssueTypeActivityResource> issueTypeActivityResources = updateIssueSubTypeRQ.getIds().stream().map(subTypeRQ -> TO_ACTIVITY_RESOURCE.apply(validateAndUpdate(subTypeRQ, project.getProjectIssueTypes().stream().map(ProjectIssueType::getIssueType).collect(Collectors.toList())))).collect(Collectors.toList());
    projectRepository.save(project);
    issueTypeActivityResources.forEach(it -> messageBus.publishActivity(new DefectTypeUpdatedEvent(it, user.getUserId(), user.getUsername(), project.getId())));
    return new OperationCompletionRS("Issue sub-type(s) was updated successfully.");
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) UpdateIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateIssueSubTypeRQ) UpdateOneIssueSubTypeRQ(com.epam.ta.reportportal.ws.model.project.config.UpdateOneIssueSubTypeRQ) PatternTemplate(com.epam.ta.reportportal.entity.pattern.PatternTemplate) Autowired(org.springframework.beans.factory.annotation.Autowired) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) UpdateProjectSettingsHandler(com.epam.ta.reportportal.core.project.settings.UpdateProjectSettingsHandler) StringUtils(org.apache.commons.lang3.StringUtils) DefectTypeUpdatedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeUpdatedEvent) PatternTemplateActivityResource(com.epam.ta.reportportal.ws.model.activity.PatternTemplateActivityResource) Predicates(com.epam.ta.reportportal.commons.Predicates) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) PatternUpdatedEvent(com.epam.ta.reportportal.core.events.activity.PatternUpdatedEvent) Service(org.springframework.stereotype.Service) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) PatternTemplateConverter(com.epam.ta.reportportal.ws.converter.converters.PatternTemplateConverter) BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) IssueTypeActivityResource(com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource) BusinessRule.expect(com.epam.ta.reportportal.commons.validation.BusinessRule.expect) Optional.ofNullable(java.util.Optional.ofNullable) TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) PatternTemplateRepository(com.epam.ta.reportportal.dao.PatternTemplateRepository) List(java.util.List) TO_ACTIVITY_RESOURCE(com.epam.ta.reportportal.ws.converter.converters.IssueTypeConverter.TO_ACTIVITY_RESOURCE) ProjectRepository(com.epam.ta.reportportal.dao.ProjectRepository) ProjectIssueType(com.epam.ta.reportportal.entity.project.ProjectIssueType) Suppliers(com.epam.ta.reportportal.commons.validation.Suppliers) UpdatePatternTemplateRQ(com.epam.ta.reportportal.ws.model.project.config.pattern.UpdatePatternTemplateRQ) Transactional(org.springframework.transaction.annotation.Transactional) Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) DefectTypeUpdatedEvent(com.epam.ta.reportportal.core.events.activity.DefectTypeUpdatedEvent) IssueTypeActivityResource(com.epam.ta.reportportal.ws.model.activity.IssueTypeActivityResource) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

Predicates (com.epam.ta.reportportal.commons.Predicates)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1 Suppliers (com.epam.ta.reportportal.commons.validation.Suppliers)1 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)1 DefectTypeUpdatedEvent (com.epam.ta.reportportal.core.events.activity.DefectTypeUpdatedEvent)1 PatternUpdatedEvent (com.epam.ta.reportportal.core.events.activity.PatternUpdatedEvent)1 UpdateProjectSettingsHandler (com.epam.ta.reportportal.core.project.settings.UpdateProjectSettingsHandler)1 PatternTemplateRepository (com.epam.ta.reportportal.dao.PatternTemplateRepository)1 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)1 TestItemIssueGroup (com.epam.ta.reportportal.entity.enums.TestItemIssueGroup)1 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)1 PatternTemplate (com.epam.ta.reportportal.entity.pattern.PatternTemplate)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ProjectIssueType (com.epam.ta.reportportal.entity.project.ProjectIssueType)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 TO_ACTIVITY_RESOURCE (com.epam.ta.reportportal.ws.converter.converters.IssueTypeConverter.TO_ACTIVITY_RESOURCE)1 PatternTemplateConverter (com.epam.ta.reportportal.ws.converter.converters.PatternTemplateConverter)1 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)1