DBA Data[Home] [Help]

PACKAGE BODY: APPS.UMX_ACCESS_ROLES_PVT

Source


1 PACKAGE  BODY UMX_ACCESS_ROLES_PVT AS
2 /*$Header: UMXVARPB.pls 120.3 2008/05/20 10:58:31 snellepa ship $*/
3 
4 procedure populateRecord(p_role_name        in varchar2,
5                          p_display_name     in varchar2,
6                          p_owner_tag        in varchar2,
7                          p_description      in varchar2,
8                          p_params           in out nocopy wf_parameter_list_t) IS
9 
10  begin
11 
12   --  Populating the structure wf_parameter_list_t
13 
14   WF_EVENT.AddParameterToList(p_name          => 'USER_NAME',
15                               p_value         => p_role_name,
16                               p_parameterlist => p_params);
17 
18   WF_EVENT.AddParameterToList(p_name          => 'DISPLAYNAME',
19                               p_value         => p_display_name,
20                               p_parameterlist => p_params);
21 
22   WF_EVENT.AddParameterToList(p_name          => 'DESCRIPTION',
23                               p_value         => p_description,
24                               p_parameterlist => p_params);
25 
26   WF_EVENT.AddParameterToList(p_name          => 'OWNER_TAG',
27                               p_value         => p_owner_tag,
28                               p_parameterlist => p_params);
29 
30   -- Setting the default values
31 
32   WF_EVENT.AddParameterToList(p_name          => 'ORCLNLSTERRITORY',
33                               p_value         => 'AMERICA',
34                               p_parameterlist => p_params);
35 
36   WF_EVENT.AddParameterToList(p_name          => 'RAISEERRORS',
37                               p_value         => 'TRUE',
38                               p_parameterlist => p_params);
39 
40 end populateRecord;
41 
42 function getParentRoles(p_role_name varchar2) return varchar2 is
43 
44 l_superiors WF_ROLE_HIERARCHY.relTAB;
45 l_subordinates WF_ROLE_HIERARCHY.relTAB;
46 length_sup number :=0;
47 l_role_name WF_ALL_ROLES_VL.NAME%TYPE;
48 l_role_display_name WF_ALL_ROLES_VL.DISPLAY_NAME%TYPE;
49 i number :=1;
50 
51 cursor find_role_disp_name is select display_name from
52 WF_ALL_ROLES_vl where name = l_role_name;
53 
54 begin
55 
56   IF p_role_name IS NULL THEN
57    RETURN NULL;
58   END IF;
59 
60   WF_ROLE_HIERARCHY.GetRelationships(p_name         => p_role_name,
61                                      p_superiors    => l_superiors,
62                                      p_subordinates => l_subordinates);
63 
64   length_sup := l_superiors.count;
65 
66   IF length_sup = 0 THEN
67    RETURN NULL;
68   END IF;
69 
70   jtf_dbstream_utils.clearOutputStream;
71   jtf_dbstream_utils.writeInt(length_sup);
72 
73   -- Iterate through the table and create a delimited string
74   loop
75 
76      if i > length_sup then -- terminating condition
77      exit;
78      end if;
79 
80        l_role_name := l_superiors(i).SUPER_NAME;
81 
82        open find_role_disp_name;
83         fetch find_role_disp_name into l_role_display_name;
84 
85         jtf_dbstream_utils.writeString(l_role_display_name);
86        close find_role_disp_name;
87      i := i+1;
88   end loop;
89 
90  return jtf_dbstream_utils.getOutputStream;
91 
92 end getParentRoles;
93 
94 function getAffectedRoles(p_role_name varchar2) return varchar2 is
95 
96 l_superiors WF_ROLE_HIERARCHY.relTAB;
97 l_subordinates WF_ROLE_HIERARCHY.relTAB;
98 length_sup number :=0;
99 l_role_name WF_ALL_ROLES_VL.NAME%TYPE;
100 l_role_display_name WF_ALL_ROLES_VL.DISPLAY_NAME%TYPE;
101 i number :=1;
102 
103 cursor find_role_disp_name is select display_name from
104 WF_ALL_ROLES_vl where name = l_role_name;
105 
106 begin
107 
108   IF p_role_name IS NULL THEN
109    RETURN NULL;
110   END IF;
111 
112   WF_ROLE_HIERARCHY.GetRelationships(p_name         => p_role_name,
113                                      p_superiors    => l_superiors,
114                                      p_subordinates => l_subordinates);
115 
116   length_sup := l_subordinates.count;
117 
118   IF length_sup = 0 THEN
119    RETURN NULL;
120   END IF;
121 
122   jtf_dbstream_utils.clearOutputStream;
123   jtf_dbstream_utils.writeInt(length_sup);
124 
125   -- Iterate through the table and create a delimited string
126   loop
127 
128      if i > length_sup then -- terminating condition
129      exit;
130      end if;
131 
132        l_role_name := l_subordinates(i).SUB_NAME;
133 
134        open find_role_disp_name;
135         fetch find_role_disp_name into l_role_display_name;
136 
137         jtf_dbstream_utils.writeString(l_role_display_name);
138        close find_role_disp_name;
139      i := i+1;
140   end loop;
141 
142  return jtf_dbstream_utils.getOutputStream;
143 
144 end getAffectedRoles;
145 
146 PROCEDURE  insert_role(p_role_name        in varchar2,
147                          p_orig_system      in varchar2,
148                          p_orig_system_id   in number,
149                          p_start_date       in date,
150                          p_expiration_date  in date,
151                          p_display_name     in varchar2,
152                          p_owner_tag        in varchar2,
153                          p_description      in varchar2) IS
154 
155 l_params wf_parameter_list_t;
156 begin
157 
158   populateRecord(p_role_name        => p_role_name,
159                  p_display_name     => p_display_name,
160                  p_owner_tag        => p_owner_tag,
161                  p_description      => p_description,
162                  p_params           => l_params     );
163 
164   WF_LOCAL_SYNCH.propagate_role(p_orig_system     => p_orig_system,
165                                 p_orig_system_id  => p_orig_system_id,
166                                 p_attributes      => l_params,
167                                 p_start_date      => p_start_date,
168                                 p_expiration_date => p_expiration_date);
169 
170 
171 end insert_role;
172 
173 PROCEDURE  update_role(p_role_name        in varchar2,
174                          p_orig_system      in varchar2,
175                          p_orig_system_id   in number,
176                          p_start_date       in date,
177                          p_expiration_date  in date,
178                          p_display_name     in varchar2,
179                          p_owner_tag        in varchar2,
180                          p_description      in varchar2) IS
181 
182 l_params wf_parameter_list_t;
183 begin
184 
185   populateRecord(p_role_name        => p_role_name,
186                  p_display_name     => p_display_name,
187                  p_owner_tag        => p_owner_tag,
188                  p_description      => p_description,
189                  p_params           => l_params     );
190 
191   WF_EVENT.AddParameterToList(p_name          => 'UPDATEONLY',
192                               p_value         => 'TRUE',
193                               p_parameterlist => l_params);
194 
195 
196   WF_EVENT.AddParameterToList(p_name          => 'WFSYNCH_OVERWRITE',
197                               p_value         => 'TRUE',
198                               p_parameterlist => l_params);
199 
200   WF_LOCAL_SYNCH.propagate_role(p_orig_system     => p_orig_system,
201                                 p_orig_system_id  => p_orig_system_id,
202                                 p_attributes      => l_params,
203                                 p_start_date      => p_start_date,
204                                 p_expiration_date => p_expiration_date);
205 
206 
207 end update_role;
208 
209 
210 
211 PROCEDURE propagateUserRole(p_user_name             in varchar2,
212                             p_role_name             in varchar2,
213                             p_start_date            in date,
214                             p_expiration_date       in date
215                             )IS
216 
217 
218 reason wf_local_user_roles.ASSIGNMENT_REASON%type;
219 begin
220 
221 
222 
223 select ASSIGNMENT_REASON into reason from wf_local_user_roles
224 where USER_NAME = p_user_name
225 and ROLE_NAME = p_role_name ;
226 
227 
228   WF_LOCAL_SYNCH.propagateUserRole(p_user_name    => p_user_name,
229                                 p_role_name       => p_role_name,
230                                 p_start_date      => p_start_date,
231                                 p_expiration_date => p_expiration_date,
232                                 p_assignmentReason => reason,
233                                 p_overwrite       => TRUE ,
234                                 p_raiseErrors     => TRUE);
235 
236 end propagateUserRole;
237 
238    --
239    -- HierarchyEnabled
240    --
241    -- IN
242    --   p_origSystem  (VARCHAR2)
243    --
244    -- RETURNS
245    --   'Y' - if orig system is hierarchy enabled, 'N' otherwise
246    --
247    -- NOTES
248    --  Wrapper on top of WF_ROLE_HIERARCHY.HierarchyEnabled
249    --
250      function HierarchyEnabled (p_origSystem in VARCHAR2) return varchar2
251      is
252        l_result  boolean;
253 
254      begin
255 
256        -- for orig system UMX or FND_RESP, always return 'Y'
257        if( (p_origSystem = 'UMX') or ( p_origSystem = 'FND_RESP' ) ) then
258          return 'Y';
259        end if;
260 
261        l_result := WF_ROLE_HIERARCHY.HierarchyEnabled( p_origSystem);
262 
263        if( l_result = TRUE ) then
264          return 'Y';
265        else
266          return 'N';
267        end if;
268      end HierarchyEnabled;
269 
270   --
271   -- TEST
272   --   Wrapper to Test if function is accessible under current responsibility.
273   -- IN
274   --   p_function_name          - function to test
275   --   p_TEST_MAINT_AVAILABILTY - 'Y' (default) means check if available for
276   --                              current value of profile APPS_MAINTENANCE_MODE
277   --                              'N' means the caller is checking so it's
278   --                              unnecessary to check.
279   -- RETURNS
280   --  'Y' if function is accessible
281   --
282   function test (p_function_name           in varchar2,
283                  p_test_maint_availability in varchar2 default 'Y') return varchar2 is
284 
285   begin
286     if (fnd_function.test(p_function_name, p_test_maint_availability)) then
287       return ('Y');
288     else
289       return ('N');
290     end if;
291   end test;
292 
293 end UMX_ACCESS_ROLES_PVT;