4 Replies Latest reply on Aug 18, 2004 11:03 AM by 416900

    OAI and Workflow - Setting Attributes to use in Notifications

    416900
      Does anyone know how I go about getting at attributes in a message that goes through the Workflow Adapter?

      What I am trying to do is to create a notification, which is more meaningful by adding some of the details I've passed through in the PARAMETER_LIST attributes of the Workflow message.

      Any ideas?
      Ian
        • 1. Re: OAI and Workflow - Setting Attributes to use in Notifications
          KavithaSrinivasan
          Hi Ian:

          I believe all the data trasmitted from OAI is in the "WF_EVENT_T" object.
          You should be able to lookup the Workflow API Reference Guide to figure how to get a handle on the attributes for the object- seems like you need the method getParameterList (PLSQL and Java versions of the API are available).

          I will be sure to post any code I find to do this in some time.

          Hope this helps.

          Regards,
          Kavitha Srinivasan

          Product Manager, AS10G Integration

          • 2. Re: OAI and Workflow - Setting Attributes to use in Notifications
            KavithaSrinivasan
            Hi Ian:

            As promised, I managed to find a wf process that gets the details from the wf_event_t object, uses the canned XMLGetTagValue wf function to get a handle on one of the tags in the xml data and sends a notification (email msg) with the data.

            The wf flow is:
            1. Subscribe to an event (from IC hub)
            2. wf function to parse wf_event_t
            3. invoke XMLGetTagValue function to get handle on a tag in the xml data
            4. send notification with the tag value got in 3 above
            5. publish back to IC hub

            The code here below is for step2. Note that this is a sample- you can extend this to get a handle on the parameter_list easily.

            procedure setoaimsg (
            itemtype IN VARCHAR2,
            itemkey IN VARCHAR2,
            actid      IN VARCHAR2,
            funcmode IN VARCHAR2,
            resultout IN OUT VARCHAR2)

            is
            a_po CLOB;
            a_postr VARCHAR2(4000);
            pos INTEGER := 2147483647;
            buf VARCHAR2(4000);
            v_inbound_event WF_EVENT_T;


            begin
            --
            -- RUN mode - normal process execution
            --
            if ( funcmode = 'RUN' ) then

            v_inbound_event := WF_ENGINE.GetItemAttrEvent ( itemtype => itemtype
            , itemkey => itemkey
                                                                             , name => 'OAI_MESSAGE' );
            --, name => 'oai.gso1.createmp.oai_v1.subscribe.oai_v1' );
                                                                        

                 a_po := v_inbound_event.GetEventData();
                 buf := DBMS_LOB.SUBSTR(a_po, 32767, pos);

                 my optional code
                 insert into ktemp (poall, poclob) values (buf, a_po);
                 commit;

            resultout:= 'COMPLETE:';
            return;

            end if; -- end of run mode

            --
            -- CANCEL mode
            --

            if (funcmode = 'CANCEL') then

            -- no result needed
            resultout := 'COMPLETE';
            return;
            end if;

            --
            -- Other execution modes.
            --
            resultout := '';
            return;

            EXCEPTION WHEN OTHERS THEN
            wf_core.context('PITNEY_WF1','setoaimsg',ItemType,ItemKey);
            raise;
            end setoaimsg;
            ======================================
            COUPLE OF SUGGESTIONS :
            1. If you want the whole workflow process and supporting code, feel free to email me at kavitha.srinivasan@oracle.com
            2. What are your business and technical needs? May I suggest using Oracle's BPEL server? The advantages are plenty including easily integrable interfaces, prebuilt notification functions etc.
            Pl., ping me if you need more information.

            Regards,
            Kavitha

            Product Manager, AS 10g Integration

            • 3. Re: OAI and Workflow - Setting Attributes to use in Notifications
              416900
              Kavitha,

              Thanks for a pointer in the right direction. I'll have a go at it soon.

              The reason that I'm looking into this is to add another weapon to the arsenal of being able to track, report and control messages going through our hub.

              We may not even choose to use the Workflow Adapter in anger when we go live, but getting to know and love all its capabilities is worthwhile.

              I'll report back to the forum any helpful tips I get out of trying to do this.

              Cheers, Ian
              • 4. Re: OAI and Workflow - Setting Attributes to use in Notifications
                416900
                Kavitha,

                I've managed to do it, but using a simpler method (I think).

                In iStudio
                My Common View contains the attributes as follows:-
                EMPLOYEE_NUMBER (String)
                START_DATE (Date)
                LAST_NAME (String) and
                FIRST_NAME (String)

                My subscribing Workflow Event maps these Common View values into the PARAMETER_LIST array in the Workflow message. The mappings are as follows:-
                PARAMETER_LIST[v1].NAME=SetConstant (EMPLOYEE_NUMBER, "EMPLOYEE_NUMBER")
                PARAMETER_LIST[v1].VALUE=CopyFields (EMPLOYEE_NUMBER)
                PARAMETER_LIST[v2].NAME=SetConstant (START_DATE, "START_DATE")
                PARAMETER_LIST[v2].VALUE=CopyFields (START_DATE)
                PARAMETER_LIST[v3].NAME=SetConstant (LAST_NAME, "LAST_NAME")
                PARAMETER_LIST[v3].VALUE=CopyFields (LAST_NAME)
                PARAMETER_LIST[v4].NAME=SetConstant (FIRST_NAME, "FIRST_NAME")
                PARAMETER_LIST[v4].VALUE=CopyFields (FIRST_NAME)

                I also created the publishing Workflow Event. To get the values out of the PARAMETER_LIST array, I simply used the 'TrueConditionalCopy' transformation. For example,
                EMPLOYEE_NUMBER=TrueConditionalCopy (PARAMETER_LIST[v1].NAME, PARAMETER_LIST[v1].VALUE, "EMPLOYEE_NUMBER")

                In Workflow Builder
                I created 4 additional ATTRIBUTES in the Workflow:-
                EMPLOYEE_NUMBER_ATT (Type - Text)
                START_DATE_ATT (Type - Text)
                LAST_NAME_ATT (Type - Text) and
                FIRST_NAME_ATT (Type - Text)

                I then created my MESSAGE (Called 'Approve Update Employee'). I added 4 new MESSAGE ATTRIBUTES to this message:-
                EMPLOYEE_NUMBER (Type - Text, Default Type - Item Attribute, Value - EMPLOYEE_NUMBER_ATT)
                START_DATE (Type - Text, Default Type - Item Attribute, Value - START_DATE_ATT)
                LAST_NAME (Type - Text, Default Type - Item Attribute, Value - LAST_NAME_ATT)
                FIRST_NAME (Type - Text, Default Type - Item Attribute, Value - FIRST_NAME_ATT)

                In the Message Body I used the '&EMPLOYEE_NUMBER' notation to bring back the values into the message when the Workflow runs. For example, "This message has been created to tell you that Employee &EMPLOYEE_NUMBER has changed some details. Details are First Name is &FIRST_NAME, Last Name is &LAST_NAME and their start date is &START_DATE. Please Approve or Reject this change by using the buttons below."


                In the Workflow Diagram
                After the START node (Subscribe Maintain_Employees.Update_Employees) I added a series (4 in all) of "Get Event Property" Standard Workflow functions (GETEVENTPROPERTY) in order to find out the values from my parameter list.

                As an example, here is the one I did to get the Employee Number.

                In the 'Node Attributes' tag (when you double-click on the "Get Event Property") set the values as follows:-
                Name = Event, Type = Item Attribute, Value = OAI Message
                Name = Property, Type = Constant, Value = Event Parameter
                Name = Event Parameter, Type = Constant, Value = EMPLOYEE_NUMBER
                Name = Item Attribute, Type = Constant, Value = EMPLOYEE_NUMBER_ATT

                (Note that the 'Event Parameter' is the name you set it to when you did the SetConstant mapping i.e. EMPLOYEE_NUMBER. The 'Item Attribute' is the target ATTRIBUTE that the result of calling the GETEVENTPROPERTY will be put.)

                I finished off the Workflow by creating a NOTIFICATION called 'Update Employee Notification' which uses the 'Approve Update Employee' message, and added the Result Type of 'Approval'.

                If the message is APPROVED, then the workflow calls the Publish Event (END node type), if REJECTED then the Workflow goes to an END node (and not processed any further).

                My Workflow looks like this.

                START (Subscribe Maintain_Employees.Update_Employees)
                \/
                GETEVENTPROPERTY (to get EMPLOYEE_NUMBER_ATT value)
                \/
                GETEVENTPROPERTY (to get START_DATE_ATT value)
                \/
                GETEVENTPROPERTY (to get LAST_NAME_ATT value)
                \/
                GETEVENTPROPERTY (to get FIRST_NAME_ATT value)
                \/
                Update Employee Notification --> REJECTED --> END
                \/
                APPROVED
                \/
                END (Publish Maintain_Employees.Update_Employee)

                I'm not sure whether this is a good approach or not. The biggest upside is that I didn't have to do any additional coding. I only used standard OAI and Workflow functionality.

                Thanks again for your help.
                Ian