Search in sources :

Example 1 with FilterCreatedEvent

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

the class UpdateUserFilterHandlerImpl method createFilter.

@Override
public EntryCreatedRS createFilter(UpdateUserFilterRQ createFilterRQ, String projectName, ReportPortalUser user) {
    ReportPortalUser.ProjectDetails projectDetails = projectExtractor.extractProjectDetails(user, projectName);
    validateFilterRq(createFilterRQ);
    BusinessRule.expect(userFilterRepository.existsByNameAndOwnerAndProjectId(createFilterRQ.getName(), user.getUsername(), projectDetails.getProjectId()), BooleanUtils::isFalse).verify(ErrorType.USER_FILTER_ALREADY_EXISTS, createFilterRQ.getName(), user.getUsername(), projectName);
    UserFilter filter = new UserFilterBuilder().addFilterRq(createFilterRQ).addProject(projectDetails.getProjectId()).addOwner(user.getUsername()).get();
    userFilterRepository.save(filter);
    aclHandler.initAcl(filter, user.getUsername(), projectDetails.getProjectId(), BooleanUtils.isTrue(createFilterRQ.getShare()));
    messageBus.publishActivity(new FilterCreatedEvent(TO_ACTIVITY_RESOURCE.apply(filter), user.getUserId(), user.getUsername()));
    return new EntryCreatedRS(filter.getId());
}
Also used : UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) FilterCreatedEvent(com.epam.ta.reportportal.core.events.activity.FilterCreatedEvent) EntryCreatedRS(com.epam.ta.reportportal.ws.model.EntryCreatedRS) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) UserFilterBuilder(com.epam.ta.reportportal.ws.converter.builders.UserFilterBuilder)

Aggregations

ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 FilterCreatedEvent (com.epam.ta.reportportal.core.events.activity.FilterCreatedEvent)1 UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)1 UserFilterBuilder (com.epam.ta.reportportal.ws.converter.builders.UserFilterBuilder)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1