Search in sources :

Example 6 with OrphanVersion

use of org.olat.core.util.vfs.version.OrphanVersion 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)

Aggregations

OrphanVersion (org.olat.core.util.vfs.version.OrphanVersion)6 DecimalFormat (java.text.DecimalFormat)2 DecimalFormatSymbols (java.text.DecimalFormatSymbols)2 ArrayList (java.util.ArrayList)2 BitSet (java.util.BitSet)2 List (java.util.List)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 VFSRevision (org.olat.core.util.vfs.version.VFSRevision)2