|
@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.fasterxml.jackson.annotation.*;
|
|
|
import com.flow.common.core.exception.BaseException;
|
|
|
+import com.flow.common.core.util.ApplicationContextUtil;
|
|
|
import com.flow.constant.NodeTypeConstant;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import lombok.Data;
|
|
|
import org.flowable.bpmn.model.FlowElement;
|
|
|
import org.flowable.bpmn.model.FlowableListener;
|
|
|
import org.flowable.bpmn.model.SequenceFlow;
|
|
|
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.List;
|
|
@@ -51,10 +53,25 @@ public abstract class Node implements Serializable {
|
|
|
public List<FlowableListener> buidEventListener() {
|
|
|
if (CollectionUtils.isNotEmpty(this.executionListeners)) {
|
|
|
return this.executionListeners.stream().filter(l -> StringUtils.isNotBlank(l.getImplementation())).map(listener -> {
|
|
|
+ String implementationType = listener.getImplementationType();
|
|
|
+ String implementation = listener.getImplementation();
|
|
|
+ if ("class".equals(implementationType)) {
|
|
|
+ try {
|
|
|
+ Class.forName(listener.getImplementation());
|
|
|
+ } catch (ClassNotFoundException e) {
|
|
|
+ throw new BaseException(String.format("节点【%s】的执行类不存在", this.name));
|
|
|
+ }
|
|
|
+ } else if ("delegateExpression".equals(implementationType)) {
|
|
|
+ try {
|
|
|
+ ApplicationContextUtil.getBean(implementation);
|
|
|
+ } catch (NoSuchBeanDefinitionException e) {
|
|
|
+ throw new BaseException(String.format("节点【%s】的对象不存在", this.name));
|
|
|
+ }
|
|
|
+ }
|
|
|
FlowableListener executionListener = new FlowableListener();
|
|
|
executionListener.setEvent(listener.getEvent());
|
|
|
- executionListener.setImplementationType(listener.getImplementationType());
|
|
|
- executionListener.setImplementation(listener.getImplementation());
|
|
|
+ executionListener.setImplementationType(implementationType);
|
|
|
+ executionListener.setImplementation(implementation);
|
|
|
return executionListener;
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|