[Home] [Help]
PACKAGE BODY: APPS.HXC_TEMPLATE_SUMMARY_API
Source
1 PACKAGE BODY HXC_TEMPLATE_SUMMARY_API AS
2 /* $Header: hxctempsumapi.pkb 120.2 2005/12/12 08:28:50 gkrishna noship $ */
3
4 FUNCTION TEMPLATE_PRESENT
5 (p_template_id in hxc_template_summary.template_id%type)
6 RETURN HXC_TEMPLATE_SUMMARY.RESOURCE_ID%TYPE IS
7
8 l_resource_id hxc_template_summary.resource_id%type;
9
10 BEGIN
11
12 select resource_id
13 into l_resource_id
14 from hxc_template_summary
15 where template_id = p_template_id;
16
17 return l_resource_id;
18
19 exception
20 when others then
21 return NULL;
22 END TEMPLATE_PRESENT;
23
24 PROCEDURE DELETE_TEMPLATE
25 (
26 p_template_id in number
27 ) is
28
29 l_index number;
30 l_resource_id hxc_template_summary.resource_id%type;
31 Begin
32
33 -- Delete the existing template information in the summary.
34 --
35
36 --Tracking the resource id to find out who already created it, if the template
37 --already exists.
38
39 l_resource_id := template_present(p_template_id);
40
41
42
43 if( l_resource_id is not null) then
44 hxc_template_summary_pkg.delete_summary_row
45 (p_template_id => p_template_id);
46 end if;
47
48 END DELETE_TEMPLATE;
49
50 --Called during the template migration.
51
52 PROCEDURE TEMPLATE_DEPOSIT
53 (
54 p_template_id in hxc_template_summary.template_id%type,
55 p_template_ovn in HXC_TEMPLATE_SUMMARY.TEMPLATE_OVN%type
56 )
57 is
58 cursor c_template_attributes(p_template_id hxc_template_summary.template_id%type,p_template_ovn in HXC_TEMPLATE_SUMMARY.TEMPLATE_OVN%type)
59 is SELECT
60 a.attribute_category
61 ,a.attribute1
62 ,a.attribute2
63 ,a.attribute3
64 ,a.attribute4
65 ,a.attribute5
66 ,a.attribute6
67 ,a.attribute7
68 ,a.attribute8
69 ,a.attribute9
70 ,a.attribute10
71 ,a.attribute11
72 ,a.attribute12
73 ,a.attribute13
74 ,a.attribute14
75 FROM hxc_time_attributes a,
76 hxc_time_attribute_usages au,
77 hxc_bld_blk_info_types bbit
78 WHERE au.time_building_block_id = p_template_id
79 AND au.time_building_block_ovn = p_template_ovn
80 AND au.time_attribute_id = a.time_attribute_id
81 AND ( (a.attribute_category = 'TEMPLATES')
82 OR (a.attribute_category = 'SECURITY')
83 OR (a.attribute_category = 'LAYOUT'))
84 AND a.bld_blk_info_type_id = bbit.bld_blk_info_type_id;
85
86 l_recurring_period hxc_template_summary.RECURRING_PERIOD_ID%type ;
87 l_layout_id hxc_template_summary.LAYOUT_ID%type;
88 l_template_name hxc_template_summary.TEMPLATE_NAME%type;
89 l_description hxc_template_summary.DESCRIPTION%type ;
90 l_template_type hxc_template_summary.TEMPLATE_TYPE%type;
91 l_business_group_id hxc_template_summary.BUSINESS_GROUP_ID%type;
92 l_resource_id hxc_template_summary.resource_id%type;
93
94 BEGIN
95
96 --
97 -- 1. Delete the template, if it already exists.
98 --
99 l_resource_id := template_present(p_template_id);
100
101 if( l_resource_id is not null) then
102 hxc_template_summary_pkg.delete_summary_row
103 (p_template_id => p_template_id);
104 end if;
105
106 for template_attribute_rec in c_template_attributes(p_template_id,p_template_ovn)
107 loop
108 if(template_attribute_rec.ATTRIBUTE_CATEGORY = 'TEMPLATES') then
109 l_template_name := template_attribute_rec.ATTRIBUTE1;
110 l_template_type := template_attribute_rec.ATTRIBUTE2;
111 if(l_template_type='PUBLIC') THEN
112 l_recurring_period := template_attribute_rec.ATTRIBUTE3;
113 l_description := template_attribute_rec.ATTRIBUTE4;
114 END IF;
115 elsif(template_attribute_rec.ATTRIBUTE_CATEGORY = 'LAYOUT') then
116 l_layout_id := template_attribute_rec.ATTRIBUTE1;
117 elsif(template_attribute_rec.ATTRIBUTE_CATEGORY = 'SECURITY') then
118 l_business_group_id := template_attribute_rec.ATTRIBUTE2;
119 end if;
120 end loop;
121 if (l_business_group_id is null) then
122 l_business_group_id :=0;
123 end if;
124 if ((l_template_name is NOT null) and (l_business_group_id is not null) and
125 (l_layout_id is not null) and (l_template_type is not null)) then
126
127 hxc_template_summary_pkg.insert_summary_row
128 (p_template_id => p_template_id,
129 p_template_ovn => p_template_ovn,
130 p_template_name =>l_template_name,
131 p_description =>l_description,
132 p_template_type =>l_template_type,
133 p_layout_id => l_layout_id,
134 p_recurring_period_id =>l_recurring_period,
135 p_business_group_id =>l_business_group_id,
136 p_resource_id => NULL
137 );
138 -- Need to pickingup the resourceid from the hxc_time_building_blocks table directly.
139 end if;
140 END TEMPLATE_DEPOSIT;
141
142
143 --Called during the template deposition.
144
145 PROCEDURE TEMPLATE_DEPOSIT
146 (p_blocks in hxc_block_table_type,
147 p_attributes in HXC_ATTRIBUTE_TABLE_TYPE,
148 p_template_id in hxc_template_summary.TEMPLATE_ID%type
149 ) is
150
151 l_recurring_period hxc_template_summary.RECURRING_PERIOD_ID%type ;
152 l_layout_id hxc_template_summary.LAYOUT_ID%type;
153 l_template_name hxc_template_summary.TEMPLATE_NAME%type;
154 l_description hxc_template_summary.DESCRIPTION%type ;
155 l_template_type hxc_template_summary.TEMPLATE_TYPE%type;
156 l_business_group_id hxc_template_summary.BUSINESS_GROUP_ID%type;
157 l_resource_id hxc_template_summary.resource_id%type;
158 l_timecard_index number;
159 l_index number;
160
161 BEGIN
162 --
163 -- 1. Find the timecard index of the blocks
164 --
165 l_timecard_index := hxc_timecard_block_utils.find_active_timecard_index(p_blocks);
166
167 --
168 -- 2. Delete the template, if it already exists.
169 --
170 l_resource_id := template_present(p_template_id);
171
172 if( l_resource_id is not null) then
173 hxc_template_summary_pkg.delete_summary_row
174 (p_template_id => p_template_id);
175 end if;
176
177 --
178 -- 3. Generate the template summary informations.
179 --
180
181 l_index := p_attributes.first;
182
183 Loop
184 Exit when not p_attributes.exists(l_index);
185
186 if(p_attributes(l_index).BUILDING_BLOCK_ID = p_blocks(l_timecard_index).time_building_block_id) then
187
188 if(p_attributes(l_index).ATTRIBUTE_CATEGORY = 'TEMPLATES') then
189 l_template_name := p_attributes(l_index).ATTRIBUTE1;
190 l_template_type := p_attributes(l_index).ATTRIBUTE2;
191
192 if(l_template_type='PUBLIC') THEN
193 l_recurring_period := p_attributes(l_index).ATTRIBUTE3;
194 l_description := p_attributes(l_index).ATTRIBUTE4;
195 END IF;
196 elsif(p_attributes(l_index).ATTRIBUTE_CATEGORY = 'LAYOUT') then
197 l_layout_id := p_attributes(l_index).ATTRIBUTE1;
198 elsif(p_attributes(l_index).ATTRIBUTE_CATEGORY = 'SECURITY') then
199 l_business_group_id := p_attributes(l_index).ATTRIBUTE2;
200 end if;
201 end if;
202 l_index := p_attributes.next(l_index);
203 End Loop;
204
205
206 hxc_template_summary_pkg.insert_summary_row
207 (p_template_id => p_blocks(l_timecard_index).time_building_block_id,
208 p_template_ovn => p_blocks(l_timecard_index).OBJECT_VERSION_NUMBER,
209 p_template_name =>l_template_name,
210 p_description =>l_description,
211 p_template_type =>l_template_type,
212 p_layout_id => l_layout_id,
213 p_recurring_period_id =>l_recurring_period,
214 p_business_group_id =>l_business_group_id,
215 p_resource_id => fnd_global.employee_id
216 );
217
218 END TEMPLATE_DEPOSIT;
219
220 END HXC_TEMPLATE_SUMMARY_API;