1 Package Body hxc_layout_utils_pkg as
2 /* $Header: hxclayoututl.pkb 120.2 2005/09/23 05:27:30 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8
9 c_attribute_category constant varchar2(18) := 'ATTRIBUTE_CATEGORY';
10
11 g_debug boolean := hr_utility.debug_enabled;
12
13 FUNCTION get_updatable_components RETURN components_tab IS
14
15 CURSOR csr_get_layout_components ( p_layout_id NUMBER ) IS
16 SELECT SUBSTRB(q.qualifier_attribute26,1,30) attribute_category,
17 UPPER(SUBSTRB(q.qualifier_attribute27,1,30)) attribute
18 FROM
19 hxc_layout_components c,
20 hxc_layout_comp_qualifiers q
21 WHERE
22 c.layout_id = p_layout_id
23 AND
24 q.layout_component_id = c.layout_component_id AND
25 q.qualifier_attribute25 = 'FLEX' AND
26 q.qualifier_attribute_category in ('LOV','CHOICE_LIST','PACKAGE_CHOICE_LIST','TEXT_FIELD','DESCRIPTIVE_FLEX');
27
28 CURSOR csr_get_alias_components ( p_alias_definition_id NUMBER ) IS
29 SELECT SUBSTRB(bbit.bld_blk_info_type,1,40) attribute_category,
30 UPPER(SUBSTRB(mc.segment,1,30)) attribute
31 FROM
32 hxc_alias_definitions ad,
33 hxc_alias_types hat,
34 hxc_alias_type_components atc,
35 hxc_mapping_components mc,
36 hxc_bld_blk_info_types bbit
37 WHERE
38 ad.alias_definition_id = p_alias_definition_id
39 and ad.alias_type_id = hat.alias_type_id
40 and hat.alias_type = 'OTL_ALT_DDF'
41 and atc.alias_type_id = hat.alias_type_id
42 and atc.mapping_component_id = mc.mapping_component_id
43 and bbit.bld_blk_info_type_id = mc.bld_blk_info_type_id;
44
45 l_resource_id fnd_user.user_id%TYPE := fnd_global.employee_id;
46 l_layout_id hxc_layouts.layout_id%TYPE;
47 l_alias_definition_id hxc_alias_definitions.alias_definition_id%TYPE;
48
49 l_components_tab components_tab;
50
51 l_ind PLS_INTEGER := 1;
52
53 BEGIN
54
55 g_debug := hr_utility.debug_enabled;
56
57 IF g_debug THEN
58 hr_utility.trace('Entering get updatable comps');
59
60 hr_utility.trace('in layout comps');
61 hr_utility.trace('resource id is '||to_char(l_resource_id));
62 END IF;
63
64 l_layout_id := hxc_preference_evaluation.resource_preferences(l_resource_id, 'TC_W_TCRD_LAYOUT', 1);
65
66 FOR comps IN csr_get_layout_components ( l_layout_id )
67 LOOP
68
69 IF ( comps.attribute_category NOT LIKE 'OTL_ALIAS%' )
70 THEN
71
72 l_components_tab(l_ind).bld_blk_info_type := comps.attribute_category;
73 l_components_tab(l_ind).segment := comps.attribute;
74
75 l_ind := l_ind + 1;
76
77 ELSE
78
79 -- this is an alias definition
80
81 l_alias_definition_id :=
82 hxc_preference_evaluation.resource_preferences(l_resource_id, 'TC_W_TCRD_ALIASES', 1);
83
84 FOR alias_comps IN csr_get_alias_components ( l_alias_definition_id )
85 LOOP
86
87 l_components_tab(l_ind).bld_blk_info_type := alias_comps.attribute_category;
88 l_components_tab(l_ind).segment := alias_comps.attribute;
89
90 l_ind := l_ind + 1;
91
92 END LOOP;
93
94 END IF;
95
96 END LOOP;
97
98 -- now do something similar for the TimeKeeper Layout Items
99
100 FOR x IN 1 .. 20
101 LOOP
102
103 l_alias_definition_id := hxc_preference_evaluation.resource_preferences(
104 p_resource_id => l_resource_id,
105 p_pref_code => 'TK_TCARD_ATTRIBUTES_DEFINITION',
106 p_attribute_n => x );
107
108 -- note the query will not return any rows if l_alias_definition_id is null
109
110 FOR alias_comps IN csr_get_alias_components ( l_alias_definition_id )
111 LOOP
112
113 l_components_tab(l_ind).bld_blk_info_type := alias_comps.attribute_category;
114 l_components_tab(l_ind).segment := alias_comps.attribute;
115
116 l_ind := l_ind + 1;
117
118 END LOOP;
119
120 END LOOP;
121
122 IF g_debug THEN
123 hr_utility.trace('Leaving get updatable comps');
124 END IF;
125
126 RETURN l_components_tab;
127
128
129 END get_updatable_components;
130
131
132
133
134 PROCEDURE reset_non_updatable_comps ( p_attributes IN OUT NOCOPY hxc_self_service_time_deposit.app_attributes_info ) IS
135
136 -- private function to compare the current attribute row to the set of updatable components.
137 -- if the attribute can be set from the user interface then return FALSE so the value
138 -- is not reset.
139
140 l_att_ind pls_integer;
141
142 l_comps_tab components_tab;
143
144 FUNCTION update_ok ( p_att_rec IN OUT NOCOPY hxc_self_service_time_deposit.app_attributes
145 , p_comps_tab IN components_tab ) RETURN BOOLEAN IS
146
147 BEGIN
148
149
150
151 IF g_debug THEN
152 hr_utility.trace('In update ok');
153 END IF;
154
155 FOR x IN p_comps_tab.FIRST .. p_comps_tab.LAST
156 LOOP
157
158 IF g_debug THEN
159 hr_utility.trace('p comps is '||p_comps_tab(x).bld_blk_info_type ||' : '||p_comps_tab(x).segment );
160 END IF;
161
162 IF ( ( p_comps_tab(x).bld_blk_info_type = p_att_rec.bld_blk_info_type ) AND
163 ( p_comps_tab(x).segment = p_att_rec.segment ) )
164 THEN
165
166 IF g_debug THEN
167 hr_utility.trace('Cannot update !!!!');
168 END IF;
169
170 RETURN FALSE;
171
172 END IF;
173 --
174 -- We should never update the attribute category of an attribute
175 -- to null, so always return false for that mapping component.
176 -- See bug 4269761
177 --
178 if(p_att_rec.segment = c_attribute_category) then
179 IF g_debug THEN
180 hr_utility.trace('Can not update attribute category!');
181 END IF;
182 return false;
183 end if;
184
185 END LOOP;
186
187 IF g_debug THEN
188 hr_utility.trace('Can update !!!!');
189 END IF;
190
191 RETURN TRUE;
192
193 END update_ok;
194
195
196 BEGIN
197
198 g_debug := hr_utility.debug_enabled;
199
200 IF g_debug THEN
201 hr_utility.trace('Entering reset non updatable comps');
202 END IF;
203
204 l_comps_tab := hxc_layout_utils_pkg.get_updatable_components;
205
206 l_att_ind := p_attributes.FIRST;
207
208 WHILE l_att_ind IS NOT NULL
209 LOOP
210
211 IF ( update_ok ( p_attributes(l_att_ind)
212 , l_comps_tab ) )
213 THEN
214
215 p_attributes(l_att_ind).attribute_value := NULL;
216
217 END IF;
218
219 l_att_ind := p_attributes.NEXT(l_att_ind);
220
221 END LOOP;
222
223 IF g_debug THEN
224 hr_utility.trace('Leaving reset non updatable comps');
225 END IF;
226
227 END reset_non_updatable_comps;
228
229 end hxc_layout_utils_pkg;