-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sort Nodes: tool to sort JCR nodes by node name or title #2537
Sort Nodes: tool to sort JCR nodes by node name or title #2537
Conversation
The Cognitive Complexity warning should be ignored. I'd like to keep that method as it is |
All you have to do is take the body of each of the conditional statements and make each its own method. |
2 notes of unsolicited feedback
|
Understanding this a bigger change, but WDYT about allowing for the sorting to be pluggable, so users could implement their own sorters? We could provide an "OOTB" sorter Title, but someone could create one for last modified, or whatever? I think the sorting of the hierarchy first could be OOTB and apply to any potential sorter. In the Conf UI, we could have a dropdown that is driven by a datasource that lists all available sorters in the system. WDYT, overkill? This is a great feature, i just expect ppl would like to sort on custom attributes as well (or things that are not title). |
It might be a good idea. NodeComparator will be a pluggable service and the POST operation will somehow resolve it from the request. The OOTB implementation will include NodeName and NodeTitle implementations and user can plug in their custom sorters. |
Good to know. I still I think my tool will be useful . 6.5 SP7+ might support sorting in collection views, but not in the pathbrowser component which shows items in their repository order.
Agree. A drop-down would be more intuitive. |
I checked-in support for pluggable sorters and updated the UI to select a sorter from a drop-down, see the updated screenshots |
Pull Request Test Coverage Report for Build 6322
💛 - Coveralls |
This was merged through #2544 which included a switch from WCMUse to SlingModel for the Sorters util |
Sometimes it is useful to re-order nodes in the repository by node name or title so that:
The patch extends the Sling POST Servlet with the acs-commons:sortNodes operation and and a simple GUI to execute it:
sort children of /content/someFolder by node name, case-insensitive (defaults)
sort children of /content/someFolder by jcr:title, case-sensitive
AEM GUI
In AEM, navigate to the Tools > ACS AEM Commons > Sort JCR Nodes
In the path field, enter the the target path to sort. You can choose whether to sort by node name (default) or by jcr:title and whether sort should be case-sensitive.
Request Parameters
:sorterName
To select the actual sorter to execute, the
:sorterName
request parameter is used. Out of the box, the SortNodesOperation supports the following sorters:byName
byTitle
:caseSensitive
Optional boolean parameter to control whether sort should be case sensitive (default:
false
), e.g.You can turn it off by setting the
-F":caseSensitive=true"
request parameter and the order will change to:nonHierarchyFirst
Optional boolean parameter to control whether sort should move non-hierarchy nodes to the top (default:
true
)The default value is
true
which means jcr:content, rep:policy and such will be sorted first followed by other, hierarchy nodes like cq:Page, e.g.You can turn it off by setting the
-F":nonHierarchyFirst=false"
parameterwhich will switch the mode to sort nodes regardless if they are
nt:hierarchyNode
or notExtending SortNodesOperation
OSGi services of the com.adobe.acs.commons.sorter.NodeSorter type can be used to implement new node sorters. For example, to register a sorter by sling:resourceType deploy the service below:
Once the ResourceTypeSorter service is deployed you should be able to select the new sorter in the UI:
or pass it as
-F":sorterName=resourceType"
request parameter to curl:Documentation is in another PR: Adobe-Consulting-Services/adobe-consulting-services.github.io#205