use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class TaxonomyWebService method getTaxonomyLevelComptences.
/**
* Return the competences of users on the taxonomy level specified in the key in path.
*
* @response.representation.200.qname {http://www.example.com}taxonomyCompetenceVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc An array of competences
* @response.representation.200.example {@link org.olat.modules.taxonomy.restapi.Examples#SAMPLE_TAXONOMYCOMPETENCEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param taxonomyKey The taxonomy tree
* @param taxonomyLevelKey The level of the taxonomy
* @param httpRequest The HTTP request
* @return An array of competences
*/
@GET
@Path("levels/{taxonomyLevelKey}/competences")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTaxonomyLevelComptences(@PathParam("taxonomyLevelKey") Long taxonomyLevelKey) {
TaxonomyLevel level = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(new Long(taxonomyLevelKey)));
if (level == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyLevelCompetences(level);
List<TaxonomyCompetenceVO> competenceVOes = new ArrayList<>(competences.size());
for (TaxonomyCompetence competence : competences) {
competenceVOes.add(new TaxonomyCompetenceVO(competence));
}
return Response.ok(competenceVOes.toArray(new TaxonomyCompetenceVO[competenceVOes.size()])).build();
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelCompetenceController method doAddCompetence.
private void doAddCompetence(List<Identity> identities, TaxonomyCompetenceTypes comptenceType) {
Taxonomy taxonomy = taxonomyLevel.getTaxonomy();
for (Identity identity : identities) {
TaxonomyCompetence competence = taxonomyService.addTaxonomyLevelCompetences(taxonomyLevel, identity, comptenceType, null);
String after = taxonomyService.toAuditXml(competence);
taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.addCompetence, null, after, null, taxonomy, competence, identity, getIdentity());
}
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelCompetenceController method doSelectTaxonomyLevelCompetence.
private void doSelectTaxonomyLevelCompetence(UserRequest ureq, TaxonomyLevelCompetenceRow row) {
if (editCompetenceCtrl != null)
return;
TaxonomyCompetence competence = row.getCompetence();
editCompetenceCtrl = new EditTaxonomyCompetenceController(ureq, getWindowControl(), competence);
listenTo(editCompetenceCtrl);
String fullname = userManager.getUserDisplayName(row.getCompetence().getIdentity());
String type = translate(row.getCompetenceType().name());
String title = translate("edit.competence.title", new String[] { fullname, type });
cmc = new CloseableModalController(getWindowControl(), translate("close"), editCompetenceCtrl.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class DocumentPoolManagerTest method createTypeLevelCompetence.
private TaxonomyLevelType createTypeLevelCompetence(Identity id, TaxonomyLevel parent, TaxonomyCompetenceTypes competenceType) {
String levelId = "DP-Lev. " + UUID.randomUUID();
Taxonomy taxonomy = getDocumentPoolTaxonomy();
TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-docpool", "A type for document pool", "Typed", "TYP-0", taxonomy);
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel(levelId, "Competence level", "A competence", null, null, parent, type, taxonomy);
TaxonomyCompetence competenceTarget = taxonomyCompetenceDao.createTaxonomyCompetence(competenceType, level, id, null);
dbInstance.commit();
type.setDocumentsLibraryManageCompetenceEnabled(false);
type.setDocumentsLibraryTeachCompetenceWriteEnabled(false);
type.setDocumentsLibraryTeachCompetenceReadEnabled(false);
type.setDocumentsLibraryHaveCompetenceReadEnabled(false);
type.setDocumentsLibraryTargetCompetenceReadEnabled(false);
type = taxonomyLevelTypeDao.updateTaxonomyLevelType(type);
dbInstance.commit();
Assert.assertNotNull(competenceTarget);
return type;
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAOTest method getCompetenceByTaxonomy.
@Test
public void getCompetenceByTaxonomy() {
// make 2 taxonomy trees
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-27", "Competence", "", null);
TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level taxonomy 1", "A competence", null, null, null, null, taxonomy1);
TaxonomyCompetence competence1 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level1, id, null);
Taxonomy taxonomy2 = taxonomyDao.createTaxonomy("ID-28", "Competence", "", null);
TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-2", "Competence level taxonomy 2", "A competence", null, null, null, null, taxonomy2);
TaxonomyCompetence competence2 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, id, null);
dbInstance.commitAndCloseSession();
// check the competences of the 2 taxonomy trees
List<TaxonomyCompetence> loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date());
Assert.assertNotNull(loadedCompetences1);
Assert.assertEquals(1, loadedCompetences1.size());
Assert.assertEquals(competence1, loadedCompetences1.get(0));
List<TaxonomyCompetence> loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date());
Assert.assertNotNull(loadedCompetences2);
Assert.assertEquals(1, loadedCompetences2.size());
Assert.assertEquals(competence2, loadedCompetences2.get(0));
}
Aggregations