Skip to content

Commit

Permalink
docs: 阅读 FlowNode
Browse files Browse the repository at this point in the history
  • Loading branch information
dongrxin committed Jan 4, 2024
1 parent ace9e2d commit a41469e
Show file tree
Hide file tree
Showing 15 changed files with 451 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,36 @@
import java.util.List;

/**
* @author Tijs Rademakers
* Activity 抽象类代表了 BPMN 流程图中的一个活动节点。
* 它是所有具体活动类型的基类,提供了活动的基本属性和行为。
*/
public abstract class Activity extends FlowNode {

// 默认流程的ID,用于在活动中作为默认的流转路径
protected String defaultFlow;

// 标识该活动是否是补偿活动
protected boolean forCompensation;

// 多实例循环特性,描述活动如何多次执行
protected MultiInstanceLoopCharacteristics loopCharacteristics;

// 输入/输出规范,定义了活动的数据输入和输出
protected IOSpecification ioSpecification;

// 数据输入关联,定义了与活动的数据输入相关的数据
protected List<DataAssociation> dataInputAssociations = new ArrayList<>();

// 数据输出关联,定义了与活动的数据输出相关的数据
protected List<DataAssociation> dataOutputAssociations = new ArrayList<>();

// 边界事件,与活动关联的事件,如错误事件或消息事件
protected List<BoundaryEvent> boundaryEvents = new ArrayList<>();

// 失败作业重试时间周期值,用于定义作业失败时的重试策略
protected String failedJobRetryTimeCycleValue;

// 异常映射条目,定义了活动发生异常时的处理规则
protected List<MapExceptionEntry> mapExceptions = new ArrayList<>();

public String getFailedJobRetryTimeCycleValue() {
Expand Down Expand Up @@ -106,18 +124,28 @@ public void setMapExceptions(List<MapExceptionEntry> mapExceptions) {
this.mapExceptions = mapExceptions;
}

/**
* 设置这个活动节点的属性为另一个 Activity 节点的属性。
* 该方法用于复制活动节点或在活动节点之间共享属性。
*/
public void setValues(Activity otherActivity) {
super.setValues(otherActivity);
// 复制其他活动的属性
setFailedJobRetryTimeCycleValue(otherActivity.getFailedJobRetryTimeCycleValue());
setDefaultFlow(otherActivity.getDefaultFlow());
setForCompensation(otherActivity.isForCompensation());

// 复制多实例循环特性
if (otherActivity.getLoopCharacteristics() != null) {
setLoopCharacteristics(otherActivity.getLoopCharacteristics().clone());
}

// 复制输入/输出规范
if (otherActivity.getIoSpecification() != null) {
setIoSpecification(otherActivity.getIoSpecification().clone());
}

// 复制数据输入和输出关联
dataInputAssociations = new ArrayList<>();
if (otherActivity.getDataInputAssociations() != null && !otherActivity.getDataInputAssociations().isEmpty()) {
for (DataAssociation association : otherActivity.getDataInputAssociations()) {
Expand All @@ -132,6 +160,7 @@ public void setValues(Activity otherActivity) {
}
}

// 复制边界事件
boundaryEvents.clear();
boundaryEvents.addAll(otherActivity.getBoundaryEvents());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,60 @@
package org.flowable.bpmn.model;

/**
* @author Tijs Rademakers
* AdhocSubProcess 类表示一个非结构化的子流程,其中包含的活动可以以任意顺序执行。
* 这种子流程通常用于更灵活、不预定义路径的业务逻辑。
*/
public class AdhocSubProcess extends SubProcess {

// 定义子流程活动的执行顺序为并行或序列
public static final String ORDERING_PARALLEL = "Parallel";
public static final String ORDERING_SEQUENTIALL = "Sequential";

// 定义子流程完成的条件
protected String completionCondition;

// 子流程的执行顺序,可以是并行或序列
protected String ordering = ORDERING_PARALLEL;

// 如果一个活动完成或者流程触发了一个中断事件,是否取消其它还在执行的实例
protected boolean cancelRemainingInstances = true;

// 获取子流程完成条件的方法
public String getCompletionCondition() {
return completionCondition;
}

// 设置子流程完成条件的方法
public void setCompletionCondition(String completionCondition) {
this.completionCondition = completionCondition;
}

// 获取子流程的执行顺序的方法
public String getOrdering() {
return ordering;
}

// 设置子流程的执行顺序的方法
public void setOrdering(String ordering) {
this.ordering = ordering;
}

// 判断子流程的执行顺序是否为并行的方法
public boolean hasParallelOrdering() {
return !ORDERING_SEQUENTIALL.equals(ordering);
}

// 判断子流程的执行顺序是否为序列的方法
public boolean hasSequentialOrdering() {
return ORDERING_SEQUENTIALL.equals(ordering);
}

// 获取是否取消剩余实例的方法
public boolean isCancelRemainingInstances() {
return cancelRemainingInstances;
}

// 设置是否取消剩余实例的方法
public void setCancelRemainingInstances(boolean cancelRemainingInstances) {
this.cancelRemainingInstances = cancelRemainingInstances;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@
import org.apache.commons.lang3.StringUtils;

/**
* @author Tijs Rademakers
* BaseElement 类是 BPMN 流程定义中所有元素的基础抽象类。
* 它定义了所有元素共有的基本属性,如id、扩展元素和属性。
*/
public abstract class BaseElement implements HasExtensionAttributes {

// 元素的唯一标识符
protected String id;

// 元素在XML文档中的行号
protected int xmlRowNumber;

// 元素在XML文档中的列号
protected int xmlColumnNumber;

// 扩展元素的集合,这些是非标准的额外信息,可以附加到任何BPMN元素上
protected Map<String, List<ExtensionElement>> extensionElements = new LinkedHashMap<>();
/** extension attributes could be part of each element */

// 扩展属性的集合,这些可以是任何BPMN元素的额外属性
protected Map<String, List<ExtensionAttribute>> attributes = new LinkedHashMap<>();

public String getId() {
Expand Down Expand Up @@ -104,11 +113,17 @@ public void addAttribute(ExtensionAttribute attribute) {
}
}

/**
* 设置当前元素的所有扩展属性。
*/
@Override
public void setAttributes(Map<String, List<ExtensionAttribute>> attributes) {
this.attributes = attributes;
}

/**
* 复制另一个 BaseElement 的属性到当前元素。
*/
public void setValues(BaseElement otherElement) {
setId(otherElement.getId());

Expand Down Expand Up @@ -141,6 +156,9 @@ public void setValues(BaseElement otherElement) {
}
}

/**
* 克隆当前元素的方法,每个具体的子类都需要实现这个方法。
*/
@Override
public abstract BaseElement clone();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,46 +15,55 @@
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* @author Tijs Rademakers
* BoundaryEvent 类表示附加到活动边界的事件。
* 这种事件在活动执行期间发生,用于模型化例如错误处理或消息中断等情况。
*/
public class BoundaryEvent extends Event {

@JsonIgnore
protected Activity attachedToRef;
protected String attachedToRefId;
protected boolean cancelActivity = true;
protected Activity attachedToRef; // 该事件附加到的活动引用
protected String attachedToRefId; // 该事件附加到的活动的ID
protected boolean cancelActivity = true; // 当事件触发时,是否取消活动的执行

// 获取附加到的活动引用
public Activity getAttachedToRef() {
return attachedToRef;
}

// 设置附加到的活动引用
public void setAttachedToRef(Activity attachedToRef) {
this.attachedToRef = attachedToRef;
}

// 获取附加到的活动ID
public String getAttachedToRefId() {
return attachedToRefId;
}

// 设置附加到的活动ID
public void setAttachedToRefId(String attachedToRefId) {
this.attachedToRefId = attachedToRefId;
}

// 判断事件触发时是否取消活动
public boolean isCancelActivity() {
return cancelActivity;
}

// 设置事件触发时是否取消活动
public void setCancelActivity(boolean cancelActivity) {
this.cancelActivity = cancelActivity;
}

// 克隆一个边界事件对象
@Override
public BoundaryEvent clone() {
BoundaryEvent clone = new BoundaryEvent();
clone.setValues(this);
return clone;
}

// 从另一个 BoundaryEvent 对象复制属性值
public void setValues(BoundaryEvent otherEvent) {
super.setValues(otherEvent);
setAttachedToRefId(otherEvent.getAttachedToRefId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,57 @@
import java.util.List;

/**
* @author Tijs Rademakers
* Event 抽象类表示 BPMN 流程图中的一个事件节点。
* 事件是流程中发生的动作或结果,比如开始、结束或捕获信号等。
* 本类是所有具体事件节点的基类,比如开始事件、结束事件或中间事件。
*/
public abstract class Event extends FlowNode {

// 与事件相关的事件定义列表
protected List<EventDefinition> eventDefinitions = new ArrayList<>();

// 事件的输入参数列表
protected List<IOParameter> inParameters = new ArrayList<>();

// 事件的输出参数列表
protected List<IOParameter> outParameters = new ArrayList<>();

// 获取事件定义的方法
public List<EventDefinition> getEventDefinitions() {
return eventDefinitions;
}

// 设置事件定义的方法
public void setEventDefinitions(List<EventDefinition> eventDefinitions) {
this.eventDefinitions = eventDefinitions;
}

// 向事件添加一个事件定义
public void addEventDefinition(EventDefinition eventDefinition) {
eventDefinitions.add(eventDefinition);
}


// 获取输入参数的方法
public List<IOParameter> getInParameters() {
return inParameters;
}

// 设置输入参数的方法
public void setInParameters(List<IOParameter> inParameters) {
this.inParameters = inParameters;
}

// 获取输出参数的方法
public List<IOParameter> getOutParameters() {
return outParameters;
}

// 设置输出参数的方法
public void setOutParameters(List<IOParameter> outParameters) {
this.outParameters = outParameters;
}

// 从另一个 Event 对象复制属性值的方法
public void setValues(Event otherEvent) {
super.setValues(otherEvent);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,52 @@
package org.flowable.bpmn.model;

/**
* Element for defining an event listener to hook in to the global event-mechanism.
*
* @author Frederik Heremans
* @author Joram Barrez
* EventListener 类用于定义全局事件监听器。
* 这些监听器可以在流程引擎中发生的特定事件时执行自定义的逻辑。
*/
public class EventListener extends BaseElement {

// 要监听的事件类型,可以是一个特定事件或一组事件
protected String events;

// 监听器实现的类型,如 'class'、'expression'、'delegateExpression' 或 'script'
protected String implementationType;

// 实现的具体内容,取决于 implementationType 的值
protected String implementation;

// 与监听器关联的实体类型
protected String entityType;

// 与事务相关的属性,定义监听器在事务的何种状态下被触发
protected String onTransaction;

// 获取监听的事件类型
public String getEvents() {
return events;
}

// 设置监听的事件类型
public void setEvents(String events) {
this.events = events;
}

// 获取实现类型
public String getImplementationType() {
return implementationType;
}

// 设置实现类型
public void setImplementationType(String implementationType) {
this.implementationType = implementationType;
}

// 获取实现
public String getImplementation() {
return implementation;
}

// 设置实现
public void setImplementation(String implementation) {
this.implementation = implementation;
}
Expand All @@ -62,17 +75,20 @@ public String getOnTransaction() {
return onTransaction;
}

// 设置事务状态
public void setOnTransaction(String onTransaction) {
this.onTransaction = onTransaction;
}

// 克隆事件监听器的方法
@Override
public EventListener clone() {
EventListener clone = new EventListener();
clone.setValues(this);
return clone;
}

// 从另一个 EventListener 对象复制属性值的方法
public void setValues(EventListener otherListener) {
super.setValues(otherListener);
setEvents(otherListener.getEvents());
Expand Down
Loading

0 comments on commit a41469e

Please sign in to comment.