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