Search in sources :

Example 46 with LicenseType

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

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());
    }
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 47 with LicenseType

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

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);
}
Also used : Translator(org.olat.core.gui.translator.Translator) SearchMetadataFieldsProvider(org.olat.search.service.SearchMetadataFieldsProvider) LicenseType(org.olat.core.commons.services.license.LicenseType)

Example 48 with LicenseType

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

the class LicenseTypeDAOTest method shouldLoadNoLicenseType.

@Test
public void shouldLoadNoLicenseType() {
    LicenseType noLicenseType = licenseTypeDao.loadNoLicenseType();
    assertThat(noLicenseType).isNotNull();
    assertThat(noLicenseType.getName()).isEqualTo(LicenseTypeDAO.NO_LICENSE_NAME);
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType) Test(org.junit.Test)

Example 49 with LicenseType

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

the class LicenseTypeDAOTest method shouldLoadAllLicensesTypes.

@Test
public void shouldLoadAllLicensesTypes() {
    LicenseType licenseType1 = licenseTypeDao.create(UUID.randomUUID().toString());
    licenseType1 = licenseTypeDao.save(licenseType1);
    LicenseType licenseType2 = licenseTypeDao.create(UUID.randomUUID().toString());
    licenseType2 = licenseTypeDao.save(licenseType2);
    LicenseType licenseType3 = licenseTypeDao.create(UUID.randomUUID().toString());
    licenseType3 = licenseTypeDao.save(licenseType3);
    dbInstance.commitAndCloseSession();
    List<LicenseType> licenseType = licenseTypeDao.loadLicenseTypes();
    assertThat(licenseType).contains(licenseType1, licenseType2, licenseType3);
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType) Test(org.junit.Test)

Example 50 with LicenseType

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

the class LicenseTypeDAOTest method shouldLoadLicenseTypeByKey.

@Test
public void shouldLoadLicenseTypeByKey() {
    LicenseType licenseType = licenseTypeDao.create(UUID.randomUUID().toString());
    licenseType = licenseTypeDao.save(licenseType);
    LicenseType otherLicenseType = licenseTypeDao.create(UUID.randomUUID().toString());
    licenseTypeDao.save(otherLicenseType);
    dbInstance.commitAndCloseSession();
    LicenseType loadedLicenseType = licenseTypeDao.loadLicenseTypeByKey(licenseType.getKey());
    assertThat(loadedLicenseType).isEqualTo(licenseType);
}
Also used : LicenseType(org.olat.core.commons.services.license.LicenseType) Test(org.junit.Test)

Aggregations

LicenseType (org.olat.core.commons.services.license.LicenseType)106 Test (org.junit.Test)40 ResourceLicense (org.olat.core.commons.services.license.ResourceLicense)28 LicenseService (org.olat.core.commons.services.license.LicenseService)14 License (org.olat.core.commons.services.license.License)12 OLATResourceable (org.olat.core.id.OLATResourceable)12 File (java.io.File)6 ArrayList (java.util.ArrayList)4 LicenseHandler (org.olat.core.commons.services.license.LicenseHandler)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 QLicense (org.olat.modules.qpool.model.QLicense)4 Date (java.util.Date)2 Random (java.util.Random)2 IdentityShort (org.olat.basesecurity.IdentityShort)2 LicenseImpl (org.olat.core.commons.services.license.model.LicenseImpl)2 MultipleSelectionElement (org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 Translator (org.olat.core.gui.translator.Translator)2 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)2 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)2