2016-11-17 60 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")