Search in sources :

Example 31 with ResourceLicense

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

the class LicenseServiceImpl method copy.

@Override
public ResourceLicense copy(OLATResourceable source, OLATResourceable target) {
    if (source == null || target == null)
        return null;
    ResourceLicense targetLicense = null;
    ResourceLicense sourceLicense = licenseDao.loadByResource(source);
    if (sourceLicense != null) {
        licenseDao.delete(target);
        targetLicense = licenseDao.createAndPersist(target, sourceLicense);
    }
    return targetLicense;
}
Also used : ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Example 32 with ResourceLicense

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

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 33 with ResourceLicense

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

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 34 with ResourceLicense

use of org.olat.core.commons.services.license.ResourceLicense 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)

Example 35 with ResourceLicense

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

the class AbstractItemListController method reload.

@Override
public List<ItemRow> reload(List<ItemRow> rows) {
    List<Long> itemToReload = new ArrayList<>();
    for (ItemRow row : rows) {
        itemToReload.add(row.getKey());
    }
    List<QuestionItemView> reloadedItems = itemsSource.getItems(itemToReload);
    List<ItemRow> reloadedRows = new ArrayList<>(reloadedItems.size());
    List<ResourceLicense> licenses = licenseService.loadLicenses(reloadedItems);
    for (QuestionItemView item : reloadedItems) {
        ItemRow reloadedRow = forgeRow(item, licenses);
        reloadedRows.add(reloadedRow);
    }
    return reloadedRows;
}
Also used : ArrayList(java.util.ArrayList) QuestionItemView(org.olat.modules.qpool.QuestionItemView) 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