use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.
the class SingleSessionCommandServiceTest method getProcessTimer.
private List<KiePackage> getProcessTimer() {
RuleFlowProcess process = new RuleFlowProcess();
process.setId("org.drools.test.TestProcess");
process.setName("TestProcess");
process.setPackageName("org.drools.test");
StartNode start = new StartNode();
start.setId(1);
start.setName("Start");
process.addNode(start);
TimerNode timerNode = new TimerNode();
timerNode.setId(2);
timerNode.setName("Timer");
Timer timer = new Timer();
timer.setDelay("2000");
timerNode.setTimer(timer);
process.addNode(timerNode);
new ConnectionImpl(start, Node.CONNECTION_DEFAULT_TYPE, timerNode, Node.CONNECTION_DEFAULT_TYPE);
ActionNode actionNode = new ActionNode();
actionNode.setId(3);
actionNode.setName("Action");
DroolsConsequenceAction action = new DroolsConsequenceAction();
action.setDialect("java");
action.setConsequence("System.out.println(\"Executed action\");");
actionNode.setAction(action);
process.addNode(actionNode);
new ConnectionImpl(timerNode, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE);
EndNode end = new EndNode();
end.setId(6);
end.setName("End");
process.addNode(end);
new ConnectionImpl(actionNode, Node.CONNECTION_DEFAULT_TYPE, end, Node.CONNECTION_DEFAULT_TYPE);
KnowledgeBuilderImpl packageBuilder = new KnowledgeBuilderImpl();
ProcessBuilderImpl processBuilder = new ProcessBuilderImpl(packageBuilder);
processBuilder.buildProcess(process, null);
return Arrays.asList(packageBuilder.getPackages());
}
use of org.jbpm.ruleflow.core.RuleFlowProcess 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.ruleflow.core.RuleFlowProcess 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.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.
the class ProcessCreatorForHelp method newProcessWithOneSubProcess.
public static RuleFlowProcess newProcessWithOneSubProcess(String processId, String subProcessId) {
RuleFlowProcess process = new RuleFlowProcess();
process.setId(processId);
StartNode startNode = new StartNode();
startNode.setName("Start");
startNode.setId(1);
SubProcessNode subProcessNode = new SubProcessNode();
subProcessNode.setId(2);
subProcessNode.setProcessId(subProcessId);
subProcessNode.setName("subProcess");
EndNode endNode = new EndNode();
endNode.setName("EndNode");
endNode.setId(4);
connect(startNode, subProcessNode);
connect(subProcessNode, endNode);
process.addNode(startNode);
process.addNode(subProcessNode);
process.addNode(endNode);
return process;
}
use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.
the class ProcessCreatorForHelp method newProcessWithOneWork.
public static RuleFlowProcess newProcessWithOneWork(String processId, String workName) {
RuleFlowProcess process = new RuleFlowProcess();
process.setId(processId);
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(workName);
workItemNode.setWork(work);
EndNode endNode = new EndNode();
endNode.setName("EndNode");
endNode.setId(4);
connect(startNode, workItemNode);
connect(workItemNode, endNode);
process.addNode(startNode);
process.addNode(workItemNode);
process.addNode(endNode);
return process;
}
Aggregations