use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TaxonomyTreeTableController method loadModel.
private void loadModel(boolean resetPage, boolean resetInternal) {
TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
searchParams.setQuickSearch(tableEl.getQuickSearchString());
List<TaxonomyLevel> taxonomyLevels = taxonomyService.getTaxonomyLevels(taxonomy, searchParams);
List<TaxonomyLevelRow> rows = new ArrayList<>(taxonomyLevels.size());
Map<Long, TaxonomyLevelRow> levelToRows = new HashMap<>();
for (TaxonomyLevel taxonomyLevel : taxonomyLevels) {
TaxonomyLevelRow row = forgeRow(taxonomyLevel);
rows.add(row);
levelToRows.put(taxonomyLevel.getKey(), row);
}
for (TaxonomyLevelRow row : rows) {
Long parentLevelKey = row.getParentLevelKey();
TaxonomyLevelRow parentRow = levelToRows.get(parentLevelKey);
row.setParent(parentRow);
}
for (TaxonomyLevelRow row : rows) {
for (FlexiTreeTableNode parent = row.getParent(); parent != null; parent = parent.getParent()) {
((TaxonomyLevelRow) parent).incrementNumberOfChildren();
}
}
Collections.sort(rows, new FlexiTreeNodeComparator());
model.setObjects(rows);
tableEl.reset(resetPage, resetInternal, true);
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TypeTaxonomyLevelController method getAvailableTypes.
private List<TaxonomyLevelType> getAvailableTypes() {
List<TaxonomyLevelType> allowedTypes = new ArrayList<>(taxonomyService.getTaxonomyLevelTypes(taxonomy));
Set<TaxonomyLevelType> analyzedTypes = new HashSet<>();
for (TaxonomyLevel level : levels) {
TaxonomyLevel parentLevel = level.getParent();
if (parentLevel != null && parentLevel.getType() != null && !analyzedTypes.contains(parentLevel.getType())) {
TaxonomyLevelType parentType = parentLevel.getType();
List<TaxonomyLevelType> allowedSubTypes = new ArrayList<>();
Set<TaxonomyLevelTypeToType> typesToTypes = parentType.getAllowedTaxonomyLevelSubTypes();
for (TaxonomyLevelTypeToType typeToType : typesToTypes) {
allowedSubTypes.add(typeToType.getAllowedSubTaxonomyLevelType());
}
if (allowedSubTypes.size() > 0) {
allowedTypes.retainAll(allowedSubTypes);
}
}
}
return allowedTypes;
}
use of org.olat.modules.taxonomy.TaxonomyLevel 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.TaxonomyLevel 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());
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class TaxonomyCompetenceDAOTest method getCompetenceByTaxonomyAndCompetenceTypes.
@Test
public void getCompetenceByTaxonomyAndCompetenceTypes() {
// make 2 taxonomy trees
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-31", "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-32", "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);
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, level2, id, null);
Identity otherId = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, otherId, null);
dbInstance.commitAndCloseSession();
// check the competences of the 2 taxonomy trees
List<TaxonomyCompetence> loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date(), TaxonomyCompetenceTypes.target);
Assert.assertNotNull(loadedCompetences1);
Assert.assertEquals(1, loadedCompetences1.size());
Assert.assertEquals(competence1, loadedCompetences1.get(0));
loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date(), TaxonomyCompetenceTypes.have);
Assert.assertEquals(0, loadedCompetences1.size());
List<TaxonomyCompetence> loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date(), TaxonomyCompetenceTypes.target);
Assert.assertNotNull(loadedCompetences2);
Assert.assertEquals(1, loadedCompetences2.size());
Assert.assertEquals(competence2, loadedCompetences2.get(0));
loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date(), TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach);
Assert.assertEquals(0, loadedCompetences2.size());
}
Aggregations