use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.
the class ServicesProcessDataEventListener method onComplete.
@Override
public void onComplete(Process process) {
// process item definitions
if (itemDefinitions != null) {
for (ItemDefinition item : itemDefinitions.values()) {
String id = item.getId();
String structureRef = item.getStructureRef();
// NPE!
String itemDefinitionId = processDescriptor.getGlobalItemDefinitions().get(id);
if (itemDefinitionId == null) {
processDescriptor.getGlobalItemDefinitions().put(id, structureRef);
if (structureRef.contains(".")) {
processDescriptor.getReferencedClasses().add(structureRef);
} else {
processDescriptor.getUnqualifiedClasses().add(structureRef);
}
}
}
}
// process globals
Map<String, String> globals = ((RuleFlowProcess) process).getGlobals();
if (globals != null) {
Set<String> globalNames = new HashSet<>();
for (Entry<String, String> globalEntry : globals.entrySet()) {
globalNames.add(globalEntry.getKey());
String type = globalEntry.getValue();
if (type.contains(".")) {
processDescriptor.getReferencedClasses().add(type);
} else {
processDescriptor.getUnqualifiedClasses().add(type);
}
}
processDescriptor.setGlobals(globalNames);
}
// process imports
Set<String> imports = ((RuleFlowProcess) process).getImports();
if (imports != null) {
for (String type : imports) {
if (type.contains(".")) {
processDescriptor.getReferencedClasses().add(type);
} else {
processDescriptor.getUnqualifiedClasses().add(type);
}
}
}
}
use of org.jbpm.bpmn2.core.ItemDefinition in project kie-wb-common by kiegroup.
the class BpmnProcessDataEventListener method addDistinctProcessVariables.
public void addDistinctProcessVariables(List<Variable> variables, Resource resource) {
if (variables != null) {
uniqueVariables = new HashSet<>();
for (Variable data : variables) {
String type = data.getType().getStringType();
String itemSubjectRef = (String) data.getMetaData("ItemSubjectRef");
if (itemSubjectRef != null && itemDefinitions != null) {
ItemDefinition itemDef = itemDefinitions.get(itemSubjectRef);
type = itemDef.getStructureRef();
}
// add only if unique
if (uniqueVariables.add(data.getName())) {
resource.addPart(data.getName(), PartType.VARIABLE);
}
if (type.contains(".")) {
getReferencedClasses().add(type);
} else {
getUnqualifiedClasses().add(type);
}
}
}
}
use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm 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 ("dataOutput".equals(nodeName)) {
String id = ((Element) xmlNode).getAttribute("id");
String outputName = ((Element) xmlNode).getAttribute("name");
dataOutputs.put(id, outputName);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, eventNode);
} else 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 IllegalArgumentException("No errors found");
}
Error error = null;
for (Error listError : errors) {
if (errorRef.equals(listError.getId())) {
error = listError;
}
}
if (error == null) {
throw new IllegalArgumentException("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 org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.
the class DefinitionsHandler method setVariableDataType.
private void setVariableDataType(Variable variable, Map<String, ItemDefinition> itemDefinitions, ClassLoader cl) {
// retrieve type from item definition
String itemSubjectRef = (String) variable.getMetaData("ItemSubjectRef");
if (UndefinedDataType.getInstance().equals(variable.getType()) && itemDefinitions != null && itemSubjectRef != null) {
DataType dataType = new ObjectDataType();
ItemDefinition itemDefinition = itemDefinitions.get(itemSubjectRef);
if (itemDefinition != null) {
String structureRef = itemDefinition.getStructureRef();
if ("java.lang.Boolean".equals(structureRef) || "Boolean".equals(structureRef)) {
dataType = new BooleanDataType();
} else if ("java.lang.Integer".equals(structureRef) || "Integer".equals(structureRef)) {
dataType = new IntegerDataType();
} else if ("java.lang.Float".equals(structureRef) || "Float".equals(structureRef)) {
dataType = new FloatDataType();
} else if ("java.lang.String".equals(structureRef) || "String".equals(structureRef)) {
dataType = new StringDataType();
} else if ("java.lang.Object".equals(structureRef) || "Object".equals(structureRef)) {
// use FQCN of Object
dataType = new ObjectDataType("java.lang.Object");
} else {
dataType = new ObjectDataType(structureRef, cl);
}
}
variable.setType(dataType);
}
}
use of org.jbpm.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();
}
}
Aggregations