From 2da121fd729edbb917e01629be52d874230dc15b Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Tue, 24 Jul 2012 13:36:12 +0200
Subject: [PATCH] OO-291: implements the wizard to copy groups

---
 .../flexible/impl/elements/FormLinkImpl.java  |  4 +
 .../gui/control/generic/wizard/BasicStep.java | 16 +++-
 .../AbstractBusinessGroupListController.java  | 36 ++++++-
 .../AdminBusinessGroupSearchController.java   | 50 ----------
 .../main/AdminBusinessGroupsController.java   | 14 ++-
 .../olat/group/ui/main/BGMainController.java  |  2 +-
 .../ui/main/BusinessGroupListController.java  |  2 +-
 .../main/BusinessGroupSearchController.java   | 25 ++---
 .../group/ui/wizard/BGCopyBusinessGroup.java  | 94 +++++++++++++++++++
 .../BGCopyPreparationStepController.java      | 25 +++--
 .../ui/wizard/BGCopySingleGroupStep.java      | 12 +++
 .../BGCopySingleGroupStepController.java      | 34 ++++++-
 12 files changed, 234 insertions(+), 80 deletions(-)
 delete mode 100644 src/main/java/org/olat/group/ui/main/AdminBusinessGroupSearchController.java
 create mode 100644 src/main/java/org/olat/group/ui/wizard/BGCopyBusinessGroup.java

diff --git a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/FormLinkImpl.java b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/FormLinkImpl.java
index f5627a8fa48..93cdb4fa816 100644
--- a/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/FormLinkImpl.java
+++ b/src/main/java/org/olat/core/gui/components/form/flexible/impl/elements/FormLinkImpl.java
@@ -117,6 +117,10 @@ public class FormLinkImpl extends FormItemImpl implements FormLink {
 			if(customDisabledLinkCSS != null){
 				this.component.setCustomDisabledLinkCSS(customDisabledLinkCSS);
 			}
+			if ((presentation - Link.FLEXIBLEFORMLNK - Link.NONTRANSLATED) >= 0) {
+				// don't translate non-tranlated links
+				this.component.setCustomDisplayText(i18n);					
+			}
 		} else {
 			this.component = FormLinkFactory.createFormLink(name, this.getRootForm());
 			// set link text
diff --git a/src/main/java/org/olat/core/gui/control/generic/wizard/BasicStep.java b/src/main/java/org/olat/core/gui/control/generic/wizard/BasicStep.java
index 64638fcec10..26ef9c7c8f8 100644
--- a/src/main/java/org/olat/core/gui/control/generic/wizard/BasicStep.java
+++ b/src/main/java/org/olat/core/gui/control/generic/wizard/BasicStep.java
@@ -33,6 +33,7 @@ import org.olat.core.gui.components.form.flexible.elements.FormLink;
 import org.olat.core.gui.components.form.flexible.impl.Form;
 import org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl;
 import org.olat.core.gui.components.form.flexible.impl.elements.StaticTextElementImpl;
+import org.olat.core.gui.components.link.Link;
 import org.olat.core.gui.control.WindowControl;
 import org.olat.core.gui.translator.Translator;
 import org.olat.core.id.Identity;
@@ -55,6 +56,7 @@ public abstract class BasicStep implements Step {
 	private Step nextStep;
 	private String i18nStepTitle;
 	private String i18nStepDescription;
+	private String[] i18nArguments;
 
 	public BasicStep(UserRequest ureq){
 		this.locale = ureq.getLocale();
@@ -88,7 +90,14 @@ public abstract class BasicStep implements Step {
 		if(i18nStepTitle == null){
 			throw new AssertException("no i18n key set for step title, or getStepTitle() not overridden.");
 		}
-		FormLink fl = new FormLinkImpl(i18nStepTitle, i18nStepTitle);
+		FormLink fl;
+		if(i18nArguments != null && i18nArguments.length > 0) {
+			String title = this.getTranslator().translate(i18nStepTitle, i18nArguments);
+			fl = new FormLinkImpl(i18nStepTitle, null, title, Link.FLEXIBLEFORMLNK + Link.NONTRANSLATED);
+		} else {
+			fl = new FormLinkImpl(i18nStepTitle, i18nStepTitle);
+		}
+		
 		fl.setTranslator(getTranslator());
 		return fl;
 	}
@@ -117,4 +126,9 @@ public abstract class BasicStep implements Step {
 		this.i18nStepTitle = i18nKeyTitle;
 		this.i18nStepDescription = i18nKeyDescription;
 	}
+	
+	protected void setI18nTitleAndDescr(String i18nKeyTitle, String i18nKeyDescription, String[] i18nArguments){
+		setI18nTitleAndDescr(i18nKeyTitle, i18nKeyDescription);
+		this.i18nArguments = i18nArguments;
+	}
 }
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 2d2fa1afebb..43357a1a786 100644
--- a/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java
+++ b/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java
@@ -63,6 +63,7 @@ import org.olat.group.GroupLoggingAction;
 import org.olat.group.model.BGRepositoryEntryRelation;
 import org.olat.group.model.SearchBusinessGroupParams;
 import org.olat.group.ui.NewBGController;
+import org.olat.group.ui.wizard.BGCopyBusinessGroup;
 import org.olat.group.ui.wizard.BGCopyPreparationStep;
 import org.olat.group.ui.wizard.BGEmailSelectReceiversStep;
 import org.olat.group.ui.wizard.BGMergeStep;
@@ -376,7 +377,29 @@ abstract class AbstractBusinessGroupListController extends BasicController {
 		StepRunnerCallback finish = new StepRunnerCallback() {
 			@Override
 			public Step execute(UserRequest ureq, WindowControl wControl, StepsRunContext runContext) {
-				return StepsMainRunController.DONE_MODIFIED;
+				@SuppressWarnings("unchecked")
+				List<BGCopyBusinessGroup> copies = (List<BGCopyBusinessGroup>)runContext.get("groupsCopy");
+				if(copies != null && !copies.isEmpty()) {
+					boolean copyAreas = convertToBoolean(runContext, "areas");
+					boolean copyCollabToolConfig = convertToBoolean(runContext, "tools");
+					boolean copyRights = convertToBoolean(runContext, "rights");
+					boolean copyOwners = convertToBoolean(runContext, "owners");
+					boolean copyParticipants = convertToBoolean(runContext, "participants");
+					boolean copyMemberVisibility = convertToBoolean(runContext, "membersvisibility");
+					boolean copyWaitingList = convertToBoolean(runContext, "waitingList");
+					boolean copyRelations = convertToBoolean(runContext, "resources");
+
+					for(BGCopyBusinessGroup copy:copies) {
+						businessGroupService.copyBusinessGroup(copy.getOriginal(), copy.getName(), copy.getDescription(),
+								copy.getMinParticipants(), copy.getMaxParticipants(), null, null,
+								copyAreas, copyCollabToolConfig, copyRights, copyOwners, copyParticipants,
+								copyMemberVisibility, copyWaitingList, copyRelations);
+					
+					}
+					return StepsMainRunController.DONE_MODIFIED;
+				} else {
+					return StepsMainRunController.DONE_UNCHANGED;
+				}
 			}
 		};
 		
@@ -385,6 +408,17 @@ abstract class AbstractBusinessGroupListController extends BasicController {
 		getWindowControl().pushAsModalDialog(businessGroupWizard.getInitialComponent());
 	}
 	
+	private boolean convertToBoolean(StepsRunContext runContext, String key) {
+		Object obj = runContext.get(key);
+		if(obj instanceof Boolean) {
+			return ((Boolean)obj).booleanValue();
+		} else {
+			return false;
+		}
+		
+		
+	}
+	
 	/**
 	 * 
 	 * @param ureq
diff --git a/src/main/java/org/olat/group/ui/main/AdminBusinessGroupSearchController.java b/src/main/java/org/olat/group/ui/main/AdminBusinessGroupSearchController.java
deleted file mode 100644
index ea9943db398..00000000000
--- a/src/main/java/org/olat/group/ui/main/AdminBusinessGroupSearchController.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * <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.control.WindowControl;
-
-/**
- * 
- * Description:<br>
- * Search form for Business groups
- * 
- * <P>
- * Initial Date:  21 avr. 2011 <br>
- * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
- */
-//fxdiff VCRP-1,2: access control of resources
-public class AdminBusinessGroupSearchController extends BusinessGroupSearchController{
-
-	/**
-	 * Generic search form.
-	 * @param name Internal form name.
-	 * @param translator Translator
-	 * @param withCancel Display a cancel button?
-	 * @param isAdmin Is calling identity an administrator? If yes, allow search by ID
-	 * @param limitTypes Limit searches to specific types.
-	 */
-	public AdminBusinessGroupSearchController(UserRequest ureq, WindowControl wControl) {
-		super(ureq, wControl, true);
-	}
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/olat/group/ui/main/AdminBusinessGroupsController.java b/src/main/java/org/olat/group/ui/main/AdminBusinessGroupsController.java
index d7d859dc73b..558f6a7f703 100644
--- a/src/main/java/org/olat/group/ui/main/AdminBusinessGroupsController.java
+++ b/src/main/java/org/olat/group/ui/main/AdminBusinessGroupsController.java
@@ -37,16 +37,16 @@ import org.olat.group.ui.main.BusinessGroupTableModelWithType.Cols;
  */
 public class AdminBusinessGroupsController extends AbstractBusinessGroupListController {
 
-	private AdminBusinessGroupSearchController searchController;
+	private final BusinessGroupSearchController searchController;
 
 	public AdminBusinessGroupsController(UserRequest ureq, WindowControl wControl) {
 		super(ureq, wControl, "admin_group_list");
-		if(!isAdmin()) {
-			return;
+		if(isAdmin()) {
+			searchController = new BusinessGroupSearchController(ureq, wControl, true, false);
+		} else {
+			searchController = new BusinessGroupSearchController(ureq, wControl, false, true);
 		}
-		
 		//search controller
-		searchController = new AdminBusinessGroupSearchController(ureq, wControl);
 		listenTo(searchController);
 		mainVC.put("searchPanel", searchController.getInitialComponent());
 	}
@@ -96,6 +96,10 @@ public class AdminBusinessGroupsController extends AbstractBusinessGroupListCont
 		long start = isLogDebugEnabled() ? System.currentTimeMillis() : 0;
 
 		SearchBusinessGroupParams params = event.convertToSearchBusinessGroupParams(getIdentity());
+		params.setOwner(false);
+		params.setAttendee(false);
+		params.setWaiting(false);
+		
 		updateTableModel(params, false);
 
 		if(isLogDebugEnabled()) {
diff --git a/src/main/java/org/olat/group/ui/main/BGMainController.java b/src/main/java/org/olat/group/ui/main/BGMainController.java
index 7dfc6895f20..2ce9b31ab04 100644
--- a/src/main/java/org/olat/group/ui/main/BGMainController.java
+++ b/src/main/java/org/olat/group/ui/main/BGMainController.java
@@ -214,7 +214,7 @@ public class BGMainController extends MainLayoutBasicController implements Activ
 		listenTo(columnLayoutCtr);
 		putInitialPanel(columnLayoutCtr.getInitialComponent());
 		//fxdiff VCRP-1,2: access control of resources
-		searchController = new BusinessGroupSearchController(ureq, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin());
+		searchController = new BusinessGroupSearchController(ureq, getWindowControl(), ureq.getUserSession().getRoles().isOLATAdmin(), true);
 		listenTo(searchController);
 		
 		// start with list of all groups
diff --git a/src/main/java/org/olat/group/ui/main/BusinessGroupListController.java b/src/main/java/org/olat/group/ui/main/BusinessGroupListController.java
index f5dd829b17d..c1dd0ada8d6 100644
--- a/src/main/java/org/olat/group/ui/main/BusinessGroupListController.java
+++ b/src/main/java/org/olat/group/ui/main/BusinessGroupListController.java
@@ -51,7 +51,7 @@ public class BusinessGroupListController extends AbstractBusinessGroupListContro
 		super(ureq, wControl, "group_list");
 
 		//search controller
-		searchController = new BusinessGroupSearchController(ureq, wControl, isAdmin());
+		searchController = new BusinessGroupSearchController(ureq, wControl, isAdmin(), true);
 		listenTo(searchController);
 		mainVC.put("search", searchController.getInitialComponent());
 		searchController.getInitialComponent().setVisible(false);
diff --git a/src/main/java/org/olat/group/ui/main/BusinessGroupSearchController.java b/src/main/java/org/olat/group/ui/main/BusinessGroupSearchController.java
index 217e2df2acc..21f3dbedd92 100644
--- a/src/main/java/org/olat/group/ui/main/BusinessGroupSearchController.java
+++ b/src/main/java/org/olat/group/ui/main/BusinessGroupSearchController.java
@@ -54,8 +54,9 @@ public class BusinessGroupSearchController extends FormBasicController{
 	private SingleSelection publicEl;
 	private SingleSelection resourceEl;
 	
+	private final boolean showId;
+	private final boolean showRoles;
 	private String limitUsername;
-	private boolean isAdmin;
 	
 	private String[] roleKeys = {"all", "owner", "attendee", "waiting"};
 	private String[] openKeys = {"all", "yes", "no"};
@@ -69,9 +70,10 @@ public class BusinessGroupSearchController extends FormBasicController{
 	 * @param isAdmin Is calling identity an administrator? If yes, allow search by ID
 	 * @param limitTypes Limit searches to specific types.
 	 */
-	public BusinessGroupSearchController(UserRequest ureq, WindowControl wControl, boolean isAdmin) {
+	public BusinessGroupSearchController(UserRequest ureq, WindowControl wControl, boolean showId, boolean showRoles) {
 		super(ureq, wControl, "group_search");
-		this.isAdmin = isAdmin;
+		this.showId = showId;
+		this.showRoles = showRoles;
 		initForm(ureq);
 	}
 	
@@ -81,9 +83,8 @@ public class BusinessGroupSearchController extends FormBasicController{
 		leftContainer.setRootForm(mainForm);
 		formLayout.add(leftContainer);
 		
-		if(isAdmin) {
+		if(showId) {
 			id = uifactory.addTextElement("cif_id", "cif.id", 12, "", leftContainer);
-			id.setVisible(isAdmin);
 			id.setRegexMatchCheck("\\d*", "search.id.format");
 		}
 
@@ -104,12 +105,14 @@ public class BusinessGroupSearchController extends FormBasicController{
 		formLayout.add(rightContainer);
 		
 		//roles
-		String[] roleValues = new String[roleKeys.length];
-		for(int i=roleKeys.length; i-->0; ) {
-			roleValues[i] = translate("search." + roleKeys[i]);
+		if(showRoles) {
+			String[] roleValues = new String[roleKeys.length];
+			for(int i=roleKeys.length; i-->0; ) {
+				roleValues[i] = translate("search." + roleKeys[i]);
+			}
+			rolesEl = uifactory.addRadiosHorizontal("roles", "search.roles", rightContainer, roleKeys, roleValues);
+			rolesEl.select("all", true);
 		}
-		rolesEl = uifactory.addRadiosHorizontal("roles", "search.roles", rightContainer, roleKeys, roleValues);
-		rolesEl.select("all", true);
 
 		//public
 		String[] openValues = new String[openKeys.length];
@@ -226,7 +229,7 @@ public class BusinessGroupSearchController extends FormBasicController{
 		e.setOwnerName(getOwner());
 		e.setCourseTitle(getCourseTitle());
 		
-		if(rolesEl.isOneSelected()) {
+		if(rolesEl != null && rolesEl.isOneSelected()) {
 			e.setAttendee(rolesEl.isSelected(0) || rolesEl.isSelected(1));
 			e.setOwner(rolesEl.isSelected(0) || rolesEl.isSelected(2));
 			e.setWaiting(rolesEl.isSelected(0) || rolesEl.isSelected(3));
diff --git a/src/main/java/org/olat/group/ui/wizard/BGCopyBusinessGroup.java b/src/main/java/org/olat/group/ui/wizard/BGCopyBusinessGroup.java
new file mode 100644
index 00000000000..16387c2cec3
--- /dev/null
+++ b/src/main/java/org/olat/group/ui/wizard/BGCopyBusinessGroup.java
@@ -0,0 +1,94 @@
+/**
+ * <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.wizard;
+
+import org.olat.group.BusinessGroup;
+import org.olat.group.BusinessGroupShort;
+
+/**
+ * 
+ * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
+ */
+public class BGCopyBusinessGroup implements BusinessGroupShort {
+
+	private String name;
+	private String description;
+	private Integer minParticipants;
+	private Integer maxParticipants;
+	
+	private final BusinessGroup original;
+	
+	public BGCopyBusinessGroup(BusinessGroup original) {
+		this.original = original;
+	}
+	
+	
+	@Override
+	public Long getKey() {
+		return null;
+	}
+
+	@Override
+	public Long getResourceableId() {
+		return null;
+	}
+
+	@Override
+	public String getResourceableTypeName() {
+		return "BusinessGroup";
+	}
+
+	public BusinessGroup getOriginal() {
+		return original;
+	}
+
+	@Override
+	public String getName() {
+		return name;
+	}
+	
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	public String getDescription() {
+		return description;
+	}
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+	public Integer getMinParticipants() {
+		return minParticipants;
+	}
+
+	public void setMinParticipants(Integer minParticipants) {
+		this.minParticipants = minParticipants;
+	}
+
+	public Integer getMaxParticipants() {
+		return maxParticipants;
+	}
+
+	public void setMaxParticipants(Integer maxParticipants) {
+		this.maxParticipants = maxParticipants;
+	}
+}
diff --git a/src/main/java/org/olat/group/ui/wizard/BGCopyPreparationStepController.java b/src/main/java/org/olat/group/ui/wizard/BGCopyPreparationStepController.java
index 2599735c2cd..a4b8304e42b 100644
--- a/src/main/java/org/olat/group/ui/wizard/BGCopyPreparationStepController.java
+++ b/src/main/java/org/olat/group/ui/wizard/BGCopyPreparationStepController.java
@@ -65,40 +65,47 @@ public class BGCopyPreparationStepController extends StepFormBasicController {
 		initForm(ureq);
 	}
 
-	public boolean isCopyTools() {
+	public Boolean getCopyTools() {
 		return getBool("Tools");
 	}
 	
-	public boolean isCopyAreas() {
+	public Boolean getCopyAreas() {
 		return getBool("Areas");
 	}
 	
-	public boolean isCopyOwners() {
+	public Boolean getCopyOwners() {
 		return getBool("Owners");
 	}
 	
-	public boolean isCopyRights() {
+	public Boolean getCopyRights() {
 		return getBool("Rights");
 	}
 	
-	public boolean isCopyParticipants() {
+	public Boolean getCopyParticipants() {
 		return getBool("Participants");
 	}
 	
-	public boolean isCopyMembersVisibility() {
+	public Boolean getCopyMembersVisibility() {
 		return getBool("MembersVisibility");
 	}
 	
-	public boolean isCopyWaitingList() {
+	public Boolean getCopyWaitingList() {
 		return getBool("WaitingList");
 	}
 
-	private boolean getBool (String k) {
-		return ce.isSelected(Arrays.asList(keys).indexOf(k));
+	private Boolean getBool (String k) {
+		return new Boolean(ce.isSelected(Arrays.asList(keys).indexOf(k)));
 	}
 	
 	@Override
 	protected void formOK(UserRequest ureq) {
+		addToRunContext("tools", getCopyTools());
+		addToRunContext("areas", getCopyAreas());
+		addToRunContext("rights", getCopyRights());
+		addToRunContext("owners", getCopyOwners());
+		addToRunContext("participants", getCopyParticipants());
+		addToRunContext("membersvisibility", getCopyMembersVisibility());
+		addToRunContext("waitingList", getCopyWaitingList());
 		fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
 	}
 
diff --git a/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStep.java b/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStep.java
index aaa0f54c081..2d812be7a23 100644
--- a/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStep.java
+++ b/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStep.java
@@ -22,7 +22,11 @@ package org.olat.group.ui.wizard;
 import java.util.List;
 
 import org.olat.core.gui.UserRequest;
+import org.olat.core.gui.components.form.flexible.FormItem;
+import org.olat.core.gui.components.form.flexible.elements.FormLink;
 import org.olat.core.gui.components.form.flexible.impl.Form;
+import org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl;
+import org.olat.core.gui.components.link.Link;
 import org.olat.core.gui.control.WindowControl;
 import org.olat.core.gui.control.generic.wizard.BasicStep;
 import org.olat.core.gui.control.generic.wizard.PrevNextFinishConfig;
@@ -54,6 +58,14 @@ public class BGCopySingleGroupStep extends BasicStep {
 		}
 	}
 
+	@Override
+	public FormItem getStepTitle() {
+		String title = getTranslator().translate("copy.wizard.bgstep", new String[]{ groupToCopy.getName() });
+		FormLink fl = new FormLinkImpl("copy.wizard." + groupToCopy.getKey(), null, title, Link.FLEXIBLEFORMLNK + Link.NONTRANSLATED);
+		fl.setTranslator(getTranslator());
+		return fl;
+	}
+
 	@Override
 	public PrevNextFinishConfig getInitialPrevNextFinishConfig() {
 		if(lastGroup) {
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 aa7070281f8..abaaf1137a0 100644
--- a/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStepController.java
+++ b/src/main/java/org/olat/group/ui/wizard/BGCopySingleGroupStepController.java
@@ -19,6 +19,9 @@
  */
 package org.olat.group.ui.wizard;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.olat.core.gui.UserRequest;
 import org.olat.core.gui.components.form.flexible.FormItemContainer;
 import org.olat.core.gui.components.form.flexible.impl.Form;
@@ -68,7 +71,36 @@ public class BGCopySingleGroupStepController extends StepFormBasicController   {
 
 	@Override
 	protected void formOK(UserRequest ureq) {
-		String copyName = groupController.getGroupName();
+		@SuppressWarnings("unchecked")
+		List<BGCopyBusinessGroup> copies = (List<BGCopyBusinessGroup>)getFromRunContext("groupsCopy");
+		if(copies == null) {
+			copies = new ArrayList<BGCopyBusinessGroup>();
+			addToRunContext("groupsCopy", copies);
+		}
+		
+		BGCopyBusinessGroup currentCopy = getWithOriginal(copies);
+		if(currentCopy == null) {
+			BGCopyBusinessGroup group = new BGCopyBusinessGroup(originalGroup);
+			group.setName(groupController.getGroupName());
+			group.setDescription(groupController.getGroupDescription());
+			group.setMinParticipants(groupController.getGroupMin());
+			group.setMaxParticipants(groupController.getGroupMax());
+			copies.add(group);
+		} else {
+			currentCopy.setName(groupController.getGroupName());
+			currentCopy.setDescription(groupController.getGroupDescription());
+			currentCopy.setMinParticipants(groupController.getGroupMin());
+			currentCopy.setMaxParticipants(groupController.getGroupMax());
+		}
 		fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
 	}
+	
+	private BGCopyBusinessGroup getWithOriginal(List<BGCopyBusinessGroup> copies) {
+		for(BGCopyBusinessGroup copy:copies) {
+			if(copy.getOriginal().equals(originalGroup)) {
+				return copy;
+			}
+		}
+		return null;
+	}
 }
-- 
GitLab