Search in sources :

Example 1 with TaxonomyTreeNodeType

use of org.olat.modules.taxonomy.model.TaxonomyTreeNodeType 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;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyTreeNodeType(org.olat.modules.taxonomy.model.TaxonomyTreeNodeType)

Example 2 with TaxonomyTreeNodeType

use of org.olat.modules.taxonomy.model.TaxonomyTreeNodeType in project OpenOLAT by OpenOLAT.

the class TaxonomyTreeBuilder method getType.

private TaxonomyTreeNodeType getType(TaxonomyLevel taxonomyLevel) {
    TaxonomyTreeNodeType type;
    String identifier = taxonomyLevel.getIdentifier();
    if (StringHelper.containsNonWhitespace(identifier)) {
        if (lostAndFoundIdentifiers.contains(identifier)) {
            type = TaxonomyTreeNodeType.lostAndFound;
        } else {
            type = TaxonomyTreeNodeType.taxonomyLevel;
        }
    } else {
        type = TaxonomyTreeNodeType.taxonomyLevel;
    }
    return type;
}
Also used : TaxonomyTreeNodeType(org.olat.modules.taxonomy.model.TaxonomyTreeNodeType)

Example 3 with TaxonomyTreeNodeType

use of org.olat.modules.taxonomy.model.TaxonomyTreeNodeType in project openolat by klemens.

the class TaxonomyTreeBuilder method getType.

private TaxonomyTreeNodeType getType(TaxonomyLevel taxonomyLevel) {
    TaxonomyTreeNodeType type;
    String identifier = taxonomyLevel.getIdentifier();
    if (StringHelper.containsNonWhitespace(identifier)) {
        if (lostAndFoundIdentifiers.contains(identifier)) {
            type = TaxonomyTreeNodeType.lostAndFound;
        } else {
            type = TaxonomyTreeNodeType.taxonomyLevel;
        }
    } else {
        type = TaxonomyTreeNodeType.taxonomyLevel;
    }
    return type;
}
Also used : TaxonomyTreeNodeType(org.olat.modules.taxonomy.model.TaxonomyTreeNodeType)

Example 4 with TaxonomyTreeNodeType

use of org.olat.modules.taxonomy.model.TaxonomyTreeNodeType in project openolat by klemens.

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;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyTreeNodeType(org.olat.modules.taxonomy.model.TaxonomyTreeNodeType)

Aggregations

TaxonomyTreeNodeType (org.olat.modules.taxonomy.model.TaxonomyTreeNodeType)4 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)2 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)2 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)2