use of org.jbpm.workflow.core.impl.WorkflowProcessImpl in project jbpm by kiegroup.
the class SwimlaneHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
WorkflowProcessImpl process = (WorkflowProcessImpl) parser.getParent();
final String name = attrs.getValue("name");
emptyAttributeCheck(localName, "name", name, parser);
SwimlaneContext swimlaneContext = (SwimlaneContext) process.getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE);
if (swimlaneContext != null) {
Swimlane swimlane = new Swimlane();
swimlane.setName(name);
swimlaneContext.addSwimlane(swimlane);
} else {
throw new SAXParseException("Could not find default swimlane context.", parser.getLocator());
}
return null;
}
use of org.jbpm.workflow.core.impl.WorkflowProcessImpl in project jbpm by kiegroup.
the class ProcessInstanceResolverStrategyTest method testAccept.
@Test
public void testAccept() {
KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
WorkflowProcessImpl process = new WorkflowProcessImpl();
RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
processInstance.setState(ProcessInstance.STATE_ACTIVE);
processInstance.setProcess(process);
processInstance.setKnowledgeRuntime((InternalKnowledgeRuntime) ksession);
ProcessInstanceResolverStrategy strategy = new ProcessInstanceResolverStrategy();
assertTrue(strategy.accept(processInstance));
Object object = new Object();
assertTrue(!strategy.accept(object));
}
use of org.jbpm.workflow.core.impl.WorkflowProcessImpl in project jbpm by kiegroup.
the class JavaReturnValueConstraintEvaluatorBuilderTest method testSimpleReturnValueConstraintEvaluator.
@Test
public void testSimpleReturnValueConstraintEvaluator() throws Exception {
final InternalKnowledgePackage pkg = new KnowledgePackageImpl("pkg1");
ProcessDescr processDescr = new ProcessDescr();
processDescr.setClassName("Process1");
processDescr.setName("Process1");
WorkflowProcessImpl process = new WorkflowProcessImpl();
process.setName("Process1");
process.setPackageName("pkg1");
ReturnValueDescr descr = new ReturnValueDescr();
descr.setText("return value;");
KnowledgeBuilderImpl pkgBuilder = new KnowledgeBuilderImpl(pkg);
DialectCompiletimeRegistry dialectRegistry = pkgBuilder.getPackageRegistry(pkg.getName()).getDialectCompiletimeRegistry();
JavaDialect javaDialect = (JavaDialect) dialectRegistry.getDialect("java");
ProcessBuildContext context = new ProcessBuildContext(pkgBuilder, pkg, process, processDescr, dialectRegistry, javaDialect);
pkgBuilder.addPackageFromDrl(new StringReader("package pkg1;\nglobal Boolean value;"));
ReturnValueConstraintEvaluator node = new ReturnValueConstraintEvaluator();
final JavaReturnValueEvaluatorBuilder builder = new JavaReturnValueEvaluatorBuilder();
builder.build(context, node, descr, null);
ProcessDialectRegistry.getDialect(JavaDialect.ID).addProcess(context);
javaDialect.compileAll();
assertEquals(0, javaDialect.getResults().size());
final InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addPackages(Arrays.asList(pkgBuilder.getPackages()));
final KieSession ksession = kbase.newKieSession();
ksession.setGlobal("value", true);
RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
processInstance.setKnowledgeRuntime((InternalKnowledgeRuntime) ksession);
SplitInstance splitInstance = new SplitInstance();
splitInstance.setProcessInstance(processInstance);
assertTrue(node.evaluate(splitInstance, null, null));
ksession.setGlobal("value", false);
assertFalse(node.evaluate(splitInstance, null, null));
}
use of org.jbpm.workflow.core.impl.WorkflowProcessImpl in project jbpm by kiegroup.
the class EndNodeInstanceTest method testEndNode.
@Test
public void testEndNode() {
KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
MockNode mockNode = new MockNode();
MockNodeInstanceFactory factory = new MockNodeInstanceFactory(new MockNodeInstance(mockNode));
NodeInstanceFactoryRegistry.getInstance(ksession.getEnvironment()).register(mockNode.getClass(), factory);
WorkflowProcessImpl process = new WorkflowProcessImpl();
Node endNode = new EndNode();
endNode.setId(1);
endNode.setName("end node");
mockNode.setId(2);
new ConnectionImpl(mockNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
process.addNode(mockNode);
process.addNode(endNode);
RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
processInstance.setState(ProcessInstance.STATE_ACTIVE);
processInstance.setProcess(process);
processInstance.setKnowledgeRuntime((InternalKnowledgeRuntime) ksession);
MockNodeInstance mockNodeInstance = (MockNodeInstance) processInstance.getNodeInstance(mockNode);
mockNodeInstance.triggerCompleted();
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
}
use of org.jbpm.workflow.core.impl.WorkflowProcessImpl in project jbpm by kiegroup.
the class FunctionImportHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
WorkflowProcessImpl process = (WorkflowProcessImpl) parser.getParent();
final String name = attrs.getValue("name");
emptyAttributeCheck(localName, "name", name, parser);
java.util.List<String> list = process.getFunctionImports();
if (list == null) {
list = new ArrayList<String>();
process.setFunctionImports(list);
}
list.add(name);
return null;
}
Aggregations