4 Replies Latest reply on Aug 5, 2011 1:04 PM by garys

    How to use a POJO as Gateway condition

    garys

      I have a POJO as a process variable, "vars". In a diverging Gateway I want to use one of its fields as a condition. This is what I've tried and it seems to work but it's too much Java in a BPMN file. Is this the right way to do it?

       

          <sequenceFlow id="_12-_13" sourceRef="_12" targetRef="_13" name="valid score" tns:priority="1" >

            <conditionExpression xsi:type="tFormalExpression" >

            org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

            x.xx.xxx.workflow.dto.PIvars vars = process.getVariable("vars");

            return vars.isValidScore() == true;</conditionExpression>

          </sequenceFlow>

        • 1. Re: How to use a POJO as Gateway condition
          calca

          I think you can use directly

          return vars.isValidScore() == true;

           

          something like:

               <sequenceFlow id="_5-_6" sourceRef="_5" targetRef="_6" name="EXCEEDS" >

                <conditionExpression xs:type="tFormalExpression" language="http://www.java.com/java" >return (exceeds == true);</conditionExpression>

              </sequenceFlow>

           

          Demian

          • 2. Re: How to use a POJO as Gateway condition
            garys

            The example projects only show drools, xPath, and cron as language attribute in conditionExpressions. I tried the above and it didn't work. IIRC it failed in KnowledgeBuilder.

             

            Then I tried

            <conditionExpression xsi:type="tFormalExpression" language="http://www.jboss.org/drools/rule">PIvars(applicationReady == true);</conditionExpression>

            The Gateway ignored it.

             

            This ugly one does work but if there is a clean way that works I'd like to know.

            <conditionExpression xsi:type="tFormalExpression">

                  org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

                  edu.berkeley.ouae.workflow.dto.FreshmanReadPIvars vars = process.getVariable("vars");

                  return vars.isApplicationReady() == false;</conditionExpression>

            • 3. Re: How to use a POJO as Gateway condition
              swiderski.maciej

              In my opinion that should work

               

              <conditionExpression xsi:type="tFormalExpression">return (vars.isApplicationReady() == false);</conditionExpression>
              

               

              just make sure that you defined that (vars) variable as property in the process.

              1 of 1 people found this helpful
              • 4. Re: How to use a POJO as Gateway condition
                garys
                Thanks Maciej,

                 

                That works when I add a cast

                <conditionExpression xsi:type="tFormalExpression">return(((PIvars)vars).isApplicationReady() == true);</conditionExpression>