Search in sources :

Example 36 with ResourceLicense

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

the class AbstractItemListController method forgeRow.

protected ItemRow forgeRow(QuestionItemView item, List<ResourceLicense> licenses) {
    boolean marked = item.isMarked();
    QuestionItemSecurityCallback securityCallback = qpoolSecurityCallbackFactory.createQuestionItemSecurityCallback(item, getSource(), roles);
    ItemRow row = new ItemRow(item, securityCallback);
    // favorite
    FormLink markLink = uifactory.addFormLink("mark_" + row.getKey(), "mark", "&nbsp;", null, null, Link.NONTRANSLATED);
    markLink.setIconLeftCSS(marked ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
    markLink.setUserObject(row);
    row.setMarkLink(markLink);
    // license
    for (ResourceLicense license : licenses) {
        if (license.getResId().equals(item.getResourceableId()) && license.getResName().equals(item.getResourceableTypeName())) {
            row.setLicense(license);
        }
    }
    return row;
}
Also used : FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) QuestionItemSecurityCallback(org.olat.modules.qpool.QuestionItemSecurityCallback) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 37 with ResourceLicense

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

the class AbstractItemListController method getRows.

@Override
public ResultInfos<ItemRow> getRows(String query, List<FlexiTableFilter> filters, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
    ResultInfos<QuestionItemView> items = itemsSource.getItems(query, condQueries, firstResult, maxResults, orderBy);
    List<ItemRow> rows = new ArrayList<>(items.getObjects().size());
    List<ResourceLicense> licenses = licenseService.loadLicenses(items.getObjects());
    for (QuestionItemView item : items.getObjects()) {
        ItemRow row = forgeRow(item, licenses);
        rows.add(row);
    }
    return new DefaultResultInfos<>(items.getNextFirstResult(), items.getCorrectedRowCount(), rows);
}
Also used : DefaultResultInfos(org.olat.core.commons.persistence.DefaultResultInfos) ArrayList(java.util.ArrayList) QuestionItemView(org.olat.modules.qpool.QuestionItemView) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 38 with ResourceLicense

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

the class RepositoryEntryImportExport method addLicenseInformations.

private void addLicenseInformations(RepositoryEntryImport imp, RepositoryEntry re) {
    LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
    ResourceLicense license = licenseService.loadLicense(re.getOlatResource());
    if (license != null) {
        imp.setLicenseTypeKey(String.valueOf(license.getLicenseType().getKey()));
        imp.setLicenseTypeName(license.getLicenseType().getName());
        imp.setLicensor(license.getLicensor());
        imp.setLicenseText(LicenseUIFactory.getLicenseText(license));
    }
}
Also used : LicenseService(org.olat.core.commons.services.license.LicenseService) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 39 with ResourceLicense

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

the class OLATUpgrade_12_4_0 method saveFreetextLicense.

private void saveFreetextLicense(QuestionItemImpl item) {
    QLicense qlicense = item.getLicense();
    ResourceLicense license = licenseService.loadOrCreateLicense(item);
    license.setLicenseType(getFreetextLicenseType());
    license.setFreetext(qlicense.getLicenseText());
    license.setLicensor(item.getCreator());
    licenseService.update(license);
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 40 with ResourceLicense

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

the class OLATUpgrade_12_4_0 method saveLicense.

private void saveLicense(QuestionItemImpl item) {
    QLicense qlicense = item.getLicense();
    String name = mapLicenseTypeName(qlicense.getLicenseKey());
    LicenseType licenseType = licenseService.loadLicenseTypeByName(name);
    ResourceLicense license = licenseService.loadOrCreateLicense(item);
    license.setLicenseType(licenseType);
    license.setFreetext(qlicense.getLicenseText());
    license.setLicensor(item.getCreator());
    licenseService.update(license);
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) LicenseType(org.olat.core.commons.services.license.LicenseType) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

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