use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.
the class TaskHandler method handleNode.
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);
itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
dataTypeInputs.clear();
dataTypeOutputs.clear();
WorkItemNode workItemNode = (WorkItemNode) node;
String name = getTaskName(element);
Work work = new WorkImpl();
work.setName(name);
workItemNode.setWork(work);
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("ioSpecification".equals(nodeName)) {
readIoSpecification(xmlNode, dataInputs, dataOutputs);
} else if ("dataInputAssociation".equals(nodeName)) {
readDataInputAssociation(xmlNode, workItemNode, dataInputs);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, workItemNode, dataOutputs);
}
xmlNode = xmlNode.getNextSibling();
}
workItemNode.setMetaData("DataInputs", new HashMap<String, String>(dataTypeInputs));
workItemNode.setMetaData("DataOutputs", new HashMap<String, String>(dataTypeOutputs));
handleScript(workItemNode, element, "onEntry");
handleScript(workItemNode, element, "onExit");
String compensation = element.getAttribute("isForCompensation");
if (compensation != null) {
boolean isForCompensation = Boolean.parseBoolean(compensation);
if (isForCompensation) {
workItemNode.setMetaData("isForCompensation", isForCompensation);
}
}
}
use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.
the class DataObjectHandler method start.
@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final String id = attrs.getValue("id");
final String itemSubjectRef = attrs.getValue("itemSubjectRef");
Object parent = parser.getParent();
if (parent instanceof ContextContainer) {
ContextContainer contextContainer = (ContextContainer) parent;
VariableScope variableScope = (VariableScope) contextContainer.getDefaultContext(VariableScope.VARIABLE_SCOPE);
List variables = variableScope.getVariables();
Variable variable = new Variable();
variable.setMetaData("DataObject", "true");
variable.setName(id);
// retrieve type from item definition
DataType dataType = new ObjectDataType();
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
if (itemDefinitions != null) {
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, parser.getClassLoader());
}
}
}
variable.setType(dataType);
variables.add(variable);
return variable;
}
return new Variable();
}
use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.
the class DefinitionsHandler method end.
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;
}
use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.
the class AbstractNodeHandler method getDataType.
protected DataType getDataType(String itemSubjectRef, Map<String, ItemDefinition> itemDefinitions, ClassLoader cl) {
DataType dataType = new ObjectDataType();
if (itemDefinitions == null) {
return dataType;
}
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)) {
dataType = new ObjectDataType(structureRef);
} else {
dataType = new ObjectDataType(structureRef, cl);
}
}
return dataType;
}
use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.
the class ServicesProcessDataEventListener method onBuildComplete.
@SuppressWarnings("unchecked")
@Override
public void onBuildComplete(Process process) {
// process java dialect types
Set<String> referencedTypes = (Set<String>) process.getMetaData().get("JavaDialectReferencedTypes");
if (referencedTypes != null && !referencedTypes.isEmpty()) {
processDescriptor.getReferencedClasses().addAll(referencedTypes);
}
Set<String> unqualifiedClasses = (Set<String>) process.getMetaData().get("JavaDialectUnqualifiedTypes");
if (unqualifiedClasses != null && !unqualifiedClasses.isEmpty()) {
processDescriptor.getUnqualifiedClasses().addAll(unqualifiedClasses);
}
// process java return value types
referencedTypes = (Set<String>) process.getMetaData().get("JavaReturnValueReferencedTypes");
if (referencedTypes != null && !referencedTypes.isEmpty()) {
processDescriptor.getReferencedClasses().addAll(referencedTypes);
}
unqualifiedClasses = (Set<String>) process.getMetaData().get("JavaReturnValueUnqualifiedTypes");
if (unqualifiedClasses != null && !unqualifiedClasses.isEmpty()) {
processDescriptor.getUnqualifiedClasses().addAll(unqualifiedClasses);
}
// process mvel dialect types
referencedTypes = (Set<String>) process.getMetaData().get("MVELDialectReferencedTypes");
if (referencedTypes != null && !referencedTypes.isEmpty()) {
processDescriptor.getReferencedClasses().addAll(referencedTypes);
}
// process mvel return value types
referencedTypes = (Set<String>) process.getMetaData().get("MVELReturnValueReferencedTypes");
if (referencedTypes != null && !referencedTypes.isEmpty()) {
processDescriptor.getReferencedClasses().addAll(referencedTypes);
}
// process unqualified classes
resolveUnqualifiedClasses();
// process variables
if (variables != null) {
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();
}
processDescriptor.getInputs().put(data.getName(), type);
}
}
// process signals
if (signals != null) {
processDescriptor.setSignals(signals);
}
}
Aggregations