cancel
Showing results for 
Search instead for 
Did you mean: 

How to execute all rules on a scheduled time?

sbixsbix
Champ in-the-making
Champ in-the-making
Hi,
for my app I am trying to avoid the case of document with incomplete filling after upload, in other words when a doc has been uploaded, if the user clicks on "Cancel" on the "Modify Content Properties" without modifying anything, I have a "no-man's land document", which is a big problem for me.
I have tried with a folder rule, which runs when documents in the folder are updated and looks for some null properties but, unfortunately, this one seems to work only if ran on a second time, even if the document results as "updated" on the same time of when it has been uploaded.
So I am would like to try with a Scheduled action which will move these incomplete docs on a specific folder, using the rule I have described above.
From the documentation I have seen that Scheduled Actions need a Query (Lucene/SolR) before to execute something, but I don't need to identify any subject of the action, because the rule works (yes the second time it is ran, but works).
I just need to ExecuteAllRules on a scheduled time.
Is it possible?
4 REPLIES 4

alch3mi5t
Champ in-the-making
Champ in-the-making
You should look at this post, I've covered this problem last year, just let me know if you need help with that.
http://alch3mi5t.blogspot.it/2012/07/scheduled-custom-action-alfresco.html

sbixsbix
Champ in-the-making
Champ in-the-making
Alch3mi5t, don't take me bad, but I wrote "From the documentation I have seen that Scheduled Actions need a Query (Lucene/SolR) before to execute something, but I don't need to identify any subject of the action, because the rule works (yes the second time it is ran, but works).I just need to ExecuteAllRules on a scheduled time."
In your example there is a query, is it possible to do not execute any query (because it is implicit in a folder rule execution)?

nikes
Champ on-the-rise
Champ on-the-rise
You can check Scheduled Java actions.
Probably Quartz job.
Implement the Job interface.
import org.quartz.Job;

and write your logic in execute method of this interface.

Then, define bean config for the same containing cron expression.


<bean id="beanID" class="org.alfresco.util.CronTriggerBean">
        <property name="jobDetail">
            <bean id="ExpiringContractJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
                <property name="jobClass">
                    <value>customJobClassFullPath</value>
                </property>
                <property name="jobDataAsMap">
                    <map>                        
                        <entry key="transactionService">
                           <ref bean="transactionService"/>
                        </entry>
                  <entry key="personService">
                           <ref bean="personService"/>
                        </entry>
                  <entry key="authorityService">
                           <ref bean="authorityService"/>
                        </entry>   
                  <entry key="templateService">
                           <ref bean="templateService"/>
                        </entry>   
                        <entry key="searchService">
                           <ref bean="searchService"/>
                        </entry>
                        <entry key="nodeService">
                            <ref bean="nodeService"/>
                        </entry>
                        <entry key="permissionService">
                            <ref bean="permissionService"/>
                        </entry>
                        <entry key="namespaceService">
                            <ref bean="namespaceService"/>
                        </entry>
                        <entry key="actionService">
                            <ref bean="actionService"/>
                        </entry>
                        <entry key="authenticationComponent">
                        <ref bean="authenticationComponent"/>
                    </entry>
                </map>
                </property>
            </bean>
        </property>
        <property name="cronExpression">
            <value>55 30 2 1,16 * ?</value>
      </property>
        <property name="scheduler">
            <ref bean="schedulerFactory" />
        </property>
    </bean>


sbixsbix
Champ in-the-making
Champ in-the-making
I solved with a "sort of" based on the alch3mi5t suggestion.
I used an "always true" query, which returns always one item (All the spaces named "Sites" under "company home").
This query is almost immediate so I don't penalize the system with unnecessary work.
In this way the Java Script containing the real query is always triggered at the scheduled time.