use of org.kie.api.definition.process.Connection in project jbpm by kiegroup.
the class CompositeNode method removeIncomingConnection.
public void removeIncomingConnection(String type, Connection connection) {
super.removeIncomingConnection(type, connection);
CompositeNode.NodeAndType nodeAndType = internalGetLinkedIncomingNode(type);
if (nodeAndType != null) {
for (Connection inConnection : nodeAndType.getNode().getIncomingConnections(nodeAndType.getType())) {
if (((CompositeNodeStart) inConnection.getFrom()).getInNodeId() == connection.getFrom().getId()) {
Node compositeNodeStart = inConnection.getFrom();
((ConnectionImpl) inConnection).terminate();
internalRemoveNode(compositeNodeStart);
return;
}
}
throw new IllegalArgumentException("Could not find internal incoming connection for node");
}
}
use of org.kie.api.definition.process.Connection in project jbpm by kiegroup.
the class CompositeNode method removeOutgoingConnection.
public void removeOutgoingConnection(String type, Connection connection) {
super.removeOutgoingConnection(type, connection);
CompositeNode.NodeAndType nodeAndType = internalGetLinkedOutgoingNode(type);
if (nodeAndType != null) {
for (Connection outConnection : nodeAndType.getNode().getOutgoingConnections(nodeAndType.getType())) {
if (((CompositeNodeEnd) outConnection.getTo()).getOutNodeId() == connection.getTo().getId()) {
Node compositeNodeEnd = outConnection.getTo();
((ConnectionImpl) outConnection).terminate();
internalRemoveNode(compositeNodeEnd);
return;
}
}
throw new IllegalArgumentException("Could not find internal outgoing connection for node");
}
}
use of org.kie.api.definition.process.Connection in project jbpm by kiegroup.
the class CompositeNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
super.writeNode(getNodeName(), node, xmlDump, includeMeta);
CompositeNode compositeNode = (CompositeNode) node;
writeAttributes(compositeNode, xmlDump, includeMeta);
xmlDump.append(">" + EOL);
if (includeMeta) {
writeMetaData(compositeNode, xmlDump);
}
for (String eventType : compositeNode.getActionTypes()) {
writeActions(eventType, compositeNode.getActions(eventType), xmlDump);
}
writeTimers(compositeNode.getTimers(), xmlDump);
if (compositeNode instanceof CompositeContextNode) {
VariableScope variableScope = (VariableScope) ((CompositeContextNode) compositeNode).getDefaultContext(VariableScope.VARIABLE_SCOPE);
if (variableScope != null) {
List<Variable> variables = variableScope.getVariables();
XmlWorkflowProcessDumper.visitVariables(variables, xmlDump);
}
ExceptionScope exceptionScope = (ExceptionScope) ((CompositeContextNode) compositeNode).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
if (exceptionScope != null) {
XmlWorkflowProcessDumper.visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump);
}
}
List<Node> subNodes = getSubNodes(compositeNode);
xmlDump.append(" <nodes>" + EOL);
for (Node subNode : subNodes) {
XmlRuleFlowProcessDumper.INSTANCE.visitNode(subNode, xmlDump, includeMeta);
}
xmlDump.append(" </nodes>" + EOL);
List<Connection> connections = getSubConnections(compositeNode);
xmlDump.append(" <connections>" + EOL);
for (Connection connection : connections) {
XmlRuleFlowProcessDumper.INSTANCE.visitConnection(connection, xmlDump, includeMeta);
}
xmlDump.append(" </connections>" + EOL);
Map<String, CompositeNode.NodeAndType> inPorts = getInPorts(compositeNode);
xmlDump.append(" <in-ports>" + EOL);
for (Map.Entry<String, CompositeNode.NodeAndType> entry : inPorts.entrySet()) {
xmlDump.append(" <in-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeInType=\"" + entry.getValue().getType() + "\" />" + EOL);
}
xmlDump.append(" </in-ports>" + EOL);
Map<String, CompositeNode.NodeAndType> outPorts = getOutPorts(compositeNode);
xmlDump.append(" <out-ports>" + EOL);
for (Map.Entry<String, CompositeNode.NodeAndType> entry : outPorts.entrySet()) {
xmlDump.append(" <out-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeOutType=\"" + entry.getValue().getType() + "\" />" + EOL);
}
xmlDump.append(" </out-ports>" + EOL);
endNode(getNodeName(), xmlDump);
}
use of org.kie.api.definition.process.Connection in project jbpm by kiegroup.
the class ProcessBuilderImpl method generateRules.
private void generateRules(Node[] nodes, Process process, StringBuffer builder) {
for (int i = 0; i < nodes.length; i++) {
if (nodes[i] instanceof Split) {
Split split = (Split) nodes[i];
if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR) {
for (Connection connection : split.getDefaultOutgoingConnections()) {
Constraint constraint = split.getConstraint(connection);
if (constraint != null && "rule".equals(constraint.getType())) {
builder.append(createSplitRule(process, connection, split.getConstraint(connection).getConstraint()));
}
}
}
} else if (nodes[i] instanceof MilestoneNode) {
MilestoneNode milestone = (MilestoneNode) nodes[i];
builder.append(createMilestoneRule(process, milestone));
} else if (nodes[i] instanceof StateNode) {
StateNode state = (StateNode) nodes[i];
builder.append(createStateRules(process, state));
} else if (nodes[i] instanceof StartNode) {
StartNode startNode = (StartNode) nodes[i];
List<Trigger> triggers = startNode.getTriggers();
if (triggers != null) {
for (Trigger trigger : triggers) {
if (trigger instanceof ConstraintTrigger) {
builder.append(createStartConstraintRule(process, startNode.getNodeContainer(), (ConstraintTrigger) trigger));
}
}
}
} else if (nodes[i] instanceof NodeContainer) {
generateRules(((NodeContainer) nodes[i]).getNodes(), process, builder);
if (nodes[i] instanceof DynamicNode && "rule".equals(((DynamicNode) nodes[i]).getLanguage())) {
DynamicNode dynamicNode = (DynamicNode) nodes[i];
if (dynamicNode.getCompletionExpression() != null) {
builder.append(createAdHocCompletionRule(process, dynamicNode));
}
if (dynamicNode.getActivationExpression() != null && !dynamicNode.getActivationExpression().isEmpty()) {
builder.append(createAdHocActivationRule(process, dynamicNode));
}
}
} else if (nodes[i] instanceof EventNode) {
EventNode state = (EventNode) nodes[i];
builder.append(createEventStateRule(process, state));
}
}
}
Aggregations