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;
}
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;
}
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;
}
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;
}
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());
}
Aggregations