use of org.jbpm.workflow.core.node.EventNode 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));
}
}
}
use of org.jbpm.workflow.core.node.EventNode in project jbpm by kiegroup.
the class EventFilterHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Object parent = parser.getParent();
final String type = element.getAttribute("type");
emptyAttributeCheck(localName, "type", type, parser);
if ("eventType".equals(type)) {
final String eventType = element.getAttribute("eventType");
emptyAttributeCheck(localName, "eventType", eventType, parser);
EventTypeFilter eventTypeFilter = new EventTypeFilter();
eventTypeFilter.setType(eventType);
if (parent instanceof EventNode) {
((EventNode) parent).addEventFilter(eventTypeFilter);
} else if (parent instanceof EventTrigger) {
((EventTrigger) parent).addEventFilter(eventTypeFilter);
}
} else {
throw new IllegalArgumentException("Unknown event filter type: " + type);
}
return null;
}
use of org.jbpm.workflow.core.node.EventNode in project jbpm by kiegroup.
the class EventNodeHandler method handleNode.
public void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
EventNode eventNode = (EventNode) node;
String variableName = element.getAttribute("variableName");
if (variableName != null && variableName.length() != 0) {
eventNode.setVariableName(variableName);
}
String scope = element.getAttribute("scope");
if (scope != null && scope.length() != 0) {
eventNode.setScope(scope);
}
}
use of org.jbpm.workflow.core.node.EventNode in project jbpm by kiegroup.
the class RuleFlowProcessValidator method checkAllNodesConnectedToStart.
private void checkAllNodesConnectedToStart(final NodeContainer container, boolean isDynamic, final List<ProcessValidationError> errors, RuleFlowProcess process) {
final Map<Node, Boolean> processNodes = new HashMap<Node, Boolean>();
final Node[] nodes;
if (container instanceof CompositeNode) {
nodes = ((CompositeNode) container).internalGetNodes();
} else {
nodes = container.getNodes();
}
List<Node> eventNodes = new ArrayList<Node>();
List<CompositeNode> compositeNodes = new ArrayList<CompositeNode>();
for (int i = 0; i < nodes.length; i++) {
final Node node = nodes[i];
processNodes.put(node, Boolean.FALSE);
if (node instanceof EventNode) {
eventNodes.add(node);
}
if (node instanceof CompositeNode) {
compositeNodes.add((CompositeNode) node);
}
}
if (isDynamic) {
for (Node node : nodes) {
if (node.getIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE).isEmpty()) {
processNode(node, processNodes);
}
}
} else {
final List<Node> start = RuleFlowProcess.getStartNodes(nodes);
if (start != null) {
for (Node s : start) {
processNode(s, processNodes);
}
}
if (container instanceof CompositeNode) {
for (CompositeNode.NodeAndType nodeAndTypes : ((CompositeNode) container).getLinkedIncomingNodes().values()) {
processNode(nodeAndTypes.getNode(), processNodes);
}
}
}
for (Node eventNode : eventNodes) {
processNode(eventNode, processNodes);
}
for (CompositeNode compositeNode : compositeNodes) {
checkAllNodesConnectedToStart(compositeNode, compositeNode instanceof DynamicNode, errors, process);
}
for (final Iterator<Node> it = processNodes.keySet().iterator(); it.hasNext(); ) {
final Node node = it.next();
if (Boolean.FALSE.equals(processNodes.get(node)) && !(node instanceof StartNode) && !(node instanceof EventSubProcessNode)) {
addErrorMessage(process, node, errors, "Has no connection to the start node.");
}
}
}
use of org.jbpm.workflow.core.node.EventNode in project jbpm by kiegroup.
the class XmlBPMNProcessDumper method visitEscalations.
protected void visitEscalations(Node[] nodes, StringBuilder xmlDump, List<String> escalations) {
for (Node node : nodes) {
if (node instanceof FaultNode) {
FaultNode faultNode = (FaultNode) node;
if (!faultNode.isTerminateParent()) {
String escalationCode = faultNode.getFaultName();
if (!escalations.contains(escalationCode)) {
escalations.add(escalationCode);
xmlDump.append(" <escalation id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(escalationCode) + "\" escalationCode=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(escalationCode) + "\" />" + EOL);
}
}
} else if (node instanceof ActionNode) {
ActionNode actionNode = (ActionNode) node;
if (actionNode.getAction() instanceof DroolsConsequenceAction) {
DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
if (action != null) {
String s = action.getConsequence();
if (s.startsWith("org.drools.core.process.instance.context.exception.ExceptionScopeInstance scopeInstance = (org.drools.core.process.instance.context.exception.ExceptionScopeInstance) ((org.drools.workflow.instance.NodeInstance) kcontext.getNodeInstance()).resolveContextInstance(org.drools.core.process.core.context.exception.ExceptionScope.EXCEPTION_SCOPE, \"")) {
s = s.substring(327);
String type = s.substring(0, s.indexOf("\""));
if (!escalations.contains(type)) {
escalations.add(type);
xmlDump.append(" <escalation id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\" escalationCode=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\" />" + EOL);
}
}
}
} else {
logger.warn("Cannot serialize custom implementation of the Action interface to XML");
}
} else if (node instanceof EventNode) {
EventNode eventNode = (EventNode) node;
String type = (String) eventNode.getMetaData("EscalationEvent");
if (type != null) {
if (!escalations.contains(type)) {
escalations.add(type);
xmlDump.append(" <escalation id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\" escalationCode=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(type) + "\" />" + EOL);
}
}
}
if (node instanceof CompositeNode) {
visitEscalations(((CompositeNode) node).getNodes(), xmlDump, escalations);
}
}
}
Aggregations