Search in sources :

Example 6 with Media

use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.

the class CitationHandler method createMedia.

@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
    Media media = mediaDao.createMedia(title, description, (String) mediaObject, CITATION_MEDIA, businessPath, null, 60, author);
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    return media;
}
Also used : Media(org.olat.modules.portfolio.Media)

Example 7 with Media

use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.

the class MediaMetadataController method loadMetadata.

private void loadMetadata(VelocityContainer metaVC) {
    metaVC.contextPut("media", media);
    String author = userManager.getUserDisplayName(media.getAuthor());
    metaVC.contextPut("author", author);
    MediaHandler handler = portfolioService.getMediaHandler(media.getType());
    String type = translate("artefact." + handler.getType());
    metaVC.contextPut("mediaType", type);
    String iconCssClass = handler.getIconCssClass(media);
    if (StringHelper.containsNonWhitespace(iconCssClass)) {
        metaVC.contextPut("mediaIconCssClass", iconCssClass);
    }
    if (media.getCollectionDate() != null) {
        String collectionDate = Formatter.getInstance(getLocale()).formatDate(media.getCollectionDate());
        metaVC.contextPut("collectionDate", collectionDate);
    }
    if (StringHelper.containsNonWhitespace(media.getMetadataXml())) {
        Object metadata = MetadataXStream.get().fromXML(media.getMetadataXml());
        metaVC.contextPut("metadata", metadata);
    }
    List<Category> categories = portfolioService.getCategories(media);
    if (categories != null && categories.size() > 0) {
        List<String> categoriesList = categories.stream().map(c -> c.getName()).collect(Collectors.toList());
        metaVC.contextPut("categoriesList", categoriesList);
    }
}
Also used : Formatter(org.olat.core.util.Formatter) PortfolioService(org.olat.modules.portfolio.PortfolioService) WindowControl(org.olat.core.gui.control.WindowControl) Autowired(org.springframework.beans.factory.annotation.Autowired) Component(org.olat.core.gui.components.Component) Collectors(java.util.stream.Collectors) UserManager(org.olat.user.UserManager) Event(org.olat.core.gui.control.Event) BasicController(org.olat.core.gui.control.controller.BasicController) List(java.util.List) MetadataXStream(org.olat.modules.portfolio.manager.MetadataXStream) Category(org.olat.modules.portfolio.Category) Media(org.olat.modules.portfolio.Media) VelocityContainer(org.olat.core.gui.components.velocity.VelocityContainer) MediaHandler(org.olat.modules.portfolio.MediaHandler) StringHelper(org.olat.core.util.StringHelper) UserRequest(org.olat.core.gui.UserRequest) Category(org.olat.modules.portfolio.Category) MediaHandler(org.olat.modules.portfolio.MediaHandler)

Example 8 with Media

use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.

the class MediaCenterController method doSelect.

private void doSelect(UserRequest ureq, Long mediaKey) {
    Media media = portfolioService.getMediaByKey(mediaKey);
    fireEvent(ureq, new MediaSelectionEvent(media));
}
Also used : MediaSelectionEvent(org.olat.modules.portfolio.ui.event.MediaSelectionEvent) Media(org.olat.modules.portfolio.Media)

Example 9 with Media

use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.

the class MediaCenterController method doImportArtefactV1.

private Media doImportArtefactV1(AbstractArtefact oldArtefact) {
    Media media = null;
    MediaHandler handler = portfolioService.getMediaHandler(oldArtefact.getResourceableTypeName());
    if (handler != null) {
        media = handler.createMedia(oldArtefact);
    }
    return media;
}
Also used : MediaHandler(org.olat.modules.portfolio.MediaHandler) Media(org.olat.modules.portfolio.Media)

Example 10 with Media

use of org.olat.modules.portfolio.Media in project OpenOLAT by OpenOLAT.

the class MediaDetailsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("title", StringHelper.escapeHtml(media.getTitle()));
        layoutCont.contextPut("description", StringHelper.xssScan(media.getDescription()));
        layoutCont.contextPut("iconCssClass", handler.getIconCssClass(media));
        mediaCtrl = handler.getMediaController(ureq, getWindowControl(), media, new StandardMediaRenderingHints());
        if (mediaCtrl != null) {
            listenTo(mediaCtrl);
            layoutCont.put("media", mediaCtrl.getInitialComponent());
        }
        String metaPage = velocity_root + "/media_details_metadata.html";
        FormLayoutContainer metaCont = FormLayoutContainer.createCustomFormLayout("meta", getTranslator(), metaPage);
        layoutCont.add("meta", metaCont);
        metaCont.setRootForm(mainForm);
        metaCont.contextPut("media", media);
        String author = userManager.getUserDisplayName(media.getAuthor());
        metaCont.contextPut("author", author);
        if (media.getCollectionDate() != null) {
            String collectionDate = Formatter.getInstance(getLocale()).formatDate(media.getCollectionDate());
            metaCont.contextPut("collectionDate", collectionDate);
        }
        if (media.getBusinessPath() != null) {
            gotoOriginalLink = LinkFactory.createLink("goto.original", metaCont.getFormItemComponent(), this);
        }
        if (StringHelper.containsNonWhitespace(media.getMetadataXml())) {
            Object metadata = MetadataXStream.get().fromXML(media.getMetadataXml());
            metaCont.contextPut("metadata", metadata);
        }
        List<Category> categories = portfolioService.getCategories(media);
        if (categories != null && categories.size() > 0) {
            Map<String, String> categoriesMap = categories.stream().collect(Collectors.toMap(c -> c.getName(), c -> c.getName()));
            TextBoxListElement categoriesEl = uifactory.addTextBoxListElement("categories", "categories", "categories.hint", categoriesMap, metaCont, getTranslator());
            categoriesEl.setHelpText(translate("categories.hint"));
            categoriesEl.setElementCssClass("o_sel_ep_tagsinput");
            categoriesEl.setEnabled(false);
        }
        List<FormLink> binderLinks = new ArrayList<>(usedInList.size());
        Set<Long> binderUniqueKeys = new HashSet<>();
        for (BinderPageUsage binder : usedInList) {
            if (binderUniqueKeys.contains(binder.getBinderKey()))
                continue;
            FormLink link;
            if (binder.getBinderKey() == null) {
                link = uifactory.addFormLink("binder_" + (++counter), "page", binder.getPageTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
                binderUniqueKeys.add(binder.getPageKey());
            } else {
                link = uifactory.addFormLink("binder_" + (++counter), "binder", binder.getBinderTitle(), null, metaCont, Link.LINK | Link.NONTRANSLATED);
                binderUniqueKeys.add(binder.getBinderKey());
            }
            link.setUserObject(binder);
            binderLinks.add(link);
        }
        metaCont.contextPut("binderLinks", binderLinks);
    }
}
Also used : BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) TooledStackedPanel(org.olat.core.gui.components.stack.TooledStackedPanel) Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) FormEvent(org.olat.core.gui.components.form.flexible.impl.FormEvent) Autowired(org.springframework.beans.factory.annotation.Autowired) FormItem(org.olat.core.gui.components.form.flexible.FormItem) TextBoxListElement(org.olat.core.gui.components.form.flexible.elements.TextBoxListElement) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) Category(org.olat.modules.portfolio.Category) ContextEntry(org.olat.core.id.context.ContextEntry) Media(org.olat.modules.portfolio.Media) Map(java.util.Map) MediaHandler(org.olat.modules.portfolio.MediaHandler) StringHelper(org.olat.core.util.StringHelper) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) StateEntry(org.olat.core.id.context.StateEntry) Formatter(org.olat.core.util.Formatter) PortfolioService(org.olat.modules.portfolio.PortfolioService) DialogBoxController(org.olat.core.gui.control.generic.modal.DialogBoxController) Link(org.olat.core.gui.components.link.Link) WindowControl(org.olat.core.gui.control.WindowControl) Set(java.util.Set) MediaEvent(org.olat.modules.portfolio.ui.event.MediaEvent) Component(org.olat.core.gui.components.Component) LinkFactory(org.olat.core.gui.components.link.LinkFactory) Collectors(java.util.stream.Collectors) Controller(org.olat.core.gui.control.Controller) UserManager(org.olat.user.UserManager) List(java.util.List) MetadataXStream(org.olat.modules.portfolio.manager.MetadataXStream) NewControllerFactory(org.olat.NewControllerFactory) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) Align(org.olat.core.gui.components.stack.TooledStackedPanel.Align) TooledController(org.olat.core.gui.components.stack.TooledController) DialogBoxUIFactory(org.olat.core.gui.control.generic.modal.DialogBoxUIFactory) UserRequest(org.olat.core.gui.UserRequest) PageStatus(org.olat.modules.portfolio.PageStatus) StandardMediaRenderingHints(org.olat.modules.portfolio.model.StandardMediaRenderingHints) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Category(org.olat.modules.portfolio.Category) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) StandardMediaRenderingHints(org.olat.modules.portfolio.model.StandardMediaRenderingHints) BinderPageUsage(org.olat.modules.portfolio.model.BinderPageUsage) TextBoxListElement(org.olat.core.gui.components.form.flexible.elements.TextBoxListElement) HashSet(java.util.HashSet)

Aggregations

Media (org.olat.modules.portfolio.Media)60 File (java.io.File)18 Test (org.junit.Test)10 WindowControl (org.olat.core.gui.control.WindowControl)10 Identity (org.olat.core.id.Identity)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 MediaHandler (org.olat.modules.portfolio.MediaHandler)10 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 UserRequest (org.olat.core.gui.UserRequest)8 Component (org.olat.core.gui.components.Component)8 OLATResourceable (org.olat.core.id.OLATResourceable)8 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 Set (java.util.Set)6 FormItem (org.olat.core.gui.components.form.flexible.FormItem)6 FormItemContainer (org.olat.core.gui.components.form.flexible.FormItemContainer)6 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)6 FormBasicController (org.olat.core.gui.components.form.flexible.impl.FormBasicController)6