use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class TaxonomyLibraryIndexer method doIndexTaxonomyLibrary.
protected void doIndexTaxonomyLibrary(SearchResourceContext searchResourceContext, Taxonomy taxonomy, OlatFullIndexer indexerWriter) throws InterruptedException {
VFSContainer templatesContainer = taxonomyService.getDocumentsLibrary(taxonomy);
if (templatesContainer != null) {
try {
taxonomyTemplatesLibraryIndexer.doIndex(searchResourceContext, taxonomy, indexerWriter);
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
logError("", e);
}
}
List<TaxonomyLevel> levels = taxonomyService.getTaxonomyLevels(taxonomy);
for (TaxonomyLevel level : levels) {
TaxonomyLevelType type = level.getType();
if (type != null && hasDocumentLibraryEnabled(type)) {
try {
taxonomyLevelLibraryIndexer.doIndex(searchResourceContext, level, indexerWriter);
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
logError("", e);
}
}
}
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class DeleteTaxonomyLevelController method initForm.
private void initForm(FormItemContainer formLayout, UserRequest ureq) {
StringBuilder sb = new StringBuilder();
for (TaxonomyLevel level : levels) {
if (sb.length() > 0)
sb.append(", ");
sb.append(StringHelper.escapeHtml(level.getDisplayName()));
}
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
String text = translate("confirmation.delete.level", new String[] { sb.toString() });
layoutCont.contextPut("msg", text);
layoutCont.contextPut("msgForList", translate("error.delete.num"));
buildDangerMessage(layoutCont);
}
List<String> keyList = new ArrayList<>();
List<String> valueList = new ArrayList<>();
keyList.add("-");
valueList.add("-");
buildMergeToSelection(treeModel.getRootNode(), "", keyList, valueList);
mergeToEl = uifactory.addDropdownSingleselect("mergeto", "merge.to", formLayout, keyList.toArray(new String[keyList.size()]), valueList.toArray(new String[valueList.size()]), null);
mergeToEl.setEscapeHtml(false);
uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
uifactory.addFormSubmitButton("delete", formLayout);
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class EditTaxonomyLevelController method getTypes.
private List<TaxonomyLevelType> getTypes() {
List<TaxonomyLevelType> types = new ArrayList<>();
if (level != null) {
List<TaxonomyLevel> parentLine = taxonomyService.getTaxonomyLevelParentLine(level, taxonomy);
for (int i = parentLine.size() - 1; i-- > 0; ) {
TaxonomyLevel parent = parentLine.get(i);
TaxonomyLevelType parentType = parent.getType();
if (parentType != null) {
Set<TaxonomyLevelTypeToType> typeToTypes = parentType.getAllowedTaxonomyLevelSubTypes();
for (TaxonomyLevelTypeToType typeToType : typeToTypes) {
if (typeToType != null) {
types.add(typeToType.getAllowedSubTaxonomyLevelType());
}
}
break;
}
}
}
if (types.isEmpty()) {
types.addAll(taxonomyService.getTaxonomyLevelTypes(taxonomy));
} else if (level != null && level.getType() != null) {
if (!types.contains(level.getType())) {
types.add(level.getType());
}
}
return types;
}
use of org.olat.modules.taxonomy.TaxonomyLevel 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.TaxonomyLevel in project openolat by klemens.
the class TaxonomyLevelDAO method updateTaxonomyLevel.
public TaxonomyLevel updateTaxonomyLevel(TaxonomyLevel level) {
TaxonomyLevel parentLevel = getParent(level);
String path = level.getMaterializedPathIdentifiers();
String newPath = getMaterializedPathIdentifiers(parentLevel, level);
boolean updatePath = !newPath.equals(path);
if (updatePath) {
((TaxonomyLevelImpl) level).setMaterializedPathIdentifiers(newPath);
}
((TaxonomyLevelImpl) level).setLastModified(new Date());
TaxonomyLevel mergedLevel = dbInstance.getCurrentEntityManager().merge(level);
if (updatePath) {
List<TaxonomyLevel> descendants = getDescendants(mergedLevel, mergedLevel.getTaxonomy());
for (TaxonomyLevel descendant : descendants) {
String descendantPath = descendant.getMaterializedPathIdentifiers();
if (descendantPath.indexOf(path) == 0) {
String end = descendantPath.substring(path.length(), descendantPath.length());
String updatedPath = newPath + end;
((TaxonomyLevelImpl) descendant).setMaterializedPathIdentifiers(updatedPath);
}
dbInstance.getCurrentEntityManager().merge(descendant);
}
}
return mergedLevel;
}
Aggregations