Search in sources :

Example 41 with Media

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

the class TextHandler method createMedia.

@Override
public Media createMedia(AbstractArtefact artefact) {
    String title = artefact.getTitle();
    String description = artefact.getDescription();
    String content = artefact.getFulltextContent();
    if (!StringHelper.containsNonWhitespace(content)) {
        content = oldPortfolioManager.getArtefactFullTextContent(artefact);
    }
    String businessPath = artefact.getBusinessPath();
    if (businessPath == null) {
        businessPath = "[PortfolioV2:0][MediaCenter:0]";
    }
    Media media = mediaDao.createMedia(title, description, content, TEXT_MEDIA, businessPath, artefact.getKey().toString(), artefact.getSignature(), artefact.getAuthor());
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    return media;
}
Also used : Media(org.olat.modules.portfolio.Media)

Example 42 with Media

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

the class ImageHandler method createMedia.

public Media createMedia(String title, String description, File file, String filename, String businessPath, Identity author) {
    Media media = mediaDao.createMedia(title, description, filename, IMAGE_TYPE, businessPath, null, 60, author);
    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);
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    return media;
}
Also used : UploadMedia(org.olat.modules.portfolio.ui.media.UploadMedia) Media(org.olat.modules.portfolio.Media) File(java.io.File)

Example 43 with Media

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

the class VideoHandler method createMedia.

public Media createMedia(String title, String description, File file, String filename, String businessPath, Identity author) {
    Media media = mediaDao.createMedia(title, description, filename, VIDEO_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 44 with Media

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

the class EfficiencyStatementMediaHandler method createMedia.

@Override
public Media createMedia(AbstractArtefact artefact) {
    String title = artefact.getTitle();
    String description = artefact.getDescription();
    String xml = artefact.getFulltextContent();
    String businessPath = artefact.getBusinessPath();
    if (businessPath == null) {
        businessPath = "[PortfolioV2:0][MediaCenter:0]";
    }
    Media media = mediaDao.createMedia(title, description, xml, EFF_MEDIA, businessPath, artefact.getKey().toString(), artefact.getSignature(), artefact.getAuthor());
    ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(), LoggingResourceable.wrap(media));
    return media;
}
Also used : Media(org.olat.modules.portfolio.Media)

Example 45 with Media

use of org.olat.modules.portfolio.Media in project openolat by klemens.

the class CategoryDAOTest method getMediaCategoriesStatistics.

@Test
public void getMediaCategoriesStatistics() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("pf-media-1");
    Media media = mediaDao.createMedia("Media to categorize", "Media category", "Media content", "text", "[Media:0]", null, 10, id);
    dbInstance.commit();
    Category category = categoryDao.createAndPersistCategory("Cool");
    OLATResourceable ores = OresHelper.createOLATResourceableInstance(Media.class, media.getKey());
    categoryDao.appendRelation(ores, category);
    dbInstance.commitAndCloseSession();
    // load medias
    List<CategoryStatistics> catStatistics = categoryDao.getMediaCategoriesStatistics(id);
    Assert.assertNotNull(catStatistics);
    Assert.assertEquals(1, catStatistics.size());
    Assert.assertEquals(category.getName(), catStatistics.get(0).getName());
    Assert.assertTrue(1 <= catStatistics.get(0).getCount());
}
Also used : CategoryStatistics(org.olat.modules.portfolio.model.CategoryStatistics) Category(org.olat.modules.portfolio.Category) OLATResourceable(org.olat.core.id.OLATResourceable) Media(org.olat.modules.portfolio.Media) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

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