use of org.olat.modules.taxonomy.Taxonomy 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.Taxonomy in project OpenOLAT by OpenOLAT.
the class MoveTaxonomyLevelController method loadModel.
private void loadModel() {
new TaxonomyAllTreesBuilder().loadTreeModel(taxonomyModel, taxonomy);
// remove children of the level to move
for (TaxonomyLevel levelToMove : levelsToMove) {
TreeNode nodeToMove = taxonomyModel.getNodeById(TaxonomyAllTreesBuilder.nodeKey(levelToMove));
nodeToMove.removeAllChildren();
}
// remove the level with
List<TreeNode> openedNodes = new ArrayList<>();
filterByAllowedTypes(taxonomyModel.getRootNode(), openedNodes);
taxonomyModel.sort(taxonomyModel.getRootNode());
List<String> nodeIds = openedNodes.stream().map(node -> node.getIdent()).collect(Collectors.toList());
taxonomyEl.setOpenNodeIds(nodeIds);
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class MoveTaxonomyLevelController method getAllowedTypes.
private Set<TaxonomyLevelType> getAllowedTypes() {
List<TaxonomyLevelType> allTypes = new ArrayList<>(taxonomyService.getTaxonomyLevelTypes(taxonomy));
Map<TaxonomyLevelType, Set<TaxonomyLevelType>> subToParentTypes = new HashMap<>();
for (TaxonomyLevelType type : allTypes) {
Set<TaxonomyLevelTypeToType> typesToTypes = type.getAllowedTaxonomyLevelSubTypes();
for (TaxonomyLevelTypeToType typeToType : typesToTypes) {
TaxonomyLevelType subTyp = typeToType.getAllowedSubTaxonomyLevelType();
subToParentTypes.computeIfAbsent(subTyp, t -> new HashSet<>()).add(type);
}
}
Set<TaxonomyLevelType> analyzedTypes = new HashSet<>();
for (TaxonomyLevel level : levelsToMove) {
TaxonomyLevelType levelType = level.getType();
if (levelType != null && !analyzedTypes.contains(levelType)) {
analyzedTypes.add(levelType);
Set<TaxonomyLevelType> allowed = subToParentTypes.get(levelType);
if (allowed != null) {
allTypes.retainAll(allowed);
}
}
}
return new HashSet<>(allTypes);
}
use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.
the class DocumentPoolManagerTest method hasCompetenceByTaxonomy_negative.
@Test
public void hasCompetenceByTaxonomy_negative() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
String levelId = "DP-Lev. " + UUID.randomUUID();
Taxonomy taxonomy = getDocumentPoolTaxonomy();
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel(levelId, "Competence level", "A competence", null, null, null, null, taxonomy);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(level);
boolean hasCompetence = documentPoolManager.hasValidCompetence(id);
Assert.assertFalse(hasCompetence);
}
use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.
the class DocumentPoolManagerTest method setupTaxonomy.
@Before
public void setupTaxonomy() {
Taxonomy taxonomy = null;
String taxonomyTreeKey = documentPoolModule.getTaxonomyTreeKey();
if (StringHelper.isLong(taxonomyTreeKey)) {
taxonomy = taxonomyDao.loadByKey(new Long(taxonomyTreeKey));
}
if (taxonomy == null) {
taxonomy = taxonomyDao.createTaxonomy("DP-1", "Doc-pool", "Taxonomy for document pool", null);
dbInstance.commitAndCloseSession();
documentPoolModule.setTaxonomyTreeKey(taxonomy.getKey().toString());
}
}
Aggregations