tblCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.group.name", 1, TABLE_ACTION_LAUNCH, ureq.getLocale()));
tblCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.user.role", 2, null, ureq.getLocale()));
tblCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.user.joindate", 3, null, ureq.getLocale()));
//build data model
BusinessGroupManager bgm = BusinessGroupManagerImpl.getInstance();
Manager sm = ManagerFactory.getManager();
List<Object[]> userGroups = new ArrayList<Object[]>();
//loop over all kind of groups with all possible memberships
List<String> bgTypes = new ArrayList<String>();
bgTypes.add(BusinessGroup.TYPE_BUDDYGROUP);
bgTypes.add(BusinessGroup.TYPE_LEARNINGROUP);
bgTypes.add(BusinessGroup.TYPE_RIGHTGROUP);
for (String bgType : bgTypes) {
List<BusinessGroup> ownedGroups = bgm.findBusinessGroupsOwnedBy(bgType, identity, null);
List<BusinessGroup> attendedGroups = bgm.findBusinessGroupsAttendedBy(bgType, identity, null);
List<BusinessGroup> waitingGroups = bgm.findBusinessGroupsWithWaitingListAttendedBy(bgType, identity, null);
//using HashSet to remove duplicate entries
HashSet<BusinessGroup> allGroups = new HashSet<BusinessGroup>();
allGroups.addAll(ownedGroups);
allGroups.addAll(attendedGroups);
allGroups.addAll(waitingGroups);
Iterator<BusinessGroup> iter = allGroups.iterator();
while (iter.hasNext()) {
Object[] groupEntry = new Object[4];
BusinessGroup group = iter.next();
groupEntry[0] = translate(group.getType());
groupEntry[1] = group;
Date joinDate = null;
if(attendedGroups.contains(group)&&ownedGroups.contains(group)) {
groupEntry[2] = translate("attende.and.owner");
joinDate = sm.getSecurityGroupJoinDateForIdentity(group.getPartipiciantGroup(), identity);
}
else if(attendedGroups.contains(group)) {
groupEntry[2] = translate("attende");
joinDate = sm.getSecurityGroupJoinDateForIdentity(group.getPartipiciantGroup(), identity);
}
else if(ownedGroups.contains(group)) {
groupEntry[2] = translate("owner");
joinDate = sm.getSecurityGroupJoinDateForIdentity(group.getOwnerGroup(), identity);
}
else if(waitingGroups.contains(group)) {
int waitingListPosition = bgm.getPositionInWaitingListFor(identity, group);
groupEntry[2] = translate("waiting", String.valueOf(waitingListPosition));
joinDate = sm.getSecurityGroupJoinDateForIdentity(group.getWaitingGroup(), identity);
}
groupEntry[3] = joinDate;