7 Replies Latest reply on Sep 26, 2007 4:52 AM by kukeltje

    Problem using expression language in a process definition (T

    sonicfab

      I'd like to use jBM's expression language so that a Timer can obtain its duedate parameter from the ContextInstance of the process. I've tried this :

      <process-definition
       xmlns="urn:jbpm.org:jpdl-3.0" name="com.bt.intfwk.businesslayer.jbpm.processes.timertest">
       <start-state name="start">
       <transition name="" to="TimerNode"></transition>
       </start-state>
       <node name="TimerNode">
       <timer name="testTimer"
       duedate="#{contextInstance.dueDate}" >
       <action class="com.bt.intfwk.testjbpm.TimedAction" />
       </timer>
       <transition name="" to="end1"></transition>
       </node>
       <end-state name="end1"></end-state>
      </process-definition>


      and I get an error message telling me that my XML is not valid. I've also tried without the quotes around
      #{contextInstance.dueDate}
      and it doesn't work either.

      Ideas please ?

        • 1. Re: Problem using expression language in a process definitio
          kukeltje

          correct... not all params can be EL. The duedate e.g. can't. File a jira issue for this....or better, look in the source of jbpm to see how to achieve this (it is realy easy)

          • 2. Re: Problem using expression language in a process definitio
            sonicfab

             

            "kukeltje" wrote:
            correct... not all params can be EL. The duedate e.g. can't. File a jira issue for this....or better, look in the source of jbpm to see how to achieve this (it is realy easy)


            I appreciate your answer, but also find it somewhat weird : if you know the answer, and if it is indeed real easy, why don't you post it here so that it is shared with everyone ? This forum is not a game.

            • 3. Re: Problem using expression language in a process definitio
              kukeltje

              Fabien, please..... do not start with these kinds of remarks..

              Easy meaning about 1 day work if you start from scratch (e.g. see start with how an attribute known to support this) For me it is about half a day's work since I've done it once before.

              ..... writing unittests, docs, implementing the code, etc...

              • 4. Re: Problem using expression language in a process definitio
                sonicfab

                Ok I've looked into it a bit, and it seems that the quickest way to achieve this, without modifying the jPDL schema, is to override the read(Element actionElement, JpdlXmlReader jpdlReader) method of class org.jbpm.scheduler.def.CreateTimerAction. The overriden method can then call the org.jbpm.jpdl.el.impl.ExpressionEvaluatorImpl class.
                Do you agree with this ?

                • 5. Re: Problem using expression language in a process definitio
                  kukeltje

                  Seems about correct. But why is modification of the schema needed? Maybe I miss something (have no access to the code now, will look into that tonight).

                  I saw you made a jira entry thanks http://jira.jboss.com/jira/browse/JBPM-1060

                  • 6. Re: Problem using expression language in a process definitio
                    sonicfab

                    Why do I talk about modifying the schema ? Well, I had a look at the jpdl-3.2 schema, and apparently all the objects that can handle EL have a "expression" attribute, whereas objects that can't don't seem to have one.
                    For example, the action element :

                    <xs:element name="action">
                     <xs:complexType mixed="true">
                     <xs:sequence>
                     <xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded" />
                     </xs:sequence>
                     <xs:attribute name="class" type="xs:string" />
                     <xs:attribute name="config-type" default="field">
                     <xs:simpleType>
                     <xs:restriction base="xs:string">
                     <xs:enumeration value="field"/>
                     <xs:enumeration value="bean"/>
                     <xs:enumeration value="constructor"/>
                     <xs:enumeration value="configuration-property"/>
                     </xs:restriction>
                     </xs:simpleType>
                     </xs:attribute>
                     <xs:attribute name="name" type="xs:string" />
                     <xs:attribute name="ref-name" type="xs:string" />
                     <xs:attribute name="accept-propagated-events" type="booleanType" default="true" />
                     <xs:attribute name="expression" type="xs:string" />
                     <xs:attribute name="async" type="xs:string" />
                     </xs:complexType>
                     </xs:element>


                    Whereas for example for the timer element :
                    <xs:element name="timer">
                     <xs:complexType>
                     <xs:choice minOccurs="0">
                     <xs:element ref="action"/>
                     <xs:element ref="script"/>
                     </xs:choice>
                     <xs:attribute name="duedate" type="xs:string" use="required" />
                     <xs:attribute name="name" type="xs:string" />
                     <xs:attribute name="repeat" type="xs:string" />
                     <xs:attribute name="transition" type="xs:string" />
                     </xs:complexType>
                     </xs:element>


                    • 7. Re: Problem using expression language in a process definitio
                      kukeltje

                      ahh... no that is not needed. The name attribute of a subprocess can also be an EL. The expression attribute is only used in situations where the 'term' expression is appropriate.

                      In the same way you could make the repeat attribute accept an EL..... but remember... test test test ;-)