use of org.olat.group.BusinessGroupRef in project openolat by klemens.
the class BusinessGroupRelationDAO method getMemberKeys.
public List<Long> getMemberKeys(List<? extends BusinessGroupRef> groups, String... roles) {
if (groups == null || groups.isEmpty())
return Collections.emptyList();
StringBuilder sb = new StringBuilder();
sb.append("select membership.identity.key from businessgroup as bgroup ").append(" inner join bgroup.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" where bgroup.key in (:businessGroupKeys) and membership.role in (:roles)");
List<String> roleList = GroupRoles.toList(roles);
List<Long> groupKeys = new ArrayList<>(groups.size());
for (BusinessGroupRef group : groups) {
groupKeys.add(group.getKey());
}
List<Long> members = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Long.class).setParameter("businessGroupKeys", groupKeys).setParameter("roles", roleList).getResultList();
return members;
}
use of org.olat.group.BusinessGroupRef in project openolat by klemens.
the class AbstractBusinessGroupListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (createButton == source) {
doCreate(ureq, getWindowControl(), null);
} else if (deleteButton == source) {
confirmDelete(ureq, getSelectedItems());
} else if (duplicateButton == source) {
doCopy(ureq, getSelectedItems());
} else if (configButton == source) {
doConfiguration(ureq, getSelectedItems());
} else if (emailButton == source) {
doEmails(ureq, getSelectedItems());
} else if (usersButton == source) {
doUserManagement(ureq, getSelectedItems());
} else if (mergeButton == source) {
doMerge(ureq, getSelectedItems());
} else if (selectButton == source) {
doSelect(ureq, getSelectedItems());
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("mark".equals(cmd)) {
BusinessGroupRow row = (BusinessGroupRow) link.getUserObject();
boolean marked = toogleMark(row);
link.setIconLeftCSS(marked ? "o_icon o_icon_bookmark o_icon-lg" : "o_icon o_icon_bookmark_add o_icon-lg");
link.getComponent().setDirty(true);
} else if ("allresources".equals(cmd)) {
BusinessGroupShort bg = (BusinessGroupShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[BusinessGroup:" + bg.getKey() + "][toolresources:0]", ureq, getWindowControl());
} else if ("resource".equals(cmd)) {
RepositoryEntryShort re = (RepositoryEntryShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[RepositoryEntry:" + re.getKey() + "]", ureq, getWindowControl());
} else if (link.getUserObject() instanceof BusinessGroupRef) {
BusinessGroupRef item = (BusinessGroupRef) link.getUserObject();
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
}
}
} else if (source == tableEl) {
String cmd = event.getCommand();
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if (se.getIndex() >= 0 && se.getIndex() < groupTableModel.getRowCount()) {
BusinessGroupRef item = groupTableModel.getObject(se.getIndex());
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
// prevent rs after a group is deleted by someone else
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_DELETE.equals(cmd)) {
confirmDelete(ureq, Collections.singletonList(item));
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_EDIT.equals(cmd)) {
doEdit(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_SELECT.equals(cmd)) {
doSelect(ureq, businessGroup);
}
}
} else if (event instanceof FlexiTableSearchEvent) {
doSearch((FlexiTableSearchEvent) event);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.group.BusinessGroupRef in project openolat by klemens.
the class AbstractBusinessGroupListController method toBusinessGroups.
protected final List<BusinessGroup> toBusinessGroups(UserRequest ureq, List<? extends BusinessGroupRef> items, boolean editableOnly) {
List<Long> groupKeys = new ArrayList<Long>();
for (BusinessGroupRef item : items) {
groupKeys.add(item.getKey());
}
if (editableOnly) {
filterEditableGroupKeys(ureq, groupKeys);
}
List<BusinessGroup> groups = businessGroupService.loadBusinessGroups(groupKeys);
return groups;
}
use of org.olat.group.BusinessGroupRef in project OpenOLAT by OpenOLAT.
the class BusinessGroupRoleRuleSPI method evaluate.
@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
List<Identity> identities = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String groupKey = r.getRightOperand();
if (StringHelper.isLong(groupKey)) {
Long key = Long.parseLong(groupKey);
BusinessGroupRef groupRef = new BusinessGroupRefImpl(key);
identities = businessGroupRelationDao.getMembers(groupRef, GroupRoles.coach.name(), GroupRoles.participant.name());
}
}
return identities == null ? Collections.<Identity>emptyList() : identities;
}
use of org.olat.group.BusinessGroupRef in project OpenOLAT by OpenOLAT.
the class AbstractBusinessGroupListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (createButton == source) {
doCreate(ureq, getWindowControl(), null);
} else if (deleteButton == source) {
confirmDelete(ureq, getSelectedItems());
} else if (duplicateButton == source) {
doCopy(ureq, getSelectedItems());
} else if (configButton == source) {
doConfiguration(ureq, getSelectedItems());
} else if (emailButton == source) {
doEmails(ureq, getSelectedItems());
} else if (usersButton == source) {
doUserManagement(ureq, getSelectedItems());
} else if (mergeButton == source) {
doMerge(ureq, getSelectedItems());
} else if (selectButton == source) {
doSelect(ureq, getSelectedItems());
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("mark".equals(cmd)) {
BusinessGroupRow row = (BusinessGroupRow) link.getUserObject();
boolean marked = toogleMark(row);
link.setIconLeftCSS(marked ? "o_icon o_icon_bookmark o_icon-lg" : "o_icon o_icon_bookmark_add o_icon-lg");
link.getComponent().setDirty(true);
} else if ("allresources".equals(cmd)) {
BusinessGroupShort bg = (BusinessGroupShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[BusinessGroup:" + bg.getKey() + "][toolresources:0]", ureq, getWindowControl());
} else if ("resource".equals(cmd)) {
RepositoryEntryShort re = (RepositoryEntryShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[RepositoryEntry:" + re.getKey() + "]", ureq, getWindowControl());
} else if (link.getUserObject() instanceof BusinessGroupRef) {
BusinessGroupRef item = (BusinessGroupRef) link.getUserObject();
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
}
}
} else if (source == tableEl) {
String cmd = event.getCommand();
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if (se.getIndex() >= 0 && se.getIndex() < groupTableModel.getRowCount()) {
BusinessGroupRef item = groupTableModel.getObject(se.getIndex());
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
// prevent rs after a group is deleted by someone else
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_DELETE.equals(cmd)) {
confirmDelete(ureq, Collections.singletonList(item));
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_EDIT.equals(cmd)) {
doEdit(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_SELECT.equals(cmd)) {
doSelect(ureq, businessGroup);
}
}
} else if (event instanceof FlexiTableSearchEvent) {
doSearch((FlexiTableSearchEvent) event);
}
}
super.formInnerEvent(ureq, source, event);
}
Aggregations