private List<String> fetchGroupNamesForUser(final Long userId) { final List<String> groupNames = new ArrayList<String>(); final Alias groupClassAlias = EntryTypeAlias.canonicalAlias(roleClass()); final Alias userClassAlias = EntryTypeAlias.canonicalAlias(userClass()); final CMQueryResult userGroupsRows = view.select(attribute(groupClassAlias, Role.CODE)) // .from(roleClass()) // .join(userClass(), as(userClassAlias), over(userGroupDomain())) // .where( and( // condition( attribute(roleClass(), Role.ACTIVE), // eq(true)), // condition( attribute(userClass(), userIdAttribute()), // eq(userId)))) // .run(); for (final CMQueryRow row : userGroupsRows) { final CMCard groupCard = row.getCard(groupClassAlias); groupNames.add((String) groupCard.getCode()); } return groupNames; }
protected CMCard fetchUserCard(final Login login) throws NoSuchElementException { final Alias userClassAlias = EntryTypeAlias.canonicalAlias(userClass()); final CMQueryResult queryResult = view.select(anyAttribute(userClass())) // .from(userClass(), as(userClassAlias)) // .where( and( // activeCondition(userClassAlias), // condition( attribute(userClassAlias, loginAttributeName(login)), // eq(login.getValue())))) // .run(); final CMCard userCard; if (queryResult.size() == 1) { userCard = queryResult.getOnlyRow().getCard(userClassAlias); } else { userCard = null; } return userCard; }