Search in sources :

Example 66 with MetaTagged

use of org.olat.core.commons.modules.bc.meta.tagged.MetaTagged in project OpenOLAT by OpenOLAT.

the class SubmitDocumentsController method updateModel.

private void updateModel() {
    File[] documents = documentsDir.listFiles(new SystemFileFilter(true, false));
    List<SubmittedSolution> docList = new ArrayList<>(documents.length);
    for (File document : documents) {
        String filename = document.getName();
        String uploadedBy = null;
        VFSItem item = documentsContainer.resolve(filename);
        if (item instanceof MetaTagged) {
            MetaInfo metaInfo = ((MetaTagged) item).getMetaInfo();
            if (metaInfo != null && metaInfo.getAuthorIdentityKey() != null) {
                uploadedBy = userManager.getUserDisplayName(metaInfo.getAuthorIdentityKey());
            }
        }
        FormItem download;
        if (filename.endsWith(".html")) {
            download = uifactory.addFormLink("view-" + CodeHelper.getRAMUniqueID(), "view", filename, null, flc, Link.LINK | Link.NONTRANSLATED);
            download.setUserObject(filename);
        } else {
            download = uifactory.addDownloadLink("view-" + CodeHelper.getRAMUniqueID(), filename, null, document, tableEl);
        }
        docList.add(new SubmittedSolution(document, uploadedBy, download));
    }
    model.setObjects(docList);
    tableEl.reset();
    if (maxDocs > 0 && docList.size() >= maxDocs) {
        if (uploadDocButton != null) {
            uploadDocButton.setEnabled(false);
        }
        if (createDocButton != null) {
            createDocButton.setEnabled(false);
        }
        String msg = translate("error.max.documents", new String[] { Integer.toString(maxDocs) });
        flc.contextPut("maxDocsWarning", msg);
    } else {
        if (uploadDocButton != null) {
            uploadDocButton.setEnabled(true);
        }
        if (createDocButton != null) {
            createDocButton.setEnabled(true);
        }
        flc.contextPut("maxDocsWarning", Boolean.FALSE);
    }
    flc.contextPut("hasDocuments", Boolean.valueOf(hasUploadDocuments()));
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem) SystemFileFilter(org.olat.core.util.io.SystemFileFilter) File(java.io.File)

Example 67 with MetaTagged

use of org.olat.core.commons.modules.bc.meta.tagged.MetaTagged in project OpenOLAT by OpenOLAT.

the class SubmitDocumentsController method doCreateDocumentEditor.

private void doCreateDocumentEditor(UserRequest ureq, String documentName) {
    if (newDocumentEditorCtrl != null)
        return;
    if (maxDocs > 0 && maxDocs <= model.getRowCount()) {
        showWarning("error.max.documents");
    } else {
        VFSItem item = documentsContainer.resolve(documentName);
        if (item == null) {
            documentsContainer.createChildLeaf(documentName);
        } else {
            documentName = VFSManager.rename(documentsContainer, documentName);
            documentsContainer.createChildLeaf(documentName);
        }
        // add missing identity in meta info
        item = documentsContainer.resolve(documentName);
        if (item instanceof MetaTagged) {
            MetaInfo metadata = ((MetaTagged) item).getMetaInfo();
            metadata.setAuthor(ureq.getIdentity());
            metadata.write();
        }
        newDocumentEditorCtrl = WysiwygFactory.createWysiwygController(ureq, getWindowControl(), documentsContainer, documentName, "media", true, true);
        newDocumentEditorCtrl.getRichTextConfiguration().disableMedia();
        newDocumentEditorCtrl.getRichTextConfiguration().setAllowCustomMediaFactory(false);
        newDocumentEditorCtrl.setNewFile(true);
        listenTo(newDocumentEditorCtrl);
        cmc = new CloseableModalController(getWindowControl(), "close", newDocumentEditorCtrl.getInitialComponent());
        listenTo(cmc);
        cmc.activate();
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 68 with MetaTagged

use of org.olat.core.commons.modules.bc.meta.tagged.MetaTagged in project openolat by klemens.

the class FileArtefactHandler method prefillArtefactAccordingToSource.

/**
 * @see org.olat.portfolio.EPAbstractHandler#prefillArtefactAccordingToSource(org.olat.portfolio.model.artefacts.AbstractArtefact,
 *      java.lang.Object)
 */
@Override
public void prefillArtefactAccordingToSource(AbstractArtefact artefact, Object source) {
    super.prefillArtefactAccordingToSource(artefact, source);
    if (source instanceof VFSItem) {
        VFSItem fileSource = (VFSItem) source;
        ((FileArtefact) artefact).setFilename(fileSource.getName());
        MetaInfo meta = null;
        if (fileSource instanceof MetaTagged) {
            meta = ((MetaTagged) fileSource).getMetaInfo();
        }
        if (meta != null && StringHelper.containsNonWhitespace(meta.getTitle())) {
            artefact.setTitle(meta.getTitle());
        } else {
            artefact.setTitle(fileSource.getName());
        }
        if (meta != null && StringHelper.containsNonWhitespace(meta.getComment())) {
            artefact.setDescription(meta.getComment());
        }
        artefact.setSignature(60);
        String path = ((OlatRootFileImpl) fileSource).getRelPath();
        String[] pathElements = path.split("/");
        String finalBusinessPath = null;
        String sourceInfo = null;
        // used to rebuild businessPath and source for a file:
        if (pathElements[1].equals("homes") && meta != null && pathElements[2].equals(meta.getAuthor())) {
            // from users briefcase
            String lastParts = "/";
            for (int i = 4; i < (pathElements.length - 1); i++) {
                lastParts = lastParts + pathElements[i] + "/";
            }
            sourceInfo = "Home -> " + pathElements[3] + " -> " + lastParts + fileSource.getName();
        } else if (pathElements[3].equals("BusinessGroup")) {
            // out of a businessgroup
            String lastParts = "/";
            for (int i = 5; i < (pathElements.length - 1); i++) {
                lastParts = lastParts + pathElements[i] + "/";
            }
            BusinessGroup bGroup = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(new Long(pathElements[4]));
            if (bGroup != null) {
                sourceInfo = bGroup.getName() + " -> " + lastParts + " -> " + fileSource.getName();
            }
            finalBusinessPath = "[BusinessGroup:" + pathElements[4] + "][toolfolder:0][path=" + lastParts + fileSource.getName() + ":0]";
        } else if (pathElements[4].equals("coursefolder")) {
            // the course folder
            sourceInfo = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(new Long(pathElements[2])) + " -> " + fileSource.getName();
        } else if (pathElements[1].equals("course") && pathElements[3].equals("foldernodes")) {
            // folders inside a course
            sourceInfo = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(new Long(pathElements[2])) + " -> " + pathElements[4] + " -> " + fileSource.getName();
            finalBusinessPath = "[RepositoryEntry:" + pathElements[2] + "][CourseNode:" + pathElements[4] + "]";
        }
        if (sourceInfo == null) {
            // unknown source, keep full path
            sourceInfo = VFSManager.getRealPath(fileSource.getParentContainer()) + "/" + fileSource.getName();
        }
        artefact.setBusinessPath(finalBusinessPath);
        artefact.setSource(sourceInfo);
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) VFSItem(org.olat.core.util.vfs.VFSItem) OlatRootFileImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFileImpl)

Example 69 with MetaTagged

use of org.olat.core.commons.modules.bc.meta.tagged.MetaTagged in project openolat by klemens.

the class VideoHandler method getThumbnail.

@Override
public VFSLeaf getThumbnail(MediaLight media, Size size) {
    String storagePath = media.getStoragePath();
    VFSLeaf thumbnail = null;
    if (StringHelper.containsNonWhitespace(storagePath)) {
        VFSContainer storageContainer = fileStorage.getMediaContainer(media);
        VFSItem item = storageContainer.resolve(media.getRootFilename());
        if (item instanceof VFSLeaf) {
            VFSLeaf leaf = (VFSLeaf) item;
            if (leaf instanceof MetaTagged) {
                MetaInfo metaInfo = ((MetaTagged) leaf).getMetaInfo();
                thumbnail = metaInfo.getThumbnail(size.getHeight(), size.getWidth(), true);
            }
        }
    }
    return thumbnail;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSContainer(org.olat.core.util.vfs.VFSContainer) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo) VFSItem(org.olat.core.util.vfs.VFSItem)

Example 70 with MetaTagged

use of org.olat.core.commons.modules.bc.meta.tagged.MetaTagged in project openolat by klemens.

the class VideoHandler method getInformations.

@Override
public MediaInformations getInformations(Object mediaObject) {
    String title = null;
    String description = null;
    if (mediaObject instanceof MetaTagged) {
        MetaInfo meta = ((MetaTagged) mediaObject).getMetaInfo();
        title = meta.getTitle();
        description = meta.getComment();
    }
    return new Informations(title, description);
}
Also used : MediaInformations(org.olat.modules.portfolio.MediaInformations) MetaTagged(org.olat.core.commons.modules.bc.meta.tagged.MetaTagged) MetaInfo(org.olat.core.commons.modules.bc.meta.MetaInfo)

Aggregations

MetaTagged (org.olat.core.commons.modules.bc.meta.tagged.MetaTagged)92 MetaInfo (org.olat.core.commons.modules.bc.meta.MetaInfo)86 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)58 VFSItem (org.olat.core.util.vfs.VFSItem)48 VFSContainer (org.olat.core.util.vfs.VFSContainer)34 File (java.io.File)16 OutputStream (java.io.OutputStream)14 Versionable (org.olat.core.util.vfs.version.Versionable)12 IOException (java.io.IOException)10 InputStream (java.io.InputStream)10 ArrayList (java.util.ArrayList)10 Date (java.util.Date)10 MediaResource (org.olat.core.gui.media.MediaResource)10 VFSMediaResource (org.olat.core.util.vfs.VFSMediaResource)10 VFSSecurityCallback (org.olat.core.util.vfs.callbacks.VFSSecurityCallback)8 BufferedOutputStream (java.io.BufferedOutputStream)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Test (org.junit.Test)6 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 NotFoundMediaResource (org.olat.core.gui.media.NotFoundMediaResource)6