Example Overview Example: Integrating External Workflow

16-34 Oracle Fusion Middleware Developers Guide for Oracle Portal Figure 16–10 Specifying That All Users Require Approval for Their Items

5. Click OK.

16.8.3.3 Run Scripts Required for the CMEF Workflow Integration Example

Before you proceed to the next step, there are several tasks that you need to perform. These steps are as follows:

1. Log in to the SYS schema and run the following command:

GRANT EXECUTE ON owf_mgr.wf_engine to cmefsamples;

2. Log in to the portal schema and run provsyns.sql. When prompted for the

schemaprovider name enter owf_mgr.

3. Log in to the CMEFSAMPLES schema and run the following:

drop sequence WF_SEQ create sequence WF_SEQ increment by 1 start with 1 maxvalue 1000000000 minvalue 1 cache 20 grant select on wf_seq to owf_mgr; This creates the sequence required by workflow, and allows the OWF_MGR workflow schema SELECT privileges on the sequence.

4. Create the synonym WF_ENGINE to the workflow schema:

create synonym wf_engine for owf_mgr.wf_engine;

16.8.3.4 Create Subscriber and Check Procedures

You need to create a subscriber that listens to the WWSBR_EVENT_Q queue, waiting until a user adds an item that requires approval. The subscriber calls the WF_ CHECKURL workflow process to perform the item validation and to send the e-mail notification. Example 16–17 shows the WORKFLOW_APPROVAL subscriber code. Example 16–17 The WORKFLOW_APPROVAL Subscriber create or replace procedure workflow_approval is MIME_TYPE_TEXT constant varchar230 := textplain; agent_list dbms_aq.aq_agent_list_t; wait_time integer := 30; begin_time pls_integer; end_time pls_integer; agent_w_message aq_agent; dequeue_options dbms_aq.dequeue_options_t; message_properties dbms_aq.message_properties_t; Using the Content Management Event Framework 16-35 message_handle raw16; message portal.wwsbr_event; l_subscriber varchar230 := CMEF_WORKFLOW; l_queue varchar230 := PORTAL.WWSBR_EVENT_Q; l_mode binary_integer := dbms_aq.REMOVE; l_attribute_site_id number := 0; l_event varchar230; l_doc wwdoc_api.document_record; l_desc varchar24000; l_itemkey varchar2100; l_job_nr number; l_itemtype varchar2100 := WF; l_wf_process varchar2100 := WF_CHECKURL; l_is_indirect boolean := TRUE; l_portal_user_name varchar230 := portal; l_portal_password varchar230 := portal password; l_url varchar24000; := ; begin begin_time := dbms_utility.get_time; agent_list1 := aq_agentl_subscriber, l_queue, null; loop -- Wait for messages. dbms_aq.listen agent_list = agent_list, wait = wait_time, agent = agent_w_message ; if agent_w_message.name = l_subscriber then dequeue_options.wait := dbms_aq.NO_WAIT; dequeue_options.consumer_name := l_subscriber; dequeue_options.navigation := dbms_aq.FIRST_MESSAGE; dequeue_options.dequeue_mode := l_mode; dbms_aq.dequeue queue_name = l_queue, dequeue_options = dequeue_options, message_properties = message_properties, payload = message, msgid = message_handle ; -- If the event is an ITEM INSERT event and marked for later publication. if message.action = SUBMIT_ITEM_FOR_APPROVAL and message.object_class = ITEM and message.raw_event = INSERT and message.state = NOT_PUBLISHED then portal.wwctx_api.set_contextl_portal_user_name, l_portal_password; -- Get the URL property for the object. select url into l_url from portal.wwsbr_all_items where id = message.object_id and caid = message.object_site_id; -- Get the nextval of the workflow sequence for the itemkey. select wf_seq.nextval into l_job_nr from dual; l_itemkey := lpadto_charl_job_nr, 5, 0; -- Launch the workflow engine process and pass the paramters for -- the portal item to the workflow process. wf_engine.createprocessl_itemtype, l_itemkey, l_wf_process;