[Home] [Help]
PACKAGE BODY: APPS.IRC_DOCUMENT_API
Source
1 Package Body IRC_DOCUMENT_API as
2 /* $Header: iridoapi.pkb 120.3.12010000.2 2008/08/05 10:48:24 ubhat ship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := 'IRC_DOCUMENT_API.';
7 g_full_mode varchar2(30) := 'FULL';
8 g_online_mode varchar2(30) := 'ONLINE';
9 g_none_mode varchar(30) :='NONE';
10 --
11 -- ----------------------------------------------------------------------------
12 -- |--------------------------< synchronize_index >-----------------------
13 -- ----------------------------------------------------------------------------
14 Procedure synchronize_index(p_mode in varchar2)
15 is
16 l_proc varchar2(72) := g_package||'synchronize_index';
17 l_hr_username fnd_oracle_userid.oracle_username%TYPE :=null ;
18 cursor csr_user is
19 select oracle_username
20 from fnd_oracle_userid
21 where oracle_id = 800;
22 begin
23 hr_utility.set_location('Entering:'|| l_proc, 10);
24 open csr_user;
25 fetch csr_user into l_hr_username;
26 close csr_user;
27 If l_hr_username is not null
28 then
29 if p_mode = g_full_mode
30 then
31 hr_utility.set_location(l_proc, 20);
32 ad_ctx_ddl.optimize_index
33 (idx_name=>l_hr_username||'.IRC_DOCUMENTS_CTX1'
34 ,optlevel=>'FULL'
35 ,maxtime=>null
36 ,token=>null);
37 elsif p_mode = g_online_mode
38 then
39 hr_utility.set_location(l_proc, 30);
40 ad_ctx_ddl.sync_index
41 (idx_name=>l_hr_username||'.IRC_DOCUMENTS_CTX1');
42 elsif p_mode = g_none_mode
43 then
44 hr_utility.set_location(l_proc, 35);
45 end if;
46 end if;
47 hr_utility.set_location('Leaving:'|| l_proc, 40);
48 exception
49 when others then
50 If csr_user%isopen
51 then
52 close csr_user;
53 End if;
54 raise;
55 end synchronize_index;
56 -- ----------------------------------------------------------------------------
57 -- |----------------------------< CREATE_DOCUMENT >---------------------------|
58 -- ----------------------------------------------------------------------------
59 --
60 procedure CREATE_DOCUMENT
61 (p_validate in boolean default false
62 ,p_effective_date in date
63 ,p_type in varchar2
64 ,p_person_id in number
65 ,p_mime_type in varchar2
66 ,p_assignment_id in number default null
67 ,p_file_name in varchar2 default null
68 ,p_description in varchar2 default null
69 ,p_end_date in date default null
70 ,p_document_id out nocopy number
71 ,p_object_version_number out nocopy number
72 ) is
73 --
74 -- Declare cursors and local variables
75 --
76 l_proc varchar2(72) := g_package||'CREATE_DOCUMENT';
77 l_effective_date date;
78 l_document_id number(15);
79 l_object_version_number number(9);
80 begin
81 hr_utility.set_location('Entering:'|| l_proc, 10);
82 --
83 -- Issue a savepoint
84 --
85 savepoint CREATE_DOCUMENT;
86 --
87 -- Truncate the time portion from all IN date parameters
88 --
89 l_effective_date := TRUNC(p_effective_date);
90
91 --
92 -- Call Before Process User Hook
93 --
94 begin
95 IRC_DOCUMENT_BK1.CREATE_DOCUMENT_b
96 (p_effective_date => l_effective_date
97 ,p_type => p_type
98 ,p_mime_type => p_mime_type
99 ,p_person_id => p_person_id
100 ,p_assignment_id => p_assignment_id
101 ,p_file_name => p_file_name
102 ,p_description => p_description
103 ,p_end_date => p_end_date
104 );
105
106 exception
107 when hr_api.cannot_find_prog_unit then
108 hr_api.cannot_find_prog_unit_error
109 (p_module_name => 'CREATE_DOCUMENT'
110 ,p_hook_type => 'BP'
111 );
112 end;
113 --
114 -- Process Logic
115 --
116 irc_ido_ins.ins
117 (p_effective_date => l_effective_date
118 ,p_person_id => p_person_id
119 ,p_mime_type => p_mime_type
120 ,p_type => p_type
121 ,p_assignment_id => p_assignment_id
122 ,p_character_doc => empty_clob()
123 ,p_file_name => p_file_name
124 ,p_description => p_description
125 ,p_document_id => l_document_id
126 ,p_parsed_xml => empty_clob()
127 ,p_object_version_number => l_object_version_number
128 ,p_end_date => p_end_date
129 );
130 --
131 -- Call After Process User Hook
132 --
133 begin
134 IRC_DOCUMENT_BK1.CREATE_DOCUMENT_a
135 (p_effective_date => l_effective_date
136 ,p_type => p_type
137 ,p_mime_type => p_mime_type
138 ,p_person_id => p_person_id
139 ,p_assignment_id => p_assignment_id
140 ,p_file_name => p_file_name
141 ,p_description => p_description
142 ,p_document_id => l_document_id
143 ,p_object_version_number => l_object_version_number
144 ,p_end_date => p_end_date
145 );
146
147 exception
148 when hr_api.cannot_find_prog_unit then
149 hr_api.cannot_find_prog_unit_error
150 (p_module_name => 'CREATE_DOCUMENT'
151 ,p_hook_type => 'AP'
152 );
153 end;
154 --
155 -- When in validation only mode raise the Validate_Enabled exception
156 --
157 if p_validate then
158 raise hr_api.validate_enabled;
159 end if;
160 --
161 -- Set all output arguments
162 --
163 p_document_id := l_document_id;
164 p_object_version_number := l_object_version_number;
165 hr_utility.set_location(' Leaving:'||l_proc, 70);
166 exception
167 when hr_api.validate_enabled then
168 --
169 -- As the Validate_Enabled exception has been raised
170 -- we must rollback to the savepoint
171 --
172 rollback to CREATE_DOCUMENT;
173 --
174 -- Only set output warning arguments
175 -- (Any key or derived arguments must be set to null
176 -- when validation only mode is being used.)
177 --
178 p_document_id := null;
179 p_object_version_number := null;
180 hr_utility.set_location(' Leaving:'||l_proc, 80);
181 when others then
182 --
183 -- A validation or unexpected error has occured
184 --
185 rollback to CREATE_DOCUMENT;
186 -- Reset IN OUT Parameters and set OUT parameters
187 --
188 p_document_id := null;
189 p_object_version_number := null;
190 --
191 hr_utility.set_location(' Leaving:'||l_proc, 90);
192 raise;
193 end CREATE_DOCUMENT;
194 --
195 --
196 -- ----------------------------------------------------------------------------
197 -- |----------------------------< UPDATE_DOCUMENT >---------------------------|
198 -- ----------------------------------------------------------------------------
199 --
200 procedure UPDATE_DOCUMENT
201 (p_validate in boolean default false
202 ,p_effective_date in date
203 ,p_document_id in number
204 ,p_mime_type in varchar2 default HR_API.G_VARCHAR2
205 ,p_type in varchar2 default HR_API.G_VARCHAR2
206 ,p_file_name in varchar2 default HR_API.G_VARCHAR2
207 ,p_description in varchar2 default HR_API.G_VARCHAR2
208 ,p_object_version_number in out nocopy number
209 ) is
210 --
211 -- Declare cursors and local variables
212 --
213 l_proc varchar2(72) := g_package||'CREATE_DOCUMENT';
214 l_effective_date date;
215 l_object_version_number number(9);
216 l_new_doc_id irc_documents.document_id%type;
217 l_party_id irc_documents.party_id%type;
218 l_assignment_id irc_documents.assignment_id%type;
219 l_person_id irc_documents.person_id%type;
220 l_end_date date;
221
222
223 --
224 -- Define cursor to fetch the document record
225 --
226 cursor csr_document_record Is
227 select
228 party_id,
229 assignment_id,
230 person_id
231 from irc_documents
232 where document_id = p_document_id;
233
234 l_doc_record csr_document_record%ROWTYPE;
235
236 begin
237 hr_utility.set_location('Entering:'|| l_proc, 10);
238 --
239 -- Issue a savepoint
240 --
241 savepoint UPDATE_DOCUMENT;
242 --
243 -- Truncate the time portion from all IN date parameters
244 --
245 l_effective_date := TRUNC(p_effective_date);
246
247 --open the cursor and fetch the document record
248 open csr_document_record;
249 fetch csr_document_record into l_doc_record;
250 close csr_document_record;
251 --
252 --
253 l_party_id := l_doc_record.party_id;
254 l_assignment_id := l_doc_record.assignment_id;
255 l_person_id := l_doc_record.person_id;
256 --
257
258 --
259 -- Call Before Process User Hook
260 --
261 begin
262 IRC_DOCUMENT_BK2.UPDATE_DOCUMENT_b
263 (p_effective_date => l_effective_date
264 ,p_document_id => p_document_id
265 ,p_type => p_type
266 ,p_mime_type => p_mime_type
267 ,p_file_name => p_file_name
268 ,p_description => p_description
269 ,p_object_version_number => p_object_version_number
270 );
271
272 exception
273 when hr_api.cannot_find_prog_unit then
274 hr_api.cannot_find_prog_unit_error
275 (p_module_name => 'UPDATE_DOCUMENT'
276 ,p_hook_type => 'BP'
277 );
278 end;
279 --
280 -- Process Logic
281 --
282 l_object_version_number := p_object_version_number;
283 update_document_track
284 ( p_validate => p_validate
285 ,p_effective_date => l_effective_date
286 ,p_document_id => p_document_id
287 ,p_mime_type => p_mime_type
288 ,p_type => p_type
289 ,p_file_name => p_file_name
290 ,p_description => p_description
291 ,p_person_id => l_person_id
292 ,p_party_id => l_party_id
293 ,p_end_date => l_end_date
294 ,p_assignment_id => l_assignment_id
295 ,p_object_version_number => l_object_version_number
296 ,p_new_doc_id => l_new_doc_id
297 );
298
299 --
300 -- Call After Process User Hook
301 --
302 begin
303 IRC_DOCUMENT_BK2.UPDATE_DOCUMENT_a
304 (p_effective_date => l_effective_date
305 ,p_document_id => p_document_id
306 ,p_type => p_type
307 ,p_mime_type => p_mime_type
308 ,p_file_name => p_file_name
309 ,p_description => p_description
310 ,p_object_version_number => p_object_version_number
311 );
312
313 exception
314 when hr_api.cannot_find_prog_unit then
315 hr_api.cannot_find_prog_unit_error
316 (p_module_name => 'UPDATE_DOCUMENT'
317 ,p_hook_type => 'AP'
318 );
319 end;
320 --
321 -- When in validation only mode raise the Validate_Enabled exception
322 --
323 if p_validate then
324 raise hr_api.validate_enabled;
325 end if;
326 --
327 -- Set all output arguments
328 --
329 p_object_version_number := l_object_version_number;
330 hr_utility.set_location(' Leaving:'||l_proc, 70);
331 exception
332 when hr_api.validate_enabled then
333 --
334 -- As the Validate_Enabled exception has been raised
335 -- we must rollback to the savepoint
336 --
337 rollback to UPDATE_DOCUMENT;
338 --
339 -- Only set output warning arguments
340 -- (Any key or derived arguments must be set to null
341 -- when validation only mode is being used.)
342 --
343 p_object_version_number := l_object_version_number;
344 hr_utility.set_location(' Leaving:'||l_proc, 80);
345 when others then
346 --
347 -- A validation or unexpected error has occured
348 --
349 rollback to UPDATE_DOCUMENT;
350 --
351 p_object_version_number := l_object_version_number;
352 hr_utility.set_location(' Leaving:'||l_proc, 90);
353 raise;
354 end UPDATE_DOCUMENT;
355 --
356 --
357 -- ----------------------------------------------------------------------------
358 -- |----------------------------< UPDATE_DOCUMENT_TRACK >---------------------|
359 -- ----------------------------------------------------------------------------
360 --
361 procedure UPDATE_DOCUMENT_TRACK
362 (p_validate in boolean default false
363 ,p_effective_date in date
364 ,p_document_id in number
365 ,p_mime_type in varchar2 default HR_API.G_VARCHAR2
366 ,p_type in varchar2 default HR_API.G_VARCHAR2
367 ,p_file_name in varchar2 default HR_API.G_VARCHAR2
368 ,p_description in varchar2 default HR_API.G_VARCHAR2
369 ,p_person_id in number default HR_API.G_NUMBER
370 ,p_party_id in number default HR_API.G_NUMBER
371 ,p_end_date in date default HR_API.G_DATE
372 ,p_assignment_id in number default HR_API.G_NUMBER
373 ,p_object_version_number in out nocopy number
374 ,p_new_doc_id out nocopy number
375 ) is
376 --
377 -- Declare cursors and local variables
378 --
379 l_proc varchar2(72) := g_package||'UPDATE_DOCUMENT';
380 l_effective_date date;
381 l_object_version_number number(9);
382 --
383 l_job_appln number := 0;
384 --
385 l_end_date date; --to populate end_date in irc_documents table for internet applicants
386 --
387 l_mime_type irc_documents.mime_type%type := HR_API.G_VARCHAR2;
388 l_type irc_documents.type%type := HR_API.G_VARCHAR2;
389 l_file_name irc_documents.file_name%type := HR_API.G_VARCHAR2;
390 l_description irc_documents.description%type := HR_API.G_VARCHAR2;
391 l_new_doc_id irc_documents.document_id%type;
392 l_doc_id irc_documents.document_id%type;
393 l_obj_version_number number(9);
394
395
396 begin
397 hr_utility.set_location('Entering:'|| l_proc, 10);
398 --
399 hr_utility.set_location('call function is_internet_applicant: '|| p_party_id || ' '|| l_proc, 115);
400 --
401 is_internet_applicant( p_document_id => p_document_id,
402 p_person_id => p_person_id ,
403 p_party_id => p_party_id ,
404 p_num_job_applications => l_job_appln);
405
406 --
407 hr_utility.set_location('leave function is_internet_applicant: job applications: '|| to_char(l_job_appln), 116);
408 --
409 If ((l_job_appln > 0) and (p_type In ('RESUME','AUTO_RESUME')) ) Then
413 --Date And Then create a new Document record with the new Resume he has uploaded
410 begin --begin For update when it Is an Internet Applicant
411
412 --The Applicant Is an Internet Applicant, so first update his existing Document record with an End
414 begin --begin For updating End Date And creating new Document record
415 --
416 -- Issue a savepoint
417 --
418 savepoint UPDATE_DOCUMENT_TRACK;
419 --
420 -- Truncate the time portion from all IN date parameters
421 --
422 l_effective_date := TRUNC(p_effective_date);
423 --
424 l_end_date := TRUNC(sysdate);
425
426
427 --
428 -- Call Before Process User Hook
429 --
430 begin
431 IRC_DOCUMENT_BK4.UPDATE_DOCUMENT_TRACK_b
432 (p_effective_date => l_effective_date
433 ,p_document_id => p_document_id
434 ,p_type => p_type
435 ,p_mime_type => p_mime_type
436 ,p_file_name => p_file_name
437 ,p_description => p_description
438 ,p_person_id => p_person_id
439 ,p_party_id => p_party_id
440 ,p_assignment_id => p_assignment_id
441 ,p_object_version_number => p_object_version_number
442 ,p_end_date => l_end_date
443 );
444
445 exception
446 when hr_api.cannot_find_prog_unit then
447 hr_api.cannot_find_prog_unit_error
448 (p_module_name => 'UPDATE_DOCUMENT_TRACK'
449 ,p_hook_type => 'BP'
450 );
451 end;
452 --
453 -- Process Logic
454 --
455 l_object_version_number := p_object_version_number;
456 irc_ido_upd.upd
457 (p_effective_date => l_effective_date
458 ,p_mime_type => l_mime_type
459 ,p_type => l_type
460 ,p_file_name => l_file_name
461 ,p_description => l_description
462 ,p_document_id => p_document_id
463 ,p_object_version_number => l_object_version_number
464 ,p_end_date => l_end_date
465 );
466 --
467 -- Call After Process User Hook
468 --
469 begin
470 IRC_DOCUMENT_BK4.UPDATE_DOCUMENT_TRACK_a
471 (p_effective_date => l_effective_date
472 ,p_document_id => p_document_id
473 ,p_type => p_type
474 ,p_mime_type => p_mime_type
475 ,p_file_name => p_file_name
476 ,p_description => p_description
477 ,p_person_id => p_person_id
478 ,p_party_id => p_party_id
479 ,p_assignment_id => p_assignment_id
480 ,p_object_version_number => p_object_version_number
481 ,p_end_date => l_end_date
482 );
483
484 exception
485 when hr_api.cannot_find_prog_unit then
486 hr_api.cannot_find_prog_unit_error
487 (p_module_name => 'UPDATE_DOCUMENT_TRACK'
488 ,p_hook_type => 'AP'
489 );
490 end;
491 --
492
493 --Select the Document id from the db sequence
494 --
495 begin
496 select irc_documents_s.nextval
497 into l_new_doc_id
498 from dual;
499 end;
500 --
501 --Call the setbase key value procedure In the row handler
502 --
503 irc_ido_ins.set_base_key_value
504 (p_document_id => l_new_doc_id
505 );
506 --
507
508 hr_utility.set_location('call create_document to create new record'||l_proc,117);
509 --
510 create_document
511 (p_validate => p_validate
512 ,p_effective_date => p_effective_date
513 ,p_type => p_type
514 ,p_person_id => p_person_id
515 ,p_mime_type => p_mime_type
516 ,p_assignment_id => p_assignment_id
517 ,p_file_name => p_file_name
518 ,p_description => p_description
519 ,p_end_date => p_end_date
520 ,p_document_id => l_doc_id
521 ,p_object_version_number => l_obj_version_number );
522 --
523 hr_utility.set_location('end call create_document to create new record'||l_proc,118);
524 --
525 -- When in validation only mode raise the Validate_Enabled exception
526 --
527 if p_validate then
528 raise hr_api.validate_enabled;
529 end if;
530 --
531 -- Set all output arguments
532 --
533 p_object_version_number := l_obj_version_number;
534 p_new_doc_id := l_new_doc_id;
535 hr_utility.set_location(' Leaving:'||l_proc, 70);
536 --
537 exception
538 when hr_api.validate_enabled then
539 --
540 -- As the Validate_Enabled exception has been raised
541 -- we must rollback to the savepoint
542 --
543 rollback to UPDATE_DOCUMENT_TRACK;
544 --
545 -- Only set output warning arguments
546 -- (Any key or derived arguments must be set to null
547 -- when validation only mode is being used.)
548 --
552 when others then
549 p_object_version_number := l_obj_version_number;
550 p_new_doc_id := l_new_doc_id;
551 hr_utility.set_location(' Leaving:'||l_proc, 80);
553 --
554 -- A validation or unexpected error has occured
555 --
556 rollback to UPDATE_DOCUMENT_TRACK;
557 --
558 p_object_version_number := l_obj_version_number;
559 p_new_doc_id := l_new_doc_id;
560 hr_utility.set_location(' Leaving:'||l_proc, 90);
561 raise;
562 end; --End For updating End Date And creating new Document record
563 --
564
565 End;--End For when it Is an Internet Applicant
566 Else
567 begin --begin when the applicant Is Not an Internet Applicant
568 --
569 begin --begin 1
570 --
571 -- Issue a savepoint
572 --
573 savepoint UPDATE_DOCUMENT_TRACK;
574 --
575 -- Truncate the time portion from all IN date parameters
576 --
577 l_effective_date := TRUNC(p_effective_date);
578
579 --
580 -- Call Before Process User Hook
581 --
582 begin
583 IRC_DOCUMENT_BK4.UPDATE_DOCUMENT_TRACK_b
584 (p_effective_date => l_effective_date
585 ,p_document_id => p_document_id
586 ,p_type => p_type
587 ,p_mime_type => p_mime_type
588 ,p_file_name => p_file_name
589 ,p_description => p_description
590 ,p_person_id => p_person_id
591 ,p_party_id => p_party_id
592 ,p_assignment_id => p_assignment_id
593 ,p_object_version_number => p_object_version_number
594 ,p_end_date => p_end_date
595 );
596
597 exception
598 when hr_api.cannot_find_prog_unit then
599 hr_api.cannot_find_prog_unit_error
600 (p_module_name => 'UPDATE_DOCUMENT_TRACK'
601 ,p_hook_type => 'BP'
602 );
603 end;
604 --
605 -- Process Logic
606 --
607 l_object_version_number := p_object_version_number;
608 irc_ido_upd.upd
609 (p_effective_date => l_effective_date
610 ,p_mime_type => p_mime_type
611 ,p_type => p_type
612 ,p_file_name => p_file_name
613 ,p_description => p_description
614 ,p_document_id => p_document_id
615 ,p_object_version_number => l_object_version_number
616 ,p_end_date => p_end_date
617 );
618 --
619 -- Call After Process User Hook
620 --
621 begin
622 IRC_DOCUMENT_BK4.UPDATE_DOCUMENT_TRACK_a
623 (p_effective_date => l_effective_date
624 ,p_document_id => p_document_id
625 ,p_type => p_type
626 ,p_mime_type => p_mime_type
627 ,p_file_name => p_file_name
628 ,p_description => p_description
629 ,p_person_id => p_person_id
630 ,p_party_id => p_party_id
631 ,p_assignment_id => p_assignment_id
632 ,p_object_version_number => p_object_version_number
633 ,p_end_date => p_end_date
634 );
635
636 exception
637 when hr_api.cannot_find_prog_unit then
638 hr_api.cannot_find_prog_unit_error
639 (p_module_name => 'UPDATE_DOCUMENT_TRACK'
640 ,p_hook_type => 'AP'
641 );
642 end;
643 --
644 -- When in validation only mode raise the Validate_Enabled exception
645 --
646 if p_validate then
647 raise hr_api.validate_enabled;
648 end if;
649 --
650 -- Set all output arguments
651 --
652 p_object_version_number := l_object_version_number;
653 p_new_doc_id := p_document_id;
654 hr_utility.set_location(' Leaving:'||l_proc, 70);
655 exception
656 when hr_api.validate_enabled then
657 --
658 -- As the Validate_Enabled exception has been raised
659 -- we must rollback to the savepoint
660 --
661 rollback to UPDATE_DOCUMENT_TRACK;
662 --
663 -- Only set output warning arguments
664 -- (Any key or derived arguments must be set to null
665 -- when validation only mode is being used.)
666 --
667 p_object_version_number := l_object_version_number;
668 p_new_doc_id := p_document_id;
669 hr_utility.set_location(' Leaving:'||l_proc, 80);
670 when others then
671 --
672 -- A validation or unexpected error has occured
673 --
674 rollback to UPDATE_DOCUMENT_TRACK;
675 --
676 p_object_version_number := l_object_version_number;
677 p_new_doc_id := p_document_id;
678 hr_utility.set_location(' Leaving:'||l_proc, 90);
679 raise;
680 end; --End 1
681 --
682
683 end; --End For when the Applicant Is Not an Internet Applicant
684 End if;
685 --
686 end UPDATE_DOCUMENT_TRACK;
687 --
688 --
689 -- ----------------------------------------------------------------------------
693 procedure DELETE_DOCUMENT
690 -- |----------------------------< DELETE_DOCUMENT >---------------------------|
691 -- ----------------------------------------------------------------------------
692 --
694 (p_validate in boolean default false
695 ,p_effective_date in date
696 ,p_document_id in number
697 ,p_object_version_number in number
698 ,p_person_id in number
699 ,p_party_id in number
700 ,p_end_date in date
701 ,p_type in varchar2
702 ,p_purge in varchar2 default 'N'
703 ) is
704 --
705 -- Declare cursors and local variables
706 --
707 l_effective_date date;
708 l_proc varchar2(72) := g_package||'DELETE_DOCUMENT';
709
710 --
711 l_end_date date;
712 --
713 l_job_applications number := 0;
714 --
715 l_object_version_number number;
716 --
717 l_doc_id number;
718 --
719 begin
720 hr_utility.set_location('Entering:'|| l_proc, 10);
721 --
722 --
723 -- Issue a savepoint
724 --
725 savepoint DELETE_DOCUMENT;
726 --
727 --
728 -- Truncate the time portion from all IN date parameters
729 --
730 l_effective_date := TRUNC(p_effective_date);
731 --
732 --
733 l_end_date := TRUNC(sysdate);
734 --
735 l_object_version_number := p_object_version_number;
736 --
737 hr_utility.set_location('call function is_internet_applicant: '|| p_party_id || ' '|| l_proc, 111);
738 --
739 is_internet_applicant( p_document_id => p_document_id,
740 p_person_id => p_person_id ,
741 p_party_id => p_party_id ,
742 p_num_job_applications => l_job_applications);
743
744
745 --
746 hr_utility.set_location('leave function is_internet_applicant: job applications: '|| to_char(l_job_applications), 112);
747 --
748
749 --
750 --
751 -- Call Before Process User Hook
752 --
753 begin
754 IRC_DOCUMENT_BK3.DELETE_DOCUMENT_b
755 (p_document_id => p_document_id
756 ,p_effective_date => l_effective_date
757 ,p_object_version_number => p_object_version_number
758 ,p_person_id => p_person_id
759 ,p_party_id => p_party_id
760 ,p_end_date => p_end_date
761 ,p_type => p_type
762 ,p_purge => p_purge
763 );
764
765 exception
766 when hr_api.cannot_find_prog_unit then
767 hr_api.cannot_find_prog_unit_error
768 (p_module_name => 'DELETE_DOCUMENT'
769 ,p_hook_type => 'BP'
770 );
771 end;
772 --
773
774 --check If the applicant Is an Internet Applicant
775 --Active application In any of the BG which has Applicant Tracking enabled
776 --Call the Function is_internet_applicant which returns True If the above
777 --condition Is true
778 If ((p_purge = 'N') and (l_job_applications > 0) and (p_type In ('RESUME','AUTO_RESUME')) ) Then
779 begin
780 hr_utility.set_location('call update document: '||l_proc,113);
781 --call the update document rowhandler to update the end_date for the document
782 irc_ido_upd.upd
783 (p_effective_date => l_effective_date
784 ,p_type => p_type
785 ,p_document_id => p_document_id
786 ,p_object_version_number => l_object_version_number
787 ,p_end_date => l_end_date
788 );
789
790 end;
791 else
792 begin
793 -- Process Logic
794 --
795 irc_ido_del.del
796 (p_document_id => p_document_id
797 ,p_object_version_number => p_object_version_number
798 );
799 --
800 end;
801 end if;
802
803
804 -- Call After Process User Hook
805 --
806 begin
807 IRC_DOCUMENT_BK3.DELETE_DOCUMENT_a
808 (p_document_id => p_document_id
809 ,p_effective_date => l_effective_date
810 ,p_object_version_number => p_object_version_number
811 ,p_person_id => p_person_id
812 ,p_party_id => p_party_id
813 ,p_end_date => p_end_date
814 ,p_type => p_type
815 ,p_purge => p_purge
816 );
817
818 exception
819 when hr_api.cannot_find_prog_unit then
820 hr_api.cannot_find_prog_unit_error
821 (p_module_name => 'DELETE_DOCUMENT'
822 ,p_hook_type => 'AP'
823 );
824
825 end;
826
827 if p_validate then
828 raise hr_api.validate_enabled;
829 end if;
830
831 hr_utility.set_location(' Leaving:'||l_proc, 70);
832
833 exception
834 when hr_api.validate_enabled then
835 --
836 -- As the Validate_Enabled exception has been raised
837 -- we must rollback to the savepoint
838 --
839 rollback to DELETE_DOCUMENT;
843 -- A validation or unexpected error has occured
840 hr_utility.set_location(' Leaving:'||l_proc, 80);
841 when others then
842 --
844 --
845 rollback to DELETE_DOCUMENT;
846 hr_utility.set_location(' Leaving:'||l_proc, 90);
847 raise;
848
849
850 end DELETE_DOCUMENT;
851 --
852 --
853 -- ----------------------------------------------------------------------------
854 -- |---------------------------< PROCESS_DOCUMENT >---------------------------|
855 -- ----------------------------------------------------------------------------
856 --
857 procedure PROCESS_DOCUMENT
858 (p_document_id in number
859 ) IS
860 --
861 l_proc varchar2(72) := g_package||'PROCESS_DOCUMENT';
862 --
863 -- Cursor to ensure row exists in table.
864 cursor csr_doc_exists(p_document_id number) is
865 select rowid
866 from irc_documents
867 where document_id = p_document_id;
868 --
869 l_hr_username fnd_oracle_userid.oracle_username%TYPE :=null;
870 cursor csr_user is
871 select oracle_username
872 from fnd_oracle_userid
873 where oracle_id = 800;
874 --
875 l_rowid rowid;
876 --
877 clob_doc clob;
878 --
879 l_ret varchar2(30);
880 begin
881 --
882 hr_utility.set_location(' Entering:'||l_proc, 10);
883 --
884 open csr_user;
885 fetch csr_user into l_hr_username;
886 close csr_user;
887 --
888 If l_hr_username is not null -- enter if product is found
889 then
890 -- Ensure doc exists, if not raise error.
891 open csr_doc_exists(p_document_id);
892 fetch csr_doc_exists into l_rowid;
893 If csr_doc_exists%found then
894 close csr_doc_exists;
895 --
896 -- Convert document
897 ctx_doc.filter(index_name => l_hr_username || '.IRC_DOCUMENTS_CTX',
898 textkey => l_rowid,
899 restab => clob_doc,
900 plaintext => true);
901 --
902 irc_ido_shd.g_api_dml := true; -- Set the api dml status
903 --
904 update irc_documents
905 set character_doc = clob_doc
906 where document_id = p_document_id;
907 --
908 irc_ido_shd.g_api_dml := false; -- Unset the api dml status
909 --
910 hr_utility.set_location(l_proc||' - BLOB Conversion Complete', 20);
911 --
912 -- Synchronize interMedia index
913 hr_utility.set_location(l_proc||' - Synchronization Complete', 30);
914 --
915 else
916 close csr_doc_exists;
917 hr_utility.set_message(800, 'IRC_412046_IDO_INV_DOC_ID');
918 hr_utility.raise_error;
919 end if;
920 end if; -- End if for l_hr_username is not null
921 hr_utility.set_location(' Leaving:'||l_proc, 40);
922 --
923 exception
924 when others then
925 If csr_user%isopen
926 then
927 close csr_user;
928 End if;
929 If csr_doc_exists%isopen
930 then
931 close csr_doc_exists;
932 End if;
933 if(fnd_log.test(fnd_log.level_error,'per.irc_document_api.process_document')) then
934 hr_utility.log_at_error_level('per'
935 ,'irc_document_api.process_document'
936 ,'unable to process'
937 ,dbms_utility.format_error_stack);
938 end if;
939 fnd_message.set_name('PER', 'IRC_UNABLE_TO_INDEX_DOC');
940 fnd_msg_pub.add_detail
941 (p_message_type => 'I'
942 );
943 end process_document;
944 --
945 function get_html_preview
946 (p_document_id in number,p_highlight_string in varchar2 default null) return clob is
947 cursor get_schema_name is
948 select oracle_username
949 from fnd_oracle_userid
950 where oracle_id = 800;
951
952 cursor csr_doc_exists is
953 select rowid
954 from irc_documents
955 where document_id = p_document_id;
956 cursor csr_doc_type is
957 select file_name
958 from irc_documents
959 where document_id = p_document_id;
960
961 l_rowid rowid;
962 l_schema_name varchar2(20) := null;
963 l_output_clob clob := null;
964 l_file_name IRC_DOCUMENTS.FILE_NAME%type;
965 l_type varchar2(10);
966 begin
967 open csr_doc_exists;
968 fetch csr_doc_exists into l_rowid;
969 if (csr_doc_exists%found) then
970 close csr_doc_exists;
971
972 open get_schema_name;
973 fetch get_schema_name into l_schema_name;
974 if (get_schema_name%found) then
975 close get_schema_name;
976 -- Highlight the keywords if highlight string is null
977 if (trim(p_highlight_string) is not null) then
978 CTX_DOC.MARKUP (index_name => l_schema_name||'.IRC_DOCUMENTS_CTX' ,
982 plaintext => FALSE,
979 textkey => l_rowid,
980 text_query => p_highlight_string,
981 restab => l_output_clob,
983 tagset => 'HTML_DEFAULT',
984 starttag => IRC_MARKUP_STARTTAG,
985 endtag => IRC_MARKUP_ENDTAG);
986
987 -- IF keyword is null then generate html version without markup
988 else
989 ctx_doc.filter(index_name => l_schema_name||'.IRC_DOCUMENTS_CTX',
990 textkey => l_rowid,
991 restab => l_output_clob,
992 plaintext => false);
993 end if;
994 open csr_doc_type;
995 fetch csr_doc_type into l_file_name;
996 if(csr_doc_type%found) then
997 l_type := lower(substr(l_file_name,- 4));
998 if(l_type = '.pdf') then
999 ame_util.runtimeexception('IRC_DOCUMENT_API','get_html_preview',-9999,'Adding the customizations');
1000 l_output_clob := '<br id="pdfBr"/><div style="position:relative" id="pdfHtmlDoc">' || l_output_clob;
1001 l_output_clob := l_output_clob || '</div><script>
1002 function getRealTop(mChildIn,maxTop)
1003 {
1004 var childMarker=mChildIn.childCount
1005 if(childMarker!=undefined)
1006 {
1007 for (m=0;m<childMarker ;m++ )
1008 {
1009 var m_ChildIn=mChildIn.childNodes[m];
1010 maxTop=getRealTop(m_ChildIn);
1011 }
1012 }
1013 var m_Top=mChildIn.offsetTop
1014 if(m_Top !=undefined)
1015 {
1016 var m_Height=mChildIn.offsetHeight;
1017 if(m_Height!=undefined)
1018 {
1019 m_Top=m_Top+m_Height;
1020 }
1021 if(m_Top>maxTop)
1022 {
1023 maxTop=m_Top;
1024 }
1025 }
1026 return maxTop;
1027 }
1028 var divElement=document.getElementById("pdfHtmlDoc")
1029 var brTop=document.getElementById("pdfBr").offsetTop
1030 var brHeight=document.getElementById("pdfBr").offsetHeight
1031 var maxTop=0
1032 for (i=0;i<divElement.childNodes.length;i++)
1033 {
1034 var mchild=divElement.childNodes[i]
1035 maxTop=getRealTop(mchild,maxTop);
1036 }
1037 if(maxTop>brTop)
1038 {
1039 var mLength=Math.ceil((maxTop)/(brHeight-1));
1040 for (j=0;j<=mLength ;j++ )
1041 {
1042 document.writeln("<br/>")
1043 }
1044 document.writeln("<br/>")
1045 }</script>';
1046 ame_util.runtimeexception('IRC_DOCUMENT_API','get_html_preview',-9999,'Added the customizations');
1047 end if;
1048 end if;
1049 close csr_doc_type;
1050 else
1051 close get_schema_name;
1052 end if;
1053 else
1054 close csr_doc_exists;
1055 hr_utility.set_message(800, 'IRC_412046_IDO_INV_DOC_ID');
1056 hr_utility.raise_error;
1057 end if;
1058
1059 return l_output_clob;
1060 exception
1061 when others then
1062 if(fnd_log.test(fnd_log.level_error,'per.irc_document_api.get_html_preview')) then
1063 hr_utility.log_at_error_level('per'
1064 ,'irc_document_api.get_html_preview'
1065 ,'unable to preview'
1066 ,dbms_utility.format_error_stack);
1067 end if;
1068 hr_utility.log_at_error_level('per','get_html_preview','unable to preview'
1069 ,dbms_utility.format_error_stack);
1070 fnd_message.set_name('PER', 'IRC_UNABLE_TO_PREVIEW_DOC');
1071 fnd_msg_pub.add_detail
1072 (p_message_type => 'W'
1073 );
1074 return l_output_clob;
1075
1076 end get_html_preview;
1077
1078 procedure is_internet_applicant
1079 ( p_document_id in number,
1080 p_person_id in number,
1081 p_party_id in number,
1082 p_num_job_applications out nocopy number)
1083 Is
1084
1085 --
1086 l_num_job_applications number := 0;
1087 --
1088
1089 cursor csr_internet_applicant
1090 Is
1091 select count(pasf.person_id)
1092 from per_all_people_f paf,
1093 per_all_assignments_f pasf
1094 where
1095 paf.party_id = p_party_id
1096 and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
1097 and trunc(sysdate) between pasf.effective_start_date and pasf.effective_end_date
1098 and pasf.person_id = paf.person_id
1099 and pasf.business_group_id in ( select bginfo.organization_id from hr_organization_information bginfo
1100 where bginfo.ORG_INFORMATION_CONTEXT = 'BG Recruitment'
1101 and bginfo.org_information11 = 'Y'
1102 );
1103 begin
1104
1105 open csr_internet_applicant;
1106 fetch csr_internet_applicant into l_num_job_applications;
1107
1108 close csr_internet_applicant;
1109
1110
1111 p_num_job_applications := l_num_job_applications;
1112
1113
1114 End is_internet_applicant;
1115
1116
1117 end IRC_DOCUMENT_API;