use of org.olat.modules.qpool.model.QLicense in project OpenOLAT by OpenOLAT.
the class QLicenseDAO method createDefaultLicenses.
protected void createDefaultLicenses() {
List<QLicense> licenses = getLicenses();
Set<String> licenseKeys = new HashSet<String>();
for (QLicense license : licenses) {
licenseKeys.add(license.getLicenseKey());
}
for (String defaultLicenseKey : defaultLicenses) {
if (!licenseKeys.contains(defaultLicenseKey)) {
create(defaultLicenseKey, null, false);
}
}
dbInstance.commitAndCloseSession();
}
use of org.olat.modules.qpool.model.QLicense in project openolat by klemens.
the class QLicenseDAOTest method testCreateAndGet_byLicenseKey.
@Test
public void testCreateAndGet_byLicenseKey() {
String licenseKey = "apache-license-" + UUID.randomUUID().toString();
QLicense license = qpoolLicenseDao.create(licenseKey, null, true);
dbInstance.commit();
// load it
QLicense reloadedLicense = qpoolLicenseDao.loadByLicenseKey(licenseKey);
// check the values
Assert.assertNotNull(reloadedLicense);
Assert.assertEquals(license.getKey(), reloadedLicense.getKey());
Assert.assertNotNull(reloadedLicense.getCreationDate());
Assert.assertEquals(licenseKey, reloadedLicense.getLicenseKey());
Assert.assertTrue(reloadedLicense.isDeletable());
}
use of org.olat.modules.qpool.model.QLicense in project openolat by klemens.
the class QLicenseDAOTest method testCreateAndGet.
@Test
public void testCreateAndGet() {
String licenseKey = "apache-license-" + UUID.randomUUID().toString();
QLicense license = qpoolLicenseDao.create(licenseKey, null, true);
dbInstance.commit();
// load it
QLicense reloadedLicense = qpoolLicenseDao.loadById(license.getKey());
// check the values
Assert.assertNotNull(reloadedLicense);
Assert.assertEquals(license.getKey(), reloadedLicense.getKey());
Assert.assertNotNull(reloadedLicense.getCreationDate());
Assert.assertEquals(licenseKey, reloadedLicense.getLicenseKey());
Assert.assertTrue(reloadedLicense.isDeletable());
}
use of org.olat.modules.qpool.model.QLicense in project openolat by klemens.
the class QLicenseDAO method create.
public QLicense create(String licenseKey, String text, boolean deletable) {
QLicense license = new QLicense();
license.setCreationDate(new Date());
license.setLicenseKey(licenseKey);
license.setLicenseText(text);
license.setDeletable(deletable);
dbInstance.getCurrentEntityManager().persist(license);
return license;
}
use of org.olat.modules.qpool.model.QLicense 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);
}
Aggregations