use of org.jbpm.process.builder.dialect.ProcessDialect in project jbpm by kiegroup.
the class ExtendedNodeBuilder method buildAction.
protected void buildAction(DroolsAction droolsAction, ProcessBuildContext context, NodeImpl node) {
DroolsConsequenceAction action = (DroolsConsequenceAction) droolsAction;
ActionDescr actionDescr = new ActionDescr();
actionDescr.setText(action.getConsequence());
actionDescr.setResource(context.getProcessDescr().getResource());
ProcessDialect dialect = ProcessDialectRegistry.getDialect(action.getDialect());
dialect.getActionBuilder().build(context, action, actionDescr, node);
}
use of org.jbpm.process.builder.dialect.ProcessDialect in project jbpm by kiegroup.
the class MultiConditionalSequenceFlowNodeBuilder method build.
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
Map<ConnectionRef, Constraint> constraints = ((NodeImpl) node).getConstraints();
// exclude split as it is handled with separate builder and nodes with non conditional sequence flows
if (node instanceof Split || constraints.size() == 0) {
return;
}
// we need to clone the map, so we can update the original while iterating.
Map<ConnectionRef, Constraint> map = new HashMap<ConnectionRef, Constraint>(constraints);
for (Iterator<Map.Entry<ConnectionRef, Constraint>> it = map.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<ConnectionRef, Constraint> entry = it.next();
ConnectionRef connection = entry.getKey();
ConstraintImpl constraint = (ConstraintImpl) entry.getValue();
Connection outgoingConnection = null;
for (Connection out : ((NodeImpl) node).getDefaultOutgoingConnections()) {
if (out.getToType().equals(connection.getToType()) && out.getTo().getId() == connection.getNodeId()) {
outgoingConnection = out;
}
}
if (outgoingConnection == null) {
throw new IllegalArgumentException("Could not find outgoing connection");
}
if ("rule".equals(constraint.getType())) {
RuleConstraintEvaluator ruleConstraint = new RuleConstraintEvaluator();
ruleConstraint.setDialect(constraint.getDialect());
ruleConstraint.setName(constraint.getName());
ruleConstraint.setPriority(constraint.getPriority());
ruleConstraint.setDefault(constraint.isDefault());
((NodeImpl) node).setConstraint(outgoingConnection, ruleConstraint);
} else if ("code".equals(constraint.getType())) {
ReturnValueConstraintEvaluator returnValueConstraint = new ReturnValueConstraintEvaluator();
returnValueConstraint.setDialect(constraint.getDialect());
returnValueConstraint.setName(constraint.getName());
returnValueConstraint.setPriority(constraint.getPriority());
returnValueConstraint.setDefault(constraint.isDefault());
((NodeImpl) node).setConstraint(outgoingConnection, returnValueConstraint);
ReturnValueDescr returnValueDescr = new ReturnValueDescr();
returnValueDescr.setText(constraint.getConstraint());
returnValueDescr.setResource(processDescr.getResource());
ProcessDialect dialect = ProcessDialectRegistry.getDialect(constraint.getDialect());
dialect.getReturnValueEvaluatorBuilder().build(context, returnValueConstraint, returnValueDescr, (NodeImpl) node);
}
}
}
use of org.jbpm.process.builder.dialect.ProcessDialect in project jbpm by kiegroup.
the class SplitNodeBuilder method build.
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
Split splitNode = (Split) node;
if (splitNode.getType() != Split.TYPE_XOR && splitNode.getType() != Split.TYPE_OR) {
// we only process or/xor
return;
}
// we need to clone the map, so we can update the original while iterating.
Map<ConnectionRef, Constraint> map = new HashMap<ConnectionRef, Constraint>(splitNode.getConstraints());
for (Iterator<Map.Entry<ConnectionRef, Constraint>> it = map.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<ConnectionRef, Constraint> entry = it.next();
ConnectionRef connection = entry.getKey();
ConstraintImpl constraint = (ConstraintImpl) entry.getValue();
Connection outgoingConnection = null;
for (Connection out : splitNode.getDefaultOutgoingConnections()) {
if (out.getToType().equals(connection.getToType()) && out.getTo().getId() == connection.getNodeId()) {
outgoingConnection = out;
}
}
if (outgoingConnection == null) {
throw new IllegalArgumentException("Could not find outgoing connection");
}
if (constraint == null && splitNode.isDefault(outgoingConnection)) {
// do nothing since conditions are ignored for default sequence flow
} else if (constraint != null && "rule".equals(constraint.getType())) {
RuleConstraintEvaluator ruleConstraint = new RuleConstraintEvaluator();
ruleConstraint.setDialect(constraint.getDialect());
ruleConstraint.setName(constraint.getName());
ruleConstraint.setPriority(constraint.getPriority());
ruleConstraint.setDefault(constraint.isDefault());
ruleConstraint.setType(constraint.getType());
ruleConstraint.setConstraint(constraint.getConstraint());
splitNode.setConstraint(outgoingConnection, ruleConstraint);
} else if (constraint != null && "code".equals(constraint.getType())) {
ReturnValueConstraintEvaluator returnValueConstraint = new ReturnValueConstraintEvaluator();
returnValueConstraint.setDialect(constraint.getDialect());
returnValueConstraint.setName(constraint.getName());
returnValueConstraint.setPriority(constraint.getPriority());
returnValueConstraint.setDefault(constraint.isDefault());
returnValueConstraint.setType(constraint.getType());
returnValueConstraint.setConstraint(constraint.getConstraint());
splitNode.setConstraint(outgoingConnection, returnValueConstraint);
ReturnValueDescr returnValueDescr = new ReturnValueDescr();
returnValueDescr.setText(constraint.getConstraint());
returnValueDescr.setResource(processDescr.getResource());
ProcessDialect dialect = ProcessDialectRegistry.getDialect(constraint.getDialect());
dialect.getReturnValueEvaluatorBuilder().build(context, returnValueConstraint, returnValueDescr, (NodeImpl) node);
}
}
}
use of org.jbpm.process.builder.dialect.ProcessDialect in project jbpm by kiegroup.
the class ProcessBuilderImpl method buildContexts.
public void buildContexts(ContextContainer contextContainer, ProcessBuildContext buildContext) {
List<Context> exceptionScopes = contextContainer.getContexts(ExceptionScope.EXCEPTION_SCOPE);
if (exceptionScopes != null) {
for (Context context : exceptionScopes) {
// TODO: OCRAM: add compensation scope to process builder????
ExceptionScope exceptionScope = (ExceptionScope) context;
for (ExceptionHandler exceptionHandler : exceptionScope.getExceptionHandlers().values()) {
if (exceptionHandler instanceof ActionExceptionHandler) {
DroolsConsequenceAction action = (DroolsConsequenceAction) ((ActionExceptionHandler) exceptionHandler).getAction();
ActionDescr actionDescr = new ActionDescr();
actionDescr.setText(action.getConsequence());
actionDescr.setResource(buildContext.getProcessDescr().getResource());
ProcessDialect dialect = ProcessDialectRegistry.getDialect(action.getDialect());
dialect.getActionBuilder().build(buildContext, action, actionDescr, (ProcessImpl) buildContext.getProcess());
}
}
}
}
}
Aggregations