I want to list down the groups which does not associate with any USERS, Brand Folders directly or indirectly. | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Kamal_Kishor
Kamal_KishorAccepted solution
New Participant
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.

5 replies

kautuk_sahni
Employee
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.

Translate
Kautuk Sahni
kautuk_sahni
Employee
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.

Translate
Kautuk Sahni
Kamal_Kishor
New Participant
February 23, 2024

@tkhan415 : Please try with below in (assuming you are doing this locally, else replace the localhost and port) http://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

 

Translate
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

Translate
Kamal_Kishor
Kamal_KishorAccepted solution
New Participant
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.

Translate