use of org.olat.modules.portfolio.MediaHandler in project openolat by klemens.
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;
}
use of org.olat.modules.portfolio.MediaHandler in project openolat by klemens.
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;
}
use of org.olat.modules.portfolio.MediaHandler in project openolat by klemens.
the class MediaCenterController method loadModel.
private void loadModel() {
String searchString = tableEl.getQuickSearchString();
List<String> tagNames = getSelectedTagNames();
Map<Long, MediaRow> currentMap = model.getObjects().stream().collect(Collectors.toMap(r -> r.getKey(), r -> r));
List<MediaLight> medias = portfolioService.searchOwnedMedias(getIdentity(), searchString, tagNames);
List<MediaRow> rows = new ArrayList<>(medias.size());
for (MediaLight media : medias) {
if (currentMap.containsKey(media.getKey())) {
rows.add(currentMap.get(media.getKey()));
} else {
MediaHandler handler = portfolioService.getMediaHandler(media.getType());
VFSLeaf thumbnail = handler.getThumbnail(media, THUMBNAIL_SIZE);
String mediaTitle = StringHelper.escapeHtml(media.getTitle());
FormLink openLink = uifactory.addFormLink("select_" + (++counter), "select", mediaTitle, null, flc, Link.NONTRANSLATED);
MediaRow row = new MediaRow(media, thumbnail, openLink, handler.getIconCssClass(media));
openLink.setUserObject(row);
rows.add(row);
}
}
model.setObjects(rows);
model.filter(tableEl.getSelectedFilters());
Map<Long, MediaRow> rowMap = model.getObjects().stream().collect(Collectors.toMap(r -> r.getKey(), r -> r));
Set<String> duplicateCategories = new HashSet<>();
List<CategoryLight> categories = portfolioService.getMediaCategories(getIdentity());
List<FormLink> newTagLinks = new ArrayList<>(categories.size());
for (CategoryLight category : categories) {
String name = category.getCategory();
MediaRow mRow = rowMap.get(category.getMediaKey());
if (mRow != null) {
mRow.addCategory(name);
}
if (duplicateCategories.contains(name)) {
continue;
}
duplicateCategories.add(name);
FormLink tagLink = uifactory.addFormLink("tag_" + (++counter), "tag", name, null, null, Link.NONTRANSLATED);
CategoryState state = new CategoryState(category, tagNames.contains(name));
tagLink.setUserObject(state);
if (state.isSelected()) {
tagLink.setCustomEnabledLinkCSS("tag label label-info o_disabled");
} else {
tagLink.setCustomEnabledLinkCSS("tag label label-info");
}
flc.add(tagLink);
newTagLinks.add(tagLink);
}
flc.contextPut("tagLinks", newTagLinks);
tagLinks = newTagLinks;
}
Aggregations