use of org.jbpm.workflow.core.node.WorkItemNode in project jbpm by kiegroup.
the class XMLPersistenceTest method testPersistenceOfEmptyNodes.
@Test
public void testPersistenceOfEmptyNodes() throws Exception {
RuleFlowProcess process = new RuleFlowProcess() {
private static final long serialVersionUID = 510l;
int id = 0;
public void addNode(org.kie.api.definition.process.Node node) {
((Node) node).setId(++id);
super.addNode(node);
}
};
process.addNode(new StartNode());
process.addNode(new EndNode());
process.addNode(new ActionNode());
process.addNode(new Split());
process.addNode(new Join());
process.addNode(new MilestoneNode());
process.addNode(new RuleSetNode());
process.addNode(new SubProcessNode());
process.addNode(new WorkItemNode());
process.addNode(new TimerNode());
process.addNode(new HumanTaskNode());
process.addNode(new ForEachNode());
process.addNode(new CompositeContextNode());
process.addNode(new EventNode());
process.addNode(new FaultNode());
process.addNode(new StateNode());
process.addNode(new DynamicNode());
String xml = XmlRuleFlowProcessDumper.INSTANCE.dump(process, false);
if (xml == null) {
throw new IllegalArgumentException("Failed to persist empty nodes!");
}
SemanticModules modules = new SemanticModules();
modules.addSemanticModule(new ProcessSemanticModule());
XmlProcessReader reader = new XmlProcessReader(modules, getClass().getClassLoader());
List<Process> processes = reader.read(new StringReader(xml));
assertNotNull(processes);
process = (RuleFlowProcess) processes.get(0);
if (process == null) {
throw new IllegalArgumentException("Failed to reload process!");
}
assertEquals(17, process.getNodes().length);
String xml2 = XmlRuleFlowProcessDumper.INSTANCE.dump(process, false);
if (xml2 == null) {
throw new IllegalArgumentException("Failed to persist empty nodes!");
}
assertXMLEqual(xml, xml2);
// assertEquals(xml, xml2);
}
use of org.jbpm.workflow.core.node.WorkItemNode in project jbpm by kiegroup.
the class WorkItemNodeBuilder method build.
public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
super.build(process, processDescr, context, node);
WorkflowProcess wfProcess = (WorkflowProcess) process;
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("imports", wfProcess.getImports());
parameters.put("classloader", context.getConfiguration().getClassLoader());
for (DataAssociation dataAssociation : ((WorkItemNode) node).getInAssociations()) {
Transformation transformation = dataAssociation.getTransformation();
if (transformation != null) {
DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
}
List<Assignment> assignments = dataAssociation.getAssignments();
if (assignments != null) {
for (Assignment assignment : assignments) {
ProcessDialect dialect = ProcessDialectRegistry.getDialect(assignment.getDialect());
dialect.getAssignmentBuilder().build(context, assignment, dataAssociation.getSources().get(0), dataAssociation.getTarget(), ((WorkItemNode) node), true);
}
}
}
for (DataAssociation dataAssociation : ((WorkItemNode) node).getOutAssociations()) {
Transformation transformation = dataAssociation.getTransformation();
if (transformation != null) {
DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
}
List<Assignment> assignments = dataAssociation.getAssignments();
if (assignments != null) {
for (Assignment assignment : assignments) {
ProcessDialect dialect = ProcessDialectRegistry.getDialect(assignment.getDialect());
dialect.getAssignmentBuilder().build(context, assignment, dataAssociation.getSources().get(0), dataAssociation.getTarget(), ((WorkItemNode) node), false);
}
}
}
}
use of org.jbpm.workflow.core.node.WorkItemNode in project kie-wb-common by kiegroup.
the class AbstractBpmnProcessDataEventListener method onNodeAdded.
// ProcessDataEventListener methods -------------------------------------------------------------------------------------------
@Override
public void onNodeAdded(Node node) {
if (node instanceof RuleSetNode) {
RuleSetNode ruleSetNode = (RuleSetNode) node;
String ruleFlowGroup = ruleSetNode.getRuleFlowGroup();
if (ruleFlowGroup != null) {
addSharedReference(ruleFlowGroup, PartType.RULEFLOW_GROUP);
}
} else if (node instanceof WorkItemNode) {
String taskName = ((WorkItemNode) node).getWork().getName();
addSharedReference(taskName, PartType.TASK_NAME);
} else if (node instanceof SubProcessNode) {
SubProcessNode subProcess = (SubProcessNode) node;
String processName = subProcess.getProcessName();
if (!StringUtils.isEmpty(processName)) {
addResourceReference(processName, getProcessNameResourceType());
}
String processId = subProcess.getProcessId();
if (!StringUtils.isEmpty(processId)) {
addResourceReference(processId, getProcessIdResourceType());
}
}
}
use of org.jbpm.workflow.core.node.WorkItemNode in project jbpm by kiegroup.
the class WorkHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
WorkItemNode workItemNode = (WorkItemNode) parser.getParent();
final String name = attrs.getValue("name");
emptyAttributeCheck(localName, "name", name, parser);
Work work = new WorkImpl();
work.setName(name);
workItemNode.setWork(work);
return work;
}
use of org.jbpm.workflow.core.node.WorkItemNode in project jbpm by kiegroup.
the class WorkItemNodeHandler method handleNode.
public 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);
WorkItemNode workItemNode = (WorkItemNode) node;
final String waitForCompletion = element.getAttribute("waitForCompletion");
workItemNode.setWaitForCompletion(!"false".equals(waitForCompletion));
for (String eventType : workItemNode.getActionTypes()) {
handleAction(workItemNode, element, eventType);
}
}
Aggregations