// workground for no session
@SuppressWarnings({ "rawtypes", "unchecked" })
public List<Group> getGroups(User user, GroupMember.Ship ship) {
if (isAdmin(user) && !ObjectUtils.equals(ship, GroupMember.Ship.MEMBER)) return entityDao
.getAll(Group.class);
OqlBuilder builder = OqlBuilder.from(GroupMember.class, "gm");
builder.where("gm.user=:user", user).select("gm.group");
if (null != ship) {
if (ship.equals(GroupMember.Ship.MEMBER)) builder.where("gm.member=true");
if (ship.equals(GroupMember.Ship.MANAGER)) builder.where("gm.manager=true");
if (ship.equals(GroupMember.Ship.GRANTER)) builder.where("gm.granter=true");
}
builder.cacheable();
return entityDao.search(builder);
}