Search in sources :

Example 31 with IdentityShort

use of org.olat.basesecurity.IdentityShort in project openolat by klemens.

the class StandardResultController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer formLayoutCont = (FormLayoutContainer) formLayout;
        formLayoutCont.contextPut("result", document);
        formLayoutCont.contextPut("id", hashCode());
        formLayoutCont.contextPut("formatter", Formatter.getInstance(getLocale()));
        String author = document.getAuthor();
        if (StringHelper.containsNonWhitespace(author)) {
            List<IdentityShort> identities = BaseSecurityManager.getInstance().findShortIdentitiesByName(Collections.singleton(author));
            if (identities.size() > 0) {
                author = UserManager.getInstance().getUserDisplayName(identities.get(0));
            }
        }
        formLayoutCont.contextPut("author", author);
        if (StringHelper.containsNonWhitespace(document.getLicenseTypeKey())) {
            LicenseType licenseType = licenseService.loadLicenseTypeByKey(document.getLicenseTypeKey());
            if (!licenseService.isNoLicense(licenseType)) {
                formLayoutCont.contextPut("licenseIcon", LicenseUIFactory.getCssOrDefault(licenseType));
                formLayoutCont.contextPut("license", LicenseUIFactory.translate(licenseType, getLocale()));
            }
        }
    }
    String icon = document.getCssIcon();
    if (!StringHelper.containsNonWhitespace(icon)) {
        icon = "o_sp_icon";
    }
    String label = document.getTitle();
    if (label != null) {
        label = label.trim();
    }
    if (label.length() > 128) {
        label = FilterFactory.getHtmlTagsFilter().filter(label);
        label = Formatter.truncate(label, 128);
    }
    label = StringHelper.escapeHtml(label);
    docLink = uifactory.addFormLink("open_doc", label, label, formLayout, Link.NONTRANSLATED);
    docLink.setIconLeftCSS("o_icon o_icon-fw " + icon);
    String highlightLabel = document.getHighlightTitle();
    if (!StringHelper.containsNonWhitespace(highlightLabel)) {
        highlightLabel = label;
    }
    docHighlightLink = uifactory.addFormLink("open_doc_highlight", highlightLabel, highlightLabel, formLayout, Link.NONTRANSLATED);
    docHighlightLink.setIconLeftCSS("o_icon o_icon-fw " + icon);
}
Also used : IdentityShort(org.olat.basesecurity.IdentityShort) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 32 with IdentityShort

use of org.olat.basesecurity.IdentityShort in project openolat by klemens.

the class RevisionListController method loadModel.

private void loadModel(VFSLeaf versionedLeaf) {
    Versions versions = versionedFile.getVersions();
    List<VFSRevision> revisions = new ArrayList<VFSRevision>(versions.getRevisions());
    revisions.add(new CurrentRevision(versionedLeaf, versions));
    Collection<String> names = new HashSet<String>();
    for (VFSRevision revision : revisions) {
        if (revision.getAuthor() != null) {
            names.add(revision.getAuthor());
        }
    }
    Map<String, IdentityShort> mappedIdentities = new HashMap<String, IdentityShort>();
    for (IdentityShort identity : BaseSecurityManager.getInstance().findShortIdentitiesByName(names)) {
        mappedIdentities.put(identity.getName(), identity);
    }
    revisionListTableCtr.setTableDataModel(new RevisionListDataModel(revisions, mappedIdentities, getLocale()));
}
Also used : Versions(org.olat.core.util.vfs.version.Versions) HashMap(java.util.HashMap) VFSRevision(org.olat.core.util.vfs.version.VFSRevision) IdentityShort(org.olat.basesecurity.IdentityShort) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Aggregations

IdentityShort (org.olat.basesecurity.IdentityShort)32 File (java.io.File)8 HashMap (java.util.HashMap)8 Path (javax.ws.rs.Path)8 WebApplicationException (javax.ws.rs.WebApplicationException)8 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 Produces (javax.ws.rs.Produces)6 HEAD (javax.ws.rs.HEAD)4 Identity (org.olat.core.id.Identity)4 ICourse (org.olat.course.ICourse)4 SearchAssessedIdentityParams (org.olat.course.assessment.model.SearchAssessedIdentityParams)4 BusinessGroup (org.olat.group.BusinessGroup)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 HashSet (java.util.HashSet)2 EntityManager (javax.persistence.EntityManager)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 Response (javax.ws.rs.core.Response)2