AnsweredAssumed Answered

Utilisation d'une classe Java dans un timer

Question asked by mlagneaux on May 3, 2010
Latest reply on May 6, 2010 by mlagneaux
Bonjour,

Je travaille actuellement sur un workflow avancé. Après une première version fonctionnant correctement, j'essaye maintenant d'intégrer un timer sur certaines tâches de ce workflow.

Voici le code du workflow en question :
<?xml version="1.0" encoding="UTF-8"?>
<!– urn:jbpm.org:jpdl-3.1 –>
<process-definition  xmlns="urn:jbpm.org:jpdl-3.1" xmlns:scwf="http://www.cea.fr/model/workflow/1.0"  name="scwf:ProcHierarchicalValidation">


   <!–Definition des swimlanes–>
   <swimlane name="initiator">
   </swimlane>
   
   <swimlane name="auteur">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{author}</actor>
        </assignment>
   </swimlane>
   
   <swimlane name="co-auteurs">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
            <actor>#{scwf_co_authors}</actor>
        </assignment>
   </swimlane>
   
   <swimlane name="verificateurs">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{scwf_verifiers}</actor>
      </assignment>
   </swimlane>
   
   <swimlane name="chef-de-groupe">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{scwf_group_leader}</actor>
      </assignment>
   </swimlane>
   
   <swimlane name="approbateur">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{scwf_approver}</actor>
      </assignment>
   </swimlane>
   
   <swimlane name="autre_verificateur">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{scwf_other_verifier}</actor>
      </assignment>
   </swimlane>

      
   <!– Definition du process –>
   <start-state name="start-state1">
      <task name="bpm:startTask" swimlane="initiator"/>
      <transition to="Chef de groupe à saisir ?" name="Intervenants à saisir">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <variable name="author" access="write" />
               <expression>
                  var test = bpm_package;
                  var doc = test.children[0];
                  doc.properties["cm:status"] = "En cours de validation";
                  doc.save();
                  author = doc.getOwner();
               </expression>
            </script>
         </action>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <variable name="scwf_co_authors" access="write" />
               <expression>
                  var test = bpm_package;
                  var doc = test.children[0];
                  scwf_co_authors = doc.properties["cm:coAuthor"];
                  if(scwf_co_authors == null){
                     scwf_co_authors = "Aucun";
                  }
               </expression>
            </script>
         </action>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="author" access="read" />
               <variable name="personName" access="write" />
               <expression>
                  personName = author;
               </expression>
            </script>
         </action>
         <script>
            <variable name="personName" access="read" />
            <variable name="hierarchicalPersonInCharge" access="write" />            
            <expression>
            </expression>
         </script>
         <action class="fr.cea.bpm.HierarchicalPersonInChargeGetter"/>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="hierarchicalPersonInCharge" access="read" />
               <variable name="scwf_group_leader" access="write" />
               <expression>
                  scwf_group_leader = hierarchicalPersonInCharge;
               </expression>
            </script>
         </action>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="scwf_group_leader" access="read" />
               <variable name="username" access="write" />
               <expression>
                  username = scwf_group_leader;
               </expression>
            </script>
         </action>
         <script>
            <variable name="username" access="read" />
            <variable name="name" access="write" />            
            <expression>
            </expression>
         </script>
         <action class="fr.cea.bpm.PersonNameGetter"/>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="name" access="read" />
               <variable name="scwf_group_leader_name" access="write" />
               <expression>
                  scwf_group_leader_name = name;
               </expression>
            </script>
         </action>
      </transition>
   </start-state>
   
   <decision name="Chef de groupe à saisir ?">
      <transition to="Saisie intervenants" name="Non">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="people" access="read" />
               <variable name="scwf_group_leader" access="read,write" />
               <expression>
                  scwf_group_leader = people.getPerson(scwf_group_leader);
               </expression>
            </script>
         </action>
      </transition>
      <transition to="Saisie intervenants (dont Chef de groupe)" name="Oui">
         <condition>#{scwf_group_leader==null}</condition>
      </transition>
   </decision>

   <task-node name="Saisie intervenants">
      <task name="scwf:wf1SaisieIntervenantsTask" swimlane="initiator"/>
      <event type="task-create">
         <action class="fr.cea.bpm.ExecutionTimerGetter"/>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="execution_timer" access="read" />
               <variable name="scwf_execution_timer" access="write" />
               <expression>
                  scwf_execution_timer = execution_timer;
               </expression>
            </script>
         </action>
      </event>
      <transition to="co-auteur(s) ?" name="OK">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="scwf_execution_timer" access="read" />
               <variable name="scwf_task_due_date" access="write" />
               <expression>
                  var due_date = new Date();
                  due_date.setMinutes(due_date.getMinutes()+scwf_execution_timer);
                  scwf_task_due_date = due_date;
               </expression>
            </script>
         </action>
      </transition>
      <transition to="end-state1" name="Arrêter le workflow">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <expression>
                  var test = bpm_package;
                  var doc = test.children[0];
                  doc.properties["cm:status"] = "Brouillon";
                  doc.save();
               </expression>
            </script>
         </action>
      </transition>
   </task-node>
   
   <task-node name="Saisie intervenants (dont Chef de groupe)">
      <task name="scwf:wf1SaisieIntervenantsDontChefDeGroupeTask" swimlane="initiator"/>
      <event type="task-create">
         <action class="fr.cea.bpm.ExecutionTimerGetter"/>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="execution_timer" access="read" />
               <variable name="scwf_execution_timer" access="write" />
               <expression>
                  scwf_execution_timer = execution_timer;
               </expression>
            </script>
         </action>
      </event>
      <transition to="co-auteur(s) ?" name="OK">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="scwf_execution_timer" access="read" />
               <variable name="scwf_task_due_date" access="write" />
               <expression>
                  var due_date = new Date();
                  due_date.setMinutes(due_date.getMinutes()+scwf_execution_timer);
                  scwf_task_due_date = due_date;
               </expression>
            </script>
         </action>
      </transition>
      <transition to="end-state1" name="Arrêter le workflow">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <expression>
                  var test = bpm_package;
                  var doc = test.children[0];
                  doc.properties["cm:status"] = "Brouillon";
                  doc.save();
               </expression>
            </script>
         </action>
      </transition>
   </task-node>

   <decision name="co-auteur(s) ?">
      <transition to="Affectation aux co-auteurs" name="Oui"></transition>
      <transition to="Vérificateurs ?" name="Non">
         <condition>#{scwf_co_authors == null || scwf_co_authors == "Aucun"}</condition>
      </transition>
   </decision>

   <node name="Affectation aux co-auteurs">
      <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
         <foreach>#{scwf_co_authors}</foreach>
         <var>co_author</var>
      </action>
      <event type="node-enter">
         <script>
            <variable name="wf1_reject_count" access="write" />
            <expression>
               wf1_reject_count = 0;
            </expression>
         </script>
      </event>
      <transition to="Commentaires et validation co-auteurs"></transition>
   </node>
   
   <task-node name="Commentaires et validation co-auteurs">
      <task name="scwf:wf1ValidationCoAuteurTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
              <actor>#{co_author}</actor>
            </assignment>
         <event type="task-create">
            <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                  var test = bpm_package;
                  var doc = test.children[0];
                  var documentName = doc.properties["cm:name"];
                  var taskDescription = "Validation du document par les co-auteurs";
                  var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
                  var co_author_person = people.getPerson(co_author);
               
                  var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-with-deadline-email.ftl\"");
                  var template = results[0];
               
                  var args = [];
                  args["notifiedPersonRef"] = co_author_person.nodeRef.toString();
                  args["documentName"] = documentName;
                  args["taskDescription"] = taskDescription;
               
                  args["timer"] = scwf_execution_timer;
                  var mail_text = doc.processTemplate(template, args);
               
                  var mail = actions.create("mail");
                  mail.parameters.to = co_author_person.properties["cm:email"];
                  mail.parameters.subject = subject;
                  mail.parameters.text = mail_text;
                  mail.execute(bpm_package);
               </script>
            </action>
         </event>
         <timer duedate="#{scwf_task_due_date}">
            <action class="fr.cea.bpm.TaskEndHandler"/>
            <!– <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <script>
                  var test = bpm_package;
                  var doc = test.children[0];
                  var documentName = doc.properties["cm:name"];
                  var taskDescription = "Validation du document par les co-auteurs";
                  var subject = "Dépassement du délai pour la tâche \""+taskDescription+"\" : validation automatique du document "+documentName;
                  var co_author_person = people.getPerson(co_author);
               
                  var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-expired-deadline-email.ftl\"");
                  var template = results[0];
                  
                  var args = [];
                  args["validatorRef"] = co_author_person.nodeRef.toString();
                  args["documentName"] = documentName;
               
                  var mail_text = doc.processTemplate(template, args);
               
                  var mail = actions.create("mail");
                  var to_many = new Array(co_author_person.properties["cm:email"], initiator.properties["cm:email"]);
                  mail.parameters.to_many = to_many;
                  mail.parameters.subject = subject;
                  mail.parameters.text = mail_text;
                   mail.execute(bpm_package);
               </script>
            </action> –>
         </timer>
      </task>
      <transition to="join1" name="Valider"></transition>
      <transition to="join1" name="Ne pas valider">
         <script>
            <variable name="wf1_reject_count" access="read,write" />
            <expression>
               wf1_reject_count = wf1_reject_count + 1;
            </expression>
         </script>
      </transition>
   </task-node>
   
   <join name="join1">
      <transition to="Au moins une non validation ?"></transition>
   </join>
   
   <task-node name="Commentaires et validation vérificateurs">
      <task name="scwf:wf1ValidationVerificateursTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
              <actor>#{verifier}</actor>
            </assignment>
         </task>
         <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Validation du document par les vérificateurs";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-with-deadline-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = verifier.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;
               
               args["timer"] = scwf_execution_timer;
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = verifier.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
         </event>
      <transition to="join2" name="Valider"></transition>
      <transition to="join2" name="Ne pas valider : mise à jour mineure">
         <script>
            <variable name="wf1_reject_count_minor" access="read,write" />
            <expression>
               wf1_reject_count_minor = wf1_reject_count_minor + 1;
            </expression>
         </script>
      </transition>
      <transition to="join2" name="Ne pas valider : mise à jour majeure">
         <script>
            <variable name="wf1_reject_count_major" access="read,write" />
            <expression>
               wf1_reject_count_major = wf1_reject_count_major + 1;
            </expression>
         </script>
      </transition>
      <transition to="join2" name="Non concerné"></transition>
   </task-node>
   
   <join name="join2">
      <transition to="Au moins une non validation majeure ?"></transition>
   </join>

   <task-node name="Commentaires et validation chef de groupe">
      <task name="scwf:wf1ValidationChefDeGroupeTask" swimlane="chef-de-groupe"/>
      <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Validation du document par le chef de groupe";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = scwf_group_leader.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;
               
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = scwf_group_leader.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <transition to="Approbateur ?" name="Valider"></transition>
      <transition to="Mise à jour du document suite à non validation chef de groupe" name="Ne pas valider : mise à jour mineure"></transition>
      <transition to="Notification auteur suite à non validation majeure chef de groupe" name="Ne pas valider : mise à jour majeure"></transition>
      <transition to="Affectation aux vérificateurs demandés par chef de groupe" name="Ajout vérificateurs"></transition>
   </task-node>
   
   <task-node name="Commentaires et validation chef de groupe (avec saisie approbateur)">
      <task name="scwf:wf1ValidationChefDeGroupeAvecSaisieApprobateurTask" swimlane="chef-de-groupe">
         <event type="task-create">
            <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <runas>admin</runas>
               <script>
                  var test = bpm_package;
                  var doc = test.children[0];
                  var documentName = doc.properties["cm:name"];
                  var taskDescription = "Validation du document par le chef de groupe";
                  var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               
                  var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-email.ftl\"");
                  var template = results[0];
               
                  var args = [];
                  args["notifiedPersonRef"] = scwf_group_leader.nodeRef.toString();
                  args["documentName"] = documentName;
                  args["taskDescription"] = taskDescription;

                  var mail_text = doc.processTemplate(template, args);
                  
                  var mail = actions.create("mail");
                  mail.parameters.to = scwf_group_leader.properties["cm:email"];
                  mail.parameters.subject = subject;
                  mail.parameters.text = mail_text;
                  mail.execute(bpm_package);
               </script>
            </action>
         </event>
      </task>
      <transition to="Approbateur ?" name="Valider"></transition>
      <transition to="Mise à jour du document suite à non validation chef de groupe" name="Ne pas valider : mise à jour mineure"></transition>
      <transition to="Notification auteur suite à non validation majeure chef de groupe" name="Ne pas valider : mise à jour majeure"></transition>
      <transition to="Affectation aux vérificateurs demandés par chef de groupe" name="Ajout vérificateurs"></transition>
   </task-node>

   <decision name="Vérificateurs ?">
      <transition to="Affectation aux vérificateurs" name="Oui"></transition>
      <transition to="Chef de groupe ?" name="Non">
         <condition>#{scwf_verifiers==null}</condition>
      </transition>
   </decision>
   
   <node name="Affectation aux vérificateurs">
      <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
         <foreach>#{scwf_verifiers}</foreach>
         <var>verifier</var>
      </action>
      <event type="node-enter">
         <script>
            <variable name="wf1_reject_count_major" access="write" />
            <expression>
               wf1_reject_count_major = 0;
            </expression>
         </script>
         <script>
            <variable name="wf1_reject_count_minor" access="write" />
            <expression>
               wf1_reject_count_minor = 0;
            </expression>
         </script>
      </event>
      <transition to="Commentaires et validation vérificateurs"></transition>
   </node>

   <task-node name="Commentaires et validation approbateur">
      <task name="scwf:wf1ValidationApprobateurTask" swimlane="approbateur"/>
      <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Validation du document par l'approbateur";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = scwf_approver.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;
               
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = scwf_approver.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <transition to="Diffusion" name="Valider"></transition>
      <transition to="Mise à jour du document suite à non validation approbateur" name="Ne pas valider : mise à jour mineure"></transition>
      <transition to="Notification auteur suite à non validation majeure approbateur" name="Ne pas valider : mise à jour majeure"></transition>
      <transition to="Affectation aux vérificateurs demandés par approbateur" name="Ajout vérificateur(s)"></transition>
   </task-node>

   <node name="Diffusion">
      <transition to="end-state1">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <variable name="node" access="write"/>
               <expression>
                  var test = bpm_package;
                  var doc = test.children[0];
                  doc.properties["cm:status"] = "Approuvé";
                  doc.save();

                  node = doc;                  
               </expression>
            </script>
         </action>
         <script>
            <variable name="node" access="read" />
            <expression>
            </expression>
         </script>
         <action class="fr.cea.bpm.PublishContent"/>
      </transition>
   </node>

   <decision name="Chef de groupe ?">
      <transition to="Approbateur déjà connu ?" name="Oui"></transition>
      <transition to="Approbateur ?" name="Non">
         <condition>#{scwf_group_leader==null}</condition>
      </transition>
   </decision>
   
   <decision name="Approbateur déjà connu ?">
      <transition to="Approbateur saisi ?" name="Oui, saisi"></transition>
      <transition to="Approbateur à saisir ?" name="Non">
         <condition>#{scwf_approver==null}</condition>
      </transition>
   </decision>
   
   <decision name="Approbateur saisi ?">
      <transition to="Commentaires et validation chef de groupe (avec saisie approbateur)" name="Oui">
         <condition>#{scwf_approver_name==null}</condition>
      </transition>
      <transition to="Commentaires et validation chef de groupe" name="Non"></transition>
   </decision>
   
   <decision name="Approbateur à saisir ?">
      <event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="scwf_group_leader" access="read" />
               <variable name="personName" access="write" />
               <expression>
                  personName = scwf_group_leader.properties["cm:userName"];
               </expression>
            </script>
         </action>
         <script>
            <variable name="personName" access="read" />
            <variable name="hierarchicalPersonInCharge" access="write" />            
            <expression>
            </expression>
         </script>
         <action class="fr.cea.bpm.HierarchicalPersonInChargeGetter"/>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="hierarchicalPersonInCharge" access="read" />
               <variable name="scwf_approver" access="write" />
               <expression>
                  scwf_approver = hierarchicalPersonInCharge;
               </expression>
            </script>
         </action>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="scwf_approver" access="read" />
               <variable name="username" access="write" />
               <expression>
                  username = scwf_approver;
               </expression>
            </script>
         </action>
         <script>
            <variable name="username" access="read" />
            <variable name="name" access="write" />            
            <expression>
            </expression>
         </script>
         <action class="fr.cea.bpm.PersonNameGetter"/>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="name" access="read" />
               <variable name="scwf_approver_name" access="write" />
               <expression>
                  scwf_approver_name = name;
               </expression>
            </script>
         </action>
      </event>
      <transition to="Commentaires et validation chef de groupe" name="Non">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="people" access="read" />
               <variable name="scwf_approver" access="read,write" />
               <expression>
                  scwf_approver = people.getPerson(scwf_approver);
               </expression>
            </script>
         </action>
      </transition>
      <transition to="Commentaires et validation chef de groupe (avec saisie approbateur)" name="Oui">
         <condition>#{scwf_approver==null}</condition>
      </transition>
   </decision>

   <task-node name="Commentaires co-auteur(s) acceptés par l'auteur">
      <task name="scwf:wf1CommentairesCoAuteurAcceptesParAuteurTask" swimlane="auteur"/>
      <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Décision de l'auteur suite aux commentaires des co-auteurs";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               var author_person = people.getPerson(author);
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = author_person.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;

               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = author_person.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <transition to="Vérificateurs ?" name="Non"></transition>
      <transition to="Mise à jour du document suite à non validation co-auteur(s)" name="Oui"></transition>
   </task-node>

   <task-node name="Mise à jour du document suite à non validation co-auteur(s)">
      <task name="scwf:wf1MAJDocumentSuiteNonValidationCoAuteurTask" swimlane="auteur"/>
      <transition to="co-auteur(s) ?" name="Mise à jour du document terminée"></transition>
   </task-node>

   <decision name="Au moins une non validation ?">
      <transition to="Commentaires co-auteur(s) acceptés par l'auteur" name="Oui">
         <condition>#{wf1_reject_count != 0}</condition>
      </transition>
      <transition to="Vérificateurs ?" name="Non"></transition>
   </decision>
   
   <decision name="Au moins une non validation majeure ?">
      <transition to="Commentaires vérificateurs acceptés par l'auteur" name="Oui">
         <condition>#{wf1_reject_count_major != 0}</condition>
      </transition>
      <transition to="Au moins une non validation mineure ?" name="Non"></transition>
   </decision>
   
   <decision name="Au moins une non validation mineure ?">
      <transition to="Commentaires vérificateurs acceptés par l'auteur" name="Oui">
         <condition>#{wf1_reject_count_minor != 0}</condition>
      </transition>
      <transition to="Chef de groupe ?" name="Non"></transition>
   </decision>

   <task-node name="Commentaires vérificateurs acceptés par l'auteur">
      <task name="scwf:wf1CommentairesVerificateursAcceptesParAuteurTask" swimlane="auteur"/>
      <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription;
               if(wf1_reject_count_major != 0){
                  taskDescription = "Décision de l'auteur suite à la demande de mise à jour majeure des vérificateurs";
               }
               else{
                  taskDescription = "Décision de l'auteur suite aux commentaires des vérificateurs";
               }
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               var author_person = people.getPerson(author);
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = author_person.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;

               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = author_person.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <transition to="Chef de groupe ?" name="Non"></transition>
      <transition to="Mise à jour du document suite à non validation vérificateurs" name="Oui"></transition>
   </task-node>

   <task-node name="Mise à jour du document suite à non validation vérificateurs">
      <task name="scwf:wf1MAJDocumentSuiteNonValidationVerificateursTask" swimlane="auteur"/>
      <transition to="Vérificateurs ?" name="Mise à jour du document terminée"></transition>
   </task-node>

   <task-node name="Acceptation mise à jour majeure par l'auteur">
      <task name="scwf:wf1AcceptationMAJMajeureParAuteurTask" swimlane="auteur"/>
      <transition to="Chef de groupe ?" name="Non"></transition>
      <transition to="end-state1" name="Oui">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <expression>
                  var test = bpm_package;
                  var doc = test.children[0];
                  doc.properties["cm:status"] = "Brouillon";
                  doc.save();
               </expression>
            </script>
         </action>
      </transition>
   </task-node>

   <task-node name="Mise à jour du document suite à non validation chef de groupe">
      <task name="scwf:wf1MAJDocumentSuiteNonValidationChefDeGroupeTask" swimlane="auteur"/>
      <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Mise à jour du document suite à sa non validation par le chef de groupe";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               var author_person = people.getPerson(author);
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = author_person.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;
               
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = author_person.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <transition to="Chef de groupe ?" name="Mise à jour du document terminée"></transition>
   </task-node>

   <node name="Notification auteur suite à non validation majeure chef de groupe">
      <transition to="end-state1">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Document refusé par le chef de groupe";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               var roleName = "le chef de groupe";
               var author_person = people.getPerson(author);
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:refusal-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = author_person.nodeRef.toString();
               args["documentName"] = documentName;
               args["roleName"] = roleName;
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = author_person.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <expression>
                  var test = bpm_package;
                  var doc = test.children[0];
                  doc.properties["cm:status"] = "Brouillon";
                  doc.save();
               </expression>
            </script>
         </action>
      </transition>
   </node>

   <decision name="Approbateur ?">
      <transition to="Commentaires et validation approbateur" name="Oui"></transition>
      <transition to="Diffusion" name="Non">
         <condition>#{scwf_approver==null}</condition>
      </transition>
   </decision>

   <task-node name="Mise à jour du document suite à non validation approbateur">
      <task name="scwf:wf1MAJDocumentSuiteNonValidationApprobateurTask" swimlane="auteur"/>
      <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Mise à jour du document suite à sa non validation par l'approbateur";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               var author_person = people.getPerson(author);
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = author_person.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;
               
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = author_person.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <transition to="Approbateur ?" name="Mise à jour du document terminée"></transition>
   </task-node>

   <node name="Notification auteur suite à non validation majeure approbateur">
      <transition to="end-state1">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Document refusé par l'approbateur";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               var roleName = "l'approbateur";
               var author_person = people.getPerson(author);
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:refusal-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = author_person.nodeRef.toString();
               args["documentName"] = documentName;
               args["roleName"] = roleName;
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = author_person.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <expression>
                  var test = bpm_package;
                  var doc = test.children[0];
                  doc.properties["cm:status"] = "Brouillon";
                  doc.save();
               </expression>
            </script>
         </action>
      </transition>
   </node>
   
   <node name="Affectation aux vérificateurs demandés par chef de groupe">
      <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
         <foreach>#{scwf_other_verifiers_from_group_leader}</foreach>
         <var>other_verifier_from_group_leader</var>
      </action>
      <transition to="Commentaire et validation vérificateurs demandés par chef de groupe"></transition>
   </node>

   <task-node name="Commentaire et validation vérificateurs demandés par chef de groupe">
      <task name="scwf:wf1ValidationVerificateursDemandesParChefDeGroupeTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
              <actor>#{other_verifier_from_group_leader}</actor>
            </assignment>
      </task>
      <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Validation du document par d'autres vérificateurs à la demande du chef de groupe";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-with-deadline-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = other_verifier_from_group_leader.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;
               
               args["timer"] = scwf_execution_timer;
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = other_verifier_from_group_leader.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <transition to="join3" name="Valider"></transition>
      <transition to="join3" name="Ne pas valider : mise à jour mineure"></transition>
      <transition to="join3" name="Ne pas valider : mise à jour majeure"></transition>
   </task-node>
   
   <join name="join3">
      <transition to="Approbateur déjà connu ?"></transition>
   </join>
   
   <node name="Affectation aux vérificateurs demandés par approbateur">
      <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
         <foreach>#{scwf_other_verifiers_from_approver}</foreach>
         <var>other_verifier_from_approver</var>
      </action>
      <transition to="Commentaire et validation vérificateurs demandés par approbateur"></transition>
   </node>

   <task-node name="Commentaire et validation vérificateurs demandés par approbateur">
      <task name="scwf:wf1ValidationVerificateursDemandesParApprobateurTask">
         <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
              <actor>#{other_verifier_from_approver}</actor>
            </assignment>
      </task>
      <event type="task-create">
         <!– <action class="fr.cea.bpm.ManageTaskUrlGetter"/> –>
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var test = bpm_package;
               var doc = test.children[0];
               var documentName = doc.properties["cm:name"];
               var taskDescription = "Validation du document par d'autres vérificateurs à la demande de l'approbateur";
               var subject = "Validation hiérarchique du document "+documentName+" - "+taskDescription;
               
               var results = search.luceneSearch(" PATH:\"app:company_home/app:dictionary/app:email_templates/cm:cea/cea:notification-with-deadline-email.ftl\"");
               var template = results[0];
               
               var args = [];
               args["notifiedPersonRef"] = other_verifier_from_approver.nodeRef.toString();
               args["documentName"] = documentName;
               args["taskDescription"] = taskDescription;
               
               args["timer"] = scwf_execution_timer;
               var mail_text = doc.processTemplate(template, args);
               
               var mail = actions.create("mail");
               mail.parameters.to = other_verifier_from_approver.properties["cm:email"];
               mail.parameters.subject = subject;
               mail.parameters.text = mail_text;
               mail.execute(bpm_package);
            </script>
         </action>
      </event>
      <transition to="join4" name="Valider"></transition>
      <transition to="join4" name="Ne pas valider : mise à jour mineure"></transition>
      <transition to="join4" name="Ne pas valider : mise à jour majeure"></transition>
   </task-node>
   
   <join name="join4">
      <transition to="Commentaires et validation approbateur"></transition>
   </join>

   <end-state name="end-state1"></end-state>


</process-definition>

Le timer se situe sur la tâche "Commentaires et validation co-auteurs". Lorsque je n'utilise que du Javascript (écriture d'un message en log par exemple), cela fonctionne bien. Par contre, dès que je fais appel à une classe Java (aussi bien dans le timer que dans la transition prise une fois le timer expiré), j'obtiens l'erreur suivante :
18:28:09,748  ERROR [repo.transaction.AlfrescoTransactionSupport] After completion (rolled-back) listener exception: 
   listener: org.alfresco.repo.workflow.jbpm.JBPMTransactionTemplate@3b0a2ef6
org.jbpm.JbpmException: closed JbpmContext in different order then they were created… check your try-finally's around JbpmContexts blocks
   at org.jbpm.JbpmConfiguration.popJbpmContext(JbpmConfiguration.java:707)
   at org.jbpm.JbpmConfiguration.jbpmContextClosed(JbpmConfiguration.java:720)
   at org.jbpm.JbpmContext.close(JbpmContext.java:144)
   at org.springmodules.workflow.jbpm31.JbpmTemplate.releaseContext(JbpmTemplate.java:111)
   at org.alfresco.repo.workflow.jbpm.JBPMTransactionTemplate.afterRollback(JBPMTransactionTemplate.java:195)
   at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.afterCompletion(AlfrescoTransactionSupport.java:782)
   at org.springframework.transaction.support.TransactionSynchronizationUtils.invokeAfterCompletion(TransactionSynchronizationUtils.java:133)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.invokeAfterCompletion(AbstractPlatformTransactionManager.java:904)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerAfterCompletion(AbstractPlatformTransactionManager.java:879)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:782)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:730)
   at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:332)
   at org.alfresco.util.transaction.SpringAwareUserTransaction.completeTransactionAfterThrowing(SpringAwareUserTransaction.java:562)
   at org.alfresco.util.transaction.SpringAwareUserTransaction.rollback(SpringAwareUserTransaction.java:532)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:387)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:233)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJobExecutorThread.executeJob(AlfrescoJobExecutorThread.java:113)
   at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:60)
18:28:09,749  ERROR [job.executor.JobExecutorThread] exception in job executor thread. waiting 90000 milliseconds
org.jbpm.JbpmException: closed JbpmContext in different order then they were created… check your try-finally's around JbpmContexts blocks
   at org.jbpm.JbpmConfiguration.popJbpmContext(JbpmConfiguration.java:707)
   at org.jbpm.JbpmConfiguration.jbpmContextClosed(JbpmConfiguration.java:720)
   at org.jbpm.JbpmContext.close(JbpmContext.java:144)
   at org.jbpm.job.executor.JobExecutorThread.executeJob(JobExecutorThread.java:190)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJobExecutorThread.access$201(AlfrescoJobExecutorThread.java:43)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJobExecutorThread$TransactionJob.execute(AlfrescoJobExecutorThread.java:138)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:326)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:233)
   at org.alfresco.repo.workflow.jbpm.AlfrescoJobExecutorThread.executeJob(AlfrescoJobExecutorThread.java:113)
   at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:60)

J'ai essayé avec différentes classes Java que j'ai déjà développées pour ce workflow (et qui fonctionnent bien sans utilisation de timer) : j'obtiens toujours cette erreur.

Est-il possible de faire appel à une classe Java dans le cadre de l'utilisation d'un timer ?
Cette classe doit-elle hériter ou implémenter une classe particulière ? (mes classes héritent de JBPMSpringActionHandler)

Merci d'avance pour votre aide.

Outcomes