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", " ", 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;
}
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);
}
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));
}
}
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);
}
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);
}
Aggregations