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());
}
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());
}
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);
}
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);
}
}
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();
}
Aggregations