DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_ENT_BUS

Source


1 Package Body ota_ent_bus as
2 /* $Header: otentrhi.pkb 115.1 2003/04/24 17:25:58 ssur noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_ent_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_event_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_parent_event_id             number default null;
21 g_business_group_id           number default null;
22 --
23 -- ----------------------------------------------------------------------------
24 -- |-----------------------< set_translation_globals >------------------------|
25 -- ----------------------------------------------------------------------------
26 PROCEDURE set_translation_globals
27   (p_business_group_id              in number
28   ,p_parent_event_id                in number default null
29   ) IS
30 --
31   l_proc  varchar2(72) := g_package||'set_translation_globals';
32 --
33 BEGIN
34   --
35   hr_utility.set_location('Entering:'||l_proc,5);
36   --
37   g_business_group_id     := p_business_group_id;
38   g_parent_event_id       := p_parent_event_id;
39 
40   --
41   hr_utility.set_location('Leaving:'||l_proc,10);
42   --
43 END set_translation_globals;
44 --
45 -- ----------------------------------------------------------------------------
46 -- |---------------------------< validate_translation >------------------------|
47 -- ----------------------------------------------------------------------------
48 -- {Start Of Comments}
49 --
50 -- Description:
51 --   This procedure performs the validation for the MLS widget.
52 --
53 -- Prerequisites:
54 --   This procedure is called from from the MLS widget.
55 --
56 -- In Parameters:
57 --
58 -- Post Success:
59 --   Processing continues.
60 --
61 -- Post Failure:
62 --   If a business rules fails the error will not be handled by this procedure
63 --
64 -- Developer Implementation Notes:
65 --
66 -- Access Status:
67 --   MLS Widget Only.
68 --
69 -- {End Of Comments}
70 -- ----------------------------------------------------------------------------
71 Procedure validate_translation
72   (p_event_id          in number
73   ,p_language                       in varchar2
74   ,p_title                           in varchar2
75   ,p_business_group_id              in number default null
76   ,p_parent_event_id                in number default null
77   ) IS
78   --
79   l_proc  varchar2(72) := g_package||'validate_translation';
80 
81   --
82 BEGIN
83   --
84   hr_utility.set_location('Entering:'||l_proc,5);
85   --
86 
87   check_title_is_unique
88     ( p_event_id                    => p_event_id
89     , p_business_group_id           => Nvl(p_business_group_id,g_business_group_id)
90     , p_language                    => p_language
91     , p_title                       => p_title
92     , p_parent_event_id             => Nvl(p_parent_event_id,g_parent_event_id)
93     );
94   --
95   hr_utility.set_location('Leaving:'||l_proc,10);
96   --
97 END Validate_translation;
98 --
99 
100 function UNIQUE_EVENT_TITLE (
101 	P_TITLE					     in	varchar2,
102 	P_BUSINESS_GROUP_ID			     in	number,
103 	P_PARENT_EVENT_ID			     in	number,
104 	P_EVENT_ID				     in	number	default null,
105 	P_LANGUAGE                                   in varchar2
106 	) return boolean is
107 --
108 	W_PROC						 varchar2 (72)
109 		:= G_PACKAGE || 'UNIQUE_EVENT_TITLE';
110 	W_TITLE_IS_UNIQUE				boolean;
111 	l_dummy number(1);
112 	--
113 	cursor C1 is
114 		select 1
115 		  from OTA_EVENTS EVT, OTA_EVENTS_TL ENT
116 		  where EVT.BUSINESS_GROUP_ID	      = P_BUSINESS_GROUP_ID
117 		    and (    (P_PARENT_EVENT_ID      is null             )
118 		         or  (EVT.PARENT_EVENT_ID     = P_PARENT_EVENT_ID))
119 		    and upper (ENT.TITLE)	      = upper (P_TITLE)
120 		    and (    (P_EVENT_ID	     is null      )
121 		         or  (ENT.EVENT_ID	     <> P_EVENT_ID))
122 		    and ENT.EVENT_ID = EVT.EVENT_ID
123 		    and ENT.LANGUAGE = P_LANGUAGE ;
124 	--
125 begin
126 	--
127 	HR_UTILITY.SET_LOCATION ('Entering:' || W_PROC, 5);
128 	--
129 	--	Check arguments
130 	--
131 	HR_API.MANDATORY_ARG_ERROR (
132 		G_PACKAGE,
133 	 	'P_TITLE',
134 		P_TITLE);
135 	HR_API.MANDATORY_ARG_ERROR (
136 		G_PACKAGE,
137 		'P_BUSINESS_GROUP_ID',
138 		P_BUSINESS_GROUP_ID);
139 	--
140 	--	Unique ?
141 	--
142 	open C1;
143 	fetch C1
144 	  into L_DUMMY;
145 	W_TITLE_IS_UNIQUE := C1%notfound;
146 	close C1;
147 	--
148 	HR_UTILITY.SET_LOCATION (W_PROC, 10);
149 	return W_TITLE_IS_UNIQUE;
150 	--
151 end UNIQUE_EVENT_TITLE;
152 --
153 -- ----------------------------------------------------------------------------
154 -- -----------------------< CHECK_TITLE_IS_UNIQUE >----------------------------
155 -- ----------------------------------------------------------------------------
156 --
157 --	Validates the uniqueness of the event title (ignoring case).
158 --
159 procedure CHECK_TITLE_IS_UNIQUE (
160 	P_TITLE					     in	varchar2,
161 	P_BUSINESS_GROUP_ID			     in	number,
162 	P_PARENT_EVENT_ID			     in number,
163 	P_EVENT_ID				     in	number	default null,
164 	P_LANGUAGE                                   in varchar2
165 	) is
166 	--
167 
168         --
169 
170 	W_PROC						varchar2 (72)
171 		:= G_PACKAGE || 'CHECK_TITLE_IS_UNIQUE';
172 	--
173 begin
174 	--
175 	HR_UTILITY.SET_LOCATION ('Entering:' || W_PROC, 5);
176 	--
177 	--	Do not perform the uniqueness check unless inserting, or updating
178 	--	with a value different from the current value (and not just changing
179 	--	case)
180 	--
181 	--	Check arguments
182 	--
183  	--if (not (    (OTA_EVT_SHD.API_UPDATING (P_EVENT_ID, P_OBJECT_VERSION_NUMBER))
184 	  --       and (upper (P_TITLE) = upper (OTA_ENT_SHD.G_OLD_REC.TITLE)         ))) then
185 		--
186 		if (not UNIQUE_EVENT_TITLE (
187 				P_TITLE		     => P_TITLE,
188 				P_BUSINESS_GROUP_ID  => P_BUSINESS_GROUP_ID,
189 				P_PARENT_EVENT_ID    =>	P_PARENT_EVENT_ID,
190 				P_EVENT_ID	     =>	P_EVENT_ID ,
191 				P_LANGUAGE           => P_LANGUAGE )) then
192                   fnd_message.set_name('PAY','HR_TRANSLATION_EXISTS');
193                   fnd_message.raise_error;
194 		end if;
195 		--
196 	-- end if;
197 	--
198 	HR_UTILITY.SET_LOCATION (' Leaving:' || W_PROC, 10);
199 	--
200 end CHECK_TITLE_IS_UNIQUE;
201 --
202 -- ----------------------------------------------------------------------------
203 -- -----------------------------< CHECK_TITLE >--------------------------------
204 -- ----------------------------------------------------------------------------
205 --
206 --	Validates the uniqueness of the event title (ignoring case), by calling
210 	P_EVENT_ID		in	number default null
207 --      check_title_is_unique
208 procedure CHECK_TITLE (
209 	P_REC			in	OTA_ENT_SHD.G_REC_TYPE,
211 	) is
212   --
213   l_proc  varchar2(72) := g_package||'check_title';
214   --
215   -- Declare cursor
216   --
217   cursor csr_event is
218     select evt.parent_event_id
219           ,evt.business_group_id
220     from ota_events evt
221     where evt.event_id  = NVL(p_rec.event_id, p_event_id);
222   --
223   l_business_group_id  ota_events.business_group_id%TYPE;
224   l_parent_event_id    ota_events.parent_event_id%TYPE;
225   --
226 Begin
227   --
228   hr_utility.set_location('Entering:'||l_proc,5);
229   --
230   open csr_event;
231   --
232   fetch csr_event into l_parent_event_id,l_business_group_id;
233   --
234   close csr_event;
235   --
236   check_title_is_unique
237    (p_event_id                => Nvl(p_rec.event_id,p_event_id)
238    ,p_parent_event_id         => l_parent_event_id
239    ,p_business_group_id       => l_business_group_id
240    ,p_language                => p_rec.language
241    ,p_title                   => p_rec.title );
242 
243   --
244   hr_utility.set_location('Leaving:'||l_proc,10);
245   --
246 End check_title;
247 --
248 --
249 --  ---------------------------------------------------------------------------
250 --  |----------------------< set_security_group_id >--------------------------|
251 --  ---------------------------------------------------------------------------
252 --
253 Procedure set_security_group_id
254   (p_event_id                             in number
255   ,p_associated_column1                   in varchar2 default null
256   ) is
257   --
258   -- Declare cursor
259   --
260   cursor csr_sec_grp is
261     select pbg.security_group_id,
262            pbg.legislation_code
263       from per_business_groups pbg
264            , ota_events evt
265      where evt.event_id = p_event_id
266      and   pbg.business_group_id = evt.business_group_id ;
267 
268 
269   --
270   -- Declare local variables
271   --
272   l_security_group_id number;
273   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
274   l_legislation_code  varchar2(150);
275   --
276 begin
277   --
278   hr_utility.set_location('Entering:'|| l_proc, 10);
279   --
280   -- Ensure that all the mandatory parameter are not null
281   --
282   hr_api.mandatory_arg_error
283     (p_api_name           => l_proc
284     ,p_argument           => 'event_id'
285     ,p_argument_value     => p_event_id
286     );
287   --
288   --
289   open csr_sec_grp;
290   fetch csr_sec_grp into l_security_group_id
291                        , l_legislation_code;
292   --
293   if csr_sec_grp%notfound then
294      --
295      close csr_sec_grp;
296      --
297      -- The primary key is invalid therefore we must error
298      --
299      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
300      hr_multi_message.add
301        (p_associated_column1
302         => nvl(p_associated_column1,'EVENT_ID')
303        );
304      --
305   else
306     close csr_sec_grp;
307     --
308     -- Set the security_group_id in CLIENT_INFO
309     --
310     hr_api.set_security_group_id
311       (p_security_group_id => l_security_group_id
312       );
313     --
314     -- Set the sessions legislation context in HR_SESSION_DATA
315     --
316     hr_api.set_legislation_context(l_legislation_code);
317   end if;
318   --
319   hr_utility.set_location(' Leaving:'|| l_proc, 20);
320   --
321 end set_security_group_id;
322 --
323 --  ---------------------------------------------------------------------------
324 --  |---------------------< return_legislation_code >-------------------------|
325 --  ---------------------------------------------------------------------------
326 --
327 Function return_legislation_code
328   (p_event_id                             in     number
329   ,p_language                             in     varchar2
330   )
331   Return Varchar2 Is
332   --
333   -- Declare cursor
334   --
335   cursor csr_leg_code is
336     select pbg.legislation_code
337       from per_business_groups pbg
338          , ota_events_tl ent
339          , ota_events evt
340      where ent.event_id = p_event_id
341        and ent.language = p_language
342        and pbg.business_group_id = evt.business_group_id
343        and evt.event_id = ent.event_id;
344   --
345   --
346   -- Declare local variables
347   --
348   l_legislation_code  varchar2(150);
349   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
350   --
351 Begin
352   --
353   hr_utility.set_location('Entering:'|| l_proc, 10);
354   --
355   -- Ensure that all the mandatory parameter are not null
356   --
357   hr_api.mandatory_arg_error
358     (p_api_name           => l_proc
359     ,p_argument           => 'event_id'
360     ,p_argument_value     => p_event_id
361     );
362   --
363   --
364   if (( nvl(ota_ent_bus.g_event_id, hr_api.g_number)
365        = p_event_id)
366   and ( nvl(ota_ent_bus.g_language, hr_api.g_varchar2)
367        = p_language)) then
368     --
369     -- The legislation code has already been found with a previous
370     -- call to this function. Just return the value in the global
371     -- variable.
372     --
373     l_legislation_code := ota_ent_bus.g_legislation_code;
374     hr_utility.set_location(l_proc, 20);
375   else
376     --
377     -- The ID is different to the last call to this function
378     -- or this is the first call to this function.
379     --
380     open csr_leg_code;
381     fetch csr_leg_code into l_legislation_code;
382     --
383     if csr_leg_code%notfound then
384       --
385       -- The primary key is invalid therefore we must error
386       --
387       close csr_leg_code;
388       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
389       fnd_message.raise_error;
390     end if;
391     hr_utility.set_location(l_proc,30);
392     --
393     -- Set the global variables so the values are
394     -- available for the next call to this function.
395     --
396     close csr_leg_code;
397     ota_ent_bus.g_event_id                    := p_event_id;
398     ota_ent_bus.g_language                    := p_language;
399     ota_ent_bus.g_legislation_code  := l_legislation_code;
400   end if;
401   hr_utility.set_location(' Leaving:'|| l_proc, 40);
402   return l_legislation_code;
403 end return_legislation_code;
404 --
405 -- ----------------------------------------------------------------------------
406 -- |-----------------------< chk_non_updateable_args >------------------------|
407 -- ----------------------------------------------------------------------------
408 -- {Start Of Comments}
409 --
410 -- Description:
411 --   This procedure is used to ensure that non updateable attributes have
412 --   not been updated. If an attribute has been updated an error is generated.
413 --
414 -- Pre Conditions:
415 --   g_old_rec has been populated with details of the values currently in
416 --   the database.
417 --
418 -- In Arguments:
419 --   p_rec has been populated with the updated values the user would like the
420 --   record set to.
421 --
422 -- Post Success:
423 --   Processing continues if all the non updateable attributes have not
424 --   changed.
425 --
426 -- Post Failure:
427 --   An application error is raised if any of the non updatable attributes
428 --   have been altered.
429 --
430 -- {End Of Comments}
431 -- ----------------------------------------------------------------------------
432 Procedure chk_non_updateable_args
433   (p_effective_date               in date
434   ,p_rec in ota_ent_shd.g_rec_type
435   ) IS
436 --
437   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
438 --
439 Begin
440   --
441   -- Only proceed with the validation if a row exists for the current
442   -- record in the HR Schema.
443   --
444   IF NOT ota_ent_shd.api_updating
445       (p_event_id                          => p_rec.event_id
446       ,p_language                          => p_rec.language
447       ) THEN
448      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
449      fnd_message.set_token('PROCEDURE ', l_proc);
450      fnd_message.set_token('STEP ', '5');
451      fnd_message.raise_error;
452   END IF;
453   --
454   --
455 End chk_non_updateable_args;
456 --
457 -- ----------------------------------------------------------------------------
458 -- |---------------------------< insert_validate >----------------------------|
459 -- ----------------------------------------------------------------------------
460 Procedure insert_validate
461   (p_effective_date               in date
462   ,p_rec                          in ota_ent_shd.g_rec_type
463   ,p_event_id                     in number
464   ) is
465 --
466   l_proc  varchar2(72) := g_package||'insert_validate';
467 --
468 Begin
469   hr_utility.set_location('Entering:'||l_proc, 5);
470   --
471   -- Call all supporting business operations
472   --
473   --
474   ota_ent_bus.set_security_group_id(p_event_id) ;
475   --
476   -- Validate Dependent Attributes
477   CHECK_TITLE
478             ( P_REC               => p_rec,
479               P_EVENT_ID          => Nvl(p_rec.event_id,p_event_id)
480             );
481   --
482   --
483   hr_utility.set_location(' Leaving:'||l_proc, 10);
484 End insert_validate;
485 --
486 -- ----------------------------------------------------------------------------
487 -- |---------------------------< update_validate >----------------------------|
488 -- ----------------------------------------------------------------------------
489 Procedure update_validate
490   (p_effective_date               in date
491   ,p_rec                          in ota_ent_shd.g_rec_type
492   ) is
493 --
494   l_proc  varchar2(72) := g_package||'update_validate';
495 --
496 Begin
497   hr_utility.set_location('Entering:'||l_proc, 5);
498   --
499   -- Call all supporting business operations
500   --
501   --
502   ota_ent_bus.set_security_group_id(p_rec.event_id);
503   --
504   -- Validate Dependent Attributes
505   --
506   chk_non_updateable_args
507     (p_effective_date              => p_effective_date
508       ,p_rec              => p_rec
509     );
510   --
511   --
512   hr_utility.set_location(' Leaving:'||l_proc, 10);
513 End update_validate;
514 --
515 -- ----------------------------------------------------------------------------
516 -- |---------------------------< delete_validate >----------------------------|
517 -- ----------------------------------------------------------------------------
518 Procedure delete_validate
519   (p_rec                          in ota_ent_shd.g_rec_type
520   ) is
521 --
522   l_proc  varchar2(72) := g_package||'delete_validate';
523 --
524 Begin
525   hr_utility.set_location('Entering:'||l_proc, 5);
526   --
527   -- Call all supporting business operations
528   --
529   hr_utility.set_location(' Leaving:'||l_proc, 10);
530 End delete_validate;
531 --
532 
533 --
534 --
535 end ota_ent_bus;