Search in sources :

Example 51 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.

the class PortfolioHandler method createResource.

@Override
public RepositoryEntry createResource(Identity initialAuthor, String displayname, String description, Object createObject, Locale locale) {
    EPFrontendManager ePFMgr = CoreSpringFactory.getImpl(EPFrontendManager.class);
    EPStructureManager eSTMgr = CoreSpringFactory.getImpl(EPStructureManager.class);
    RepositoryService repositoryService = CoreSpringFactory.getImpl(RepositoryService.class);
    OLATResource resource = eSTMgr.createPortfolioMapTemplateResource();
    RepositoryEntry re = repositoryService.create(initialAuthor, null, "", displayname, description, resource, RepositoryEntry.ACC_OWNERS);
    PortfolioStructureMap mapTemp = eSTMgr.createAndPersistPortfolioMapTemplateFromEntry(initialAuthor, re);
    // add a page, as each map should have at least one per default!
    Translator pt = Util.createPackageTranslator(EPCreateMapController.class, locale);
    String pageTitle = pt.translate("new.page.title");
    String pageDescription = pt.translate("new.page.desc");
    ePFMgr.createAndPersistPortfolioPage(mapTemp, pageTitle, pageDescription);
    DBFactory.getInstance().commit();
    return re;
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) Translator(org.olat.core.gui.translator.Translator) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) EPFrontendManager(org.olat.portfolio.manager.EPFrontendManager) EPStructureManager(org.olat.portfolio.manager.EPStructureManager) RepositoryService(org.olat.repository.RepositoryService)

Example 52 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.

the class AbstractPortfolioMapIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext searchResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    if (!portfolioModule.isEnabled())
        return;
    SearchResourceContext resourceContext = new SearchResourceContext();
    int firstResult = 0;
    List<PortfolioStructure> structures = null;
    do {
        structures = frontendManager.getStructureElements(firstResult, 500, getElementType());
        for (PortfolioStructure structure : structures) {
            if (structure instanceof PortfolioStructureMap) {
                PortfolioStructureMap map = (PortfolioStructureMap) structure;
                if (accept(map)) {
                    resourceContext.setDocumentType(getDocumentType());
                    resourceContext.setBusinessControlFor(map.getOlatResource());
                    Document document = PortfolioMapDocument.createDocument(resourceContext, map);
                    indexerWriter.addDocument(document);
                }
            }
        }
        firstResult += structures.size();
    } while (structures != null && structures.size() == BATCH_SIZE);
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) SearchResourceContext(org.olat.search.service.SearchResourceContext) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) PortfolioMapDocument(org.olat.search.service.document.PortfolioMapDocument) Document(org.apache.lucene.document.Document)

Example 53 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.

the class EPMultipleMapController method event.

/**
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    super.event(ureq, source, event);
    if (source == delMapCtrl) {
        if (DialogBoxUIFactory.isYesEvent(event)) {
            PortfolioStructure mapToDel = (PortfolioStructure) ((DialogBoxController) source).getUserObject();
            String title = mapToDel.getTitle();
            ePFMgr.deletePortfolioStructure(mapToDel);
            showInfo("delete.map.success", title);
            ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(mapToDel));
            ThreadLocalUserActivityLogger.log(EPLoggingAction.EPORTFOLIO_MAP_REMOVED, getClass());
            initOrUpdateMaps(ureq);
        }
    } else if (source == copyMapCtrl) {
        if (event.equals(Event.CANCELLED_EVENT)) {
            fireEvent(ureq, Event.CANCELLED_EVENT);
            return;
        }
        int pos = DialogBoxUIFactory.getButtonPos(event);
        boolean withArtefacts = false;
        PortfolioStructure mapToCopy = (PortfolioStructure) ((DialogBoxController) source).getUserObject();
        // shift clicked pos, when "with artefacts" was hidden before
        if (!ePFMgr.isMapOwner(getIdentity(), mapToCopy))
            pos++;
        if (pos == 2) {
            // clicked cancel button
            fireEvent(ureq, Event.CANCELLED_EVENT);
            return;
        } else if (pos == 0)
            withArtefacts = true;
        PortfolioStructureMap targetMap = ePFMgr.createAndPersistPortfolioDefaultMap(getIdentity(), translate("map.copy.of", mapToCopy.getTitle()), mapToCopy.getDescription());
        ePFMgr.copyStructureRecursively(mapToCopy, targetMap, withArtefacts);
        // open the map
        String title = targetMap.getTitle();
        showInfo("copy.map.success", title);
        initOrUpdateMaps(ureq);
        String businessPath = "[" + targetMap.getClass().getSimpleName() + ":" + targetMap.getResourceableId() + "]";
        NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
    } else if (source == mapViewCtrl) {
        if (EPStructureEvent.CLOSE.equals(event.getCommand())) {
            myPanel.popContent();
            fireEvent(ureq, event);
            removeAsListenerAndDispose(mapViewCtrl);
            mapViewCtrl = null;
            // refresh on close (back-link) to prevent stale object errors, when map got changed meanwhile
            initOrUpdateMaps(ureq);
            addToHistory(ureq);
        } else if (EPStructureEvent.SUBMIT.equals(event.getCommand()) || event.equals(Event.CHANGED_EVENT)) {
            // refresh on submission of a map or on any other changes which needs an ui-update
            initOrUpdateMaps(ureq);
        }
    } else if (source == shareListController) {
        shareBox.deactivate();
        removeAsListenerAndDispose(shareListController);
        initOrUpdateMaps(ureq);
    }
    if (event instanceof EPStructureChangeEvent) {
        // event from child
        String evCmd = event.getCommand();
        if (evCmd.equals(EPStructureChangeEvent.ADDED) || evCmd.equals(EPStructureChangeEvent.CHANGED)) {
            initOrUpdateMaps(ureq);
        }
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap) PortfolioStructure(org.olat.portfolio.model.structel.PortfolioStructure) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController)

Example 54 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.

the class EPMultipleMapController method activateMap.

private void activateMap(UserRequest ureq, Long mapKey) {
    if (mapKey == null)
        return;
    boolean foundTheMap = false;
    // we have a key, find the corresponding map with the current option (restrcited view or not)
    for (PortfolioStructureMap map : userMaps) {
        if (map.getKey().equals(mapKey) || (map.getResourceableId().equals(mapKey))) {
            activateMap(ureq, map);
            fireEvent(ureq, new EPMapEvent(EPStructureEvent.SELECT, map));
            foundTheMap = true;
            break;
        }
    }
    if (!foundTheMap) {
        // map not found, switch the option and retry to found the map
        restrictShareView = !restrictShareView;
        initOrUpdateMaps(ureq);
        for (PortfolioStructureMap map : userMaps) {
            if (map.getKey().equals(mapKey) || (map.getResourceableId().equals(mapKey))) {
                activateMap(ureq, map);
                fireEvent(ureq, new EPMapEvent(EPStructureEvent.SELECT, map));
                break;
            }
        }
    }
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap)

Example 55 with PortfolioStructureMap

use of org.olat.portfolio.model.structel.PortfolioStructureMap in project openolat by klemens.

the class EPCreateMapController method formOK.

/**
 * @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#formOK(org.olat.core.gui.UserRequest)
 */
@Override
protected void formOK(UserRequest ureq) {
    String mapTitle = titleEl.getValue();
    String mapDesc = descEl.getValue();
    PortfolioStructureMap resMap = ePFMgr.createAndPersistPortfolioDefaultMap(getIdentity(), mapTitle, mapDesc);
    // add a page, as each map should have at least one per default!
    String title = translate("new.page.title");
    String description = translate("new.page.desc");
    ePFMgr.createAndPersistPortfolioPage(resMap, title, description);
    // refresh to get all elements with db-keys
    resMap = (PortfolioStructureMap) ePFMgr.loadPortfolioStructureByKey(resMap.getKey());
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(resMap));
    ThreadLocalUserActivityLogger.log(EPLoggingAction.EPORTFOLIO_MAP_CREATED, getClass());
    fireEvent(ureq, new EPMapCreatedEvent(resMap));
}
Also used : PortfolioStructureMap(org.olat.portfolio.model.structel.PortfolioStructureMap)

Aggregations

PortfolioStructureMap (org.olat.portfolio.model.structel.PortfolioStructureMap)118 Test (org.junit.Test)64 PortfolioStructure (org.olat.portfolio.model.structel.PortfolioStructure)54 Identity (org.olat.core.id.Identity)34 RepositoryEntry (org.olat.repository.RepositoryEntry)30 OLATResource (org.olat.resource.OLATResource)30 ArrayList (java.util.ArrayList)18 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)18 EPStructuredMap (org.olat.portfolio.model.structel.EPStructuredMap)18 EPMapPolicy (org.olat.portfolio.manager.EPMapPolicy)16 Date (java.util.Date)10 Invitation (org.olat.basesecurity.Invitation)8 Binder (org.olat.modules.portfolio.Binder)8 EPTargetResource (org.olat.portfolio.model.structel.EPTargetResource)8 EPSecurityCallback (org.olat.portfolio.EPSecurityCallback)6 EPStructureElement (org.olat.portfolio.model.structel.EPStructureElement)6 CalendarController (org.olat.commons.calendar.ui.CalendarController)4 WeeklyCalendarController (org.olat.commons.calendar.ui.WeeklyCalendarController)4 FolderRunController (org.olat.core.commons.modules.bc.FolderRunController)4 Link (org.olat.core.gui.components.link.Link)4