[Home] [Help]
PACKAGE BODY: APPS.CAC_SYNC_TASK
Source
1 PACKAGE BODY Cac_Sync_Task AS
2 /* $Header: cacvstsb.pls 120.8 2005/10/02 17:19:48 rhshriva noship $ */
3 /*=======================================================================+
4 | Copyright (c) 2002 Oracle Corporation Redwood Shores, California, USA|
5 | All rights reserved. |
6 +=======================================================================+
7 | FILENAME |
8 | cacvstsb.pls |
9 | |
10 | DESCRIPTION |
11 | - This package is for Task Business Logic. |
12 | |
13 | NOTES |
14 | |
15 | Date Developer Change |
16 | ------ --------------- -------------------------------------- |
17 | 04-Nov-2004 sachoudh Created. |
18 | |
19 +======================================================================*/
20
21 -------------------------------
22 -- Private Method
23 -------------------------------
24
25
26 PROCEDURE get_all_data (
27 p_request_type IN VARCHAR2,
28 p_syncanchor IN DATE,
29 p_principal_id IN NUMBER,
30 p_get_data IN BOOLEAN,
31 p_sync_type IN VARCHAR2,
32 x_totalnew OUT NOCOPY NUMBER,
33 x_totalmodified OUT NOCOPY NUMBER,
34 x_totaldeleted OUT NOCOPY NUMBER,
35 x_data OUT NOCOPY cac_sync_task.task_tbl,
36 x_exclusion_data OUT NOCOPY cac_sync_task.exclusion_tbl,
37 x_attendee_data OUT NOCOPY Cac_Sync_Task.attendee_tbl
38 )
39 IS
40 -- Added a group calendar feature
41 -- Used to store the list of group resource ids for the current resource
42 l_resources cac_sync_task_common.resource_list_tbl;
43 i NUMBER := 0;
44 l_operation VARCHAR2(240);
45 l_syncanchor DATE ;
46 l_source_object_type VARCHAR2(60) := RTRIM(p_request_type,'S');
47 l_task_rec cac_sync_task.task_rec;
48 l_resource_id NUMBER;
49 l_resource_type VARCHAR2(30);
50 l_new_syncanchor date ;
51
52
53 CURSOR c_assignment (b_task_id NUMBER)
54 IS
55 SELECT a.assignee_role, a.assignment_status_id,
56 a.resource_id, a.resource_type_code
57 FROM jtf_task_all_assignments a
58 WHERE a.task_id = b_task_id;
59
60 cursor getEmployeeResourceInfo(b_resource_id NUMBER)
61 is
62 Select resource_id,
63 source_phone, source_email, source_job_title,
64 source_first_name, source_middle_name, source_last_name
65 from
66 JTF_RS_RESOURCE_EXTNS
67 where
68 resource_id =b_resource_id;
69
70 cursor getGroupResourceInfo(b_resource_id NUMBER)
71 is
72 Select
73 cp.party_id,
74 pp.person_first_name,
75 pp.person_middle_name,
76 pp.person_last_name,
77 cp.primary_phone_country_code,
78 cp.primary_phone_area_code,
79 cp.primary_phone_number,
80 cp.primary_phone_extension,
81 cp.email_address,
82 ctct.job_title
83 from
84 HZ_PARTIES pp, HZ_PARTIES cp, HZ_RELATIONSHIPS rel, HZ_ORG_CONTACTS ctct
85 where cp.party_id = rel.party_id
86 and rel.relationship_id = ctct.party_relationship_id
87 and rel.subject_id = pp.party_id
88 and rel.directional_flag = 'F'
89 and cp.party_id =b_resource_id;
90
91
92
93 l_getEmployeeResourceInfo getEmployeeResourceInfo%rowtype;
94 l_getGroupResourceInfo getGroupResourceInfo%rowtype;
95 l_assignee_role VARCHAR2(30);
96 l_assignment_status_id NUMBER;
97 l_attendee_id NUMBER;
98 l_attendee_type_code VARCHAR2(30);
99
100 i_counter BINARY_INTEGER := 0 ;
101
102 l_return_status VARCHAR2(1);
103 l_msg_count NUMBER;
104 l_msg_data VARCHAR2(2000);
105
106 BEGIN
107 x_totalnew := 0;
108 x_totalmodified := 0;
109 x_totaldeleted := 0;
110
111 cac_sync_task_common.get_resource_details (g_login_resource_id, l_resource_type);
112
113 l_syncanchor := p_syncanchor;
114 --JTA_SYNC_DEBUG_PKG.DEBUG('l_syncanchor = '||to_char(l_syncanchor,'DD-MON-YYYY HH24:MI:SS'));
115
116 -----------------------------------------------------
117 -- Get group ids including current resource id
118 -----------------------------------------------------
119 cac_sync_task_common.get_group_resource (
120 p_request_type => p_request_type,
121 p_resource_id => g_login_resource_id,
122 p_resource_type => l_resource_type,
123 x_resources => l_resources
124 );
125
126
127
128 -----------------------------------------------------
129 -- Loop with current resource id and group ids
130 -----------------------------------------------------
131 --l_new_syncanchor := sysdate;
132
133 -- FOR j IN l_resources.FIRST .. l_resources.LAST
134 -- LOOP
135 -------------------------------------------------
136 -- Process non repeat tasks
137 -------------------------------------------------
138
139
140
141 cac_sync_task_common.get_all_nonrepeat_tasks(
142 p_request_type => p_request_type,
143 p_syncanchor => l_syncanchor,
144 p_recordindex => NVL(x_data.count,0),
145 p_resource_id => g_login_resource_id,
146 p_principal_id => p_principal_id,
147 p_resource_type => l_resource_type,
148 p_source_object_type => l_source_object_type,
149 p_get_data => p_get_data,
150 x_totalnew => x_totalnew,
151 x_totalmodified => x_totalmodified,
152 --x_totaldeleted => x_totaldeleted,
153 --p_new_syncanchor => l_new_syncanchor,
154 x_data => x_data
155 );
156
157
158 -------------------------------------------------
159 -- Process repeating tasks
160 -------------------------------------------------
161 IF l_source_object_type = 'APPOINTMENT'
162 THEN
163 cac_sync_task_common.get_all_repeat_tasks(
164 p_request_type => p_request_type,
165 p_syncanchor => l_syncanchor,
166 p_recordindex => nvl(x_data.count,0) + 1,
167 p_resource_id => g_login_resource_id,
168 p_principal_id => p_principal_id,
169 p_resource_type => l_resource_type,
170 p_source_object_type => l_source_object_type,
171 p_get_data => p_get_data,
172 x_totalnew => x_totalnew,
173 x_totalmodified => x_totalmodified,
174 --x_totaldeleted => x_totaldeleted,
175 --p_new_syncanchor => l_new_syncanchor,
176 x_data => x_data,
177 x_exclusion_data => x_exclusion_data
178 );
179
180 END IF;
181
182 ----------------------------------
183 -- processing all deleted records
184 ----------------------------------
185
186 if (trim(p_sync_type) <>'SS') then
187
188 cac_sync_task_common.get_all_deleted_tasks(
189 p_request_type => p_request_type,
190 p_syncanchor => l_syncanchor,
191 p_recordindex => nvl(x_data.count,0) + 1,
192 p_resource_id => g_login_resource_id,
193 p_principal_id => p_principal_id,
194 p_resource_type => l_resource_type,
195 p_source_object_type => l_source_object_type,
196 p_get_data => p_get_data,
197 --p_new_syncanchor => l_new_syncanchor,
198 x_totaldeleted => x_totaldeleted,
199 x_data => x_data
200 );
201
202
203 end if;
204
205 -- END LOOP;
206
207
208 FOR k IN 1 .. x_data.COUNT
209 LOOP
210
211 i_counter := i_counter + 1 ;
212
213 FOR c_attendee IN c_assignment (x_data(k).task_id)
214 LOOP
215 x_attendee_data(i_counter).task_id := x_data(k).task_id;
216 x_attendee_data(i_counter).attendee_role := c_attendee.assignee_role;
217 x_attendee_data(i_counter).attendee_status := c_attendee.assignment_status_id;
218 x_attendee_data(i_counter).resourceId := c_attendee.resource_id;
219 x_attendee_data(i_counter).resourceType := c_attendee.resource_type_code;
220
221 if (c_attendee.resource_type_code='RS_EMPLOYEE') then
222
223 open getEmployeeResourceInfo(c_attendee.resource_id);
224 fetch getEmployeeResourceInfo into l_getEmployeeResourceInfo;
225 if (getEmployeeResourceInfo%FOUND) then
226
227 x_attendee_data(i_counter).first_name:=l_getEmployeeResourceInfo.source_first_name;
228 x_attendee_data(i_counter).middle_name:=l_getEmployeeResourceInfo.source_middle_name;
229 x_attendee_data(i_counter).last_name:=l_getEmployeeResourceInfo.source_last_name;
230 x_attendee_data(i_counter).primary_phone_country_code:=null;
231 x_attendee_data(i_counter).primary_phone_area_code:=null;
232 x_attendee_data(i_counter).primary_phone_number:=l_getEmployeeResourceInfo.source_phone;
233 x_attendee_data(i_counter).primary_phone_extension:=null;
234 x_attendee_data(i_counter).email_address:=l_getEmployeeResourceInfo.source_email;
235 x_attendee_data(i_counter).job_title:=l_getEmployeeResourceInfo.source_job_title;
236
237 end if;-- if (getEmployeeResourceInfo%FOUND) then
238
239 if (getEmployeeResourceInfo%ISOPEN) then
240 close getEmployeeResourceInfo;
241 end if;
242
243 else -- for if (c_attendee.resource_type_code='RS_EMPLOYEE') then
244
245 open getGroupResourceInfo(c_attendee.resource_id);
246 fetch getGroupResourceInfo into l_getGroupResourceInfo;
247 if (getGroupResourceInfo%FOUND) then
248
249 x_attendee_data(i_counter).first_name:=l_getGroupResourceInfo.person_first_name;
250 x_attendee_data(i_counter).middle_name:=l_getGroupResourceInfo.person_middle_name;
251 x_attendee_data(i_counter).last_name:=l_getGroupResourceInfo.person_last_name;
252 x_attendee_data(i_counter).primary_phone_country_code:=l_getGroupResourceInfo.primary_phone_country_code;
253 x_attendee_data(i_counter).primary_phone_area_code:=l_getGroupResourceInfo.primary_phone_area_code;
254 x_attendee_data(i_counter).primary_phone_number:=l_getGroupResourceInfo.primary_phone_number;
255 x_attendee_data(i_counter).primary_phone_extension:=l_getGroupResourceInfo.primary_phone_extension;
256 x_attendee_data(i_counter).email_address:=l_getGroupResourceInfo.email_address;
257 x_attendee_data(i_counter).job_title:=l_getGroupResourceInfo.job_title;
258
259 end if;-- if (getGroupResourceInfo%FOUND) then
260
261 if (getGroupResourceInfo%ISOPEN) then
262 close getGroupResourceInfo;
263 end if;
264
265 end if;-- if (c_attendee.resource_type_code='RS_GROUP') then
266
267 i_counter := i_counter + 1 ;
268
269 END LOOP;
270
271
272 END LOOP;
273
274
275
276 --fetching through exclusion table
277
278
279 FOR k IN 1 .. x_exclusion_data.COUNT
280 LOOP
281
282 i_counter := i_counter + 1 ;
283
284 FOR c_attendee IN c_assignment (x_exclusion_data(k).task_id)
285 LOOP
286 x_attendee_data(i_counter).task_id := x_exclusion_data(k).task_id;
287 x_attendee_data(i_counter).attendee_role := c_attendee.assignee_role;
288 x_attendee_data(i_counter).attendee_status := c_attendee.assignment_status_id;
289 x_attendee_data(i_counter).resourceId := c_attendee.resource_id;
290 x_attendee_data(i_counter).resourceType := c_attendee.resource_type_code;
291
292 if (c_attendee.resource_type_code='RS_EMPLOYEE') then
293
294 open getEmployeeResourceInfo(c_attendee.resource_id);
295 fetch getEmployeeResourceInfo into l_getEmployeeResourceInfo;
296 if (getEmployeeResourceInfo%FOUND) then
297
298 x_attendee_data(i_counter).first_name:=l_getEmployeeResourceInfo.source_first_name;
299 x_attendee_data(i_counter).middle_name:=l_getEmployeeResourceInfo.source_middle_name;
300 x_attendee_data(i_counter).last_name:=l_getEmployeeResourceInfo.source_last_name;
301 x_attendee_data(i_counter).primary_phone_country_code:=null;
302 x_attendee_data(i_counter).primary_phone_area_code:=null;
303 x_attendee_data(i_counter).primary_phone_number:=l_getEmployeeResourceInfo.source_phone;
304 x_attendee_data(i_counter).primary_phone_extension:=null;
308 end if;-- if (getEmployeeResourceInfo%FOUND) then
305 x_attendee_data(i_counter).email_address:=l_getEmployeeResourceInfo.source_email;
306 x_attendee_data(i_counter).job_title:=l_getEmployeeResourceInfo.source_job_title;
307
309
310 if (getEmployeeResourceInfo%ISOPEN) then
311 close getEmployeeResourceInfo;
312 end if;
313
314 else -- for if (c_attendee.resource_type_code='RS_EMPLOYEE') then
315
316 open getGroupResourceInfo(c_attendee.resource_id);
317 fetch getGroupResourceInfo into l_getGroupResourceInfo;
318 if (getGroupResourceInfo%FOUND) then
319
320 x_attendee_data(i_counter).first_name:=l_getGroupResourceInfo.person_first_name;
321 x_attendee_data(i_counter).middle_name:=l_getGroupResourceInfo.person_middle_name;
322 x_attendee_data(i_counter).last_name:=l_getGroupResourceInfo.person_last_name;
323 x_attendee_data(i_counter).primary_phone_country_code:=l_getGroupResourceInfo.primary_phone_country_code;
324 x_attendee_data(i_counter).primary_phone_area_code:=l_getGroupResourceInfo.primary_phone_area_code;
325 x_attendee_data(i_counter).primary_phone_number:=l_getGroupResourceInfo.primary_phone_number;
326 x_attendee_data(i_counter).primary_phone_extension:=l_getGroupResourceInfo.primary_phone_extension;
327 x_attendee_data(i_counter).email_address:=l_getGroupResourceInfo.email_address;
328 x_attendee_data(i_counter).job_title:=l_getGroupResourceInfo.job_title;
329
330 end if;-- if (getGroupResourceInfo%FOUND) then
331
332 if (getGroupResourceInfo%ISOPEN) then
333 close getGroupResourceInfo;
334 end if;
335
336 end if;-- if (c_attendee.resource_type_code='RS_GROUP') then
337
338 i_counter := i_counter + 1 ;
339
340 END LOOP;
341
342
343 END LOOP;
344
345
346 END get_all_data;
347
348
349
350 -------------------------------
351 -- Public Method
352 -------------------------------
353 PROCEDURE get_count (
354 p_request_type IN VARCHAR2,
355 p_syncanchor IN DATE,
356 p_principal_id IN NUMBER,
357 x_total OUT NOCOPY NUMBER,
358 x_totalnew OUT NOCOPY NUMBER,
359 x_totalmodified OUT NOCOPY NUMBER,
360 x_totaldeleted OUT NOCOPY NUMBER
361 )
362 IS
363 l_syncanchor DATE;
364 l_data cac_sync_task.task_tbl;
365 l_exclusion_data cac_sync_task.exclusion_tbl;
366 l_attendee_data Cac_Sync_Task.attendee_tbl;
367 BEGIN
368 x_total := 0;
369 x_totalnew := 0;
370 x_totalmodified := 0;
371 x_totaldeleted := 0;
372
373 -- Call the private api to get the data.
374 get_all_data (
375 p_request_type => p_request_type,
376 p_syncanchor => p_syncanchor,
377 p_principal_id => p_principal_id,
378 p_get_data => FALSE,
379 p_sync_type => 'IS', --it will not delete the booking data,only on get list we will delete booking data
380 x_totalnew => x_totalnew,
381 x_totalmodified => x_totalmodified,
382 x_totaldeleted => x_totaldeleted,
383 x_data => l_data,
384 x_exclusion_data => l_exclusion_data,
385 x_attendee_data => l_attendee_data
386 );
387 x_total := x_totalnew + x_totalmodified + x_totaldeleted;
388
389 END get_count;
390
391 --only on get_list will booking data be deleted.
392 --On get_count the booking data will not be deleted.
393
394 PROCEDURE get_list (
395 p_request_type IN VARCHAR2,
396 p_syncanchor IN DATE,
397 p_principal_id IN NUMBER,
398 p_sync_type IN VARCHAR2, --'SS' for slow sync, 'IS' for Incremental sync
399 x_data OUT NOCOPY cac_sync_task.task_tbl,
400 x_exclusion_data OUT NOCOPY cac_sync_task.exclusion_tbl,
401 x_attendee_data OUT NOCOPY Cac_Sync_Task.attendee_tbl
402
403 )
404 IS
405 l_totalnew NUMBER;
406 l_totalmodified NUMBER;
407 l_totaldeleted NUMBER;
408 l_data cac_sync_task.task_tbl;
409 l_resource_id NUMBER;
410 l_resource_type VARCHAR2(30);
411 BEGIN
412 get_all_data (
413 p_request_type => p_request_type,
414 p_syncanchor => p_syncanchor,
415 p_principal_id => p_principal_id,
416 p_get_data => TRUE,
417 p_sync_type => p_sync_type,
418 x_totalnew => l_totalnew,
419 x_totalmodified => l_totalmodified,
420 x_totaldeleted => l_totaldeleted,
421 x_data => l_data,
422 x_exclusion_data => x_exclusion_data,
423 x_attendee_data => x_attendee_data
424 );
425 x_data := l_data;
426 END get_list;
427
428 PROCEDURE create_ids (
429 p_num_req IN NUMBER,
430 x_results IN OUT NOCOPY cac_sync_task.task_tbl
431 )
432 IS
433 BEGIN
434 FOR i IN 1 .. NVL (p_num_req, 0)
435 LOOP
436 -- Fix Bug# 2387015 to avoid using contacts sequence number
437 SELECT jta_sync_task_mapping_s.nextval
438 INTO x_results (i).syncid
439 FROM DUAL;
440 x_results (i).resultid := cac_sync_task_common.g_sync_success; --success, no message will be displayed to user
441 END LOOP;
442 END create_ids;
446 IS
443
444 PROCEDURE update_data (p_tasks IN OUT NOCOPY cac_sync_task.task_tbl
445 ,p_exclusions IN OUT NOCOPY cac_sync_task.exclusion_tbl)
447 l_resource_id NUMBER;
448 l_resource_type VARCHAR2(100);
449 l_is_this_new_task BOOLEAN;
450 l_old_sync_id NUMBER;
451 l_principal_id NUMBER;
452 l_new_task_id NUMBER;
453 BEGIN
454 cac_sync_task_common.get_resource_details (l_resource_id, l_resource_type);
455
456 g_login_resource_id := l_resource_id;
457
458
459 for i IN 1 .. NVL (p_tasks.LAST, 0)
460 LOOP
461 if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
462
463 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'sync id ' ||p_tasks(i).syncId||' for task name '|| p_tasks(i).subject);
464 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'task id ' ||p_tasks(i).task_id||' for task name '|| p_tasks(i).subject);
465 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'objectcode ' ||p_tasks(i).objectCode||' for task name '|| p_tasks(i).objectCode);
466 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'subject ' ||p_tasks(i).subject||' for task name '|| p_tasks(i).subject);
467 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'description ' ||p_tasks(i).description||' for task name '|| p_tasks(i).subject);
468
469 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'dateSelected ' ||p_tasks(i).dateSelected||' for task name '|| p_tasks(i).subject);
470 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'plannedStartDate ' ||p_tasks(i).plannedStartDate||' for task name '|| p_tasks(i).subject);
471 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'plannedEndDate ' ||p_tasks(i).plannedEndDate||' for task name '|| p_tasks(i).objectCode);
472 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'scheduledStartDate ' ||p_tasks(i).scheduledStartDate||' for task name '|| p_tasks(i).subject);
473 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'scheduledEndDate ' ||p_tasks(i).scheduledEndDate||' for task name '|| p_tasks(i).subject);
474
475 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'actualStartDate ' ||p_tasks(i).actualStartDate||' for task name '|| p_tasks(i).subject);
476 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'actualendDate ' ||p_tasks(i).actualendDate||' for task name '|| p_tasks(i).subject);
477 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'statusId ' ||p_tasks(i).statusId||' for task name '|| p_tasks(i).objectCode);
478 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'priorityId ' ||p_tasks(i).priorityId||' for task name '|| p_tasks(i).subject);
479 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'alarmFlag ' ||p_tasks(i).alarmFlag||' for task name '|| p_tasks(i).subject);
480
481 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'alarmDate ' ||p_tasks(i).alarmDate||' for task name '|| p_tasks(i).subject);
482 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'privateFlag ' ||p_tasks(i).privateFlag||' for task name '|| p_tasks(i).subject);
483 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'catgory ' ||p_tasks(i).category||' for task name '|| p_tasks(i).objectCode);
484 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'resource Id ' ||p_tasks(i).resourceId||' for task name '|| p_tasks(i).subject);
485 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'resourc type ' ||p_tasks(i).resourceType||' for task name '|| p_tasks(i).subject);
486
487 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'assignemtn id ' ||p_tasks(i).task_assignment_id||' for task name '|| p_tasks(i).subject);
488 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'result id ' ||p_tasks(i).resultId||' for task name '|| p_tasks(i).subject);
489 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'resultSystemMessage ' ||p_tasks(i).resultSystemMessage||' for task name '|| p_tasks(i).objectCode);
490 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'unit_of_measure ' ||p_tasks(i).unit_of_measure||' for task name '|| p_tasks(i).subject);
491
492 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'occurs_which ' ||p_tasks(i).occurs_which||' for task name '|| p_tasks(i).subject);
493 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'occurs every ' ||p_tasks(i).occurs_every ||' for task name '|| p_tasks(i).subject);
494 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'date of month ' ||p_tasks(i).date_of_month||' for task name '|| p_tasks(i).subject);
495 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'locations ' ||p_tasks(i).locations||' for task name '|| p_tasks(i).objectCode);
496 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'principal id ' ||p_tasks(i).principal_id||' for task name '|| p_tasks(i).subject);
497 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'free busy type ' ||p_tasks(i).free_busy_type||' for task name '|| p_tasks(i).subject);
498 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'dial in ' ||p_tasks(i).dial_in||' for task name '|| p_tasks(i).subject);
499
500 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'sunday ' ||p_tasks(i).sunday ||' for task name '|| p_tasks(i).subject);
501 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'monday ' ||p_tasks(i).monday||' for task name '|| p_tasks(i).subject);
502 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'tuesday ' ||p_tasks(i).tuesday||' for task name '|| p_tasks(i).subject);
503 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'wednesday ' ||p_tasks(i).wednesday||' for task name '|| p_tasks(i).subject);
504 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'thursday ' ||p_tasks(i).thursday||' for task name '|| p_tasks(i).subject);
508 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'unit_of_measure ' ||p_tasks(i).unit_of_measure||' for task name '|| p_tasks(i).subject);
505 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'friday ' ||p_tasks(i).friday||' for task name '|| p_tasks(i).subject);
506 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_dataa', 'saturday ' ||p_tasks(i).saturday||' for task name '|| p_tasks(i).subject);
507 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'date_of_month ' ||p_tasks(i).date_of_month||' for task name '|| p_tasks(i).subject);
509 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'start_date ' ||p_tasks(i).start_date||' for task name '|| p_tasks(i).subject);
510 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'end_date ' ||p_tasks(i).end_date||' for task name '|| p_tasks(i).subject);
511
512
513 end if;
514 end loop;
515
516
517
518 FOR i IN 1 .. NVL (p_tasks.LAST, 0)
519 LOOP
520 l_is_this_new_task := cac_sync_task_common.is_this_new_task(p_tasks(i).syncid);
521
522 IF p_tasks(i).subject IS NOT NULL AND
523 ( ( l_is_this_new_task AND p_tasks(i).subject <> FND_API.G_MISS_CHAR) OR
524 (NOT l_is_this_new_task)
525 )
526 THEN
527
528 IF l_is_this_new_task
529 THEN -- This is a new task
530 cac_sync_task_common.create_new_data( p_task_rec => p_tasks(i)
531 , p_exclusion_tbl => p_exclusions
532 , p_resource_id => l_resource_id
533 , p_resource_type => l_resource_type);
534
535
536
537 ELSE -- This is an existing task
538
539 if (cac_sync_task_common.is_recur_rule_same(p_task_rec=>p_tasks(i))) then
540
541 if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
542
543 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'recurrence rule is same so calling update_existing_data');
544 end if;
545
546 cac_sync_task_common.update_existing_data( p_task_rec => p_tasks(i)
547 , p_exclusion_tbl => p_exclusions
548 , p_resource_id => l_resource_id
549 , p_resource_type => l_resource_type);
550
551 else
552 --case when re-inclusion happens on the client. the server deleted all data and re-creates them .
553
554
555
556
557 l_old_sync_id:=p_tasks(i).syncid;
558 l_principal_id:=p_tasks(i).principal_id;
559
560
561 if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
562
563 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'calling delete_task and then create task inside update_data');
564 end if;
565
566 cac_sync_task_common.delete_task_data (p_task_rec=>p_tasks(i));
567
568
569
570
571 cac_sync_task_common.create_new_data( p_task_rec => p_tasks(i)
572 , p_exclusion_tbl => p_exclusions
573 , p_resource_id => l_resource_id
574 , p_resource_type => l_resource_type);
575
576
577 --update sync mapping table with old sync_id.
578 l_new_task_id := cac_sync_task_common.get_task_id (p_sync_id => p_tasks(i).syncid);
579
580 if (l_new_task_id is not null) then
581
582 if( FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
583
584 FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE,'cac_sync_task.update_data', 'updating sync mapping after deletion and creation of data');
585 end if;
586
587 UPDATE jta_sync_task_mapping
588 SET task_sync_id = l_old_sync_id,
589 last_update_date = sysdate,
590 last_updated_by = fnd_global.user_id,
591 last_update_login = fnd_global.login_id
592
593 WHERE task_id = l_new_task_id
594 and principal_id = l_principal_id;
595
596 else
597
598 cac_sync_common.put_messages_to_result (
599 p_tasks(i),
600 p_status => 2,
601 p_user_message => 'JTA_SYNC_NULL_TASKNAME'
602 );
603
604
605 end if;-- for if (l_new_task_id is not null) then
606
607 end if;--for if (cac_sync_task_common.is_recur_rule_same(p_task_rec=>p_tasks(i)) then
608
609 END IF;-- for IF l_is_this_new_task
610 ELSE
611 cac_sync_common.put_messages_to_result (
612 p_tasks(i),
613 p_status => 2,
614 p_user_message => 'JTA_SYNC_NULL_TASKNAME'
615 );
616 END IF;
617
618 p_tasks(i).recordIndex := i ;
619 END LOOP; -- for loop of p_tasks
620
621
622 END update_data;
623
624 PROCEDURE delete_data (
625 p_tasks IN OUT NOCOPY cac_sync_task.task_tbl
626 )
627 IS
628 l_task_id NUMBER;
629 l_delete_flag VARCHAR2(1);
630 l_resource_id NUMBER;
631 l_resource_type VARCHAR2(30);
632 l_status_id NUMBER;
633 l_sync_id NUMBER;
634 l_source_object_type_code VARCHAR2(60);
638
635 BEGIN
636 cac_sync_task_common.get_resource_details (l_resource_id, l_resource_type);
637 g_login_resource_id := l_resource_id;
639
640
641 commit;
642
643
644 FOR i IN 1 .. NVL (p_tasks.LAST, 0)
645 LOOP
646 IF cac_sync_task_common.validate_syncid(p_syncid => p_tasks(i).syncid) -- Fix Bug 2382927
647 THEN
648 fnd_msg_pub.initialize;
649
650 l_sync_id := p_tasks (i).syncid;
651 l_task_id := cac_sync_task_common.get_task_id (p_sync_id => l_sync_id);
652 l_source_object_type_code := cac_sync_task_common.get_source_object_type(p_task_id => l_task_id);
653
654
655
656 cac_sync_task_common.check_delete_data(
657 p_task_id => l_task_id,
658 p_resource_id => l_resource_id,
659 p_objectcode => l_source_object_type_code,
660 x_status_id => l_status_id,
661 x_delete_flag => l_delete_flag);
662
663 IF l_delete_flag = 'D'
664 THEN
665
666
667 cac_sync_task_common.delete_task_data(p_task_rec => p_tasks(i));
668
669 ELSIF l_delete_flag = 'U'
670
671 THEN
672
673 cac_sync_task_common.reject_task_data(p_task_rec => p_tasks(i));
674
675 ELSE -- l_delete_flag = 'X'
676
677
678 p_tasks (i).syncanchor := cac_sync_task_common.convert_server_to_gmt (SYSDATE);
679 cac_sync_common.put_messages_to_result (p_tasks (i),
680 p_status => cac_sync_task_common.g_sync_success,
681 p_user_message => 'JTA_SYNC_SUCCESS');
682
683 END IF; -- l_delete_flag
684 --------------------------------------------------------------
685 -- Fix Bug 2382927 :
686 -- When Intellisync sends a sync id which has not been synced,
687 -- the record is ignored and returned as success.
688 --------------------------------------------------------------
689 ELSE -- Cannot found sync id in mapping table
690
691 p_tasks (i).syncanchor := cac_sync_task_common.convert_server_to_gmt (SYSDATE); -- Newly added on 04-Jun-2002 to fix bug 2382927
692 cac_sync_common.put_messages_to_result (
693 p_tasks(i),
694 p_status => cac_sync_task_common.g_sync_success,
695 p_user_message => 'JTA_SYNC_SUCCESS'
696 );
697 END IF; -- cac_sync_task_common.validate_syncid(p_syncid => p_tasks(i).syncid)
698 END LOOP; -- FOR i IN 1 .. NVL (p_tasks.LAST, 0)
699 commit;
700
701 END delete_data;
702
703
704
705 END Cac_Sync_Task;