Search in sources :

Example 26 with TaxonomyLevel

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

the class NewItemOptionsController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String typeKey = typeEl.getSelectedKey();
    QItemFactory factory = keyToFactoryMap.get(typeKey);
    String title = titleEl.getValue();
    TaxonomyLevel taxonomyLevel = null;
    if (taxonomyLevelEl.isOneSelected()) {
        String selectedKey = taxonomyLevelEl.getSelectedKey();
        taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
    }
    fireEvent(ureq, new QItemCreationCmdEvent(title, taxonomyLevel, factory));
}
Also used : QItemFactory(org.olat.modules.qpool.QItemFactory) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) QItemCreationCmdEvent(org.olat.modules.qpool.ui.events.QItemCreationCmdEvent)

Example 27 with TaxonomyLevel

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

the class GeneralMetadataEditController method buildTaxonomyLevelEl.

private void buildTaxonomyLevelEl() {
    qpoolTaxonomyTreeBuilder.loadTaxonomyLevelsSelection(getIdentity(), securityCallback.canRemoveTaxonomy(), ignoreCompetences);
    String[] selectableKeys = qpoolTaxonomyTreeBuilder.getSelectableKeys();
    String[] selectableValues = qpoolTaxonomyTreeBuilder.getSelectableValues();
    taxonomyLevelEl.setKeysAndValues(selectableKeys, selectableValues, null);
    if (item instanceof QuestionItemImpl) {
        QuestionItemImpl itemImpl = (QuestionItemImpl) item;
        TaxonomyLevel selectedTaxonomyLevel = itemImpl.getTaxonomyLevel();
        if (selectedTaxonomyLevel != null) {
            String selectedTaxonomyLevelKey = String.valueOf(selectedTaxonomyLevel.getKey());
            for (String taxonomyKey : qpoolTaxonomyTreeBuilder.getSelectableKeys()) {
                if (taxonomyKey.equals(selectedTaxonomyLevelKey)) {
                    taxonomyLevelEl.select(taxonomyKey, true);
                }
            }
            if (!taxonomyLevelEl.isOneSelected() && itemImpl.getTaxonomyLevel() != null) {
                if (selectableKeys.length == 0) {
                    selectableKeys = new String[] { "dummy" };
                    selectableValues = new String[1];
                }
                selectableValues[0] = itemImpl.getTaxonomyLevel().getDisplayName();
                taxonomyLevelEl.setEnabled(false);
            }
        }
    }
    taxonomyLevelEl.addActionListener(FormEvent.ONCHANGE);
    setTaxonomicPath();
}
Also used : QuestionItemImpl(org.olat.modules.qpool.model.QuestionItemImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 28 with TaxonomyLevel

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

the class MetadataBulkChangeController method formOKGeneral.

private void formOKGeneral(QuestionItemImpl itemImpl) {
    if (isEnabled(topicEl))
        itemImpl.setTopic(topicEl.getValue());
    if (isEnabled(keywordsEl))
        itemImpl.setKeywords(keywordsEl.getValue());
    if (isEnabled(coverageEl))
        itemImpl.setCoverage(coverageEl.getValue());
    if (isEnabled(addInfosEl))
        itemImpl.setAdditionalInformations(addInfosEl.getValue());
    if (isEnabled(languageEl))
        itemImpl.setLanguage(languageEl.getValue());
    if (isEnabled(taxonomyLevelEl)) {
        String selectedKey = taxonomyLevelEl.getSelectedKey();
        TaxonomyLevel taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
        itemImpl.setTaxonomyLevel(taxonomyLevel);
    }
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 29 with TaxonomyLevel

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

the class TaxonomyWebServiceTest method deleteTaxonomyLevel.

@Test
public void deleteTaxonomyLevel() throws IOException, URISyntaxException {
    Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Del-1", "Taxonomy on rest", "Delete is sad!", "DELETE-tax-1");
    TaxonomyLevel rootLevel = taxonomyService.createTaxonomyLevel("REST-Del-root", "Root level on rest", "Level", "Ext-55", null, null, taxonomy);
    TaxonomyLevel levelToDelete = taxonomyService.createTaxonomyLevel("REST-Del-u-1", "Sub level on rest", "Level", "Ext-56", null, rootLevel, taxonomy);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(taxonomy);
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").path(levelToDelete.getKey().toString()).build();
    HttpDelete method = conn.createDelete(request, MediaType.APPLICATION_JSON);
    HttpResponse response = conn.execute(method);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    EntityUtils.consume(response.getEntity());
    // check the deleted value
    TaxonomyLevel deletedLevel = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(levelToDelete.getKey()));
    Assert.assertNull(deletedLevel);
    TaxonomyLevel survivingRootLevel = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(rootLevel.getKey()));
    Assert.assertNotNull(survivingRootLevel);
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) HttpResponse(org.apache.http.HttpResponse) TaxonomyLevelRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl) URI(java.net.URI) Test(org.junit.Test)

Example 30 with TaxonomyLevel

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

the class TaxonomyWebServiceTest method updateTaxonomyLevel.

/**
 * Update level.
 *
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
public void updateTaxonomyLevel() throws IOException, URISyntaxException {
    Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-4", "Taxonomy on rest", "PUT is cool, yes!", "PUT-tax-2");
    TaxonomyLevel rootLevel = taxonomyService.createTaxonomyLevel("REST-Tax-u-1", "Root level on rest", "Level", "Ext-25", null, null, taxonomy);
    TaxonomyLevel levelToUpdate = taxonomyService.createTaxonomyLevel("REST-Tax-u-1", "Sub level on rest", "Level", "Ext-26", null, rootLevel, taxonomy);
    TaxonomyLevelType type = taxonomyService.createTaxonomyLevelType("Sub-type", "Type for a sub level", "All is in the title", "TYP-27", taxonomy);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(taxonomy);
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    TaxonomyLevelVO levelVo = new TaxonomyLevelVO();
    levelVo.setKey(levelToUpdate.getKey());
    levelVo.setIdentifier("Updated id");
    levelVo.setDisplayName("Updated name");
    levelVo.setDescription("Updated description");
    levelVo.setExternalId("Updated ext.");
    levelVo.setTypeKey(type.getKey());
    levelVo.setParentKey(rootLevel.getKey());
    URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").build();
    HttpPut method = conn.createPut(request, MediaType.APPLICATION_JSON, true);
    conn.addJsonEntity(method, levelVo);
    HttpResponse response = conn.execute(method);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    // check the updated value
    TaxonomyLevelVO updatedTaxonomyLevelVo = conn.parse(response, TaxonomyLevelVO.class);
    Assert.assertNotNull(updatedTaxonomyLevelVo);
    Assert.assertEquals("Updated id", updatedTaxonomyLevelVo.getIdentifier());
    Assert.assertEquals("Updated name", updatedTaxonomyLevelVo.getDisplayName());
    Assert.assertEquals("Updated description", updatedTaxonomyLevelVo.getDescription());
    Assert.assertEquals("Updated ext.", updatedTaxonomyLevelVo.getExternalId());
    Assert.assertEquals(rootLevel.getKey(), updatedTaxonomyLevelVo.getParentKey());
    Assert.assertEquals(type.getKey(), updatedTaxonomyLevelVo.getTypeKey());
    // check the database
    TaxonomyLevel savedLevel = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(updatedTaxonomyLevelVo.getKey()));
    Assert.assertNotNull(savedLevel);
    Assert.assertEquals("Updated id", savedLevel.getIdentifier());
    Assert.assertEquals("Updated name", savedLevel.getDisplayName());
    Assert.assertEquals("Updated description", savedLevel.getDescription());
    Assert.assertEquals("Updated ext.", savedLevel.getExternalId());
    Assert.assertEquals(rootLevel.getKey(), savedLevel.getParent().getKey());
    Assert.assertEquals(type.getKey(), savedLevel.getType().getKey());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelVO(org.olat.modules.taxonomy.restapi.TaxonomyLevelVO) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) HttpResponse(org.apache.http.HttpResponse) TaxonomyLevelRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl) URI(java.net.URI) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Aggregations

TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)238 Taxonomy (org.olat.modules.taxonomy.Taxonomy)122 Test (org.junit.Test)106 Identity (org.olat.core.id.Identity)58 ArrayList (java.util.ArrayList)40 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)40 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)24 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)24 URI (java.net.URI)22 HttpResponse (org.apache.http.HttpResponse)22 TreeNode (org.olat.core.gui.components.tree.TreeNode)22 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)18 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)16 HashMap (java.util.HashMap)14 List (java.util.List)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)12 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)12 Path (javax.ws.rs.Path)10