Search in sources :

Example 1 with MediaHandler

use of org.olat.modules.portfolio.MediaHandler 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 2 with MediaHandler

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

the class MediaCenterController method initFilters.

private void initFilters(FlexiTableElement tableElement) {
    List<FlexiTableFilter> filters = new ArrayList<>(16);
    filters.add(new FlexiTableFilter(translate("filter.show.all"), "showall"));
    filters.add(FlexiTableFilter.SPACER);
    List<MediaHandler> handlers = portfolioService.getMediaHandlers();
    for (MediaHandler handler : handlers) {
        filters.add(new FlexiTableFilter(translate("artefact." + handler.getType()), handler.getType()));
    }
    tableElement.setFilters(null, filters, false);
}
Also used : MediaHandler(org.olat.modules.portfolio.MediaHandler) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) ArrayList(java.util.ArrayList)

Example 3 with MediaHandler

use of org.olat.modules.portfolio.MediaHandler 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 4 with MediaHandler

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

the class MediaTypeCellRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator translator) {
    if (cellValue instanceof MediaRow) {
        MediaRow mRow = (MediaRow) cellValue;
        MediaHandler handler = handlersMap.get(mRow.getType());
        if (handler != null) {
            target.append("<i class='o_icon o_icon-lg ").append(handler.getIconCssClass(mRow)).append("'> </i>");
        }
    }
}
Also used : MediaHandler(org.olat.modules.portfolio.MediaHandler) MediaRow(org.olat.modules.portfolio.ui.model.MediaRow)

Example 5 with MediaHandler

use of org.olat.modules.portfolio.MediaHandler 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)

Aggregations

MediaHandler (org.olat.modules.portfolio.MediaHandler)18 Media (org.olat.modules.portfolio.Media)8 PortfolioService (org.olat.modules.portfolio.PortfolioService)8 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 UserRequest (org.olat.core.gui.UserRequest)6 Component (org.olat.core.gui.components.Component)6 FlexiTableFilter (org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter)6 VelocityContainer (org.olat.core.gui.components.velocity.VelocityContainer)6 AbstractArtefact (org.olat.portfolio.model.artefacts.AbstractArtefact)6 HashSet (java.util.HashSet)4 Map (java.util.Map)4 Set (java.util.Set)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 SortKey (org.olat.core.commons.persistence.SortKey)4 Size (org.olat.core.commons.services.image.Size)4 Mapper (org.olat.core.dispatcher.mapper.Mapper)4 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4 FormItemContainer (org.olat.core.gui.components.form.flexible.FormItemContainer)4