Search in sources :

Example 76 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseServiceImpl method createDefaultLicense.

@Override
public License createDefaultLicense(LicenseHandler handler, Identity licensor) {
    LicenseType defautlLicenseType = getDefaultLicenseType(handler);
    String licensorName = licensorFactory.create(handler, licensor);
    License license = new LicenseImpl();
    license.setLicenseType(defautlLicenseType);
    license.setLicensor(licensorName);
    return license;
}
Also used : License(org.olat.core.commons.services.license.License) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense) LicenseType(org.olat.core.commons.services.license.LicenseType) LicenseImpl(org.olat.core.commons.services.license.model.LicenseImpl)

Example 77 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseRenderer method renderLicense.

private void renderLicense(StringOutput sb, License license, boolean small) {
    LicenseType licenseType = license.getLicenseType();
    long id = CodeHelper.getRAMUniqueID();
    // license text link
    sb.append("<a id='o_lic_").append(id).append("' href='javascript:;'><span");
    if (small) {
        sb.append(" class='small'");
    }
    sb.append(">");
    sb.append(LicenseUIFactory.translate(licenseType, locale));
    sb.append("</span></a>");
    // popup with license informations
    sb.append("<div id='o_lic_pop_").append(id).append("' style='display:none;' class='o_lic_popup'><div>");
    appendStaticControl(sb, "license.popup.type", LicenseUIFactory.translate(licenseType, locale), LicenseUIFactory.getCssOrDefault(licenseType));
    String licensor = license.getLicensor() != null ? license.getLicensor() : "";
    appendStaticControl(sb, "license.popup.licensor", licensor);
    appendStaticControl(sb, "license.popup.text", LicenseUIFactory.getFormattedLicenseText(license));
    sb.append("</div>");
    // JavaScript to pup up the popup
    sb.append("<script type='text/javascript'>").append("/* <![CDATA[ */").append("jQuery(function() {\n").append("  o_popover('o_lic_").append(id).append("','o_lic_pop_").append(id).append("','top');\n").append("});").append("/* ]]> */").append("</script>");
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 78 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseUIFactory method validateLicenseTypeMandatoryButNonSelected.

public static boolean validateLicenseTypeMandatoryButNonSelected(SingleSelection licenseEl) {
    if (licenseEl == null)
        return false;
    if (!licenseEl.isMandatory())
        return false;
    LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
    boolean isNoLicenseSelected = false;
    if (licenseEl.isOneSelected()) {
        String selectedKey = licenseEl.getSelectedKey();
        LicenseType selectedLicenseType = licenseService.loadLicenseTypeByKey(selectedKey);
        isNoLicenseSelected = licenseService.isNoLicense(selectedLicenseType);
    }
    return isNoLicenseSelected;
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 79 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class LicenseUIFactory method getLicenseText.

public static String getLicenseText(License license) {
    LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
    String licenseText = "";
    if (license != null && license.getLicenseType() != null) {
        LicenseType licenseType = license.getLicenseType();
        if (licenseService.isFreetext(licenseType) && StringHelper.containsNonWhitespace(license.getFreetext())) {
            licenseText = license.getFreetext();
        } else if (StringHelper.containsNonWhitespace(licenseType.getText())) {
            licenseText = licenseType.getText();
        }
    }
    return licenseText;
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 80 with LicenseType

use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.

the class MetadataBulkChangeController method formOKRights.

private void formOKRights(QuestionItemImpl itemImpl) {
    if (isEnabled(licenseWrapperCont) || isEnabled(licensorEl)) {
        ResourceLicense license = licenseService.loadOrCreateLicense(itemImpl);
        if (isEnabled(licenseWrapperCont)) {
            if (licenseEl != null && licenseEl.isOneSelected()) {
                String licenseTypeKey = licenseEl.getSelectedKey();
                LicenseType licneseType = licenseService.loadLicenseTypeByKey(licenseTypeKey);
                license.setLicenseType(licneseType);
                String freetext = null;
                if (licenseFreetextEl != null && licenseFreetextEl.isVisible()) {
                    freetext = StringHelper.containsNonWhitespace(licenseFreetextEl.getValue()) ? licenseFreetextEl.getValue() : null;
                }
                license.setFreetext(freetext);
                license = licenseService.update(license);
            }
        }
        if (isEnabled(licensorEl)) {
            license.setLicensor(licensorEl.getValue());
        }
        licenseService.update(license);
    }
}
Also used : ResourceLicense(org.olat.core.commons.services.license.ResourceLicense) LicenseType(org.olat.core.commons.services.license.LicenseType)

Aggregations

LicenseType (org.olat.core.commons.services.license.LicenseType)106 Test (org.junit.Test)40 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)28 LicenseService (org.olat.core.commons.services.license.LicenseService)14 License (org.olat.core.commons.services.license.License)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 File (java.io.File)6 ArrayList (java.util.ArrayList)4 LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 QLicense (org.olat.modules.qpool.model.QLicense)4 Date (java.util.Date)2 Random (java.util.Random)2 IdentityShort (org.olat.basesecurity.IdentityShort)2 LicenseImpl (org.olat.core.commons.services.license.model.LicenseImpl)2 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 Translator (org.olat.core.gui.translator.Translator)2 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2