use of org.olat.modules.qpool.model.QLicense 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);
}
use of org.olat.modules.qpool.model.QLicense in project openolat by klemens.
the class OLATUpgrade_12_4_0 method migrateQPoolLicenseTypes.
private void migrateQPoolLicenseTypes() {
List<QLicense> qpoolLicenseTypes = getQpoolLicenseTypes();
for (QLicense qlicense : qpoolLicenseTypes) {
String licenseKey = qlicense.getLicenseKey();
if (StringHelper.containsNonWhitespace(licenseKey) && isNotFreetextLicense(licenseKey)) {
String licenseTypeName = mapLicenseTypeName(licenseKey);
if (isLicenseTypeMissing(licenseTypeName)) {
LicenseType licenseType = licenseService.createLicenseType(licenseTypeName);
licenseService.saveLicenseType(licenseType);
log.info("LicenseType created: " + licenseTypeName);
} else {
log.info("LicenseType not created (exists): " + licenseTypeName);
}
LicenseType licenseType = licenseService.loadLicenseTypeByName(licenseTypeName);
licenseService.activate(licenseHandler, licenseType);
}
}
}
Aggregations