[Home] [Help]
PACKAGE BODY: APPS.WF_EVENT_PING_PKG
Source
1 package body WF_EVENT_PING_PKG as
2 /* $Header: WFEVPNGB.pls 120.1 2005/07/02 03:14:33 appldev ship $ */
3 ------------------------------------------------------------------------------
4 /*
5 ** launch_processes - Loops through all external agents
6 **
7 **
8 **
9 */
10 procedure LAUNCH_PROCESSES (
11 ITEMTYPE in varchar2,
12 ITEMKEY in varchar2,
13 ACTID in number,
14 FUNCMODE in varchar2,
15 RESULTOUT out nocopy varchar2
16 ) is
17 ------------------------------------------------------------------------------
18
19 CURSOR c_external_in_agents IS
20 SELECT
21 wfa.name AGENT,
22 wfs.name SYSTEM
23 FROM
24 wf_systems wfs,
25 wf_agents wfa
26 WHERE
27 wfa.name <> 'WF_ERROR'
28 and wfa.status = 'ENABLED'
29 and wfa.direction = 'IN'
30 and wfa.system_guid = wfs.guid
31 and upper(wfa.queue_handler) = 'WF_EVENT_QH';
32
33 l_eventname varchar2(100);
34 l_eventkey varchar2(240);
35 l_itemkey varchar2(100);
36 l_event_t wf_event_t;
37 l_msg varchar2(32000);
38 l_clob clob;
39
40 begin
41
42 if (funcmode = 'RUN') then
43
44 l_eventname := wf_engine.GetActivityAttrText(
45 itemtype => itemtype,
46 itemkey => itemkey,
47 actid => actid,
48 aname => 'EVNTNAME');
49
50 for x in c_external_in_agents loop
51 --
52 -- For every agent launch detail process
53 --
54 l_eventkey := x.agent||'@'||x.system||'@'||itemkey;
55 l_itemkey := l_eventkey;
56
57 wf_engine.CreateProcess(
58 itemtype => itemtype,
59 itemkey => l_itemkey,
60 process => 'WFDTLPNG');
61
62 wf_engine.SetItemAttrText(
63 itemtype => itemtype,
64 itemkey => l_itemkey,
65 aname => 'EVNTNAME',
66 avalue => l_eventname);
67
68 wf_engine.SetItemAttrText(
69 itemtype => itemtype,
70 itemkey => l_itemkey,
71 aname => 'EVNTKEY',
72 avalue => l_eventkey);
73
74 wf_engine.SetItemAttrText(
75 itemtype => itemtype,
76 itemkey => l_itemkey,
77 aname => 'TOAGENT',
78 avalue => x.agent||'@'||x.system);
79
80 -- Initialise the wf_event_t
81 wf_event_t.initialize(l_event_t);
82 l_event_t.setcorrelationid(l_itemkey);
83 l_msg := '<PING>Test Ping</PING>';
84 dbms_lob.createtemporary(l_clob, FALSE, DBMS_LOB.CALL);
85 dbms_lob.write(l_clob, length(l_msg), 1 , l_msg);
86 l_event_t.SetEventData(l_clob);
87
88 wf_engine.SetItemAttrEvent(
89 itemtype => itemtype,
90 itemkey => l_itemkey,
91 name => 'EVNTMSG',
92 event => l_event_t);
93
94 wf_engine.SetItemParent(
95 itemtype => itemtype,
96 itemkey => l_itemkey,
97 parent_itemtype => itemtype,
98 parent_itemkey => itemkey,
99 parent_context => null);
100
101 wf_engine.StartProcess(
102 itemtype => itemtype,
103 itemkey => l_itemkey);
104
105 end loop;
106
107 resultout := wf_engine.eng_completed||':'||wf_engine.eng_null;
108
109 return;
110
111 elsif (funcmode = 'CANCEL') then
112
113 null;
114
115 end if;
116
117 exception
118 when others then
119 WF_CORE.CONTEXT('WF_EVENT_PING_PKG', 'LAUNCH_PROCESSES', ITEMTYPE, ITEMKEY, to_char(ACTID), FUNCMODE);
120 raise;
121 end LAUNCH_PROCESSES;
122 ------------------------------------------------------------------------------
123 function ACKNOWLEDGE (
124 P_SUBSCRIPTION_GUID in raw,
125 P_EVENT in out nocopy wf_event_t
126 ) return varchar2 is
127 ------------------------------------------------------------------------------
128 l_fromagent wf_agent_t;
129 l_result varchar2(100);
130 l_returnagent varchar2(100);
131
132 CURSOR c_return_agent (p_name VARCHAR2) IS
133 SELECT wfa.name AGENT
134 FROM
135 wf_systems wfs,
136 wf_agents wfa,
137 wf_resources res
138 WHERE
139 res.name = 'WF_SYSTEM_GUID'
140 and res.language = userenv('LANG')
141 and wfa.system_guid = res.text
142 and wfs.name = p_name
143 and wfa.name <> 'WF_ERROR'
144 and wfa.status = 'ENABLED'
145 and wfa.direction = 'IN'
146 and upper(wfa.queue_handler) = 'WF_EVENT_QH';
147
148 begin
149
150 l_fromagent := wf_agent_t (NULL, NULL);
151
152 /*
153 ** Get the Return To Agent
154 */
155 open c_return_agent (p_event.from_agent.system);
156 fetch c_return_agent into l_returnagent;
157 close c_return_agent;
158
159 /*
160 ** Null out From Agent, repackage up the event and use wf_event.send
161 **
162 */
163 if (wf_log_pkg.level_procedure >= fnd_log.g_current_runtime_level) then
164 wf_log_pkg.string(wf_log_pkg.level_procedure,
165 'wf.plsqlWF_EVENT_PING_PKG.ACKNOWLEDGE.Begin',
166 ' Started');
167 end if;
168
169 p_event.to_agent.name := l_returnagent;
170 p_event.to_agent.system := p_event.from_agent.system;
171
172 p_event.SetFromAgent(l_FromAgent);
173
174 if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
175 wf_log_pkg.string(wf_log_pkg.level_statement,
176 'wf.plsqlWF_EVENT_PING_PKG.ACKNOWLEDGE.ToAgent',
177 'To Agent:'||p_event.to_agent.name);
178 wf_log_pkg.string(wf_log_pkg.level_statement,
179 'wf.plsqlWF_EVENT_PING_PKG.ACKNOWLEDGE.ToSystem',
180 'To System:'||p_event.to_agent.system);
181 wf_log_pkg.string(wf_log_pkg.level_statement,
182 'wf.plsqlWF_EVENT_PING_PKG.ACKNOWLEDGE.FromAgent',
183 'From Agent:'||p_event.from_agent.name);
184 wf_log_pkg.string(wf_log_pkg.level_statement,
185 'wf.plsqlWF_EVENT_PING_PKG.ACKNOWLEDGE.FromSystem',
186 'From System:'||p_event.from_agent.system);
187 end if;
188
189 p_event.SetEventName('oracle.apps.wf.event.test.ack');
190
191 if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
192 wf_log_pkg.string(wf_log_pkg.level_statement,
193 'wf.plsqlWF_EVENT_PING_PKG.ACKNOWLEDGE.Send',
194 'Sending Event');
195 end if;
196
197 wf_event.send(
198 p_event => p_event);
199
200 if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
201 wf_log_pkg.string(wf_log_pkg.level_statement,
202 'wf.plsqlWF_EVENT_PING_PKG.ACKNOWLEDGE.Sent',
203 ' Sent');
204 end if;
205
206 l_result := wf_rule.default_rule(p_subscription_guid, p_event);
207
208 return(l_result);
209
210 exception
211 when others then
212 WF_CORE.CONTEXT('WF_EVENT_PING_PKG','ACKNOWLEDGE',p_event.event_name,p_event.event_key, p_event.correlation_id);
213 wf_event.setErrorInfo(p_event,'ERROR');
214 return('ERROR');
215 end;
216
217 end WF_EVENT_PING_PKG;