diff --git a/src/main/java/org/olat/group/BusinessGroupService.java b/src/main/java/org/olat/group/BusinessGroupService.java index 8dbb063456d4f412e4271c6ddbb13b27816b5a42..cd54c80d56705a3adb810b0e8f48aa317566f2c1 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 679dbedc7b9bcdf8e1061aa4d1b881ddc6dadc9d..6c565d2c0a48744c2e6525e49f2f2096124fb35e 100644 --- a/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java +++ b/src/main/java/org/olat/group/manager/BusinessGroupServiceImpl.java @@ -351,6 +351,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 f92a90cbdd67c9b3c812b3a404ec6b20ee3d52f9..d7d9f0759638b30f16554493d97cbd0c7a286d5b 100644 --- a/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java +++ b/src/main/java/org/olat/group/ui/main/AbstractBusinessGroupListController.java @@ -697,7 +697,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()); diff --git a/src/main/java/org/olat/modules/lecture/ui/coach/RepositoryEntriesListTableModel.java b/src/main/java/org/olat/modules/lecture/ui/coach/RepositoryEntriesListTableModel.java index 9f0e6ed98685710df908b866e0d46b9875524089..c6b262d99fca6b2c401a6ab86e6c86a54a8ab9bf 100644 --- a/src/main/java/org/olat/modules/lecture/ui/coach/RepositoryEntriesListTableModel.java +++ b/src/main/java/org/olat/modules/lecture/ui/coach/RepositoryEntriesListTableModel.java @@ -27,7 +27,6 @@ import org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFle import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiSortableColumnDef; import org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel; import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableDataModel; -import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableModelDelegate; import org.olat.modules.lecture.model.LectureRepositoryEntryInfos; import org.olat.repository.RepositoryEntry; import org.olat.repository.model.RepositoryEntryLifecycle; @@ -51,7 +50,7 @@ implements SortableFlexiTableDataModel<LectureRepositoryEntryInfos> { @Override public void sort(SortKey orderBy) { if(orderBy != null) { - List<LectureRepositoryEntryInfos> rows = new SortableFlexiTableModelDelegate<>(orderBy, this, locale).sort(); + List<LectureRepositoryEntryInfos> rows = new RepositoryEntriesListTableModelSortDelegate(orderBy, this, locale).sort(); super.setObjects(rows); } } diff --git a/src/main/java/org/olat/modules/lecture/ui/coach/RepositoryEntriesListTableModelSortDelegate.java b/src/main/java/org/olat/modules/lecture/ui/coach/RepositoryEntriesListTableModelSortDelegate.java new file mode 100644 index 0000000000000000000000000000000000000000..bed1288b6c309a82a1aaf3e60830eadf16110cdb --- /dev/null +++ b/src/main/java/org/olat/modules/lecture/ui/coach/RepositoryEntriesListTableModelSortDelegate.java @@ -0,0 +1,86 @@ +/** + * <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.modules.lecture.ui.coach; + +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; + +import org.olat.core.commons.persistence.SortKey; +import org.olat.core.gui.components.form.flexible.impl.elements.table.SortableFlexiTableModelDelegate; +import org.olat.modules.lecture.model.LectureRepositoryEntryInfos; +import org.olat.modules.lecture.ui.coach.RepositoryEntriesListTableModel.LectureRepoCols; +import org.olat.repository.RepositoryEntry; +import org.olat.repository.RepositoryEntryStatusEnum; + +/** + * + * Initial date: 13 mars 2020<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class RepositoryEntriesListTableModelSortDelegate extends SortableFlexiTableModelDelegate<LectureRepositoryEntryInfos> { + + public RepositoryEntriesListTableModelSortDelegate(SortKey orderBy, RepositoryEntriesListTableModel tableModel, Locale locale) { + super(orderBy, tableModel, locale); + } + + @Override + protected void sort(List<LectureRepositoryEntryInfos> rows) { + int columnIndex = getColumnIndex(); + if(LectureRepoCols.access.ordinal() == columnIndex) { + Collections.sort(rows, new AccessComparator()); + } else { + super.sort(rows); + } + } + + private class AccessComparator implements Comparator<LectureRepositoryEntryInfos> { + @Override + public int compare(LectureRepositoryEntryInfos o1, LectureRepositoryEntryInfos o2) { + if(o1 == null || o2 == null) { + return compareNullObjects(o1, o2); + } + + RepositoryEntry r1 = o1.getEntry(); + RepositoryEntry r2 = o2.getEntry(); + if(r1 == null || r2 == null) { + return compareNullObjects(r1, r2); + } + + RepositoryEntryStatusEnum s1 = r1.getEntryStatus(); + RepositoryEntryStatusEnum s2 = r2.getEntryStatus(); + if(s1 == null || s2 == null) { + return compareNullObjects(s1, s2); + } + + int c = s1.compareTo(s2); + if(c == 0) { + c = compareString(r1.getDisplayname(), r2.getDisplayname()); + } + if(c == 0) { + c = compareLongs(r1.getKey(), r2.getKey()); + } + return c; + } + } + +}