diff --git a/src/main/java/org/olat/group/BusinessGroupManagerImpl.java b/src/main/java/org/olat/group/BusinessGroupManagerImpl.java index 5d2b860ade267c5d4172a012e7288c7792d267aa..344cbf0fd30775512d1500e2cd71071bb79b14a5 100644 --- a/src/main/java/org/olat/group/BusinessGroupManagerImpl.java +++ b/src/main/java/org/olat/group/BusinessGroupManagerImpl.java @@ -25,78 +25,10 @@ package org.olat.group; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import org.hibernate.ObjectNotFoundException; -import org.hibernate.StaleObjectStateException; -import org.olat.admin.user.delete.service.UserDeletionManager; import org.olat.basesecurity.BaseSecurity; -import org.olat.basesecurity.BaseSecurityManager; -import org.olat.basesecurity.Constants; -import org.olat.basesecurity.IdentityImpl; -import org.olat.basesecurity.SecurityGroup; -import org.olat.basesecurity.SecurityGroupMembershipImpl; -import org.olat.collaboration.CollaborationTools; -import org.olat.collaboration.CollaborationToolsFactory; -import org.olat.commons.lifecycle.LifeCycleManager; -import org.olat.core.CoreSpringFactory; -import org.olat.core.commons.persistence.DB; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.commons.persistence.DBQuery; -import org.olat.core.commons.taskExecutor.TaskExecutorManager; -import org.olat.core.gui.UserRequest; -import org.olat.core.gui.control.WindowControl; -import org.olat.core.gui.translator.Translator; -import org.olat.core.id.Identity; -import org.olat.core.logging.DBRuntimeException; -import org.olat.core.logging.KnownIssueException; -import org.olat.core.logging.Tracing; -import org.olat.core.logging.activity.ActionType; -import org.olat.core.logging.activity.ThreadLocalUserActivityLogger; import org.olat.core.manager.BasicManager; -import org.olat.core.util.StringHelper; -import org.olat.core.util.coordinate.CoordinatorManager; -import org.olat.core.util.coordinate.SyncerCallback; -import org.olat.core.util.coordinate.SyncerExecutor; -import org.olat.core.util.mail.MailContext; -import org.olat.core.util.mail.MailContextImpl; -import org.olat.core.util.mail.MailHelper; -import org.olat.core.util.mail.MailTemplate; -import org.olat.core.util.mail.MailerResult; -import org.olat.core.util.mail.MailerWithTemplate; -import org.olat.core.util.notifications.NotificationsManager; -import org.olat.core.util.notifications.Subscriber; -import org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent; -import org.olat.course.nodes.projectbroker.service.ProjectBrokerManagerFactory; -import org.olat.group.area.BGArea; -import org.olat.group.area.BGAreaManager; -import org.olat.group.context.BGContext; -import org.olat.group.model.SearchBusinessGroupParams; -import org.olat.group.properties.BusinessGroupPropertyManager; -import org.olat.group.right.BGRightManager; -import org.olat.group.ui.BGConfigFlags; -import org.olat.group.ui.BGMailHelper; -import org.olat.group.ui.edit.BusinessGroupModifiedEvent; -import org.olat.instantMessaging.InstantMessagingModule; -import org.olat.instantMessaging.syncservice.SyncSingleUserTask; -import org.olat.notifications.NotificationsManagerImpl; -import org.olat.properties.Property; -import org.olat.repository.RepositoryEntry; -import org.olat.repository.RepositoryManager; -import org.olat.resource.OLATResource; -import org.olat.testutils.codepoints.server.Codepoint; -import org.olat.user.UserDataDeletable; -import org.olat.user.UserImpl; -import org.olat.util.logging.activity.LoggingResourceable; /** * Description:<br> diff --git a/src/main/java/org/olat/group/BusinessGroupService.java b/src/main/java/org/olat/group/BusinessGroupService.java index 0ec3a280482573c69b0ad1e52bbef60d1c1fc026..835786ae10562f8522ca94ea2c2e8829c4e2a88b 100644 --- a/src/main/java/org/olat/group/BusinessGroupService.java +++ b/src/main/java/org/olat/group/BusinessGroupService.java @@ -33,6 +33,7 @@ import org.olat.core.util.mail.MailTemplate; import org.olat.core.util.mail.MailerResult; import org.olat.group.area.BGArea; import org.olat.group.model.AddToGroupsEvent; +import org.olat.group.model.DisplayMembers; import org.olat.group.model.SearchBusinessGroupParams; import org.olat.group.ui.BGConfigFlags; import org.olat.repository.RepositoryEntry; @@ -61,6 +62,11 @@ public interface BusinessGroupService { public BusinessGroup mergeBusinessGroup(BusinessGroup group); + + public DisplayMembers getDisplayMembers(BusinessGroup group); + + public void updateDisplayMembers(BusinessGroup group, DisplayMembers displayMembers); + public void deleteBusinessGroup(BusinessGroup group); public void deleteGroupsAfterLifeCycle(List<BusinessGroup> groups); diff --git a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java index 3768d502c664a72e6b0da74bafc0b8c702f59534..85074f816695b764eba4703dd4ce425916c48590 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupDAO.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupDAO.java @@ -46,7 +46,6 @@ import org.olat.group.BusinessGroupImpl; import org.olat.group.BusinessGroupService; import org.olat.group.model.BGResourceRelation; import org.olat.group.model.SearchBusinessGroupParams; -import org.olat.group.properties.BusinessGroupPropertyManager; import org.olat.properties.Property; import org.olat.resource.OLATResource; import org.olat.resource.OLATResourceManager; @@ -69,6 +68,8 @@ public class BusinessGroupDAO { private BaseSecurity securityManager; @Autowired private OLATResourceManager olatResourceManager; + @Autowired + private BusinessGroupPropertyDAO businessGroupPropertyManager; public BusinessGroup createAndPersist(Identity creator, String name, String description, int minParticipants, int maxParticipants, boolean waitingListEnabled, boolean autoCloseRanksEnabled, @@ -116,8 +117,7 @@ public class BusinessGroupDAO { // per default all collaboration-tools are disabled // group members visibility - BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(businessgroup); - bgpm.createAndPersistDisplayMembers(showOwners, showParticipants, showWaitingList); + businessGroupPropertyManager.createAndPersistDisplayMembers(businessgroup, showOwners, showParticipants, showWaitingList); return businessgroup; } diff --git a/src/main/java/org/olat/group/manager/BusinessGroupImportExport.java b/src/main/java/org/olat/group/manager/BusinessGroupImportExport.java index 6a6de335f8ecaf2a992e6a67cdc4407ca76e6106..1579722da97653e10fed62c518c0a39ee0bba569 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupImportExport.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupImportExport.java @@ -39,7 +39,7 @@ import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; import org.olat.group.area.BGArea; import org.olat.group.area.BGAreaManager; -import org.olat.group.properties.BusinessGroupPropertyManager; +import org.olat.properties.Property; import org.olat.resource.OLATResource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -60,6 +60,8 @@ public class BusinessGroupImportExport { private BGAreaManager areaManager; @Autowired private BusinessGroupService businessGroupService; + @Autowired + private BusinessGroupPropertyDAO businessGroupPropertyManager; public void exportGroups(List<BusinessGroup> groups, File fExportFile) { @@ -145,10 +147,10 @@ public class BusinessGroupImportExport { newGroup.areaRelations.add(areaRelation.getName()); } // export properties - BusinessGroupPropertyManager bgPropertyManager = new BusinessGroupPropertyManager(group); - boolean showOwners = bgPropertyManager.showOwners(); - boolean showParticipants = bgPropertyManager.showPartips(); - boolean showWaitingList = bgPropertyManager.showWaitingList(); + Property property = businessGroupPropertyManager.findProperty(group); + boolean showOwners = businessGroupPropertyManager.showOwners(property); + boolean showParticipants = businessGroupPropertyManager.showPartips(property); + boolean showWaitingList = businessGroupPropertyManager.showWaitingList(property); newGroup.showOwners = showOwners; newGroup.showParticipants = showParticipants; @@ -272,8 +274,7 @@ public class BusinessGroupImportExport { if (group.showWaitingList != null) { showWaitingList = group.showWaitingList; } - BusinessGroupPropertyManager bgPropertyManager = new BusinessGroupPropertyManager(newGroup); - bgPropertyManager.updateDisplayMembers(showOwners, showParticipants, showWaitingList); + businessGroupPropertyManager.updateDisplayMembers(newGroup, showOwners, showParticipants, showWaitingList); } } } diff --git a/src/main/java/org/olat/group/properties/BusinessGroupPropertyManager.java b/src/main/java/org/olat/group/manager/BusinessGroupPropertyDAO.java similarity index 57% rename from src/main/java/org/olat/group/properties/BusinessGroupPropertyManager.java rename to src/main/java/org/olat/group/manager/BusinessGroupPropertyDAO.java index 8fc12b98189d6ea4c0f0dc12f7464127a9db396e..e1a0644aeb8cca95f75b586996537aa822d74c8c 100644 --- a/src/main/java/org/olat/group/properties/BusinessGroupPropertyManager.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupPropertyDAO.java @@ -23,14 +23,14 @@ * under the Apache 2.0 license as the original file. */ -package org.olat.group.properties; +package org.olat.group.manager; -import org.olat.core.commons.persistence.DBFactory; -import org.olat.core.manager.BasicManager; import org.olat.group.BusinessGroup; -import org.olat.properties.NarrowedPropertyManager; import org.olat.properties.Property; import org.olat.properties.PropertyConstants; +import org.olat.properties.PropertyManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** * Description:<BR> @@ -44,30 +44,15 @@ import org.olat.properties.PropertyConstants; * * @author patrick */ +@Service("businessGroupPropertyManager") +public class BusinessGroupPropertyDAO { + private static final String PROP_NAME = "displayMembers"; + private static final int showOwnersVal = 1;// 0x..0001 + private static final int showPartipsVal = 2;// 0x..0010 + private static final int showWaitingListVal = 4;// 0x..0100 -public class BusinessGroupPropertyManager extends BasicManager { - private static String PROP_NAME = "displayMembers"; - private int showOwnersVal = 1;// 0x..0001 - private int showPartipsVal = 2;// 0x..0010 - private int showWaitingListVal = 4;// 0x..0100 - - // 0x..1000 - // next used int values should be 8, 16, .... - // - private BusinessGroup businessGroup; - private NarrowedPropertyManager npm; - private Property myProperty; // local copy - - /** - * Create a new BusinessGroupPropertyManager which instantiates a - * NarrowedPropertyManager, narrowed to the supplied BusinessGroup. - * - * @param bg BusinessGroup not null. - */ - public BusinessGroupPropertyManager(BusinessGroup bg) { - this.businessGroup = bg; - this.npm = NarrowedPropertyManager.getInstance(businessGroup); - } + @Autowired + private PropertyManager propertyManager; /** * Creates and persists a new Property for the Display Members configuration @@ -77,15 +62,14 @@ public class BusinessGroupPropertyManager extends BasicManager { * @param showPartips * @return The generated property */ - public Property createAndPersistDisplayMembers(boolean showOwners, boolean showPartips, boolean showWaitingList) { + public Property createAndPersistDisplayMembers(BusinessGroup group, boolean showOwners, boolean showPartips, boolean showWaitingList) { long showXXX = 0; if (showOwners) showXXX += showOwnersVal; if (showPartips) showXXX += showPartipsVal; if (showWaitingList) showXXX += showWaitingListVal; - Property prop = npm.createPropertyInstance(null, this.businessGroup, PropertyConstants.OLATRESOURCE_CONFIGURATION, PROP_NAME, null, - new Long(showXXX), null, null); - npm.saveProperty(prop); - this.myProperty = prop; + + Property prop = propertyManager.createPropertyInstance(null, group, group, PropertyConstants.OLATRESOURCE_CONFIGURATION, PROP_NAME, null, new Long(showXXX), null, null); + propertyManager.saveProperty(prop); return prop; } @@ -96,30 +80,23 @@ public class BusinessGroupPropertyManager extends BasicManager { * @param showOwners * @param showPartips */ - public void updateDisplayMembers(boolean showOwners, boolean showPartips, boolean showWaitingList) { + public void updateDisplayMembers(BusinessGroup group, boolean showOwners, boolean showPartips, boolean showWaitingList) { long showXXX = 0; if (showOwners) showXXX += showOwnersVal; if (showPartips) showXXX += showPartipsVal; if (showWaitingList) showXXX += showWaitingListVal; - if (this.myProperty == null) { - this.myProperty = findProperty(); - } else { - // reload object to prevent stale object exception - this.myProperty = (Property) DBFactory.getInstance().loadObject(this.myProperty); - } - this.myProperty.setLongValue(new Long(showXXX)); - npm.updateProperty(this.myProperty); + + Property property = findProperty(group); + property.setLongValue(new Long(showXXX)); + propertyManager.updateProperty(property); } /** * delete the display members property */ - public void deleteDisplayMembers() { - if (this.myProperty == null) { - this.myProperty = findProperty(); - } - npm.deleteProperty(myProperty); - this.myProperty = null; + public void deleteDisplayMembers(BusinessGroup group) { + Property property = findProperty(group); + propertyManager.deleteProperty(property); } /** @@ -129,35 +106,43 @@ public class BusinessGroupPropertyManager extends BasicManager { * * @return true if group owners are configured to be displayed */ - public boolean showOwners() { - return ((getDisplayMembersValue() & showOwnersVal) == showOwnersVal); + public boolean showOwners(Property prop) { + return ((getDisplayMembersValue(prop) & showOwnersVal) == showOwnersVal); } /** - * true if Members can see the Partipiciants, false otherwise. If the property + * true if Members can see the Participants, false otherwise. If the property * is not existing, i.e. called before the property was created and persisted, * a null pointer exception occurs. * * @return true if group participants are configured to be displayed */ - public boolean showPartips() { - return ((getDisplayMembersValue() & showPartipsVal) == showPartipsVal); + public boolean showPartips(Property prop) { + return ((getDisplayMembersValue(prop) & showPartipsVal) == showPartipsVal); } + - private int getDisplayMembersValue() { - if (this.myProperty == null) { - this.myProperty = findProperty(); - } - // - int showXXX = this.myProperty.getLongValue().intValue(); + /** + * true if Members can see the Waiting, false otherwise. If the property + * is not existing, i.e. called before the property was created and persisted, + * a null pointer exception occurs. + * + * @return true if group participants are configured to be displayed + */ + public boolean showWaitingList(Property prop) { + return ((getDisplayMembersValue(prop) & showWaitingListVal) == showWaitingListVal); + } + + private int getDisplayMembersValue(Property prop) { + int showXXX = prop.getLongValue().intValue(); return showXXX; } /** * @return The group property. Either red from database or newly created. */ - private Property findProperty() { - Property prop = npm.findProperty(null, businessGroup, PropertyConstants.OLATRESOURCE_CONFIGURATION, PROP_NAME); + public Property findProperty(BusinessGroup group) { + Property prop = propertyManager.findProperty(null, group, group, PropertyConstants.OLATRESOURCE_CONFIGURATION, PROP_NAME); // prop != null, otherwise the init of this businessGroup was incomplete // or the caller uses the function in the wrong way // @@ -167,7 +152,7 @@ public class BusinessGroupPropertyManager extends BasicManager { // are to show. This reproduces behaviour of OLAT before the code was added. // Furthermore if the property wass not existing one will be created. if (prop == null) { - prop = createAndPersistDisplayMembers(true, true, true); + prop = createAndPersistDisplayMembers(group, true, true, true); } return prop; } @@ -175,20 +160,13 @@ public class BusinessGroupPropertyManager extends BasicManager { /** * @param sourceGroup The group from which the configuration should be copied */ - public void copyConfigurationFromGroup(BusinessGroup sourceGroup) { - BusinessGroupPropertyManager sourceGPM = new BusinessGroupPropertyManager(sourceGroup); - updateDisplayMembers(sourceGPM.showOwners(), sourceGPM.showPartips(), sourceGPM.showWaitingList() ); + public void copyConfigurationFromGroup(BusinessGroup sourceGroup, BusinessGroup targetGroup) { + Property sourceGPM = findProperty(sourceGroup); + boolean showOwners = showOwners(sourceGPM); + boolean showPartips = showPartips(sourceGPM); + boolean showWaitingList = showWaitingList(sourceGPM); + updateDisplayMembers(targetGroup, showOwners, showPartips, showWaitingList); } - /** - * true if Members can see the Waiting, false otherwise. If the property - * is not existing, i.e. called before the property was created and persisted, - * a null pointer exception occurs. - * - * @return true if group participants are configured to be displayed - */ - public boolean showWaitingList() { - return ((getDisplayMembersValue() & showWaitingListVal) == showWaitingListVal); - } } diff --git a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java index e426199d84ed6d0750aaa94fb967c8325cc59ac1..f3c01c15e9459137e55522d18ecbd76a08293954 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java @@ -71,8 +71,8 @@ import org.olat.group.GroupLoggingAction; import org.olat.group.area.BGArea; import org.olat.group.area.BGAreaManager; import org.olat.group.model.AddToGroupsEvent; +import org.olat.group.model.DisplayMembers; import org.olat.group.model.SearchBusinessGroupParams; -import org.olat.group.properties.BusinessGroupPropertyManager; import org.olat.group.right.BGRightManager; import org.olat.group.ui.BGConfigFlags; import org.olat.group.ui.BGMailHelper; @@ -80,6 +80,7 @@ import org.olat.group.ui.edit.BusinessGroupModifiedEvent; import org.olat.instantMessaging.InstantMessagingModule; import org.olat.instantMessaging.syncservice.SyncSingleUserTask; import org.olat.notifications.NotificationsManagerImpl; +import org.olat.properties.Property; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; import org.olat.resource.OLATResource; @@ -117,6 +118,8 @@ public class BusinessGroupServiceImpl implements BusinessGroupService { private RepositoryManager repositoryManager; @Autowired private BusinessGroupDeletionManager businessGroupDeletionManager; + @Autowired + private BusinessGroupPropertyDAO businessGroupPropertyManager; private List<DeletableGroupData> deleteListeners = new ArrayList<DeletableGroupData>(); @@ -191,7 +194,25 @@ public class BusinessGroupServiceImpl implements BusinessGroupService { public BusinessGroup mergeBusinessGroup(BusinessGroup group) { return businessGroupDAO.merge(group); } - + + @Override + public DisplayMembers getDisplayMembers(BusinessGroup group) { + Property props = businessGroupPropertyManager.findProperty(group); + DisplayMembers displayMembers = new DisplayMembers(); + displayMembers.setShowOwners(businessGroupPropertyManager.showOwners(props)); + displayMembers.setShowParticipants(businessGroupPropertyManager.showPartips(props)); + displayMembers.setShowWaitingList(businessGroupPropertyManager.showWaitingList(props)); + return displayMembers; + } + + @Override + public void updateDisplayMembers(BusinessGroup group, DisplayMembers displayMembers) { + boolean showOwners = displayMembers.isShowOwners(); + boolean showPartips = displayMembers.isShowParticipants(); + boolean showWaitingList = displayMembers.isShowWaitingList(); + businessGroupPropertyManager.updateDisplayMembers(group, showOwners, showPartips, showWaitingList); + } + @Override @Transactional public BusinessGroup setLastUsageFor(final BusinessGroup group) { @@ -281,8 +302,7 @@ public class BusinessGroupServiceImpl implements BusinessGroupService { } // 3. copy member visibility if (copyMemberVisibility) { - BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(newGroup); - bgpm.copyConfigurationFromGroup(sourceBusinessGroup); + businessGroupPropertyManager.copyConfigurationFromGroup(sourceBusinessGroup, newGroup); } // 4. copy areas if (copyAreas) { @@ -417,8 +437,7 @@ public class BusinessGroupServiceImpl implements BusinessGroupService { ct.deleteTools(group);// deletes everything concerning properties&collabTools // 1.b)delete display member property - BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(group); - bgpm.deleteDisplayMembers(); + businessGroupPropertyManager.deleteDisplayMembers(group); // 1.c)delete user in security groups removeFromRepositoryEntrySecurityGroup(group); // 2) Delete the group areas diff --git a/src/main/java/org/olat/group/model/DisplayMembers.java b/src/main/java/org/olat/group/model/DisplayMembers.java new file mode 100644 index 0000000000000000000000000000000000000000..8b4c11be3f751dfc0b0ab668c30364e7bbcc554e --- /dev/null +++ b/src/main/java/org/olat/group/model/DisplayMembers.java @@ -0,0 +1,65 @@ +/** + * <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; + +/** + * + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + */ +public class DisplayMembers { + + private boolean showOwners; + private boolean showParticipants; + private boolean showWaitingList; + + public DisplayMembers() { + // + } + + public DisplayMembers(boolean showOwners, boolean showParticipants, boolean showWaitingList) { + this.showOwners = showOwners; + this.showParticipants = showParticipants; + this.showWaitingList = showWaitingList; + } + + public boolean isShowOwners() { + return showOwners; + } + + public void setShowOwners(boolean showOwners) { + this.showOwners = showOwners; + } + + public boolean isShowParticipants() { + return showParticipants; + } + + public void setShowParticipants(boolean showParticipants) { + this.showParticipants = showParticipants; + } + + public boolean isShowWaitingList() { + return showWaitingList; + } + + public void setShowWaitingList(boolean showWaitingList) { + this.showWaitingList = showWaitingList; + } +} diff --git a/src/main/java/org/olat/group/ui/edit/BusinessGroupEditController.java b/src/main/java/org/olat/group/ui/edit/BusinessGroupEditController.java index b7c8b537018354cd0db8316c02cc6e29db0ff119..92408d7908b21e910a6c70055a428b8ed86b6a78 100644 --- a/src/main/java/org/olat/group/ui/edit/BusinessGroupEditController.java +++ b/src/main/java/org/olat/group/ui/edit/BusinessGroupEditController.java @@ -84,7 +84,7 @@ import org.olat.group.BusinessGroupService; import org.olat.group.GroupLoggingAction; import org.olat.group.area.BGArea; import org.olat.group.area.BGAreaManager; -import org.olat.group.properties.BusinessGroupPropertyManager; +import org.olat.group.model.DisplayMembers; import org.olat.group.right.BGRightManager; import org.olat.group.right.BGRights; import org.olat.group.ui.BGConfigFlags; @@ -292,10 +292,9 @@ public class BusinessGroupEditController extends BasicController implements Cont */ @Override public void event(UserRequest ureq, Controller source, Event event) { - if (source == this.dmsForm && event == Event.CHANGED_EVENT) { - BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(currBusinessGroup); - bgpm.updateDisplayMembers(dmsForm.getShowOwners(), dmsForm.getShowPartipiciants(), dmsForm.getShowWaitingList()); - bgpm = null; + if (source == dmsForm && event == Event.CHANGED_EVENT) { + businessGroupService.updateDisplayMembers(currBusinessGroup, + new DisplayMembers(dmsForm.getShowOwners(), dmsForm.getShowPartipiciants(), dmsForm.getShowWaitingList())); // notify current active users of this business group BusinessGroupModifiedEvent.fireModifiedGroupEvents(BusinessGroupModifiedEvent.CONFIGURATION_MODIFIED_EVENT, currBusinessGroup, null); // do loggin @@ -576,17 +575,16 @@ public class BusinessGroupEditController extends BasicController implements Cont // Member Display Form, allows to enable/disable that others partips see // partips and/or owners // - BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(currBusinessGroup); + DisplayMembers displayMembers = businessGroupService.getDisplayMembers(currBusinessGroup); // configure the form with checkboxes for owners and/or partips according // the booleans removeAsListenerAndDispose(dmsForm); dmsForm = new DisplayMemberSwitchForm(ureq, getWindowControl(), hasOwners, hasPartips, hasWaitingList); listenTo(dmsForm); // set if the checkboxes are checked or not. - if (hasOwners) dmsForm.setShowOwnersChecked(bgpm.showOwners()); - if (hasPartips) dmsForm.setShowPartipsChecked(bgpm.showPartips()); - if (hasWaitingList) dmsForm.setShowWaitingListChecked(bgpm.showWaitingList()); - bgpm = null; + if (hasOwners) dmsForm.setShowOwnersChecked(displayMembers.isShowOwners()); + if (hasPartips) dmsForm.setShowPartipsChecked(displayMembers.isShowParticipants()); + if (hasWaitingList) dmsForm.setShowWaitingListChecked(displayMembers.isShowWaitingList()); tmp.put("displayMembers", dmsForm.getInitialComponent()); boolean enableTablePreferences = flags.isEnabled(BGConfigFlags.ADMIN_SEE_ALL_USER_DATA); diff --git a/src/main/java/org/olat/group/ui/run/BusinessGroupMainRunController.java b/src/main/java/org/olat/group/ui/run/BusinessGroupMainRunController.java index de51035e725b90d80eb9ac96c26d8a71c5335bf6..c376702b6b30c0a5005cfd7dade54a0104dc5e38 100644 --- a/src/main/java/org/olat/group/ui/run/BusinessGroupMainRunController.java +++ b/src/main/java/org/olat/group/ui/run/BusinessGroupMainRunController.java @@ -84,7 +84,7 @@ import org.olat.course.nodes.iq.AssessmentEvent; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; import org.olat.group.GroupLoggingAction; -import org.olat.group.properties.BusinessGroupPropertyManager; +import org.olat.group.model.DisplayMembers; import org.olat.group.ui.BGConfigFlags; import org.olat.group.ui.BGControllerFactory; import org.olat.group.ui.BGTranslatorFactory; @@ -199,7 +199,6 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im private BGConfigFlags flags; - private BusinessGroupPropertyManager bgpm; private final BusinessGroupService businessGroupService; private UserSession userSession; private String adminNodeId; // reference to admin menu item @@ -254,7 +253,6 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im addLoggingResourceable(LoggingResourceable.wrap(businessGroup)); ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_OPEN, getClass()); - bgpm = new BusinessGroupPropertyManager(businessGroup); this.userSession = ureq.getUserSession(); this.assessmentEventOres = OresHelper.createOLATResourceableType(AssessmentEvent.class); @@ -822,7 +820,8 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im private void doShowMembers(UserRequest ureq) { VelocityContainer membersVc = createVelocityContainer("ownersandmembers"); // 1. show owners if configured with Owners - if (flags.isEnabled(BGConfigFlags.GROUP_OWNERS) && bgpm.showOwners()) { + DisplayMembers displayMembers = businessGroupService.getDisplayMembers(businessGroup); + if (flags.isEnabled(BGConfigFlags.GROUP_OWNERS) && displayMembers.isShowOwners()) { removeAsListenerAndDispose(gownersC); gownersC = new GroupController(ureq, getWindowControl(), false, true, false, businessGroup.getOwnerGroup()); listenTo(gownersC); @@ -832,7 +831,7 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im membersVc.contextPut("showOwnerGroups", Boolean.FALSE); } // 2. show participants if configured with Participants - if (bgpm.showPartips()) { + if (displayMembers.isShowParticipants()) { removeAsListenerAndDispose(gparticipantsC); gparticipantsC = new GroupController(ureq, getWindowControl(), false, true, false, businessGroup.getPartipiciantGroup()); listenTo(gparticipantsC); @@ -844,7 +843,7 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im } // 3. show waiting-list if configured membersVc.contextPut("hasWaitingList", new Boolean(businessGroup.getWaitingListEnabled()) ); - if (bgpm.showWaitingList()) { + if (displayMembers.isShowWaitingList()) { removeAsListenerAndDispose(waitingListController); waitingListController = new GroupController(ureq, getWindowControl(), false, true, false, businessGroup.getWaitingGroup()); listenTo(waitingListController); @@ -995,9 +994,8 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im BusinessGroupModifiedEvent bgmfe = (BusinessGroupModifiedEvent) event; if (event.getCommand().equals(BusinessGroupModifiedEvent.CONFIGURATION_MODIFIED_EVENT)) { // reset business group property manager - this.bgpm = new BusinessGroupPropertyManager(this.businessGroup); // update reference to update business group object - this.businessGroup = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(this.businessGroup); + businessGroup = businessGroupService.loadBusinessGroup(this.businessGroup); main.contextPut("BuddyGroup", this.businessGroup); TreeModel trMdl = buildTreeModel(); bgTree.setTreeModel(trMdl); @@ -1105,8 +1103,9 @@ public class BusinessGroupMainRunController extends MainLayoutBasicController im //fxdiff BAKS-7 Resume function nodeResources = gtnChild; } - - if ((flags.isEnabled(BGConfigFlags.GROUP_OWNERS) && bgpm.showOwners()) || bgpm.showPartips()) { + + DisplayMembers displayMembers = businessGroupService.getDisplayMembers(businessGroup); + if ((flags.isEnabled(BGConfigFlags.GROUP_OWNERS) && displayMembers.isShowOwners()) || displayMembers.isShowParticipants()) { // either owners or participants, or both are visible // otherwise the node is not visible gtnChild = new GenericTreeNode(); diff --git a/src/main/java/org/olat/group/ui/run/BusinessGroupSendToChooserForm.java b/src/main/java/org/olat/group/ui/run/BusinessGroupSendToChooserForm.java index b4e2afd9a13e99e4caa9f88ebe7f04dcc07f5e0e..3f195696f87c223d21a5e546622d66218f0e3840 100644 --- a/src/main/java/org/olat/group/ui/run/BusinessGroupSendToChooserForm.java +++ b/src/main/java/org/olat/group/ui/run/BusinessGroupSendToChooserForm.java @@ -30,9 +30,9 @@ import java.util.Arrays; import java.util.List; import java.util.Set; -import org.olat.basesecurity.BaseSecurity; import org.olat.basesecurity.BaseSecurityManager; import org.olat.basesecurity.SecurityGroup; +import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.form.flexible.FormItem; import org.olat.core.gui.components.form.flexible.FormItemContainer; @@ -48,7 +48,8 @@ import org.olat.core.id.Identity; import org.olat.core.id.User; import org.olat.core.util.ArrayHelper; import org.olat.group.BusinessGroup; -import org.olat.group.properties.BusinessGroupPropertyManager; +import org.olat.group.BusinessGroupService; +import org.olat.group.model.DisplayMembers; import org.olat.user.UserManager; import org.olat.user.propertyhandlers.UserPropertyHandler; @@ -95,7 +96,7 @@ public class BusinessGroupSendToChooserForm extends FormBasicController { public final static String NLS_RADIO_ALL = "all"; public final static String NLS_RADIO_NOTHING = "nothing"; public final static String NLS_RADIO_CHOOSE = "choose"; - + /** * @param name * @param translator @@ -107,11 +108,10 @@ public class BusinessGroupSendToChooserForm extends FormBasicController { this.isAdmin = isAdmin; // check 'members can see owners' and 'members can see participants' - BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(businessGroup); - BaseSecurity scrtMngr = BaseSecurityManager.getInstance(); - - showChooseOwners = bgpm.showOwners(); - showChoosePartips = bgpm.showPartips(); + BusinessGroupService businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); + DisplayMembers displayMembers = businessGroupService.getDisplayMembers(businessGroup); + showChooseOwners = displayMembers.isShowOwners(); + showChoosePartips = displayMembers.isShowParticipants(); showWaitingList = isAdmin && businessGroup.getWaitingListEnabled().booleanValue(); if (isMultiSelectionOwnerKeys()) { diff --git a/src/main/java/org/olat/restapi/group/LearningGroupWebService.java b/src/main/java/org/olat/restapi/group/LearningGroupWebService.java index 71ef79e109922942d3c47ce7d53f82c2e95230a1..ec2f52117ce34fc4b1216f80bb2c451897cef414 100644 --- a/src/main/java/org/olat/restapi/group/LearningGroupWebService.java +++ b/src/main/java/org/olat/restapi/group/LearningGroupWebService.java @@ -66,8 +66,8 @@ import org.olat.core.util.vfs.restapi.VFSWebServiceSecurityCallback; import org.olat.core.util.vfs.restapi.VFSWebservice; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; +import org.olat.group.model.DisplayMembers; import org.olat.group.model.SearchBusinessGroupParams; -import org.olat.group.properties.BusinessGroupPropertyManager; import org.olat.group.ui.BGConfigFlags; import org.olat.modules.fo.Forum; import org.olat.modules.fo.restapi.ForumWebService; @@ -407,8 +407,8 @@ public class LearningGroupWebService { if(!bgs.isIdentityInBusinessGroup(identity, bg)) { return Response.serverError().status(Status.UNAUTHORIZED).build(); } - BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(bg); - if(!bgpm.showOwners()) { + DisplayMembers displayMembers = bgs.getDisplayMembers(bg); + if(!displayMembers.isShowOwners()) { return Response.serverError().status(Status.UNAUTHORIZED).build(); } } @@ -442,8 +442,8 @@ public class LearningGroupWebService { if(!bgs.isIdentityInBusinessGroup(identity, bg)) { return Response.serverError().status(Status.UNAUTHORIZED).build(); } - BusinessGroupPropertyManager bgpm = new BusinessGroupPropertyManager(bg); - if(!bgpm.showPartips()) { + DisplayMembers displayMembers = bgs.getDisplayMembers(bg); + if(!displayMembers.isShowParticipants()) { return Response.serverError().status(Status.UNAUTHORIZED).build(); } } diff --git a/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java b/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java index 9ff2af87af5f9194240f828a130677112b0dedf3..325dcd580ac759d86d703ddbc49758f621cc94e2 100644 --- a/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java +++ b/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java @@ -36,8 +36,9 @@ import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.group.BusinessGroup; import org.olat.group.manager.BusinessGroupDAO; +import org.olat.group.manager.BusinessGroupPropertyDAO; import org.olat.group.model.SearchBusinessGroupParams; -import org.olat.group.properties.BusinessGroupPropertyManager; +import org.olat.properties.Property; import org.olat.test.JunitTestHelper; import org.olat.test.OlatTestCase; import org.springframework.beans.factory.annotation.Autowired; @@ -56,6 +57,8 @@ public class BusinessGroupDAOTest extends OlatTestCase { private DB dbInstance; @Autowired private BaseSecurity securityManager; + @Autowired + private BusinessGroupPropertyDAO businessGroupPropertyManager; @After @@ -330,20 +333,20 @@ public class BusinessGroupDAOTest extends OlatTestCase { dbInstance.commitAndCloseSession(); //check the value - BusinessGroupPropertyManager bgpm1 = new BusinessGroupPropertyManager(group1); - Assert.assertTrue(bgpm1.showOwners()); - Assert.assertTrue(bgpm1.showPartips()); - Assert.assertFalse(bgpm1.showWaitingList()); - - BusinessGroupPropertyManager bgpm2 = new BusinessGroupPropertyManager(group2); - Assert.assertFalse(bgpm2.showOwners()); - Assert.assertTrue(bgpm2.showPartips()); - Assert.assertFalse(bgpm2.showWaitingList()); - - BusinessGroupPropertyManager bgpm3 = new BusinessGroupPropertyManager(group3); - Assert.assertFalse(bgpm3.showOwners()); - Assert.assertFalse(bgpm3.showPartips()); - Assert.assertTrue(bgpm3.showWaitingList()); + Property prop1 = businessGroupPropertyManager.findProperty(group1); + Assert.assertTrue(businessGroupPropertyManager.showOwners(prop1)); + Assert.assertTrue(businessGroupPropertyManager.showPartips(prop1)); + Assert.assertFalse(businessGroupPropertyManager.showWaitingList(prop1)); + + Property prop2 = businessGroupPropertyManager.findProperty(group2); + Assert.assertFalse(businessGroupPropertyManager.showOwners(prop2)); + Assert.assertTrue(businessGroupPropertyManager.showPartips(prop2)); + Assert.assertFalse(businessGroupPropertyManager.showWaitingList(prop2)); + + Property prop3 = businessGroupPropertyManager.findProperty(group3); + Assert.assertFalse(businessGroupPropertyManager.showOwners(prop3)); + Assert.assertFalse(businessGroupPropertyManager.showPartips(prop3)); + Assert.assertTrue(businessGroupPropertyManager.showWaitingList(prop3)); } @Test diff --git a/src/test/java/org/olat/restapi/ContactsTest.java b/src/test/java/org/olat/restapi/ContactsTest.java index b03f6a7e73ecbae9876e6bac0ae551bb23bc126f..41838e8fd88b6fdb34d86aa55bf93790aea32d22 100644 --- a/src/test/java/org/olat/restapi/ContactsTest.java +++ b/src/test/java/org/olat/restapi/ContactsTest.java @@ -45,7 +45,7 @@ import org.olat.core.id.OLATResourceable; import org.olat.core.util.resource.OresHelper; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; -import org.olat.group.properties.BusinessGroupPropertyManager; +import org.olat.group.model.DisplayMembers; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; import org.olat.resource.OLATResource; @@ -122,10 +122,8 @@ public class ContactsTest extends OlatJerseyTestCase { g2 = businessGroupService.createBusinessGroup(null, "rest-g2", null, 0, 10, false, false, c1); //permission to see owners and participants - BusinessGroupPropertyManager bgpm1 = new BusinessGroupPropertyManager(g1); - bgpm1.updateDisplayMembers(false, false, false); - BusinessGroupPropertyManager bgpm2 = new BusinessGroupPropertyManager(g2); - bgpm2.updateDisplayMembers(true, true, false); + businessGroupService.updateDisplayMembers(g1, new DisplayMembers(false, false, false)); + businessGroupService.updateDisplayMembers(g2, new DisplayMembers(true, true, false)); // members g1 secm.addIdentityToSecurityGroup(owner1, g1.getOwnerGroup()); @@ -142,9 +140,9 @@ public class ContactsTest extends OlatJerseyTestCase { OLATResource c2 = JunitTestHelper.createRandomResource(); // groups g3 = businessGroupService.createBusinessGroup(null, "rest-g3", null, -1, -1, false, false, c2); - new BusinessGroupPropertyManager(g3).updateDisplayMembers(false, true, false); + businessGroupService.updateDisplayMembers(g3, new DisplayMembers(false, true, false)); g4 = businessGroupService.createBusinessGroup(null, "rest-g4", null, -1, -1, false, false, c2); - new BusinessGroupPropertyManager(g4).updateDisplayMembers(false, true, false); + businessGroupService.updateDisplayMembers(g4, new DisplayMembers(false, true, false)); // members -> default participants are visible secm.addIdentityToSecurityGroup(owner1, g3.getPartipiciantGroup()); secm.addIdentityToSecurityGroup(part3, g3.getPartipiciantGroup()); diff --git a/src/test/java/org/olat/restapi/GroupFoldersTest.java b/src/test/java/org/olat/restapi/GroupFoldersTest.java index 5d2179755dcd61001288e5789300da52750f4a45..5eac47e5111e122127c178a53ecaafb89044b329 100644 --- a/src/test/java/org/olat/restapi/GroupFoldersTest.java +++ b/src/test/java/org/olat/restapi/GroupFoldersTest.java @@ -68,7 +68,7 @@ import org.olat.core.util.vfs.VFSContainer; import org.olat.core.util.vfs.VFSLeaf; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; -import org.olat.group.properties.BusinessGroupPropertyManager; +import org.olat.group.model.DisplayMembers; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryManager; import org.olat.resource.OLATResource; @@ -154,10 +154,8 @@ public class GroupFoldersTest extends OlatJerseyTestCase { g2 = businessGroupService.createBusinessGroup(null, "rest-g2", null, 0, 10, false, false, c1); //permission to see owners and participants - BusinessGroupPropertyManager bgpm1 = new BusinessGroupPropertyManager(g1); - bgpm1.updateDisplayMembers(false, false, false); - BusinessGroupPropertyManager bgpm2 = new BusinessGroupPropertyManager(g2); - bgpm2.updateDisplayMembers(true, true, false); + businessGroupService.updateDisplayMembers(g1, new DisplayMembers(false, false, false)); + businessGroupService.updateDisplayMembers(g2, new DisplayMembers(true, true, false)); // members g1 secm.addIdentityToSecurityGroup(owner1, g1.getOwnerGroup()); diff --git a/src/test/java/org/olat/restapi/GroupMgmtTest.java b/src/test/java/org/olat/restapi/GroupMgmtTest.java index 6366a243da93bc89da922c8f850692bdbbbe3a28..70329e783d2e63c7f451145e37030ce35b49fa94 100644 --- a/src/test/java/org/olat/restapi/GroupMgmtTest.java +++ b/src/test/java/org/olat/restapi/GroupMgmtTest.java @@ -67,7 +67,7 @@ import org.olat.core.logging.Tracing; import org.olat.core.util.resource.OresHelper; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupService; -import org.olat.group.properties.BusinessGroupPropertyManager; +import org.olat.group.model.DisplayMembers; import org.olat.modules.fo.Forum; import org.olat.modules.fo.ForumManager; import org.olat.modules.fo.Message; @@ -166,10 +166,8 @@ public class GroupMgmtTest extends OlatJerseyTestCase { g2 = businessGroupService.createBusinessGroup(null, "rest-g2", null, 0, 10, false, false, c1); //permission to see owners and participants - BusinessGroupPropertyManager bgpm1 = new BusinessGroupPropertyManager(g1); - bgpm1.updateDisplayMembers(false, false, false); - BusinessGroupPropertyManager bgpm2 = new BusinessGroupPropertyManager(g2); - bgpm2.updateDisplayMembers(true, true, false); + businessGroupService.updateDisplayMembers(g1, new DisplayMembers(false, false, false)); + businessGroupService.updateDisplayMembers(g2, new DisplayMembers(true, true, false)); // members g1 secm.addIdentityToSecurityGroup(owner1, g1.getOwnerGroup());