Search in sources :

Example 21 with CollectRestriction

use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.

the class EPStructureManager method copyOrUpdateCollectRestriction.

/**
 * @param source
 * @param target
 * @param update if true, the old existing restrictions will be overwritten
 */
private void copyOrUpdateCollectRestriction(PortfolioStructure source, PortfolioStructure target, boolean update) {
    if (source == null || target == null) {
        return;
    }
    List<CollectRestriction> targetRestrictions = target.getCollectRestrictions();
    if ((source.getCollectRestrictions() == null || source.getCollectRestrictions().isEmpty()) && (target.getCollectRestrictions() != null && !target.getCollectRestrictions().isEmpty()) && update) {
        // remove former existing restrictions
        targetRestrictions.clear();
        return;
    }
    if (update) {
        targetRestrictions.clear();
    }
    for (CollectRestriction sourceRestriction : source.getCollectRestrictions()) {
        CollectRestriction targetRestriction = new CollectRestriction();
        targetRestriction.setArtefactType(sourceRestriction.getArtefactType());
        targetRestriction.setAmount(sourceRestriction.getAmount());
        targetRestriction.setRestriction(sourceRestriction.getRestriction());
        targetRestrictions.add(targetRestriction);
    }
}
Also used : CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Example 22 with CollectRestriction

use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.

the class EPPageViewController method init.

private void init(UserRequest ureq) {
    vC.contextPut("page", page);
    PortfolioStructureMap parentOfPage = (PortfolioStructureMap) ePFMgr.loadStructureParent(page);
    boolean parentMapClosed = StructureStatusEnum.CLOSED.equals(parentOfPage.getStatus());
    vC.remove(vC.getComponent("checkResults"));
    if (secCallback.isRestrictionsEnabled()) {
        removeAsListenerAndDispose(resultCtrl);
        List<CollectRestriction> restrictions = page.getCollectRestrictions();
        if (!restrictions.isEmpty()) {
            boolean check = ePFMgr.checkCollectRestriction(page);
            resultCtrl = new EPCollectRestrictionResultController(ureq, getWindowControl());
            resultCtrl.setMessage(restrictions, check);
            vC.put("checkResults", resultCtrl.getInitialComponent());
            listenTo(resultCtrl);
        }
    }
    vC.remove(vC.getComponent("artefacts"));
    List<AbstractArtefact> artefacts = ePFMgr.getArtefacts(page);
    if (artefacts.size() != 0) {
        EPMultiArtefactsController artefactCtrl = EPUIFactory.getConfigDependentArtefactsControllerForStructure(ureq, getWindowControl(), artefacts, page, secCallback);
        vC.put("artefacts", artefactCtrl.getInitialComponent());
        listenTo(artefactCtrl);
    }
    vC.remove(vC.getComponent("structElements"));
    List<PortfolioStructure> structElements = ePFMgr.loadStructureChildren(page);
    if (structElements.size() != 0) {
        EPStructureElementsController structElCtrl = new EPStructureElementsController(ureq, getWindowControl(), structElements, secCallback, parentMapClosed);
        vC.put("structElements", structElCtrl.getInitialComponent());
        listenTo(structElCtrl);
    }
    vC.remove(vC.getComponent("addButton"));
    if (!parentMapClosed && (secCallback.canAddArtefact() || secCallback.canAddStructure())) {
        addButtonCtrl = new EPAddElementsController(ureq, getWindowControl(), page);
        listenTo(addButtonCtrl);
        if (secCallback.canAddArtefact()) {
            addButtonCtrl.setShowLink(EPAddElementsController.ADD_ARTEFACT);
        }
        if (secCallback.canAddStructure()) {
            addButtonCtrl.setShowLink(EPAddElementsController.ADD_STRUCTUREELEMENT);
        }
        vC.put("addButton", addButtonCtrl.getInitialComponent());
    }
    vC.remove(vC.getComponent("commentCtrl"));
    if (secCallback.canCommentAndRate()) {
        removeAsListenerAndDispose(commentsAndRatingCtr);
        boolean anonym = ureq.getUserSession().getRoles().isGuestOnly();
        CommentAndRatingSecurityCallback ratingSecCallback = new CommentAndRatingDefaultSecurityCallback(getIdentity(), false, anonym);
        commentsAndRatingCtr = new UserCommentsAndRatingsController(ureq, getWindowControl(), map.getOlatResource(), page.getKey().toString(), ratingSecCallback, true, true, true);
        listenTo(commentsAndRatingCtr);
        vC.put("commentCtrl", commentsAndRatingCtr.getInitialComponent());
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) EPCollectRestrictionResultController(org.olat.portfolio.ui.structel.edit.EPCollectRestrictionResultController) CommentAndRatingSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback) EPMultiArtefactsController(org.olat.portfolio.ui.artefacts.view.EPMultiArtefactsController) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) CommentAndRatingDefaultSecurityCallback(org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback) UserCommentsAndRatingsController(org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Example 23 with CollectRestriction

use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.

the class EPCollectRestrictionResultController method setMessage.

public void setMessage(List<CollectRestriction> restrictions, boolean passed) {
    List<String> errors = new ArrayList<String>();
    for (CollectRestriction restriction : restrictions) {
        String error = getMessage(restriction, getTranslator(), null);
        errors.add(error);
    }
    Boolean passedObj = new Boolean(passed);
    mainVc.contextPut("messages", errors);
    mainVc.contextPut("restrictionsPassed", passedObj);
    mainVc.setDirty(true);
}
Also used : ArrayList(java.util.ArrayList) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Example 24 with CollectRestriction

use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.

the class EPStructureDetailsController method formInnerEvent.

@Override
protected void formInnerEvent(final UserRequest ureq, final FormItem source, final FormEvent event) {
    if (source instanceof FormLink && source.getUserObject() instanceof CollectRestriction) {
        final CollectRestriction restriction = (CollectRestriction) source.getUserObject();
        if (source.getName().startsWith("collect.restriction.add.")) {
            addCollectRestriction(restriction);
        } else if (source.getName().startsWith("collect.restriction.del.")) {
            deleteCollectRestriction(restriction);
        }
        // secure title and description before redraw UI
        editStructure.setTitle(titleEl.getValue());
        editStructure.setDescription(descriptionEl.getValue());
        editStructure.setArtefactRepresentationMode(viewRadio.getSelectedKey());
        setCollectRestrictions();
        updateUI(ureq);
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 25 with CollectRestriction

use of org.olat.portfolio.model.restriction.CollectRestriction in project openolat by klemens.

the class EPStructureDetailsController method setCollectRestrictions.

protected void setCollectRestrictions() {
    if (restrictionElements == null || restrictionElements.isEmpty()) {
        return;
    }
    for (int i = 0; i < restrictionElements.size(); i++) {
        final SingleSelection restrictionElement = restrictionElements.get(i);
        final SingleSelection restrictToArtefactElement = restrictToArtefactElements.get(i);
        final TextElement amountElement = amountElements.get(i);
        final CollectRestriction cr = (CollectRestriction) restrictionElement.getUserObject();
        String restriction = "";
        if (restrictionElement.isOneSelected()) {
            restriction = restrictionElement.getSelectedKey();
        }
        String artefactType = "";
        if (restrictToArtefactElement.isOneSelected()) {
            artefactType = restrictToArtefactElement.getSelectedKey();
        }
        final String amount = amountElement.getValue();
        cr.setRestriction(restriction);
        cr.setArtefactType(artefactType);
        if (StringHelper.containsNonWhitespace(amount)) {
            try {
                cr.setAmount(Integer.parseInt(amount));
            } catch (final NumberFormatException e) {
                logWarn("Wrong format for number", e);
            }
        }
    }
}
Also used : RichTextElement(org.olat.core.gui.components.form.flexible.elements.RichTextElement) StaticTextElement(org.olat.core.gui.components.form.flexible.elements.StaticTextElement) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) CollectRestriction(org.olat.portfolio.model.restriction.CollectRestriction)

Aggregations

CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)26 ArrayList (java.util.ArrayList)10 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)10 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)8 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)8 StaticTextElement (org.olat.core.gui.components.form.flexible.elements.StaticTextElement)6 EPStructuredMapTemplate (org.olat.portfolio.model.structel.EPStructuredMapTemplate)6 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)4 RichTextElement (org.olat.core.gui.components.form.flexible.elements.RichTextElement)4 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)4 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)4 EPMultiArtefactsController (org.olat.portfolio.ui.artefacts.view.EPMultiArtefactsController)4 EPCollectRestrictionResultController (org.olat.portfolio.ui.structel.edit.EPCollectRestrictionResultController)4 CommentAndRatingDefaultSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback)2 CommentAndRatingSecurityCallback (org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback)2 UserCommentsAndRatingsController (org.olat.core.commons.services.commentAndRating.ui.UserCommentsAndRatingsController)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 Controller (org.olat.core.gui.control.Controller)2 BasicController (org.olat.core.gui.control.controller.BasicController)2 EPArtefactHandler (org.olat.portfolio.EPArtefactHandler)2