cancel
Showing results for 
Search instead for 
Did you mean: 

Comment modifier le contenu de bpm_package ?

riogrande
Champ in-the-making
Champ in-the-making
Bonjour à tous,

Après pas mal de galère j'arrive à quelque chose mais j'ai encore des problèmes et des questions.
Mon workflow ressemble à ça :

[img]http://img194.imageshack.us/img194/9379/workflow.png[/img]

En gros le fichier arrive, si sont statu est "Pending" il entre dans le processus de validation, sinon il en sort directement. Chose qui marche très bien.
En suite un validateur à la possibilité de modifier est d'approuver le document ou de le rejeter pour que l'initiateur corrige le document.
Je voudrais donner la possibilité au Validateur de valider directement même si le status est encore "Pending", le workflow doit le "seter" à "In" avant de terminer le flux.
Autre possibilité, si l'initiateur met le status à "In", il ne doit pas passer par le validateur.

Voilà le code :

<?xml version="1.0" encoding="UTF-8"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="afwf:workflowTest">

   <swimlane name="initiator" />

   <swimlane name="validator">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <pooledactors>#{people.getGroup('GROUP_Administrator')}</pooledactors>
      </assignment>
   </swimlane>
   
   
   <start-state name="start">
      <task name="bpm:startTask" swimlane="initiator" />
      <transition to="IsPending">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <variable name="statusValue" access="read,write"/>
               <expression>
                  statusValue = bpm_package.children[0].properties["af:status"];
               </expression>
            </script>
         </action>
      </transition>
   </start-state>


   <decision name="IsPending">      
      <transition to="end" name="NoValidationNeeded">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="statusValue" access="read" />
               <expression>
                  logger.log("No validation needed, because status is set to '" + statusValue + "' need 'Pending'");
               </expression>
            </script>
         </action>         
      </transition>
      <transition to="Validation" name="ValidationNeeded">
         <condition>#{statusValue == "Pending"}</condition>   
      </transition>
   </decision>


   <task-node name="Validation">
      <task name="afwf:validation" swimlane="validator" />
      <transition to="IsValid" name="approved"></transition>
      <transition to="Correction" name="reject"></transition>
   </task-node>


   <task-node name="Correction">
      <task name="afwf:correction" swimlane="initiator" />
      <transition to="IsPending" name="done">   
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="bpm_package" access="read" />
               <variable name="statusValue" access="read,write"/>
               <expression>
                  statusValue = bpm_package.children[0].properties["af:status"];
               </expression>
            </script>
         </action>      
      </transition>
   </task-node>


   <node name="IsValid">
      <transition to="end">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <runas>admin</runas>
               <variable name="bpm_package" access="read" />
               <expression>
               logger.log("Is in IsValid");
                  if(bpm_package.children[0].properties["af:status"] == "Pending"){
                     bpm_package.children[0].properties["af:status"] = "In";
                     logger.log("Status set to 'In'");
                  }
               </expression>
            </script>
         </action>   
      </transition>
   </node>


   <end-state name="end">
      <event type="node-enter">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <expression>
                  logger.log("End of the Physical Archive Validation !");
               </expression>
            </script>
         </action>
      </event>      
   </end-state>

</process-definition>


Je précis que le workflow est lancé avec un .js et cela marche très bien.

Maintenant j'ai en fait 3 problèmes (je pouvais pas tout mettre dans le titre Smiley Happy ).

1.- Après la tâche "Correction", j'ai fais une réassignation pour "statusValue", mais ça ne marche pas car ce retourne toujours vers "Validation" (et donc on ne sort pas de la boucle).
2.- "bpm_package.children[0].properties["af:status"] = "In";" n'a aucun effet et laisse la valeur à "Pending". Normal me direz-vous, car je n'ai pas mit "write" en plus de "read", le problème quand je fais ça j'obtiens une erreur :
19:46:30,375 ERROR [org.alfresco.web.ui.common.Utils] A system error happened during the operation: org.mozilla.javascript.Undefined cannot be cast to org.alfresco.repo.workflow.jbpm.JBPMNode
java.lang.ClassCastException: org.mozilla.javascript.Undefined cannot be cast to org.alfresco.repo.workflow.jbpm.JBPMNode
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowInstance(JBPMEngine.java:2775)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowPath(JBPMEngine.java:2673)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.createWorkflowTask(JBPMEngine.java:2830)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine$26.doInJbpm(JBPMEngine.java:1711)
   at org.springmodules.workflow.jbpm31.JbpmTemplate$1.doInHibernate(JbpmTemplate.java:87)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:338)
   at org.springmodules.workflow.jbpm31.JbpmTemplate.execute(JbpmTemplate.java:80)
   at org.alfresco.repo.workflow.jbpm.JBPMEngine.endTask(JBPMEngine.java:1670)
   at org.alfresco.repo.workflow.WorkflowServiceImpl.endTask(WorkflowServiceImpl.java:544)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
   at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:40)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
   at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:301)
   at org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:229)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
   at $Proxy51.endTask(Unknown Source)
   at org.alfresco.web.bean.workflow.ManageTaskDialog.transition(ManageTaskDialog.java:390)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
   at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
   at javax.faces.component.UICommand.broadcast(UICommand.java:109)
   at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
   at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
   at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
   at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:81)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
   at java.lang.Thread.run(Thread.java:619)

3.- Je voudrais lancer le workflow une fois que le fichier est ajouter, le problème c'est qu'il se lance juste après le fichier ait été ajouté et donc il manque les méta-données supplémentaires. Ce qui veut dire qu'un document peut-être défini comme "In" dès le début, mais passera quand même pas le Validateur. Situation qui n'est bien évidement pas souhaitable.

Si vous avez une solution même pour un seul de ces trois points, je vous en serais très reconnaissant.
13 REPLIES 13

riogrande
Champ in-the-making
Champ in-the-making
J'ai beau chercher je trouve rien. Il y a bien le fichier document-details.jsp, mais je ne sais pas comment remonter vers la partie qui génère la liste des workflow actif.

Edit : j'ai trouvé c'est dans UINodeWorkflowInfo.java je sens que je suis pas sorti de l'auberge  :roll:

landry_2530
Champ in-the-making
Champ in-the-making
Bonjour

Tu peux voir les workflows dans lequel un document participe à partir du détail du document.
En fait, c'est à partir du client web.
Tu te connectes à l'application, et tu navigues jusqu'au document dont tu veux voir les workflows.
Tu cliques sur l'icone "visualiser les détails" dans le menu contextuel du document, puis
dans les détails tu ouvres "workflows". Tu pourras voir les workflows simples et avancées démarrés sur le document.

riogrande
Champ in-the-making
Champ in-the-making
au passage j'ai trouvé entre temps sur le forum anglais, il existe en fait une fonction javascript :

Array activeWorkflows : Returns an array of all active workflows this node is involved in. If the node is not part of an active workflow, null is returned. Items in the returned array are of type JscriptWorkflowInstance.

Je fais le test donc comme suite :
if(document.activeWorkflows.length == 0){
***start workflow***
}
else{
**Message**
}

landry_2530
Champ in-the-making
Champ in-the-making
Bonjour

Excellent cette découverte.
ça apporte quelques solutions à des futurs problématiques que j'aurais.

Il faut que je sculpe l'API JavaScript afin d'avoir tout ce qu'elle peut m'offrir pour
le reporting des workflows.

Un projet d'extension pour le reporting des workflows avancés a été initié sur le forge Alfresco
et est encours. http://forge.alfresco.com/projects/workflowmanager/