1 TYPE BODY WF_Event_Obj AS
2
3 STATIC PROCEDURE initialize(p_event_obj IN OUT NOCOPY WF_Event_Obj) is
4 l_event_subs WF_Event_Subs_Tab;
5 begin
6 p_event_obj := WF_Event_Obj(null, -- guid
7 null, -- name
8 null, -- type
9 null, -- status
10 null, -- generate_function
11 null, -- java_generate_func
12 null, -- licensed_flag
13 null, -- local_subs_list
14 'N', -- local_subs_loaded
15 'N', -- local_src_agt_avl
16 null, -- external_subs_list
17 'N', -- external_subs_loaded
18 'N', -- external_src_agt_avl
19 null, -- error_subs_list
20 'N', -- error_subs_loaded
21 'N' -- error_src_agt_avl
22 );
23 end initialize;
24
25 MEMBER PROCEDURE AddSubscriptionToList(p_subscription in WF_Event_Subs_Obj,
26 p_source_type in varchar2)
27 is
28 l_subs_list WF_Event_Subs_Tab;
29 l_idx number;
30 begin
31 if (p_source_type = 'LOCAL') then
32 l_subs_list := self.LOCAL_SUBS_LIST;
33 elsif (p_source_type = 'EXTERNAL') then
34 l_subs_list := self.EXTERNAL_SUBS_LIST;
35 elsif (p_source_type = 'ERROR') then
36 l_subs_list := self.ERROR_SUBS_LIST;
37 end if;
38
39 if (l_subs_list is null) then
40 l_subs_list := Wf_Event_Subs_Tab(null);
41 l_subs_list(1) := p_subscription;
42 else
43 l_subs_list.EXTEND;
44 l_idx := l_subs_list.COUNT;
45 l_subs_list(l_idx) := p_subscription;
46 end if;
47
48 if (p_source_type = 'LOCAL') then
49 self.LOCAL_SUBS_LIST := l_subs_list;
50 elsif (p_source_type = 'EXTERNAL') then
51 self.EXTERNAL_SUBS_LIST := l_subs_list;
52 elsif (p_source_type = 'ERROR') then
53 self.ERROR_SUBS_LIST := l_subs_list;
54 end if;
55 end AddSubscriptionToList;
56
57 MEMBER FUNCTION GetSubscriptionList(p_source_type in varchar2)
58 return WF_Event_Subs_Tab
59 is
60 begin
61 if (p_source_type = 'LOCAL') then
62 return self.LOCAL_SUBS_LIST;
63 elsif (p_source_type = 'EXTERNAL') then
64 return self.EXTERNAL_SUBS_LIST;
65 elsif (p_source_type = 'ERROR') then
66 return self.ERROR_SUBS_LIST;
67 end if;
68 end GetSubscriptionList;
69
70 MEMBER PROCEDURE SetSubsLoaded(p_source_type in varchar2,
71 p_loaded in varchar2)
72 is
73 begin
74 if (p_source_type = 'LOCAL') then
75 self.LOCAL_SUBS_LOADED := p_loaded;
76 elsif (p_source_type = 'EXTERNAL') then
77 self.EXTERNAL_SUBS_LOADED := p_loaded;
78 elsif (p_source_type = 'ERROR') then
79 self.ERROR_SUBS_LOADED := p_loaded;
80 end if;
81 end SetSubsLoaded;
82
83 MEMBER FUNCTION GetSubsLoaded(p_source_type in varchar2)
84 return varchar2
85 is
86 begin
87 if (p_source_type = 'LOCAL') then
88 return self.LOCAL_SUBS_LOADED;
89 elsif (p_source_type = 'EXTERNAL') then
90 return self.EXTERNAL_SUBS_LOADED;
91 elsif (p_source_type = 'ERROR') then
92 return self.ERROR_SUBS_LOADED;
93 end if;
94 end GetSubsLoaded;
95
96 MEMBER PROCEDURE SetSourceAgentAvl(p_source_type in varchar2,
97 p_src_agt_avl in varchar2)
98 is
99 begin
100 if (p_source_type = 'LOCAL') then
101 self.LOCAL_SRC_AGT_AVL := p_src_agt_avl;
102 elsif (p_source_type = 'EXTERNAL') then
103 self.EXTERNAL_SRC_AGT_AVL := p_src_agt_avl;
104 elsif (p_source_type = 'ERROR') then
105 self.ERROR_SRC_AGT_AVL := p_src_agt_avl;
106 end if;
107 end SetSourceAgentAvl;
108
109 MEMBER FUNCTION GetSourceAgentAvl(p_source_type in varchar2)
110 return varchar2
111 is
112 begin
113 if (p_source_type = 'LOCAL') then
114 return self.LOCAL_SRC_AGT_AVL;
115 elsif (p_source_type = 'EXTERNAL') then
116 return self.EXTERNAL_SRC_AGT_AVL;
117 elsif (p_source_type = 'ERROR') then
118 return self.ERROR_SRC_AGT_AVL;
119 end if;
120 end GetSourceAgentAvl;
121
122 MEMBER FUNCTION GetSubscriptionByGuid(p_sub_guid in raw)
123 return Wf_Event_Subs_Obj
124 is
125 l_subs_list WF_Event_Subs_Tab;
126 l_found boolean;
127 l_sub WF_Event_Subs_Obj;
128 begin
129 l_found := false;
130 l_subs_list := self.LOCAL_SUBS_LIST;
131
132 if (l_subs_list is not null) then
133 for i in 1..l_subs_list.COUNT loop
134 if (l_subs_list(i).GUID = p_sub_guid) then
135 l_sub := l_subs_list(i);
136 l_found := true;
137 exit;
138 end if;
139 end loop;
140 if (l_found) then
141 return l_sub;
142 end if;
143 end if;
144
145 l_subs_list := self.EXTERNAL_SUBS_LIST;
146
147 if (l_subs_list is not null) then
148 for i in 1..l_subs_list.COUNT loop
149 if (l_subs_list(i).GUID = p_sub_guid) then
150 l_sub := l_subs_list(i);
151 l_found := true;
152 exit;
153 end if;
154 end loop;
155 if (l_found) then
156 return l_sub;
157 end if;
158 end if;
159
160 l_subs_list := self.ERROR_SUBS_LIST;
161
162 if (l_subs_list is not null) then
163 for i in 1..l_subs_list.COUNT loop
164 if (l_subs_list(i).GUID = p_sub_guid) then
165 l_sub := l_subs_list(i);
166 l_found := true;
167 exit;
168 end if;
169 end loop;
170 if (l_found) then
171 return l_sub;
172 end if;
173 end if;
174
175 return null;
176 end GetSubscriptionByGuid;
177
178 MEMBER FUNCTION GetSubscriptionBySrcAgtGUID(p_source_type in varchar2,
179 p_source_agt in raw)
180 return WF_Event_Subs_Tab
181 is
182 l_all_subs_list WF_Event_Subs_Tab;
183 l_subs_list WF_Event_Subs_Tab;
184 l_sub WF_Event_Subs_Obj;
185 l_idx number;
186 begin
187 l_all_subs_list := self.GetSubscriptionList(p_source_type);
188
189 if (l_all_subs_list is null) then
190 return null;
191 end if;
192
193 for i in 1..l_all_subs_list.COUNT loop
194 -- either the source_agent_guid should be same as p_source_agt or
195 -- source_agent_guid should be null
196 if ((l_all_subs_list(i).SOURCE_AGENT_GUID is not null AND
197 l_all_subs_list(i).SOURCE_AGENT_GUID = p_source_agt) OR
198 l_all_subs_list(i).SOURCE_AGENT_GUID is null) then
199
200 l_sub := l_all_subs_list(i);
201 if (l_subs_list is null) then
202 l_subs_list := Wf_Event_Subs_Tab(null);
203 l_subs_list(1) := l_sub;
204 else
205 l_subs_list.EXTEND;
206 l_idx := l_subs_list.COUNT;
207 l_subs_list(l_idx) := l_sub;
208 end if;
209 end if;
210 end loop;
211
212 return l_subs_list;
213 end GetSubscriptionBySrcAgtGUID;
214
215 end;