Java Code Examples for org.alfresco.service.cmr.repository.ChildAssociationRef#setNthSibling()
The following examples show how to use
org.alfresco.service.cmr.repository.ChildAssociationRef#setNthSibling() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewXMLExporter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Helper to convert a path into an indexed path which uniquely identifies a node * * @param nodeRef NodeRef * @param path Path * @return Path */ private Path createIndexedPath(NodeRef nodeRef, Path path) { // Add indexes for same name siblings // TODO: Look at more efficient approach for (int i = path.size() - 1; i >= 0; i--) { Path.Element pathElement = path.get(i); if (i > 0 && pathElement instanceof Path.ChildAssocElement) { int index = 1; // for xpath index compatibility String searchPath = path.subPath(i).toPrefixString(namespaceService); List<NodeRef> siblings = searchService.selectNodes(nodeRef, searchPath, null, namespaceService, false); if (siblings.size() > 1) { ChildAssociationRef childAssoc = ((Path.ChildAssocElement)pathElement).getRef(); NodeRef childRef = childAssoc.getChildRef(); for (NodeRef sibling : siblings) { if (sibling.equals(childRef)) { childAssoc.setNthSibling(index); break; } index++; } } } } return path; }