DBA Data[Home] [Help]

PACKAGE BODY: APPS.WF_EVENT_GROUPS_PKG

Source


1 package body WF_EVENT_GROUPS_PKG as
2 /* $Header: WFEVGRPB.pls 120.3 2005/10/19 05:25:49 vshanmug ship $ */
3 m_table_name       varchar2(255) := 'WF_EVENT_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_event_groups
13               where  group_guid  = X_GROUP_GUID
14               and    member_guid = X_MEMBER_GUID;
15 begin
16   insert into wf_event_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.event.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_Event_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_event_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.event.group.update',x_group_guid||'/'||x_member_guid);
56   end if;
57 
58 exception
59   when others then
60     wf_core.context('Wf_Event_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_EVENT_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_core.clear;
79     WF_EVENT_GROUPS_PKG.INSERT_ROW(
80       X_ROWID       => row_id,
81       X_GROUP_GUID  => X_GROUP_GUID,
82       X_MEMBER_GUID => X_MEMBER_GUID
83     );
84   when others then
85     wf_core.context('Wf_Event_Groups_Pkg', 'Load_Row', x_group_guid,
86                 x_member_guid);
87     raise;
88 end LOAD_ROW;
89 -----------------------------------------------------------------------------
90 
91 procedure DELETE_ROW (
92   X_GROUP_GUID  in  raw,
93   X_MEMBER_GUID in  raw
94 ) is
95 begin
96   wf_event.raise('oracle.apps.wf.event.group.delete',x_group_guid||'/'||x_member_guid);
97 
98   delete from wf_event_groups
99   where  group_guid  = X_GROUP_GUID
100   and    member_guid = X_MEMBER_GUID;
101 
102   if (sql%notfound) then
103     raise no_data_found;
104   end if;
105 
106 exception
107   when others then
108     wf_core.context('Wf_Event_Groups_Pkg', 'Delete_Row', x_group_guid,
109        x_member_guid);
110     raise;
111 
112 end DELETE_ROW;
113 -----------------------------------------------------------------------------
114 function GENERATE (
115   X_GROUP_GUID  in  raw,
116   X_MEMBER_GUID in  raw
117 ) return varchar2 is
118   buf              varchar2(32000);
119   l_doc            xmldom.DOMDocument;
120   l_element        xmldom.DOMElement;
121   l_root           xmldom.DOMNode;
122   l_node           xmldom.DOMNode;
123   l_header         xmldom.DOMNode;
124 
125 begin
126 --  select DISPLAY_NAME, DESCRIPTION
127 --    into l_display_name, l_description
128 --    from wf_event_groups
129 --  where group_guid = x_guid
130 --    and member_guid = x_member_guid;
131 
132   l_doc := xmldom.newDOMDocument;
133   l_root := xmldom.makeNode(l_doc);
134   l_root := wf_event_xml.newtag (l_doc, l_root, wf_event_xml.masterTagName);
135   l_header := wf_event_xml.newtag(l_doc, l_root, m_table_name);
136   l_node := wf_event_xml.newtag(l_doc, l_header, wf_event_xml.versionTagName,
137                                                  m_package_version);
138   l_node := wf_event_xml.newtag(l_doc, l_header, 'GROUP_GUID',
139                                     rawtohex(x_GROUP_GUID));
140   l_node := wf_event_xml.newtag(l_doc, l_header, 'MEMBER_GUID',
141                                     rawtohex(x_MEMBER_GUID));
142 
143   xmldom.writeToBuffer(l_root, buf);
144   return buf;
145 
146 null;
147 exception
148   when others then
149     wf_core.context('Wf_Event_Groups_Pkg', 'Generate', x_group_guid,
150        x_member_guid);
151     raise;
152 end GENERATE;
153 -----------------------------------------------------------------------------
154 procedure CHECK_EVENT(X_MEMBER_GUID RAW,
155 		      X_ERROR out nocopy varchar2)is
156 event_count number;
157 begin
158    Select 1 into event_count
159    from   WF_EVENTS
160    where  guid=X_MEMBER_GUID;
161 exception
162   when no_data_found then
163      x_error:='NON_EXIST_EVENT:'||X_MEMBER_GUID;
164   when others then
165     wf_core.context('Wf_Event_Groups_Pkg', 'Check_Event', x_member_guid);
166     raise;
167 end CHECK_EVENT;
168 -----------------------------------------------------------------------------
169 procedure RECEIVE2 (
170   X_MESSAGE     in varchar2,
171   X_ERROR  out nocopy varchar2) is
172   l_group_guid       varchar2(32);
173   l_member_guid      varchar2(32);
174   l_version          varchar2(80);
175   l_message          varchar2(32000);
176 
177   l_node_name        varchar2(255);
178   l_node             xmldom.DOMNode;
179   l_child            xmldom.DOMNode;
180   l_value            varchar2(32000);
181   l_length           integer;
182   l_node_list        xmldom.DOMNodeList;
183 
184 begin
185   l_message := x_message;
186   l_message := WF_EVENT_SYNCHRONIZE_PKG.SetGUID(l_message); -- update #NEW
187   l_message := WF_EVENT_SYNCHRONIZE_PKG.SetSYSTEMGUID(l_message); -- update #LOCAL
188   l_message := WF_EVENT_SYNCHRONIZE_PKG.SetSID(l_message); -- update #SID
189 
190   l_node_list := wf_event_xml.findTable(l_message, m_table_name);
191   l_length := xmldom.getLength(l_node_list);
192 
193   -- loop through elements that we received.
194   for i in 0..l_length-1 loop
195      l_node := xmldom.item(l_node_list, i);
196      l_node_name := xmldom.getNodeName(l_node);
197      if xmldom.hasChildNodes(l_node) then
198         l_child := xmldom.GetFirstChild(l_node);
199         l_value := xmldom.getNodevalue(l_child);
200      else
201         l_value := NULL;
202      end if;
203 
204      if(l_node_name = 'GROUP_GUID') then
205        l_group_guid := l_value;
206      elsif(l_node_name = 'MEMBER_GUID') then
207        l_member_guid := l_value;
208      elsif(l_node_name = 'GROUP_NAME') then
209        select guid
210        into   l_group_guid
211        from   wf_events
212        where  name = l_value
213        and    type = 'GROUP';
214      elsif(l_node_name = 'MEMBER_NAME') then
215        select guid
216        into   l_member_guid
217        from   wf_events
218        where  name = l_value;
219      elsif(l_node_name = wf_event_xml.versionTagName) then
220        l_version := l_value;
221      else
222        Wf_Core.Token('REASON', 'Invalid column name found:' ||
223            l_node_name || ' with value:'||l_value);
224        Wf_Core.Raise('WFSQL_INTERNAL');
225      end if;
226   end loop;
227 
228   wf_event_groups_pkg.check_event(l_member_guid,x_error);
229 
230   wf_event_groups_pkg.load_row(
231      X_GROUP_GUID      => l_group_guid,
232      X_MEMBER_GUID     => l_member_guid
233   );
234 
235 exception
236   when others then
237     wf_core.context('Wf_Event_Groups_Pkg', 'Receive', x_message);
238     raise;
239 end RECEIVE2;
240 
241 -----------------------------------------------------------------------------
242 procedure RECEIVE (
243   X_MESSAGE     in varchar2 ) is
244   l_error          varchar2(4000);
245 begin
246   RECEIVE2(X_MESSAGE,l_error);
247 end RECEIVE;
248 -----------------------------------------------------------------------------
249 function GENERATE2 (
250   X_GROUP_NAME  in  varchar2,
251   X_MEMBER_NAME in  varchar2
252 ) return varchar2 is
253   buf              varchar2(32000);
254   l_doc            xmldom.DOMDocument;
255   l_element        xmldom.DOMElement;
256   l_root           xmldom.DOMNode;
257   l_node           xmldom.DOMNode;
258   l_header         xmldom.DOMNode;
259 
260 begin
261 
262   l_doc := xmldom.newDOMDocument;
263   l_root := xmldom.makeNode(l_doc);
264   l_root := wf_event_xml.newtag (l_doc, l_root, wf_event_xml.masterTagName);
265   l_header := wf_event_xml.newtag(l_doc, l_root, m_table_name);
266   l_node := wf_event_xml.newtag(l_doc, l_header, wf_event_xml.versionTagName,
267                                                  m_package_version);
268   l_node := wf_event_xml.newtag(l_doc, l_header, 'GROUP_NAME', x_group_name);
269   l_node := wf_event_xml.newtag(l_doc, l_header, 'MEMBER_NAME', x_member_name);
270 
271   xmldom.writeToBuffer(l_root, buf);
272   return buf;
273 
274 null;
275 exception
276   when others then
277     wf_core.context('Wf_Event_Groups_Pkg', 'Generate2', x_group_name,
278        x_member_name);
279     raise;
280 end GENERATE2;
281 
282 end WF_EVENT_GROUPS_PKG;