Search in sources :

Example 1 with Media

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

the class EfficiencyStatementMediaHandler method createMedia.

@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
    Media media = null;
    if (mediaObject instanceof EfficiencyStatement) {
        EfficiencyStatement statement = (EfficiencyStatement) mediaObject;
        String xml = myXStream.toXML(statement);
        media = mediaDao.createMedia(title, description, xml, EFF_MEDIA, businessPath, null, 90, author);
        ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    }
    return media;
}
Also used : Media(org.olat.modules.portfolio.Media) EfficiencyStatement(org.olat.course.assessment.EfficiencyStatement)

Example 2 with Media

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

the class FileHandler method createMedia.

@Override
public Media createMedia(AbstractArtefact artefact) {
    Media media = null;
    if (artefact instanceof FileArtefact) {
        VFSContainer artefactFolder = oldPortfolioManager.getArtefactContainer(artefact);
        String filename = ((FileArtefact) artefact).getFilename();
        String extension = FileUtils.getFileSuffix(filename);
        String type = FILE_TYPE;
        if ("jpg".equalsIgnoreCase(extension) || "jpeg".equalsIgnoreCase(extension) || "png".equalsIgnoreCase(extension) || "gif".equalsIgnoreCase(extension)) {
            type = ImageHandler.IMAGE_TYPE;
        }
        String businessPath = artefact.getBusinessPath();
        if (businessPath == null) {
            businessPath = "[PortfolioV2:0][MediaCenter:0]";
        }
        media = mediaDao.createMedia(artefact.getTitle(), artefact.getDescription(), filename, type, businessPath, artefact.getKey().toString(), artefact.getSignature(), artefact.getAuthor());
        ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
        File mediaDir = fileStorage.generateMediaSubDirectory(media);
        String storagePath = fileStorage.getRelativePath(mediaDir);
        mediaDao.updateStoragePath(media, storagePath, filename);
        VFSContainer mediaContainer = fileStorage.getMediaContainer(media);
        VFSManager.copyContent(artefactFolder, mediaContainer);
    }
    return media;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) UploadMedia(org.olat.modules.portfolio.ui.media.UploadMedia) Media(org.olat.modules.portfolio.Media) FileArtefact(org.olat.portfolio.model.artefacts.FileArtefact) File(java.io.File)

Example 3 with Media

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

the class FileHandler method createMedia.

public Media createMedia(String title, String description, File file, String filename, String businessPath, Identity author) {
    Media media = mediaDao.createMedia(title, description, filename, FILE_TYPE, businessPath, null, 60, author);
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    File mediaDir = fileStorage.generateMediaSubDirectory(media);
    File mediaFile = new File(mediaDir, filename);
    FileUtils.copyFileToFile(file, mediaFile, false);
    String storagePath = fileStorage.getRelativePath(mediaDir);
    mediaDao.updateStoragePath(media, storagePath, filename);
    return media;
}
Also used : UploadMedia(org.olat.modules.portfolio.ui.media.UploadMedia) Media(org.olat.modules.portfolio.Media) File(java.io.File)

Example 4 with Media

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

the class TextHandler method createMedia.

@Override
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
    Media media = mediaDao.createMedia(title, description, (String) mediaObject, TEXT_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 5 with Media

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

the class MediaDAO method deleteMedia.

public void deleteMedia(Media media) {
    if (StringHelper.containsNonWhitespace(media.getRootFilename())) {
        VFSContainer container = fileStorage.getMediaContainer(media);
        VFSItem item = container.resolve(media.getRootFilename());
        if (item instanceof VFSLeaf) {
            ((VFSLeaf) item).delete();
        }
    }
    Media reloadedMedia = dbInstance.getCurrentEntityManager().getReference(MediaImpl.class, media.getKey());
    dbInstance.getCurrentEntityManager().remove(reloadedMedia);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) Media(org.olat.modules.portfolio.Media) VFSItem(org.olat.core.util.vfs.VFSItem)

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