[Home] [Help]
PACKAGE BODY: APPS.WF_AGENT_GROUPS_PKG
Source
1 package body WF_AGENT_GROUPS_PKG as
2 /* $Header: WFEVAGPB.pls 120.3 2005/11/10 01:40:49 mputhiya ship $ */
3 m_table_name varchar2(255) := 'WF_AGENT_GROUPS';
4 m_package_version varchar2(30) := '1.0';
5 -----------------------------------------------------------------------------
6 procedure INSERT_ROW (
7 X_ROWID in out nocopy varchar2,
8 X_GROUP_GUID in raw,
9 X_MEMBER_GUID in raw
10 ) is
11 cursor C is select rowid
12 from wf_agent_groups
13 where group_guid = X_GROUP_GUID
14 and member_guid = X_MEMBER_GUID;
15 begin
16 insert into wf_agent_groups (
17 group_guid,
18 member_guid
19 ) values (
20 X_GROUP_GUID,
21 X_MEMBER_GUID
22 );
23
24 open c;
25 fetch c into X_ROWID;
26 if (c%notfound) then
27 close c;
28 raise no_data_found;
29 else
30 wf_event.raise('oracle.apps.wf.agent.group.create',x_group_guid||'/'||x_member_guid);
31 end if;
32 close c;
33
34 exception
35 when others then
36 wf_core.context('Wf_Agent_Groups_Pkg', 'Insert_Row', x_group_guid, x_member_guid);
37 raise;
38
39 end INSERT_ROW;
40 -----------------------------------------------------------------------------
41 procedure UPDATE_ROW (
42 X_GROUP_GUID in raw,
43 X_MEMBER_GUID in raw
44 ) is
45 begin
46 update wf_agent_groups set
47 group_guid = X_GROUP_GUID,
48 member_guid = X_MEMBER_GUID
49 where group_guid = X_GROUP_GUID
50 and member_guid = X_MEMBER_GUID;
51
52 if (sql%notfound) then
53 raise no_data_found;
54 else
55 wf_event.raise('oracle.apps.wf.agent.group.update',x_group_guid||'/'||x_member_guid);
56 end if;
57
58 exception
59 when others then
60 wf_core.context('Wf_Agent_Groups_Pkg', 'Update_Row', x_group_guid,
61 x_member_guid);
62 raise;
63 end UPDATE_ROW;
64 -----------------------------------------------------------------------------
65 procedure LOAD_ROW (
66 X_GROUP_GUID in raw,
67 X_MEMBER_GUID in raw
68 ) is
69 row_id varchar2(64);
70 begin
71 WF_AGENT_GROUPS_PKG.UPDATE_ROW (
72 X_GROUP_GUID => X_GROUP_GUID,
73 X_MEMBER_GUID => X_MEMBER_GUID
74 );
75
76 exception
77 when no_data_found then
78 WF_AGENT_GROUPS_PKG.INSERT_ROW(
79 X_ROWID => row_id,
80 X_GROUP_GUID => X_GROUP_GUID,
81 X_MEMBER_GUID => X_MEMBER_GUID
82 );
83 when others then
84 wf_core.context('Wf_Agent_Groups_Pkg', 'Load_Row', x_group_guid,
85 x_member_guid);
86 raise;
87 end LOAD_ROW;
88 -----------------------------------------------------------------------------
89
90 procedure DELETE_ROW (
91 X_GROUP_GUID in raw,
92 X_MEMBER_GUID in raw
93 ) is
94 begin
95 wf_event.raise('oracle.apps.wf.agent.group.delete',x_group_guid||'/'||x_member_guid);
96
97 delete from wf_agent_groups
98 where group_guid = X_GROUP_GUID
99 and member_guid = X_MEMBER_GUID;
100
101 if (sql%notfound) then
102 raise no_data_found;
103 end if;
104
105 exception
106 when others then
107 wf_core.context('Wf_Agent_Groups_Pkg', 'Delete_Row', x_group_guid,
108 x_member_guid);
109 raise;
110
111 end DELETE_ROW;
112 -----------------------------------------------------------------------------
113 function GENERATE (
114 X_GROUP_GUID in raw,
115 X_MEMBER_GUID in raw
116 ) return varchar2 is
117 buf varchar2(32000);
118 l_doc xmldom.DOMDocument;
119 l_element xmldom.DOMElement;
120 l_root xmldom.DOMNode;
121 l_node xmldom.DOMNode;
122 l_header xmldom.DOMNode;
123
124 begin
125 -- select DISPLAY_NAME, DESCRIPTION
126 -- into l_display_name, l_description
127 -- from wf_agent_groups
128 -- where group_guid = x_guid
129 -- and member_guid = x_member_guid;
130
131 l_doc := xmldom.newDOMDocument;
132 l_root := xmldom.makeNode(l_doc);
133 l_root := wf_event_xml.newtag (l_doc, l_root, wf_event_xml.masterTagName);
134 l_header := wf_event_xml.newtag(l_doc, l_root, m_table_name);
135 l_node := wf_event_xml.newtag(l_doc, l_header, wf_event_xml.versionTagName,
136 m_package_version);
137 l_node := wf_event_xml.newtag(l_doc, l_header, 'GROUP_GUID',
138 rawtohex(x_GROUP_GUID));
139 l_node := wf_event_xml.newtag(l_doc, l_header, 'MEMBER_GUID',
140 rawtohex(x_MEMBER_GUID));
141
142 xmldom.writeToBuffer(l_root, buf);
143 return buf;
144
145 null;
146 exception
147 when others then
148 wf_core.context('Wf_Agent_Groups_Pkg', 'Generate', x_group_guid,
149 x_member_guid);
150 raise;
151 end GENERATE;
152 -----------------------------------------------------------------------------
153 function GENERATE1 (
154 X_GROUP_GUID in varchar2,
155 X_MEMBER_GUID in varchar2
156 ) return varchar2 is
157 buf varchar2(32000);
158 l_doc xmldom.DOMDocument;
159 l_element xmldom.DOMElement;
160 l_root xmldom.DOMNode;
161 l_node xmldom.DOMNode;
162 l_header xmldom.DOMNode;
163
164 begin
165 -- select DISPLAY_NAME, DESCRIPTION
166 -- into l_display_name, l_description
167 -- from wf_agent_groups
168 -- where group_guid = x_guid
169 -- and member_guid = x_member_guid;
170
171 l_doc := xmldom.newDOMDocument;
172 l_root := xmldom.makeNode(l_doc);
173 l_root := wf_event_xml.newtag (l_doc, l_root, wf_event_xml.masterTagName);
174 l_header := wf_event_xml.newtag(l_doc, l_root, m_table_name);
175 l_node := wf_event_xml.newtag(l_doc, l_header, wf_event_xml.versionTagName,
176 m_package_version);
177 l_node := wf_event_xml.newtag(l_doc, l_header, 'GROUP_NAME',
178 x_GROUP_GUID);
179 l_node := wf_event_xml.newtag(l_doc, l_header, 'MEMBER_NAME',
180 x_MEMBER_GUID);
181
182 xmldom.writeToBuffer(l_root, buf);
183 return buf;
184
185 null;
186 exception
187 when others then
188 wf_core.context('Wf_Agent_Groups_Pkg', 'Generate1', x_group_guid,
189 x_member_guid);
190 raise;
191 end GENERATE1;
192 -----------------------------------------------------------------------------
193 procedure RECEIVE (
194 X_MESSAGE in varchar2
195 ) is
196 l_group_guid varchar2(32);
197 l_member_guid varchar2(32);
198 l_version varchar2(80);
199 l_message varchar2(32000);
200
201 l_node_name varchar2(255);
202 l_node xmldom.DOMNode;
203 l_child xmldom.DOMNode;
204 l_value varchar2(32000);
205 l_length integer;
206 l_node_list xmldom.DOMNodeList;
207
208 begin
209 l_message := x_message;
210 l_message := WF_EVENT_SYNCHRONIZE_PKG.SetGUID(l_message); -- update #NEW
211 l_message := WF_EVENT_SYNCHRONIZE_PKG.SetSYSTEMGUID(l_message); -- update #LOCAL
212 l_message := WF_EVENT_SYNCHRONIZE_PKG.SetSID(l_message); -- update #SID
213
214 l_node_list := wf_event_xml.findTable(l_message, m_table_name);
215 l_length := xmldom.getLength(l_node_list);
216
217 -- loop through elements that we received.
218 for i in 0..l_length-1 loop
219 l_node := xmldom.item(l_node_list, i);
220 l_node_name := xmldom.getNodeName(l_node);
221 if xmldom.hasChildNodes(l_node) then
222 l_child := xmldom.GetFirstChild(l_node);
223 l_value := xmldom.getNodevalue(l_child);
224 else
225 l_value := NULL;
226 end if;
227
228 if(l_node_name = 'GROUP_GUID') then
229 l_group_guid := l_value;
230 elsif(l_node_name = 'MEMBER_GUID') then
231 l_member_guid := l_value;
232 elsif(l_node_name = 'GROUP_NAME') then
233 Select guid
234 into l_group_guid
235 from wf_agents
236 where name=l_value;
237 elsif(l_node_name = 'MEMBER_NAME') then
238 Select guid
239 into l_member_guid
240 from wf_agents
241 where name=l_value;
242 elsif(l_node_name = wf_event_xml.versionTagName) then
243 l_version := l_value;
244 else
245 Wf_Core.Token('REASON', 'Invalid column name found:' ||
246 l_node_name || ' with value:'||l_value);
247 Wf_Core.Raise('WFSQL_INTERNAL');
248 end if;
249 end loop;
250
251 wf_agent_groups_pkg.load_row(
252 X_GROUP_GUID => l_group_guid,
253 X_MEMBER_GUID => l_member_guid
254 );
255
256 exception
257 when others then
258 wf_core.context('Wf_Agent_Groups_Pkg', 'Receive', x_message);
259 raise;
260 end RECEIVE;
261 -----------------------------------------------------------------------------
262
263 end WF_AGENT_GROUPS_PKG;