Customize the CQ-DAM search panel | Community
Skip to main content
Level 4
October 16, 2015
Solved

Customize the CQ-DAM search panel

  • October 16, 2015
  • 11 replies
  • 2094 views

Hi masters!

I’m trying to customize the CQ-DAM search panel, in damadmin console. I’m following instructions in [1].

I’ve successfully added a new optionspredicate to add a custom search for ‘activated/deactivated’ assets, looking for a ‘jcr:content/cq:lastReplicationAction’ property, with ‘Activate’ and ‘Deactivate’ values. Nice! smiley

The question is... I would like to add a predicate to filter assets that have a pending activation (thus, assets marked in the ‘Status’ column with a calendar icon, with a message like ‘Task Scheduled…’)

But I don’t know where this information is stored in the JCR repository, and how to define a new predicate with this information. Is it possible?

Do you have any advice?

Thank you very much!

 [1] http://dev.day.com/docs/en/cq/current/dam/extending-cq-dam-search.html

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 smacdonald2008

This is the reply from our Eng team:

That is not a simple predicate addition, because pending activation is not directly stored in some jcr property but is derived from jcr:content/cq:lastReplicationAction and then looking at the replication queue.

So, one will have to implement a filtering predicate
https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/search/eval/AbstractPredicateEvaluator.html

little bit of code that can help you find it is pending goes like this
replicationStatus = resource.adaptTo(ReplicationStatus.class);

https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/replication/ReplicationStatus.html#isPending()

Hope this helps.

11 replies

smacdonald2008
Level 10
October 16, 2015

That is a good question. I will pass this question to the Eng team.

Creating a predicate to filter assets that have a pending activation is something that is not documented. But we will add this to the list. 

Level 4
October 16, 2015

Thank you smacdonald2008! I'll be waiting for any news from Eng team. For our customer is important to have a list with the next assets planned to be published. I think it should be a very interesting functionality for many others customers...

smacdonald2008
Level 10
October 16, 2015

I agree -  this will make a good community article - i will add this to our list to document.

I have passed this question to the Eng team. I am hoping to hear back from them soon. 

Level 4
October 16, 2015

In addition, it would be great to know how to add the 'Status' column to the search panel, because this column is only visible in the 'Digital Assets' panel. Without the 'Status' column in the search panel, we will get the results, but we won't have the information about the planned publish date.

Thank you again :-)

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

This is the reply from our Eng team:

That is not a simple predicate addition, because pending activation is not directly stored in some jcr property but is derived from jcr:content/cq:lastReplicationAction and then looking at the replication queue.

So, one will have to implement a filtering predicate
https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/search/eval/AbstractPredicateEvaluator.html

little bit of code that can help you find it is pending goes like this
replicationStatus = resource.adaptTo(ReplicationStatus.class);

https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/replication/ReplicationStatus.html#isPending()

Hope this helps.

Level 4
October 16, 2015

Hi smacdonald2008.

I've tried with a dummy component to test the ReplicationStatus.isPending() functionality (code at [1]). But the isPending() method always return 'false'. I've tried with a 'no activated' image, but with the activation pending marked in the 'status' column.

For recheck purposes, I've tried with activated images too, with and without pending activation, and getLastReplicationAction() is working fine, but isPending() always return 'false'.

Could you help me? Any advice will be very appreciated.

[1]

<%-- test Replication Status component. test Replication Status Component --%><% %><%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" %><% %><%@page import="org.apache.sling.api.resource.Resource"%><% %><%@page import="com.day.cq.replication.ReplicationStatus"%><% %><%@page import="javax.jcr.Session"%><% %><cq:defineObjects /><% // TODO add you code here //Session session = currentNode.getSession(); //Resource res = resourceResolver.getResource("/content/dam/test/Hydrangeas.jpg"); Resource res = resourceResolver.getResource("/content/dam/test/Lighthouse.jpg"); ReplicationStatus replicationStatus = res.adaptTo(ReplicationStatus.class); %><h1>test Replication Status component</h1> res.getPath() = <%=res.getPath()%><br/> res.getName() = <%=res.getName()%><br/> replicationStatus.isPending() = <%=replicationStatus.isPending()%><br/> replicationStatus.getLastReplicationAction() = <%=replicationStatus.getLastReplicationAction()%><br/>
Level 4
October 16, 2015

Hi smacdonald2008!

Have you been able to ask the last question to Eng. Team (about the 'isPending()' method)?

Could you help me, please? Any advise will be veru appreciated!

Thank you very much!

smacdonald2008
Level 10
October 16, 2015

With your code - you can never get a return value of true?  I will pass this to the Eng team again.

Sham_HC
Level 10
October 16, 2015

Are you using the right user session ?   All damadmin uses same API & indicates status so should work.  Try with admin session instead of user session & verify.

Level 4
October 16, 2015

@smacdonald2008: Correct: I never get a return value of true. This is a screenshot of the images referenced in the code:

[img]image1.png[/img]

As you could see, both images has pending activation. One of them is published, and the other is not published.

 

@Sham HC: I've made the tests with admin user, so I suppose the user session should not be the problem. Correct?

 

Thank you very much to both.