use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project openolat by klemens.
the class EditTaxonomyCompetenceController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String fullName = userManager.getUserDisplayName(competence.getIdentity());
uifactory.addStaticTextElement("taxonomy.competence.fullName", fullName, formLayout);
TaxonomyCompetenceTypes competenceType = competence.getCompetenceType();
String type = translate(competenceType.name());
uifactory.addStaticTextElement("taxonomy.competence.type", type, formLayout);
TaxonomyLevelManagedFlag marker = TaxonomyLevelManagedFlag.getCorrespondingFlag(competenceType);
expirationEl = uifactory.addDateChooser("taxonomy.competence.expiration", competence.getExpiration(), formLayout);
expirationEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(taxonomyLevel, marker));
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
if (expirationEl.isEnabled()) {
// save only if there is something to update
uifactory.addFormSubmitButton("save", buttonsCont);
}
}
use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project openolat by klemens.
the class IdentityCompetenceRow method isManaged.
public boolean isManaged() {
TaxonomyLevel level = competence.getTaxonomyLevel();
TaxonomyCompetenceTypes competenceType = competence.getCompetenceType();
TaxonomyLevelManagedFlag marker = TaxonomyLevelManagedFlag.getCorrespondingFlag(competenceType);
return TaxonomyLevelManagedFlag.isManaged(level, marker);
}
use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project openolat by klemens.
the class TaxonomyTreeBuilder method computePermissionsRecursive.
private void computePermissionsRecursive(TaxonomyTreeNode node, Map<TaxonomyLevel, List<TaxonomyCompetenceTypes>> levelToCompetences) {
boolean hasRead = node.isCanRead();
boolean hasWrite = node.isCanWrite();
if (node.getType() == TaxonomyTreeNodeType.lostAndFound) {
hasRead = isTaxonomyAdmin;
hasWrite = isTaxonomyAdmin;
node.setCanRead(hasRead);
node.setCanWrite(hasWrite);
} else if (node.getTaxonomyLevel() != null) {
TaxonomyLevel level = node.getTaxonomyLevel();
TaxonomyLevelType type = level.getType();
if (type != null) {
List<TaxonomyCompetenceTypes> competences = levelToCompetences.get(level);
if (competences != null && competences.size() > 0) {
for (TaxonomyCompetenceTypes competence : competences) {
hasRead |= hasReadAccess(type, competence);
hasWrite |= hasWriteAccess(type, competence);
if (competence == TaxonomyCompetenceTypes.teach && type.getDocumentsLibraryTeachCompetenceReadParentLevels() > 0) {
int parentLevels = type.getDocumentsLibraryTeachCompetenceReadParentLevels();
TaxonomyTreeNode parent = (TaxonomyTreeNode) node.getParent();
for (int i = parentLevels; i-- > 0 && parent != null; ) {
parent.setCanRead(true);
parent = (TaxonomyTreeNode) parent.getParent();
}
}
}
} else if (isTaxonomyAdmin) {
hasRead |= hasReadAccess(type, null);
hasWrite |= hasWriteAccess(type, null);
}
}
node.setCanRead(hasRead);
node.setCanWrite(hasWrite);
} else if (node.getType() == TaxonomyTreeNodeType.templates) {
hasRead = true;
hasWrite = isTaxonomyAdmin;
node.setCanRead(hasRead);
node.setCanWrite(hasWrite);
}
for (int i = node.getChildCount(); i-- > 0; ) {
TaxonomyTreeNode child = (TaxonomyTreeNode) node.getChildAt(i);
child.setCanRead(hasRead);
child.setCanWrite(hasWrite);
computePermissionsRecursive(child, levelToCompetences);
}
}
use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project openolat by klemens.
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.TaxonomyCompetenceTypes in project openolat by klemens.
the class TaxonomyCompetenceTypeRenderer method render.
@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
if (cellValue instanceof TaxonomyCompetenceTypes) {
TaxonomyCompetenceTypes type = (TaxonomyCompetenceTypes) cellValue;
target.append(translator.translate(type.name()));
}
}
Aggregations