use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class TaxonomyWebService method addTaxonomyLevelComptencesByIdentity.
private Response addTaxonomyLevelComptencesByIdentity(Long taxonomyLevelKey, TaxonomyCompetenceVO comptenceVo, Identity executor) {
if (taxonomyLevelKey != null && comptenceVo.getTaxonomyLevelKey() != null && !taxonomyLevelKey.equals(comptenceVo.getTaxonomyLevelKey())) {
return Response.serverError().status(Status.CONFLICT).build();
}
if (taxonomyLevelKey == null) {
taxonomyLevelKey = comptenceVo.getTaxonomyLevelKey();
}
TaxonomyLevel level = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(new Long(taxonomyLevelKey)));
if (level == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
Identity identity = securityManager.loadIdentityByKey(comptenceVo.getIdentityKey());
if (identity == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
TaxonomyCompetence competence = null;
List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyLevelCompetences(level, identity);
for (TaxonomyCompetence c : competences) {
if (c.getCompetenceType().name().equals(comptenceVo.getTaxonomyCompetenceType())) {
competence = c;
}
}
if (competence == null) {
TaxonomyCompetenceTypes competenceType = TaxonomyCompetenceTypes.valueOf(comptenceVo.getTaxonomyCompetenceType());
competence = taxonomyService.addTaxonomyLevelCompetences(level, identity, competenceType, comptenceVo.getExpiration());
} else {
competence.setExpiration(comptenceVo.getExpiration());
competence = taxonomyService.updateTaxonomyLevelCompetence(competence);
}
String after = taxonomyService.toAuditXml(competence);
taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.addCompetence, null, after, null, taxonomy, competence, identity, executor);
return Response.ok(new TaxonomyCompetenceVO(competence)).build();
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class TaxonomyWebService method getTaxonomyLevelComptencesByIdentity.
/**
* Return the competences of a specific user 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 identityKey The user
* @param httpRequest The HTTP request
* @return An array of competences
*/
@GET
@Path("levels/{taxonomyLevelKey}/competences/{identityKey}")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTaxonomyLevelComptencesByIdentity(@PathParam("taxonomyLevelKey") Long taxonomyLevelKey, @PathParam("identityKey") Long identityKey) {
TaxonomyLevel level = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(new Long(taxonomyLevelKey)));
if (level == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
Identity identity = securityManager.loadIdentityByKey(identityKey);
if (identity == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyLevelCompetences(level, identity);
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 IdentityCompetencesController method doRemoveCompetence.
private void doRemoveCompetence(IdentityCompetenceRow row) {
Taxonomy taxonomy = row.getTaxonomy();
TaxonomyCompetence competence = row.getCompetence();
String before = taxonomyService.toAuditXml(competence);
taxonomyService.removeTaxonomyLevelCompetence(competence);
taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.removeCompetence, before, null, null, taxonomy, competence, assessedIdentity, getIdentity());
loadModel();
tableEl.reset(true, true, true);
String competenceTypeName = translate(row.getCompetenceType().name());
String levelDisplayName = StringHelper.escapeHtml(row.getTaxonomyLevel().getDisplayName());
showInfo("confirm.removed.competence", new String[] { competenceTypeName, levelDisplayName });
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class IdentityCompetencesController method doAddTaxonomyLevelsAsCompetence.
private void doAddTaxonomyLevelsAsCompetence(TaxonomyLevel selectedLevel, TaxonomyCompetenceTypes competenceType) {
if (selectedLevel == null) {
showWarning("warning.atleastone.level.competence");
} else {
boolean found = false;
List<TaxonomyCompetence> currentCompetences = taxonomyService.getTaxonomyCompetences(assessedIdentity, competenceType);
for (TaxonomyCompetence currentCompetence : currentCompetences) {
if (selectedLevel.equals(currentCompetence.getTaxonomyLevel())) {
found = true;
}
}
if (!found) {
TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(selectedLevel);
Taxonomy taxonomy = taxonomyLevel.getTaxonomy();
TaxonomyCompetence competence = taxonomyService.addTaxonomyLevelCompetences(taxonomyLevel, assessedIdentity, competenceType, null);
String after = taxonomyService.toAuditXml(competence);
taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.addCompetence, null, after, null, taxonomy, competence, assessedIdentity, getIdentity());
}
loadModel();
tableEl.reset(true, true, true);
}
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project openolat by klemens.
the class TaxonomyCompetenceDAOTest method createTaxonomyCompetence.
@Test
public void createTaxonomyCompetence() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-1");
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-24", "Competence", "", null);
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level", "A very difficult competence", null, null, null, null, taxonomy);
TaxonomyCompetence competence = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, level, id, null);
dbInstance.commit();
Assert.assertNotNull(competence);
Assert.assertNotNull(competence.getCreationDate());
}
Aggregations