Search in sources :

Example 16 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class TaxonomyModuleWebService method getTaxonomyWebService.

@Path("{taxonomyKey}")
public TaxonomyWebService getTaxonomyWebService(@PathParam("taxonomyKey") Long taxonomyKey, @Context HttpServletRequest httpRequest) {
    Roles roles = getRoles(httpRequest);
    if (!roles.isOLATAdmin()) {
        throw new WebApplicationException(Response.serverError().status(Status.UNAUTHORIZED).build());
    }
    if (taxonomyKey == null || taxonomyKey.longValue() <= 0) {
        throw new WebApplicationException(Response.serverError().status(Status.BAD_REQUEST).build());
    }
    TaxonomyService taxonomyService = CoreSpringFactory.getImpl(TaxonomyService.class);
    Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(taxonomyKey));
    if (taxonomy == null) {
        throw new WebApplicationException(Response.serverError().status(Status.NOT_FOUND).build());
    }
    return new TaxonomyWebService(taxonomy);
}
Also used : TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) WebApplicationException(javax.ws.rs.WebApplicationException) Taxonomy(org.olat.modules.taxonomy.Taxonomy) RestSecurityHelper.getRoles(org.olat.restapi.security.RestSecurityHelper.getRoles) Roles(org.olat.core.id.Roles) Path(javax.ws.rs.Path)

Example 17 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class QItemQueriesDAOTest method shouldGetItemsIsTeacher.

@Test
public void shouldGetItemsIsTeacher() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("QPool", "QPool", "", null);
    TaxonomyLevel taxonomyLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, null, null, taxonomy);
    TaxonomyLevel taxonomySubLevel = taxonomyLevelDao.createTaxonomyLevel("QPool", "QPool", "QPool", null, null, taxonomyLevel, null, taxonomy);
    Identity ownerAndTeacher = createRandomIdentity();
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.teach, taxonomyLevel, ownerAndTeacher, null);
    Identity teacher = createRandomIdentity();
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.teach, taxonomyLevel, teacher, null);
    Identity noTeacher = createRandomIdentity();
    QuestionItemImpl item11 = createRandomItem(ownerAndTeacher);
    item11.setTaxonomyLevel(taxonomyLevel);
    QuestionItemImpl item12 = createRandomItem(ownerAndTeacher);
    item12.setTaxonomyLevel(taxonomySubLevel);
    dbInstance.commitAndCloseSession();
    SearchQuestionItemParams params = new SearchQuestionItemParams(ownerAndTeacher, null);
    List<QuestionItemView> loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isTrue();
    params = new SearchQuestionItemParams(ownerAndTeacher, null);
    loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isTrue();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isTrue();
    params = new SearchQuestionItemParams(noTeacher, null);
    loadedItems = qItemQueriesDao.getItems(params, null, 0, -1);
    assertThat(filterByKey(loadedItems, item11).isTeacher()).isFalse();
    assertThat(filterByKey(loadedItems, item12).isTeacher()).isFalse();
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Identity(org.olat.core.id.Identity) SearchQuestionItemParams(org.olat.modules.qpool.model.SearchQuestionItemParams) QuestionItemView(org.olat.modules.qpool.QuestionItemView) Test(org.junit.Test)

Example 18 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class DocumentPoolAdminConfigurationController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormDescription("admin.description");
    String[] onValues = new String[] { translate("on") };
    enableEl = uifactory.addCheckboxesHorizontal("document.pool.admin.enabled", formLayout, onKeys, onValues);
    enableEl.addActionListener(FormEvent.ONCHANGE);
    if (docPoolModule.isEnabled()) {
        enableEl.select(onKeys[0], true);
    }
    String mountPoint = docPoolModule.getWebDAVMountPoint();
    webDAVMountPointEl = uifactory.addTextElement("mount.point", "document.pool.webdav.mount.point", 32, mountPoint, formLayout);
    webDAVMountPointEl.setMandatory(true);
    String selectedTaxonomyTreeKey = docPoolModule.getTaxonomyTreeKey();
    List<Taxonomy> taxonomyList = taxonomyService.getTaxonomyList();
    String[] taxonomyKeys = new String[taxonomyList.size() + 1];
    String[] taxonomyValues = new String[taxonomyList.size() + 1];
    taxonomyKeys[0] = "";
    taxonomyValues[0] = "-";
    for (int i = taxonomyList.size(); i-- > 0; ) {
        Taxonomy taxonomy = taxonomyList.get(i);
        taxonomyKeys[i + 1] = taxonomy.getKey().toString();
        taxonomyValues[i + 1] = taxonomy.getDisplayName();
    }
    taxonomyTreeEl = uifactory.addDropdownSingleselect("selected.taxonomy.tree", formLayout, taxonomyKeys, taxonomyValues, null);
    taxonomyTreeEl.setMandatory(true);
    boolean found = false;
    if (StringHelper.containsNonWhitespace(selectedTaxonomyTreeKey)) {
        for (String taxonomyKey : taxonomyKeys) {
            if (taxonomyKey.equals(selectedTaxonomyTreeKey)) {
                taxonomyTreeEl.select(taxonomyKey, true);
                found = true;
            }
        }
    }
    if (!found && taxonomyKeys.length > 0) {
        taxonomyTreeEl.select(taxonomyKeys[0], true);
    }
    templatesDirectoryEl = uifactory.addCheckboxesHorizontal("document.pool.templates.directory", formLayout, onKeys, onValues);
    if (docPoolModule.isTemplatesDirectoryEnabled()) {
        templatesDirectoryEl.select(onKeys[0], true);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormSubmitButton("save", buttonsCont);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 19 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class DocumentPoolAdminController method doOpenPermissions.

private void doOpenPermissions(UserRequest ureq) {
    removeAsListenerAndDispose(permissionsCtrl);
    if (StringHelper.containsNonWhitespace(docPoolModule.getTaxonomyTreeKey())) {
        WindowControl bwControl = addToHistory(ureq, OresHelper.createOLATResourceableType("Types"), null);
        Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(docPoolModule.getTaxonomyTreeKey())));
        permissionsCtrl = new DocumentPoolAdminPermissionsController(ureq, bwControl, taxonomy);
        listenTo(permissionsCtrl);
        mainVC.put("segmentCmp", permissionsCtrl.getInitialComponent());
    }
}
Also used : TaxonomyRefImpl(org.olat.modules.taxonomy.model.TaxonomyRefImpl) Taxonomy(org.olat.modules.taxonomy.Taxonomy) WindowControl(org.olat.core.gui.control.WindowControl)

Example 20 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class QuestionPoolAdminConfigurationController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer moduleCont = FormLayoutContainer.createDefaultFormLayout("module", getTranslator());
    moduleCont.setFormTitle(translate("admin.configuration.title"));
    moduleCont.setRootForm(mainForm);
    formLayout.add("module", moduleCont);
    String[] onValues = new String[] { translate("on") };
    reviewProcessEnabledEl = uifactory.addCheckboxesHorizontal("review.process.enabled", moduleCont, onKeys, onValues);
    reviewProcessEnabledEl.addActionListener(FormEvent.ONCHANGE);
    if (qpoolModule.isReviewProcessEnabled()) {
        reviewProcessEnabledEl.select(onKeys[0], true);
    }
    collectionsEnabledEl = uifactory.addCheckboxesHorizontal("collections.enabled", moduleCont, onKeys, onValues);
    if (qpoolModule.isCollectionsEnabled()) {
        collectionsEnabledEl.select(onKeys[0], true);
    }
    poolsEnabledEl = uifactory.addCheckboxesHorizontal("pools.enabled", moduleCont, onKeys, onValues);
    if (qpoolModule.isPoolsEnabled()) {
        poolsEnabledEl.select(onKeys[0], true);
    }
    sharesEnabledEl = uifactory.addCheckboxesHorizontal("shares.enabled", moduleCont, onKeys, onValues);
    if (qpoolModule.isSharesEnabled()) {
        sharesEnabledEl.select(onKeys[0], true);
    }
    taxonomyEnabledEl = uifactory.addCheckboxesHorizontal("taxonomy.enabled", moduleCont, onKeys, onValues);
    if (qpoolModule.isTaxonomyEnabled()) {
        taxonomyEnabledEl.select(onKeys[0], true);
    }
    taxonomyEnabledEl.addActionListener(FormEvent.ONCHANGE);
    List<Taxonomy> taxonomyList = taxonomyService.getTaxonomyList();
    String[] taxonomyKeys = new String[taxonomyList.size() + 1];
    String[] taxonomyValues = new String[taxonomyList.size() + 1];
    taxonomyKeys[0] = "";
    taxonomyValues[0] = "-";
    for (int i = taxonomyList.size(); i-- > 0; ) {
        Taxonomy taxonomy = taxonomyList.get(i);
        taxonomyKeys[i + 1] = taxonomy.getKey().toString();
        taxonomyValues[i + 1] = taxonomy.getDisplayName();
    }
    String selectedTaxonomyQPoolKey = qpoolModule.getTaxonomyQPoolKey();
    taxonomyTreeEl = uifactory.addDropdownSingleselect("selected.taxonomy.tree", moduleCont, taxonomyKeys, taxonomyValues, null);
    taxonomyTreeEl.setEnabled(false);
    if (StringHelper.containsNonWhitespace(selectedTaxonomyQPoolKey)) {
        for (String taxonomyKey : taxonomyKeys) {
            if (taxonomyKey.equals(selectedTaxonomyQPoolKey)) {
                taxonomyTreeEl.select(taxonomyKey, true);
            }
        }
    }
    String[] ignoreCompetencesKeys = new String[] { TAXONOMY_COMPETENCES, TAXONOMY_ALL };
    ignoreCompetencesEl = uifactory.addDropdownSingleselect("taxonomy.selectable", moduleCont, ignoreCompetencesKeys, translateKeys(ignoreCompetencesKeys));
    String selectedKey = qpoolModule.isIgnoreCompetences() ? TAXONOMY_ALL : TAXONOMY_COMPETENCES;
    ignoreCompetencesEl.select(selectedKey, true);
    importCreateTaxonomyLevelEl = uifactory.addCheckboxesHorizontal("import.create.subject", moduleCont, onKeys, onValues);
    if (qpoolModule.isImportCreateTaxonomyLevel()) {
        importCreateTaxonomyLevelEl.select(onKeys[0], true);
    }
    educationalContextEnabledEl = uifactory.addCheckboxesHorizontal("educational.context.enabled", moduleCont, onKeys, onValues);
    if (qpoolModule.isEducationalContextEnabled()) {
        educationalContextEnabledEl.select(onKeys[0], true);
    }
    educationalContextEnabledEl.addActionListener(FormEvent.ONCHANGE);
    deleteQuestionsWithoutAuthorEl = uifactory.addCheckboxesHorizontal("delete.qustions.without.author", moduleCont, onKeys, onValues);
    deleteQuestionsWithoutAuthorEl.setHelpTextKey("delete.qustions.without.author.info", null);
    if (qpoolModule.isDeleteQuestionsWithoutAuthor()) {
        deleteQuestionsWithoutAuthorEl.select(onKeys[0], true);
    }
    FormLayoutContainer poolManagerRightsCont = FormLayoutContainer.createDefaultFormLayout("poolManagerRights", getTranslator());
    poolManagerRightsCont.setFormTitle(translate("admin.pool.manager.title"));
    poolManagerRightsCont.setRootForm(mainForm);
    formLayout.add("poolManagerRights", poolManagerRightsCont);
    poolManagerRightsEl = uifactory.addCheckboxesVertical("pool.manager.allowed", poolManagerRightsCont, POOL_MANAGER_RIGHTS_KEYS, translateKeys(POOL_MANAGER_RIGHTS_KEYS), 1);
    poolManagerRightsEl.select(POOL_MANAGER_EDIT_METADATA, qpoolModule.isPoolAdminAllowedToEditMetadata());
    poolManagerRightsEl.select(POOL_MANAGER_EDIT_STATUS, qpoolModule.isPoolAdminAllowedToEditStatus());
    poolManagerRightsEl.select(POOL_MANAGER_REVIEW_PROCESS, qpoolModule.isPoolAdminAllowedToConfigReviewProcess());
    poolManagerRightsEl.select(POOL_MANAGER_TAXONOMY, qpoolModule.isPoolAdminAllowedToConfigTaxonomy());
    poolManagerRightsEl.select(POOL_MANAGER_POOLS, qpoolModule.isPoolAdminAllowedToConfigPools());
    poolManagerRightsEl.select(POOL_MANAGER_ITEM_TYPES, qpoolModule.isPoolAdminAllowedToConfigItemTypes());
    poolManagerRightsEl.select(POOL_MANAGER_EDUCATIONAL_CONTEXT, qpoolModule.isPoolAdminAllowedToConfigEducationalContext());
    FormLayoutContainer buttonsWrapperCont = FormLayoutContainer.createDefaultFormLayout("global", getTranslator());
    buttonsWrapperCont.setRootForm(mainForm);
    formLayout.add("buttonsWrapper", buttonsWrapperCont);
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    buttonsWrapperCont.add(buttonsCont);
    uifactory.addFormSubmitButton("save", buttonsCont);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

Taxonomy (org.olat.modules.taxonomy.Taxonomy)194 Test (org.junit.Test)132 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)122 Identity (org.olat.core.id.Identity)56 URI (java.net.URI)36 HttpResponse (org.apache.http.HttpResponse)36 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)36 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)22 HttpGet (org.apache.http.client.methods.HttpGet)16 ArrayList (java.util.ArrayList)14 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)14 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)14 HttpPut (org.apache.http.client.methods.HttpPut)12 HashMap (java.util.HashMap)10 List (java.util.List)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)10 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)10