passage de propriétés par workflow

cancel
Showing results for 
Search instead for 
Did you mean: 
dorra87
Member II

passage de propriétés par workflow

Bonjour,j'ai voulu ajouter des propriétés personnalisées en utilisant un aspect dans un workflow adhoc de tel façon que j'entre la valeur de propriété dans le formulaire de workflow et dans la tâche reçu je veux que la valeur de la propriété soit affichée hors la valeur ne s'affiche pas.
J'utilise alfresco share 4.0.c et activiti
voila le code
demDAO.bpmn20.xml
<?xml version="1.0" encoding="UTF-8" ?>

<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://alfresco.org">

<process id="activitiDemDAO" name="Demande d'élaboration du DAO">

   <startEvent id="start"
      activiti:formKey="wf:submitAdhocTask" />
   <sequenceFlow id='flow1'
      sourceRef='start'
      targetRef='adhocTask' />

   <userTask id="adhocTask" name="Adhoc Task"
      activiti:formKey="wf:adhocTask">
      <extensionElements>
         <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
           <activiti:field name="script">
             <activiti:string>
              if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
              if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
             </activiti:string>
           </activiti:field>
         </activiti:taskListener>
         <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
           <activiti:field name="script">
             <activiti:string>
              execution.setVariable('wf_marketName',task.getVariable('wf_marketName'));
             execution.setVariable('wf_projectName',task.getVariable('wf_projectName'));
</activiti:string>
</activiti:field>
</activiti:taskListener>
      </extensionElements>
      <humanPerformer>
         <resourceAssignmentExpression>
            <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
         </resourceAssignmentExpression>
      </humanPerformer>
   </userTask>

   <sequenceFlow id='flow2'
   sourceRef='adhocTask'
      targetRef='verifyTaskDone' />

   <userTask id="verifyTaskDone" name="Verify Adhoc Task Completed."
      activiti:formKey="wf:completedAdhocTask" >
      <documentation>
         Verify the arbitrary task was completed.
      </documentation>
      <extensionElements>
         <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
           <activiti:field name="script">
             <activiti:string>
               if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
               if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
               
               if (wf_notifyMe)
               {
                  var mail = actions.create("mail");
                  mail.parameters.to = initiator.properties.email;
                  mail.parameters.subject = "Adhoc Task " + bpm_workflowDescription;
                  mail.parameters.from = bpm_assignee.properties.email;
                  mail.parameters.text = "It's done";
                  mail.execute(bpm_package);
               }
             </activiti:string>
           </activiti:field>
         </activiti:taskListener>
      </extensionElements>
      <humanPerformer>
         <resourceAssignmentExpression>
            <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
         </resourceAssignmentExpression>
      </humanPerformer>
   </userTask>

   <sequenceFlow id='flow3' sourceRef='verifyTaskDone'
      targetRef='theEnd' />

   <endEvent id="theEnd" />

</process>

<!– Graphical representaion of diagram –>
<bpmndi:BPMNDiagram id="BPMNDiagram_activitiDemDAO">
  <bpmndi:BPMNPlane bpmnElement="activitiDemDAO" id="BPMNPlane_activitiDemDAO">
    <bpmndi:BPMNShape bpmnElement="start"
      id="BPMNShape_start">
      <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
    </bpmndi:BPMNShape>
    <bpmndi:BPMNShape bpmnElement="adhocTask"
      id="BPMNShape_adhocTask">
      <omgdc:Bounds height="55" width="105" x="130"
         y="190"></omgdc:Bounds>
    </bpmndi:BPMNShape>
    <bpmndi:BPMNShape bpmnElement="verifyTaskDone"
      id="BPMNShape_verifyTaskDone">
      <omgdc:Bounds height="55" width="105" x="290"
         y="190"></omgdc:Bounds>
    </bpmndi:BPMNShape>
    <bpmndi:BPMNShape bpmnElement="theEnd"
      id="BPMNShape_theEnd">
      <omgdc:Bounds height="35" width="35" x="455" y="200"></omgdc:Bounds>
    </bpmndi:BPMNShape>
    <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
      <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
      <omgdi:waypoint x="130" y="217"></omgdi:waypoint>
    </bpmndi:BPMNEdge>
    <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
      <omgdi:waypoint x="235" y="217"></omgdi:waypoint>
      <omgdi:waypoint x="290" y="217"></omgdi:waypoint>
    </bpmndi:BPMNEdge>
    <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
      <omgdi:waypoint x="395" y="217"></omgdi:waypoint>
      <omgdi:waypoint x="455" y="217"></omgdi:waypoint>
    </bpmndi:BPMNEdge>
  </bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>

</definitions>
demDAOModel.xml
<?xml version="1.0" encoding="UTF-8"?>

<model name="wf:workflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
   </imports>

   <namespaces>
      <namespace uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf"/>
   </namespaces>
     
   <types>
      <!–                               –>
      <!–  Adhoc Tasks –>              
      <!–                               –>
     
      <type name="wf:submitAdhocTask">
         <parent>bpm:startTask</parent>
         <properties>
            <property name="wf:notifyMe">
               <type>d:boolean</type>
               <default>false</default>
            </property>
         </properties>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         <aspect>wf:marketInfo</aspect>
         <aspect>wf:projectInfo</aspect>
         </mandatory-aspects>
      </type>

      <type name="wf:adhocTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageActionGroup">
               <default>add_package_item_actions</default>
            </property>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
      </type>

      <type name="wf:completedAdhocTask">
         <parent>bpm:workflowTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

   </types>
  
   <aspects>
<aspect name="wf:marketInfo">
         <properties>
            <property name="wf:marketName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
         </properties>
      </aspect>
      <aspect name="wf:projectInfo">
         <properties>
            <property name="wf:projectName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
         </properties>
      </aspect>
  
   </aspects>

</model>
et le share-workflow-form-config.xml

<alfresco-config>
<config evaluator="string-compare" condition="activiti$activitiDemDAO">
      <forms>
         <form>
            <field-visibility>
               <show id="bpm:workflowDescription"/>
               <show id="bpm:workflowDueDate"/>
               <show id="bpm:workflowPriority"/>
               <show id="bpm:assignee"/>
               <show id="wf:projectName"/>
                <show id="wf:marketName"/>
               <show id="bpm:sendEMailNotifications"/>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.general"/>
               <set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl"/>
               <set id="assignee" appearance="title" label-id="workflow.set.assignee"/>
               <set id="market" appearance="title" label="workflow.set.market"/>
               <set id="other" appearance="title" label-id="workflow.set.other"/>
               <field id="bpm:workflowDescription" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl">
                     <control-param name="style">width: 95%</control-param>
                  </control>
               </field>
               <field id="bpm:workflowDueDate" label-id="workflow.field.due" set="info"/>
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl"/>
               </field>
               <field id="bpm:assignee" label-id="workflow.field.assign_to" set="assignee"/>
               <field id="wf:projectName" set="market">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl"/>
               </field>
               <field id="wf:marketName" set="market">
                  <control template="/org/alfresco/components/form/controls/textfield.ftl"/>
               </field>
               <field id="bpm:sendEMailNotifications" set="other">
                  <control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl"/>
               </field>
            </appearance>
         </form>
      </forms>
   </config>
<config evaluator="task-type" condition="wf:submitAdhocTask">
      <forms>
         <form id="workflow-details">
            <field-visibility>
               <show id="bpm:sendEMailNotifications"/>
               <show id="packageItems"/>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.workflow.more_info"/>
               <set id="items" appearance="title" label-id="workflow.set.items"/>
               <field id="packageItems" set="items"/>
            </appearance>
         </form>
         <form>
            <field-visibility>
               <show id="message"/>
               <show id="taskOwner"/>
               <show id="bpm:workflowPriority"/>
               <show id="bpm:workflowDueDate"/>
               <show id="bpm:taskId"/>
               <show id="wf:projectName"/>
                <show id="wf:marketName"/>
               <show id="bpm:status"/>
               <show id="packageItems"/>
               <show id="bpm:sendEMailNotifications"/>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.task.info"/>
               <set id="info" appearance="" template="/org/alfresco/components/form/3-column-set.ftl"/>
               <set id="progress" appearance="title" label-id="workflow.set.task.progress"/>
               <set id="items" appearance="title" label-id="workflow.set.items"/>
               <set id="other" appearance="title" label-id="workflow.set.other"/>
               <field id="message">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="taskOwner" set="info"/>
               <field id="bpm:taskId" set="info">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="wf:projectName"  set="info">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="wf:marketName"  set="info">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info" read-only="true">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl"/>
               </field>
               <field id="bpm:workflowDueDate" set="info" label-id="workflow.field.due">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="bpm:status" set="progress"/>
               <field id="bpm:sendEMailNotifications" set="other"/>
               <field id="packageItems" set="items"/>
            </appearance>
         </form>
      </forms>
   </config>
<config evaluator="task-type" condition="wf:adhocTask">
      <forms>
         <form id="workflow-details">
            <field-visibility>
               <show id="bpm:sendEMailNotifications"/>
               <show id="packageItems"/>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.workflow.more_info"/>
               <set id="items" appearance="title" label-id="workflow.set.items"/>
            </appearance>
         </form>
         <form>
            <field-visibility>
               <show id="message"/>
               <show id="taskOwner"/>
               <show id="bpm:workflowPriority"/>
               <show id="bpm:workflowDueDate"/>
               <show id="bpm:taskId"/>
               <show id="wf:projectName"/>
                <show id="wf:marketName"/>
               <show id="bpm:status"/>
               <show id="bpm:sendEMailNotifications"/>
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.task.info"/>
               <set id="info" appearance="" template="/org/alfresco/components/form/3-column-set.ftl"/>
               <set id="progress" appearance="title" label-id="workflow.set.task.progress"/>
               <set id="other" appearance="title" label-id="workflow.set.other"/>
               <field id="message">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="taskOwner" set="info"/>
               <field id="bpm:taskId" set="info">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="wf:projectName" set="info">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="wf:marketName" set="info">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info" read-only="true">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl"/>
               </field>
               <field id="bpm:workflowDueDate" set="info" label-id="workflow.field.due">
                  <control template="/org/alfresco/components/form/controls/info.ftl"/>
               </field>
               <field id="bpm:status" set="progress"/>
               <field id="bpm:sendEMailNotifications" set="other"/>
               
            </appearance>
         </form>
      </forms>
   </config>
</alfresco-config>
J'utilise le fichier share-workflow-form-config.xml car quand j'ai utilisé le share-config-custom.xml, le model ,leworkflow et le fichier context sous extension/workflow .Au déploiement il ne m'affiche pas le formulaire correcte mais un formulaire par défaut.
Bon mon principal besoin c'est de pouvoir afficher les propriétés dans le adhoc task.
merci d'avance
1 Reply
dorra87
Member II

Re: passage de propriétés par workflow

Bon c'est résolu j'ai pu faire marcher le code il suffit de le mettre dans share-config-custom.xml et ça marche j'avais avant un problème avec le fichier de context maintenant tous vas bien