Search in sources :

Example 16 with QLicense

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();
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) HashSet(java.util.HashSet)

Example 17 with QLicense

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());
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) Test(org.junit.Test)

Example 18 with QLicense

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());
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) Test(org.junit.Test)

Example 19 with QLicense

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;
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) Date(java.util.Date)

Example 20 with QLicense

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);
}
Also used : QLicense(org.olat.modules.qpool.model.QLicense) ResourceLicense(org.olat.core.commons.services.license.ResourceLicense)

Aggregations

QLicense (org.olat.modules.qpool.model.QLicense)22 Test (org.junit.Test)12 LicenseType (org.olat.core.commons.services.license.LicenseType)4 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)4 Date (java.util.Date)2 HashSet (java.util.HashSet)2