Search in sources :

Example 1 with PreferenceResource

use of com.epam.ta.reportportal.ws.model.preference.PreferenceResource in project service-api by reportportal.

the class GetPreferenceHandlerImpl method getPreference.

@Override
public PreferenceResource getPreference(ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
    List<UserPreference> userPreferences = userPreferenceRepository.findByProjectIdAndUserId(projectDetails.getProjectId(), user.getUserId());
    PreferenceResource preferenceResource = new PreferenceResource();
    preferenceResource.setUserId(user.getUserId());
    preferenceResource.setProjectId(projectDetails.getProjectId());
    List<UserFilterResource> filters = userPreferences.stream().map(it -> UserFilterConverter.TO_FILTER_RESOURCE.apply(it.getFilter())).collect(Collectors.toList());
    preferenceResource.setFilters(filters);
    return preferenceResource;
}
Also used : List(java.util.List) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) GetPreferenceHandler(com.epam.ta.reportportal.core.preference.GetPreferenceHandler) Service(org.springframework.stereotype.Service) UserFilterConverter(com.epam.ta.reportportal.ws.converter.converters.UserFilterConverter) UserPreference(com.epam.ta.reportportal.entity.preference.UserPreference) Autowired(org.springframework.beans.factory.annotation.Autowired) UserFilterResource(com.epam.ta.reportportal.ws.model.filter.UserFilterResource) PreferenceResource(com.epam.ta.reportportal.ws.model.preference.PreferenceResource) Collectors(java.util.stream.Collectors) UserPreferenceRepository(com.epam.ta.reportportal.dao.UserPreferenceRepository) UserPreference(com.epam.ta.reportportal.entity.preference.UserPreference) PreferenceResource(com.epam.ta.reportportal.ws.model.preference.PreferenceResource) UserFilterResource(com.epam.ta.reportportal.ws.model.filter.UserFilterResource)

Aggregations

ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 GetPreferenceHandler (com.epam.ta.reportportal.core.preference.GetPreferenceHandler)1 UserPreferenceRepository (com.epam.ta.reportportal.dao.UserPreferenceRepository)1 UserPreference (com.epam.ta.reportportal.entity.preference.UserPreference)1 UserFilterConverter (com.epam.ta.reportportal.ws.converter.converters.UserFilterConverter)1 UserFilterResource (com.epam.ta.reportportal.ws.model.filter.UserFilterResource)1 PreferenceResource (com.epam.ta.reportportal.ws.model.preference.PreferenceResource)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1