ordering the directoryTree

I would like to know how I can impose a sort according to the vocabulary order element on the way a directoryTree is displayed.

For example, in this code

<extension target="org.nuxeo.ecm.directory.ui.DirectoryUIManager"
    point="directories">

    <directory name="topic" layout="vocabulary" sortField="ordering">
      <deleteConstraint
        class="org.nuxeo.ecm.directory.api.ui.HierarchicalDirectoryUIDeleteConstraint">
        <property name="targetDirectory">subtopic</property>
        <property name="targetDirectoryField">parent</property>
      </deleteConstraint>
    </directory>
    <directory name="subtopic" layout="subtopic_vocabulary" sortField="parent" />

</extension>

the attribute sortFied=“ordering” in the first line, will cause any directory widget to correctly sort the directory for display according to the order field, but this has no affect on the associated directory tree widget.

The directoryTree bySubjectsNavigation, which displays this topic/subtopic tree will continue sorting the topics in ascending order by the label element. I cannot find any way to change this.

Can you tell me how to get the tree to sort by the vocabulary order element, or by some other mechanism. Thanks in advance

Neil

1 votes

1 answers

1161 views

ANSWER

I am surmising that the sort command on the second last line in this code snippet from the DirectoryTreeService class is the reason why the Tree will always be presented in Alpha order. I am just wondering about what gets sorted. In the dc_subjects table there is a 'pos' integer column that I suspect may be intended to give more control to this ordering. So my question is can I use the contents of this field and will it get sorted before the 'item' string column.

   /**
     * Returns only the enabled Directory Trees marked
     * as being also Navigation Trees.
     *
     * @since 5.4
     */
    public List&lt;String&gt; getNavigationDirectoryTrees() {
        List&lt;String&gt; directoryTrees = new ArrayList&lt;String&gt;();
        for (DirectoryTreeDescriptor desc : registry.values()) {
            if (desc.getEnabled() &amp;&amp; desc.isNavigationTree()) {
                directoryTrees.add(desc.getName());
            }
        }
        Collections.sort(directoryTrees);
        return directoryTrees;
    }
02/23/2012



The contribution to DirectoryUIManager is used to display the vocabulary in the “manage vocabularies” page in the admin center: it has no control over the way this vocabulary will be presented as a tree.

The above sort code orders directory trees so it will have an impact on the order of trees one compared to another, bu i don't think it has anything to do with the order of the vocabulary entries themselves.

I think you should be looking at DirectoryTreeNode#FieldComparator that is used to perform this sort. It's quite hard-coded right now, this should ideally be made configurable on the directory tree service extension points. Using the vocabulary ordering is indeed a legitimate need.

0 votes



Hello,

"this should ideally be made configurable on the directory tree service extension points. Using the vocabulary ordering is indeed a legitimate need"

Do you think it would be available shortly ?

It seems that DirectoryTreeNode#FieldComparator sorts but that do not for my directory entries. When a poweruser enter a new value, it appear at the bottom of entries list…

09/30/2013