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

Merge remote-tracking branch 'origin/OpenOLAT_14.2'

parents d6585173 97d219de
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
......@@ -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,
......
......@@ -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
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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());
......
......@@ -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);
}
}
......
/**
* <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;
}
}
}
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