AnsweredAssumed Answered

Problem with date range in Template expression

Question asked by agey on Jul 16, 2009
Latest reply on Jul 16, 2009 by jayjayecl
Hi all,

I have a problem with a Lucene expression to configure a scheduled action. I have created a new action to transform the documents to pdf files. This action should be executed automatically every Saturday on the documents that have been created this week. The configuration in scheduled-action-services-context.xml is:


<bean id="transformPdfOCR" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
        <property name="actionName">
            <value>transformOCR</value>
        </property>
        <property name="parameterTemplates">
            <map>
                <entry>
                    <key>
                        <value>mime-type</value>
                    </key>
                    <value>application/pdf</value>
                </entry>
              
            </map>
        </property>
      
        <property name="templateActionModelFactory">
            <ref bean="templateActionModelFactory"/>
        </property>
        <property name="dictionaryService">
            <ref bean="DictionaryService"/>
        </property>
        <property name="actionService">
            <ref bean="ActionService"/>
        </property>
        <property name="templateService">
            <ref bean="TemplateService"/>
        </property>
    </bean>
  
    <bean id="programTransformOCR" class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">
        <property name="transactionMode">
            <value>UNTIL_FIRST_FAILURE</value>
        </property>
        <property name="compensatingActionMode">
            <value>IGNORE</value>
        </property>
        <property name="searchService">
            <ref bean="SearchService"/>
        </property>
        <property name="templateService">
            <ref bean="TemplateService"/>
        </property>
        <property name="queryLanguage">
            <value>lucene</value>
        </property>
        <property name="stores">
            <list>
                <value>workspace://SpacesStore</value>
            </list>
        </property>
        <!– Find all nodes that do not have the aspect –>
        <property name="queryTemplate">
            <value>+PATH:"/app:company_home/*//*" +TYPE:"{custom.model}Recorte" +@\{http\://www.alfresco.org/model/content/1.0\}content.mimetype:application/pdf +@cm\:created:${luceneDateRange(today, \"-P7D\")</value>
        </property>
        <property name="cronExpression">
            <value>0 */2 * * * ?</value>
        </property>
        <property name="jobName">
            <value>jobA</value>
        </property>
        <property name="jobGroup">
            <value>jobGroup</value>
        </property>
        <property name="triggerName">
            <value>triggerA</value>
        </property>
        <property name="triggerGroup">
            <value>triggerGroup</value>
        </property>
        <!– Inject the scheduler - the trigger will be registered with this scheduler –>
        <property name="scheduler">
            <ref bean="schedulerFactory"/>
        </property>
        <property name="actionService">
            <ref bean="ActionService"/>
        </property>
        <property name="templateActionModelFactory">
            <ref bean="templateActionModelFactory"/>
        </property>
        <property name="templateActionDefinition">
            <ref bean="transformPdfOCR"/>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean>

This action is never executed but if I change the "queryTemplate" in the configuration excluding the search by date range, the action is executed fine.


<property name="queryTemplate">
            <value>+PATH:"/app:company_home/*//*" +TYPE:"{custom.model}Recorte" +@\{http\://www.alfresco.org/model/content/1.0\}content.mimetype:application/pdf</value>
</property>

I use the expression showed on http://wiki.alfresco.com/wiki/Scheduled_Actions#Examples. Can someone point  me how the Template expression must be to limit the date range of creation of the documents?

Thanks a lot in advance.

NOTE: the "cronExpression" is set to run every 2 minutes for testing.

Outcomes