[Home] [Help]
PACKAGE BODY: APPS.WF_NTF_RULE
Source
1 package body WF_NTF_RULE as
2 /* $Header: WFNRULEB.pls 120.4 2006/01/25 15:34:10 smayze noship $ */
3
4 --Variables
5 hashbase number:=1;
6 hashsize number:=512;
7
8 --APIs
9 function Submit_Conc_Program_RF( p_sub_guid in RAW,
10 p_event in out NOCOPY WF_EVENT_T)
11 return VARCHAR2
12 is
13 i_submit_id number;
14 l_rule_name varchar2(30);
15 l_msg_type varchar2(30);
16 l_parameter_list wf_parameter_list_t;
17 request_id varchar2(4000);
18 org_user_id number;
19 org_resp_id number;
20 org_resp_appl_id number;
21
22 cursor c_rules is
23 select distinct wnrc.message_type
24 from wf_ntf_rules wnr,
25 wf_ntf_rule_criteria wnrc
26 where wnr.rule_name = l_rule_name
27 and wnr.rule_name = wnrc.rule_name;
28 begin
29 org_user_id := fnd_global.user_id;
30 org_resp_id := fnd_global.resp_id;
31 org_resp_appl_id := fnd_global.resp_appl_id;
32
33 fnd_global.apps_initialize(0, org_resp_id, org_resp_appl_id);
34
35 l_rule_name := p_event.getEventKey();
36
37 for v_rule in c_rules
38 loop
39 i_submit_id := fnd_request.submit_request(
40 application => 'FND',
41 program => 'FNDWFDCC',
42 Start_Time => NULL,
43 Sub_Request => FALSE,
44 Argument1 => v_rule.message_type,
45 Argument2 => 'OPEN',
46 Argument3 => null);
47 request_id := request_id || ','||to_char(i_submit_id);
48
49 end loop;
50 p_event.addParameterToList('REQUEST_ID', ltrim(request_id,','));
51
52 commit;
53 fnd_global.apps_initialize( org_user_id,org_resp_id,org_resp_appl_id);
54
55 return 'SUCCESS';
56 exception
57 when others then
58 wf_core.context('WF_NTF_RULE','Submit_Conc_Program_RF',p_event.getEventName(),rawtohex(p_sub_guid));
59 WF_EVENT.setErrorInfo(p_event, 'ERROR');
60 return 'ERROR';
61 end Submit_Conc_Program_RF;
62
63
64 procedure simulate_rules (p_message_type in varchar2,
65 p_message_name in varchar2,
66 p_customization_level in varchar2,
67 x_custom_col_tbl out nocopy custom_col_type)
68 is
69 cursor custom_cols is
70 select
71 wnrm.column_name,
72 wnr.phase,
73 wnrm.attribute_name,
74 wnr.customization_level,
75 wnr.rule_name
76 from wf_ntf_rules wnr,
77 wf_ntf_rule_criteria wnrc,
78 wf_ntf_rule_maps wnrm
79 where wnr.rule_name = wnrc.rule_name
80 and wnr.rule_name = wnrm.rule_name
81 and wnr.status = 'ENABLED'
82 and wnrc.message_type = p_message_type
83 and ((p_customization_level is null and wnr.customization_level <> 'C')
84 or wnr.customization_level = p_customization_level)
85 and exists (select null from wf_message_attributes wma
86 where wma.message_type = p_message_type
87 and (wma.message_name = p_message_name or p_message_name is null)
88 and wma.name = wnrm.attribute_name)
89 order by wnrm.column_name, wnr.phase desc;
90
91 cursor mesg_attr1(aname varchar2) is
92 select display_name
93 from wf_message_attributes_tl
94 where message_type = p_message_type
95 and message_name = p_message_name
96 and name = aname
97 and language = userenv('LANG');
98
99 cursor mesg_attr_all(aname varchar2) is
100 select distinct display_name
101 from wf_message_attributes_tl
102 where message_type = p_message_type
103 and name = aname
104 and language = userenv('LANG');
105
106 idx number;
107
108 begin
109 x_custom_col_tbl.delete;
110 for c in custom_cols
111 loop
112 -- column name is unique within the same rule
113 -- Hash Size 512 (2^9) must be large enough to prevent collision
114
115 idx := dbms_utility.get_hash_value(c.column_name, hashbase, hashsize);
116 if (x_custom_col_tbl.exists(idx)) then
117 x_custom_col_tbl(idx).override := 'Y';
118 else
119 x_custom_col_tbl(idx).rule_name := c.rule_name;
120 x_custom_col_tbl(idx).column_name := c.column_name;
121 x_custom_col_tbl(idx).attribute_name := c.attribute_name;
122 x_custom_col_tbl(idx).phase := c.phase;
123 x_custom_col_tbl(idx).customization_level := c.customization_level;
124 x_custom_col_tbl(idx).override := 'N';
125
126 if (p_message_name is null) then
127 for a in mesg_attr_all(c.attribute_name)
128 loop
129 if (x_custom_col_tbl(idx).display_name is null) then
130 x_custom_col_tbl(idx).display_name := a.display_name;
131 else
132 x_custom_col_tbl(idx).display_name :=
133 x_custom_col_tbl(idx).display_name||', '||a.display_name;
134 end if;
135 end loop;
136 else
137 for a in mesg_attr1(c.attribute_name)
138 loop
139 x_custom_col_tbl(idx).display_name := a.display_name;
140 end loop;
141 end if;
142 end if;
143 end loop;
144
145 exception
146 when others then
147 wf_core.context('WF_NTF_RULE','Simulate', p_message_type, p_message_name, p_customization_level);
148 raise;
149 end simulate_rules;
150
151 end WF_NTF_RULE;
152