DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_FTU_BUS

Source


1 Package Body ota_ftu_bus as
2 /* $Header: otfturhi.pkb 120.1 2005/09/21 02:31 aabalakr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_ftu_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_forum_thread_id             number         default null;
15 g_forum_id                    number         default null;
16 g_person_id                   number         default null;
17 g_contact_id                  number         default null;
18 --
19 --  ---------------------------------------------------------------------------
20 --  |----------------------< set_security_group_id >--------------------------|
21 --  ---------------------------------------------------------------------------
22 --
23 Procedure set_security_group_id
27   ,p_contact_id                           in number
24   (p_forum_thread_id                      in number
25   ,p_forum_id                             in number
26   ,p_person_id                            in number
28   ,p_associated_column1                   in varchar2 default null
29   ,p_associated_column2                   in varchar2 default null
30   ,p_associated_column3                   in varchar2 default null
31   ,p_associated_column4                   in varchar2 default null
32   ) is
33   --
34   -- Declare cursor
35   --
36   cursor csr_sec_grp is
37     select pbg.security_group_id,
38            pbg.legislation_code
39       from per_business_groups_perf pbg
40          , ota_pvt_frm_thread_users ftu
41      where ftu.forum_thread_id = p_forum_thread_id
42      and ftu.forum_id = p_forum_id
43        and ftu.person_id = p_person_id
44        and ftu.contact_id = p_contact_id
45        and pbg.business_group_id = ftu.business_group_id;
46   --
47   -- Declare local variables
48   --
49   l_security_group_id number;
50   l_proc              varchar2(72)  :=  g_package||'set_security_group_id';
51   l_legislation_code  varchar2(150);
52   --
53 begin
54   --
55   hr_utility.set_location('Entering:'|| l_proc, 10);
56   --
57   -- Ensure that all the mandatory parameter are not null
58   --
59   hr_api.mandatory_arg_error
60     (p_api_name           => l_proc
61     ,p_argument           => 'forum_thread_id'
62     ,p_argument_value     => p_forum_thread_id
63     );
64   hr_api.mandatory_arg_error
65     (p_api_name           => l_proc
66     ,p_argument           => 'forum_id'
67     ,p_argument_value     => p_forum_id
68     );
69   hr_api.mandatory_arg_error
70     (p_api_name           => l_proc
71     ,p_argument           => 'person_id'
72     ,p_argument_value     => p_person_id
73     );
74   hr_api.mandatory_arg_error
75     (p_api_name           => l_proc
76     ,p_argument           => 'contact_id'
77     ,p_argument_value     => p_contact_id
78     );
79   --
80   open csr_sec_grp;
81   fetch csr_sec_grp into l_security_group_id
82                        , l_legislation_code;
83   --
84   if csr_sec_grp%notfound then
85      --
86      close csr_sec_grp;
87      --
88      -- The primary key is invalid therefore we must error
89      --
90      fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
91      hr_multi_message.add
92        (p_associated_column1
93         => nvl(p_associated_column1,'FORUM_THREAD_ID')
94       ,p_associated_column2
95         => nvl(p_associated_column2,'FORUM_ID')
96       ,p_associated_column3
97         => nvl(p_associated_column3,'PERSON_ID')
98       ,p_associated_column4
99         => nvl(p_associated_column4,'CONTACT_ID')
100        );
101      --
102   else
103     close csr_sec_grp;
104     --
105     -- Set the security_group_id in CLIENT_INFO
106     --
107     hr_api.set_security_group_id
108       (p_security_group_id => l_security_group_id
109       );
110     --
111     -- Set the sessions legislation context in HR_SESSION_DATA
112     --
113     hr_api.set_legislation_context(l_legislation_code);
114   end if;
115   --
116   hr_utility.set_location(' Leaving:'|| l_proc, 20);
117   --
118 end set_security_group_id;
119 --
120 --  ---------------------------------------------------------------------------
121 --  |---------------------< return_legislation_code >-------------------------|
122 --  ---------------------------------------------------------------------------
123 --
124 Function return_legislation_code
125   (p_forum_thread_id                      in     number
126   ,p_forum_id                             in     number
127   ,p_person_id                            in     number
128   ,p_contact_id                           in     number
129   )
130   Return Varchar2 Is
131   --
132   -- Declare cursor
133   --
134  cursor csr_leg_code is
135     select pbg.legislation_code
136       from per_business_groups_perf pbg
137          , ota_pvt_frm_thread_users ftu
138      where ftu.forum_thread_id = p_forum_thread_id
139        and ftu.forum_id = p_forum_id
140        and ftu.person_id = p_person_id
141        and ftu.contact_id = p_contact_id
142        and pbg.business_group_id = ftu.business_group_id;
143   --
144   -- Declare local variables
145   --
146   l_legislation_code  varchar2(150);
147   l_proc              varchar2(72)  :=  g_package||'return_legislation_code';
148   --
149 Begin
150   --
151   hr_utility.set_location('Entering:'|| l_proc, 10);
152   --
153   -- Ensure that all the mandatory parameter are not null
154   --
155   hr_api.mandatory_arg_error
156     (p_api_name           => l_proc
157     ,p_argument           => 'forum_thread_id'
158     ,p_argument_value     => p_forum_thread_id
159     );
160   hr_api.mandatory_arg_error
161     (p_api_name           => l_proc
162     ,p_argument           => 'forum_id'
163     ,p_argument_value     => p_forum_id
164     );
165   hr_api.mandatory_arg_error
166     (p_api_name           => l_proc
167     ,p_argument           => 'person_id'
168     ,p_argument_value     => p_person_id
169     );
170   hr_api.mandatory_arg_error
171     (p_api_name           => l_proc
172     ,p_argument           => 'contact_id'
173     ,p_argument_value     => p_contact_id
174     );
175   --
176   if (( nvl(ota_ftu_bus.g_forum_thread_id, hr_api.g_number)
177        = p_forum_thread_id)
178   and ( nvl(ota_ftu_bus.g_forum_id, hr_api.g_number)
179        = p_forum_id)
180   and ( nvl(ota_ftu_bus.g_person_id, hr_api.g_number)
181        = p_person_id)
182   and ( nvl(ota_ftu_bus.g_contact_id, hr_api.g_number)
183        = p_contact_id)) then
184     --
185     -- The legislation code has already been found with a previous
186     -- call to this function. Just return the value in the global
187     -- variable.
188     --
189     l_legislation_code := ota_ftu_bus.g_legislation_code;
190     hr_utility.set_location(l_proc, 20);
191   else
192     --
193     -- The ID is different to the last call to this function
194     -- or this is the first call to this function.
195     --
196     open csr_leg_code;
197     fetch csr_leg_code into l_legislation_code;
198     --
199     if csr_leg_code%notfound then
200       --
201       -- The primary key is invalid therefore we must error
202       --
203       close csr_leg_code;
204       fnd_message.set_name('PAY','HR_7220_INVALID_PRIMARY_KEY');
205       fnd_message.raise_error;
206     end if;
207     hr_utility.set_location(l_proc,30);
208     --
209     -- Set the global variables so the values are
210     -- available for the next call to this function.
211     --
212     close csr_leg_code;
213     ota_ftu_bus.g_forum_thread_id             := p_forum_thread_id;
214     ota_ftu_bus.g_forum_id                    := p_forum_id;
215     ota_ftu_bus.g_person_id                   := p_person_id;
216     ota_ftu_bus.g_contact_id                  := p_contact_id;
217     ota_ftu_bus.g_legislation_code  := l_legislation_code;
218   end if;
219   hr_utility.set_location(' Leaving:'|| l_proc, 40);
220   return l_legislation_code;
221 end return_legislation_code;
222 --
223 -- ----------------------------------------------------------------------------
224 -- |-----------------------< chk_non_updateable_args >------------------------|
225 -- ----------------------------------------------------------------------------
226 -- {Start Of Comments}
227 --
228 -- Description:
229 --   This procedure is used to ensure that non updateable attributes have
230 --   not been updated. If an attribute has been updated an error is generated.
231 --
232 -- Pre Conditions:
233 --   g_old_rec has been populated with details of the values currently in
234 --   the database.
235 --
236 -- In Arguments:
237 --   p_rec has been populated with the updated values the user would like the
238 --   record set to.
239 --
240 -- Post Success:
241 --   Processing continues if all the non updateable attributes have not
242 --   changed.
243 --
244 -- Post Failure:
245 --   An application error is raised if any of the non updatable attributes
246 --   have been altered.
247 --
248 -- {End Of Comments}
249 -- ----------------------------------------------------------------------------
250 Procedure chk_non_updateable_args
251   (p_effective_date               in date
252   ,p_rec in ota_ftu_shd.g_rec_type
253   ) IS
254 --
255   l_proc     varchar2(72) := g_package || 'chk_non_updateable_args';
256 --
257 Begin
258   --
259   -- Only proceed with the validation if a row exists for the current
260   -- record in the HR Schema.
261   --
262   IF NOT ota_ftu_shd.api_updating
263       (p_forum_thread_id                   => p_rec.forum_thread_id
264       ,p_forum_id                          => p_rec.forum_id
265       ,p_person_id                         => p_rec.person_id
266       ,p_contact_id                        => p_rec.contact_id
267       ,p_object_version_number             => p_rec.object_version_number
268       ) THEN
269      fnd_message.set_name('PER', 'HR_6153_ALL_PROCEDURE_FAIL');
270      fnd_message.set_token('PROCEDURE ', l_proc);
271      fnd_message.set_token('STEP ', '5');
272      fnd_message.raise_error;
273   END IF;
274   --
275   -- EDIT_HERE: Add checks to ensure non-updateable args have
276   --            not been updated.
277   --
278 End chk_non_updateable_args;
279 --
280 -- ----------------------------------------------------------------------------
281 -- |---------------------------< insert_validate >----------------------------|
282 -- ----------------------------------------------------------------------------
283 Procedure insert_validate
284   (p_effective_date               in date
285   ,p_rec                          in ota_ftu_shd.g_rec_type
286   ,p_forum_thread_id              in number
287   ,p_forum_id                     in number
288   ,p_person_id 	                  in number
289   ,p_contact_id                   in number
290   ) is
291 --
292   l_proc  varchar2(72) := g_package||'insert_validate';
293 --
294 Begin
295   hr_utility.set_location('Entering:'||l_proc, 5);
296   --
297   -- Call all supporting business operations
298   --
299   hr_api.validate_bus_grp_id
300     (p_business_group_id => p_rec.business_group_id
301     ,p_associated_column1 => ota_ftu_shd.g_tab_nam
302                               || '.BUSINESS_GROUP_ID');
303   --
304   -- After validating the set of important attributes,
305   -- if Multiple Message detection is enabled and at least
306   -- one error has been found then abort further validation.
307   --
308   hr_multi_message.end_validation_set;
309   --
310   -- Validate Dependent Attributes
311   --
312   --
313   hr_utility.set_location(' Leaving:'||l_proc, 10);
314 End insert_validate;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------< update_validate >----------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure update_validate
320   (p_effective_date               in date
321   ,p_rec                          in ota_ftu_shd.g_rec_type
322   ) is
323 --
324   l_proc  varchar2(72) := g_package||'update_validate';
325 --
326 Begin
327   hr_utility.set_location('Entering:'||l_proc, 5);
328   --
329   -- Call all supporting business operations
330   --
331   hr_api.validate_bus_grp_id
332     (p_business_group_id => p_rec.business_group_id
333     ,p_associated_column1 => ota_ftu_shd.g_tab_nam
334                               || '.BUSINESS_GROUP_ID');
335   --
336   -- After validating the set of important attributes,
337   -- if Multiple Message detection is enabled and at least
338   -- one error has been found then abort further validation.
339   --
340   hr_multi_message.end_validation_set;
341   --
342   -- Validate Dependent Attributes
343   --
344   chk_non_updateable_args
345     (p_effective_date              => p_effective_date
346       ,p_rec              => p_rec
347     );
348   --
349   --
350   hr_utility.set_location(' Leaving:'||l_proc, 10);
351 End update_validate;
352 --
353 -- ----------------------------------------------------------------------------
354 -- |---------------------------< delete_validate >----------------------------|
355 -- ----------------------------------------------------------------------------
356 Procedure delete_validate
357   (p_rec                          in ota_ftu_shd.g_rec_type
358   ) is
359 --
360   l_proc  varchar2(72) := g_package||'delete_validate';
361 --
362 Begin
363   hr_utility.set_location('Entering:'||l_proc, 5);
364   --
365   -- Call all supporting business operations
366   --
367   hr_utility.set_location(' Leaving:'||l_proc, 10);
368 End delete_validate;
369 --
370 end ota_ftu_bus;