Search in sources :

Example 6 with QLicense

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

Example 7 with QLicense

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

Example 8 with QLicense

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

Example 9 with QLicense

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

Example 10 with QLicense

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

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