I want to list down the groups which does not associate with any USERS, Brand Folders directly or indirectly. | Community
Skip to main content
Level 2
February 22, 2024
Solved

I want to list down the groups which does not associate with any USERS, Brand Folders directly or indirectly.

  • February 22, 2024
  • 3 replies
  • 1158 views

Hi Team,

I want to list down all the groups which does not associate with any USERS, Brand Folders directly or indirectly on my AEM 6.5, Can you Please suggest any sql 2 query.

 

Thanks,

User415

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kamal_Kishor

@tkhan415 : Yes, everything that we do in query builder can be converted to backend code.

 

// create query description as hash map (simplest way, same as form post) Map<String, String> map = new HashMap<String, String>(); // create query description as hash map (simplest way, same as form post) //I have done this with static values for demo, the values and property names can be dynamic as well. map.put("path", "/home/groups"); map.put("1_property", "jcr:primaryType"); map.put("1_property", "rep:Group"); map.put("2_property", "rep:members"); map.put("2_property.operation", "not"); map.put("p.limit", "-1"); // -1, gives all the matching results, if you set a postive value, it will return that many results Query query = builder.createQuery(PredicateGroup.create(map), session); SearchResult result = query.getResult();

 

You can refer this example and will be able to get an idea on how to do it: https://experienceleague.adobe.com/docs/experience-manager-65/content/implementing/developing/platform/query-builder/querybuilder-api.html?lang=en#example-query-builder-api-usage

thanks.

3 replies

Kamal_Kishor
Community Advisor
Community Advisor
February 23, 2024

@tkhan415 : Please try with below in (assuming you are doing this locally, else replace the localhost and porthttp://localhost:4502/libs/cq/search/content/querydebug.html

  • List of groups who are not associated with any other user or group.
path=/home/groups 1_property=jcr:primaryType 1_property.value=rep:Group 2_property=rep:members 2_property.operation=not p.limit=-1
  • List of groups who are associated with any specific user or group
path=/home/groups 1_property=jcr:primaryType 1_property.value=rep:Group 2_property=rep:members 2_property.value=<jcr:uuid of specific user or group> p.limit=-1

 

tkhan415Author
Level 2
February 26, 2024

Hi Kamal,

 

Can we convert this query to stand alone java code? If yes can you please share the code snippet.

 

Thanks,

User415

Kamal_Kishor
Community Advisor
Kamal_KishorCommunity AdvisorAccepted solution
Community Advisor
February 27, 2024

@tkhan415 : Yes, everything that we do in query builder can be converted to backend code.

 

// create query description as hash map (simplest way, same as form post) Map<String, String> map = new HashMap<String, String>(); // create query description as hash map (simplest way, same as form post) //I have done this with static values for demo, the values and property names can be dynamic as well. map.put("path", "/home/groups"); map.put("1_property", "jcr:primaryType"); map.put("1_property", "rep:Group"); map.put("2_property", "rep:members"); map.put("2_property.operation", "not"); map.put("p.limit", "-1"); // -1, gives all the matching results, if you set a postive value, it will return that many results Query query = builder.createQuery(PredicateGroup.create(map), session); SearchResult result = query.getResult();

 

You can refer this example and will be able to get an idea on how to do it: https://experienceleague.adobe.com/docs/experience-manager-65/content/implementing/developing/platform/query-builder/querybuilder-api.html?lang=en#example-query-builder-api-usage

thanks.

kautuk_sahni
Community Manager
Community Manager
February 28, 2024

@tkhan415  Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
kautuk_sahni
Community Manager
Community Manager
February 28, 2024

@tkhan415  Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni