Search in sources :

Example 1 with ReadableUserPopulator

use of com.salesmanager.shop.populator.user.ReadableUserPopulator in project shopizer by shopizer-ecommerce.

the class UserFacadeImpl method convertUserToReadableUser.

private ReadableUser convertUserToReadableUser(Language lang, User user) {
    ReadableUserPopulator populator = new ReadableUserPopulator();
    try {
        ReadableUser readableUser = new ReadableUser();
        readableUser = populator.populate(user, readableUser, user.getMerchantStore(), lang);
        List<Integer> groupIds = readableUser.getGroups().stream().map(ReadableGroup::getId).map(Long::intValue).collect(Collectors.toList());
        List<ReadablePermission> permissions = findPermissionsByGroups(groupIds);
        readableUser.setPermissions(permissions);
        return readableUser;
    } catch (ConversionException e) {
        throw new ConversionRuntimeException(e);
    }
}
Also used : ReadableGroup(com.salesmanager.shop.model.security.ReadableGroup) ReadablePermission(com.salesmanager.shop.model.security.ReadablePermission) ConversionException(com.salesmanager.core.business.exception.ConversionException) ReadableUser(com.salesmanager.shop.model.user.ReadableUser) ReadableUserPopulator(com.salesmanager.shop.populator.user.ReadableUserPopulator) ConversionRuntimeException(com.salesmanager.shop.store.api.exception.ConversionRuntimeException)

Aggregations

ConversionException (com.salesmanager.core.business.exception.ConversionException)1 ReadableGroup (com.salesmanager.shop.model.security.ReadableGroup)1 ReadablePermission (com.salesmanager.shop.model.security.ReadablePermission)1 ReadableUser (com.salesmanager.shop.model.user.ReadableUser)1 ReadableUserPopulator (com.salesmanager.shop.populator.user.ReadableUserPopulator)1 ConversionRuntimeException (com.salesmanager.shop.store.api.exception.ConversionRuntimeException)1