Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

Extract Human Task Event payload detail in SOA Mediator

$
0
0

Oracle SOA/BPM Human Task provides a very powerful feature to generate Business Event upon a task assignment or completion. The associated Business Event will then be sent to the Oracle Event Delivery Network and it can be captured by a Mediator component, which in turn executes others services or processes, like creating a Microsoft Exchange Task with Reminder as nicely described from this blog entry.


When the information that you need from the Business Event is only related to the Task metadata (taskid, assignee, taskURL…) then the configuration is pretty straight forward as it is possible to extract each desired element easily from the XSL mapping tools. However, if you need to extract a specific ‘value’ from the Task payloads, the picture suddenly becomes more complicated as the ‘payload’ element in the Business Event has a “anyXML” type and it is not possible to “browse” the payload detail, hence mapping them out easily from the XSL Mapping tool in Jdeveloper for further processing.


To address to the problem there are 2 options: 



  1. (Easy but Restrictive) Map the specific values to be catch using the Human Task Mapped Attributes (or directly in the systemMessageAttributes in the execData). When doing so those values can not only be used for queries from BPM Workspace, and they will be mapped as the Task metadata so you can easily link them up during the XSL transformation. Nevertheless, every time you want to extract additional values, the Human Task has to be modified and the associated process needs to be redeployed. It is a valid option if you know exactly what you need upfront.

  2. (Relatively difficult but flexible) Fully utilize XSL Transformation capability to extract the “hidden” values from the payload element. This option requires more XML/XSL knowledge and not necessarily easy to comprehend. However it provides much more flexibility and it can have a completely independent design lifecycle from the original business process. This is the option we will explore in this post. If you want to get before hand the source code of the example below, you can download from here.




    First of all, consider the following BPM Process with a very simple Human Task taking 2 Data arguments defined by the Business Object FirstBO and SecondBO. Please note a third Business Object ThirdBO is encapsulated within SecondBO.






    Now let’s enable the Human Task to generate a Business Event upon the task assignment. To do this, open the Human Task, go to Event and check the box OnAssigned (Please note the other available option but there are not key in our current demonstration)



    From the Business Process perspective we are all set. Now let’s consider the following SOA Composite Application which contains a Mediator to capture the associated business event and an File Adaptor to extract write data into a file.



    Once we link the Mediator to the File Adaptor, we can then generate a XSL stylesheet to transform the Human Task Event into service call to write data into a file. 



    Now the challenge is to extract the Payload information within the stylesheet. This can be done via the XSL source mode with 3 major steps:



    1. Add all the namespace of the objects within the payload. Those namespaces can be retrieved either directly from the BO definition or the Human Task configuration page

    2.       xmlns:p1="http://xmlns.oracle.com/bpm/bpmobject/Data/FirstBO"
            xmlns:p2="http://xmlns.oracle.com/bpm/bpmobject/Data/SecondBO"
            xmlns:p3="http://xmlns.oracle.com/bpm/bpmobject/Data/SubData/ThirdBO"

       


    3. Create XSL variables, pointing to a specific argument of the Human Task with the Payload, using the namespaces defined above. In our case we have 2 arguments so we create 2 variables

    4. <xsl:variable name="">p1:firstPayload
      select="/tns:taskAssignedMessage/task:task/task:payload/p1:FirstBO"/>
      <xsl:variable name="p2:secondPayload"
      select="/tns:taskAssignedMessage/task:task/task:payload/p2:SecondBO"/>

    5. Finally, you can now manually extract each desired value from the XSL variable by using the XPath expression

    6.       
            <imp1:FirstBO.one>
              <xsl:value-of select="$p1:firstPayload/p1:one"/>
            </imp1:FirstBO.one>
            <imp1:FirstBO.two>
              <xsl:value-of select="$p1:firstPayload/p1:two"/>
            </imp1:FirstBO.two>
            <imp1:FirstBO.three>
              <xsl:value-of select="$p1:firstPayload/p1:three"/>
            </imp1:FirstBO.three>
            <imp1:SecondBO.one>
              <xsl:value-of select="$p2:secondPayload/p2:one"/>
            </imp1:SecondBO.one>
            <imp1:SecondBO.two>
              <xsl:value-of select="$p2:secondPayload/p2:two"/>
            </imp1:SecondBO.two>
            <imp1:SecondBO.three.ThirdBO.one>
              <xsl:value-of select="$p2:secondPayload/p2:three/p3:one"/>
            </imp1:SecondBO.three.ThirdBO.one>
            <imp1:SecondBO.three.ThirdBO.two>
              <xsl:value-of select="$p2:secondPayload/p2:three/p3:two"/>
            </imp1:SecondBO.three.ThirdBO.two>


    Voilà ! Hope this entry is useful to you.


    Viewing all articles
    Browse latest Browse all 19780

    Trending Articles



    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>