Search in sources :

Example 1 with ActionNode

use of org.jbpm.workflow.core.node.ActionNode in project jbpm by kiegroup.

the class ActionNodeHandler 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);
    ActionNode actionNode = (ActionNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    if (xmlNode instanceof Element) {
        Element actionXml = (Element) xmlNode;
        DroolsAction action = extractAction(actionXml);
        actionNode.setAction(action);
    }
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) Element(org.w3c.dom.Element) ActionNode(org.jbpm.workflow.core.node.ActionNode)

Example 2 with ActionNode

use of org.jbpm.workflow.core.node.ActionNode in project jbpm by kiegroup.

the class ActionNodeHandler method writeNode.

public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
    ActionNode actionNode = (ActionNode) node;
    writeNode("actionNode", actionNode, xmlDump, includeMeta);
    DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
    if (action != null || (includeMeta && containsMetaData(actionNode))) {
        xmlDump.append(">" + EOL);
        if (action != null) {
            writeAction(action, xmlDump);
        }
        if (includeMeta) {
            writeMetaData(actionNode, xmlDump);
        }
        endNode("actionNode", xmlDump);
    } else {
        endNode(xmlDump);
    }
}
Also used : DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ActionNode(org.jbpm.workflow.core.node.ActionNode)

Example 3 with ActionNode

use of org.jbpm.workflow.core.node.ActionNode in project jbpm by kiegroup.

the class ProcessNodeInstanceFactoryTest method testDefaultEntries.

@Test
public void testDefaultEntries() throws Exception {
    Node node = new ActionNode();
    assertEquals(CreateNewNodeFactory.class, NodeInstanceFactoryRegistry.getInstance(null).getProcessNodeInstanceFactory(node).getClass());
}
Also used : ActionNode(org.jbpm.workflow.core.node.ActionNode) Node(org.jbpm.workflow.core.Node) ActionNode(org.jbpm.workflow.core.node.ActionNode) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 4 with ActionNode

use of org.jbpm.workflow.core.node.ActionNode 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());
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) StartNode(org.jbpm.workflow.core.node.StartNode) Timer(org.jbpm.process.core.timer.Timer) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) EndNode(org.jbpm.workflow.core.node.EndNode) KnowledgeBuilderImpl(org.drools.compiler.builder.impl.KnowledgeBuilderImpl) ActionNode(org.jbpm.workflow.core.node.ActionNode) ConnectionImpl(org.jbpm.workflow.core.impl.ConnectionImpl) TimerNode(org.jbpm.workflow.core.node.TimerNode) ProcessBuilderImpl(org.jbpm.compiler.ProcessBuilderImpl)

Example 5 with ActionNode

use of org.jbpm.workflow.core.node.ActionNode 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;
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) StartNode(org.jbpm.workflow.core.node.StartNode) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DroolsAction(org.jbpm.workflow.core.DroolsAction) Action(org.jbpm.process.instance.impl.Action) Variable(org.jbpm.process.core.context.variable.Variable) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ArrayList(java.util.ArrayList) ActionNode(org.jbpm.workflow.core.node.ActionNode) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) KnowledgeBaseImpl(org.drools.core.impl.KnowledgeBaseImpl) ProcessContext(org.kie.api.runtime.process.ProcessContext) NamingException(javax.naming.NamingException) HeuristicRollbackException(javax.transaction.HeuristicRollbackException) HeuristicMixedException(javax.transaction.HeuristicMixedException) RollbackException(javax.transaction.RollbackException) NotSupportedException(javax.transaction.NotSupportedException) SystemException(javax.transaction.SystemException) MyVariableExtendingSerializable(org.jbpm.persistence.session.objects.MyVariableExtendingSerializable) EndNode(org.jbpm.workflow.core.node.EndNode) KieBase(org.kie.api.KieBase) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Work(org.jbpm.process.core.Work) WorkImpl(org.jbpm.process.core.impl.WorkImpl)

Aggregations

ActionNode (org.jbpm.workflow.core.node.ActionNode)48 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)41 EndNode (org.jbpm.workflow.core.node.EndNode)29 StartNode (org.jbpm.workflow.core.node.StartNode)28 ArrayList (java.util.ArrayList)25 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)25 DroolsAction (org.jbpm.workflow.core.DroolsAction)24 Action (org.jbpm.process.instance.impl.Action)21 Test (org.junit.Test)20 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)18 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)18 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)18 KieSession (org.kie.api.runtime.KieSession)17 ProcessContext (org.kie.api.runtime.process.ProcessContext)17 EventNode (org.jbpm.workflow.core.node.EventNode)14 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)14 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)12 Variable (org.jbpm.process.core.context.variable.Variable)11 TestProcessEventListener (org.jbpm.process.test.TestProcessEventListener)9 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)8