use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class AbstractBusinessGroupListController method getSelectedItems.
protected List<BusinessGroupRow> getSelectedItems() {
Set<Integer> selections = tableEl.getMultiSelectedIndex();
List<BusinessGroupRow> rows = new ArrayList<>(selections.size());
for (Integer i : selections) {
BusinessGroupRow row = groupTableModel.getObject(i.intValue());
if (row != null) {
rows.add(row);
}
}
return rows;
}
use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class BusinessGroupListController method searchTableItems.
@Override
protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) {
List<BusinessGroupRow> rows = businessGroupService.findBusinessGroupsWithMemberships(params, getIdentity());
List<BGTableItem> items = new ArrayList<>(rows.size());
for (BusinessGroupRow row : rows) {
BusinessGroupMembership membership = row.getMember();
Boolean allowLeave = membership != null;
Boolean allowDelete = isAdmin() ? Boolean.TRUE : (membership == null ? null : new Boolean(membership.isOwner()));
FormLink markLink = uifactory.addFormLink("mark_" + row.getKey(), "mark", "", null, null, Link.NONTRANSLATED);
markLink.setIconLeftCSS(row.isMarked() ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
BGTableItem item = new BGTableItem(row, markLink, allowLeave, allowDelete);
items.add(item);
}
return items;
}
use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class CourseBusinessGroupListController method event.
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (event instanceof BusinessGroupSelectionEvent) {
BusinessGroupSelectionEvent selectionEvent = (BusinessGroupSelectionEvent) event;
List<BusinessGroup> selectedGroups = selectionEvent.getGroups();
cmc.deactivate();
cleanUpPopups();
addGroupsToCourse(selectedGroups);
fireEvent(ureq, Event.CHANGED_EVENT);
} else if (source == confirmRemoveResource) {
if (DialogBoxUIFactory.isYesEvent(event)) {
// yes case
BusinessGroup group = (BusinessGroup) confirmRemoveResource.getUserObject();
doRemoveBusinessGroups(Collections.singletonList(group));
fireEvent(ureq, Event.CHANGED_EVENT);
}
} else if (source == confirmRemoveMultiResource) {
if (DialogBoxUIFactory.isYesEvent(event)) {
// yes case
@SuppressWarnings("unchecked") List<BusinessGroupRow> selectedItems = (List<BusinessGroupRow>) confirmRemoveMultiResource.getUserObject();
List<BusinessGroup> groups = toBusinessGroups(ureq, selectedItems, false);
doRemoveBusinessGroups(groups);
}
}
super.event(ureq, source, event);
}
use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAO method searchBusinessGroupsForSelection.
public List<StatisticsBusinessGroupRow> searchBusinessGroupsForSelection(BusinessGroupQueryParams params, IdentityRef identity) {
StringBuilder sb = new StringBuilder();
sb.append("select bgi, ").append(" (select count(nCoaches.key) from bgroupmember as nCoaches ").append(" where nCoaches.group.key=bgi.baseGroup.key and nCoaches.role='").append(GroupRoles.coach.name()).append("'").append(" ) as numOfCoaches,").append(" (select count(nParticipants.key) from bgroupmember as nParticipants ").append(" where nParticipants.group.key=bgi.baseGroup.key and nParticipants.role='").append(GroupRoles.participant.name()).append("'").append(" ) as numOfParticipants,").append(" (select count(nWaiting.key) from bgroupmember as nWaiting ").append(" where bgi.waitingListEnabled=true and nWaiting.group.key=bgi.baseGroup.key and nWaiting.role='").append(GroupRoles.waiting.name()).append("'").append(" ) as numWaiting,").append(" (select count(reservation.key) from resourcereservation as reservation ").append(" where reservation.resource.key=bgi.resource.key").append(" ) as numOfReservations,").append(" (select count(mark.key) from ").append(MarkImpl.class.getName()).append(" as mark ").append(" where mark.creator.key=:identityKey and mark.resId=bgi.key and mark.resName='BusinessGroup'").append(" ) as marks").append(" from businessgrouptosearch as bgi").append(" inner join fetch bgi.resource as bgResource ").append(" inner join bgi.baseGroup as bGroup ");
filterBusinessGroupToSearch(sb, params, false);
TypedQuery<Object[]> objectsQuery = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class);
filterBusinessGroupToSearchParameters(objectsQuery, params, identity, true);
List<Object[]> objects = objectsQuery.getResultList();
List<StatisticsBusinessGroupRow> groups = new ArrayList<>(objects.size());
Map<Long, BusinessGroupRow> keyToGroup = new HashMap<>();
for (Object[] object : objects) {
BusinessGroupToSearch businessGroup = (BusinessGroupToSearch) object[0];
Number numOfCoaches = (Number) object[1];
Number numOfParticipants = (Number) object[2];
Number numWaiting = (Number) object[3];
Number numPending = (Number) object[4];
Number marked = (Number) object[5];
StatisticsBusinessGroupRow row = new StatisticsBusinessGroupRow(businessGroup, numOfCoaches, numOfParticipants, numWaiting, numPending);
groups.add(row);
row.setMarked(marked == null ? false : marked.longValue() > 0);
keyToGroup.put(businessGroup.getKey(), row);
}
loadRelations(keyToGroup, params, identity);
return groups;
}
use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAO method loadMemberships.
private void loadMemberships(IdentityRef identity, Map<Long, ? extends BusinessGroupRow> keyToGroup) {
// memberships
StringBuilder sm = new StringBuilder();
sm.append("select membership, bgi.key").append(" from businessgroup as bgi ").append(" inner join bgi.baseGroup as bGroup ").append(" inner join bGroup.members as membership").append(" where membership.identity.key=:identityKey");
List<Object[]> memberships = dbInstance.getCurrentEntityManager().createQuery(sm.toString(), Object[].class).setParameter("identityKey", identity.getKey()).getResultList();
for (Object[] membership : memberships) {
Long groupkey = (Long) membership[1];
BusinessGroupRow row = keyToGroup.get(groupkey);
addMembershipToRow(row, (GroupMembershipImpl) membership[0]);
}
}
Aggregations