cancel
Showing results for 
Search instead for 
Did you mean: 

is luceneDateRange working on cron scheduled actions?

efestione
Champ in-the-making
Champ in-the-making
Hi all,
I am going crazy!  Smiley Happy
I have configured the scheduled action you can read below (alfresco 4.0.c):


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   
       <!–
    Define the model factory used to generate object models suitable for use with freemarker templates.
    –>
    <bean id="templateActionModelFactory" class="org.alfresco.repo.action.scheduled.FreeMarkerWithLuceneExtensionsModelFactory">
        <property name="serviceRegistry">
            <ref bean="ServiceRegistry"/>
        </property>
    </bean>
   
       <!–
    Execute the script /Company Home/Record Management/testscript.js
    –>
    <bean id="runScriptAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
        <property name="actionName">
            <value>script</value>
        </property>
        <property name="parameterTemplates">
            <map>
                <entry>
                    <key>
                        <value>script-ref</value>
                    </key>
                    <!– Note that as of Alfresco 4.0, due to a  Spring upgrade, the FreeMarker ${foo} entries must be escaped –>
                    <value>\$\{selectSingleNode('workspace://SpacesStore', 'lucene', 'PATH:"/app:company_home/app:dictionary/app:scripts/cm:send_mail.js"' )\}</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>
   
    <!–
   Run the script every minute - select the single node company home that is not used …
    –>
    <bean id="runScript" 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>
        <property name="queryTemplate">
            <!–<value>+@ia\:fromDate:\$\{luceneDateRange(now, \"P5D\")\} AND +PATH:"/app:company_home/st:sites/cm:prova/cm:calendar//*"</value>–>
         <value>+PATH:"/app:company_home/st:sites/cm:prova/cm:calendar//*" AND +@ia\:fromDate:[2012\-1\-20T00:00:00 TO 2012\-1\-30T00:00:00]</value>
         
        </property>
        <property name="cronExpression">
            <value>0 0/1 * * * ?</value>
        </property>
        <property name="jobName">
            <value>jobD</value>
        </property>
        <property name="jobGroup">
            <value>jobGroup</value>
        </property>
        <property name="triggerName">
            <value>triggerD</value>
        </property>
        <property name="triggerGroup">
            <value>triggerGroup</value>
        </property>
        <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="runScriptAction"/> <!– This is name of the action (bean) that gets run –>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean>
   
</beans>

If I use the query:
<value>+PATH:"/app:company_home/st:sites/cm:prova/cm:calendar//*" AND +@ia\:fromDate:[2012\-1\-20T00:00:00 TO 2012\-1\-30T00:00:00]</value>
everything goes fine.

If I use one of these others:
<value>+@ia\:fromDate:\$\{luceneDateRange(now, \"P10D\")\} AND +PATH:"/app:company_home/st:sites/cm:prova/cm:calendar//*"</value>
or
<value>+@ia\:fromDate:\$\{luceneDateRange(today, \"P10D\")\} AND +PATH:"/app:company_home/st:sites/cm:prova/cm:calendar//*"</value>
nothing happens (nodes are not selected).

Must I suspect a bug in luceneDateRange function?

Thanks for your help
Alex
4 REPLIES 4

efestione
Champ in-the-making
Champ in-the-making
Can anybody help me?

The reminder is almost completed, but I still have problems with the lucene query.

I need to obtain all the calendars event which have "fromDate = 2 days after the day the scheduled action runs".

which query should I use in your opinion?

mrogers
Star Contributor
Star Contributor
I'd work out the date to use and then add that to the query.

efestione
Champ in-the-making
Champ in-the-making
Thanks for your reply mrogers.

But, the query is hard coded in scheduled-action-services-context.xml which is read during the Alfresco's startup.
So, how can I do what you suggested?

efestione
Champ in-the-making
Champ in-the-making
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.