Search in sources :

Example 11 with UserGroupRecord

use of com.nike.cerberus.record.UserGroupRecord in project cerberus by Nike-Inc.

the class UserGroupPermissionService method getUserGroupPermissions.

public Set<UserGroupPermission> getUserGroupPermissions(final String safeDepositBoxId) {
    final Set<UserGroupPermission> permissionsSet = Sets.newHashSet();
    final List<UserGroupPermissionRecord> permissionRecords = userGroupDao.getUserGroupPermissions(safeDepositBoxId);
    permissionRecords.forEach(r -> {
        final Optional<UserGroupRecord> userGroupRecord = userGroupDao.getUserGroup(r.getUserGroupId());
        if (userGroupRecord.isPresent()) {
            UserGroupPermission permission = new UserGroupPermission();
            permission.setId(r.getId());
            permission.setRoleId(r.getRoleId());
            permission.setName(userGroupRecord.get().getName());
            permission.setCreatedBy(r.getCreatedBy());
            permission.setCreatedTs(r.getCreatedTs());
            permission.setLastUpdatedBy(r.getLastUpdatedBy());
            permission.setLastUpdatedTs(r.getLastUpdatedTs());
            permissionsSet.add(permission);
        }
    });
    return permissionsSet;
}
Also used : UserGroupRecord(com.nike.cerberus.record.UserGroupRecord) UserGroupPermissionRecord(com.nike.cerberus.record.UserGroupPermissionRecord) UserGroupPermission(com.nike.cerberus.domain.UserGroupPermission)

Aggregations

UserGroupRecord (com.nike.cerberus.record.UserGroupRecord)11 UserGroupPermission (com.nike.cerberus.domain.UserGroupPermission)8 UserGroupPermissionRecord (com.nike.cerberus.record.UserGroupPermissionRecord)8 Test (org.junit.Test)7 Role (com.nike.cerberus.domain.Role)3 Transactional (org.springframework.transaction.annotation.Transactional)2