use of org.jbpm.workflow.core.impl.ConnectionImpl 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.jbpm.workflow.core.impl.ConnectionImpl in project jbpm by kiegroup.
the class ConnectionHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
String fromId = attrs.getValue("from");
emptyAttributeCheck(localName, "from", fromId, parser);
String toId = attrs.getValue("to");
emptyAttributeCheck(localName, "to", toId, parser);
String bendpoints = attrs.getValue("bendpoints");
String fromType = attrs.getValue("fromType");
if (fromType == null || fromType.trim().length() == 0) {
fromType = NodeImpl.CONNECTION_DEFAULT_TYPE;
}
String toType = attrs.getValue("toType");
if (toType == null || toType.trim().length() == 0) {
toType = NodeImpl.CONNECTION_DEFAULT_TYPE;
}
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
Node fromNode = nodeContainer.getNode(new Long(fromId));
Node toNode = nodeContainer.getNode(new Long(toId));
if (fromNode == null) {
throw new SAXParseException("Node '" + fromId + "'cannot be found", parser.getLocator());
}
if (toNode == null) {
throw new SAXParseException("Node '" + toId + "' cannot be found", parser.getLocator());
}
ConnectionImpl connection = new ConnectionImpl(fromNode, fromType, toNode, toType);
connection.setMetaData("bendpoints", bendpoints);
return connection;
}
use of org.jbpm.workflow.core.impl.ConnectionImpl in project jbpm by kiegroup.
the class RuleFlowNodeContainerFactory method connection.
public RuleFlowNodeContainerFactory connection(long fromId, long toId) {
Node from = nodeContainer.getNode(fromId);
Node to = nodeContainer.getNode(toId);
new ConnectionImpl(from, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, to, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
return this;
}
use of org.jbpm.workflow.core.impl.ConnectionImpl in project jbpm by kiegroup.
the class XmlBPMNProcessDumper method visitConnection.
public void visitConnection(Connection connection, StringBuilder xmlDump, int metaDataType) {
// if the connection was generated by a link event, don't dump.
if (isConnectionRepresentingLinkEvent(connection)) {
return;
}
// if the connection is a hidden one (compensations), don't dump
Object hidden = ((ConnectionImpl) connection).getMetaData("hidden");
if (hidden != null && ((Boolean) hidden)) {
return;
}
xmlDump.append(" <sequenceFlow id=\"" + getUniqueNodeId(connection.getFrom()) + "-" + getUniqueNodeId(connection.getTo()) + "\" sourceRef=\"" + getUniqueNodeId(connection.getFrom()) + "\" ");
// TODO fromType, toType
xmlDump.append("targetRef=\"" + getUniqueNodeId(connection.getTo()) + "\" ");
if (metaDataType == META_DATA_AS_NODE_PROPERTY) {
String bendpoints = (String) connection.getMetaData().get("bendpoints");
if (bendpoints != null) {
xmlDump.append("g:bendpoints=\"" + bendpoints + "\" ");
}
}
if (connection.getFrom() instanceof Split) {
Split split = (Split) connection.getFrom();
if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR) {
Constraint constraint = split.getConstraint(connection);
if (constraint == null) {
xmlDump.append(">" + EOL + " <conditionExpression xsi:type=\"tFormalExpression\" />");
} else {
if (constraint.getName() != null && constraint.getName().trim().length() > 0) {
xmlDump.append("name=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(constraint.getName()) + "\" ");
}
if (constraint.getPriority() != 0) {
xmlDump.append("tns:priority=\"" + constraint.getPriority() + "\" ");
}
xmlDump.append(">" + EOL + " <conditionExpression xsi:type=\"tFormalExpression\" ");
if ("code".equals(constraint.getType())) {
if (JavaDialect.ID.equals(constraint.getDialect())) {
xmlDump.append("language=\"" + JAVA_LANGUAGE + "\" ");
} else if ("XPath".equals(constraint.getDialect())) {
xmlDump.append("language=\"" + XPATH_LANGUAGE + "\" ");
} else if ("JavaScript".equals(constraint.getDialect())) {
xmlDump.append("language=\"" + JAVASCRIPT_LANGUAGE + "\" ");
}
} else {
xmlDump.append("language=\"" + RULE_LANGUAGE + "\" ");
}
String constraintString = constraint.getConstraint();
if (constraintString == null) {
constraintString = "";
}
xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</conditionExpression>");
}
xmlDump.append(EOL + " </sequenceFlow>" + EOL);
} else {
xmlDump.append("/>" + EOL);
}
} else {
xmlDump.append("/>" + EOL);
}
}
use of org.jbpm.workflow.core.impl.ConnectionImpl in project jbpm by kiegroup.
the class ProcessHandler method checkBoundaryEventCompensationHandler.
/**
* This logic belongs in {@link RuleFlowProcessValidator} -- except that {@link Association}s are a jbpm-bpmn2 class,
* and {@link RuleFlowProcessValidator} is a jbpm-flow class..
* </p>
* Maybe we should have a BPMNProcessValidator class?
*
* @param association The association to check.
* @param source The source of the association.
* @param target The target of the association.
*/
private static void checkBoundaryEventCompensationHandler(Association association, Node source, Node target) {
// - event node is boundary event node
if (!(source instanceof BoundaryEventNode)) {
throw new IllegalArgumentException("(Compensation) activities may only be associated with Boundary Event Nodes (not with" + source.getClass().getSimpleName() + " nodes [node " + ((String) source.getMetaData().get("UniqueId")) + "].");
}
BoundaryEventNode eventNode = (BoundaryEventNode) source;
// - event node has compensationEvent
List<EventFilter> eventFilters = eventNode.getEventFilters();
boolean compensationCheckPassed = false;
if (eventFilters != null) {
for (EventFilter filter : eventFilters) {
if (filter instanceof EventTypeFilter) {
String type = ((EventTypeFilter) filter).getType();
if (type != null && type.equals("Compensation")) {
compensationCheckPassed = true;
}
}
}
}
if (!compensationCheckPassed) {
throw new IllegalArgumentException("An Event [" + ((String) eventNode.getMetaData("UniqueId")) + "] linked from an association [" + association.getId() + "] must be a (Boundary) Compensation Event.");
}
// - boundary event node is attached to the correct type of node?
/**
* Tasks:
* business: RuleSetNode
* manual: WorkItemNode
* receive: WorkItemNode
* script: ActionNode
* send: WorkItemNode
* service: WorkItemNode
* task: WorkItemNode
* user: HumanTaskNode
*/
String attachedToId = eventNode.getAttachedToNodeId();
Node attachedToNode = null;
for (Node node : eventNode.getNodeContainer().getNodes()) {
if (attachedToId.equals(node.getMetaData().get("UniqueId"))) {
attachedToNode = node;
break;
}
}
if (attachedToNode == null) {
throw new IllegalArgumentException("Boundary Event [" + ((String) eventNode.getMetaData("UniqueId")) + "] is not attached to a node [" + attachedToId + "] that can be found.");
}
if (!(attachedToNode instanceof RuleSetNode || attachedToNode instanceof WorkItemNode || attachedToNode instanceof ActionNode || attachedToNode instanceof HumanTaskNode || attachedToNode instanceof CompositeNode || attachedToNode instanceof SubProcessNode)) {
throw new IllegalArgumentException("Compensation Boundary Event [" + ((String) eventNode.getMetaData("UniqueId")) + "] must be attached to a task or sub-process.");
}
// - associated node is a task or subProcess
compensationCheckPassed = false;
if (target instanceof WorkItemNode || target instanceof HumanTaskNode || target instanceof CompositeContextNode || target instanceof SubProcessNode) {
compensationCheckPassed = true;
} else if (target instanceof ActionNode) {
Object nodeTypeObj = ((ActionNode) target).getMetaData("NodeType");
if (nodeTypeObj != null && nodeTypeObj.equals("ScriptTask")) {
compensationCheckPassed = true;
}
}
if (!compensationCheckPassed) {
throw new IllegalArgumentException("An Activity [" + ((String) ((NodeImpl) target).getMetaData("UniqueId")) + "] associated with a Boundary Compensation Event must be a Task or a (non-Event) Sub-Process");
}
// - associated node does not have outgoingConnections of it's own
compensationCheckPassed = true;
NodeImpl targetNode = (NodeImpl) target;
Map<String, List<org.kie.api.definition.process.Connection>> connectionsMap = targetNode.getOutgoingConnections();
ConnectionImpl outgoingConnection = null;
for (String connectionType : connectionsMap.keySet()) {
List<org.kie.api.definition.process.Connection> connections = connectionsMap.get(connectionType);
if (connections != null && !connections.isEmpty()) {
for (org.kie.api.definition.process.Connection connection : connections) {
Object hiddenObj = connection.getMetaData().get("hidden");
if (hiddenObj != null && ((Boolean) hiddenObj)) {
continue;
}
outgoingConnection = (ConnectionImpl) connection;
compensationCheckPassed = false;
break;
}
}
}
if (!compensationCheckPassed) {
throw new IllegalArgumentException("A Compensation Activity [" + ((String) targetNode.getMetaData("UniqueId")) + "] may not have any outgoing connection [" + (String) outgoingConnection.getMetaData("UniqueId") + "]");
}
}
Aggregations