Search in sources :

Example 31 with TaxonomyLevel

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

the class TaxonomyWebServiceTest method removeTaxonomyLevelCompetence.

@Test
public void removeTaxonomyLevelCompetence() throws IOException, URISyntaxException {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competence-4");
    Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-8", "Taxonomy on rest", "PUT is cool, yes!", "PUT-tax-2");
    TaxonomyLevel level = taxonomyService.createTaxonomyLevel("REST-Tax-r-8", "Root level on rest", "Level", "Ext-23", null, null, taxonomy);
    TaxonomyCompetence competence = taxonomyService.addTaxonomyLevelCompetences(level, id, TaxonomyCompetenceTypes.target, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(competence);
    // make sure we have something to delete
    TaxonomyCompetence reloadedCompetence = taxonomyService.getTaxonomyCompetence(competence);
    Assert.assertNotNull(reloadedCompetence);
    dbInstance.commitAndCloseSession();
    // remove the competence
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").path(level.getKey().toString()).path("competences").path(competence.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 database
    List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyCompetences(id, TaxonomyCompetenceTypes.target);
    Assert.assertNotNull(competences);
    Assert.assertEquals(0, competences.size());
}
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) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) Identity(org.olat.core.id.Identity) URI(java.net.URI) Test(org.junit.Test)

Example 32 with TaxonomyLevel

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

the class TaxonomyWebServiceTest method getTaxonomyLevelComptences_byIdentity.

@Test
public void getTaxonomyLevelComptences_byIdentity() throws IOException, URISyntaxException {
    // prepare a level, 1 user and 1 competence
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competence-4");
    Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-7", "Taxonomy on rest", "Rest is cool", "Ext-tax-7");
    TaxonomyLevel level = taxonomyService.createTaxonomyLevel("REST-Tax-l-7", "Level 1 on rest", "Level", "Ext-7", null, null, taxonomy);
    taxonomyService.addTaxonomyLevelCompetences(level, id, TaxonomyCompetenceTypes.teach, null);
    dbInstance.commitAndCloseSession();
    // get the competences
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").path(level.getKey().toString()).path("competences").path(id.getKey().toString()).build();
    HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    List<TaxonomyCompetenceVO> competenceList = parseTaxonomyComptencesArray(response.getEntity().getContent());
    Assert.assertNotNull(competenceList);
    Assert.assertEquals(1, competenceList.size());
    TaxonomyCompetenceVO competence = competenceList.get(0);
    Assert.assertEquals(id.getKey(), competence.getIdentityKey());
    Assert.assertEquals(level.getKey(), competence.getTaxonomyLevelKey());
    Assert.assertEquals(TaxonomyCompetenceTypes.teach.name(), competence.getTaxonomyCompetenceType());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) Identity(org.olat.core.id.Identity) URI(java.net.URI) TaxonomyCompetenceVO(org.olat.modules.taxonomy.restapi.TaxonomyCompetenceVO) Test(org.junit.Test)

Example 33 with TaxonomyLevel

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

the class TaxonomyWebServiceTest method getTaxonomyComptencesByIdentity.

@Test
public void getTaxonomyComptencesByIdentity() throws IOException, URISyntaxException {
    // prepare a level, 2 users and 2 competences
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competence-4");
    Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-20", "Taxonomy on rest", "Rest is cool", "Ext-tax-7");
    TaxonomyLevel level1 = taxonomyService.createTaxonomyLevel("REST-Tax-l-21", "Level 1 on rest", "Level", "Ext-7", null, null, taxonomy);
    TaxonomyLevel level2 = taxonomyService.createTaxonomyLevel("REST-Tax-l-22", "Level 1 on rest", "Level", "Ext-7", null, null, taxonomy);
    taxonomyService.addTaxonomyLevelCompetences(level1, id, TaxonomyCompetenceTypes.teach, null);
    taxonomyService.addTaxonomyLevelCompetences(level2, id, TaxonomyCompetenceTypes.have, null);
    dbInstance.commitAndCloseSession();
    // get the competences
    RestConnection conn = new RestConnection();
    Assert.assertTrue(conn.login("administrator", "openolat"));
    URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("competences").path(id.getKey().toString()).build();
    HttpGet method = conn.createGet(request, MediaType.APPLICATION_JSON, true);
    HttpResponse response = conn.execute(method);
    Assert.assertEquals(200, response.getStatusLine().getStatusCode());
    List<TaxonomyCompetenceVO> competenceList = parseTaxonomyComptencesArray(response.getEntity().getContent());
    Assert.assertNotNull(competenceList);
    Assert.assertEquals(2, competenceList.size());
    boolean foundComptenceId1 = false;
    boolean foundComptenceId2 = false;
    for (TaxonomyCompetenceVO competence : competenceList) {
        if (competence.getTaxonomyLevelKey().equals(level1.getKey()) && competence.getIdentityKey().equals(id.getKey()) && TaxonomyCompetenceTypes.teach.name().equals(competence.getTaxonomyCompetenceType())) {
            foundComptenceId1 = true;
        } else if (competence.getTaxonomyLevelKey().equals(level2.getKey()) && competence.getIdentityKey().equals(id.getKey()) && TaxonomyCompetenceTypes.have.name().equals(competence.getTaxonomyCompetenceType())) {
            foundComptenceId2 = true;
        }
    }
    Assert.assertTrue(foundComptenceId1);
    Assert.assertTrue(foundComptenceId2);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) Identity(org.olat.core.id.Identity) URI(java.net.URI) TaxonomyCompetenceVO(org.olat.modules.taxonomy.restapi.TaxonomyCompetenceVO) Test(org.junit.Test)

Example 34 with TaxonomyLevel

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

the class QuestionPoolMenuTreeModel method buildFinalSubTreeModel.

public void buildFinalSubTreeModel(TreeNode rootNode) {
    if (!securityCallback.canUseReviewProcess())
        return;
    qpoolTaxonomyTreeBuilder.loadTaxonomyLevelsFinal(identity);
    List<TaxonomyLevel> taxonomyLevels = qpoolTaxonomyTreeBuilder.getTreeTaxonomyLevels();
    if (!taxonomyLevels.isEmpty()) {
        finalNode = new GenericTreeNode(translator.translate("menu.final"));
        finalNode.setTitle(translator.translate("menu.final"));
        rootNode.addChild(finalNode);
        for (TaxonomyLevel taxonomyLevel : taxonomyLevels) {
            TreeNode node = new FinalTreeNode(stackPanel, securityCallback, taxonomyLevel);
            finalNode.addChild(node);
        }
        setFirstChildAsDelegate(finalNode);
    }
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 35 with TaxonomyLevel

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

the class QPoolTaxonomyTreeBuilder method prefillSelectableTaxonomyLevelsArrays.

private void prefillSelectableTaxonomyLevelsArrays() {
    selectableKeys = new String[selectableTaxonomyLevels.size()];
    selectableValues = new String[selectableTaxonomyLevels.size()];
    taxonomicPaths = new String[selectableTaxonomyLevels.size()];
    for (int i = selectableTaxonomyLevels.size(); i-- > 0; ) {
        TaxonomyLevel level = selectableTaxonomyLevels.get(i);
        selectableKeys[i] = Long.toString(level.getKey());
        selectableValues[i] = computeIntendention(level, new StringBuilder()).append(level.getDisplayName()).toString();
        taxonomicPaths[i] = level.getMaterializedPathIdentifiers();
    }
    addEmptyEntry();
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

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