Search in sources :

Example 1 with UserPreferenceBuilder

use of com.epam.ta.reportportal.ws.converter.builders.UserPreferenceBuilder in project service-api by reportportal.

the class UpdatePreferenceHandlerImpl method addPreference.

@Override
public OperationCompletionRS addPreference(ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user, Long filterId) {
    if (userPreferenceRepository.findByProjectIdAndUserIdAndFilterId(projectDetails.getProjectId(), user.getUserId(), filterId).isPresent()) {
        throw new ReportPortalException(ErrorType.RESOURCE_ALREADY_EXISTS, "User Preference");
    }
    UserFilter filter = getShareableEntityHandler.getPermitted(filterId, projectDetails);
    UserPreference userPreference = new UserPreferenceBuilder().withUser(user.getUserId()).withProject(projectDetails.getProjectId()).withFilter(filter).get();
    userPreferenceRepository.save(userPreference);
    return new OperationCompletionRS("Filter with id = " + filterId + " successfully added to launches tab.");
}
Also used : UserPreferenceBuilder(com.epam.ta.reportportal.ws.converter.builders.UserPreferenceBuilder) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) UserPreference(com.epam.ta.reportportal.entity.preference.UserPreference) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)1 UserPreference (com.epam.ta.reportportal.entity.preference.UserPreference)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 UserPreferenceBuilder (com.epam.ta.reportportal.ws.converter.builders.UserPreferenceBuilder)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1