I'm trying to put together a SQL2 query to find all of the rtePlugins under a cq:dialog node within a path.
Here is what I have so far:
select * from [nt:unstructured] as p where isdescendantnode (p, [/apps]) AND NAME(p)="rtePlugins"
But I'm missing the part where it needs to be under a cq:dialog
It should find these:
/apps/somename/components/page/main/page/cq:dialog/content/items/tabs/items/article/items/articleTitle/rtePlugins
But NOT find this
/apps/somename/components/page/main/page/dialog/content/items/tabs/items/article/items/articleTitle/rtePlugins
I've tried adding another isdescendantnode or contains ... but no luck so far.
Thank you in advance for any assistance.
-Dean
Solved! Go to Solution.
Views
Replies
Total Likes
Views
Replies
Total Likes
I will look into this tool - my first observation is can you try and make the path you list for isdescendantnode a deeper JCR path - see if that helps.
Views
Replies
Total Likes
Hey Scott,
The problem I have is that once it gets under apps, things are all dynamic ... at least projects and page names will be different.
/apps/somename-1/components/page/main/page/cq:dialog/content/items/tabs/items/article/items/articleTitle/rtePlugins
/apps/somename-2/components/page-a/main/component-4/cq:dialog/content/items/tabs/items/article/items/articleTitle/rtePlugins
/apps/somename-3/components/page1/main/component-6/cq:dialog/content/items/tabs/items/article/items/articleTitle/rtePlugins
-Dean
Views
Replies
Total Likes
I ran this same query and its picking up all of the nodes -- see:
What JCR JAR are you using?
Views
Replies
Total Likes
This code is picking up all nodes for me. I am getting a few other super users to test too. I have included:
jackrabbit-standalone-2.6.5.jar
Code:
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import javax.jcr.Node;
import javax.jcr.query.Query;
import org.apache.jackrabbit.commons.JcrUtils;
public class TestJCR {
public static void main(String [] args)
{
try {
String aemUrl = "http://localhost:4502/crx/server" ;
//Create a connection to the CQ repository running on local host
Repository repository = JcrUtils.getRepository(aemUrl);
//Create a Session
javax.jcr.Session session = repository.login( new SimpleCredentials("admin", "admin".toCharArray()));
//Obtain the query manager for the session ...
javax.jcr.query.QueryManager queryManager = session.getWorkspace().getQueryManager();
//Specify the AEM JCR path where examples users are stored at /home/users/test
String sqlStatement = "select * from [nt:unstructured] as p where isdescendantnode (p, [/apps]) AND NAME(p)='rtePlugins'";
javax.jcr.query.Query query = queryManager.createQuery(sqlStatement,"JCR-SQL2");
//Execute the query and get the results ...
javax.jcr.query.QueryResult result = query.execute();
//Iterate over the nodes in the results ...
javax.jcr.NodeIterator nodeIter = result.getNodes();
long mySize = nodeIter.getSize();
while ( nodeIter.hasNext() ) {
//For each node-- get the path of the node
javax.jcr.Node node = nodeIter.nextNode();
String myPath = node.getPath();
System.out.println(myPath);
}
// Save the session changes and log out
session.save();
session.logout();
}
catch(Exception e){
e.printStackTrace();
}
}
}
Views
Replies
Total Likes
It picks up these:
/apps/touchRTE/components/text/cq:editConfig/cq:inplaceEditing/config/rtePlugins
/apps/touchRTE/components/text/dialog/items/tab1/items/text/rtePlugins
/apps/vmwaredevapp/components/content/hcontentcard/cq:dialog/content/items/image/items/column/items/body/rtePlugins
/apps/vmwaredevapp/components/content/hcontentcard/dialog/items/basic/items/body/rtePlugins
/apps/geometrixx-media/components/welcome-message/dialog/items/tab1/items/description/rtePlugins
/apps/geometrixx-gov/components/image/dialog/items/text/rtePlugins
/apps/geometrixx-gov/components/text/dialog/items/tab1/items/text/rtePlugins
which is correct.
Views
Replies
Total Likes
As discussed, one way is to process the result set and place the paths that meet your requirements into a collection.
Views
Replies
Total Likes
Append your query with this:
AND [jcr:path] like '%/cq:dialog/%'
Views
Replies
Total Likes
Thank you Scott for all your help!!!!!
I can use the JCR API to make this work ... Antons solution will allow me to do this just using one query.
select * from [nt:unstructured] as p where isdescendantnode (p, [/apps]) AND [jcr:path] like '%cq:dialog%' AND NAME(p) LIKE 'rtePlugins'
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies