diff --git a/src/main/java/org/olat/group/BusinessGroupService.java b/src/main/java/org/olat/group/BusinessGroupService.java index 747c410c31adf2437a7d2bc3bb979422abae51fa..53ef3992f0144ecaf1c73613617b574e61e362fa 100644 --- a/src/main/java/org/olat/group/BusinessGroupService.java +++ b/src/main/java/org/olat/group/BusinessGroupService.java @@ -23,6 +23,7 @@ import java.io.File; import java.util.Collection; import java.util.List; import java.util.Locale; +import java.util.Set; import org.olat.basesecurity.Group; import org.olat.basesecurity.IdentityRef; @@ -204,11 +205,35 @@ public interface BusinessGroupService { * @param copyParticipants * @param copyMemberVisibility * @param copyWaitingList - * @return The copied business group */ public BusinessGroup copyBusinessGroup(Identity identity, BusinessGroup sourceBusinessGroup, String targetName, String targetDescription, Integer targetMin, Integer targetMax, boolean copyAreas, boolean copyCollabToolConfig, boolean copyRights, boolean copyOwners, boolean copyParticipants, boolean copyMemberVisibility, boolean copyWaitingList, boolean copyRelations); + + /** + * Create and persist new business groups based on a source group. + * @param sourceBusinessGroup The group that will be used as the source group and everything + * @param targetNames A list of group names + * @param targetDescription The description + * @param targetMin + * @param targetMax + * @param targetResource + * @param areaLookupMap The area lookup map (the target group will references + * mapped areas) or null (target group will reference the same areas + * as the original group) + * @param copyAreas + * @param copyCollabToolConfig + * @param copyRights + * @param copyOwners + * @param copyParticipants + * @param copyMemberVisibility + * @param copyWaitingList + * @return The copied business group + */ + public void copyBusinessGroup(Identity identity, BusinessGroup sourceBusinessGroup, Set<String> targetNames, String targetDescription, + Integer targetMin, Integer targetMax, boolean copyAreas, boolean copyCollabToolConfig, boolean copyRights, + boolean copyOwners, boolean copyParticipants, boolean copyMemberVisibility, boolean copyWaitingList, boolean copyRelations); + /** * Merge the owners, participants and the waiting list. diff --git a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java index 4e1ffd8261afe81f735a0186503f75281b18659b..6a023c22b977d042068ed433f82a762a38b3a5c1 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java @@ -350,6 +350,20 @@ public class BusinessGroupServiceImpl implements BusinessGroupService { public List<BusinessGroup> loadAllBusinessGroups() { return businessGroupDAO.loadAll(); } + + + + @Override + public void copyBusinessGroup(Identity identity, BusinessGroup sourceBusinessGroup, + Set<String> targetNames, String targetDescription, Integer targetMin, Integer targetMax, boolean copyAreas, + boolean copyCollabToolConfig, boolean copyRights, boolean copyOwners, boolean copyParticipants, + boolean copyMemberVisibility, boolean copyWaitingList, boolean copyRelations) { + for(String targetName:targetNames) { + copyBusinessGroup(identity, sourceBusinessGroup, targetName, targetDescription, + targetMin, targetMax, copyAreas, copyCollabToolConfig, copyRights, + copyOwners, copyParticipants, copyMemberVisibility, copyWaitingList, copyRelations); + } + } @Override public BusinessGroup copyBusinessGroup(Identity identity, BusinessGroup sourceBusinessGroup, String targetName, String targetDescription, diff --git a/src/main/java/org/olat/group/ui/BusinessGroupFormController.java b/src/main/java/org/olat/group/ui/BusinessGroupFormController.java index 69c2805ea1aea076f5990fb9149ed969b3f9ee42..36ff125233500fcee0dad40f9baf2e1c7caabaca 100644 --- a/src/main/java/org/olat/group/ui/BusinessGroupFormController.java +++ b/src/main/java/org/olat/group/ui/BusinessGroupFormController.java @@ -26,7 +26,6 @@ import java.util.Set; import org.olat.admin.restapi.RestapiAdminController; import org.olat.basesecurity.GroupRoles; -import org.olat.core.CoreSpringFactory; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.form.flexible.FormItemContainer; import org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement; @@ -48,6 +47,7 @@ import org.olat.core.util.Util; import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupManagedFlag; import org.olat.group.BusinessGroupService; +import org.springframework.beans.factory.annotation.Autowired; /** * Implements a Business group creation dialog using FlexiForms. @@ -105,7 +105,8 @@ public class BusinessGroupFormController extends FormBasicController { /** The value for the autoCloseRanks checkbox. */ private final String[] autoCloseValues = new String[] { translate("create.form.enableAutoCloseRanks") }; - private final BusinessGroupService businessGroupService; + @Autowired + private BusinessGroupService businessGroupService; /** * Creates this controller. @@ -118,7 +119,6 @@ public class BusinessGroupFormController extends FormBasicController { public BusinessGroupFormController(UserRequest ureq, WindowControl wControl, BusinessGroup businessGroup) { super(ureq, wControl, FormBasicController.LAYOUT_DEFAULT); this.businessGroup = businessGroup; - businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); initForm(ureq); } @@ -134,16 +134,14 @@ public class BusinessGroupFormController extends FormBasicController { super(ureq, wControl, FormBasicController.LAYOUT_DEFAULT); this.businessGroup = businessGroup; this.bulkMode = bulkMode; - businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); initForm(ureq); // depends on bulkMode flag } public BusinessGroupFormController(UserRequest ureq, WindowControl wControl, BusinessGroup businessGroup, Form rootForm) { super(ureq, wControl, FormBasicController.LAYOUT_DEFAULT, null, rootForm); this.businessGroup = businessGroup; - bulkMode = false; + bulkMode = true; embbeded = true; - businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); initForm(ureq); // depends on bulkMode flag } diff --git a/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java index 95f970a0ed00f537e49a30df71398e33edb84ffd..42623a47e01b1d17151c68056224ae289b8fca35 100644 --- a/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java @@ -687,7 +687,7 @@ public abstract class AbstractBusinessGroupListController extends FormBasicContr boolean copyRelations = convertToBoolean(runContext, "resources"); for(BGCopyBusinessGroup copy:copies) { - businessGroupService.copyBusinessGroup(getIdentity(), copy.getOriginal(), copy.getName(), copy.getDescription(), + businessGroupService.copyBusinessGroup(getIdentity(), copy.getOriginal(), copy.getNames(), copy.getDescription(), copy.getMinParticipants(), copy.getMaxParticipants(), copyAreas, copyCollabToolConfig, copyRights, copyOwners, copyParticipants, copyMemberVisibility, copyWaitingList, copyRelations); diff --git a/src/main/java/org/olat/group/ui/wizard/BGCopyBusinessGroup.java b/src/main/java/org/olat/group/ui/wizard/BGCopyBusinessGroup.java index 8ddc5a48e5a7b39f716e81a8f09e780cf4b17bc8..e108a01c648858e3b1e29b83b6fa43a7c7256086 100644 --- a/src/main/java/org/olat/group/ui/wizard/BGCopyBusinessGroup.java +++ b/src/main/java/org/olat/group/ui/wizard/BGCopyBusinessGroup.java @@ -19,6 +19,8 @@ */ package org.olat.group.ui.wizard; +import java.util.Set; + import org.olat.group.BusinessGroup; import org.olat.group.BusinessGroupManagedFlag; import org.olat.group.BusinessGroupShort; @@ -30,6 +32,7 @@ import org.olat.group.BusinessGroupShort; public class BGCopyBusinessGroup implements BusinessGroupShort { private String name; + private Set<String> names; private String description; private Integer minParticipants; private Integer maxParticipants; @@ -69,6 +72,15 @@ public class BGCopyBusinessGroup implements BusinessGroupShort { this.name = name; } + public Set<String> getNames() { + return names; + } + + public void setNames(Set<String> names) { + this.names = names; + } + + @Override public BusinessGroupManagedFlag[] getManagedFlags() { return BusinessGroupManagedFlag.EMPTY_ARRAY; diff --git a/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStepController.java b/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStepController.java index 7f2ed1743f78979cc5895f5ac554928e9817e572..3ca976484b76ad26c52eb2ce91f7b9e317fc527a 100644 --- a/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStepController.java +++ b/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStepController.java @@ -82,13 +82,13 @@ public class BGCopySingleGroupStepController extends StepFormBasicController { BGCopyBusinessGroup currentCopy = getWithOriginal(copies); if(currentCopy == null) { BGCopyBusinessGroup group = new BGCopyBusinessGroup(originalGroup); - group.setName(groupController.getGroupName()); + group.setNames(groupController.getGroupNames()); group.setDescription(groupController.getGroupDescription()); group.setMinParticipants(groupController.getGroupMin()); group.setMaxParticipants(groupController.getGroupMax()); copies.add(group); } else { - currentCopy.setName(groupController.getGroupName()); + currentCopy.setNames(groupController.getGroupNames()); currentCopy.setDescription(groupController.getGroupDescription()); currentCopy.setMinParticipants(groupController.getGroupMin()); currentCopy.setMaxParticipants(groupController.getGroupMax());