use of org.jbpm.process.core.datatype.impl.type.ObjectDataType in project jbpm by kiegroup.
the class ForEachNodeHandler 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);
ForEachNode forEachNode = (ForEachNode) node;
final String variableName = element.getAttribute("variableName");
if (variableName != null && variableName.length() != 0) {
forEachNode.setVariable(variableName, new ObjectDataType());
}
final String collectionExpression = element.getAttribute("collectionExpression");
if (collectionExpression != null && collectionExpression.length() != 0) {
forEachNode.setCollectionExpression(collectionExpression);
}
final String waitForCompletion = element.getAttribute("waitForCompletion");
if ("false".equals(waitForCompletion)) {
forEachNode.setWaitForCompletion(false);
}
}
use of org.jbpm.process.core.datatype.impl.type.ObjectDataType in project jbpm by kiegroup.
the class VariablePersistenceStrategyTest method getKnowledgeBaseForExtendingInterfaceVariablePersistence.
private KieBase getKnowledgeBaseForExtendingInterfaceVariablePersistence(String processId, final String variableText) {
RuleFlowProcess process = new RuleFlowProcess();
process.setId(processId);
List<Variable> variables = new ArrayList<Variable>();
Variable variable = new Variable();
variable.setName("x");
ObjectDataType extendingSerializableDataType = new ObjectDataType();
extendingSerializableDataType.setClassName(MyVariableExtendingSerializable.class.getName());
variable.setType(extendingSerializableDataType);
variables.add(variable);
process.getVariableScope().setVariables(variables);
StartNode startNode = new StartNode();
startNode.setName("Start");
startNode.setId(1);
WorkItemNode workItemNode = new WorkItemNode();
workItemNode.setName("workItemNode");
workItemNode.setId(2);
Work work = new WorkImpl();
work.setName("MyWork");
workItemNode.setWork(work);
ActionNode actionNode = new ActionNode();
actionNode.setName("Print");
DroolsAction action = new DroolsConsequenceAction("java", null);
action.setMetaData("Action", new Action() {
public void execute(ProcessContext context) throws Exception {
Assert.assertEquals(variableText, ((MyVariableExtendingSerializable) context.getVariable("x")).getText());
;
}
});
actionNode.setAction(action);
actionNode.setId(3);
EndNode endNode = new EndNode();
endNode.setName("EndNode");
endNode.setId(4);
connect(startNode, workItemNode);
connect(workItemNode, actionNode);
connect(actionNode, endNode);
process.addNode(startNode);
process.addNode(workItemNode);
process.addNode(actionNode);
process.addNode(endNode);
KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
((KnowledgeBaseImpl) kbase).addProcess(process);
return kbase;
}
use of org.jbpm.process.core.datatype.impl.type.ObjectDataType in project jbpm by kiegroup.
the class WorkItemPersistenceTest method getWorkItemProcess.
private RuleFlowProcess getWorkItemProcess(String processId, String workName) {
RuleFlowProcess process = new RuleFlowProcess();
process.setId(processId);
List<Variable> variables = new ArrayList<Variable>();
Variable variable = new Variable();
variable.setName("UserName");
variable.setType(new StringDataType());
variables.add(variable);
variable = new Variable();
variable.setName("MyObject");
variable.setType(new ObjectDataType());
variables.add(variable);
variable = new Variable();
variable.setName("Number");
variable.setType(new IntegerDataType());
variables.add(variable);
process.getVariableScope().setVariables(variables);
StartNode startNode = new StartNode();
startNode.setName("Start");
startNode.setId(1);
HumanTaskNode workItemNode = new HumanTaskNode();
workItemNode.setName("workItemNode");
workItemNode.setId(2);
workItemNode.addInMapping("Attachment", "MyObject");
workItemNode.addOutMapping("Result", "MyObject");
workItemNode.addOutMapping("Result.length()", "Number");
Work work = new WorkImpl();
work.setName(workName);
Set<ParameterDefinition> parameterDefinitions = new HashSet<ParameterDefinition>();
ParameterDefinition parameterDefinition = new ParameterDefinitionImpl("ActorId", new StringDataType());
parameterDefinitions.add(parameterDefinition);
parameterDefinition = new ParameterDefinitionImpl("Content", new StringDataType());
parameterDefinitions.add(parameterDefinition);
parameterDefinition = new ParameterDefinitionImpl("Comment", new StringDataType());
parameterDefinitions.add(parameterDefinition);
work.setParameterDefinitions(parameterDefinitions);
work.setParameter("ActorId", "#{UserName}");
work.setParameter("Content", "#{Person.name}");
workItemNode.setWork(work);
EndNode endNode = new EndNode();
endNode.setName("End");
endNode.setId(3);
connect(startNode, workItemNode);
connect(workItemNode, endNode);
process.addNode(startNode);
process.addNode(workItemNode);
process.addNode(endNode);
return process;
}
use of org.jbpm.process.core.datatype.impl.type.ObjectDataType 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.process.core.datatype.impl.type.ObjectDataType in project jbpm by kiegroup.
the class DataStoreHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
DataStore store = new DataStore();
store.setId(attrs.getValue("id"));
store.setName(attrs.getValue("name"));
final String itemSubjectRef = attrs.getValue("itemSubjectRef");
store.setItemSubjectRef(itemSubjectRef);
Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
// retrieve type from item definition
// FIXME we bypass namespace resolving here. That's not a good idea when we start having several documents, with imports.
String localItemSubjectRef = itemSubjectRef.substring(itemSubjectRef.indexOf(":") + 1);
DataType dataType = new ObjectDataType();
if (itemDefinitions != null) {
ItemDefinition itemDefinition = itemDefinitions.get(localItemSubjectRef);
if (itemDefinition != null) {
dataType = new ObjectDataType(itemDefinition.getStructureRef(), parser.getClassLoader());
}
}
store.setType(dataType);
Definitions parent = (Definitions) parser.getParent();
List<DataStore> dataStores = parent.getDataStores();
if (dataStores == null) {
dataStores = new ArrayList<DataStore>();
parent.setDataStores(dataStores);
}
dataStores.add(store);
return store;
}
Aggregations