[Home] [Help]
PACKAGE BODY: APPS.HXC_APPLICATION_SET_API
Source
1 Package Body hxc_application_set_api as
2 /* $Header: hxcapsapi.pkb 120.2 2005/09/23 08:05:28 sechandr noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := ' hxc_application_set_api.';
7
8 g_entity_type varchar2(16) := 'TIME_RECIPIENTS';
9 g_debug boolean :=hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |-----------------------< create_application_set >------------------------|
13 -- ----------------------------------------------------------------------------
14 --
15 procedure create_application_set
16 (p_validate in boolean default false
17 ,p_application_set_id in out nocopy number
18 ,p_object_version_number in out nocopy number
19 ,p_name in varchar2
20 ) is
21 --
22 -- Declare cursors and local variables
23 --
24 l_proc varchar2(72);
25 l_object_version_number hxc_entity_groups.object_version_number%TYPE;
26 l_application_set_id hxc_entity_groups.entity_group_id%TYPE;
27 --
28 begin
29 --
30 g_debug:=hr_utility.debug_enabled;
31 --
32 if g_debug then
33 l_proc := g_package||' create_application_set';
34 hr_utility.set_location('Entering:'|| l_proc, 10);
35 end if;
36 --
37 -- Issue a savepoint if operating in validation only mode
38 --
39 savepoint create_application_set;
40 --
41 hxc_application_set_api.chk_name
42 ( p_name => p_name
43 , p_entity_group_id => p_application_set_id );
44
45 if g_debug then
46 hr_utility.set_location(l_proc, 20);
47 end if;
48 --
49 -- Call Before Process User Hook
50 --
51 begin
52 hxc_application_set_BK_1.create_application_set_b
53 (p_application_set_id => p_application_set_id
54 ,p_object_version_number => p_object_version_number
55 ,p_name => p_name
56 );
57 exception
58 when hr_api.cannot_find_prog_unit then
59 hr_api.cannot_find_prog_unit_error
60 (p_module_name => 'create_application_set'
61 ,p_hook_type => 'BP'
62 );
63 end;
64 --
65 if g_debug then
66 hr_utility.set_location(l_proc, 30);
67 end if;
68 --
69 -- Process Logic
70 --
71 --
72 if g_debug then
73 hr_utility.set_location(l_proc, 40);
74 end if;
75 --
76 -- call row handler
77 --
78 hxc_heg_ins.ins (
79 p_name => p_name
80 ,p_entity_type => g_entity_type
81 ,p_entity_group_id => l_application_set_id
82 ,p_object_version_number => l_object_version_number );
83 --
84 if g_debug then
85 hr_utility.set_location(l_proc, 50);
86 end if;
87 --
88 -- Call After Process User Hook
89 --
90 begin
91 hxc_application_set_BK_1.create_application_set_a
92 (p_application_set_id => l_application_set_id
93 ,p_object_version_number => l_object_version_number
94 ,p_name => p_name
95 );
96 exception
97 when hr_api.cannot_find_prog_unit then
98 hr_api.cannot_find_prog_unit_error
99 (p_module_name => 'create_application_set'
100 ,p_hook_type => 'AP'
101 );
102 end;
103 --
104 if g_debug then
105 hr_utility.set_location(l_proc, 60);
106 end if;
107 --
108 -- When in validation only mode raise the Validate_Enabled exception
109 --
110 if p_validate then
111 raise hr_api.validate_enabled;
112 end if;
113 --
114 if g_debug then
115 hr_utility.set_location(' Leaving:'||l_proc, 70);
116 end if;
117 --
118 -- Set all output arguments
119 --
120 p_application_set_id := l_application_set_id;
121 p_object_version_number := l_object_version_number;
122 --
123 exception
124 --
125 when hr_api.validate_enabled then
126 --
127 -- As the Validate_Enabled exception has been raised
128 -- we must rollback to the savepoint
129 --
130 ROLLBACK TO create_application_set;
131 --
132 -- Only set output warning arguments
133 -- (Any key or derived arguments must be set to null
134 -- when validation only mode is being used.)
135 --
136 p_application_set_id := null;
137 p_object_version_number := null;
138 --
139 if g_debug then
140 hr_utility.set_location(' Leaving:'||l_proc, 80);
141 end if;
142 --
143 when others then
144 --
145 -- A validation or unexpected error has occured
146 --
147 if g_debug then
148 hr_utility.trace('In exeception');
149 end if;
150 ROLLBACK TO create_application_set;
151 raise;
152 --
153 END create_application_set;
154 --
155 -- ----------------------------------------------------------------------------
156 -- |-------------------< update_application_set>-----------------------------|
160 (p_validate in boolean default false
157 -- ----------------------------------------------------------------------------
158 --
159 procedure update_application_set
161 ,p_application_set_id in number
162 ,p_object_version_number in out nocopy number
163 ,p_name in varchar2
164 ) is
165 --
166 -- Declare cursors and local variables
167 --
168 l_proc varchar2(72);
169 l_object_version_number hxc_entity_groups.object_version_number%TYPE := p_object_version_number;
170 --
171 begin
172 g_debug:=hr_utility.debug_enabled;
173 --
174 if g_debug then
175 l_proc:= g_package||' update_application_set';
176 hr_utility.set_location('Entering:'|| l_proc, 10);
177 end if;
178 --
179 -- Issue a savepoint if operating in validation only mode
180 --
181 savepoint update_application_set;
182 --
183 hxc_application_set_api.chk_name
184 ( p_name => p_name
185 , p_entity_group_id => p_application_set_id );
186
187 if g_debug then
188 hr_utility.set_location(l_proc, 20);
189 end if;
190 --
191 -- Call Before Process User Hook
192 --
193 begin
194 hxc_application_set_BK_2.update_application_set_b
195 (p_application_set_id => p_application_set_id
196 ,p_object_version_number => p_object_version_number
197 ,p_name => p_name
198 );
199 exception
200 when hr_api.cannot_find_prog_unit then
201 hr_api.cannot_find_prog_unit_error
202 (p_module_name => 'update_application_set'
203 ,p_hook_type => 'BP'
204 );
205 end;
206 --
207 if g_debug then
208 hr_utility.set_location(l_proc, 30);
209 end if;
210 --
211 -- Process Logic
212 --
213 -- call row handler
214 --
215 hxc_heg_upd.upd (
216 p_name => p_name
217 ,p_entity_type => g_entity_type
218 ,p_entity_group_id => p_application_set_id
219 ,p_object_version_number => l_object_version_number );
220 --
221 --
222 if g_debug then
223 hr_utility.set_location(l_proc, 40);
224 end if;
225 --
226 -- Call After Process User Hook
227 --
228 begin
229 hxc_application_set_BK_2.update_application_set_a
230 (p_application_set_id => p_application_set_id
231 ,p_object_version_number => l_object_version_number
232 ,p_name => p_name
233 );
234 exception
235 when hr_api.cannot_find_prog_unit then
236 hr_api.cannot_find_prog_unit_error
237 (p_module_name => 'update_application_set'
238 ,p_hook_type => 'AP'
239 );
240 end;
241 --
242 if g_debug then
243 hr_utility.set_location(l_proc, 50);
244 end if;
245 --
246 -- When in validation only mode raise the Validate_Enabled exception
247 --
248 if p_validate then
249 raise hr_api.validate_enabled;
250 end if;
251 --
252 if g_debug then
253 hr_utility.set_location(' Leaving:'||l_proc, 60);
254 end if;
255 --
256 -- Set all output arguments
257 --
258 p_object_version_number := l_object_version_number;
259 --
260 exception
261 --
262 when hr_api.validate_enabled then
263 --
264 -- As the Validate_Enabled exception has been raised
265 -- we must rollback to the savepoint
266 --
267 ROLLBACK TO update_application_set;
268 --
269 -- Only set output warning arguments
270 -- (Any key or derived arguments must be set to null
271 -- when validation only mode is being used.)
272 --
273 p_object_version_number := null;
274 --
275 if g_debug then
276 hr_utility.set_location(' Leaving:'||l_proc, 60);
277 end if;
278 --
279 when others then
280 --
281 -- A validation or unexpected error has occured
282 --
283 if g_debug then
284 hr_utility.trace('In exeception');
285 end if;
286 ROLLBACK TO update_application_set;
287 raise;
288 --
289 END update_application_set;
290 --
291 -- ----------------------------------------------------------------------------
292 -- |----------------------< delete_application_set >-------------------------|
293 -- ----------------------------------------------------------------------------
294 --
295 procedure delete_application_set
296 (p_validate in boolean default false
297 ,p_application_set_id in number
298 ,p_object_version_number in number
299 ) is
300 --
301 -- Declare cursors and local variables
302 --
303 l_proc varchar2(72);
304 --
305 begin
306 --
307 if g_debug then
308 l_proc:= g_package||'delete_application_set';
309 hr_utility.set_location('Entering:'|| l_proc, 10);
310 end if;
311 --
312 -- Issue a savepoint if operating in validation only mode
313 --
314 savepoint delete_application_set;
315 --
316 hxc_application_set_api.chk_delete (
317 p_entity_group_id => p_application_set_id
318 , p_entity_type => g_entity_type );
319
320 if g_debug then
321 hr_utility.set_location(l_proc, 20);
322 end if;
323 --
324 -- Call Before Process User Hook
325 --
326 begin
327 --
328 hxc_application_set_BK_3.delete_application_set_b
329 (p_application_set_id => p_application_set_id
330 ,p_object_version_number => p_object_version_number
331 );
332 exception
336 ,p_hook_type => 'BP'
333 when hr_api.cannot_find_prog_unit then
334 hr_api.cannot_find_prog_unit_error
335 (p_module_name => 'delete_application_set_b'
337 );
338 end;
339 --
340 if g_debug then
341 hr_utility.set_location(l_proc, 30);
342 end if;
343 --
344 -- Process Logic
345 --
346 hxc_heg_del.del
347 (
348 p_entity_group_id => p_application_set_id
349 ,p_object_version_number => p_object_version_number
350 );
351 --
352 if g_debug then
353 hr_utility.set_location(l_proc, 40);
354 end if;
355 --
356 -- Call After Process User Hook
357 --
358 begin
359 --
360 hxc_application_set_BK_3.delete_application_set_a
361 (p_application_set_id => p_application_set_id
362 ,p_object_version_number => p_object_version_number
363 );
364 exception
365 when hr_api.cannot_find_prog_unit then
366 hr_api.cannot_find_prog_unit_error
367 (p_module_name => 'delete_application_set_a'
368 ,p_hook_type => 'AP'
369 );
370 end;
371 --
372 -- When in validation only mode raise the Validate_Enabled exception
373 --
374 if p_validate then
375 raise hr_api.validate_enabled;
376 end if;
377 --
378 if g_debug then
379 hr_utility.set_location(' Leaving:'||l_proc, 50);
380 end if;
381 --
382 exception
383 --
384 when hr_api.validate_enabled then
385 --
386 -- As the Validate_Enabled exception has been raised
387 -- we must rollback to the savepoint
388 --
389 ROLLBACK TO delete_application_set;
390 --
391 when others then
392 --
393 -- A validation or unexpected error has occured
394 --
395 ROLLBACK TO delete_application_set;
396 raise;
397 --
398 end delete_application_set;
399 --
400 --
401 -- ----------------------------------------------------------------------------
402 -- |-----------------------< chk_name >---------------------------------------|
403 -- ----------------------------------------------------------------------------
404 --
405 -- Description:
406 --
407 -- SEE DESCRIPTION IN PACKAGE HEADER
408 --
409 -- Note:
410 -- This procedure is called from the client
411 --
412 -- ----------------------------------------------------------------------------
413 Procedure chk_name
414 (
415 p_name in hxc_entity_groups.name%TYPE
416 ,p_entity_group_id in hxc_entity_groups.entity_group_id%TYPE
417 ) IS
418
419 l_proc varchar2(72);
420 --
421 -- cursor to check name is unique
422 --
423 CURSOR csr_chk_name IS
424 SELECT 'error'
425 FROM sys.dual
426 WHERE EXISTS (
427 SELECT 'x'
428 FROM hxc_entity_groups heg
429 WHERE heg.name = p_name
430 AND heg.entity_type = g_entity_type AND
431 ( heg.entity_group_id <> p_entity_group_id OR
432 p_entity_group_id IS NULL ) );
433 --
434 l_dup_name varchar2(5) := NULL;
435 --
436 BEGIN
437 g_debug:=hr_utility.debug_enabled;
438 if g_debug then
439 l_proc:= g_package||'chk_name';
440 hr_utility.set_location('Entering:'||l_proc, 5);
441 end if;
442 --
443 -- check that the name has been entered
444 --
445 IF ( p_name IS NULL )
446 THEN
447 --
448 hr_utility.set_message(809, 'HXC_HEG_AS_NAME_MAND');
449 hr_utility.raise_error;
450 --
451 END IF;
452 if g_debug then
453 hr_utility.set_location('Processing:'||l_proc, 10);
454 end if;
455 --
456 -- check that the name is unique
457 --
458 OPEN csr_chk_name;
459 FETCH csr_chk_name INTO l_dup_name;
460 CLOSE csr_chk_name;
461 --
462 IF ( l_dup_name IS NOT NULL )
463 THEN
464 --
465 hr_utility.set_message(809, 'HXC_HEG_AS_NAME_DUP');
466 hr_utility.raise_error;
467 --
468 END IF;
469 --
470 if g_debug then
471 hr_utility.set_location('Leaving:'||l_proc, 20);
472 end if;
473 --
474 END chk_name;
475 --
476 -- ----------------------------------------------------------------------------
477 -- |-----------------------< chk_delete >-------------------------------------|
478 -- ----------------------------------------------------------------------------
479 --
480 -- Description:
481 --
482 -- SEE DESCRIPTION IN PACKAGE HEADER
483 --
484 -- ----------------------------------------------------------------------------
485 Procedure chk_delete
486 (
487 p_entity_group_id in hxc_entity_groups.entity_group_id%TYPE
488 , p_entity_type in hxc_entity_group_comps.entity_type%TYPE
489 ) IS
490 --
491 l_proc varchar2(72);
492 --
493 --
494 /*
495 CURSOR csr_chk_pref IS
496 SELECT 'exists'
497 FROM sys.dual
498 WHERE EXISTS (
499 SELECT 'x'
500 FROM hxc_resource_all_elig_pref_v
501 WHERE preference_code = 'TS_PER_APPLICATION_SET'
502 AND attribute1 = TO_CHAR(p_entity_group_id) );
503 */
504
505 l_exists VARCHAR2(6) := NULL;
506
507 BEGIN
508 g_debug:=hr_utility.debug_enabled;
509 if g_debug then
510 l_proc := g_package||'chk_delete';
511 hr_utility.set_location('Entering:'||l_proc, 5);
512 end if;
513
514 -- check that entity_group is not being used in the pref hierarchy
515 -- call function num_hierarchy_occurances to check for data integrity.
516
517 /*OPEN csr_chk_pref;
518 FETCH csr_chk_pref INTO l_exists;
519 CLOSE csr_chk_pref;*/
520
521 if g_debug then
522 hr_utility.set_location('Calling num_hierarchy_occurances:'||l_proc,10);
523 end if;
524 l_exists := HXC_PREFERENCE_EVALUATION.num_hierarchy_occurances
525 ('TS_PER_APPLICATION_SET'
526 ,1
527 ,TO_CHAR(p_entity_group_id));
528 if g_debug then
529 hr_utility.set_location('After calling num_hierarchy_occurances:'||l_proc,20);
530 end if;
531 IF l_exists <> 0 THEN
532 --
533 hr_utility.set_message(809, 'HXC_HEG_AS_IN_USE');
534 hr_utility.raise_error;
535 --
536 END IF;
537 --
538 if g_debug then
539 hr_utility.set_location('Processing: '||l_proc, 60);
540 end if;
541 --
542 END chk_delete;
543 --
544 END hxc_application_set_api;