[Home] [Help]
PACKAGE BODY: APPS.OTA_ADT_BUS
Source
1 Package Body ota_adt_bus as
2 /* $Header: otadtrhi.pkb 115.2 2004/04/02 01:11:13 rdola noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_adt_bus.'; -- Global package name
9 --
10 -- The following two global variables are only to be
11 -- used by the return_legislation_code function.
12 --
13 g_legislation_code varchar2(150) default null;
14 g_activity_id number default null;
15 g_language varchar2(4) default null;
16 --
17 -- The following global vaiables are only to be used by the
18 -- validate_translation function.
19 --
20 g_business_group_id number default null;
21
22 --
23 -- ----------------------------------------------------------------------------
24 -- |-----------------------< set_translation_globals >------------------------|
25 -- ----------------------------------------------------------------------------
26 PROCEDURE set_translation_globals
27 (p_business_group_id in number
28 ) IS
29 --
30 l_proc varchar2(72) := g_package||'set_translation_globals';
31 --
32 BEGIN
33 --
34 hr_utility.set_location('Entering:'||l_proc,5);
35 --
36 g_business_group_id := p_business_group_id;
37
38 --
39 hr_utility.set_location('Leaving:'||l_proc,10);
40 --
41 END set_translation_globals;
42 --
43 -- ----------------------------------------------------------------------------
44 -- |---------------------------< validate_translation >------------------------|
45 -- ----------------------------------------------------------------------------
46 -- {Start Of Comments}
47 --
48 -- Description:
49 -- This procedure performs the validation for the MLS widget.
50 --
51 -- Prerequisites:
52 -- This procedure is called from from the MLS widget.
53 --
54 -- In Parameters:
55 --
56 -- Post Success:
57 -- Processing continues.
58 --
59 -- Post Failure:
60 -- If a business rules fails the error will not be handled by this procedure
61 --
62 -- Developer Implementation Notes:
63 --
64 -- Access Status:
65 -- MLS Widget Only.
66 --
67 -- {End Of Comments}
68 -- ----------------------------------------------------------------------------
69 Procedure validate_translation
70 (activity_id in number
71 ,language in varchar2
72 ,name in varchar2
73 ,description in varchar2
74 ,p_business_group_id in number default null
75 ) IS
76 --
77 l_proc varchar2(72) := g_package||'validate_translation';
78
79 --
80 BEGIN
81 --
82 hr_utility.set_location('Entering:'||l_proc,5);
83 --
84
85 check_unique_name
86 ( p_activity_id => activity_id
87 , p_business_group_id => Nvl(p_business_group_id,g_business_group_id)
88 , p_language => language
89 , p_name => name
90 );
91 --
92 hr_utility.set_location('Leaving:'||l_proc,10);
93 --
94 END Validate_translation;
95 --
96 -- ----------------------------------------------------------------------------
97 -- |---------------------------< check_unique_name >--------------------------|
98 -- ----------------------------------------------------------------------------
99 --
100 -- Description:
101 -- The activity name is mandatory and must be unique within business group.
102 --
103 Procedure check_unique_name
104 (
105 p_business_group_id in number
106 ,p_name in varchar2
107 ,p_language in varchar2
108 ,p_activity_id in number
109 ) is
110 --
111 v_exists varchar2(1);
112 v_proc varchar2(72) := g_package||'check_unique_name';
113 --
114 CURSOR csr_unique_name is
115 select 'Y'
116 from ota_activity_definitions tad, ota_activity_definitions_tl adt
117 --Modified for Bug#3547758
118 -- where upper(adt.name) = upper(p_name)
119 where adt.name = p_name
120 and (tad.business_group_id = p_business_group_id
121 OR p_business_group_id is NULL )
122 and adt.activity_id = tad.activity_id
123 and (adt.activity_id <> p_activity_id
124 OR p_activity_id is NULL )
125 and adt.language = p_language ;
126 --
127 Begin
128 --
129 hr_utility.set_location('Entering:'|| v_proc, 5);
130 --
131 Open csr_unique_name;
132 fetch csr_unique_name into v_exists;
133 --
134 if csr_unique_name%found then
135 --
136 close csr_unique_name;
137 --
138 -- ** TEMP ** Add error message with the following text.
139 --
140 -- call_error_message( p_error_appl => 'OTA'
141 -- , p_error_txt => 'OTA_13331_TAD_DUPLICATE'
142 -- );
143 fnd_message.set_name('PAY','HR_TRANSLATION_EXISTS');
144 fnd_message.raise_error;
145 --
146 end if;
147 --
148 close csr_unique_name;
149 --
150 hr_utility.set_location(' Leaving:'|| v_proc, 10);
151 --
152 End check_unique_name;
153 --
154 -- ----------------------------------------------------------------------------
155 -- |---------------------------< check_unique_name >--------------------------|
156 -- ----------------------------------------------------------------------------
157 --
158 -- Description:
159 -- The activity name is mandatory and must be unique within business group.
160 --
161 Procedure check_unique_name
162 (
163 p_rec in ota_adt_shd.g_rec_type
164 ,p_activity_id in number default null
165 ) is
166 --
167 l_proc varchar2(72) := g_package||'check_unique_name';
168 --
169 --Decalare cursor
170 Cursor csr_adtbsg is
171 Select adt.business_group_id
172 from ota_activity_definitions adt
173 where adt.activity_id = Nvl(p_rec.activity_id,p_activity_id) ;
174 --
175 l_business_group_id ota_activity_definitions.business_group_id%TYPE ;
176 --
177 Begin
178 --
179 hr_utility.set_location('Entering:'||l_proc,5);
180 --
181 open csr_adtbsg ;
182 --
183 fetch csr_adtbsg into l_business_group_id ;
184 --
185 close csr_adtbsg ;
186 --
187 check_unique_name
188 (p_activity_id => Nvl(p_rec.activity_id,p_activity_id)
189 ,p_business_group_id => l_business_group_id
190 ,p_language => p_rec.language
191 ,p_name => p_rec.name );
192
193 --
194 hr_utility.set_location('Leaving:'||l_proc,10);
195 --
196 End check_unique_name ;
197 --
198 --
199 -- ---------------------------------------------------------------------------
200 -- |----------------------< set_security_group_id >--------------------------|
201 -- ---------------------------------------------------------------------------
202 --
203 Procedure set_security_group_id
204 (p_activity_id in number
205 ,p_associated_column1 in varchar2 default null
206 ) is
207 --
208 -- Declare cursor
209 --
210 cursor csr_sec_grp is
211 select pbg.security_group_id,
212 pbg.legislation_code
213 from per_business_groups pbg
214 , ota_activity_definitions tad
215 where tad.activity_id = p_activity_id
216 and pbg.business_group_id = tad.business_group_id;
217 --
218 -- Declare local variables
219 --
220 l_security_group_id number;
221 l_proc varchar2(72) := g_package||'set_security_group_id';
222 l_legislation_code varchar2(150);
223 --
224 begin
225 --
226 hr_utility.set_location('Entering:'|| l_proc, 10);
227 --
228 -- Ensure that all the mandatory parameter are not null
229 --
230 hr_api.mandatory_arg_error
231 (p_api_name => l_proc
232 ,p_argument => 'activity_id'
233 ,p_argument_value => p_activity_id
234 );
235 --
236 --
237 open csr_sec_grp;
238 fetch csr_sec_grp into l_security_group_id
239 , l_legislation_code;
240 --
241 if csr_sec_grp%notfound then
242 --
243 close csr_sec_grp;
244 --
245 -- The primary key is invalid therefore we must error
246 --
247 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
248 hr_multi_message.add
249 (p_associated_column1
250 => nvl(p_associated_column1,'ACTIVITY_ID')
251 );
252 --
253 else
254 close csr_sec_grp;
255 --
256 -- Set the security_group_id in CLIENT_INFO
257 --
258 hr_api.set_security_group_id
259 (p_security_group_id => l_security_group_id
260 );
261 --
262 -- Set the sessions legislation context in HR_SESSION_DATA
263 --
264 hr_api.set_legislation_context(l_legislation_code);
265 end if;
266 --
267 hr_utility.set_location(' Leaving:'|| l_proc, 20);
268 --
269 end set_security_group_id;
270 --
271 -- ---------------------------------------------------------------------------
272 -- |---------------------< return_legislation_code >-------------------------|
273 -- ---------------------------------------------------------------------------
274 --
275 Function return_legislation_code
276 (p_activity_id in number
277 ,p_language in varchar2
278 )
279 Return Varchar2 Is
280 --
281 -- Declare cursor
282 --
283 cursor csr_leg_code is
284 select pbg.legislation_code
285 from per_business_groups pbg
286 , ota_activity_definitions tad
287 where tad.activity_id = p_activity_id
288 and pbg.business_group_id = tad.business_group_id;
289 --
290 -- Declare local variables
291 --
292 l_legislation_code varchar2(150);
293 l_proc varchar2(72) := g_package||'return_legislation_code';
294 --
295 Begin
296 --
297 hr_utility.set_location('Entering:'|| l_proc, 10);
298 --
299 -- Ensure that all the mandatory parameter are not null
300 --
301 hr_api.mandatory_arg_error
302 (p_api_name => l_proc
303 ,p_argument => 'activity_id'
304 ,p_argument_value => p_activity_id
305 );
306 --
307 --
308 if (( nvl(ota_adt_bus.g_activity_id, hr_api.g_number)
309 = p_activity_id)
310 and ( nvl(ota_adt_bus.g_language, hr_api.g_varchar2)
311 = p_language)) then
312 --
313 -- The legislation code has already been found with a previous
314 -- call to this function. Just return the value in the global
315 -- variable.
316 --
317 l_legislation_code := ota_adt_bus.g_legislation_code;
318 hr_utility.set_location(l_proc, 20);
319 else
320 --
321 -- The ID is different to the last call to this function
322 -- or this is the first call to this function.
323 --
324 open csr_leg_code;
325 fetch csr_leg_code into l_legislation_code;
326 --
327 if csr_leg_code%notfound then
328 --
329 -- The primary key is invalid therefore we must error
330 --
331 close csr_leg_code;
332 fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
333 fnd_message.raise_error;
334 end if;
335 hr_utility.set_location(l_proc,30);
336 --
337 -- Set the global variables so the values are
338 -- available for the next call to this function.
339 --
340 close csr_leg_code;
341 ota_adt_bus.g_activity_id := p_activity_id;
342 ota_adt_bus.g_language := p_language;
343 ota_adt_bus.g_legislation_code := l_legislation_code;
344 end if;
345 hr_utility.set_location(' Leaving:'|| l_proc, 40);
346 return l_legislation_code;
347 end return_legislation_code;
348 --
349 -- ----------------------------------------------------------------------------
350 -- |-----------------------< chk_non_updateable_args >------------------------|
351 -- ----------------------------------------------------------------------------
352 -- {Start Of Comments}
353 --
354 -- Description:
355 -- This procedure is used to ensure that non updateable attributes have
356 -- not been updated. If an attribute has been updated an error is generated.
357 --
358 -- Pre Conditions:
359 -- g_old_rec has been populated with details of the values currently in
360 -- the database.
361 --
362 -- In Arguments:
363 -- p_rec has been populated with the updated values the user would like the
364 -- record set to.
365 --
366 -- Post Success:
367 -- Processing continues if all the non updateable attributes have not
368 -- changed.
369 --
370 -- Post Failure:
371 -- An application error is raised if any of the non updatable attributes
372 -- have been altered.
373 --
374 -- {End Of Comments}
375 -- ----------------------------------------------------------------------------
376 Procedure chk_non_updateable_args
377 (p_effective_date in date
378 ,p_rec in ota_adt_shd.g_rec_type
379 ) IS
380 --
381 l_proc varchar2(72) := g_package || 'chk_non_updateable_args';
382 --
383 Begin
384 --
385 -- Only proceed with the validation if a row exists for the current
386 -- record in the HR Schema.
387 --
388 IF NOT ota_adt_shd.api_updating
389 (p_activity_id => p_rec.activity_id
390 ,p_language => p_rec.language
391 ) THEN
392 fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
393 fnd_message.set_token('PROCEDURE ', l_proc);
394 fnd_message.set_token('STEP ', '5');
395 fnd_message.raise_error;
396 END IF;
397 --
398 --
399 End chk_non_updateable_args;
400 --
401 -- ----------------------------------------------------------------------------
402 -- |---------------------------< insert_validate >----------------------------|
403 -- ----------------------------------------------------------------------------
404 Procedure insert_validate
405 (p_effective_date in date
406 ,p_rec in ota_adt_shd.g_rec_type
407 ,p_activity_id in number
408 ) is
409 --
410 l_proc varchar2(72) := g_package||'insert_validate';
411 --
412 Begin
413 hr_utility.set_location('Entering:'||l_proc, 5);
414 --
415 -- Call all supporting business operations
416 --
417
418 ota_adt_bus.set_security_group_id(p_activity_id) ;
419 --
420 -- Validate Dependent Attributes
421 check_unique_name(p_rec,p_activity_id) ;
422 --
423 --
424 hr_utility.set_location(' Leaving:'||l_proc, 10);
425 End insert_validate;
426 --
427 -- ----------------------------------------------------------------------------
428 -- |---------------------------< update_validate >----------------------------|
429 -- ----------------------------------------------------------------------------
430 Procedure update_validate
431 (p_effective_date in date
432 ,p_rec in ota_adt_shd.g_rec_type
433 ) is
434 --
435 l_proc varchar2(72) := g_package||'update_validate';
436 --
437 Begin
438 hr_utility.set_location('Entering:'||l_proc, 5);
439 --
440 -- Call all supporting business operations
441 --
442 --
443 ota_adt_bus.set_security_group_id(p_rec.activity_id) ;
444 --
445 -- Validate Dependent Attributes
446 check_unique_name(p_rec) ;
447 --
448 chk_non_updateable_args
449 (p_effective_date => p_effective_date
450 ,p_rec => p_rec
451 );
452 --
453 --
454 hr_utility.set_location(' Leaving:'||l_proc, 10);
455 End update_validate;
456 --
457 -- ----------------------------------------------------------------------------
458 -- |---------------------------< delete_validate >----------------------------|
459 -- ----------------------------------------------------------------------------
460 Procedure delete_validate
461 (p_rec in ota_adt_shd.g_rec_type
462 ) is
463 --
464 l_proc varchar2(72) := g_package||'delete_validate';
465 --
466 Begin
467 hr_utility.set_location('Entering:'||l_proc, 5);
468 --
469 -- Call all supporting business operations
470 --
471 hr_utility.set_location(' Leaving:'||l_proc, 10);
472 End delete_validate;
473 --
474 --
475
476 end ota_adt_bus;