use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TaxonomyTreeNodeComparator method compare.
@Override
public int compare(INode i1, INode i2) {
if (i1 == null || i2 == null) {
return compareNullObjects(i1, i2);
}
Integer s1 = null;
Integer s2 = null;
String title1 = null;
String title2 = null;
TaxonomyTreeNodeType type1 = null;
TaxonomyTreeNodeType type2 = null;
if (i1 instanceof TaxonomyTreeNode) {
TaxonomyTreeNode t1 = (TaxonomyTreeNode) i1;
title1 = t1.getTitle();
type1 = t1.getType();
if (t1.getTaxonomyLevel() != null) {
s1 = t1.getTaxonomyLevel().getSortOrder();
}
} else if (i1 instanceof GenericTreeNode) {
GenericTreeNode node = (GenericTreeNode) i1;
title1 = node.getTitle();
Object uobject = node.getUserObject();
if (uobject instanceof TaxonomyLevel) {
TaxonomyLevel level = (TaxonomyLevel) uobject;
type1 = TaxonomyTreeNodeType.taxonomyLevel;
s1 = level.getSortOrder();
}
}
if (i2 instanceof TaxonomyTreeNode) {
TaxonomyTreeNode t2 = (TaxonomyTreeNode) i2;
title2 = t2.getTitle();
type2 = t2.getType();
if (t2.getTaxonomyLevel() != null) {
s2 = t2.getTaxonomyLevel().getSortOrder();
}
} else if (i1 instanceof GenericTreeNode) {
GenericTreeNode node = (GenericTreeNode) i2;
title2 = node.getTitle();
Object uobject = node.getUserObject();
if (uobject instanceof TaxonomyLevel) {
TaxonomyLevel level = (TaxonomyLevel) uobject;
type2 = TaxonomyTreeNodeType.taxonomyLevel;
s2 = level.getSortOrder();
}
}
int c = 0;
if (type1 == TaxonomyTreeNodeType.templates && type2 == TaxonomyTreeNodeType.templates) {
c = 0;
} else if (type1 == TaxonomyTreeNodeType.templates) {
return -1;
} else if (type2 == TaxonomyTreeNodeType.templates) {
return 1;
}
if (type1 == TaxonomyTreeNodeType.lostAndFound && type2 == TaxonomyTreeNodeType.lostAndFound) {
c = 0;
} else if (type1 == TaxonomyTreeNodeType.lostAndFound) {
return 1;
} else if (type2 == TaxonomyTreeNodeType.lostAndFound) {
return -1;
}
if (c == 0) {
if (s1 == null || s2 == null) {
c = compareNullObjects(s1, s2);
} else {
c = s1.compareTo(s2);
}
}
if (c == 0) {
if (title1 == null || title2 == null) {
c = compareNullObjects(title1, title2);
} else {
c = title1.compareTo(title2);
}
}
return c;
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelLibraryIndexer method checkAccess.
@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
if (roles.isOLATAdmin())
return true;
if ("TaxonomyLevel".equals(contextEntry.getOLATResourceable().getResourceableTypeName())) {
Long levelKey = contextEntry.getOLATResourceable().getResourceableId();
TaxonomyLevel level = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(levelKey));
TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(level.getTaxonomy(), identity, null, false, true, "Templates", null);
TreeModel model = builder.buildTreeModel();
List<TreeNode> flat = new ArrayList<>();
TreeHelper.makeTreeFlat(model.getRootNode(), flat);
for (TreeNode node : flat) {
TaxonomyTreeNode taxonomyNode = (TaxonomyTreeNode) node;
if (taxonomyNode.getType() == TaxonomyTreeNodeType.taxonomyLevel && level.equals(taxonomyNode.getTaxonomyLevel())) {
if (taxonomyNode.isDocumentsLibraryEnabled() && taxonomyNode.isCanRead()) {
return true;
}
}
}
}
return false;
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelLibraryIndexer method doIndex.
@Override
public void doIndex(SearchResourceContext parentResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
if (object instanceof TaxonomyLevel) {
TaxonomyLevel level = (TaxonomyLevel) object;
VFSContainer library = taxonomyService.getDocumentsLibrary(level);
if (library != null) {
SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
searchResourceContext.setBusinessControlFor(level);
searchResourceContext.setTitle(level.getDisplayName());
searchResourceContext.setDescription(level.getDescription());
searchResourceContext.setLastModified(level.getLastModified());
searchResourceContext.setCreatedDate(level.getCreationDate());
FolderIndexerWorker runnableFolderIndexer = new FolderIndexerWorker();
runnableFolderIndexer.setAccessRule(FolderIndexerAccess.FULL_ACCESS);
runnableFolderIndexer.setParentResourceContext(searchResourceContext);
runnableFolderIndexer.setContainer(library);
runnableFolderIndexer.setIndexWriter(indexerWriter);
runnableFolderIndexer.setFilePath("");
indexerWriter.submit(runnableFolderIndexer);
}
}
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class EditTaxonomyLevelController method buildPathKeysAndValues.
private void buildPathKeysAndValues(List<String> pathKeyList, List<String> pathValueList) {
pathKeyList.add("-");
pathValueList.add("");
List<TreeNode> nodeList = new TaxonomyAllTreesBuilder().getFlattedModel(taxonomy, false);
for (TreeNode node : nodeList) {
TaxonomyLevel taxonomyLevel = (TaxonomyLevel) node.getUserObject();
pathKeyList.add(taxonomyLevel.getKey().toString());
pathValueList.add(taxonomyLevel.getMaterializedPathIdentifiers());
}
}
Aggregations