use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseServiceImpl method createDefaultLicense.
@Override
public License createDefaultLicense(LicenseHandler handler, Identity licensor) {
LicenseType defautlLicenseType = getDefaultLicenseType(handler);
String licensorName = licensorFactory.create(handler, licensor);
License license = new LicenseImpl();
license.setLicenseType(defautlLicenseType);
license.setLicensor(licensorName);
return license;
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseRenderer method renderLicense.
private void renderLicense(StringOutput sb, License license, boolean small) {
LicenseType licenseType = license.getLicenseType();
long id = CodeHelper.getRAMUniqueID();
// license text link
sb.append("<a id='o_lic_").append(id).append("' href='javascript:;'><span");
if (small) {
sb.append(" class='small'");
}
sb.append(">");
sb.append(LicenseUIFactory.translate(licenseType, locale));
sb.append("</span></a>");
// popup with license informations
sb.append("<div id='o_lic_pop_").append(id).append("' style='display:none;' class='o_lic_popup'><div>");
appendStaticControl(sb, "license.popup.type", LicenseUIFactory.translate(licenseType, locale), LicenseUIFactory.getCssOrDefault(licenseType));
String licensor = license.getLicensor() != null ? license.getLicensor() : "";
appendStaticControl(sb, "license.popup.licensor", licensor);
appendStaticControl(sb, "license.popup.text", LicenseUIFactory.getFormattedLicenseText(license));
sb.append("</div>");
// JavaScript to pup up the popup
sb.append("<script type='text/javascript'>").append("/* <![CDATA[ */").append("jQuery(function() {\n").append(" o_popover('o_lic_").append(id).append("','o_lic_pop_").append(id).append("','top');\n").append("});").append("/* ]]> */").append("</script>");
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseUIFactory method validateLicenseTypeMandatoryButNonSelected.
public static boolean validateLicenseTypeMandatoryButNonSelected(SingleSelection licenseEl) {
if (licenseEl == null)
return false;
if (!licenseEl.isMandatory())
return false;
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
boolean isNoLicenseSelected = false;
if (licenseEl.isOneSelected()) {
String selectedKey = licenseEl.getSelectedKey();
LicenseType selectedLicenseType = licenseService.loadLicenseTypeByKey(selectedKey);
isNoLicenseSelected = licenseService.isNoLicense(selectedLicenseType);
}
return isNoLicenseSelected;
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class LicenseUIFactory method getLicenseText.
public static String getLicenseText(License license) {
LicenseService licenseService = CoreSpringFactory.getImpl(LicenseService.class);
String licenseText = "";
if (license != null && license.getLicenseType() != null) {
LicenseType licenseType = license.getLicenseType();
if (licenseService.isFreetext(licenseType) && StringHelper.containsNonWhitespace(license.getFreetext())) {
licenseText = license.getFreetext();
} else if (StringHelper.containsNonWhitespace(licenseType.getText())) {
licenseText = licenseType.getText();
}
}
return licenseText;
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class MetadataBulkChangeController method formOKRights.
private void formOKRights(QuestionItemImpl itemImpl) {
if (isEnabled(licenseWrapperCont) || isEnabled(licensorEl)) {
ResourceLicense license = licenseService.loadOrCreateLicense(itemImpl);
if (isEnabled(licenseWrapperCont)) {
if (licenseEl != null && licenseEl.isOneSelected()) {
String licenseTypeKey = licenseEl.getSelectedKey();
LicenseType licneseType = licenseService.loadLicenseTypeByKey(licenseTypeKey);
license.setLicenseType(licneseType);
String freetext = null;
if (licenseFreetextEl != null && licenseFreetextEl.isVisible()) {
freetext = StringHelper.containsNonWhitespace(licenseFreetextEl.getValue()) ? licenseFreetextEl.getValue() : null;
}
license.setFreetext(freetext);
license = licenseService.update(license);
}
}
if (isEnabled(licensorEl)) {
license.setLicensor(licensorEl.getValue());
}
licenseService.update(license);
}
}
Aggregations