Search in sources :

Example 46 with ResourceLicense

use of org.olat.core.commons.services.license.ResourceLicense in project openolat by klemens.

the class QTIMetadataConverter method createLicense.

public void createLicense(QuestionItemImpl poolItem, String licenseText, String licensor) {
    ResourceLicense license = licenseService.loadOrCreateLicense(poolItem);
    if (StringHelper.containsNonWhitespace(licenseText)) {
        String mappedLicenseText = mapLicenseTypeName(licenseText);
        LicenseType licenseType = licenseService.loadLicenseTypeByName(mappedLicenseText);
        if (licenseType == null) {
            licenseType = licenseService.loadFreetextLicenseType();
            license.setFreetext(mappedLicenseText);
        } else {
            license.setFreetext(null);
        }
        license.setLicenseType(licenseType);
    }
    if (StringHelper.containsNonWhitespace(licensor)) {
        license.setLicensor(licensor);
    }
    licenseService.update(license);
}
Also used : ResourceLicense(org.olat.core.commons.services.license.ResourceLicense) LicenseType(org.olat.core.commons.services.license.LicenseType)

Aggregations

ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)46 LicenseType (org.olat.core.commons.services.license.LicenseType)26 OLATResourceable (org.olat.core.id.OLATResourceable)16 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)8 LicenseService (org.olat.core.commons.services.license.LicenseService)8 HashSet (java.util.HashSet)4 Document (org.apache.lucene.document.Document)4 QuestionItemView (org.olat.modules.qpool.QuestionItemView)4 QLicense (org.olat.modules.qpool.model.QLicense)4 OLATResource (org.olat.resource.OLATResource)4 OlatDocument (org.olat.search.model.OlatDocument)4 Random (java.util.Random)2 StringTokenizer (java.util.StringTokenizer)2 StringField (org.apache.lucene.document.StringField)2 TextField (org.apache.lucene.document.TextField)2 DefaultResultInfos (org.olat.core.commons.persistence.DefaultResultInfos)2 License (org.olat.core.commons.services.license.License)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 Identity (org.olat.core.id.Identity)2