use of io.automatiko.engine.workflow.bpmn2.core.ItemDefinition 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 io.automatiko.engine.workflow.bpmn2.core.ItemDefinition in project kogito-runtimes by kiegroup.
the class AbstractNodeHandler method readMultiInstanceSpecification.
// this is only for compiling purposes
protected MultiInstanceSpecification readMultiInstanceSpecification(ExtensibleXmlParser parser, org.w3c.dom.Node parent, IOSpecification ioSpecification) {
MultiInstanceSpecification multiInstanceSpecification = new MultiInstanceSpecification();
Optional<Element> multiInstanceParent = readSingleChildElementByTag(parent, "multiInstanceLoopCharacteristics");
if (multiInstanceParent.isEmpty()) {
return multiInstanceSpecification;
}
Element multiInstanceNode = multiInstanceParent.get();
multiInstanceSpecification.setSequential(Boolean.parseBoolean(multiInstanceNode.getAttribute("isSequential")));
readSingleChildElementByTag(multiInstanceNode, "inputDataItem").ifPresent(inputDataItem -> {
String id = inputDataItem.getAttribute("id");
String name = inputDataItem.getAttribute("name");
String itemSubjectRef = inputDataItem.getAttribute("itemSubjectRef");
ItemDefinition itemDefinition = getStructureRef(parser, itemSubjectRef);
String structureRef = itemDefinition != null ? itemDefinition.getStructureRef() : null;
DataDefinition input = new DataDefinition(id, name, structureRef);
multiInstanceSpecification.setInputDataItem(input);
if (!ioSpecification.containsInputLabel(input.getLabel())) {
ioSpecification.getDataInputs().add(input);
}
});
readSingleChildElementByTag(multiInstanceNode, "outputDataItem").ifPresent(outputDataItem -> {
String id = outputDataItem.getAttribute("id");
String name = outputDataItem.getAttribute("name");
String itemSubjectRef = outputDataItem.getAttribute("itemSubjectRef");
ItemDefinition itemDefinition = getStructureRef(parser, itemSubjectRef);
String structureRef = itemDefinition != null ? itemDefinition.getStructureRef() : null;
DataDefinition output = new DataDefinition(id, name, structureRef);
multiInstanceSpecification.setOutputDataItem(output);
if (!ioSpecification.containsOutputLabel(output.getLabel())) {
ioSpecification.getDataOutputs().add(output);
}
});
readSingleChildElementByTag(multiInstanceNode, "loopDataOutputRef").ifPresent(loopDataOutputRef -> {
String expressiontOutput = loopDataOutputRef.getTextContent();
if (expressiontOutput != null && !expressiontOutput.isEmpty()) {
multiInstanceSpecification.setLoopDataOutputRef(ioSpecification.getDataOutput().get(expressiontOutput));
}
});
readSingleChildElementByTag(multiInstanceNode, "loopDataInputRef").ifPresent(loopDataInputRef -> {
String expressionInput = loopDataInputRef.getTextContent();
if (expressionInput != null && !expressionInput.isEmpty()) {
multiInstanceSpecification.setLoopDataInputRef(ioSpecification.getDataInput().get(expressionInput));
}
});
readSingleChildElementByTag(multiInstanceNode, COMPLETION_CONDITION).ifPresent(completeCondition -> {
String completion = completeCondition.getTextContent();
if (completion != null && !completion.isEmpty()) {
multiInstanceSpecification.setCompletionCondition(completion);
}
});
return multiInstanceSpecification;
}
use of io.automatiko.engine.workflow.bpmn2.core.ItemDefinition in project kogito-runtimes by kiegroup.
the class AbstractNodeHandler method getStructureRef.
protected ItemDefinition getStructureRef(ExtensibleXmlParser parser, String id) {
ProcessBuildData buildData = (ProcessBuildData) parser.getData();
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) buildData.getMetaData("ItemDefinitions");
return itemDefinitions.get(id);
}
use of io.automatiko.engine.workflow.bpmn2.core.ItemDefinition in project kogito-runtimes by kiegroup.
the class BoundaryEventHandler method handleErrorNode.
@SuppressWarnings("unchecked")
protected void handleErrorNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, final String attachedTo, final boolean cancelActivity) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
BoundaryEventNode eventNode = (BoundaryEventNode) node;
eventNode.setMetaData("AttachedTo", attachedTo);
eventNode.setAttachedToNodeId(attachedTo);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("errorEventDefinition".equals(nodeName)) {
String errorRef = ((Element) xmlNode).getAttribute("errorRef");
if (errorRef != null && errorRef.trim().length() > 0) {
List<Error> errors = (List<Error>) ((ProcessBuildData) parser.getData()).getMetaData("Errors");
if (errors == null) {
throw new ProcessParsingValidationException("No errors found");
}
Error error = null;
for (Error listError : errors) {
if (errorRef.equals(listError.getId())) {
error = listError;
}
}
if (error == null) {
throw new ProcessParsingValidationException("Could not find error " + errorRef);
}
String type = error.getErrorCode();
boolean hasErrorCode = true;
if (type == null) {
type = error.getId();
hasErrorCode = false;
}
String structureRef = error.getStructureRef();
if (structureRef != null) {
Map<String, ItemDefinition> itemDefs = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
if (itemDefs.containsKey(structureRef)) {
structureRef = itemDefs.get(structureRef).getStructureRef();
}
}
List<EventFilter> eventFilters = new ArrayList<EventFilter>();
EventTypeFilter eventFilter = new EventTypeFilter();
eventFilter.setType("Error-" + attachedTo + "-" + type);
eventFilters.add(eventFilter);
eventNode.setEventFilters(eventFilters);
eventNode.setMetaData("ErrorEvent", type);
eventNode.setMetaData("HasErrorEvent", hasErrorCode);
eventNode.setMetaData("ErrorStructureRef", structureRef);
}
}
xmlNode = xmlNode.getNextSibling();
}
}
use of io.automatiko.engine.workflow.bpmn2.core.ItemDefinition in project kogito-runtimes by kiegroup.
the class DefinitionsHandler method end.
@Override
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Definitions definitions = (Definitions) parser.getCurrent();
String namespace = element.getAttribute("targetNamespace");
List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses();
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
List<Interface> interfaces = (List<Interface>) ((ProcessBuildData) parser.getData()).getMetaData("Interfaces");
for (Process process : processes) {
RuleFlowProcess ruleFlowProcess = (RuleFlowProcess) process;
ruleFlowProcess.setMetaData("TargetNamespace", namespace);
postProcessItemDefinitions(ruleFlowProcess, itemDefinitions, parser.getClassLoader());
postProcessInterfaces(ruleFlowProcess, interfaces);
}
definitions.setTargetNamespace(namespace);
return definitions;
}
Aggregations