2016-11-17 59 views
1

我們使用Activiti的工作流引擎在這種情況下的父進程:的Activiti - 子

Flow

<?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:xsd="http://www.w3.org/2001/XMLSchema" 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://www.activiti.org/test"> 
<signal id="alertSignal" name="alert" /> 
    <process id="myProcess" name="myProcess" isExecutable="true"> 
    <subProcess id="subprocess1" name="Sub Process"> 
     <startEvent id="startevent2" name="Start"></startEvent> 
     <endEvent id="endevent1" name="End"></endEvent> 
     <userTask id="verifico-id-transitorio-paciente" name="verifico-id-transitorio-paciente"> 
     <extensionElements> 
      <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener> 
      <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener> 
     </extensionElements> 
     </userTask> 
     <sequenceFlow id="flow1" sourceRef="startevent2" targetRef="verifico-id-transitorio-paciente"></sequenceFlow> 
     <sequenceFlow id="flow2" sourceRef="verifico-id-transitorio-paciente" targetRef="parallelgateway1"></sequenceFlow> 
     <parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway> 
     <sequenceFlow id="flow10" sourceRef="parallelgateway1" targetRef="ingreso-formulario-ConMed"></sequenceFlow> 
     <intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent"> 
     <signalEventDefinition signalRef="alertSignal"></signalEventDefinition> 
     </intermediateThrowEvent> 
     <sequenceFlow id="flow11" sourceRef="parallelgateway1" targetRef="signalintermediatethrowevent1"></sequenceFlow> 
     <userTask id="ingreso-formulario-ConMed" name="ingreso-formulario-ConMed"> 
     <extensionElements> 
      <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener> 
      <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener> 
     </extensionElements> 
     </userTask> 
     <sequenceFlow id="flow13" sourceRef="ingreso-formulario-ConMed" targetRef="endevent1"></sequenceFlow> 
    </subProcess> 
    <subProcess id="subprocess2" name="Sub Process"> 
     <startEvent id="startevent3" name="Start"></startEvent> 
     <endEvent id="endevent2" name="End"></endEvent> 
     <userTask id="ingreso-formulario-Con" name="ingreso-formulario-Con"> 
     <extensionElements> 
      <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoTarea(task)}"></activiti:taskListener> 
      <activiti:taskListener event="create" expression="#{INTERNA_LOGICA_TRAMITE.setearPermisoDependencia(task)}"></activiti:taskListener> 
     </extensionElements> 
     </userTask> 
     <sequenceFlow id="flow5" sourceRef="startevent3" targetRef="ingreso-formulario-Con"></sequenceFlow> 
     <sequenceFlow id="flow6" sourceRef="ingreso-formulario-Con" targetRef="endevent2"></sequenceFlow> 
    </subProcess> 
    <startEvent id="startevent1" name="Start"></startEvent> 
    <subProcess id="subprocess3" name="Sub Process"> 
     <userTask id="modifico-formulario-ConMed" name="modifico-formulario-ConMed"> 
     <extensionElements> 
     </extensionElements> 
     </userTask> 
     <startEvent id="startevent4" name="Start"></startEvent> 
     <endEvent id="endevent3" name="End"></endEvent> 
     <sequenceFlow id="flow8" sourceRef="startevent4" targetRef="modifico-formulario-ConMed"></sequenceFlow> 
     <sequenceFlow id="flow9" sourceRef="modifico-formulario-ConMed" targetRef="endevent3"></sequenceFlow> 
    </subProcess> 
    <sequenceFlow id="flow3" sourceRef="startevent1" targetRef="subprocess1"></sequenceFlow> 
    <sequenceFlow id="flow4" sourceRef="subprocess1" targetRef="subprocess2"></sequenceFlow> 
    <endEvent id="endevent4" name="End"></endEvent> 
    <sequenceFlow id="flow7" sourceRef="subprocess2" targetRef="endevent4"></sequenceFlow> 
    <startEvent id="signalstartevent1" name="Signal start"> 
     <signalEventDefinition signalRef="alertSignal"></signalEventDefinition> 
    </startEvent> 
    <sequenceFlow id="flow14" sourceRef="signalstartevent1" targetRef="subprocess3"></sequenceFlow> 
    </process> 
</definitions> 

而且act_ru_execution表顯示像2名的是兩個獨立的過程與無父:

enter image description here

是否有可能得到一個子進程的父進程,以及如何g^ets代表activiti的數據庫?因爲我們沒有找到那種關係。

是否有可能將主進程的所有變量傳遞給我們的場景中的子進程?

回答

1

父進程

如何ServiceTask得到:

選擇具有作爲子流程實例給定流程實例的流程實例。請注意,總是隻有最大值一個這樣的流程實例可能是此查詢的結果。 runtimeService.createProcessInstanceQuery()。subProcessInstanceId(subProcessInstanceId).list();

在數據庫:

ACT_RU_EXECUTION有兩個屬性PARENT_ID_和SUPER_EXEC_。執行的

  • PARENT_ID_ ID爲不超過在樹的層次結構,但在一個過程(例如並行執行,...)在處理超執行的
  • SUPER_EXEC_ ID /子關係

enter image description here

通行證人:與並行執行和一個子進程的進程表ACT_RU_EXECUTION的實施例l變量到子過程

手動進行過程定義或動態地通過偵聽器實現。

+0

super_exec_id_爲空,我編輯與該信息的問題。我們可能會做錯什麼? – Mateo

+0

對於信號邊界事件,我用parent_id得到了預期的行爲。是否有可能用流程而不是執行來實現這種行爲?換句話說,子流程的實際流程不是執行。那些進程有一個共同的父進程,甚至可能嗎? – Mateo

+0

我在一個進程中添加了ACT_RU_EXECUTION表中關係的圖像。但就你而言,你是對的。由信號啓動的過程是獨立的。如果您想要與正在投擲信號的實例建立連接,則必須使用信號邊界事件。 – fersmi

1

在執行期間,確定子過程的密鑰給出爲<parent_process_id>-<sub-process-id>。這密鑰將給你想要的結果,如果您通過查詢子進程的密鑰 - runtimeService.createProcessInstanceQuery().processDefinitionKey("your-key")