Search in sources :

Example 6 with VFSRevision

use of org.olat.core.util.vfs.version.VFSRevision in project OpenOLAT by OpenOLAT.

the class DeletedFileListController method loadModel.

private void loadModel(UserRequest ureq) {
    Collection<String> names = new HashSet<String>();
    for (Versions deletedFile : deletedFiles) {
        if (deletedFile.getCreator() != null && !"-".equals(deletedFile.getCreator())) {
            names.add(deletedFile.getCreator());
        }
        VFSRevision lastRevision = getLastRevision(deletedFile);
        if (lastRevision != null && lastRevision.getAuthor() != null && !"-".equals(lastRevision.getAuthor())) {
            names.add(lastRevision.getAuthor());
        }
    }
    Map<String, String> mappedFullnames = userManager.getUserDisplayNamesByUserName(names);
    DeletedFileListDataModel model = new DeletedFileListDataModel(deletedFiles, mappedFullnames, ureq.getLocale());
    deletedFilesListTableCtr.setTableDataModel(model);
}
Also used : Versions(org.olat.core.util.vfs.version.Versions) VFSRevision(org.olat.core.util.vfs.version.VFSRevision) HashSet(java.util.HashSet)

Example 7 with VFSRevision

use of org.olat.core.util.vfs.version.VFSRevision in project OpenOLAT by OpenOLAT.

the class DeletedFileListController method renderVersionsAsHtml.

private String renderVersionsAsHtml(List<Versions> versions) {
    StringBuilder sb = new StringBuilder();
    sb.append("<ul>");
    for (Versions version : versions) {
        VFSRevision lastRevision = getLastRevision(version);
        if (lastRevision != null) {
            sb.append("<li>").append(lastRevision.getName()).append("</li>");
        }
    }
    sb.append("</ul>");
    return sb.toString();
}
Also used : Versions(org.olat.core.util.vfs.version.Versions) VFSRevision(org.olat.core.util.vfs.version.VFSRevision)

Example 8 with VFSRevision

use of org.olat.core.util.vfs.version.VFSRevision in project OpenOLAT by OpenOLAT.

the class RevisionListController method getSelectedRevisions.

private List<VFSRevision> getSelectedRevisions(BitSet objectMarkers) {
    List<VFSRevision> allVersions = versionedFile.getVersions().getRevisions();
    List<VFSRevision> results = new ArrayList<VFSRevision>();
    for (int i = objectMarkers.nextSetBit(0); i >= 0; i = objectMarkers.nextSetBit(i + 1)) {
        if (i >= 0 && i < allVersions.size()) {
            VFSRevision elem = allVersions.get(i);
            results.add(elem);
        }
    }
    return results;
}
Also used : VFSRevision(org.olat.core.util.vfs.version.VFSRevision) ArrayList(java.util.ArrayList)

Example 9 with VFSRevision

use of org.olat.core.util.vfs.version.VFSRevision in project openolat by klemens.

the class VersionMaintenanceForm method calculateOrphanSize.

public final void calculateOrphanSize() {
    long size = 0l;
    List<OrphanVersion> orphans = versionsManager.orphans();
    for (OrphanVersion orphan : orphans) {
        List<VFSRevision> revisions = orphan.getVersions().getRevisions();
        if (revisions != null) {
            for (VFSRevision revision : revisions) {
                size += revision.getSize();
            }
        }
    }
    String unit = "KB";
    double humanSize = size / 1024.0d;
    if (humanSize > 1024) {
        humanSize /= 1024;
        unit = "MB";
    }
    DecimalFormat sizeFormat = new DecimalFormat("#0.#", new DecimalFormatSymbols(Locale.ENGLISH));
    String readableSize = sizeFormat.format(humanSize) + " " + unit;
    if (orphanSizeEl != null && !isDisposed()) {
        orphanSizeEl.setValue(readableSize);
    }
}
Also used : DecimalFormatSymbols(java.text.DecimalFormatSymbols) VFSRevision(org.olat.core.util.vfs.version.VFSRevision) DecimalFormat(java.text.DecimalFormat) OrphanVersion(org.olat.core.util.vfs.version.OrphanVersion)

Example 10 with VFSRevision

use of org.olat.core.util.vfs.version.VFSRevision in project openolat by klemens.

the class DeletedFileListController method loadModel.

private void loadModel(UserRequest ureq) {
    Collection<String> names = new HashSet<String>();
    for (Versions deletedFile : deletedFiles) {
        if (deletedFile.getCreator() != null && !"-".equals(deletedFile.getCreator())) {
            names.add(deletedFile.getCreator());
        }
        VFSRevision lastRevision = getLastRevision(deletedFile);
        if (lastRevision != null && lastRevision.getAuthor() != null && !"-".equals(lastRevision.getAuthor())) {
            names.add(lastRevision.getAuthor());
        }
    }
    Map<String, String> mappedFullnames = userManager.getUserDisplayNamesByUserName(names);
    DeletedFileListDataModel model = new DeletedFileListDataModel(deletedFiles, mappedFullnames, ureq.getLocale());
    deletedFilesListTableCtr.setTableDataModel(model);
}
Also used : Versions(org.olat.core.util.vfs.version.Versions) VFSRevision(org.olat.core.util.vfs.version.VFSRevision) HashSet(java.util.HashSet)

Aggregations

VFSRevision (org.olat.core.util.vfs.version.VFSRevision)14 ArrayList (java.util.ArrayList)8 Versions (org.olat.core.util.vfs.version.Versions)8 HashSet (java.util.HashSet)4 List (java.util.List)4 TableEvent (org.olat.core.gui.components.table.TableEvent)4 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)4 MediaResource (org.olat.core.gui.media.MediaResource)4 VFSRevisionMediaResource (org.olat.core.util.vfs.VFSRevisionMediaResource)4 DecimalFormat (java.text.DecimalFormat)2 DecimalFormatSymbols (java.text.DecimalFormatSymbols)2 HashMap (java.util.HashMap)2 IdentityShort (org.olat.basesecurity.IdentityShort)2 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)2 VFSMediaResource (org.olat.core.util.vfs.VFSMediaResource)2 OrphanVersion (org.olat.core.util.vfs.version.OrphanVersion)2