use of org.jbpm.bpmn2.core.Expression in project jbpm by kiegroup.
the class AdHocSubProcessHandler method handleNode.
@SuppressWarnings("unchecked")
protected 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);
DynamicNode dynamicNode = (DynamicNode) node;
String cancelRemainingInstances = element.getAttribute("cancelRemainingInstances");
if ("false".equals(cancelRemainingInstances)) {
dynamicNode.setCancelRemainingInstances(false);
}
// by default it should not autocomplete as it's adhoc
dynamicNode.setAutoComplete(false);
dynamicNode.setActivationExpression((String) dynamicNode.getMetaData("customActivationCondition"));
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("completionCondition".equals(nodeName)) {
String expression = xmlNode.getTextContent();
if (AUTOCOMPLETE_EXPRESSIONS.contains(expression)) {
dynamicNode.setAutoComplete(true);
} else {
dynamicNode.setCompletionExpression(expression == null ? "" : expression);
}
org.w3c.dom.Node languageNode = xmlNode.getAttributes().getNamedItem("language");
if (languageNode != null) {
String language = languageNode.getNodeValue();
if (XmlBPMNProcessDumper.MVEL_LANGUAGE.equals(language)) {
dynamicNode.setLanguage("mvel");
} else if (XmlBPMNProcessDumper.RULE_LANGUAGE.equals(language)) {
dynamicNode.setLanguage("rule");
} else {
throw new IllegalArgumentException("Unknown language " + language);
}
} else {
dynamicNode.setLanguage("mvel");
}
}
xmlNode = xmlNode.getNextSibling();
}
List<SequenceFlow> connections = (List<SequenceFlow>) dynamicNode.getMetaData(ProcessHandler.CONNECTIONS);
ProcessHandler.linkConnections(dynamicNode, connections);
ProcessHandler.linkBoundaryEvents(dynamicNode);
handleScript(dynamicNode, element, "onEntry");
handleScript(dynamicNode, element, "onExit");
}
use of org.jbpm.bpmn2.core.Expression in project kogito-runtimes by kiegroup.
the class AdHocSubProcessHandler method handleNode.
@SuppressWarnings("unchecked")
@Override
protected Node 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);
DynamicNode dynamicNode = (DynamicNode) node;
String cancelRemainingInstances = element.getAttribute("cancelRemainingInstances");
if ("false".equals(cancelRemainingInstances)) {
dynamicNode.setCancelRemainingInstances(false);
}
// by default it should not autocomplete as it's adhoc
org.w3c.dom.Node xmlNode = element.getFirstChild();
dynamicNode.setActivationCondition((String) node.getMetaData().get(CUSTOM_ACTIVATION_CONDITION));
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if (COMPLETION_CONDITION.equals(nodeName)) {
String expression = xmlNode.getTextContent();
if (AUTOCOMPLETE_EXPRESSIONS.contains(expression)) {
dynamicNode.setAutoComplete(true);
} else {
dynamicNode.setCompletionCondition(expression);
}
}
xmlNode = xmlNode.getNextSibling();
}
List<SequenceFlow> connections = (List<SequenceFlow>) dynamicNode.getMetaData(ProcessHandler.CONNECTIONS);
ProcessHandler.linkConnections(dynamicNode, connections);
ProcessHandler.linkBoundaryEvents(dynamicNode);
handleScript(dynamicNode, element, "onEntry");
handleScript(dynamicNode, element, "onExit");
return node;
}
use of org.jbpm.bpmn2.core.Expression in project jbpm by kiegroup.
the class SequenceFlowHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
SequenceFlow sequenceFlow = (SequenceFlow) parser.getCurrent();
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("conditionExpression".equals(nodeName)) {
String expression = xmlNode.getTextContent();
org.w3c.dom.Node languageNode = xmlNode.getAttributes().getNamedItem("language");
if (languageNode != null) {
String language = languageNode.getNodeValue();
if (XmlBPMNProcessDumper.JAVA_LANGUAGE.equals(language)) {
sequenceFlow.setLanguage("java");
} else if (XmlBPMNProcessDumper.MVEL_LANGUAGE.equals(language)) {
sequenceFlow.setLanguage("mvel");
} else if (XmlBPMNProcessDumper.RULE_LANGUAGE.equals(language)) {
sequenceFlow.setType("rule");
} else if (XmlBPMNProcessDumper.XPATH_LANGUAGE.equals(language)) {
sequenceFlow.setLanguage("XPath");
} else if (XmlBPMNProcessDumper.JAVASCRIPT_LANGUAGE.equals(language)) {
sequenceFlow.setLanguage("JavaScript");
} else if (XmlBPMNProcessDumper.FEEL_LANGUAGE.equals(language)) {
sequenceFlow.setLanguage("FEEL");
} else {
throw new IllegalArgumentException("Unknown language " + language);
}
}
sequenceFlow.setExpression(expression);
}
xmlNode = xmlNode.getNextSibling();
}
return sequenceFlow;
}
use of org.jbpm.bpmn2.core.Expression in project jbpm by kiegroup.
the class AbstractNodeHandler method readMultiInstanceLoopCharacteristics.
@SuppressWarnings("unchecked")
protected void readMultiInstanceLoopCharacteristics(org.w3c.dom.Node xmlNode, ForEachNode forEachNode, ExtensibleXmlParser parser) {
// sourceRef
org.w3c.dom.Node subNode = xmlNode.getFirstChild();
while (subNode != null) {
String nodeName = subNode.getNodeName();
if ("inputDataItem".equals(nodeName)) {
String variableName = ((Element) subNode).getAttribute("id");
String itemSubjectRef = ((Element) subNode).getAttribute("itemSubjectRef");
DataType dataType = null;
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
dataType = getDataType(itemSubjectRef, itemDefinitions, parser.getClassLoader());
if (variableName != null && variableName.trim().length() > 0) {
forEachNode.setVariable(variableName, dataType);
}
} else if ("outputDataItem".equals(nodeName)) {
String variableName = ((Element) subNode).getAttribute("id");
String itemSubjectRef = ((Element) subNode).getAttribute("itemSubjectRef");
DataType dataType = null;
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
dataType = getDataType(itemSubjectRef, itemDefinitions, parser.getClassLoader());
if (variableName != null && variableName.trim().length() > 0) {
forEachNode.setOutputVariable(variableName, dataType);
}
} else if ("loopDataOutputRef".equals(nodeName)) {
String outputDataRef = ((Element) subNode).getTextContent();
if (outputDataRef != null && outputDataRef.trim().length() > 0) {
String collectionName = outputAssociation.get(outputDataRef);
if (collectionName == null) {
collectionName = dataOutputs.get(outputDataRef);
}
forEachNode.setOutputCollectionExpression(collectionName);
}
forEachNode.setMetaData("MICollectionOutput", outputDataRef);
} else if ("loopDataInputRef".equals(nodeName)) {
String inputDataRef = ((Element) subNode).getTextContent();
if (inputDataRef != null && inputDataRef.trim().length() > 0) {
String collectionName = inputAssociation.get(inputDataRef);
if (collectionName == null) {
collectionName = dataInputs.get(inputDataRef);
}
forEachNode.setCollectionExpression(collectionName);
}
forEachNode.setMetaData("MICollectionInput", inputDataRef);
} else if ("completionCondition".equals(nodeName)) {
String expression = subNode.getTextContent();
forEachNode.setCompletionConditionExpression(expression);
}
subNode = subNode.getNextSibling();
}
}
use of org.jbpm.bpmn2.core.Expression in project kogito-runtimes by kiegroup.
the class ProcessHandler method postProcessCollaborations.
private void postProcessCollaborations(RuleFlowProcess process, ExtensibleXmlParser parser) {
// now we wire correlation process subscriptions
CorrelationManager correlationManager = process.getCorrelationManager();
for (Message message : HandlerUtil.messages(parser).values()) {
correlationManager.newMessage(message.getId(), message.getName(), message.getType());
}
// only the ones this process is member of
List<Collaboration> collaborations = HandlerUtil.collaborations(parser).values().stream().filter(c -> c.getProcessesRef().contains(process.getId())).collect(Collectors.toList());
for (Collaboration collaboration : collaborations) {
for (CorrelationKey key : collaboration.getCorrelationKeys()) {
correlationManager.newCorrelation(key.getId(), key.getName());
List<CorrelationProperty> properties = key.getPropertiesRef().stream().map(k -> HandlerUtil.correlationProperties(parser).get(k)).collect(Collectors.toList());
for (CorrelationProperty correlationProperty : properties) {
correlationProperty.getMessageRefs().forEach(messageRef -> {
// for now only MVEL expressions
MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(correlationProperty.getRetrievalExpression(messageRef).getScript());
correlationManager.addMessagePropertyExpression(key.getId(), messageRef, correlationProperty.getId(), evaluator);
});
}
}
}
// we create the correlations
for (CorrelationSubscription subscription : HandlerUtil.correlationSubscription(process).values()) {
correlationManager.subscribeTo(subscription.getCorrelationKeyRef());
for (Map.Entry<String, Expression> binding : subscription.getPropertyExpressions().entrySet()) {
MVELMessageExpressionEvaluator evaluator = new MVELMessageExpressionEvaluator(binding.getValue().getScript());
correlationManager.addProcessSubscriptionPropertyExpression(subscription.getCorrelationKeyRef(), binding.getKey(), evaluator);
}
}
}
Aggregations