Search in sources :

Example 16 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.

the class CmdAddToEPortfolioImpl method execute.

/**
 * might return NULL!, if item clicked was removed meanwhile or if portfolio is disabled or if only the folder-artefact-handler is disabled.
 *
 * @see org.olat.core.commons.modules.bc.commands.FolderCommand#execute(org.olat.core.commons.modules.bc.components.FolderComponent,
 *      org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.WindowControl,
 *      org.olat.core.gui.translator.Translator)
 */
@Override
public Controller execute(FolderComponent folderComponent, UserRequest ureq, WindowControl wControl, Translator translator) {
    String pos = ureq.getParameter(ListRenderer.PARAM_EPORT);
    if (!StringHelper.containsNonWhitespace(pos)) {
        // somehow parameter did not make it to us
        status = FolderCommandStatus.STATUS_FAILED;
        getWindowControl().setError(translator.translate("failed"));
        return null;
    }
    status = FolderCommandHelper.sanityCheck(wControl, folderComponent);
    if (status == FolderCommandStatus.STATUS_SUCCESS) {
        currentItem = folderComponent.getCurrentContainerChildren().get(Integer.parseInt(pos));
        status = FolderCommandHelper.sanityCheck2(wControl, folderComponent, currentItem);
    }
    if (status == FolderCommandStatus.STATUS_FAILED) {
        return null;
    }
    if (portfolioV2Module.isEnabled()) {
        PortfolioService portfolioService = CoreSpringFactory.getImpl(PortfolioService.class);
        MediaHandler handler = null;
        String extension = FileUtils.getFileSuffix(currentItem.getName());
        if (StringHelper.containsNonWhitespace(extension)) {
            if ("jpg".equalsIgnoreCase(extension) || "jpeg".equalsIgnoreCase(extension) || "png".equalsIgnoreCase(extension) || "gif".equalsIgnoreCase(extension)) {
                handler = portfolioService.getMediaHandler(ImageHandler.IMAGE_TYPE);
            }
        // TODO video
        }
        if (handler == null) {
            handler = portfolioService.getMediaHandler(FileHandler.FILE_TYPE);
        }
        collectStepsCtrl = new CollectArtefactController(ureq, wControl, currentItem, handler, "");
    } else {
        EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(FileArtefact.FILE_ARTEFACT_TYPE);
        AbstractArtefact artefact = artHandler.createArtefact();
        artHandler.prefillArtefactAccordingToSource(artefact, currentItem);
        artefact.setAuthor(getIdentity());
        collectStepsCtrl = new ArtefactWizzardStepsController(ureq, wControl, artefact, currentItem.getParentContainer());
    }
    return collectStepsCtrl;
}
Also used : PortfolioService(org.olat.modules.portfolio.PortfolioService) MediaHandler(org.olat.modules.portfolio.MediaHandler) CollectArtefactController(org.olat.modules.portfolio.ui.wizard.CollectArtefactController) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 17 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.

the class EPArtefactWizzardStepCallback method execute.

/**
 * @see org.olat.core.gui.control.generic.wizard.StepRunnerCallback#execute(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.WindowControl,
 *      org.olat.core.gui.control.generic.wizard.StepsRunContext)
 */
@Override
public Step execute(UserRequest ureq2, WindowControl wControl, StepsRunContext runContext) {
    boolean hasChanges = false;
    if (runContext.containsKey("artefact")) {
        hasChanges = true;
        AbstractArtefact locArtefact = (AbstractArtefact) runContext.get("artefact");
        ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean("epFrontendManager");
        PortfolioModule portfolioModule = (PortfolioModule) CoreSpringFactory.getBean("portfolioModule");
        // set the defined signature level, if its not from inside olat
        if (locArtefact.getSignature() < 0 && ((runContext.containsKey("copyright.accepted") && (Boolean) runContext.get("copyright.accepted")) || !portfolioModule.isCopyrightStepEnabled())) {
            locArtefact.setSignature(-1 * locArtefact.getSignature());
        }
        ePFMgr.updateArtefact(locArtefact);
        if (runContext.containsKey("tempArtFolder")) {
            // a new text or file-artefact was created, copy everything to destination
            VFSContainer tmpFolder = (VFSContainer) runContext.get("tempArtFolder");
            copyFromTempToArtefactContainer(locArtefact, tmpFolder);
        } else if (tempUpload != null) {
            // an artefact was collected in bc, only copy the selected file
            copyFromBCToArtefactContainer(locArtefact, tempUpload);
        }
        // add to a structure if any was selected
        if (runContext.containsKey("selectedStructure")) {
            PortfolioStructure parentStructure = (PortfolioStructure) runContext.get("selectedStructure");
            if (parentStructure != null) {
                ePFMgr.addArtefactToStructure(ureq2.getIdentity(), locArtefact, parentStructure);
            }
        }
        @SuppressWarnings("unchecked") List<String> allTags = (List<String>) runContext.get("artefactTagsList");
        ePFMgr.setArtefactTags(ureq2.getIdentity(), locArtefact, allTags);
        ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(locArtefact));
        ThreadLocalUserActivityLogger.log(EPLoggingAction.EPORTFOLIO_ARTEFACT_ADDED, getClass());
    }
    return hasChanges ? StepsMainRunController.DONE_MODIFIED : StepsMainRunController.DONE_UNCHANGED;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) List(java.util.List) PortfolioModule(org.olat.portfolio.PortfolioModule)

Example 18 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.

the class EPArtefactPoolRunController method initTPAllView.

private void initTPAllView(UserRequest ureq) {
    filterSettings = new EPFilterSettings();
    List<AbstractArtefact> artefacts = ePFMgr.getArtefactPoolForUser(getIdentity());
    initMultiArtefactCtrl(ureq, artefacts);
    initFilterPanel(ureq, Filter.read_only);
    setSegmentContent(artCtrl);
    addToHistory(ureq, OresHelper.createOLATResourceableType("All"), null);
}
Also used : EPFilterSettings(org.olat.portfolio.model.EPFilterSettings) AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact)

Example 19 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.

the class ArtefactWizzardStepsController method prepareNewArtefact.

/**
 * @param ores
 * @param businessPath
 */
private void prepareNewArtefact() {
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(ores.getResourceableTypeName());
    AbstractArtefact artefact1 = artHandler.createArtefact();
    artefact1.setAuthor(getIdentity());
    artefact1.setCollectionDate(new Date());
    artefact1.setBusinessPath(businessPath);
    artHandler.prefillArtefactAccordingToSource(artefact1, ores);
    this.artefact = artefact1;
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) Date(java.util.Date)

Example 20 with AbstractArtefact

use of org.olat.portfolio.model.artefacts.AbstractArtefact in project OpenOLAT by OpenOLAT.

the class EPAddArtefactController method prepareNewTextArtefactWizzard.

/**
 * prepare a new text artefact and open with wizzard initialized with a
 * special first step for text-artefacts
 *
 * @param ureq
 */
private void prepareNewTextArtefactWizzard(UserRequest ureq) {
    EPArtefactHandler<?> artHandler = portfolioModule.getArtefactHandler(EPTextArtefact.TEXT_ARTEFACT_TYPE);
    AbstractArtefact artefact1 = artHandler.createArtefact();
    artefact1.setAuthor(getIdentity());
    artefact1.setSource(translate("text.artefact.source.info"));
    artefact1.setCollectionDate(new Date());
    artefact1.setSignature(-20);
    vfsTemp = ePFMgr.getArtefactsTempContainer(getIdentity());
    Step start = new EPCreateTextArtefactStep00(ureq, artefact1, preSelectedStruct, vfsTemp);
    StepRunnerCallback finish = new EPArtefactWizzardStepCallback(vfsTemp);
    collectStepsCtrl = new StepsMainRunController(ureq, getWindowControl(), start, finish, null, translate("create.text.artefact.wizzard.title"), "o_sel_artefact_add_wizard o_sel_artefact_add_text_wizard");
    listenTo(collectStepsCtrl);
    getWindowControl().pushAsModalDialog(collectStepsCtrl.getInitialComponent());
}
Also used : AbstractArtefact(org.olat.portfolio.model.artefacts.AbstractArtefact) StepsMainRunController(org.olat.core.gui.control.generic.wizard.StepsMainRunController) Step(org.olat.core.gui.control.generic.wizard.Step) Date(java.util.Date) StepRunnerCallback(org.olat.core.gui.control.generic.wizard.StepRunnerCallback)

Aggregations

AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)164 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)70 Test (org.junit.Test)54 ArrayList (java.util.ArrayList)36 Date (java.util.Date)20 PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)18 DBQuery (org.olat.core.commons.persistence.DBQuery)10 Link (org.olat.core.gui.components.link.Link)10 Identity (org.olat.core.id.Identity)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 CollectRestriction (org.olat.portfolio.model.restriction.CollectRestriction)10 List (java.util.List)8 EPFilterSettings (org.olat.portfolio.model.EPFilterSettings)8 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)6 Step (org.olat.core.gui.control.generic.wizard.Step)6 StepRunnerCallback (org.olat.core.gui.control.generic.wizard.StepRunnerCallback)6 StepsMainRunController (org.olat.core.gui.control.generic.wizard.StepsMainRunController)6 OLATResourceable (org.olat.core.id.OLATResourceable)6 EPAbstractMap (org.olat.portfolio.model.structel.EPAbstractMap)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6