Search in sources :

Example 1 with LicenseTypeImpl

use of org.olat.core.commons.services.license.model.LicenseTypeImpl in project OpenOLAT by OpenOLAT.

the class LicenseTypeDAO method create.

LicenseType create(String name) {
    LicenseTypeImpl licenseType = new LicenseTypeImpl();
    Date now = new Date();
    licenseType.setCreationDate(now);
    licenseType.setLastModified(now);
    licenseType.setName(name);
    licenseType.setPredefined(false);
    return licenseType;
}
Also used : LicenseTypeImpl(org.olat.core.commons.services.license.model.LicenseTypeImpl) Date(java.util.Date)

Example 2 with LicenseTypeImpl

use of org.olat.core.commons.services.license.model.LicenseTypeImpl in project OpenOLAT by OpenOLAT.

the class LicenseXStreamHelperTest method shouldConvertToXmlAndBack.

@Test
public void shouldConvertToXmlAndBack() {
    String licensor = "licensor";
    String freetext = "freetext";
    String licenseTypeName = "licenseTypeName";
    LicenseTypeImpl licenseType = new LicenseTypeImpl();
    licenseType.setName(licenseTypeName);
    LicenseImpl license = new LicenseImpl();
    license.setLicensor(licensor);
    license.setFreetext(freetext);
    license.setLicenseType(licenseType);
    LicenseXStreamHelper licenseXStreamHelper = new LicenseXStreamHelper();
    String licenseAsXml = licenseXStreamHelper.toXml(license);
    System.out.println(licenseAsXml);
    License licenseFromXml = licenseXStreamHelper.licenseFromXml(licenseAsXml);
    assertThat(licenseFromXml.getLicensor()).isEqualTo(licensor);
    assertThat(licenseFromXml.getFreetext()).isEqualTo(freetext);
    assertThat(licenseFromXml.getLicenseType().getName()).isEqualTo(licenseTypeName);
}
Also used : License(org.olat.core.commons.services.license.License) LicenseTypeImpl(org.olat.core.commons.services.license.model.LicenseTypeImpl) LicenseImpl(org.olat.core.commons.services.license.model.LicenseImpl) Test(org.junit.Test)

Example 3 with LicenseTypeImpl

use of org.olat.core.commons.services.license.model.LicenseTypeImpl in project openolat by klemens.

the class DefaultModuleValues method createAndPersistPredefined.

private void createAndPersistPredefined(String name, String cssClass, String text) {
    if (!licenseTypeDao.exists(name)) {
        LicenseTypeImpl licenseType = (LicenseTypeImpl) licenseTypeDao.create(name);
        licenseType.setCssClass(cssClass);
        licenseType.setText(text);
        licenseType.setPredefined(true);
        licenseTypeDao.save(licenseType);
    }
}
Also used : LicenseTypeImpl(org.olat.core.commons.services.license.model.LicenseTypeImpl)

Example 4 with LicenseTypeImpl

use of org.olat.core.commons.services.license.model.LicenseTypeImpl in project openolat by klemens.

the class LicenseTypeDAO method create.

LicenseType create(String name) {
    LicenseTypeImpl licenseType = new LicenseTypeImpl();
    Date now = new Date();
    licenseType.setCreationDate(now);
    licenseType.setLastModified(now);
    licenseType.setName(name);
    licenseType.setPredefined(false);
    return licenseType;
}
Also used : LicenseTypeImpl(org.olat.core.commons.services.license.model.LicenseTypeImpl) Date(java.util.Date)

Example 5 with LicenseTypeImpl

use of org.olat.core.commons.services.license.model.LicenseTypeImpl in project openolat by klemens.

the class LicenseXStreamHelperTest method shouldConvertToXmlAndBack.

@Test
public void shouldConvertToXmlAndBack() {
    String licensor = "licensor";
    String freetext = "freetext";
    String licenseTypeName = "licenseTypeName";
    LicenseTypeImpl licenseType = new LicenseTypeImpl();
    licenseType.setName(licenseTypeName);
    LicenseImpl license = new LicenseImpl();
    license.setLicensor(licensor);
    license.setFreetext(freetext);
    license.setLicenseType(licenseType);
    LicenseXStreamHelper licenseXStreamHelper = new LicenseXStreamHelper();
    String licenseAsXml = licenseXStreamHelper.toXml(license);
    System.out.println(licenseAsXml);
    License licenseFromXml = licenseXStreamHelper.licenseFromXml(licenseAsXml);
    assertThat(licenseFromXml.getLicensor()).isEqualTo(licensor);
    assertThat(licenseFromXml.getFreetext()).isEqualTo(freetext);
    assertThat(licenseFromXml.getLicenseType().getName()).isEqualTo(licenseTypeName);
}
Also used : License(org.olat.core.commons.services.license.License) LicenseTypeImpl(org.olat.core.commons.services.license.model.LicenseTypeImpl) LicenseImpl(org.olat.core.commons.services.license.model.LicenseImpl) Test(org.junit.Test)

Aggregations

LicenseTypeImpl (org.olat.core.commons.services.license.model.LicenseTypeImpl)6 Date (java.util.Date)2 Test (org.junit.Test)2 License (org.olat.core.commons.services.license.License)2 LicenseImpl (org.olat.core.commons.services.license.model.LicenseImpl)2