[Home] [Help]
PACKAGE BODY: APPS.JTF_AUTH_BULKLOAD_PKG
Source
1 package body JTF_AUTH_BULKLOAD_PKG as
2 /* $Header: JTFSEABB.pls 120.1 2005/07/02 02:10:03 appldev ship $ */
3 procedure ASSIGN_ROLE (
4 USER_NAME in VARCHAR2,
5 ROLE_NAME in VARCHAR2
6 ) is
7 mapping_id NUMBER;
8 p_id NUMBER;
9 r_id NUMBER;
10 d_id NUMBER;
11 source_id NUMBER;
12 cnt NUMBER;
13 count1 NUMBER;
14 maps_sources NUMBER;
15 seq NUMBER;
16 U_USER_NAME VARCHAR2(255);
17 U_ROLE_NAME VARCHAR2(255);
18 begin
19 U_USER_NAME := UPPER(USER_NAME);
20 U_ROLE_NAME := UPPER(ROLE_NAME);
21
22 select count(*) into cnt
23 from fnd_user
24 where user_name=U_USER_NAME;
25
26 if cnt=0 then
27 fnd_message.set_name('JTF', 'JTF-1055');
28 app_exception.raise_exception;
29 end if;
30
31 select count(*) into cnt
32 from jtf_auth_principals_b
33 where principal_name=U_ROLE_NAME and is_user_flag=0;
34
35 if cnt=0 then
36 fnd_message.set_name('JTF', 'JTF-1056');
37 app_exception.raise_exception;
38 end if;
39
40 select count(*) into cnt
41 from jtf_auth_principals_b
42 where principal_name=U_USER_NAME and is_user_flag=1;
43
44 if cnt=0 then
45
46 select jtf_auth_s1.nextval into seq from dual;
47 JTF_AUTH_PRINCIPALS_PKG.INSERT_ROW(seq,seq,1,U_USER_NAME,690,null,1,0,U_USER_NAME, null, SYSDATE, 0, SYSDATE, 0, null);
48
49 end if;
50
51 select count(*) into count1
52 from jtf_auth_principal_maps c,
53 jtf_auth_principals_b a,
54 jtf_auth_domains_b d,
55 jtf_auth_principals_b b
56 where a.principal_name=U_USER_NAME and a.is_user_flag=1
57 and a.jtf_auth_principal_id=c.jtf_auth_principal_id
58 and b.principal_name=U_ROLE_NAME and b.is_user_flag=0
59 and b.jtf_auth_principal_id=c.jtf_auth_parent_principal_id
60 and d.domain_name='CRM_DOMAIN'
61 and d.jtf_auth_domain_id=c.jtf_auth_domain_id;
62
63 select jtf_auth_principal_id into p_id
64 from jtf_auth_principals_b
65 where principal_name=U_USER_NAME and is_user_flag=1;
66
67 select jtf_auth_principal_id into r_id
68 from jtf_auth_principals_b
69 where principal_name=U_ROLE_NAME and is_user_flag=0;
70
71 select jtf_auth_domain_id into d_id
72 from jtf_auth_domains_b where
73 domain_name='CRM_DOMAIN';
74
75 if count1=0 then
76 insert into jtf_auth_principal_maps (jtf_auth_principal_id,
77 jtf_auth_parent_principal_id, jtf_auth_domain_id,
78 created_by, creation_date, last_updated_by, last_update_date,
79 application_id, object_version_number) values
80 (p_id, r_id, d_id,
81 0,SYSDATE,0,SYSDATE,690,1);
82 end if;
83
84 select jtf_auth_s1.nextval into source_id from dual;
85
86 select jtf_auth_principal_mapping_id into mapping_id
87 from jtf_auth_principal_maps
88 where jtf_auth_principal_id = p_id
89 and jtf_auth_parent_principal_id = r_id
90 and jtf_auth_domain_id = d_id;
91
92 select count(*) into maps_sources
93 from jtf_auth_maps_sources a
94 where a.jtf_auth_principal_mapping_id = mapping_id
95 and a.ownertable_name = 'JTF_AUTH_PRINCIPALS_B'
96 and a.ownertable_key = TO_CHAR(p_id);
97
98 if maps_sources=0 then
99 insert into jtf_auth_maps_sources (JTF_AUTH_MAPS_SOURCE_ID,
100 JTF_AUTH_PRINCIPAL_MAPPING_ID, OWNERTABLE_NAME, OWNERTABLE_KEY,
101 CREATED_BY, CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE,
102 APPLICATION_ID, OBJECT_VERSION_NUMBER) VALUES
103 (source_id, mapping_id, 'JTF_AUTH_PRINCIPALS_B',
104 TO_CHAR(p_id), 0, SYSDATE, 0, SYSDATE, 690, 1);
105 end if;
106
107
108 end ASSIGN_ROLE;
109
110 procedure ASSIGN_ROLE (
111 USER_NAME in VARCHAR2,
112 ROLE_NAME in VARCHAR2,
113 OWNERTABLE_NAME in VARCHAR2,
114 OWNERTABLE_KEY in VARCHAR2
115 ) is
116 mapping_id NUMBER;
117 p_id NUMBER;
118 r_id NUMBER;
119 d_id NUMBER;
120 source_id NUMBER;
121 cnt NUMBER;
122 count1 NUMBER;
123 maps_sources NUMBER;
124 key NUMBER;
125 count2 NUMBER;
126 seq NUMBER;
127 U_USER_NAME VARCHAR2(255);
128 U_ROLE_NAME VARCHAR2(255);
129 U_OWNERTABLE_NAME VARCHAR2(255);
130 table_error EXCEPTION;
131
132 begin
133
134 U_USER_NAME := UPPER(USER_NAME);
135 U_ROLE_NAME := UPPER(ROLE_NAME);
136 U_OWNERTABLE_NAME := UPPER(OWNERTABLE_NAME);
137 key := OWNERTABLE_KEY;
138
139 select count(*) into count2
140 from fnd_lookups
141 where lookup_type = 'JTF_AUTH_OWNERTABLE_NAME'
142 and lookup_code = U_OWNERTABLE_NAME;
143
144 if count2=0 then
145
146 RAISE table_error;
147
148 end if;
149
150 select count(*) into cnt
151 from fnd_user
152 where user_name=U_USER_NAME;
153
154 if cnt=0 then
155 fnd_message.set_name('JTF', 'JTF-1055');
156 app_exception.raise_exception;
157 end if;
158
159 select count(*) into cnt
160 from jtf_auth_principals_b
161 where principal_name=U_ROLE_NAME and is_user_flag=0;
162
163 if cnt=0 then
164 fnd_message.set_name('JTF', 'JTF-1056');
165 app_exception.raise_exception;
166 end if;
167
168
169 select count(*) into cnt
170 from jtf_auth_principals_b
171 where principal_name=U_USER_NAME and is_user_flag=1;
172
173 if cnt=0 then
174
175 select jtf_auth_s1.nextval into seq from dual;
176 JTF_AUTH_PRINCIPALS_PKG.INSERT_ROW(seq,seq,1,U_USER_NAME,690,null,1,0,U_USER_NAME, null, SYSDATE, 0, SYSDATE, 0, null);
177
178 end if;
179
180 select count(*) into count1
181 from jtf_auth_principal_maps c,
182 jtf_auth_principals_b a,
183 jtf_auth_domains_b d,
184 jtf_auth_principals_b b
185 where a.principal_name=U_USER_NAME and a.is_user_flag=1
186 and a.jtf_auth_principal_id=c.jtf_auth_principal_id
187 and b.principal_name=U_ROLE_NAME and b.is_user_flag=0
188 and b.jtf_auth_principal_id=c.jtf_auth_parent_principal_id
189 and d.domain_name='CRM_DOMAIN'
190 and d.jtf_auth_domain_id=c.jtf_auth_domain_id;
191
192 select jtf_auth_principal_id into p_id
193 from jtf_auth_principals_b
194 where principal_name=U_USER_NAME and is_user_flag=1;
195
196 select jtf_auth_principal_id into r_id
197 from jtf_auth_principals_b
198 where principal_name=U_ROLE_NAME and is_user_flag=0;
199
200 select jtf_auth_domain_id into d_id
201 from jtf_auth_domains_b where
202 domain_name='CRM_DOMAIN';
203
204 if count1 = 0 then
205
206 insert into jtf_auth_principal_maps (jtf_auth_principal_id,
207 jtf_auth_parent_principal_id, jtf_auth_domain_id,
208 created_by, creation_date, last_updated_by, last_update_date,
209 application_id, object_version_number) values
210 (p_id, r_id, d_id,
211 0,SYSDATE,0,SYSDATE,690,1);
212
213 end if;
214
215 select jtf_auth_s1.nextval into source_id from dual;
216
217 select jtf_auth_principal_mapping_id into mapping_id
218 from jtf_auth_principal_maps
219 where jtf_auth_principal_id = p_id
220 and jtf_auth_parent_principal_id = r_id
221 and jtf_auth_domain_id = d_id;
222
223 select count(*) into maps_sources
224 from jtf_auth_maps_sources a
225 where a.jtf_auth_principal_mapping_id = mapping_id
226 and a.ownertable_name = U_OWNERTABLE_NAME
227 and a.ownertable_key = key;
228
229 if maps_sources=0 then
230 insert into jtf_auth_maps_sources (JTF_AUTH_MAPS_SOURCE_ID,
231 JTF_AUTH_PRINCIPAL_MAPPING_ID, OWNERTABLE_NAME, OWNERTABLE_KEY,
232 CREATED_BY, CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE,
233 APPLICATION_ID, OBJECT_VERSION_NUMBER) VALUES
234 (source_id, mapping_id, U_OWNERTABLE_NAME,
235 key, 0, SYSDATE, 0, SYSDATE, 690, 1);
236 end if;
237
238 exception
239 when table_error then
240 fnd_message.set_name('JTF', 'JTF-1049');
241 app_exception.raise_exception;
242
243
244
245 end ASSIGN_ROLE;
246
247 procedure ASSIGN_ROLE (
248 USER_NAME in VARCHAR2,
249 ROLE_NAME in VARCHAR2,
250 APP_ID in NUMBER
251 ) is
252 mapping_id NUMBER;
253 p_id NUMBER;
254 r_id NUMBER;
255 d_id NUMBER;
256 source_id NUMBER;
257 cnt NUMBER;
258 count1 NUMBER;
259 maps_sources NUMBER;
260 seq NUMBER;
261 U_USER_NAME VARCHAR2(255);
262 U_ROLE_NAME VARCHAR2(255);
263 begin
264 U_USER_NAME := UPPER(USER_NAME);
265 U_ROLE_NAME := UPPER(ROLE_NAME);
266
267 select count(*) into cnt
268 from fnd_user
269 where user_name=U_USER_NAME;
270
271 if cnt=0 then
272 fnd_message.set_name('JTF', 'JTF-1055');
273 app_exception.raise_exception;
274 end if;
275
276 select count(*) into cnt
277 from jtf_auth_principals_b
278 where principal_name=U_ROLE_NAME and is_user_flag=0;
279
280 if cnt=0 then
281 fnd_message.set_name('JTF', 'JTF-1056');
282 app_exception.raise_exception;
283 end if;
284
285
286 select count(*) into cnt
287 from jtf_auth_principals_b
288 where principal_name=U_USER_NAME and is_user_flag=1;
289
290 if cnt=0 then
291
292 select jtf_auth_s1.nextval into seq from dual;
293 JTF_AUTH_PRINCIPALS_PKG.INSERT_ROW(seq,seq,1,U_USER_NAME,APP_ID,null,1,0,U_USER_NAME, null, SYSDATE, 0, SYSDATE, 0, null);
294
295 end if;
296
297 select count(*) into count1
298 from jtf_auth_principal_maps c,
299 jtf_auth_principals_b a,
300 jtf_auth_domains_b d,
301 jtf_auth_principals_b b
302 where a.principal_name=U_USER_NAME and a.is_user_flag=1
303 and a.jtf_auth_principal_id=c.jtf_auth_principal_id
304 and b.principal_name=U_ROLE_NAME and b.is_user_flag=0
305 and b.jtf_auth_principal_id=c.jtf_auth_parent_principal_id
306 and d.domain_name='CRM_DOMAIN'
307 and d.jtf_auth_domain_id=c.jtf_auth_domain_id;
308
309 select jtf_auth_principal_id into p_id
310 from jtf_auth_principals_b
311 where principal_name=U_USER_NAME and is_user_flag=1;
312
313 select jtf_auth_principal_id into r_id
314 from jtf_auth_principals_b
315 where principal_name=U_ROLE_NAME and is_user_flag=0;
316
317 select jtf_auth_domain_id into d_id
318 from jtf_auth_domains_b where
319 domain_name='CRM_DOMAIN';
320
321 if count1=0 then
322 insert into jtf_auth_principal_maps (jtf_auth_principal_id,
323 jtf_auth_parent_principal_id, jtf_auth_domain_id,
324 created_by, creation_date, last_updated_by, last_update_date,
325 application_id, object_version_number) values
326 (p_id, r_id, d_id,
327 0,SYSDATE,0,SYSDATE,APP_ID,1);
328 end if;
329
330 select jtf_auth_s1.nextval into source_id from dual;
331
332 select jtf_auth_principal_mapping_id into mapping_id
333 from jtf_auth_principal_maps
334 where jtf_auth_principal_id = p_id
335 and jtf_auth_parent_principal_id = r_id
336 and jtf_auth_domain_id = d_id;
337
338 select count(*) into maps_sources
339 from jtf_auth_maps_sources a
340 where a.jtf_auth_principal_mapping_id = mapping_id
341 and a.ownertable_name = 'JTF_AUTH_PRINCIPALS_B'
342 and a.ownertable_key = TO_CHAR(p_id);
343
344 if maps_sources=0 then
345 insert into jtf_auth_maps_sources (JTF_AUTH_MAPS_SOURCE_ID,
346 JTF_AUTH_PRINCIPAL_MAPPING_ID, OWNERTABLE_NAME, OWNERTABLE_KEY,
347 CREATED_BY, CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE,
348 APPLICATION_ID, OBJECT_VERSION_NUMBER) VALUES
349 (source_id, mapping_id, 'JTF_AUTH_PRINCIPALS_B',
350 TO_CHAR(p_id), 0, SYSDATE, 0, SYSDATE, APP_ID, 1);
351 end if;
352
353
354 end ASSIGN_ROLE;
355
356 procedure ASSIGN_ROLE (
357 USER_NAME in VARCHAR2,
358 ROLE_NAME in VARCHAR2,
359 OWNERTABLE_NAME in VARCHAR2,
360 OWNERTABLE_KEY in VARCHAR2,
361 APP_ID in NUMBER
362 ) is
363 mapping_id NUMBER;
364 p_id NUMBER;
365 r_id NUMBER;
366 d_id NUMBER;
367 source_id NUMBER;
368 cnt NUMBER;
369 count1 NUMBER;
370 count2 NUMBER;
371 maps_sources NUMBER;
372 key NUMBER;
373 seq NUMBER;
374 U_USER_NAME VARCHAR2(255);
375 U_ROLE_NAME VARCHAR2(255);
376 U_OWNERTABLE_NAME VARCHAR2(255);
377 table_error EXCEPTION;
378
379 begin
380
381 U_USER_NAME := UPPER(USER_NAME);
382 U_ROLE_NAME := UPPER(ROLE_NAME);
383 U_OWNERTABLE_NAME := UPPER(OWNERTABLE_NAME);
384 key := OWNERTABLE_KEY;
385
386 select count(*) into count2
387 from fnd_lookups
388 where lookup_type = 'JTF_AUTH_OWNERTABLE_NAME'
389 and lookup_code = U_OWNERTABLE_NAME;
390
391 if count2=0 then
392
393 RAISE table_error;
394
395 end if;
396
397 select count(*) into cnt
398 from fnd_user
399 where user_name=U_USER_NAME;
400
401 if cnt=0 then
402 fnd_message.set_name('JTF', 'JTF-1055');
403 app_exception.raise_exception;
404 end if;
405
406 select count(*) into cnt
407 from jtf_auth_principals_b
408 where principal_name=U_ROLE_NAME and is_user_flag=0;
409
410 if cnt=0 then
411 fnd_message.set_name('JTF', 'JTF-1056');
412 app_exception.raise_exception;
413 end if;
414
415
416 select count(*) into cnt
417 from jtf_auth_principals_b
418 where principal_name=U_USER_NAME and is_user_flag=1;
419
420 if cnt=0 then
421
422 select jtf_auth_s1.nextval into seq from dual;
423 JTF_AUTH_PRINCIPALS_PKG.INSERT_ROW(seq,seq,1,U_USER_NAME,APP_ID,null,1,0,U_USER_NAME, null, SYSDATE, 0, SYSDATE, 0, null);
424
425 end if;
426
427 select count(*) into count1
428 from jtf_auth_principal_maps c,
429 jtf_auth_principals_b a,
430 jtf_auth_domains_b d,
431 jtf_auth_principals_b b
432 where a.principal_name=U_USER_NAME and a.is_user_flag=1
433 and a.jtf_auth_principal_id=c.jtf_auth_principal_id
434 and b.principal_name=U_ROLE_NAME and b.is_user_flag=0
435 and b.jtf_auth_principal_id=c.jtf_auth_parent_principal_id
436 and d.domain_name='CRM_DOMAIN'
437 and d.jtf_auth_domain_id=c.jtf_auth_domain_id;
438
439 select jtf_auth_principal_id into p_id
440 from jtf_auth_principals_b
441 where principal_name=U_USER_NAME and is_user_flag=1;
442
443 select jtf_auth_principal_id into r_id
444 from jtf_auth_principals_b
445 where principal_name=U_ROLE_NAME and is_user_flag=0;
446
447 select jtf_auth_domain_id into d_id
448 from jtf_auth_domains_b where
449 domain_name='CRM_DOMAIN';
450
451 if count1 = 0 then
452
453 insert into jtf_auth_principal_maps (jtf_auth_principal_id,
454 jtf_auth_parent_principal_id, jtf_auth_domain_id,
455 created_by, creation_date, last_updated_by, last_update_date,
456 application_id, object_version_number) values
457 (p_id, r_id, d_id,
458 0,SYSDATE,0,SYSDATE,APP_ID,1);
459
460 end if;
461
462 select jtf_auth_s1.nextval into source_id from dual;
463
464 select jtf_auth_principal_mapping_id into mapping_id
465 from jtf_auth_principal_maps
466 where jtf_auth_principal_id = p_id
467 and jtf_auth_parent_principal_id = r_id
468 and jtf_auth_domain_id = d_id;
469
470 select count(*) into maps_sources
471 from jtf_auth_maps_sources a
472 where a.jtf_auth_principal_mapping_id = mapping_id
473 and a.ownertable_name = U_OWNERTABLE_NAME
474 and a.ownertable_key = key;
475
476 if maps_sources=0 then
477 insert into jtf_auth_maps_sources (JTF_AUTH_MAPS_SOURCE_ID,
478 JTF_AUTH_PRINCIPAL_MAPPING_ID, OWNERTABLE_NAME, OWNERTABLE_KEY,
479 CREATED_BY, CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE,
480 APPLICATION_ID, OBJECT_VERSION_NUMBER) VALUES
481 (source_id, mapping_id, U_OWNERTABLE_NAME,
482 key, 0, SYSDATE, 0, SYSDATE, APP_ID, 1);
483 end if;
484
485 exception
486 when table_error then
487 fnd_message.set_name('JTF', 'JTF-1049');
488 app_exception.raise_exception;
489
490
491
492 end ASSIGN_ROLE;
493
494 end JTF_AUTH_BULKLOAD_PKG;