Search in sources :

Example 1 with BGCopyBusinessGroup

use of org.olat.group.ui.wizard.BGCopyBusinessGroup in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method doCopy.

/**
 * Make copies of a list of business groups
 * @param ureq
 * @param items
 */
private void doCopy(UserRequest ureq, List<? extends BusinessGroupRef> items) {
    removeAsListenerAndDispose(businessGroupWizard);
    if (items == null || items.isEmpty()) {
        showWarning("error.select.one");
        return;
    }
    List<BusinessGroup> groups = toBusinessGroups(ureq, items, true);
    if (groups.isEmpty()) {
        showWarning("msg.alleastone.editable.group");
        return;
    }
    if (items.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    boolean enableCoursesCopy = businessGroupService.hasResources(groups);
    boolean enableAreasCopy = areaManager.countBGAreasOfBusinessGroups(groups) > 0;
    boolean enableRightsCopy = rightManager.hasBGRight(groups);
    Step start = new BGCopyPreparationStep(ureq, groups, enableCoursesCopy, enableAreasCopy, enableRightsCopy);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            @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(getIdentity(), copy.getOriginal(), copy.getName(), copy.getDescription(), copy.getMinParticipants(), copy.getMaxParticipants(), copyAreas, copyCollabToolConfig, copyRights, copyOwners, copyParticipants, copyMemberVisibility, copyWaitingList, copyRelations);
                }
                return StepsMainRunController.DONE_MODIFIED;
            } else {
                return StepsMainRunController.DONE_UNCHANGED;
            }
        }
    };
    businessGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("copy.group"), "o_sel_group_copy_wizard");
    listenTo(businessGroupWizard);
    getWindowControl().pushAsModalDialog(businessGroupWizard.getInitialComponent());
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Example 2 with BGCopyBusinessGroup

use of org.olat.group.ui.wizard.BGCopyBusinessGroup in project openolat by klemens.

the class AbstractBusinessGroupListController method doCopy.

/**
 * Make copies of a list of business groups
 * @param ureq
 * @param items
 */
private void doCopy(UserRequest ureq, List<? extends BusinessGroupRef> items) {
    removeAsListenerAndDispose(businessGroupWizard);
    if (items == null || items.isEmpty()) {
        showWarning("error.select.one");
        return;
    }
    List<BusinessGroup> groups = toBusinessGroups(ureq, items, true);
    if (groups.isEmpty()) {
        showWarning("msg.alleastone.editable.group");
        return;
    }
    if (items.size() != groups.size()) {
        showWarning("msg.only.editable.group");
        return;
    }
    boolean enableCoursesCopy = businessGroupService.hasResources(groups);
    boolean enableAreasCopy = areaManager.countBGAreasOfBusinessGroups(groups) > 0;
    boolean enableRightsCopy = rightManager.hasBGRight(groups);
    Step start = new BGCopyPreparationStep(ureq, groups, enableCoursesCopy, enableAreasCopy, enableRightsCopy);
    StepRunnerCallback finish = new StepRunnerCallback() {

        @Override
        public Step execute(UserRequest uureq, WindowControl wControl, StepsRunContext runContext) {
            @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(getIdentity(), copy.getOriginal(), copy.getName(), copy.getDescription(), copy.getMinParticipants(), copy.getMaxParticipants(), copyAreas, copyCollabToolConfig, copyRights, copyOwners, copyParticipants, copyMemberVisibility, copyWaitingList, copyRelations);
                }
                return StepsMainRunController.DONE_MODIFIED;
            } else {
                return StepsMainRunController.DONE_UNCHANGED;
            }
        }
    };
    businessGroupWizard = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("copy.group"), "o_sel_group_copy_wizard");
    listenTo(businessGroupWizard);
    getWindowControl().pushAsModalDialog(businessGroupWizard.getInitialComponent());
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) Step(org.olat.core.gui.control.generic.wizard.Step) BGCopyPreparationStep(org.olat.group.ui.wizard.BGCopyPreparationStep) BGMergeStep(org.olat.group.ui.wizard.BGMergeStep) BGConfigToolsStep(org.olat.group.ui.wizard.BGConfigToolsStep) BGEmailSelectReceiversStep(org.olat.group.ui.wizard.BGEmailSelectReceiversStep) WindowControl(org.olat.core.gui.control.WindowControl) StepsRunContext(org.olat.core.gui.control.generic.wizard.StepsRunContext) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback) UserRequest(org.olat.core.gui.UserRequest)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 UserRequest (org.olat.core.gui.UserRequest)2 WindowControl (org.olat.core.gui.control.WindowControl)2 Step (org.olat.core.gui.control.generic.wizard.Step)2 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)2 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)2 StepsRunContext (org.olat.core.gui.control.generic.wizard.StepsRunContext)2 ContactList (org.olat.core.util.mail.ContactList)2 BusinessGroup (org.olat.group.BusinessGroup)2 BGConfigBusinessGroup (org.olat.group.ui.wizard.BGConfigBusinessGroup)2 BGConfigToolsStep (org.olat.group.ui.wizard.BGConfigToolsStep)2 BGCopyBusinessGroup (org.olat.group.ui.wizard.BGCopyBusinessGroup)2 BGCopyPreparationStep (org.olat.group.ui.wizard.BGCopyPreparationStep)2 BGEmailSelectReceiversStep (org.olat.group.ui.wizard.BGEmailSelectReceiversStep)2 BGMergeStep (org.olat.group.ui.wizard.BGMergeStep)2