cancel
Showing results for 
Search instead for 
Did you mean: 

conditional flow expressions

valarmathi
Champ in-the-making
Champ in-the-making
Hi,

I have created conditional flow expressions example.

this is my xml file

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="uelExpressions" name="Expressions">
    <startEvent id="theStart" name="Start"></startEvent>
    <exclusiveGateway id="exclusiveGw" name="Exclusive Gateway" default="flow2"></exclusiveGateway>
    <userTask id="standardService" name="Standard Service"></userTask>
    <userTask id="premiumService" name="Premium Service"></userTask>
    <endEvent id="theEnd1" name="End"></endEvent>
    <endEvent id="theEnd2" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="theStart" targetRef="exclusiveGw"></sequenceFlow>
    <sequenceFlow id="flow3" name="${order.isPremiumOrder}" sourceRef="exclusiveGw" targetRef="premiumService">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${order.isPremiumOrder}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow2" name="${order.price&lt;=250}" sourceRef="exclusiveGw" targetRef="standardService">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${order.price <= 250}
]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow5" name="" sourceRef="standardService" targetRef="theEnd1"></sequenceFlow>
    <sequenceFlow id="flow6" name="" sourceRef="premiumService" targetRef="theEnd2"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_uelExpressions">
    <bpmndi:BPMNPlane bpmnElement="uelExpressions" id="BPMNPlane_uelExpressions">
      <bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart">
        <omgdc:Bounds height="35" width="35" x="90" y="160"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusiveGw" id="BPMNShape_exclusiveGw">
        <omgdc:Bounds height="40" width="40" x="210" y="157"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="standardService" id="BPMNShape_standardService">
        <omgdc:Bounds height="55" width="105" x="390" y="10"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="premiumService" id="BPMNShape_premiumService">
        <omgdc:Bounds height="55" width="105" x="400" y="260"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="theEnd1" id="BPMNShape_theEnd1">
        <omgdc:Bounds height="35" width="35" x="550" y="20"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="theEnd2" id="BPMNShape_theEnd2">
        <omgdc:Bounds height="35" width="35" x="560" y="270"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="125" y="177"></omgdi:waypoint>
        <omgdi:waypoint x="210" y="177"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="230" y="197"></omgdi:waypoint>
        <omgdi:waypoint x="230" y="287"></omgdi:waypoint>
        <omgdi:waypoint x="400" y="287"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42" width="100" x="-30" y="3"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="230" y="157"></omgdi:waypoint>
        <omgdi:waypoint x="230" y="37"></omgdi:waypoint>
        <omgdi:waypoint x="390" y="37"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="42" width="100" x="10" y="0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="495" y="37"></omgdi:waypoint>
        <omgdi:waypoint x="550" y="37"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="505" y="287"></omgdi:waypoint>
        <omgdi:waypoint x="560" y="287"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>


this is my java class

package org.activiti.examples.bpmn.expression;

import org.activiti.engine.impl.test.PluggableActivitiTestCase;
import org.activiti.engine.impl.util.CollectionUtil;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.Deployment;


/**
* @author Joram Barrez
*/
public class UelExpressionTest extends PluggableActivitiTestCase {

  @Deployment
  public void testValueAndMethodExpression() {
    // An order of price 150 is a standard order (goes through an UEL value expression)
    UelExpressionTestOrder order = new UelExpressionTestOrder(150);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("uelExpressions",
            CollectionUtil.singletonMap("order",  order));
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("Standard service", task.getName());
   
    // While an order of 300, gives us a premium service (goes through an UEL method expression)
    order = new UelExpressionTestOrder(300);
    processInstance = runtimeService.startProcessInstanceByKey("uelExpressions",
            CollectionUtil.singletonMap("order",  order));
    task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertEquals("Premium service", task.getName());
   
  }

}

I have export the java class and place it in the following locations,

C:\activiti-5.8\apps\apache-tomcat-6.0.32\webapps\activiti-explorer\WEB-INF\lib , C:\activiti-5.8\apps\apache-tomcat-6.0.32\webapps\activiti-rest\WEB-INF\lib ,
C:\activiti-5.8\apps\apache-tomcat-6.0.32\lib

While running the java class using juint ,i got the error like …

EXCEPTION: org.activiti.engine.ActivitiException: resource 'org/activiti/examples/bpmn/expression/UelExpressionTest.testValueAndMethodExpression.bpmn20.xml' not found
org.activiti.engine.ActivitiException: resource 'org/activiti/examples/bpmn/expression/UelExpressionTest.testValueAndMethodExpression.bpmn20.xml' not found
   at org.activiti.engine.impl.repository.DeploymentBuilderImpl.addClasspathResource(DeploymentBuilderImpl.java:59)
   at org.activiti.engine.impl.test.TestHelper.annotationDeploymentSetUp(TestHelper.java:95)
   at org.activiti.engine.impl.test.AbstractActivitiTestCase.runBare(AbstractActivitiTestCase.java:88)
   at junit.framework.TestResult$1.protect(TestResult.java:110)
   at junit.framework.TestResult.runProtected(TestResult.java:128)
   at junit.framework.TestResult.run(TestResult.java:113)
   at junit.framework.TestCase.run(TestCase.java:124)
   at junit.framework.TestSuite.runTest(TestSuite.java:232)
   at junit.framework.TestSuite.run(TestSuite.java:227)
   at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
   at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Oct 29, 2012 2:29:20 PM org.activiti.engine.impl.test.AbstractActivitiTestCase assertAndEnsureCleanDb
INFO: database was clean

But the xml file is there in the corresponding location.
Please help me.What i have missed.

Thanks,
Valarmathi P
11 REPLIES 11

valarmathi
Champ in-the-making
Champ in-the-making
Hello,

In java we declared a variable in the same class itself(if not using POJO classes means).
I asked activiti class ,in the activiti class itself i have declared the variables frm the same class.


Thanks
Valarmathi

frederikherema1
Star Contributor
Star Contributor
Can you provide a code sample? Can't really make up what you mean by your previous comment…