//开始节点
StartNode startNode = workflowProcess.getStartNode();
startNodeInstance = new StartNodeInstance(startNode);
List<IKernelExtension> extensionList = kenelExtensions.get(startNodeInstance.getExtensionTargetName());
for (int i = 0; extensionList != null && i < extensionList.size(); i++) {
IKernelExtension extension = extensionList.get(i);
startNodeInstance.registExtension(extension);
}
this.setStartNodeInstance(startNodeInstance);
wfElementInstanceMap.put(startNode.getId(), startNodeInstance);
//活动节点activity
List<Activity> activities = workflowProcess.getActivities();
for (int i = 0; i < activities.size(); i++) {
Activity activity = activities.get(i);
ActivityInstance activityInstance = new ActivityInstance(activity);
extensionList = kenelExtensions.get(activityInstance.getExtensionTargetName());
for (int j = 0; extensionList != null && j < extensionList.size(); j++) {
IKernelExtension extension = extensionList.get(j);
activityInstance.registExtension(extension);
}
wfElementInstanceMap.put(activity.getId(), activityInstance);
}
//同步器节点
List<Synchronizer> synchronizers = workflowProcess.getSynchronizers();
for (int i = 0; i < synchronizers.size(); i++) {
Synchronizer synchronizer = synchronizers.get(i);
SynchronizerInstance synchronizerInstance = new SynchronizerInstance(synchronizer);
extensionList = kenelExtensions.get(synchronizerInstance.getExtensionTargetName());
for (int j = 0; extensionList != null && j < extensionList.size(); j++) {
IKernelExtension extension = extensionList.get(j);
synchronizerInstance.registExtension(extension);
}
wfElementInstanceMap.put(synchronizer.getId(), synchronizerInstance);
}
//结束节点
List<EndNode> endNodes = workflowProcess.getEndNodes();
for (int i = 0; i < endNodes.size(); i++) {
EndNode endNode = endNodes.get(i);
EndNodeInstance endNodeInstance = new EndNodeInstance(endNode);
extensionList = kenelExtensions.get(endNodeInstance.getExtensionTargetName());
for (int j = 0; extensionList != null && j < extensionList.size(); j++) {
IKernelExtension extension = extensionList.get(j);
endNodeInstance.registExtension(extension);
}
wfElementInstanceMap.put(endNode.getId(), endNodeInstance);
}
//转移线
List<Transition> transitions = workflowProcess.getTransitions();
for (int i = 0; i < transitions.size(); i++) {
Transition transition = transitions.get(i);
TransitionInstance transitionInstance = new TransitionInstance(transition);
String fromNodeId = transition.getFromNode().getId();
if (fromNodeId != null) {
INodeInstance enteringNodeInstance = (INodeInstance) wfElementInstanceMap.get(fromNodeId);
if (enteringNodeInstance != null) {
enteringNodeInstance.addLeavingTransitionInstance(transitionInstance);
transitionInstance.setEnteringNodeInstance(enteringNodeInstance);
}
}
String toNodeId = transition.getToNode().getId();
if (toNodeId != null) {
INodeInstance leavingNodeInstance = (INodeInstance) wfElementInstanceMap.get(toNodeId);
if (leavingNodeInstance != null) {
leavingNodeInstance.addEnteringTransitionInstance(transitionInstance);
transitionInstance.setLeavingNodeInstance(leavingNodeInstance);
}
}
extensionList = kenelExtensions.get(transitionInstance.getExtensionTargetName());
for (int j = 0; extensionList != null && j < extensionList.size(); j++) {
IKernelExtension extension = extensionList.get(j);
transitionInstance.registExtension(extension);
}
wfElementInstanceMap.put(transitionInstance.getId(), transitionInstance);
}
//循环线
List<Loop> loops = workflowProcess.getLoops();
for (int i = 0; i < loops.size(); i++) {
Loop loop = loops.get(i);
LoopInstance loopInstance = new LoopInstance(loop);
String fromNodeId = loop.getFromNode().getId();
if (fromNodeId != null) {
INodeInstance enteringNodeInstance = (INodeInstance) wfElementInstanceMap.get(fromNodeId);
if (enteringNodeInstance != null) {
enteringNodeInstance.addLeavingLoopInstance(loopInstance);
loopInstance.setEnteringNodeInstance(enteringNodeInstance);
}
}
String toNodeId = loop.getToNode().getId();
if (toNodeId != null) {
INodeInstance leavingNodeInstance = (INodeInstance) wfElementInstanceMap.get(toNodeId);
if (leavingNodeInstance != null) {
leavingNodeInstance.addEnteringLoopInstance(loopInstance);
loopInstance.setLeavingNodeInstance(leavingNodeInstance);
}
}
extensionList = kenelExtensions.get(loopInstance.getExtensionTargetName());
for (int j = 0; extensionList != null && j < extensionList.size(); j++) {
IKernelExtension extension = extensionList.get(j);
loopInstance.registExtension(extension);
}
wfElementInstanceMap.put(loopInstance.getId(), loopInstance);
}
}