AnsweredAssumed Answered

scheduled action not returning results

Question asked by msj4u on Dec 12, 2013
Latest reply on Jan 7, 2014 by msj4u
hello,

wrt https://forums.alfresco.com/forum/end-user-discussions/alfresco-explorer/contentdocument-expiry-12042013-1316

Used the CronScheduledQueryBasedTemplateActionDefinition just to schedule something so that i can moveon (used the example code to update the createdon property)

scheduler runs but debugging CronScheduledQueryBasedTemplateActionDefinition.java i found that no results were returning for my query.

i was trying with lucene query

<property name="queryTemplate">
            <value>ASPECT:"{http://www.123company.com/product123/model/content/1.0}expireable"</value>
        </property>


but reading JeffPott's article from http://ecmarchitect.com i also found example of cmis-alfresco based query so i wrote


<property name="queryTemplate">
            <value>select d.* from cmis:document as d join pd:expireable as pd on d.cmis:objectId = pd.cmis:objectId</value>
        </property>


still it is not returning any results :(

what am i missing ????

my pdMode.xml

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

<model name="pd:productmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>product123 Custom Model</description>
   <author>Saqib Javed</author>
   <version>1.0</version>
   
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
   </imports>
   
   <namespaces>
      <namespace uri="http://www.123company.com/product123/model/content/1.0" prefix="pd" />
   </namespaces>
   
   <aspects>
      <aspect name="pd:expireable">
         <title>Expireable</title>
         <properties>
            <property name="pd:expiry">
               <type>d:datetime</type>
               <mandatory>true</mandatory>
            </property>
         </properties>
      </aspect>
   </aspects>
</model>


my scheduled-action-services-context.xml

<?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>
   
    <!–
    An example that sets the created date to now
    –>
    <bean id="setCreatedDateAction" class="org.alfresco.repo.action.scheduled.SimpleTemplateActionDefinition">
        <property name="actionName">
            <value>set-property-value</value>
        </property>
        <property name="parameterTemplates">
            <map>
                <entry>
                    <key>
                        <value>property</value>
                    </key>
                    <value>{http://www.alfresco.org/model/content/1.0}created</value>
                </entry>
                <entry>
                    <key>
                        <value>value</value>
                    </key>
                    <!– Note - FreeMarker ${..} entries must be escaped in Spring context files –>
                    <value>\$\{today?string("yyyy-MM-dd'T'HH:mm:ss.sss'Z'")\}</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="setCreatedDateActionEveryTenMinutes" class="org.alfresco.repo.action.scheduled.CronScheduledQueryBasedTemplateActionDefinition">
        <property name="transactionMode">
            <value>ISOLATED_TRANSACTIONS</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>cmis-alfresco</value>
        </property>
        <property name="stores">
            <list>
                <value>workspace://SpacesStore</value>
            </list>
        </property>
        <property name="queryTemplate">
            <value>select d.* from cmis:document as d join pd:expireable as pd on d.cmis:objectId = pd.cmis:objectId</value>
        </property>
        <property name="cronExpression">
            <value>0 0/1 * * * ?</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>
        <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="setCreatedDateAction"/> <!– action reference here –>
        </property>
        <property name="transactionService">
            <ref bean="TransactionService"/>
        </property>
        <property name="runAsUser">
            <value>System</value>
        </property>
    </bean>
   
</beans>

Outcomes