Skip to content
Snippets Groups Projects
Commit 296e1215 authored by srosse's avatar srosse
Browse files

OO-291: implements remove of course members

parent f8b0727b
No related branches found
No related tags found
No related merge requests found
Showing
with 757 additions and 105 deletions
......@@ -194,6 +194,14 @@ public interface BaseSecurity {
*/
public Identity loadIdentityByKey(Long identityKey);
/**
* Load a list of identities by their keys.
*
* @param identityKeys
* @return A list of identities
*/
public List<Identity> loadIdentityByKeys(Collection<Long> identityKeys);
public IdentityShort loadIdentityShortByKey(Long identityKey);
/**
......@@ -312,7 +320,15 @@ public interface BaseSecurity {
* @param identity
* @param secGroup
*/
public void removeIdentityFromSecurityGroup(Identity identity, SecurityGroup secGroup);
public boolean removeIdentityFromSecurityGroup(Identity identity, SecurityGroup secGroup);
/**
* Remove an Identity
* @param identity
* @param secGroups
* @return
*/
public boolean removeIdentityFromSecurityGroups(List<Identity> identities, List<SecurityGroup> secGroups);
// --- Policy management
// again no pure RAM creation, since all attributes are mandatory and given by
......
......@@ -552,11 +552,31 @@ public class BaseSecurityManager extends BasicManager implements BaseSecurity {
/**
* @see org.olat.basesecurity.Manager#removeIdentityFromSecurityGroup(org.olat.core.id.Identity, org.olat.basesecurity.SecurityGroup)
*/
public void removeIdentityFromSecurityGroup(Identity identity, SecurityGroup secGroup) {
IdentityImpl iimpl = getImpl(identity);
DBFactory.getInstance().delete(
"from org.olat.basesecurity.SecurityGroupMembershipImpl as msi where msi.identity.key = ? and msi.securityGroup.key = ?",
new Object[] { iimpl.getKey(), secGroup.getKey() }, new Type[] { StandardBasicTypes.LONG, StandardBasicTypes.LONG });
@Override
public boolean removeIdentityFromSecurityGroup(Identity identity, SecurityGroup secGroup) {
return removeIdentityFromSecurityGroups(Collections.singletonList(identity), Collections.singletonList(secGroup));
}
@Override
public boolean removeIdentityFromSecurityGroups(List<Identity> identities, List<SecurityGroup> secGroups) {
StringBuilder sb = new StringBuilder();
sb.append("delete from ").append(SecurityGroupMembershipImpl.class.getName()).append(" as msi ")
.append(" where msi.identity.key in (:identityKeys) and msi.securityGroup.key in (:secGroupKeys)");
List<Long> identityKeys = new ArrayList<Long>();
for(Identity identity:identities) {
identityKeys.add(identity.getKey());
}
List<Long> secGroupKeys = new ArrayList<Long>();
for(SecurityGroup secGroup:secGroups) {
secGroupKeys.add(secGroup.getKey());
}
int rowsAffected = DBFactory.getInstance().getCurrentEntityManager()
.createQuery(sb.toString())
.setParameter("identityKeys", identityKeys)
.setParameter("secGroupKeys", secGroupKeys)
.executeUpdate();
return rowsAffected > 0;
}
/**
......@@ -1111,7 +1131,21 @@ public class BaseSecurityManager extends BasicManager implements BaseSecurity {
if(identityKey.equals(Long.valueOf(0))) return null;
return (Identity) DBFactory.getInstance().loadObject(IdentityImpl.class, identityKey);
}
@Override
public List<Identity> loadIdentityByKeys(Collection<Long> identityKeys) {
if (identityKeys == null || identityKeys.isEmpty()) {
return Collections.emptyList();
}
StringBuilder sb = new StringBuilder();
sb.append("select ident from ").append(Identity.class.getName()).append(" as ident where ident.key in (:keys)");
return DBFactory.getInstance().getCurrentEntityManager()
.createQuery(sb.toString(), Identity.class)
.setParameter("keys", identityKeys)
.getResultList();
}
/**
* @see org.olat.basesecurity.Manager#loadIdentityByKey(java.lang.Long,boolean)
*/
......
......@@ -20,6 +20,7 @@
package org.olat.course.member;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
......@@ -37,12 +38,19 @@ import org.olat.core.gui.components.table.CustomCellRenderer;
import org.olat.core.gui.components.table.CustomRenderColumnDescriptor;
import org.olat.core.gui.components.table.DefaultColumnDescriptor;
import org.olat.core.gui.components.table.StaticColumnDescriptor;
import org.olat.core.gui.components.table.Table;
import org.olat.core.gui.components.table.TableController;
import org.olat.core.gui.components.table.TableEvent;
import org.olat.core.gui.components.table.TableGuiConfiguration;
import org.olat.core.gui.components.table.TableMultiSelectEvent;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.gui.control.generic.modal.DialogBoxController;
import org.olat.core.gui.control.generic.modal.DialogBoxUIFactory;
import org.olat.core.id.Identity;
import org.olat.course.member.MemberListTableModel.Cols;
import org.olat.group.BusinessGroup;
import org.olat.group.BusinessGroupMembership;
......@@ -51,6 +59,7 @@ import org.olat.group.BusinessGroupShort;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager;
import org.olat.repository.model.RepositoryEntryMembership;
import org.olat.user.UserManager;
/**
*
......@@ -65,6 +74,9 @@ public abstract class AbstractMemberListController extends BasicController {
protected final TableController memberListCtr;
protected final VelocityContainer mainVC;
private DialogBoxController leaveDialogBox;
private final UserManager userManager;
private final RepositoryEntry repoEntry;
private final BaseSecurity securityManager;
private final RepositoryManager repositoryManager;
......@@ -74,6 +86,7 @@ public abstract class AbstractMemberListController extends BasicController {
super(ureq, wControl);
this.repoEntry = repoEntry;
userManager = CoreSpringFactory.getImpl(UserManager.class);
securityManager = CoreSpringFactory.getImpl(BaseSecurity.class);
repositoryManager = CoreSpringFactory.getImpl(RepositoryManager.class);
businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class);
......@@ -100,11 +113,6 @@ public abstract class AbstractMemberListController extends BasicController {
//
}
@Override
protected void event(UserRequest ureq, Component source, Event event) {
//
}
protected int initColumns() {
memberListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.lastName.i18n(), Cols.lastName.ordinal(), null, getLocale()));
memberListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.firstName.i18n(), Cols.firstName.ordinal(), null, getLocale()));
......@@ -114,11 +122,71 @@ public abstract class AbstractMemberListController extends BasicController {
memberListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.role.i18n(), Cols.role.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, roleRenderer));
CustomCellRenderer groupRenderer = new GroupCellRenderer();
memberListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.groups.i18n(), Cols.groups.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, groupRenderer));
memberListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_EDIT, "action", translate("table.header.work")));
memberListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_EDIT, "action", translate("table.header.edit")));
memberListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_REMOVE, "action", translate("table.header.remove")));
return 8;
}
@Override
protected void event(UserRequest ureq, Component source, Event event) {
//
}
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if (source == memberListCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
MemberView member = memberListModel.getObject(te.getRowId());
if(actionid.equals(TABLE_ACTION_EDIT)) {
doEdit(ureq, member);
} else if(actionid.equals(TABLE_ACTION_REMOVE)) {
confirmDelete(ureq, Collections.singletonList(member));
}
} else if (event instanceof TableMultiSelectEvent) {
TableMultiSelectEvent te = (TableMultiSelectEvent)event;
List<MemberView> selectedItems = memberListModel.getObjects(te.getSelection());
if(TABLE_ACTION_REMOVE.equals(te.getAction())) {
confirmDelete(ureq, selectedItems);
}
}
} else if (source == leaveDialogBox) {
if (event != Event.CANCELLED_EVENT && DialogBoxUIFactory.isYesEvent(event)) {
@SuppressWarnings("unchecked")
List<Identity> members = (List<Identity>)leaveDialogBox.getUserObject();
doLeave(ureq, members);
reloadModel();
}
}
}
protected void confirmDelete(UserRequest ureq, List<MemberView> members) {
List<Long> identityKeys = new ArrayList<Long>();
for(MemberView member:members) {
identityKeys.add(member.getIdentityKey());
}
List<Identity> ids = securityManager.loadIdentityByKeys(identityKeys);
StringBuilder sb = new StringBuilder();
for(Identity id:ids) {
if(sb.length() > 0) sb.append(", ");
sb.append(userManager.getUserDisplayName(id.getUser()));
}
leaveDialogBox = activateYesNoDialog(ureq, null, translate("dialog.modal.bg.leave.text", sb.toString()), leaveDialogBox);
leaveDialogBox.setUserObject(ids);
}
protected void doEdit(UserRequest ureq, MemberView member) {
}
protected void doLeave(UserRequest ureq, List<Identity> members) {
repositoryManager.removeMembers(members, repoEntry);
businessGroupService.removeMembers(getIdentity(), members, repoEntry.getOlatResource());
reloadModel();
}
protected abstract SearchMembersParams getSearchParams();
protected void reloadModel() {
......@@ -138,7 +206,7 @@ public abstract class AbstractMemberListController extends BasicController {
groupKeys.add(group.getKey());
keyToGroupMap.put(group.getKey(), group);
}
List<BusinessGroupMembership> memberships =
List<BusinessGroupMembership> memberships = groups.isEmpty() ? Collections.<BusinessGroupMembership>emptyList() :
businessGroupService.getBusinessGroupMembership(groupKeys);
//get identities
......
......@@ -19,6 +19,9 @@
*/
package org.olat.course.member;
import java.util.Collections;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link;
......@@ -29,14 +32,19 @@ import org.olat.core.gui.components.table.CustomCssCellRenderer;
import org.olat.core.gui.components.table.CustomRenderColumnDescriptor;
import org.olat.core.gui.components.table.DefaultColumnDescriptor;
import org.olat.core.gui.components.table.StaticColumnDescriptor;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.generic.closablewrapper.CloseableModalController;
import org.olat.group.BusinessGroup;
import org.olat.group.model.BusinessGroupSelectionEvent;
import org.olat.group.model.SearchBusinessGroupParams;
import org.olat.group.ui.main.AbstractBusinessGroupListController;
import org.olat.group.ui.main.BGAccessControlledCellRenderer;
import org.olat.group.ui.main.BGResourcesCellRenderer;
import org.olat.group.ui.main.BusinessGroupNameCellRenderer;
import org.olat.group.ui.main.BusinessGroupTableModelWithType.Cols;
import org.olat.group.ui.main.SelectBusinessGroupController;
import org.olat.resource.OLATResource;
/**
......@@ -49,6 +57,8 @@ public class CourseBusinessGroupListController extends AbstractBusinessGroupList
private final Link createGroup;
private final Link addGroup;
private SelectBusinessGroupController selectController;
public CourseBusinessGroupListController(UserRequest ureq, WindowControl wControl, OLATResource resource) {
super(ureq, wControl, "group_list");
this.resource = resource;
......@@ -84,7 +94,7 @@ public class CourseBusinessGroupListController extends AbstractBusinessGroupList
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.waitingListCount.i18n(), Cols.waitingListCount.ordinal(), null, getLocale()));
CustomCellRenderer acRenderer = new BGAccessControlledCellRenderer();
groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.accessTypes.i18n(), Cols.accessTypes.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, acRenderer));
groupListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_LAUNCH, "action", translate("table.header.work")));
groupListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_LAUNCH, "action", translate("table.header.edit")));
groupListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_LAUNCH, "action", translate("table.header.remove")));
return 11;
}
......@@ -94,11 +104,48 @@ public class CourseBusinessGroupListController extends AbstractBusinessGroupList
if(source == createGroup) {
doCreate(ureq, getWindowControl(), resource);
} else if (source == addGroup) {
//TODO
doSelectGroups(ureq);
} else {
super.event(ureq, source, 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);
} else {
super.event(ureq, source, event);
}
}
@Override
protected void cleanUpPopups() {
super.cleanUpPopups();
removeAsListenerAndDispose(selectController);
selectController = null;
}
protected void doSelectGroups(UserRequest ureq) {
removeAsListenerAndDispose(selectController);
selectController = new SelectBusinessGroupController(ureq, getWindowControl());
listenTo(selectController);
cmc = new CloseableModalController(getWindowControl(), translate("close"), selectController.getInitialComponent(), true, translate("select.group"));
cmc.activate();
listenTo(cmc);
}
protected void addGroupsToCourse(List<BusinessGroup> groups) {
List<OLATResource> resources = Collections.singletonList(resource);
businessGroupService.addResourcesTo(groups, resources);
reloadModel();
mainVC.setDirty(true);
}
@Override
protected void reloadModel() {
......
#if($r.available("createGroup"))
$r.render("createGroup")
#end
#if($r.available("addGroup"))
$r.render("addGroup")
#end
<div class="o_buttons_box_right">
#if($r.available("createGroup"))
$r.render("createGroup")
#end
#if($r.available("addGroup"))
$r.render("addGroup")
#end
</div>
<h4 class="b_with_small_icon_left b_group_icon">
$r.translate("menu.groups")
</h4>
......
......@@ -14,13 +14,14 @@ participants=Teilnehmer
waitinglist=Warteliste
search=Suche
action=Aktion
dialog.modal.bg.leave.text=Wollen Sie wirklich dieser Person {0} von dem Kurs und alle Gruppe entfernen?
group.create=Gruppe erstellen
group.add=Gruppe hinzufgen
role.owner=Besitzer
role.tutor=Betreuer
role.participant=Teilnehmer
role.waiting=Warteliste
table.header.work=Bearbeiten
table.header.edit=Bearbeiten
table.header.remove=Entfernen
table.header.firstName=Vorname
table.header.lastName=Name
......@@ -28,4 +29,5 @@ table.header.firstTime=Beitritt
table.header.lastTime=Zuletzt besucht
table.header.role=Rolle
table.header.groups=Gruppe
nomembers=Es wurden keine Mitglieder gefunden die Ihren Kriterien entsprechen.
select.group=Gruppe whlen
nomembers=Es wurden keine Mitglieder gefunden die Ihren Kriterien entsprechen.
\ No newline at end of file
......@@ -20,7 +20,7 @@ role.owner=Propri
role.tutor=Coach
role.participant=Participant
role.waiting=En attente
table.header.work=Work
table.header.edit=Edit
table.header.remove=Remove
table.header.firstName=First name
table.header.lastName=Last name
......@@ -28,4 +28,5 @@ table.header.firstTime=Joining
table.header.lastTime=Last visit
table.header.role=Roles
table.header.groups=Groups
select.group=Select groups
nomembers=There are no members matching your criteria.
\ No newline at end of file
......@@ -16,7 +16,11 @@ search=Recherche
action=Action
group.create=Cr\u00E9er un groupe
group.add=Ajouter un groupe
table.header.work=Editer
role.owner=Propri\u00E9taire
role.tutor=Coach
role.participant=Participant
role.waiting=En attente
table.header.edit=Editer
table.header.remove=Enlever
table.header.firstName=Pr\u00E9nom
table.header.lastName=Nom
......@@ -24,4 +28,5 @@ table.header.firstTime=Admission
table.header.lastTime=Derni\u00E8re visite
table.header.role=R\u00D4les
table.header.groups=Groupes
select.group=S\u00E9lectionner des groupes
nomembers.nogroup=Aucun membre correspondant \u00E0 vos crit\u00E8res n'a \u00E9t\u00E9 trouv\u00E9.
\ No newline at end of file
......@@ -240,9 +240,23 @@ public interface BusinessGroupService {
public int countBusinessGroupViews(SearchBusinessGroupParams params, OLATResource resource);
/**
* Find business groups (the view)
* @param params
* @param resource
* @param firstResult
* @param maxResults
* @param ordering
* @return
*/
public List<BusinessGroupView> findBusinessGroupViews(SearchBusinessGroupParams params, OLATResource resource, int firstResult, int maxResults, BusinessGroupOrder... ordering);
/**
* Find all groups within resources where the identity is author.
* @param author
* @return
*/
public List<BusinessGroupView> findBusinessGroupViewsWithAuthorConnection(Identity author);
public List<Long> toGroupKeys(String groupNames, OLATResource resource);
......@@ -349,6 +363,16 @@ public interface BusinessGroupService {
* @param flags
*/
public void removeParticipants(Identity ureqIdentity, List<Identity> identities, BusinessGroup group);
/**
* Remove the members (tutors and participants) from all business groups connected
* to the resource.
*
* @param ureqIdentity
* @param identities
* @param group
*/
public void removeMembers(Identity ureqIdentity, List<Identity> identities, OLATResource resource);
/**
* Adds a user to a waiting-list of a group and does all the magic that needs to
......
......@@ -101,6 +101,10 @@ public class GroupLoggingAction extends BaseLoggingAction {
public static final ILoggingAction GROUP_FROM_WAITING_LIST_REMOVED =
new GroupLoggingAction(ActionType.tracking, CrudAction.delete, ActionVerb.remove, ActionObject.waitingperson).setTypeList(GROUP_ACTION_RESOURCEABLE_TYPE_LIST);
/** activity identitfyer: group participant has been removed from group * */
public static final ILoggingAction GROUP_MEMBER_REMOVED =
new GroupLoggingAction(ActionType.tracking, CrudAction.delete, ActionVerb.remove, ActionObject.participant).setTypeList(GROUP_ACTION_RESOURCEABLE_TYPE_LIST);
/** activity identitfyer: group configuration has been changed * */
public static final ILoggingAction GROUP_CONFIGURATION_CHANGED =
......
......@@ -51,8 +51,10 @@ import org.olat.group.model.BGRepositoryEntryRelation;
import org.olat.group.model.BGResourceRelation;
import org.olat.group.model.BusinessGroupMembershipViewImpl;
import org.olat.group.model.BusinessGroupShortImpl;
import org.olat.group.model.BusinessGroupViewImpl;
import org.olat.group.model.SearchBusinessGroupParams;
import org.olat.properties.Property;
import org.olat.repository.model.RepositoryEntryMembership;
import org.olat.resource.OLATResource;
import org.olat.resource.OLATResourceManager;
import org.olat.resource.accesscontrol.model.OfferImpl;
......@@ -235,8 +237,17 @@ public class BusinessGroupDAO {
Number res = query.getSingleResult();
return res.intValue();
}
public List<BusinessGroupMembershipViewImpl> getMembershipInfoInBusinessGroups(Collection<BusinessGroup> groups, List<Identity> identities) {
List<Long> groupKeys = new ArrayList<Long>();
for(BusinessGroup group:groups) {
groupKeys.add(group.getKey());
}
Identity[] identityArr = identities.toArray(new Identity[identities.size()]);
return getMembershipInfoInBusinessGroups(groupKeys, identityArr);
}
public List<BusinessGroupMembershipViewImpl> getMembershipInfoInBusinessGroups(Collection<Long> groupKeys, Identity... identity) {
public List<BusinessGroupMembershipViewImpl> getMembershipInfoInBusinessGroups(Collection<Long> groupKeys, Identity... identity) {
StringBuilder sb = new StringBuilder();
sb.append("select membership from ").append(BusinessGroupMembershipViewImpl.class.getName()).append(" as membership ");
boolean and = false;
......@@ -616,6 +627,24 @@ public class BusinessGroupDAO {
}
return dbq;
}
public List<BusinessGroupView> findBusinessGroupWithAuthorConnection(Identity author) {
StringBuilder sb = new StringBuilder();
sb.append("select bgi from ").append(BusinessGroupViewImpl.class.getName()).append(" as bgi ")
.append("where bgi.key in (")
.append(" select rel.group.key from ").append(BGResourceRelation.class.getName()).append(" as rel ")
.append(" where rel.resource.key in (")
.append(" select membership.ownerResourceKey from ").append(RepositoryEntryMembership.class.getName()).append(" as membership")
.append(" where membership.identityKey=:authorKey and membership.ownerRepoKey is not null")
.append(" )")
.append(")");
List<BusinessGroupView> groups = dbInstance.getCurrentEntityManager()
.createQuery(sb.toString(), BusinessGroupView.class)
.setParameter("authorKey", author.getKey())
.getResultList();
return groups;
}
public int countBusinessGroupViews(SearchBusinessGroupParams params, OLATResource resource) {
TypedQuery<Number> query = createFindViewDBQuery(params, resource, Number.class)
......@@ -643,7 +672,7 @@ public class BusinessGroupDAO {
} else {
query.append("select count(bgi.key) from ");
}
query.append(BusinessGroupView.class.getName()).append(" as bgi ");
query.append(BusinessGroupViewImpl.class.getName()).append(" as bgi ");
if(StringHelper.containsNonWhitespace(params.getOwnerName())) {
//implicit joins
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.group.manager;
import java.util.Comparator;
import org.olat.group.model.BusinessGroupMembershipViewImpl;
/**
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class BusinessGroupMembershipViewComparator implements Comparator<BusinessGroupMembershipViewImpl> {
@Override
public int compare(BusinessGroupMembershipViewImpl o1, BusinessGroupMembershipViewImpl o2) {
Long g1 = o1.getGroupKey();
Long g2 = o2.getGroupKey();
return (g1.longValue() < g2.longValue() ? -1 : (g1.longValue()==g2.longValue() ? 0 : 1)) ;
}
}
......@@ -598,8 +598,8 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD
return businessGroupDAO.findBusinessGroups(params, resource, firstResult, maxResults);
}
@Override
@Transactional(readOnly=true)
public int countBusinessGroupViews(SearchBusinessGroupParams params, OLATResource resource) {
if(params == null) {
params = new SearchBusinessGroupParams();
......@@ -608,6 +608,7 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD
}
@Override
@Transactional(readOnly=true)
public List<BusinessGroupView> findBusinessGroupViews(SearchBusinessGroupParams params, OLATResource resource, int firstResult,
int maxResults, BusinessGroupOrder... ordering) {
if(params == null) {
......@@ -616,6 +617,12 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD
return businessGroupDAO.findBusinessGroupViews(params, resource, firstResult, maxResults);
}
@Override
@Transactional(readOnly=true)
public List<BusinessGroupView> findBusinessGroupViewsWithAuthorConnection(Identity author) {
return businessGroupDAO.findBusinessGroupWithAuthorConnection(author);
}
@Override
@Transactional(readOnly=true)
public List<Long> toGroupKeys(String groupNames, OLATResource resource) {
......@@ -662,7 +669,7 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD
// 1.b)delete display member property
businessGroupPropertyManager.deleteDisplayMembers(group);
// 1.c)delete user in security groups
removeFromRepositoryEntrySecurityGroup(group);
//removeFromRepositoryEntrySecurityGroup(group);
// 2) Delete the group areas
areaManager.deleteBGtoAreaRelations(group);
// 3) Delete the group object itself on the database
......@@ -744,44 +751,6 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD
}
return null;
}
private void removeFromRepositoryEntrySecurityGroup(BusinessGroup group) {
//TODO
/*
BGContext context = group.getGroupContext();
if(context == null) return;//nothing to do
BGContextManager contextManager = BGContextManagerImpl.getInstance();
List<Identity> coaches = group.getOwnerGroup() == null ? Collections.<Identity>emptyList() :
securityManager.getIdentitiesOfSecurityGroup(group.getOwnerGroup());
List<Identity> participants = group.getPartipiciantGroup() == null ? Collections.<Identity>emptyList() :
securityManager.getIdentitiesOfSecurityGroup(group.getPartipiciantGroup());
List<RepositoryEntry> entries = contextManager.findRepositoryEntriesForBGContext(context);
for(Identity coach:coaches) {
List<BusinessGroup> businessGroups = contextManager.getBusinessGroupAsOwnerOfBGContext(coach, context) ;
if(context.isDefaultContext() && businessGroups.size() == 1) {
for(RepositoryEntry entry:entries) {
if(entry.getTutorGroup() != null && securityManager.isIdentityInSecurityGroup(coach, entry.getTutorGroup())) {
securityManager.removeIdentityFromSecurityGroup(coach, entry.getTutorGroup());
}
}
}
}
for(Identity participant:participants) {
List<BusinessGroup> businessGroups = contextManager.getBusinessGroupAsParticipantOfBGContext(participant, context) ;
if(context.isDefaultContext() && businessGroups.size() == 1) {
for(RepositoryEntry entry:entries) {
if(entry.getParticipantGroup() != null && securityManager.isIdentityInSecurityGroup(participant, entry.getParticipantGroup())) {
securityManager.removeIdentityFromSecurityGroup(participant, entry.getParticipantGroup());
}
}
}
}
*/
}
@Override
public int countMembersOf(OLATResource resource, boolean owner, boolean attendee) {
......@@ -905,6 +874,80 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD
});
}
@Override
public void removeMembers(final Identity ureqIdentity, final List<Identity> identities, OLATResource resource) {
if(identities == null || identities.isEmpty() || resource == null) return;//nothing to do
List<BusinessGroup> groups = findBusinessGroups(null, resource, 0, -1);
if(groups.isEmpty()) return;//nothing to do
Map<Long,BusinessGroup> keyToGroupMap = new HashMap<Long,BusinessGroup>();
for(BusinessGroup group:groups) {
keyToGroupMap.put(group.getKey(), group);
}
final Map<Long,Identity> keyToIdentityMap = new HashMap<Long,Identity>();
for(Identity identity:identities) {
keyToIdentityMap.put(identity.getKey(), identity);
}
List<BusinessGroupMembershipViewImpl> memberships = businessGroupDAO.getMembershipInfoInBusinessGroups(groups, identities);
Collections.sort(memberships, new BusinessGroupMembershipViewComparator());
BusinessGroupMembershipViewImpl nextGroupMembership = null;
for(final Iterator<BusinessGroupMembershipViewImpl> itMembership=memberships.iterator(); nextGroupMembership != null || itMembership.hasNext(); ) {
final BusinessGroupMembershipViewImpl currentMembership;
if(nextGroupMembership == null) {
currentMembership = itMembership.next();
} else {
currentMembership = nextGroupMembership;
nextGroupMembership = null;
}
Long groupKey = currentMembership.getGroupKey();
BusinessGroup nextGroup = keyToGroupMap.get(groupKey);
final BusinessGroup currentGroup = nextGroup;
nextGroupMembership = CoordinatorManager.getInstance().getCoordinator().getSyncer()
.doInSync(currentGroup, new SyncerCallback<BusinessGroupMembershipViewImpl>(){
public BusinessGroupMembershipViewImpl execute() {
BusinessGroupMembershipViewImpl previsousComputedMembership = currentMembership;
BusinessGroupMembershipViewImpl membership;
do {
if(previsousComputedMembership != null) {
membership = previsousComputedMembership;
previsousComputedMembership = null;
} else if(itMembership.hasNext()) {
membership = itMembership.next();
} else {
//security, nothing to do
return null;
}
if(currentGroup.getKey().equals(membership.getGroupKey())) {
Identity id = keyToIdentityMap.get(membership.getIdentityKey());
if(membership.getOwnerGroupKey() != null) {
removeOwner(ureqIdentity, id, currentGroup);
}
if(membership.getParticipantGroupKey() != null) {
removeParticipant(ureqIdentity, id, currentGroup);
}
if(membership.getWaitingGroupKey() != null) {
removeFromWaitingList(ureqIdentity, id, currentGroup);
}
} else {
return membership;
}
} while (itMembership.hasNext());
return null;
}
});
}
}
@Override
public void addToWaitingList(Identity ureqIdentity, Identity identity, BusinessGroup group) {
CoordinatorManager.getInstance().getCoordinator().getSyncer().assertAlreadyDoInSyncFor(group);
......@@ -1183,26 +1226,29 @@ public class BusinessGroupServiceImpl implements BusinessGroupService, UserDataD
return tools.isToolEnabled(CollaborationTools.TOOL_CHAT);
}
public void removeOwner(Identity ureqIdentity, Identity identityToRemove, BusinessGroup group) {
securityManager.removeIdentityFromSecurityGroup(identityToRemove, group.getOwnerGroup());
// remove user from buddies rosters
removeFromRoster(identityToRemove, group);
//remove subsciptions if user gets removed
removeSubscriptions(identityToRemove, group);
// notify currently active users of this business group
if (identityToRemove.getKey().equals(ureqIdentity.getKey()) ) {
BusinessGroupModifiedEvent.fireModifiedGroupEvents(BusinessGroupModifiedEvent.MYSELF_ASOWNER_REMOVED_EVENT, group, identityToRemove);
} else {
BusinessGroupModifiedEvent.fireModifiedGroupEvents(BusinessGroupModifiedEvent.IDENTITY_REMOVED_EVENT, group, identityToRemove);
}
// do logging
ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_OWNER_REMOVED, getClass(), LoggingResourceable.wrap(group), LoggingResourceable.wrap(identityToRemove));
}
@Override
public void removeOwners(Identity ureqIdentity, Collection<Identity> identitiesToRemove, BusinessGroup group) {
//fxdiff VCRP-2: access control
for(Identity identity:identitiesToRemove) {
securityManager.removeIdentityFromSecurityGroup(identity, group.getOwnerGroup());
// remove user from buddies rosters
removeFromRoster(identity, group);
//remove subsciptions if user gets removed
removeSubscriptions(identity, group);
// notify currently active users of this business group
if (identity.getKey().equals(ureqIdentity.getKey()) ) {
BusinessGroupModifiedEvent.fireModifiedGroupEvents(BusinessGroupModifiedEvent.MYSELF_ASOWNER_REMOVED_EVENT, group, identity);
} else {
BusinessGroupModifiedEvent.fireModifiedGroupEvents(BusinessGroupModifiedEvent.IDENTITY_REMOVED_EVENT, group, identity);
}
// do logging
ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_OWNER_REMOVED, getClass(), LoggingResourceable.wrap(group), LoggingResourceable.wrap(identity));
// send notification mail in your controller!
for(Identity identityToRemove:identitiesToRemove) {
removeOwner(ureqIdentity, identityToRemove, group);
}
}
......
......@@ -52,6 +52,16 @@ public class BusinessGroupMembershipViewImpl extends PersistentObject {
public void setLastModified(Date lastModified) {
this.lastModified = lastModified;
}
public Long getGroupKey() {
if(participantGroupKey != null) {
return participantGroupKey;
}
if(ownerGroupKey != null) {
return ownerGroupKey;
}
return waitingGroupKey;
}
public Long getOwnerGroupKey() {
return ownerGroupKey;
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.group.model;
import java.util.List;
import org.olat.core.gui.control.Event;
import org.olat.group.BusinessGroup;
/**
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class BusinessGroupSelectionEvent extends Event {
private static final long serialVersionUID = 5213464644816221323L;
private final List<BusinessGroup> groups;
public BusinessGroupSelectionEvent(List<BusinessGroup> groups) {
super("bgselect");
this.groups = groups;
}
public List<BusinessGroup> getGroups() {
return groups;
}
}
......@@ -75,6 +75,7 @@ import org.olat.group.BusinessGroupView;
import org.olat.group.GroupLoggingAction;
import org.olat.group.area.BGAreaManager;
import org.olat.group.model.BGRepositoryEntryRelation;
import org.olat.group.model.BusinessGroupSelectionEvent;
import org.olat.group.model.MembershipModification;
import org.olat.group.model.SearchBusinessGroupParams;
import org.olat.group.right.BGRightManager;
......@@ -108,6 +109,7 @@ public abstract class AbstractBusinessGroupListController extends BasicControlle
protected static final String TABLE_ACTION_CONFIG = "bgTblConfig";
protected static final String TABLE_ACTION_EMAIL = "bgTblEmail";
protected static final String TABLE_ACTION_DELETE = "bgTblDelete";
protected static final String TABLE_ACTION_SELECT = "bgTblSelect";
protected final VelocityContainer mainVC;
......@@ -124,7 +126,7 @@ public abstract class AbstractBusinessGroupListController extends BasicControlle
private MailNotificationEditController userManagementSendMailController;
private BusinessGroupDeleteDialogBoxController deleteDialogBox;
private StepsMainRunController businessGroupWizard;
private CloseableModalController cmc;
protected CloseableModalController cmc;
private final boolean admin;
protected final MarkManager markManager;
......@@ -262,6 +264,8 @@ public abstract class AbstractBusinessGroupListController extends BasicControlle
leaveDialogBox.setUserObject(businessGroup);
} else if (actionid.equals(TABLE_ACTION_ACCESS)) {
doAccess(ureq, businessGroup);
} else if (actionid.equals(TABLE_ACTION_SELECT)) {
doSelect(ureq, businessGroup);
}
} else if (event instanceof TableMultiSelectEvent) {
TableMultiSelectEvent te = (TableMultiSelectEvent)event;
......@@ -278,6 +282,8 @@ public abstract class AbstractBusinessGroupListController extends BasicControlle
doUserManagement(ureq, selectedItems);
} else if(TABLE_ACTION_MERGE.equals(te.getAction())) {
doMerge(ureq, selectedItems);
} else if(TABLE_ACTION_SELECT.equals(te.getAction())) {
doSelect(ureq, selectedItems);
}
}
} else if (source == deleteDialogBox) {
......@@ -347,7 +353,7 @@ public abstract class AbstractBusinessGroupListController extends BasicControlle
/**
* Aggressive clean up all popup controllers
*/
private void cleanUpPopups() {
protected void cleanUpPopups() {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(deleteDialogBox);
removeAsListenerAndDispose(groupCreateController);
......@@ -604,6 +610,16 @@ public abstract class AbstractBusinessGroupListController extends BasicControlle
//TODO send mails
}
private void doSelect(UserRequest ureq, List<BGTableItem> items) {
List<BusinessGroup> selection = toBusinessGroups(ureq, items, false);
fireEvent(ureq, new BusinessGroupSelectionEvent(selection));
}
private void doSelect(UserRequest ureq, BusinessGroup group) {
List<BusinessGroup> selection = Collections.singletonList(group);
fireEvent(ureq, new BusinessGroupSelectionEvent(selection));
}
/**
*
* @param ureq
......@@ -709,13 +725,18 @@ public abstract class AbstractBusinessGroupListController extends BasicControlle
return null;
}
protected List<BusinessGroupView> updateTableModel(SearchBusinessGroupParams params, boolean alreadyMarked) {
protected List<BusinessGroupView> searchBusinessGroupViews(SearchBusinessGroupParams params) {
List<BusinessGroupView> groups;
if(params == null) {
groups = new ArrayList<BusinessGroupView>();
} else {
groups = businessGroupService.findBusinessGroupViews(params, getResource(), 0, -1);
}
return groups;
}
protected List<BusinessGroupView> updateTableModel(SearchBusinessGroupParams params, boolean alreadyMarked) {
List<BusinessGroupView> groups = searchBusinessGroupViews(params);
lastSearchParams = params;
if(groups.isEmpty()) {
groupListModel.setEntries(Collections.<BGTableItem>emptyList());
......
......@@ -4,14 +4,15 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.link.Link;
import org.olat.core.gui.components.link.LinkFactory;
import org.olat.core.gui.components.panel.Panel;
import org.olat.core.gui.components.segmentedview.SegmentViewComponent;
import org.olat.core.gui.components.segmentedview.SegmentViewEvent;
import org.olat.core.gui.components.segmentedview.SegmentViewFactory;
import org.olat.core.gui.components.velocity.VelocityContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.group.model.BusinessGroupSelectionEvent;
/**
*
......@@ -25,9 +26,10 @@ public class SelectBusinessGroupController extends BasicController {
private final SegmentViewComponent segmentView;
private final VelocityContainer mainVC;
private FavoritBusinessGroupListController favoritGroupsCtrl;
private OwnedBusinessGroupListController ownedGroupsCtrl;
private SearchBusinessGroupListController searchGroupsCtrl;
private SelectFavoritBusinessGroupController favoritGroupsCtrl;
private SelectOwnedBusinessGroupController ownedGroupsCtrl;
private SelectBusinessGroupCourseAuthorController authorGroupsCtrL;
private SelectSearchBusinessGroupController searchGroupsCtrl;
public SelectBusinessGroupController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl);
......@@ -43,10 +45,10 @@ public class SelectBusinessGroupController extends BasicController {
segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this);
markedGroupsLink = LinkFactory.createLink("marked.groups", mainVC, this);
segmentView.addSegment(markedGroupsLink, marked);
ownedGroupsLink = LinkFactory.createLink("course.groups", mainVC, this);
segmentView.addSegment(ownedGroupsLink, false);
courseGroupsLink = LinkFactory.createLink("opengroups.all", mainVC, this);
segmentView.addSegment(courseGroupsLink, !marked);
courseGroupsLink = LinkFactory.createLink("course.groups", mainVC, this);
segmentView.addSegment(courseGroupsLink, false);
ownedGroupsLink = LinkFactory.createLink("owned.groups.2", mainVC, this);
segmentView.addSegment(ownedGroupsLink, !marked);
searchOpenLink = LinkFactory.createLink("opengroups.search", mainVC, this);
segmentView.addSegment(searchOpenLink, false);
......@@ -78,9 +80,18 @@ public class SelectBusinessGroupController extends BasicController {
}
}
private FavoritBusinessGroupListController updateMarkedGroups(UserRequest ureq) {
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
if(event instanceof BusinessGroupSelectionEvent) {
fireEvent(ureq, event);
} else {
super.event(ureq, source, event);
}
}
private SelectFavoritBusinessGroupController updateMarkedGroups(UserRequest ureq) {
if(favoritGroupsCtrl == null) {
favoritGroupsCtrl = new FavoritBusinessGroupListController(ureq, getWindowControl());
favoritGroupsCtrl = new SelectFavoritBusinessGroupController(ureq, getWindowControl());
listenTo(favoritGroupsCtrl);
}
favoritGroupsCtrl.updateMarkedGroups();
......@@ -88,9 +99,9 @@ public class SelectBusinessGroupController extends BasicController {
return favoritGroupsCtrl;
}
private OwnedBusinessGroupListController updateOwnedGroups(UserRequest ureq) {
private SelectOwnedBusinessGroupController updateOwnedGroups(UserRequest ureq) {
if(ownedGroupsCtrl == null) {
ownedGroupsCtrl = new OwnedBusinessGroupListController(ureq, getWindowControl());
ownedGroupsCtrl = new SelectOwnedBusinessGroupController(ureq, getWindowControl());
listenTo(ownedGroupsCtrl);
}
ownedGroupsCtrl.updateOwnedGroups();
......@@ -98,13 +109,19 @@ public class SelectBusinessGroupController extends BasicController {
return ownedGroupsCtrl;
}
private void updateCourseGroups(UserRequest ureq) {
mainVC.put("groupList", new Panel("empty"));
private SelectBusinessGroupCourseAuthorController updateCourseGroups(UserRequest ureq) {
if(authorGroupsCtrL == null) {
authorGroupsCtrL = new SelectBusinessGroupCourseAuthorController(ureq, getWindowControl());
listenTo(authorGroupsCtrL);
}
authorGroupsCtrL.updateOwnedGroups();
mainVC.put("groupList", authorGroupsCtrL.getInitialComponent());
return authorGroupsCtrL;
}
private SearchBusinessGroupListController updateSearch(UserRequest ureq) {
private SelectSearchBusinessGroupController updateSearch(UserRequest ureq) {
if(searchGroupsCtrl == null) {
searchGroupsCtrl = new SearchBusinessGroupListController(ureq, getWindowControl());
searchGroupsCtrl = new SelectSearchBusinessGroupController(ureq, getWindowControl());
listenTo(searchGroupsCtrl);
}
searchGroupsCtrl.updateSearch(ureq);
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.group.ui.main;
import java.util.List;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.table.ColumnDescriptor;
import org.olat.core.gui.components.table.CustomCellRenderer;
import org.olat.core.gui.components.table.CustomCssCellRenderer;
import org.olat.core.gui.components.table.CustomRenderColumnDescriptor;
import org.olat.core.gui.components.table.DefaultColumnDescriptor;
import org.olat.core.gui.components.table.StaticColumnDescriptor;
import org.olat.core.gui.control.WindowControl;
import org.olat.group.BusinessGroupView;
import org.olat.group.model.SearchBusinessGroupParams;
import org.olat.group.ui.main.BusinessGroupTableModelWithType.Cols;
/**
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class SelectBusinessGroupCourseAuthorController extends AbstractBusinessGroupListController {
public SelectBusinessGroupCourseAuthorController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, "select_group_list");
}
@Override
protected boolean canCreateBusinessGroup(UserRequest ureq) {
return false;
}
@Override
protected void initButtons(UserRequest ureq) {
groupListCtr.setMultiSelect(true);
groupListCtr.addMultiSelectAction("select", TABLE_ACTION_SELECT);
}
@Override
protected int initColumns() {
CustomCellRenderer markRenderer = new BGMarkCellRenderer(this, mainVC, getTranslator());
groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.mark.i18n(), Cols.resources.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, markRenderer));
CustomCssCellRenderer nameRenderer = new BusinessGroupNameCellRenderer();
groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.name.i18n(), Cols.name.ordinal(), TABLE_ACTION_LAUNCH, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, nameRenderer));
groupListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor(Cols.key.i18n(), Cols.key.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor(Cols.description.i18n(), Cols.description.ordinal(), null, getLocale()));
CustomCellRenderer resourcesRenderer = new BGResourcesCellRenderer(this, mainVC, getTranslator());
groupListCtr.addColumnDescriptor( new CustomRenderColumnDescriptor(Cols.resources.i18n(), Cols.resources.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, resourcesRenderer));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.tutorsCount.i18n(), Cols.tutorsCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.participantsCount.i18n(), Cols.participantsCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.freePlaces.i18n(), Cols.freePlaces.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.waitingListCount.i18n(), Cols.waitingListCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_SELECT, "action", translate("select")));
return 10;
}
protected void updateOwnedGroups() {
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
updateTableModel(params, true);
}
@Override
protected List<BusinessGroupView> searchBusinessGroupViews(SearchBusinessGroupParams params) {
return businessGroupService.findBusinessGroupViewsWithAuthorConnection(getIdentity());
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.group.ui.main;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.table.ColumnDescriptor;
import org.olat.core.gui.components.table.CustomCellRenderer;
import org.olat.core.gui.components.table.CustomCssCellRenderer;
import org.olat.core.gui.components.table.CustomRenderColumnDescriptor;
import org.olat.core.gui.components.table.DefaultColumnDescriptor;
import org.olat.core.gui.components.table.StaticColumnDescriptor;
import org.olat.core.gui.control.WindowControl;
import org.olat.group.model.SearchBusinessGroupParams;
import org.olat.group.ui.main.BusinessGroupTableModelWithType.Cols;
/**
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class SelectFavoritBusinessGroupController extends AbstractBusinessGroupListController {
public SelectFavoritBusinessGroupController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, "select_group_list");
}
@Override
protected boolean canCreateBusinessGroup(UserRequest ureq) {
return false;
}
@Override
protected void initButtons(UserRequest ureq) {
groupListCtr.setMultiSelect(true);
groupListCtr.addMultiSelectAction("select", TABLE_ACTION_SELECT);
}
@Override
protected int initColumns() {
CustomCssCellRenderer nameRenderer = new BusinessGroupNameCellRenderer();
groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.name.i18n(), Cols.name.ordinal(), TABLE_ACTION_LAUNCH, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, nameRenderer));
groupListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor(Cols.key.i18n(), Cols.key.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor(Cols.description.i18n(), Cols.description.ordinal(), null, getLocale()));
CustomCellRenderer resourcesRenderer = new BGResourcesCellRenderer(this, mainVC, getTranslator());
groupListCtr.addColumnDescriptor( new CustomRenderColumnDescriptor(Cols.resources.i18n(), Cols.resources.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, resourcesRenderer));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.tutorsCount.i18n(), Cols.tutorsCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.participantsCount.i18n(), Cols.participantsCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.freePlaces.i18n(), Cols.freePlaces.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.waitingListCount.i18n(), Cols.waitingListCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_SELECT, "action", translate("select")));
return 9;
}
protected boolean updateMarkedGroups() {
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setMarked(Boolean.TRUE);
params.setAttendee(true);
params.setOwner(true);
params.setWaiting(true);
params.setIdentity(getIdentity());
return !updateTableModel(params, true).isEmpty();
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.group.ui.main;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.table.ColumnDescriptor;
import org.olat.core.gui.components.table.CustomCellRenderer;
import org.olat.core.gui.components.table.CustomCssCellRenderer;
import org.olat.core.gui.components.table.CustomRenderColumnDescriptor;
import org.olat.core.gui.components.table.DefaultColumnDescriptor;
import org.olat.core.gui.components.table.StaticColumnDescriptor;
import org.olat.core.gui.control.WindowControl;
import org.olat.group.model.SearchBusinessGroupParams;
import org.olat.group.ui.main.BusinessGroupTableModelWithType.Cols;
/**
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
public class SelectOwnedBusinessGroupController extends AbstractBusinessGroupListController {
public SelectOwnedBusinessGroupController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, "select_group_list");
}
@Override
protected boolean canCreateBusinessGroup(UserRequest ureq) {
return false;
}
@Override
protected void initButtons(UserRequest ureq) {
groupListCtr.setMultiSelect(true);
groupListCtr.addMultiSelectAction("select", TABLE_ACTION_SELECT);
}
@Override
protected int initColumns() {
CustomCellRenderer markRenderer = new BGMarkCellRenderer(this, mainVC, getTranslator());
groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.mark.i18n(), Cols.resources.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, markRenderer));
CustomCssCellRenderer nameRenderer = new BusinessGroupNameCellRenderer();
groupListCtr.addColumnDescriptor(new CustomRenderColumnDescriptor(Cols.name.i18n(), Cols.name.ordinal(), TABLE_ACTION_LAUNCH, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, nameRenderer));
groupListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor(Cols.key.i18n(), Cols.key.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(false, new DefaultColumnDescriptor(Cols.description.i18n(), Cols.description.ordinal(), null, getLocale()));
CustomCellRenderer resourcesRenderer = new BGResourcesCellRenderer(this, mainVC, getTranslator());
groupListCtr.addColumnDescriptor( new CustomRenderColumnDescriptor(Cols.resources.i18n(), Cols.resources.ordinal(), null, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, resourcesRenderer));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.tutorsCount.i18n(), Cols.tutorsCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.participantsCount.i18n(), Cols.participantsCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.freePlaces.i18n(), Cols.freePlaces.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new DefaultColumnDescriptor(Cols.waitingListCount.i18n(), Cols.waitingListCount.ordinal(), null, getLocale()));
groupListCtr.addColumnDescriptor(new StaticColumnDescriptor(TABLE_ACTION_SELECT, "action", translate("select")));
return 10;
}
protected void updateOwnedGroups() {
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setIdentity(getIdentity());
params.setOwner(true);
params.setAttendee(false);
params.setWaiting(false);
updateTableModel(params, true);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment