use of org.olat.modules.qpool.model.QLicense in project OpenOLAT by OpenOLAT.
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.modules.qpool.model.QLicense in project OpenOLAT by OpenOLAT.
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);
}
}
}
use of org.olat.modules.qpool.model.QLicense in project openolat by klemens.
the class QLicenseDAOTest method testDelete_notDeletable.
@Test
public void testDelete_notDeletable() {
String licenseKey = "lgpl-" + UUID.randomUUID().toString();
QLicense license = qpoolLicenseDao.create(licenseKey, null, false);
dbInstance.commitAndCloseSession();
// delete it
boolean deleted = qpoolLicenseDao.delete(license);
dbInstance.commitAndCloseSession();
Assert.assertFalse(deleted);
// check that the type is really, really deleted
QLicense reloadedLicense = qpoolLicenseDao.loadById(license.getKey());
Assert.assertNotNull(reloadedLicense);
List<QLicense> allLicenses = qpoolLicenseDao.getLicenses();
Assert.assertTrue(allLicenses.contains(license));
}
use of org.olat.modules.qpool.model.QLicense in project openolat by klemens.
the class QLicenseDAOTest method testDelete_deletable.
@Test
public void testDelete_deletable() {
String licenseKey = "gpl-" + UUID.randomUUID().toString();
QLicense license = qpoolLicenseDao.create(licenseKey, null, true);
dbInstance.commitAndCloseSession();
// delete it
boolean deleted = qpoolLicenseDao.delete(license);
dbInstance.commitAndCloseSession();
Assert.assertTrue(deleted);
// check that the type is really, really deleted
QLicense reloadedLicense = qpoolLicenseDao.loadById(license.getKey());
Assert.assertNull(reloadedLicense);
List<QLicense> licenses = qpoolLicenseDao.getLicenses();
Assert.assertFalse(licenses.contains(license));
}
use of org.olat.modules.qpool.model.QLicense in project openolat by klemens.
the class QLicenseDAOTest method testGetItemLevels.
@Test
public void testGetItemLevels() {
String licenseKey = "gnu-" + UUID.randomUUID().toString();
QLicense license = qpoolLicenseDao.create(licenseKey, null, true);
dbInstance.commit();
// load it
List<QLicense> allLicenses = qpoolLicenseDao.getLicenses();
// check the values
Assert.assertNotNull(allLicenses);
Assert.assertTrue(allLicenses.contains(license));
}
Aggregations