use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class QTIMetadataConverter method addLicenseMetadataField.
private void addLicenseMetadataField(String label, QuestionItemFull fullItem, Element metadata) {
LicenseService lService = CoreSpringFactory.getImpl(LicenseService.class);
ResourceLicense license = lService.loadLicense(fullItem);
if (license != null) {
String licenseText = null;
LicenseType licenseType = license.getLicenseType();
if (lService.isFreetext(licenseType)) {
licenseText = license.getFreetext();
} else if (!lService.isNoLicense(licenseType)) {
licenseText = license.getLicenseType().getName();
}
if (StringHelper.containsNonWhitespace(licenseText)) {
addMetadataField(label, licenseText, metadata);
}
}
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class QTIMetadataConverter method createLicense.
public void createLicense(QuestionItemImpl poolItem, String licenseText, String licensor) {
ResourceLicense license = licenseService.loadOrCreateLicense(poolItem);
if (StringHelper.containsNonWhitespace(licenseText)) {
String mappedLicenseText = mapLicenseTypeName(licenseText);
LicenseType licenseType = licenseService.loadLicenseTypeByName(mappedLicenseText);
if (licenseType == null) {
licenseType = licenseService.loadFreetextLicenseType();
license.setFreetext(mappedLicenseText);
} else {
license.setFreetext(null);
}
license.setLicenseType(licenseType);
}
if (StringHelper.containsNonWhitespace(licensor)) {
license.setLicensor(licensor);
}
licenseService.update(license);
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class AdvancedSearchInputController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
searchInput = uifactory.addTextElement("search_input", "search.title", 255, "", formLayout);
authorQuery = uifactory.addTextElement("search_author", "form.search.label.author", 255, "", formLayout);
titleQuery = uifactory.addTextElement("search_title", "form.search.label.title", 255, "", formLayout);
descriptionQuery = uifactory.addTextElement("search_description", "form.search.label.description", 255, "", formLayout);
createdDate = uifactory.addDateChooser("search_creation", "form.search.label.created.date", null, formLayout);
modifiedDate = uifactory.addDateChooser("search_modification", "form.search.label.modified.date", null, formLayout);
// document types
initDocumentTypesKeysAndValues();
String[] documentTypeKeys = new String[documentInfos.size()];
String[] documentTypeValues = new String[documentInfos.size()];
int j = 0;
for (DocumentInfo documentType : documentInfos) {
documentTypeKeys[j] = documentType.getKey();
documentTypeValues[j++] = documentType.getValue();
}
documentTypeQuery = uifactory.addCheckboxesDropdown("doc_type", "form.search.label.documenttype", formLayout, documentTypeKeys, documentTypeValues);
documentTypeQuery.setNonSelectedText(translate("drop.down.no.selection"));
// licenses
List<LicenseType> activeLicenseTypes = licenseService.loadLicenseTypes();
activeLicenseTypes.removeIf(licenseService::isNoLicense);
Collections.sort(activeLicenseTypes);
String[] licenseTypeKeys = new String[activeLicenseTypes.size()];
String[] licenseTypeValues = new String[activeLicenseTypes.size()];
int counter = 0;
for (LicenseType licenseType : activeLicenseTypes) {
licenseTypeKeys[counter] = String.valueOf(licenseType.getKey());
licenseTypeValues[counter] = LicenseUIFactory.translate(licenseType, getLocale());
counter++;
}
licenseQuery = uifactory.addCheckboxesDropdown("search_license", "form.search.label.license", formLayout, licenseTypeKeys, licenseTypeValues);
licenseQuery.setNonSelectedText(translate("drop.down.no.selection"));
if (!licenseModule.isAnyHandlerEnabled()) {
licenseQuery.setVisible(false);
}
// metadatas
SearchMetadataFieldsProvider metadataProvider = (SearchMetadataFieldsProvider) CoreSpringFactory.getBean("SearchMetadataFieldsProvider");
// The metadata key selection, e.g DC.language for doublin core language metadata
List<String> metaDataList = metadataProvider.getAdvancedSearchableFields();
if (metaDataList.size() > 0) {
String[] metaDataFields = ArrayHelper.toArray(metaDataList);
String[] metaDataFieldsTranslated = new String[metaDataFields.length];
Translator metaTranslator = metadataProvider.createFieldsTranslator(getLocale());
for (int i = 0; i < metaDataFields.length; i++) {
String key = metaDataFields[i];
metaDataFieldsTranslated[i] = key + " (" + metaTranslator.translate(key) + ")";
}
metadataType = uifactory.addDropdownSingleselect("metadata_type", "form.search.label.metadatatype", formLayout, metaDataFields, metaDataFieldsTranslated, null);
metadataQuery = uifactory.addTextElement("metadata_query", null, 255, "", formLayout);
}
contextSelection = uifactory.addRadiosHorizontal("context", "form.search.label.context", formLayout, new String[0], new String[0]);
searchButton = uifactory.addFormLink("search", formLayout, Link.BUTTON_SMALL);
searchButton.setEnabled(true);
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class MetadataBulkChangeController method updateLicenseVisibility.
void updateLicenseVisibility() {
boolean freetextSelected = false;
if (licenseEl != null && licenseEl.isOneSelected()) {
String selectedKey = licenseEl.getSelectedKey();
LicenseType licenseType = licenseService.loadLicenseTypeByKey(selectedKey);
freetextSelected = licenseService.isFreetext(licenseType);
}
licenseFreetextEl.setVisible(freetextSelected);
}
use of org.olat.core.commons.services.license.LicenseType in project OpenOLAT by OpenOLAT.
the class AuthorSearchController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FormLayoutContainer leftContainer = FormLayoutContainer.createDefaultFormLayout("left_1", getTranslator());
leftContainer.setRootForm(mainForm);
formLayout.add(leftContainer);
// LEFT part of form
displayName = uifactory.addTextElement("cif_displayname", "cif.displayname", 255, "", leftContainer);
displayName.setElementCssClass("o_sel_repo_search_displayname");
displayName.setFocus(true);
id = uifactory.addTextElement("cif_id", "cif.id", 128, "", leftContainer);
id.setElementCssClass("o_sel_repo_search_id");
author = uifactory.addTextElement("cif_author", "cif.author", 255, "", leftContainer);
author.setElementCssClass("o_sel_repo_search_author");
description = uifactory.addTextElement("cif_description", "cif.description", 255, "", leftContainer);
description.setElementCssClass("o_sel_repo_search_description");
// RIGHT part of form
FormLayoutContainer rightContainer = FormLayoutContainer.createDefaultFormLayout("right_1", getTranslator());
rightContainer.setRootForm(mainForm);
formLayout.add(rightContainer);
List<String> typeList = getResources();
typeKeys = typeList.toArray(new String[typeList.size()]);
String[] typeValues = getTranslatedResources(typeList);
String[] typeCSS = getResourcesCSS(typeList);
types = uifactory.addCheckboxesDropdown("cif.type", "cif.type", rightContainer, typeKeys, typeValues, null, typeCSS);
types.setNonSelectedText(translate("table.showall"));
if (licenseModule.isEnabled(licenseHandler)) {
List<LicenseType> activeLicenseTypes = licenseService.loadActiveLicenseTypes(licenseHandler);
Collections.sort(activeLicenseTypes);
String[] licenseTypeKeys = new String[activeLicenseTypes.size()];
String[] licenseTypeValues = new String[activeLicenseTypes.size()];
int counter = 0;
for (LicenseType licenseType : activeLicenseTypes) {
licenseTypeKeys[counter] = String.valueOf(licenseType.getKey());
licenseTypeValues[counter] = LicenseUIFactory.translate(licenseType, getLocale());
counter++;
}
licenseEl = uifactory.addCheckboxesDropdown("cif.license", "cif.license", rightContainer, licenseTypeKeys, licenseTypeValues, null, null);
licenseEl.setNonSelectedText(translate("table.showall"));
}
String[] statusValues = new String[] { translate("cif.resources.status.all"), translate("cif.resources.status.active"), translate("cif.resources.status.closed") };
closedEl = uifactory.addRadiosHorizontal("cif_status", "cif.resources.status", rightContainer, statusKeys, statusValues);
closedEl.select(statusKeys[1], true);
String[] usageValues = new String[] { translate("cif.owned.resources.usage.all"), translate("cif.owned.resources.usage.used"), translate("cif.owned.resources.usage.notUsed") };
resourceUsageEl = uifactory.addRadiosHorizontal("cif_used", "cif.owned.resources.usage", rightContainer, usageKeys, usageValues);
resourceUsageEl.select(usageKeys[0], true);
ownedResourcesOnlyEl = uifactory.addCheckboxesHorizontal("cif_my", "cif.owned.resources.only", rightContainer, keys, new String[] { "" });
ownedResourcesOnlyEl.select(keys[0], true);
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
formLayout.add(buttonLayout);
searchButton = uifactory.addFormLink("search", buttonLayout, Link.BUTTON);
searchButton.setCustomEnabledLinkCSS("btn btn-primary");
if (cancelAllowed) {
uifactory.addFormCancelButton("quick.search", buttonLayout, ureq, getWindowControl());
}
}
Aggregations