1: package body WF_ENGINE as
2: /* $Header: wfengb.pls 120.38.12020000.3 2012/11/13 19:42:45 alsosa ship $ */
3:
4: type InstanceArrayTyp is table of pls_integer
5: index by binary_integer;
39: function Current_Schema
40: return varchar2
41: is
42: begin
43: if (wf_engine.schema is null) then
44: select sys_context('USERENV','CURRENT_SCHEMA')
45: into wf_engine.schema
46: from sys.dual;
47: end if;
41: is
42: begin
43: if (wf_engine.schema is null) then
44: select sys_context('USERENV','CURRENT_SCHEMA')
45: into wf_engine.schema
46: from sys.dual;
47: end if;
48: return wf_engine.schema;
49: exception
44: select sys_context('USERENV','CURRENT_SCHEMA')
45: into wf_engine.schema
46: from sys.dual;
47: end if;
48: return wf_engine.schema;
49: exception
50: when OTHERS then
51: Wf_Core.Context('Wf_Engine', 'Current_Schema');
52: raise;
47: end if;
48: return wf_engine.schema;
49: exception
50: when OTHERS then
51: Wf_Core.Context('Wf_Engine', 'Current_Schema');
52: raise;
53: end Current_Schema;
54:
55: --
94: Wf_Core.Raise('WFENG_ITEM');
95:
96: end if;
97:
98: if (itemkey = wf_engine.eng_synch) then
99: --ItemAttrValues are indexed on the hash value of the name.
100: --ItemKey is not used here because we are in #SYNCH mode.
101: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname, iStatus, wiavIND);
102:
126: end if;
127:
128: exception
129: when dup_val_on_index then
130: Wf_Core.Context('Wf_Engine', 'AddItemAttr', itemtype, itemkey, aname);
131: Wf_Core.Token('TYPE', itemtype);
132: Wf_Core.Token('KEY', itemkey);
133: Wf_Core.Token('ATTRIBUTE', aname);
134: Wf_Core.Raise('WFENG_ITEM_ATTR_UNIQUE');
132: Wf_Core.Token('KEY', itemkey);
133: Wf_Core.Token('ATTRIBUTE', aname);
134: Wf_Core.Raise('WFENG_ITEM_ATTR_UNIQUE');
135: when others then
136: Wf_Core.Context('Wf_Engine', 'AddItemAttr', itemtype, itemkey, aname);
137: raise;
138: end AddItemAttr;
139:
140: --
151: --
152: procedure AddItemAttrTextArray(
153: itemtype in varchar2,
154: itemkey in varchar2,
155: aname in Wf_Engine.NameTabTyp,
156: avalue in Wf_Engine.TextTabTyp)
157: is
158: iStatus pls_integer;
159: wiavIND pls_integer;
152: procedure AddItemAttrTextArray(
153: itemtype in varchar2,
154: itemkey in varchar2,
155: aname in Wf_Engine.NameTabTyp,
156: avalue in Wf_Engine.TextTabTyp)
157: is
158: iStatus pls_integer;
159: wiavIND pls_integer;
160: arrayIndex pls_integer;
190:
191: -- Check to see if we are in synch mode and use WF_CACHE.
192:
193: success_cnt := 0;
194: if (itemkey = wf_engine.eng_synch) then
195: -- Use WF_CACHE.ItemAttrValues for #SYNCH mode.
196: for arrayIndex in aname.FIRST..aname.LAST loop
197: -- first check duplicate attribute name
198: WF_CACHE.GetItemAttrValue( itemType, itemKey, aname(arrayIndex), iStatus,
234: end if;
235:
236: exception
237: when dup_val_on_index then
238: Wf_Core.Context('Wf_Engine', 'AddItemAttrTextArray', itemtype, itemkey);
239: Wf_Core.Token('TYPE', itemtype);
240: Wf_Core.Token('KEY', itemkey);
241: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
242: Wf_Core.Token('SUCCESS', to_char(success_cnt));
241: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
242: Wf_Core.Token('SUCCESS', to_char(success_cnt));
243: Wf_Core.Raise('WFENG_ITEM_ATTR_ARRAY');
244: when others then
245: Wf_Core.Context('Wf_Engine', 'AddItemAttrTextArray', itemtype, itemkey);
246: raise;
247: end AddItemAttrTextArray;
248:
249: --
260: --
261: procedure AddItemAttrNumberArray(
262: itemtype in varchar2,
263: itemkey in varchar2,
264: aname in Wf_Engine.NameTabTyp,
265: avalue in Wf_Engine.NumTabTyp)
266: is
267: arrayIndex pls_integer;
268: iStatus pls_integer;
261: procedure AddItemAttrNumberArray(
262: itemtype in varchar2,
263: itemkey in varchar2,
264: aname in Wf_Engine.NameTabTyp,
265: avalue in Wf_Engine.NumTabTyp)
266: is
267: arrayIndex pls_integer;
268: iStatus pls_integer;
269: wiavIND NUMBER;
296:
297: success_cnt := 0;
298: --If we are in #SYNCH mode, we will go ahead and use WF_CACHE to
299: --Store the attributes.
300: if (itemkey = wf_engine.eng_synch) then
301: for arrayIndex in aname.FIRST..aname.LAST loop
302: -- first check duplicate attribute name
303: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname(arrayIndex), iStatus,
304: wiavIND);
335: end if;
336:
337: exception
338: when dup_val_on_index then
339: Wf_Core.Context('Wf_Engine', 'AddItemAttrNumberArray', itemtype, itemkey);
340: Wf_Core.Token('TYPE', itemtype);
341: Wf_Core.Token('KEY', itemkey);
342: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
343: Wf_Core.Token('SUCCESS', to_char(success_cnt));
342: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
343: Wf_Core.Token('SUCCESS', to_char(success_cnt));
344: Wf_Core.Raise('WFENG_ITEM_ATTR_ARRAY');
345: when others then
346: Wf_Core.Context('Wf_Engine', 'AddItemAttrNumberArray', itemtype, itemkey);
347: raise;
348: end AddItemAttrNumberArray;
349:
350: --
361: --
362: procedure AddItemAttrDateArray(
363: itemtype in varchar2,
364: itemkey in varchar2,
365: aname in Wf_Engine.NameTabTyp,
366: avalue in Wf_Engine.DateTabTyp)
367: is
368: iStatus pls_integer;
369: wiavIND number;
362: procedure AddItemAttrDateArray(
363: itemtype in varchar2,
364: itemkey in varchar2,
365: aname in Wf_Engine.NameTabTyp,
366: avalue in Wf_Engine.DateTabTyp)
367: is
368: iStatus pls_integer;
369: wiavIND number;
370: success_cnt number;
397: end if;
398:
399: success_cnt := 0;
400: -- If in #SYNCH mode, we will use WF_CACHE to store the attributes.
401: if (itemkey = wf_engine.eng_synch) then
402: for arrayIndex in aname.FIRST..aname.LAST loop
403: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname(arrayIndex), iStatus,
404: wiavIND);
405:
434: end if;
435:
436: exception
437: when dup_val_on_index then
438: Wf_Core.Context('Wf_Engine', 'AddItemAttrDateArray', itemtype, itemkey);
439: Wf_Core.Token('TYPE', itemtype);
440: Wf_Core.Token('KEY', itemkey);
441: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
442: Wf_Core.Token('SUCCESS', to_char(success_cnt));
441: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
442: Wf_Core.Token('SUCCESS', to_char(success_cnt));
443: Wf_Core.Raise('WFENG_ITEM_ATTR_ARRAY');
444: when others then
445: Wf_Core.Context('Wf_Engine', 'AddItemAttrDateArray', itemtype, itemkey);
446: raise;
447: end AddItemAttrDateArray;
448:
449: --
520: nvalue := to_number(avalue);
521: else
522: nvalue := to_number(avalue, WF_CACHE.ItemAttributes(wiaIND).FORMAT);
523: end if;
524: Wf_Engine.SetItemAttrNumber(itemtype, itemkey, aname, nvalue);
525:
526: elsif (WF_CACHE.ItemAttributes(wiaIND).TYPE = 'DATE') then
527:
528: if (WF_CACHE.ItemAttributes(wiaIND).FORMAT is null) then
529: dvalue := to_date(avalue,SYS_CONTEXT('USERENV','NLS_DATE_FORMAT'));
530: else
531: dvalue := to_date(avalue, WF_CACHE.ItemAttributes(wiaIND).FORMAT);
532: end if;
533: Wf_Engine.SetItemAttrDate(itemtype, itemkey, aname, dvalue);
534:
535: else -- One of the text values
536:
537: if (WF_CACHE.ItemAttributes(wiaIND).TYPE = 'VARCHAR2') then
574: tvalue := avalue;
575: end if;
576:
577: -- Set the text value.
578: if (itemkey = wf_engine.eng_synch) then
579: -- Use WF_CACHE in synch mode
580: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname, status, wiavIND);
581:
582: if (status <> WF_CACHE.task_SUCCESS) then
620: end if;
621:
622: exception
623: when no_data_found then
624: Wf_Core.Context('Wf_Engine', 'SetItemAttrText', itemtype, itemkey,
625: aname, avalue);
626: Wf_Core.Token('TYPE', itemtype);
627: Wf_Core.Token('KEY', itemkey);
628: Wf_Core.Token('ATTRIBUTE', aname);
628: Wf_Core.Token('ATTRIBUTE', aname);
629: Wf_Core.Raise('WFENG_ITEM_ATTR');
630:
631: when bad_format then --
632: Wf_Core.Context('Wf_Engine', 'SetItemAttrText', itemtype, itemkey,
633: aname, avalue);
634: Wf_Core.Token('VALUE', avalue);
635: Wf_Core.Token('TYPE', WF_CACHE.ItemAttributes(wiaIND).TYPE);
636:
644:
645: Wf_Core.Raise('WFENG_BAD_FORMAT');
646:
647: when others then
648: Wf_Core.Context('Wf_Engine', 'SetItemAttrText', itemtype, itemkey,
649: aname, avalue);
650: raise;
651: end SetItemAttrText;
652:
682: Wf_Core.Raise('WFSQL_ARGS');
683: end if;
684:
685: -- Set the text value.
686: if (p_itemkey = wf_engine.eng_synch) then
687: -- Use WF_CACHE in synch mode
688: WF_CACHE.GetItemAttrValue(p_itemtype, p_itemkey, p_aname, status, wiavIND);
689:
690: if (status <> WF_CACHE.task_SUCCESS) then
735: when no_data_found then
736: return FALSE;
737:
738: when others then
739: Wf_Core.Context('Wf_Engine', 'SetItemAttrText2', p_itemtype, p_itemkey,
740: p_aname, p_avalue);
741: raise;
742: end SetItemAttrText2;
743:
799: nvalue := to_number(avalue, wf_core.canonical_number_mask);
800: else
801: nvalue := to_number(avalue, WF_CACHE.ItemAttributes(wiaIND).FORMAT);
802: end if;
803: Wf_Engine.SetItemAttrNumber(itemtype, itemkey, aname, nvalue);
804:
805: elsif (WF_CACHE.ItemAttributes(wiaIND).TYPE = 'DATE') then
806:
807: if (WF_CACHE.ItemAttributes(wiaIND).FORMAT is null) then
808: dvalue := to_date(avalue, wf_core.canonical_date_mask);
809: else
810: dvalue := to_date(avalue, WF_CACHE.ItemAttributes(wiaIND).FORMAT);
811: end if;
812: Wf_Engine.SetItemAttrDate(itemtype, itemkey, aname, dvalue);
813:
814: else -- One of the text values
815:
816: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, avalue);
812: Wf_Engine.SetItemAttrDate(itemtype, itemkey, aname, dvalue);
813:
814: else -- One of the text values
815:
816: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, avalue);
817:
818: end if;
819:
820: exception
818: end if;
819:
820: exception
821: when no_data_found then
822: Wf_Core.Context('Wf_Engine', 'SetEventItemAttr', itemtype, itemkey,
823: aname, avalue);
824: Wf_Core.Token('TYPE', itemtype);
825: Wf_Core.Token('KEY', itemkey);
826: Wf_Core.Token('ATTRIBUTE', aname);
826: Wf_Core.Token('ATTRIBUTE', aname);
827: Wf_Core.Raise('WFENG_ITEM_ATTR');
828:
829: when others then
830: Wf_Core.Context('Wf_Engine', 'SetEventItemAttr', itemtype, itemkey,
831: aname, avalue);
832: raise;
833: end SetEventItemAttr;
834:
860: Wf_Core.Token('ANAME', nvl(aname, 'NULL'));
861: Wf_Core.Raise('WFSQL_ARGS');
862: end if;
863:
864: if (itemkey = wf_engine.eng_synch) then
865: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname, iStatus, wiavIND);
866:
867: if (iStatus <> WF_CACHE.task_SUCCESS) then
868: raise no_data_found;
904: end if;
905:
906: exception
907: when no_data_found then
908: Wf_Core.Context('Wf_Engine', 'SetItemAttrNumber', itemtype, itemkey,
909: aname, to_char(avalue));
910: Wf_Core.Token('TYPE', itemtype);
911: Wf_Core.Token('KEY', itemkey);
912: Wf_Core.Token('ATTRIBUTE', aname);
912: Wf_Core.Token('ATTRIBUTE', aname);
913: Wf_Core.Raise('WFENG_ITEM_ATTR');
914:
915: when others then
916: Wf_Core.Context('Wf_Engine', 'SetItemAttrNumber', itemtype, itemkey,
917: aname, to_char(avalue));
918: raise;
919: end SetItemAttrNumber;
920:
947: Wf_Core.Token('ANAME', nvl(aname, 'NULL'));
948: Wf_Core.Raise('WFSQL_ARGS');
949: end if;
950:
951: if (itemkey = wf_engine.eng_synch) then
952: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname, iStatus, wiavIND);
953:
954: if (iStatus <> WF_CACHE.task_SUCCESS) then
955: raise no_data_found;
991: end if;
992:
993: exception
994: when no_data_found then
995: Wf_Core.Context('Wf_Engine', 'SetItemAttrDate', itemtype, itemkey,
996: aname, to_char(avalue));
997: Wf_Core.Token('TYPE', itemtype);
998: Wf_Core.Token('KEY', itemkey);
999: Wf_Core.Token('ATTRIBUTE', aname);
999: Wf_Core.Token('ATTRIBUTE', aname);
1000: Wf_Core.Raise('WFENG_ITEM_ATTR');
1001:
1002: when bad_format then --
1003: Wf_Core.Context('Wf_Engine', 'SetItemAttr', itemtype, itemkey,
1004: aname, avalue);
1005: Wf_Core.Token('VALUE', avalue);
1006: Wf_Core.Token('FORMAT', 'DATE');
1007: Wf_Core.Raise('WFENG_BAD_FORMAT');
1006: Wf_Core.Token('FORMAT', 'DATE');
1007: Wf_Core.Raise('WFENG_BAD_FORMAT');
1008:
1009: when others then
1010: Wf_Core.Context('Wf_Engine', 'SetItemAttrDate', itemtype, itemkey,
1011: aname, to_char(avalue));
1012: raise;
1013: end SetItemAttrDate;
1014:
1039: Wf_Core.Token('ANAME', nvl(aname, 'NULL'));
1040: Wf_Core.Raise('WFSQL_ARGS');
1041: end if;
1042:
1043: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, documentid);
1044: exception
1045: when others then
1046: Wf_Core.Context('Wf_Engine', 'SetItemAttrDocument', itemtype, itemkey,
1047: aname);
1042:
1043: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, documentid);
1044: exception
1045: when others then
1046: Wf_Core.Context('Wf_Engine', 'SetItemAttrDocument', itemtype, itemkey,
1047: aname);
1048: raise;
1049: end SetItemAttrDocument;
1050:
1074: Wf_Core.Raise('WFSQL_ARGS');
1075: end if;
1076:
1077: -- Not allowed in synch mode
1078: if (itemkey = wf_engine.eng_synch) then
1079: wf_core.token('OPERATION', 'Wf_Engine.SetItemAttrEvent');
1080: wf_core.raise('WFENG_SYNCH_DISABLED');
1081: end if;
1082:
1075: end if;
1076:
1077: -- Not allowed in synch mode
1078: if (itemkey = wf_engine.eng_synch) then
1079: wf_core.token('OPERATION', 'Wf_Engine.SetItemAttrEvent');
1080: wf_core.raise('WFENG_SYNCH_DISABLED');
1081: end if;
1082:
1083: update WF_ITEM_ATTRIBUTE_VALUES set
1110: end if;
1111: end if;
1112: exception
1113: when no_data_found then
1114: Wf_Core.Context('Wf_Engine', 'SetItemAttrEvent', itemtype, itemkey,
1115: name);
1116: Wf_Core.Token('TYPE', itemtype);
1117: Wf_Core.Token('KEY', itemkey);
1118: Wf_Core.Token('ATTRIBUTE', name);
1117: Wf_Core.Token('KEY', itemkey);
1118: Wf_Core.Token('ATTRIBUTE', name);
1119: Wf_Core.Raise('WFENG_ITEM_ATTR');
1120: when others then
1121: Wf_Core.Context('Wf_Engine', 'SetItemAttrEvent', itemtype, itemkey,
1122: name);
1123: raise;
1124: end SetItemAttrEvent;
1125:
1135: --
1136: procedure SetItemAttrTextArray(
1137: itemtype in varchar2,
1138: itemkey in varchar2,
1139: aname in Wf_Engine.NameTabTyp,
1140: avalue in Wf_Engine.TextTabTyp)
1141: is
1142: status pls_integer;
1143: arrayIndex pls_integer;
1136: procedure SetItemAttrTextArray(
1137: itemtype in varchar2,
1138: itemkey in varchar2,
1139: aname in Wf_Engine.NameTabTyp,
1140: avalue in Wf_Engine.TextTabTyp)
1141: is
1142: status pls_integer;
1143: arrayIndex pls_integer;
1144: wiavIND number;
1163: Wf_Core.Raise('WFENG_ITEM_ATTR_ARRAY_MISMATCH');
1164: end if;
1165:
1166: -- Set the text value.
1167: if (itemkey = wf_engine.eng_synch) then
1168: -- Use WF_CACHE in synch mode
1169: success_cnt := 0;
1170:
1171: for arrayIndex in aname.FIRST..aname.LAST loop
1221: end if;
1222:
1223: exception
1224: when no_data_found then
1225: Wf_Core.Context('Wf_Engine', 'SetItemAttrTextArray', itemtype, itemkey);
1226: Wf_Core.Token('TYPE', itemtype);
1227: Wf_Core.Token('KEY', itemkey);
1228: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
1229: Wf_Core.Token('SUCCESS', to_char(success_cnt));
1229: Wf_Core.Token('SUCCESS', to_char(success_cnt));
1230: Wf_Core.Raise('WFENG_ITEM_ATTR_ARRAY');
1231:
1232: when others then
1233: Wf_Core.Context('Wf_Engine', 'SetItemAttrTextArray', itemtype, itemkey);
1234: raise;
1235: end SetItemAttrTextArray;
1236:
1237:
1247: --
1248: procedure SetItemAttrNumberArray(
1249: itemtype in varchar2,
1250: itemkey in varchar2,
1251: aname in Wf_Engine.NameTabTyp,
1252: avalue in Wf_Engine.NumTabTyp)
1253: is
1254: arrayIndex pls_integer;
1255: status pls_integer;
1248: procedure SetItemAttrNumberArray(
1249: itemtype in varchar2,
1250: itemkey in varchar2,
1251: aname in Wf_Engine.NameTabTyp,
1252: avalue in Wf_Engine.NumTabTyp)
1253: is
1254: arrayIndex pls_integer;
1255: status pls_integer;
1256: wiavIND number;
1275:
1276: end if;
1277:
1278: -- Set the number value.
1279: if (itemkey = wf_engine.eng_synch) then
1280: -- Use WF_CACHE in synch mode
1281: success_cnt := 0;
1282:
1283: for arrayIndex in aname.FIRST..aname.LAST loop
1334: end if;
1335:
1336: exception
1337: when no_data_found then
1338: Wf_Core.Context('Wf_Engine', 'SetItemAttrNumberArray', itemtype, itemkey);
1339: Wf_Core.Token('TYPE', itemtype);
1340: Wf_Core.Token('KEY', itemkey);
1341: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
1342: Wf_Core.Token('SUCCESS', to_char(success_cnt));
1342: Wf_Core.Token('SUCCESS', to_char(success_cnt));
1343: Wf_Core.Raise('WFENG_ITEM_ATTR_ARRAY');
1344:
1345: when others then
1346: Wf_Core.Context('Wf_Engine', 'SetItemAttrNumberArray', itemtype, itemkey);
1347: raise;
1348: end SetItemAttrNumberArray;
1349:
1350: --
1359: --
1360: procedure SetItemAttrDateArray(
1361: itemtype in varchar2,
1362: itemkey in varchar2,
1363: aname in Wf_Engine.NameTabTyp,
1364: avalue in Wf_Engine.DateTabTyp)
1365: is
1366: status pls_integer;
1367: arrayIndex pls_integer;
1360: procedure SetItemAttrDateArray(
1361: itemtype in varchar2,
1362: itemkey in varchar2,
1363: aname in Wf_Engine.NameTabTyp,
1364: avalue in Wf_Engine.DateTabTyp)
1365: is
1366: status pls_integer;
1367: arrayIndex pls_integer;
1368: wiavIND number;
1388: end if;
1389:
1390: success_cnt := 0;
1391: -- Set the date value.
1392: if (itemkey = wf_engine.eng_synch) then
1393: -- Use WF_CACHE in synch mode
1394: for arrayIndex in aname.FIRST..aname.LAST loop
1395: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname(arrayIndex), status,
1396: wiavIND);
1445: end if;
1446:
1447: exception
1448: when no_data_found then
1449: Wf_Core.Context('Wf_Engine', 'SetItemAttrDateArray', itemtype, itemkey);
1450: Wf_Core.Token('TYPE', itemtype);
1451: Wf_Core.Token('KEY', itemkey);
1452: Wf_Core.Token('TOTAL', to_char(aname.COUNT));
1453: Wf_Core.Token('SUCCESS', to_char(success_cnt));
1453: Wf_Core.Token('SUCCESS', to_char(success_cnt));
1454: Wf_Core.Raise('WFENG_ITEM_ATTR_ARRAY');
1455:
1456: when others then
1457: Wf_Core.Context('Wf_Engine', 'SetItemAttrDateArray', itemtype, itemkey);
1458: raise;
1459: end SetItemAttrDateArray;
1460:
1461: --
1505: format := WF_CACHE.ItemAttributes(wiaIND).FORMAT;
1506:
1507: exception
1508: when no_data_found then
1509: Wf_Core.Context('Wf_Engine', 'GetItemAttrInfo', itemtype, aname);
1510: Wf_Core.Token('TYPE', itemtype);
1511: Wf_Core.Token('KEY', NULL);
1512: Wf_Core.Token('ATTRIBUTE', aname);
1513: Wf_Core.Raise('WFENG_ITEM_ATTR');
1512: Wf_Core.Token('ATTRIBUTE', aname);
1513: Wf_Core.Raise('WFENG_ITEM_ATTR');
1514:
1515: when others then
1516: Wf_Core.Context('Wf_Engine', 'GetItemAttrInfo', itemtype, aname);
1517: raise;
1518: end GetItemAttrInfo;
1519:
1520: --
1582: end if;
1583:
1584: -- Select value from appropriate type column.
1585: if (WF_CACHE.ItemAttributes(wiaIND).TYPE = 'NUMBER') then
1586: nvalue := Wf_Engine.GetItemAttrNumber(itemtype, itemkey, aname);
1587: if (WF_CACHE.ItemAttributes(wiaIND).FORMAT is null) then
1588: lvalue := to_char(nvalue);
1589: else
1590: lvalue := to_char(nvalue, WF_CACHE.ItemAttributes(wiaIND).FORMAT);
1589: else
1590: lvalue := to_char(nvalue, WF_CACHE.ItemAttributes(wiaIND).FORMAT);
1591: end if;
1592: elsif (WF_CACHE.ItemAttributes(wiaIND).TYPE = 'DATE') then
1593: dvalue := Wf_Engine.GetItemAttrDate(itemtype, itemkey, aname);
1594: if (WF_CACHE.ItemAttributes(wiaIND).FORMAT is null) then
1595: lvalue := to_char(dvalue);
1596: else
1597: lvalue := to_char(dvalue, WF_CACHE.ItemAttributes(wiaIND).FORMAT);
1598: end if;
1599: else
1600: -- VARCHAR2, LOOKUP, FORM, URL, DOCUMENT.
1601: -- Get the text value directly with no translation.
1602: if (itemkey = wf_engine.eng_synch) then
1603: -- Use WF_CACHE in synch mode
1604: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname, status, wiavIND);
1605:
1606: if (status <> WF_CACHE.task_SUCCESS) then
1647: return(null);
1648:
1649: else
1650:
1651: Wf_Core.Context('Wf_Engine', 'GetItemAttrText', itemtype, itemkey,
1652: aname);
1653: Wf_Core.Token('TYPE', itemtype);
1654: Wf_Core.Token('KEY', itemkey);
1655: Wf_Core.Token('ATTRIBUTE', aname);
1657:
1658: end if;
1659:
1660: when others then
1661: Wf_Core.Context('Wf_Engine', 'GetItemAttrText', itemtype, itemkey,
1662: aname);
1663: raise;
1664:
1665: end GetItemAttrText;
1695: Wf_Core.Token('ANAME', nvl(aname, 'NULL'));
1696: Wf_Core.Raise('WFSQL_ARGS');
1697: end if;
1698:
1699: if (itemkey = wf_engine.eng_synch) then
1700: -- Use WF_CACHE in synch mode
1701: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname, status, wiavIND);
1702:
1703: if (status <> WF_CACHE.task_SUCCESS) then
1740: return(null);
1741:
1742: else
1743:
1744: Wf_Core.Context('Wf_Engine', 'GetItemAttrNumber', itemtype, itemkey,
1745: aname);
1746: Wf_Core.Token('TYPE', itemtype);
1747: Wf_Core.Token('KEY', itemkey);
1748: Wf_Core.Token('ATTRIBUTE', aname);
1750:
1751: end if;
1752:
1753: when others then
1754: Wf_Core.Context('Wf_Engine', 'GetItemAttrNumber', itemtype, itemkey,
1755: aname);
1756: raise;
1757: end GetItemAttrNumber;
1758:
1786: Wf_Core.Token('ANAME', nvl(aname, 'NULL'));
1787: Wf_Core.Raise('WFSQL_ARGS');
1788: end if;
1789:
1790: if (itemkey = wf_engine.eng_synch) then
1791: -- Use WF_CACHE in synch mode
1792: WF_CACHE.GetItemAttrValue(itemtype, itemKey, aname, status, wiavIND);
1793:
1794: if (status <> WF_CACHE.task_SUCCESS) then
1831: return(null);
1832:
1833: else
1834:
1835: Wf_Core.Context('Wf_Engine', 'GetItemAttrDate', itemtype, itemkey,
1836: aname);
1837: Wf_Core.Token('TYPE', itemtype);
1838: Wf_Core.Token('KEY', itemkey);
1839: Wf_Core.Token('ATTRIBUTE', aname);
1840: Wf_Core.Raise('WFENG_ITEM_ATTR');
1841:
1842: end if;
1843: when others then
1844: Wf_Core.Context('Wf_Engine', 'GetItemAttrDate', itemtype, itemkey,
1845: aname);
1846: raise;
1847: end GetItemAttrDate;
1848:
1875: Wf_Core.Token('ANAME', nvl(aname, 'NULL'));
1876: Wf_Core.Raise('WFSQL_ARGS');
1877: end if;
1878:
1879: return(Wf_Engine.GetItemAttrText(itemtype, itemkey, aname, ignore_notfound));
1880: exception
1881: when others then
1882: Wf_Core.Context('Wf_Engine', 'GetItemAttrDocument', itemtype, itemkey,
1883: aname);
1878:
1879: return(Wf_Engine.GetItemAttrText(itemtype, itemkey, aname, ignore_notfound));
1880: exception
1881: when others then
1882: Wf_Core.Context('Wf_Engine', 'GetItemAttrDocument', itemtype, itemkey,
1883: aname);
1884: raise;
1885: end GetItemAttrDocument;
1886:
1955: -- Parse out document subtypes
1956: null;
1957: else
1958: -- All others just use text value
1959: value := WF_Engine.GetItemAttrText(itemtype, itemkey, aname);
1960: end if;
1961:
1962: -- Write value to fake clob and return
1963: if (value is null) then
1970: end if;
1971:
1972: exception
1973: when others then
1974: Wf_Core.Context('Wf_Engine', 'GetItemAttrClob', itemtype,
1975: itemkey, aname);
1976: raise;
1977: end GetItemAttrClob;
1978:
2005: Wf_Core.Raise('WFSQL_ARGS');
2006: end if;
2007:
2008: -- Not allowed in synch mode
2009: if (itemkey = wf_engine.eng_synch) then
2010: wf_core.token('OPERATION', 'Wf_Engine.GetItemAttrEvent');
2011: wf_core.raise('WFENG_SYNCH_DISABLED');
2012: end if;
2013:
2006: end if;
2007:
2008: -- Not allowed in synch mode
2009: if (itemkey = wf_engine.eng_synch) then
2010: wf_core.token('OPERATION', 'Wf_Engine.GetItemAttrEvent');
2011: wf_core.raise('WFENG_SYNCH_DISABLED');
2012: end if;
2013:
2014: begin
2049: end if;
2050: end;
2051: exception
2052: when no_data_found then
2053: Wf_Core.Context('Wf_Engine', 'GetItemAttrEvent', itemtype, itemkey,
2054: name);
2055: Wf_Core.Token('TYPE', itemtype);
2056: Wf_Core.Token('KEY', itemkey);
2057: Wf_Core.Token('ATTRIBUTE', name);
2056: Wf_Core.Token('KEY', itemkey);
2057: Wf_Core.Token('ATTRIBUTE', name);
2058: Wf_Core.Raise('WFENG_ITEM_ATTR');
2059: when others then
2060: Wf_Core.Context('Wf_Engine', 'GetItemAttrEvent', itemtype,
2061: itemkey, name);
2062: raise;
2063: end GetItemAttrEvent;
2064:
2192: format := WF_CACHE.ActivityAttributes(waaIND).FORMAT;
2193:
2194: exception
2195: when no_data_found then
2196: Wf_Core.Context('Wf_Engine', 'GetActivityAttrInfo', itemtype, itemkey,
2197: to_char(actid), aname);
2198: Wf_Core.Token('TYPE', itemtype);
2199: Wf_Core.Token('KEY', itemkey);
2200: Wf_Core.Token('ACTIVITY', to_char(actid));
2200: Wf_Core.Token('ACTIVITY', to_char(actid));
2201: Wf_Core.Token('ATTRIBUTE', aname);
2202: Wf_Core.Raise('WFENG_ACTIVITY_ATTR');
2203: when others then
2204: Wf_Core.Context('Wf_Engine', 'GetActivityAttrInfo', itemtype, itemkey,
2205: to_char(actid), aname);
2206: raise;
2207: end GetActivityAttrInfo;
2208:
2476: return(null);
2477:
2478: else
2479:
2480: Wf_Core.Context('Wf_Engine', 'GetActivityAttrText', itemtype, itemkey,
2481: to_char(actid), aname);
2482: Wf_Core.Token('TYPE', itemtype);
2483: Wf_Core.Token('KEY', itemkey);
2484: Wf_Core.Token('ACTIVITY', to_char(actid));
2492: if (curs_activityattr%ISOPEN) then
2493: CLOSE curs_activityattr;
2494: end if;
2495:
2496: Wf_Core.Context('Wf_Engine', 'GetActivityAttrText', itemtype, itemkey,
2497: to_char(actid), aname);
2498: raise;
2499: end GetActivityAttrText;
2500:
2570: return null;
2571:
2572: else
2573:
2574: Wf_Core.Context('Wf_Engine', 'GetActivityAttrNumber', itemtype, itemkey,
2575: to_char(actid), aname);
2576: Wf_Core.Token('TYPE', itemtype);
2577: Wf_Core.Token('KEY', itemkey);
2578: Wf_Core.Token('ACTIVITY', to_char(actid));
2586: if (curs_activityattr%ISOPEN) then
2587: CLOSE curs_activityattr;
2588: end if;
2589:
2590: Wf_Core.Context('Wf_Engine', 'GetActivityAttrNumber', itemtype, itemkey,
2591: to_char(actid), aname);
2592: raise;
2593: end GetActivityAttrNumber;
2594:
2663: return(null);
2664:
2665: else
2666:
2667: Wf_Core.Context('Wf_Engine', 'GetActivityAttrDate', itemtype, itemkey,
2668: to_char(actid), aname);
2669: Wf_Core.Token('TYPE', itemtype);
2670: Wf_Core.Token('KEY', itemkey);
2671: Wf_Core.Token('ACTIVITY', to_char(actid));
2679: if (curs_activityattr%ISOPEN) then
2680: CLOSE curs_activityattr;
2681: end if;
2682:
2683: Wf_Core.Context('Wf_Engine', 'GetActivityAttrDate', itemtype, itemkey,
2684: to_char(actid), aname);
2685: raise;
2686: end GetActivityAttrDate;
2687:
2760: -- Parse out document subtypes
2761: null;
2762: else
2763: -- All others just use text value
2764: value := WF_Engine.GetActivityAttrText(itemtype, itemkey, actid, aname);
2765: end if;
2766:
2767: -- Write value to fake clob and return
2768: dbms_lob.write(tempclob, lengthb(value), 1, value);
2774: if (curs_activityattr%ISOPEN) then
2775: CLOSE curs_activityattr;
2776: end if;
2777:
2778: Wf_Core.Context('Wf_Engine', 'GetActivityAttrClob', itemtype,
2779: itemkey, to_char(actid), aname);
2780: raise;
2781: end GetActivityAttrClob;
2782:
2842: if (curs_activityattr%ISOPEN) then
2843: CLOSE curs_activityattr;
2844: end if;
2845:
2846: Wf_Core.Context('Wf_Engine', 'GetActivityAttrEvent', itemtype, itemkey,
2847: to_char(actid), name);
2848: Wf_Core.Token('TYPE', itemtype);
2849: Wf_Core.Token('KEY', itemkey);
2850: Wf_Core.Token('ACTIVITY', to_char(actid));
2856: if (curs_activityattr%ISOPEN) then
2857: CLOSE curs_activityattr;
2858: end if;
2859:
2860: Wf_Core.Context('Wf_Engine', 'GetActivityAttrEvent', itemtype,
2861: itemkey, to_char(actid), name);
2862: raise;
2863: end GetActivityAttrEvent;
2864:
2873: parent_context in varchar2)
2874: is
2875: begin
2876: -- Not allowed in synch mode
2877: if (itemkey = wf_engine.eng_synch) then
2878: wf_core.token('OPERATION', 'Wf_Engine.Set_Item_Parent');
2879: wf_core.raise('WFENG_SYNCH_DISABLED');
2880: end if;
2881:
2874: is
2875: begin
2876: -- Not allowed in synch mode
2877: if (itemkey = wf_engine.eng_synch) then
2878: wf_core.token('OPERATION', 'Wf_Engine.Set_Item_Parent');
2879: wf_core.raise('WFENG_SYNCH_DISABLED');
2880: end if;
2881:
2882: Wf_Item.Set_Item_Parent(itemtype, itemkey, parent_itemtype, parent_itemkey,
2882: Wf_Item.Set_Item_Parent(itemtype, itemkey, parent_itemtype, parent_itemkey,
2883: parent_context);
2884: exception
2885: when others then
2886: Wf_Core.Context('Wf_Engine', 'Set_Item_Parent', itemtype, itemkey,
2887: parent_itemtype, parent_itemkey, parent_context);
2888: raise;
2889: end Set_Item_Parent;
2890:
2920:
2921: end if;
2922:
2923: -- Not allowed in synch mode
2924: if (itemkey = wf_engine.eng_synch) then
2925: wf_core.token('OPERATION', 'Wf_Engine.SetItemParent');
2926: wf_core.raise('WFENG_SYNCH_DISABLED');
2927: end if;
2928:
2921: end if;
2922:
2923: -- Not allowed in synch mode
2924: if (itemkey = wf_engine.eng_synch) then
2925: wf_core.token('OPERATION', 'Wf_Engine.SetItemParent');
2926: wf_core.raise('WFENG_SYNCH_DISABLED');
2927: end if;
2928:
2929: Wf_Item.Set_Item_Parent(itemtype, itemkey, parent_itemtype,
2929: Wf_Item.Set_Item_Parent(itemtype, itemkey, parent_itemtype,
2930: parent_itemkey, parent_context, masterdetail);
2931: exception
2932: when others then
2933: Wf_Core.Context('Wf_Engine', 'SetItemParent', itemtype, itemkey,
2934: parent_itemtype, parent_itemkey, parent_context);
2935: raise;
2936: end SetItemParent;
2937:
2958:
2959: end if;
2960:
2961: -- Not allowed in synch mode
2962: if (itemkey = wf_engine.eng_synch) then
2963: wf_core.token('OPERATION', 'Wf_Engine.SetItemOwner');
2964: wf_core.raise('WFENG_SYNCH_DISABLED');
2965: end if;
2966:
2959: end if;
2960:
2961: -- Not allowed in synch mode
2962: if (itemkey = wf_engine.eng_synch) then
2963: wf_core.token('OPERATION', 'Wf_Engine.SetItemOwner');
2964: wf_core.raise('WFENG_SYNCH_DISABLED');
2965: end if;
2966:
2967: Wf_Item.SetItemOwner(itemtype, itemkey, owner);
2966:
2967: Wf_Item.SetItemOwner(itemtype, itemkey, owner);
2968: exception
2969: when others then
2970: Wf_Core.Context('Wf_Engine', 'SetItemOwner', itemtype, itemkey,
2971: owner);
2972: raise;
2973: end SetItemOwner;
2974:
2997:
2998: return(Wf_Item.GetItemUserKey(itemtype, itemkey));
2999: exception
3000: when others then
3001: Wf_Core.Context('Wf_Engine', 'GetItemUserKey', itemtype, itemkey);
3002: raise;
3003: end GetItemUserKey;
3004:
3005: --
3025:
3026: end if;
3027:
3028: -- Not allowed in synch mode
3029: if (itemkey = wf_engine.eng_synch) then
3030: wf_core.token('OPERATION', 'Wf_Engine.SetItemUserKey');
3031: wf_core.raise('WFENG_SYNCH_DISABLED');
3032: end if;
3033:
3026: end if;
3027:
3028: -- Not allowed in synch mode
3029: if (itemkey = wf_engine.eng_synch) then
3030: wf_core.token('OPERATION', 'Wf_Engine.SetItemUserKey');
3031: wf_core.raise('WFENG_SYNCH_DISABLED');
3032: end if;
3033:
3034: Wf_Item.SetItemUserKey(itemtype, itemkey, userkey);
3033:
3034: Wf_Item.SetItemUserKey(itemtype, itemkey, userkey);
3035: exception
3036: when others then
3037: Wf_Core.Context('Wf_Engine', 'SetItemUserKey', itemtype, itemkey,
3038: userkey);
3039: raise;
3040: end SetItemUserKey;
3041:
3041:
3042: --
3043: -- GetActivityLabel (PUBLIC)
3044: -- Get activity instance label given id, in a format
3045: -- suitable for passing to other wf_engine apis.
3046: -- IN
3047: -- actid - activity instance id
3048: -- RETURNS
3049: --
3080: WF_CACHE.ProcessActivities(actid).INSTANCE_LABEL);
3081:
3082: exception
3083: when no_data_found then
3084: Wf_Core.Context('Wf_Engine', 'GetActivityLabel', to_char(actid));
3085: Wf_Core.Token('ACTID', to_char(actid));
3086: Wf_Core.Raise('WFENG_ACTID');
3087: when others then
3088: Wf_Core.Context('Wf_Engine', 'GetActivityLabel', to_char(actid));
3084: Wf_Core.Context('Wf_Engine', 'GetActivityLabel', to_char(actid));
3085: Wf_Core.Token('ACTID', to_char(actid));
3086: Wf_Core.Raise('WFENG_ACTID');
3087: when others then
3088: Wf_Core.Context('Wf_Engine', 'GetActivityLabel', to_char(actid));
3089: raise;
3090: end GetActivityLabel;
3091:
3092: -- Bug 2376033
3188: actid := to_number(substr(context, secondcolon+1,
3189: length(context) - secondcolon));
3190:
3191: -- Not allowed in synch mode
3192: if (itemkey = wf_engine.eng_synch) then
3193: wf_core.token('OPERATION', 'Wf_Engine.CB');
3194: wf_core.raise('WFENG_SYNCH_DISABLED');
3195: end if;
3196:
3189: length(context) - secondcolon));
3190:
3191: -- Not allowed in synch mode
3192: if (itemkey = wf_engine.eng_synch) then
3193: wf_core.token('OPERATION', 'Wf_Engine.CB');
3194: wf_core.raise('WFENG_SYNCH_DISABLED');
3195: end if;
3196:
3197: --
3248: else
3249: raise;
3250: end if;
3251: end;
3252: elsif (upper(command) = wf_engine.eng_completed) then
3253: -- CB is signalling that a notification has completed.
3254: -- If the activity originating this notification still has ACTIVE
3255: -- status, then a routing rule (or some other kind of automatic
3256: -- processing) has completed the notification before the activity
3259: -- execute_activity() pick up the execution when the activity
3260: -- owning this notification is actually completed.
3261: Wf_Item_Activity_Status.Status(itemtype, itemkey,
3262: actid, status);
3263: if (status = wf_engine.eng_active) then
3264: -- Do nothing!!!
3265: return;
3266: end if;
3267:
3279: NULL;
3280:
3281: end if;
3282:
3283: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result);
3284: exception
3285: when trig_savepoint or dist_savepoint then
3286: -- Savepoint violation.
3287: -- Try without fancy error processing.
3284: exception
3285: when trig_savepoint or dist_savepoint then
3286: -- Savepoint violation.
3287: -- Try without fancy error processing.
3288: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result);
3289: when others then
3290: -- If anything in this process raises an exception:
3291: -- 1. rollback any work in this process thread
3292: -- 2. set this activity to error status
3293: -- 3. execute the error process (if any)
3294: -- 4. clear the error to continue with next activity
3295: rollback to wf_savepoint;
3296: --The rollback will be done in the when others block
3297: Wf_Core.Context('Wf_Engine', 'CB', command, context, attr_name,
3298: attr_type, ':'||text_value||':'||to_char(number_value)||':'||
3299: to_char(date_value)||':');
3300: Wf_Item_Activity_Status.Set_Error(itemtype,
3301: itemkey, actid, wf_engine.eng_exception, FALSE);
3297: Wf_Core.Context('Wf_Engine', 'CB', command, context, attr_name,
3298: attr_type, ':'||text_value||':'||to_char(number_value)||':'||
3299: to_char(date_value)||':');
3300: Wf_Item_Activity_Status.Set_Error(itemtype,
3301: itemkey, actid, wf_engine.eng_exception, FALSE);
3302: Wf_Engine_Util.Execute_Error_Process(itemtype,
3303: itemkey, actid, wf_engine.eng_exception);
3304: Wf_Core.Clear;
3305: end;
3298: attr_type, ':'||text_value||':'||to_char(number_value)||':'||
3299: to_char(date_value)||':');
3300: Wf_Item_Activity_Status.Set_Error(itemtype,
3301: itemkey, actid, wf_engine.eng_exception, FALSE);
3302: Wf_Engine_Util.Execute_Error_Process(itemtype,
3303: itemkey, actid, wf_engine.eng_exception);
3304: Wf_Core.Clear;
3305: end;
3306: elsif (upper(command) = wf_engine.eng_error) then
3299: to_char(date_value)||':');
3300: Wf_Item_Activity_Status.Set_Error(itemtype,
3301: itemkey, actid, wf_engine.eng_exception, FALSE);
3302: Wf_Engine_Util.Execute_Error_Process(itemtype,
3303: itemkey, actid, wf_engine.eng_exception);
3304: Wf_Core.Clear;
3305: end;
3306: elsif (upper(command) = wf_engine.eng_error) then
3307:
3302: Wf_Engine_Util.Execute_Error_Process(itemtype,
3303: itemkey, actid, wf_engine.eng_exception);
3304: Wf_Core.Clear;
3305: end;
3306: elsif (upper(command) = wf_engine.eng_error) then
3307:
3308: -- Set the error status
3309: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
3310: wf_engine.eng_mail, FALSE);
3306: elsif (upper(command) = wf_engine.eng_error) then
3307:
3308: -- Set the error status
3309: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
3310: wf_engine.eng_mail, FALSE);
3311: -- Run any error process for the activity
3312: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
3313: wf_engine.eng_mail);
3314: elsif (upper(command) = 'TESTCTX') then
3308: -- Set the error status
3309: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
3310: wf_engine.eng_mail, FALSE);
3311: -- Run any error process for the activity
3312: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
3313: wf_engine.eng_mail);
3314: elsif (upper(command) = 'TESTCTX') then
3315: -- Call selector function in test mode
3316: -- Return true if result is either true or null (means context
3309: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
3310: wf_engine.eng_mail, FALSE);
3311: -- Run any error process for the activity
3312: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
3313: wf_engine.eng_mail);
3314: elsif (upper(command) = 'TESTCTX') then
3315: -- Call selector function in test mode
3316: -- Return true if result is either true or null (means context
3317: -- test not implemented)
3314: elsif (upper(command) = 'TESTCTX') then
3315: -- Call selector function in test mode
3316: -- Return true if result is either true or null (means context
3317: -- test not implemented)
3318: result := Wf_Engine_Util.Execute_Selector_Function(itemtype,
3319: itemkey, wf_engine.eng_testctx);
3320: text_value := nvl(result, 'TRUE');
3321: elsif (upper(command) = 'SETCTX') then
3322: -- Call selector function in set mode
3315: -- Call selector function in test mode
3316: -- Return true if result is either true or null (means context
3317: -- test not implemented)
3318: result := Wf_Engine_Util.Execute_Selector_Function(itemtype,
3319: itemkey, wf_engine.eng_testctx);
3320: text_value := nvl(result, 'TRUE');
3321: elsif (upper(command) = 'SETCTX') then
3322: -- Call selector function in set mode
3323: result := Wf_Engine_Util.Execute_Selector_Function(itemtype,
3319: itemkey, wf_engine.eng_testctx);
3320: text_value := nvl(result, 'TRUE');
3321: elsif (upper(command) = 'SETCTX') then
3322: -- Call selector function in set mode
3323: result := Wf_Engine_Util.Execute_Selector_Function(itemtype,
3324: itemkey, wf_engine.eng_setctx);
3325: elsif (upper(command) in ('FORWARD', 'TRANSFER', 'RESPOND',
3326: 'ANSWER', 'QUESTION', 'VALIDATE')) then
3327: -- FORWARD/TRANSFER/RESPOND/ANSWER/QUESTION/VALIDATE
3320: text_value := nvl(result, 'TRUE');
3321: elsif (upper(command) = 'SETCTX') then
3322: -- Call selector function in set mode
3323: result := Wf_Engine_Util.Execute_Selector_Function(itemtype,
3324: itemkey, wf_engine.eng_setctx);
3325: elsif (upper(command) in ('FORWARD', 'TRANSFER', 'RESPOND',
3326: 'ANSWER', 'QUESTION', 'VALIDATE')) then
3327: -- FORWARD/TRANSFER/RESPOND/ANSWER/QUESTION/VALIDATE
3328: -- Look for a notification callback function to execute.
3334: -- 2. The callback function will raise an exception if the
3335: -- operation isn't allowed. If so, allow the exception to raise
3336: -- up to the calling function.
3337:
3338: Wf_Engine_Util.Execute_Notification_Callback(command, itemtype,
3339: itemkey, actid, number_value, text_value);
3340:
3341: -- For TRANSFER mode only, reset the assigned user, but only
3342: -- if not a voting activity
3353: end if;
3354:
3355: exception
3356: when wf_invalid_command then
3357: Wf_Core.Context('Wf_Engine', 'CB', command, context, attr_name, attr_type,
3358: ':'||text_value||':'||to_char(number_value)||':'||
3359: to_char(date_value)||':');
3360: Wf_Core.Token('COMMAND', command);
3361: Wf_Core.Raise('WFSQL_COMMAND');
3360: Wf_Core.Token('COMMAND', command);
3361: Wf_Core.Raise('WFSQL_COMMAND');
3362:
3363: when wf_invalid_argument then
3364: Wf_Core.Context('Wf_Engine', 'CB', command, context, attr_name, attr_type,
3365: ':'||text_value||':'||to_char(number_value)||':'||
3366: to_char(date_value)||':');
3367: Wf_Core.Token('CONTEXT', context);
3368: Wf_Core.Raise('WFSQL_ARGS');
3367: Wf_Core.Token('CONTEXT', context);
3368: Wf_Core.Raise('WFSQL_ARGS');
3369:
3370: when OTHERS then
3371: Wf_Core.Context('Wf_Engine', 'CB', command, context, attr_name, attr_type,
3372: ':'||text_value||':'||to_char(number_value)||':'||
3373: to_char(date_value)||':');
3374: raise;
3375: end CB;
3421: is
3422: event_value wf_event_t;
3423: begin
3424:
3425: Wf_Engine.CB(command, context, attr_name, attr_type, text_value, number_value, date_value, event_value);
3426:
3427: exception
3428: when OTHERS then
3429: Wf_Core.Context('Wf_Engine', 'oldCB', command, context, attr_name, attr_type,
3425: Wf_Engine.CB(command, context, attr_name, attr_type, text_value, number_value, date_value, event_value);
3426:
3427: exception
3428: when OTHERS then
3429: Wf_Core.Context('Wf_Engine', 'oldCB', command, context, attr_name, attr_type,
3430: ':'||text_value||':'||to_char(number_value)||':'||
3431: to_char(date_value)||':');
3432: raise;
3433:
3449: begin
3450: wf_queue.ProcessDeferredQueue(itemtype, minthreshold, maxthreshold);
3451: exception
3452: when others then
3453: Wf_Core.Context('Wf_Engine', 'ProcessDeferred',itemtype,
3454: to_char(minthreshold), to_char(maxthreshold));
3455: raise;
3456: end ProcessDeferred;
3457:
3539: and WI.item_key = S.ITEM_KEY
3540: for update of S.ACTIVITY_STATUS, WI.item_type , wi.item_key NOWAIT;
3541:
3542: -- check if schema matched
3543: schema := Wf_Engine.GetItemAttrText(l_itemtype,l_itemkey,
3544: wf_engine.eng_schema, ignore_notfound=>TRUE);
3545:
3546: if (schema is null or
3547: schema = Wf_Engine.Current_Schema) then
3540: for update of S.ACTIVITY_STATUS, WI.item_type , wi.item_key NOWAIT;
3541:
3542: -- check if schema matched
3543: schema := Wf_Engine.GetItemAttrText(l_itemtype,l_itemkey,
3544: wf_engine.eng_schema, ignore_notfound=>TRUE);
3545:
3546: if (schema is null or
3547: schema = Wf_Engine.Current_Schema) then
3548: eligible := TRUE;
3543: schema := Wf_Engine.GetItemAttrText(l_itemtype,l_itemkey,
3544: wf_engine.eng_schema, ignore_notfound=>TRUE);
3545:
3546: if (schema is null or
3547: schema = Wf_Engine.Current_Schema) then
3548: eligible := TRUE;
3549: else
3550: eligible := FALSE;
3551: end if;
3558:
3559: if (eligible) then
3560: -- Set the status to COMPLETE:#TIMEOUT.
3561: Wf_Item_Activity_Status.Create_Status(l_itemtype, l_itemkey, l_actid,
3562: wf_engine.eng_completed, wf_engine.eng_timedout);
3563:
3564: begin
3565: begin
3566: begin
3567: savepoint wf_savepoint;
3568: -- If there is a function attached, call it in timeout mode to
3569: -- give the function one last chance to complete and override
3570: -- the timeout.
3571: Wf_Engine_Util.Execute_Post_NTF_Function(l_itemtype, l_itemkey,
3572: l_actid, wf_engine.eng_timeout, pntfstatus, pntfresult);
3573: if (pntfstatus = wf_engine.eng_completed) then
3574: -- Post-notification function found and returned a completed
3575: -- status.
3568: -- If there is a function attached, call it in timeout mode to
3569: -- give the function one last chance to complete and override
3570: -- the timeout.
3571: Wf_Engine_Util.Execute_Post_NTF_Function(l_itemtype, l_itemkey,
3572: l_actid, wf_engine.eng_timeout, pntfstatus, pntfresult);
3573: if (pntfstatus = wf_engine.eng_completed) then
3574: -- Post-notification function found and returned a completed
3575: -- status.
3576: -- Complete activity with result of post-notification function.
3569: -- give the function one last chance to complete and override
3570: -- the timeout.
3571: Wf_Engine_Util.Execute_Post_NTF_Function(l_itemtype, l_itemkey,
3572: l_actid, wf_engine.eng_timeout, pntfstatus, pntfresult);
3573: if (pntfstatus = wf_engine.eng_completed) then
3574: -- Post-notification function found and returned a completed
3575: -- status.
3576: -- Complete activity with result of post-notification function.
3577: Wf_Engine_Util.Complete_Activity(l_itemtype, l_itemkey, l_actid,
3573: if (pntfstatus = wf_engine.eng_completed) then
3574: -- Post-notification function found and returned a completed
3575: -- status.
3576: -- Complete activity with result of post-notification function.
3577: Wf_Engine_Util.Complete_Activity(l_itemtype, l_itemkey, l_actid,
3578: pntfresult, FALSE);
3579: else
3580: -- Either had no post-notification function, or result was still
3581: -- not complete.
3579: else
3580: -- Either had no post-notification function, or result was still
3581: -- not complete.
3582: -- In either case, complete activity with #TIMEOUT.
3583: Wf_Engine_Util.Complete_Activity(l_itemtype, l_itemkey, l_actid,
3584: wf_engine.eng_timedout);
3585: end if;
3586: exception
3587: when others then
3580: -- Either had no post-notification function, or result was still
3581: -- not complete.
3582: -- In either case, complete activity with #TIMEOUT.
3583: Wf_Engine_Util.Complete_Activity(l_itemtype, l_itemkey, l_actid,
3584: wf_engine.eng_timedout);
3585: end if;
3586: exception
3587: when others then
3588: -- If anything in this process raises an exception:
3594: end;
3595: exception
3596: when NO_SAVEPOINT then
3597: -- Catch any savepoint error in case of a commit happened.
3598: Wf_Core.Token('ACTIVITY', Wf_Engine.GetActivityLabel(l_actid));
3599: Wf_Core.Raise('WFENG_COMMIT_IN_COMPLETE');
3600: end;
3601: exception
3602: when OTHERS then
3603: -- Remaining steps for completing activity raises an exception:
3604: -- 2. set this activity to error status
3605: -- 3. execute the error process (if any)
3606: -- 4. clear the error to continue with next activity
3607: Wf_Core.Context('Wf_Engine', 'ProcessTimeout', l_itemkey, l_itemtype,
3608: to_char(l_actid));
3609: Wf_Item_Activity_Status.Set_Error(l_itemtype, l_itemkey, l_actid,
3610: wf_engine.eng_exception, FALSE);
3611: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey,
3606: -- 4. clear the error to continue with next activity
3607: Wf_Core.Context('Wf_Engine', 'ProcessTimeout', l_itemkey, l_itemtype,
3608: to_char(l_actid));
3609: Wf_Item_Activity_Status.Set_Error(l_itemtype, l_itemkey, l_actid,
3610: wf_engine.eng_exception, FALSE);
3611: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey,
3612: l_actid, wf_engine.eng_exception);
3613: Wf_Core.Clear;
3614: end;
3607: Wf_Core.Context('Wf_Engine', 'ProcessTimeout', l_itemkey, l_itemtype,
3608: to_char(l_actid));
3609: Wf_Item_Activity_Status.Set_Error(l_itemtype, l_itemkey, l_actid,
3610: wf_engine.eng_exception, FALSE);
3611: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey,
3612: l_actid, wf_engine.eng_exception);
3613: Wf_Core.Clear;
3614: end;
3615: end if;
3608: to_char(l_actid));
3609: Wf_Item_Activity_Status.Set_Error(l_itemtype, l_itemkey, l_actid,
3610: wf_engine.eng_exception, FALSE);
3611: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey,
3612: l_actid, wf_engine.eng_exception);
3613: Wf_Core.Clear;
3614: end;
3615: end if;
3616:
3626: end loop;
3627:
3628: exception
3629: when others then
3630: Wf_Core.Context('Wf_Engine', 'ProcessTimeout', l_itemkey, l_itemtype,
3631: to_char(l_actid));
3632: raise;
3633: end ProcessTimeOut;
3634:
3671: and WIASP.ITEM_TYPE = WI.ITEM_TYPE
3672: and WIASP.ITEM_KEY = WI.ITEM_KEY
3673: and WI.BEGIN_DATE >= WAP.BEGIN_DATE
3674: and WI.BEGIN_DATE < nvl(WAP.END_DATE, WI.BEGIN_DATE+1)
3675: and WAP.TYPE = wf_engine.eng_process
3676: and WIASP.ACTIVITY_STATUS = 'ACTIVE' --use literal to force index
3677: and not exists
3678: (select null
3679: from WF_ITEM_ACTIVITY_STATUSES WIASC,
3765: and WIASP.ITEM_TYPE = WI.ITEM_TYPE
3766: and WIASP.ITEM_KEY = WI.ITEM_KEY
3767: and WI.BEGIN_DATE >= WAP.BEGIN_DATE
3768: and WI.BEGIN_DATE < nvl(WAP.END_DATE, WI.BEGIN_DATE+1)
3769: and WAP.TYPE = wf_engine.eng_process
3770: and WIASP.ACTIVITY_STATUS = 'ACTIVE' --use literal to force index
3771: and not exists
3772: (select null
3773: from WF_ITEM_ACTIVITY_STATUSES WIASC,
3793:
3794: if (eligible) then
3795: -- Set the status to ERROR:#STUCK
3796: Wf_Item_Activity_Status.Create_Status(l_itemtype, l_itemkey, l_actid,
3797: wf_engine.eng_error, wf_engine.eng_stuck);
3798:
3799: -- Execute the error process for stuck process
3800: begin
3801: begin
3800: begin
3801: begin
3802: begin
3803: savepoint wf_savepoint;
3804: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey, l_actid,
3805: wf_engine.eng_stuck);
3806: exception
3807: when others then
3808: -- If anything in this process raises an exception:
3801: begin
3802: begin
3803: savepoint wf_savepoint;
3804: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey, l_actid,
3805: wf_engine.eng_stuck);
3806: exception
3807: when others then
3808: -- If anything in this process raises an exception:
3809: -- 1. rollback any work in this process thread
3814: end;
3815: exception
3816: when NO_SAVEPOINT then
3817: -- Catch any savepoint error in case of a commit happened.
3818: Wf_Core.Token('ACTIVITY', Wf_Engine.GetActivityLabel(l_actid));
3819: Wf_Core.Raise('WFENG_COMMIT_IN_ERRPROC');
3820: end;
3821: exception
3822: when OTHERS then
3823: -- Remaining steps for completing activity raises an exception:
3824: -- 2. set this activity to error status
3825: -- 3. execute the error process (if any)
3826: -- 4. clear the error to continue with next activity
3827: Wf_Core.Context('Wf_Engine', 'ProcessStuckProcess', l_itemkey,
3828: l_itemtype, to_char(l_actid));
3829: Wf_Item_Activity_Status.Set_Error(l_itemtype, l_itemkey, l_actid,
3830: wf_engine.eng_exception, FALSE);
3831: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey,
3826: -- 4. clear the error to continue with next activity
3827: Wf_Core.Context('Wf_Engine', 'ProcessStuckProcess', l_itemkey,
3828: l_itemtype, to_char(l_actid));
3829: Wf_Item_Activity_Status.Set_Error(l_itemtype, l_itemkey, l_actid,
3830: wf_engine.eng_exception, FALSE);
3831: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey,
3832: l_actid, wf_engine.eng_exception);
3833: Wf_Core.Clear;
3834: end;
3827: Wf_Core.Context('Wf_Engine', 'ProcessStuckProcess', l_itemkey,
3828: l_itemtype, to_char(l_actid));
3829: Wf_Item_Activity_Status.Set_Error(l_itemtype, l_itemkey, l_actid,
3830: wf_engine.eng_exception, FALSE);
3831: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey,
3832: l_actid, wf_engine.eng_exception);
3833: Wf_Core.Clear;
3834: end;
3835:
3828: l_itemtype, to_char(l_actid));
3829: Wf_Item_Activity_Status.Set_Error(l_itemtype, l_itemkey, l_actid,
3830: wf_engine.eng_exception, FALSE);
3831: Wf_Engine_Util.Execute_Error_Process(l_itemtype, l_itemkey,
3832: l_actid, wf_engine.eng_exception);
3833: Wf_Core.Clear;
3834: end;
3835:
3836: -- Commit work to insure this activity thread doesn't interfere
3843: end loop;
3844:
3845: exception
3846: when others then
3847: Wf_Core.Context('Wf_Engine', 'ProcessStuckProcess', l_itemkey, l_itemtype,
3848: to_char(l_actid));
3849: raise;
3850: end ProcessStuckProcess;
3851:
3893: --Enable the deferred and inbound queues.
3894: wf_queue.Enablebackgroundqueues;
3895:
3896: -- Do not need to preserve context
3897: wf_engine.preserved_context := FALSE;
3898:
3899: -- bug 7828862 Cache Apps context before starting to process any type
3900: wfa_sec.Cache_Ctx();
3901:
3902: -- Process deferred activities
3903: if (process_deferred) then
3904: -- process the inbound queue first - it may place events on the deferred Q
3905: wf_queue.ProcessInboundQueue(itemtype);
3906: wf_engine.ProcessDeferred(itemtype, minthreshold, maxthreshold);
3907: end if;
3908:
3909: -- Process timeout activities
3910: if (process_timeout) then
3907: end if;
3908:
3909: -- Process timeout activities
3910: if (process_timeout) then
3911: wf_engine.ProcessTimeout(itemtype);
3912: end if;
3913:
3914: -- Process stuck activities
3915: if (process_stuck) then
3912: end if;
3913:
3914: -- Process stuck activities
3915: if (process_stuck) then
3916: wf_engine.ProcessStuckProcess(itemtype);
3917: end if;
3918:
3919: exception
3920: when others then
3917: end if;
3918:
3919: exception
3920: when others then
3921: Wf_Core.Context('Wf_Engine', 'Background', itemtype,
3922: to_char(minthreshold), to_char(maxthreshold));
3923: -- Restore Apps Context
3924: wfa_sec.Restore_Ctx();
3925: raise;
3985: end if;
3986:
3987: --Bug 9527839. RAC enabled workflows
3988: if instance_number > 0 then
3989: WF_ENGINE_RAC.Set_Context('INST_ID', instance_number);
3990: end if;
3991:
3992: -- Call background engine with new args
3993: Wf_Engine.Background(
3989: WF_ENGINE_RAC.Set_Context('INST_ID', instance_number);
3990: end if;
3991:
3992: -- Call background engine with new args
3993: Wf_Engine.Background(
3994: itemtype,
3995: minthreshold_num,
3996: maxthreshold_num,
3997: process_deferred_bool,
4037: typ varchar2(8);
4038: rootid pls_integer;
4039: status varchar2(8);
4040: l_event wf_event_t; -- Buffer for initing event itemattrs
4041: l_pkg_name varchar2(20) := 'WF_ENGINE';
4042: l_prc_name varchar2(20) := '.CreateProcess';
4043:
4044: -- All event item attrs to be initialized
4045: -- Initialization is now deferred until GetItemAttrEvent
4063: null;
4064: end if;
4065:
4066: --Bug 9527839. RAC enabled workflows
4067: if WF_ENGINE_RAC.Process_Is_RAC_Enabled(itemtype, process) then
4068: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
4069: wf_log_pkg.string(wf_log_pkg.level_statement, l_pkg_name||l_prc_name,
4070: itemtype||' is RAC enabled');
4071: end if;
4075: wf_log_pkg.string(wf_log_pkg.level_statement, l_pkg_name||l_prc_name,
4076: 'switching type from '||nvl(setctx_itemtype,'null')||
4077: ' to '||nvl(itemtype, 'null'));
4078: end if;
4079: WF_ENGINE_RAC.Set_Context('INST_ID',nvl(sys_context('WF_RAC_CTX','INST_ID'),
4080: sys_context('userenv', 'instance')));
4081: end if;
4082: else --If not RAC-enabled we'll make sure the context is reset if previously set.
4083: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
4088: if (wf_log_pkg.level_statement >= fnd_log.g_current_runtime_level) then
4089: wf_log_pkg.string(wf_log_pkg.level_statement, l_pkg_name||l_prc_name,
4090: 'resetting WF_RAC_CTX.INST_ID to null');
4091: end if;
4092: WF_ENGINE_RAC.Set_Context('INST_ID', null);
4093: end if;
4094: end if;
4095:
4096: -- Check for duplicate item
4093: end if;
4094: end if;
4095:
4096: -- Check for duplicate item
4097: if (itemkey = wf_engine.eng_synch) then
4098: if (Wf_Item.Item_Exist(itemtype, itemkey)) then
4099: -- SYNCHMODE: If duplicate is a synch process, check the status
4100: -- of the root process of the existing item.
4101: -- If the cached item is already complete, then it is ok to
4108: exception
4109: when others then
4110: status := 'x'; -- Treat errors like incomplete process
4111: end;
4112: if (nvl(status, 'x') <> wf_engine.eng_completed) then
4113: Wf_Core.Token('ITEMTYPE', itemtype);
4114: Wf_Core.Token('ITEMKEY', itemkey);
4115: Wf_Core.Raise('WFENG_SYNCH_ITEM');
4116: end if;
4127: end if;
4128:
4129: if (process is null) then
4130: -- Call the selector function to get the process
4131: root := Wf_Engine_Util.Get_Root_Process(itemtype, itemkey);
4132: if (root is null) then
4133: Wf_Core.Token('TYPE', itemtype);
4134: Wf_Core.Token('KEY', itemkey);
4135: Wf_Core.Raise('WFENG_ITEM_ROOT_SELECTOR');
4144: -- The check that the process is runnable can't be done until AFTER
4145: -- create_item so the date has been established.
4146: actdate := sysdate;
4147: typ := Wf_Activity.Type(itemtype, root, actdate);
4148: if ((typ is null) or (typ <> wf_engine.eng_process)) then
4149: Wf_Core.Token('TYPE', itemtype);
4150: Wf_Core.Token('NAME', root);
4151: Wf_Core.Raise('WFENG_PROCESS_NAME');
4152: end if;
4163: Wf_Core.Token('NAME', root);
4164: Wf_Core.Raise('WFENG_PROCESS_RUNNABLE');
4165: end if;
4166:
4167: if (itemkey <> WF_ENGINE.eng_synch) then
4168: -- Create monitor access key attributes
4169: Wf_Engine.AddItemAttr(itemtype, itemkey, wf_engine.wfmon_mon_key,
4170: Wf_Core.Random);
4171: Wf_Engine.AddItemAttr(itemtype, itemkey, wf_engine.wfmon_acc_key,
4165: end if;
4166:
4167: if (itemkey <> WF_ENGINE.eng_synch) then
4168: -- Create monitor access key attributes
4169: Wf_Engine.AddItemAttr(itemtype, itemkey, wf_engine.wfmon_mon_key,
4170: Wf_Core.Random);
4171: Wf_Engine.AddItemAttr(itemtype, itemkey, wf_engine.wfmon_acc_key,
4172: Wf_Core.Random);
4173: end if;
4167: if (itemkey <> WF_ENGINE.eng_synch) then
4168: -- Create monitor access key attributes
4169: Wf_Engine.AddItemAttr(itemtype, itemkey, wf_engine.wfmon_mon_key,
4170: Wf_Core.Random);
4171: Wf_Engine.AddItemAttr(itemtype, itemkey, wf_engine.wfmon_acc_key,
4172: Wf_Core.Random);
4173: end if;
4174:
4175: -- Create a schema attribute
4172: Wf_Core.Random);
4173: end if;
4174:
4175: -- Create a schema attribute
4176: Wf_Engine.AddItemAttr(itemtype, itemkey, wf_engine.eng_schema,
4177: Wf_Engine.Current_Schema);
4178:
4179: -- Initialize all EVENT-type item attributes
4180: -- Not done here, it is deferred until GetItemAttrEvent
4173: end if;
4174:
4175: -- Create a schema attribute
4176: Wf_Engine.AddItemAttr(itemtype, itemkey, wf_engine.eng_schema,
4177: Wf_Engine.Current_Schema);
4178:
4179: -- Initialize all EVENT-type item attributes
4180: -- Not done here, it is deferred until GetItemAttrEvent
4181: /* for evtattr in evtcurs loop
4179: -- Initialize all EVENT-type item attributes
4180: -- Not done here, it is deferred until GetItemAttrEvent
4181: /* for evtattr in evtcurs loop
4182: Wf_Event_T.Initialize(l_event);
4183: Wf_Engine.SetItemAttrEvent(
4184: itemtype => itemtype,
4185: itemkey => itemkey,
4186: name => evtattr.name,
4187: event => l_event);
4190: exception
4191: when others then
4192: -- Bug 4117740
4193: -- Call clearcache() when #SYNCH flow is in error
4194: if ((itemkey = WF_ENGINE.eng_synch) and
4195: (wf_core.error_name is null or wf_core.error_name <> 'WFENG_SYNCH_ITEM') and
4196: (not WF_ENGINE.debug)) then
4197: Wf_Item.ClearCache;
4198: end if;
4192: -- Bug 4117740
4193: -- Call clearcache() when #SYNCH flow is in error
4194: if ((itemkey = WF_ENGINE.eng_synch) and
4195: (wf_core.error_name is null or wf_core.error_name <> 'WFENG_SYNCH_ITEM') and
4196: (not WF_ENGINE.debug)) then
4197: Wf_Item.ClearCache;
4198: end if;
4199:
4200: Wf_Core.Context('Wf_Engine', 'CreateProcess', itemtype, itemkey, process);
4196: (not WF_ENGINE.debug)) then
4197: Wf_Item.ClearCache;
4198: end if;
4199:
4200: Wf_Core.Context('Wf_Engine', 'CreateProcess', itemtype, itemkey, process);
4201: raise;
4202: end CreateProcess;
4203:
4204: --
4219: if (WF_CACHE.MetaRefreshed) then
4220: null;
4221: end if;
4222: --Bug 2259039
4223: Wf_Engine_Util.Start_Process_Internal(
4224: itemtype=> itemtype,
4225: itemkey => itemkey,
4226: runmode => 'START');
4227: exception
4225: itemkey => itemkey,
4226: runmode => 'START');
4227: exception
4228: when others then
4229: Wf_Core.Context('Wf_Engine', 'StartProcess', itemtype, itemkey);
4230: raise;
4231: end StartProcess;
4232:
4233: --
4257: Wf_Core.Raise('WFSQL_ARGS');
4258:
4259: end if;
4260:
4261: wf_engine.CreateProcess (itemtype,itemkey,process);
4262:
4263: if userkey is not null then
4264: wf_engine.SetItemUserKey(itemtype,itemkey,userkey);
4265: end if;
4260:
4261: wf_engine.CreateProcess (itemtype,itemkey,process);
4262:
4263: if userkey is not null then
4264: wf_engine.SetItemUserKey(itemtype,itemkey,userkey);
4265: end if;
4266:
4267: if owner is not null then
4268: wf_engine.SetItemOwner(itemtype,itemkey,owner);
4264: wf_engine.SetItemUserKey(itemtype,itemkey,userkey);
4265: end if;
4266:
4267: if owner is not null then
4268: wf_engine.SetItemOwner(itemtype,itemkey,owner);
4269: end if;
4270:
4271: wf_engine.StartProcess (itemtype,itemkey);
4272: exception
4267: if owner is not null then
4268: wf_engine.SetItemOwner(itemtype,itemkey,owner);
4269: end if;
4270:
4271: wf_engine.StartProcess (itemtype,itemkey);
4272: exception
4273: when others then
4274: Wf_Core.Context('Wf_Engine', 'LaunchProcess', itemtype, itemkey,
4275: process, userkey, owner);
4270:
4271: wf_engine.StartProcess (itemtype,itemkey);
4272: exception
4273: when others then
4274: Wf_Core.Context('Wf_Engine', 'LaunchProcess', itemtype, itemkey,
4275: process, userkey, owner);
4276: raise;
4277: end LaunchProcess;
4278:
4307: select PROCESS_ACTIVITY, BEGIN_DATE
4308: from WF_ITEM_ACTIVITY_STATUSES
4309: where ITEM_TYPE = itemtype
4310: and ITEM_KEY = itemkey
4311: and ACTIVITY_STATUS = wf_engine.eng_deferred;
4312:
4313: begin
4314: -- Check Arguments
4315: if (itemtype is null) then
4316: Wf_Core.Token('ITEMTYPE', nvl(itemtype, 'NULL'));
4317: Wf_Core.Raise('WFSQL_ARGS');
4318:
4319: -- Not allowed in synch mode
4320: elsif (itemkey = wf_engine.eng_synch) then
4321: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
4322: wf_core.raise('WFENG_SYNCH_DISABLED');
4323:
4324: elsif (itemkey is null) then
4317: Wf_Core.Raise('WFSQL_ARGS');
4318:
4319: -- Not allowed in synch mode
4320: elsif (itemkey = wf_engine.eng_synch) then
4321: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
4322: wf_core.raise('WFENG_SYNCH_DISABLED');
4323:
4324: elsif (itemkey is null) then
4325: WF_ENGINE.SuspendAll(itemtype, process); --
4321: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
4322: wf_core.raise('WFENG_SYNCH_DISABLED');
4323:
4324: elsif (itemkey is null) then
4325: WF_ENGINE.SuspendAll(itemtype, process); --
4326: return;
4327:
4328: end if;
4329:
4365:
4366: -- Check that activity is a PROCESS-type.
4367: -- Only PROCESS activities may be suspended.
4368: if (Wf_Activity.Instance_Type(procid, actdate) <>
4369: wf_engine.eng_process) then
4370: Wf_Core.Token('NAME', proc);
4371: Wf_Core.Token('TYPE', itemtype);
4372: Wf_Core.Raise('WFENG_PROCESS_NAME');
4373: end if;
4385: if (status is null) then
4386: -- This process has not been run yet. Create a pre-suspended
4387: -- status row so engine does not run process later
4388: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4389: wf_engine.eng_suspended, wf_engine.eng_null, null, null,
4390: newStatus=>TRUE);
4391: elsif (status = wf_engine.eng_deferred) then
4392: -- Change status from 'deferred' to 'suspended'
4393: -- Doing this prevents the background processor from picking it up.
4387: -- status row so engine does not run process later
4388: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4389: wf_engine.eng_suspended, wf_engine.eng_null, null, null,
4390: newStatus=>TRUE);
4391: elsif (status = wf_engine.eng_deferred) then
4392: -- Change status from 'deferred' to 'suspended'
4393: -- Doing this prevents the background processor from picking it up.
4394: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4395: wf_engine.eng_suspended, null,
4391: elsif (status = wf_engine.eng_deferred) then
4392: -- Change status from 'deferred' to 'suspended'
4393: -- Doing this prevents the background processor from picking it up.
4394: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4395: wf_engine.eng_suspended, null,
4396: null, null);
4397: elsif (status = wf_engine.eng_active) then
4398: -- Mark process as 'suspended', 'null' in WIAS table
4399: -- Doing this stops the engine from going through the rest of the flow
4393: -- Doing this prevents the background processor from picking it up.
4394: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4395: wf_engine.eng_suspended, null,
4396: null, null);
4397: elsif (status = wf_engine.eng_active) then
4398: -- Mark process as 'suspended', 'null' in WIAS table
4399: -- Doing this stops the engine from going through the rest of the flow
4400: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4401: wf_engine.eng_suspended, null,
4397: elsif (status = wf_engine.eng_active) then
4398: -- Mark process as 'suspended', 'null' in WIAS table
4399: -- Doing this stops the engine from going through the rest of the flow
4400: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4401: wf_engine.eng_suspended, null,
4402: null, null);
4403:
4404: -- Suspend all the children processes
4405: Wf_Engine_Util.Suspend_Child_Processes(itemtype, itemkey, procid);
4401: wf_engine.eng_suspended, null,
4402: null, null);
4403:
4404: -- Suspend all the children processes
4405: Wf_Engine_Util.Suspend_Child_Processes(itemtype, itemkey, procid);
4406: else
4407: Wf_Core.Token('TYPE', itemtype);
4408: Wf_Core.Token('KEY', itemkey);
4409: Wf_Core.Token('NAME', proc);
4411: end if;
4412:
4413: exception
4414: when others then
4415: Wf_Core.Context('Wf_Engine', 'SuspendProcess', itemtype, itemkey, process);
4416: raise;
4417: end SuspendProcess;
4418:
4419: --
4478: Wf_Core.Token('ITEMTYPE', nvl(itemtype, 'NULL'));
4479: Wf_Core.Token('ITEMKEY', nvl(itemkey, 'NULL'));
4480: Wf_Core.Raise('WFSQL_ARGS');
4481:
4482: elsif (itemkey = wf_engine.eng_synch) then -- Not allowed in synch mode
4483: wf_core.token('OPERATION', 'Wf_Engine.AbortProcess');
4484: wf_core.raise('WFENG_SYNCH_DISABLED');
4485: end if;
4486:
4479: Wf_Core.Token('ITEMKEY', nvl(itemkey, 'NULL'));
4480: Wf_Core.Raise('WFSQL_ARGS');
4481:
4482: elsif (itemkey = wf_engine.eng_synch) then -- Not allowed in synch mode
4483: wf_core.token('OPERATION', 'Wf_Engine.AbortProcess');
4484: wf_core.raise('WFENG_SYNCH_DISABLED');
4485: end if;
4486:
4487: --Do the check for lock ONLY if there is an explicit
4494:
4495: -- Get the root process for this key and also validate the item
4496: Wf_Item.Root_Process(itemtype, itemkey, root, version);
4497: if (root is null) then
4498: Wf_Core.Context('Wf_Engine', 'AbortProcess', itemtype, itemkey, process);
4499: Wf_Core.Token('TYPE', itemtype);
4500: Wf_Core.Token('KEY', itemkey);
4501: Wf_Core.Raise('WFENG_ITEM');
4502: end if;
4531:
4532: -- Check that activity is a PROCESS-type.
4533: -- Only PROCESS activities may be aborted.
4534: if (Wf_Activity.Instance_Type(procid, actdate) <>
4535: wf_engine.eng_process) then
4536: Wf_Core.Token('NAME', proc);
4537: Wf_Core.Token('TYPE', itemtype);
4538: Wf_Core.Raise('WFENG_PROCESS_NAME');
4539: end if;
4552: Wf_core.Token('NAME', proc);
4553: Wf_Core.Raise('WFENG_ITEM_PROCESS_RUNNING');
4554: end if;
4555:
4556: elsif (status = wf_engine.eng_completed) then
4557: Wf_Core.Token('TYPE', itemtype);
4558: Wf_Core.Token('KEY', itemkey);
4559: Wf_Core.Token('NAME', proc);
4560: Wf_Core.Raise('WFENG_ITEM_PROCESS_ACTIVE');
4561: else
4562: -- Mark process as 'COMPLETE', 'result' in WIAS table
4563: -- Doing this stops the engine from going through the rest of the flow
4564: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4565: wf_engine.eng_completed, result,
4566: null, SYSDATE);
4567:
4568: -- Kill child activities recursively
4569: Wf_Engine_Util.Process_Kill_Children(itemtype, itemkey, procid);
4565: wf_engine.eng_completed, result,
4566: null, SYSDATE);
4567:
4568: -- Kill child activities recursively
4569: Wf_Engine_Util.Process_Kill_Children(itemtype, itemkey, procid);
4570: --If cascade option is set to true abort all child
4571: --processes aswell
4572: if cascade then
4573: Wf_Engine_Util.Process_Kill_ChildProcess(itemtype, itemkey);
4569: Wf_Engine_Util.Process_Kill_Children(itemtype, itemkey, procid);
4570: --If cascade option is set to true abort all child
4571: --processes aswell
4572: if cascade then
4573: Wf_Engine_Util.Process_Kill_ChildProcess(itemtype, itemkey);
4574: end if;
4575: end if;
4576:
4577: --Cancel any OPEN FYI notifications
4587: wf_event.AddParameterToList('PROCESS', process, l_parameterlist);
4588: wf_event.AddParameterToList('RESULT', result, l_parameterlist);
4589:
4590: -- Raise the event
4591: wf_event.Raise(p_event_name => 'oracle.apps.wf.engine.abort',
4592: p_event_key => itemkey,
4593: p_parameters => l_parameterlist);
4594:
4595: exception
4598: wf_core.token('KEY',itemkey);
4599: wf_core.raise('WFENG_RESOURCE_BUSY');
4600:
4601: when others then
4602: Wf_Core.Context('Wf_Engine', 'AbortProcess', itemtype, itemkey,
4603: process, result);
4604: raise;
4605: end AbortProcess;
4606:
4633: PROCESS_ACTIVITY, BEGIN_DATE
4634: from WF_ITEM_ACTIVITY_STATUSES
4635: where ITEM_TYPE = itemtype
4636: and ITEM_KEY = itemkey
4637: and ACTIVITY_STATUS = wf_engine.eng_deferred;
4638:
4639: actidarr InstanceArrayTyp; -- Deferred activities array
4640: i pls_integer := 0; -- Counter for the for loop
4641:
4654: if (itemtype is null) then
4655: Wf_Core.Token('ITEMTYPE', nvl(itemtype, 'NULL'));
4656: Wf_Core.Raise('WFSQL_ARGS');
4657:
4658: elsif (itemkey = wf_engine.eng_synch) then -- Not allowed in synch mode
4659: wf_core.token('OPERATION', 'Wf_Engine.ResumeProcess');
4660: wf_core.raise('WFENG_SYNCH_DISABLED');
4661:
4662: elsif (itemkey is NULL) then
4655: Wf_Core.Token('ITEMTYPE', nvl(itemtype, 'NULL'));
4656: Wf_Core.Raise('WFSQL_ARGS');
4657:
4658: elsif (itemkey = wf_engine.eng_synch) then -- Not allowed in synch mode
4659: wf_core.token('OPERATION', 'Wf_Engine.ResumeProcess');
4660: wf_core.raise('WFENG_SYNCH_DISABLED');
4661:
4662: elsif (itemkey is NULL) then
4663: WF_ENGINE.ResumeAll(itemtype, process); --
4659: wf_core.token('OPERATION', 'Wf_Engine.ResumeProcess');
4660: wf_core.raise('WFENG_SYNCH_DISABLED');
4661:
4662: elsif (itemkey is NULL) then
4663: WF_ENGINE.ResumeAll(itemtype, process); --
4664: return;
4665:
4666: end if;
4667:
4703:
4704: -- Check that activity is a PROCESS-type.
4705: -- Only PROCESS activities may be resumed.
4706: if (Wf_Activity.Instance_Type(procid, actdate) <>
4707: wf_engine.eng_process) then
4708: Wf_Core.Token('NAME', proc);
4709: Wf_Core.Token('TYPE', itemtype);
4710: Wf_Core.Raise('WFENG_PROCESS_NAME');
4711: end if;
4720: Wf_Core.Token('TYPE', itemtype);
4721: Wf_Core.Token('KEY', itemkey);
4722: Wf_Core.Token('NAME', proc);
4723: Wf_Core.Raise('WFENG_ITEM_PROCESS_RUNNING');
4724: elsif (status <> wf_engine.eng_suspended) then
4725: Wf_Core.Token('TYPE', itemtype);
4726: Wf_Core.Token('KEY', itemkey);
4727: Wf_Core.Token('NAME', proc);
4728: Wf_Core.Raise('WFENG_ITEM_PROCESS_SUSPENDED');
4729: else
4730: -- If we came here, that means the process is currently suspended.
4731: -- Mark process as eng_active 'active', 'null' in WIAS table
4732: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4733: wf_engine.eng_active, null, null, null);
4734:
4735: -- Mark any sub-processes as active again
4736: Wf_Engine_Util.Resume_Child_Processes(itemtype, itemkey, procid);
4737:
4732: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, procid,
4733: wf_engine.eng_active, null, null, null);
4734:
4735: -- Mark any sub-processes as active again
4736: Wf_Engine_Util.Resume_Child_Processes(itemtype, itemkey, procid);
4737:
4738: -- Restart any activities that were deferred because completion
4739: -- came in while process was suspended.
4740: --
4763: --Also set the status to active only if begin_date <= sysdate
4764:
4765: if (nvl(act_begin_date(i),sysdate) <= sysdate) then
4766: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, actidarr(i),
4767: wf_engine.eng_active, null, sysdate, null);
4768: begin
4769: savepoint wf_savepoint;
4770: Wf_Engine_Util.Process_Activity(itemtype, itemkey, actidarr(i),
4771: Wf_Engine.Threshold, TRUE);
4766: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, actidarr(i),
4767: wf_engine.eng_active, null, sysdate, null);
4768: begin
4769: savepoint wf_savepoint;
4770: Wf_Engine_Util.Process_Activity(itemtype, itemkey, actidarr(i),
4771: Wf_Engine.Threshold, TRUE);
4772: exception
4773: when trig_savepoint or dist_savepoint then
4774: -- Can't restart process here, re-defer for the
4767: wf_engine.eng_active, null, sysdate, null);
4768: begin
4769: savepoint wf_savepoint;
4770: Wf_Engine_Util.Process_Activity(itemtype, itemkey, actidarr(i),
4771: Wf_Engine.Threshold, TRUE);
4772: exception
4773: when trig_savepoint or dist_savepoint then
4774: -- Can't restart process here, re-defer for the
4775: -- background process to pick up.
4773: when trig_savepoint or dist_savepoint then
4774: -- Can't restart process here, re-defer for the
4775: -- background process to pick up.
4776: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey,
4777: actidarr(i),wf_engine.eng_deferred, null, sysdate, null);
4778: when others then
4779: -- If anything in this process raises an exception:
4780: -- 1. rollback any work in this process thread
4781: -- 2. set this activity to error status
4781: -- 2. set this activity to error status
4782: -- 3. execute the error process (if any)
4783: -- 4. clear the error to continue with next activity
4784: rollback to wf_savepoint;
4785: Wf_Core.Context('Wf_Engine', 'ResumeProcess', itemtype, itemkey,
4786: process);
4787: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actidarr(i),
4788: wf_engine.eng_exception, FALSE);
4789: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actidarr(i),
4784: rollback to wf_savepoint;
4785: Wf_Core.Context('Wf_Engine', 'ResumeProcess', itemtype, itemkey,
4786: process);
4787: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actidarr(i),
4788: wf_engine.eng_exception, FALSE);
4789: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actidarr(i),
4790: wf_engine.eng_exception);
4791:
4792: Wf_Core.Clear;
4785: Wf_Core.Context('Wf_Engine', 'ResumeProcess', itemtype, itemkey,
4786: process);
4787: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actidarr(i),
4788: wf_engine.eng_exception, FALSE);
4789: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actidarr(i),
4790: wf_engine.eng_exception);
4791:
4792: Wf_Core.Clear;
4793: end;
4786: process);
4787: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actidarr(i),
4788: wf_engine.eng_exception, FALSE);
4789: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actidarr(i),
4790: wf_engine.eng_exception);
4791:
4792: Wf_Core.Clear;
4793: end;
4794: --else case status is same as right now that is deferred.
4799: end if;
4800:
4801: exception
4802: when others then
4803: Wf_Core.Context('Wf_Engine', 'ResumeProcess', itemtype, itemkey, process);
4804: raise;
4805: end ResumeProcess;
4806:
4807:
4830:
4831: if (p_itemType is NULL) then
4832: for c in All_Open_items loop
4833: begin
4834: WF_ENGINE.SuspendProcess(c.item_type, c.item_key, p_process);
4835:
4836: exception
4837: when others then
4838: if ( wf_core.error_name = 'WFENG_ITEM_PROCESS_ACTIVE' ) then
4849:
4850: else
4851: for c in Open_Items(p_itemType) loop
4852: begin
4853: WF_ENGINE.SuspendProcess(p_itemType, c.item_key, p_process);
4854:
4855: exception
4856: when others then
4857: if ( wf_core.error_name = 'WFENG_ITEM_PROCESS_ACTIVE' ) then
4868: end if;
4869:
4870: exception
4871: when others then
4872: Wf_Core.Context('Wf_Engine', 'SuspendAll', p_itemType, p_process);
4873: raise;
4874:
4875: end SuspendAll;
4876:
4886: cursor suspended_items(p_itemType in varchar2) is
4887: SELECT distinct wias.item_key
4888: FROM wf_item_activity_statuses wias
4889: WHERE wias.item_type = p_itemType
4890: AND wias.activity_status = wf_engine.eng_suspended;
4891:
4892: cursor all_suspended_items is
4893: SELECT distinct wias.item_type, wias.item_key
4894: FROM wf_item_activity_statuses wias
4891:
4892: cursor all_suspended_items is
4893: SELECT distinct wias.item_type, wias.item_key
4894: FROM wf_item_activity_statuses wias
4895: WHERE wias.activity_status = wf_engine.eng_suspended;
4896:
4897: begin
4898:
4899: if (p_itemType is NULL) then
4898:
4899: if (p_itemType is NULL) then
4900: for c in all_suspended_items loop
4901: begin
4902: WF_ENGINE.ResumeProcess(c.item_type, c.item_key, p_process);
4903:
4904: exception
4905: when others then
4906: null;
4911:
4912: else
4913: for c in suspended_items(p_itemType) loop
4914: begin
4915: WF_ENGINE.ResumeProcess(p_itemType, c.item_key, p_process);
4916:
4917: exception
4918: when others then
4919: null;
4962: Wf_Core.Raise('WFSQL_ARGS');
4963: end if;
4964:
4965: -- Not allowed in synch mode
4966: if (new_itemkey = wf_engine.eng_synch)
4967: or (copy_itemkey = wf_engine.eng_synch) then
4968: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
4969: wf_core.raise('WFENG_SYNCH_DISABLED');
4970: end if;
4963: end if;
4964:
4965: -- Not allowed in synch mode
4966: if (new_itemkey = wf_engine.eng_synch)
4967: or (copy_itemkey = wf_engine.eng_synch) then
4968: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
4969: wf_core.raise('WFENG_SYNCH_DISABLED');
4970: end if;
4971:
4964:
4965: -- Not allowed in synch mode
4966: if (new_itemkey = wf_engine.eng_synch)
4967: or (copy_itemkey = wf_engine.eng_synch) then
4968: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
4969: wf_core.raise('WFENG_SYNCH_DISABLED');
4970: end if;
4971:
4972: -- Check status
4969: wf_core.raise('WFENG_SYNCH_DISABLED');
4970: end if;
4971:
4972: -- Check status
4973: Wf_engine.ItemStatus(copy_itemtype, copy_itemkey, status, result);
4974: if (status = wf_engine.eng_error) then
4975: Wf_Core.Raise('WFENG_NOFORK_ONERROR');
4976: end if;
4977:
4970: end if;
4971:
4972: -- Check status
4973: Wf_engine.ItemStatus(copy_itemtype, copy_itemkey, status, result);
4974: if (status = wf_engine.eng_error) then
4975: Wf_Core.Raise('WFENG_NOFORK_ONERROR');
4976: end if;
4977:
4978: -- Check for duplicate item
5014: itemkey => copy_itemkey,
5015: wflow => root_process,
5016: version =>root_process_version);
5017:
5018: wf_engine.CreateProcess(copy_itemtype,new_itemkey,root_process);
5019:
5020: --delete any defaulted attributes because we will copy the existing ones.
5021: delete from wf_item_attribute_values
5022: where item_type = copy_itemtype
5051: and name not like '#CNT_');
5052:
5053:
5054: -- reset the access_keys to make them unique
5055: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5056: wf_engine.wfmon_mon_key, Wf_Core.Random);
5057: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5058: wf_engine.wfmon_acc_key, Wf_Core.Random);
5059:
5052:
5053:
5054: -- reset the access_keys to make them unique
5055: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5056: wf_engine.wfmon_mon_key, Wf_Core.Random);
5057: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5058: wf_engine.wfmon_acc_key, Wf_Core.Random);
5059:
5060:
5053:
5054: -- reset the access_keys to make them unique
5055: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5056: wf_engine.wfmon_mon_key, Wf_Core.Random);
5057: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5058: wf_engine.wfmon_acc_key, Wf_Core.Random);
5059:
5060:
5061: -- reset the schema, just in case, if the #SCHEMA attribute does not exist
5054: -- reset the access_keys to make them unique
5055: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5056: wf_engine.wfmon_mon_key, Wf_Core.Random);
5057: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5058: wf_engine.wfmon_acc_key, Wf_Core.Random);
5059:
5060:
5061: -- reset the schema, just in case, if the #SCHEMA attribute does not exist
5062: -- it will be added. The CreateProcess api now adds the #SCHEMA.
5059:
5060:
5061: -- reset the schema, just in case, if the #SCHEMA attribute does not exist
5062: -- it will be added. The CreateProcess api now adds the #SCHEMA.
5063: -- Only items created before WF_ENGINE was upgraded will encounter the
5064: -- exception to be handled, so this is for backward compatibility.
5065:
5066: begin
5067: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5063: -- Only items created before WF_ENGINE was upgraded will encounter the
5064: -- exception to be handled, so this is for backward compatibility.
5065:
5066: begin
5067: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5068: wf_engine.eng_schema, Wf_Engine.Current_Schema);
5069:
5070: exception
5071: when others then
5064: -- exception to be handled, so this is for backward compatibility.
5065:
5066: begin
5067: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5068: wf_engine.eng_schema, Wf_Engine.Current_Schema);
5069:
5070: exception
5071: when others then
5072: if (wf_core.error_name = 'WFENG_ITEM_ATTR') then
5070: exception
5071: when others then
5072: if (wf_core.error_name = 'WFENG_ITEM_ATTR') then
5073: wf_core.clear;
5074: WF_ENGINE.AddItemAttr(copy_itemtype, new_itemkey,
5075: wf_engine.eng_schema,
5076: Wf_Engine.Current_Schema);
5077:
5078: else
5071: when others then
5072: if (wf_core.error_name = 'WFENG_ITEM_ATTR') then
5073: wf_core.clear;
5074: WF_ENGINE.AddItemAttr(copy_itemtype, new_itemkey,
5075: wf_engine.eng_schema,
5076: Wf_Engine.Current_Schema);
5077:
5078: else
5079:
5072: if (wf_core.error_name = 'WFENG_ITEM_ATTR') then
5073: wf_core.clear;
5074: WF_ENGINE.AddItemAttr(copy_itemtype, new_itemkey,
5075: wf_engine.eng_schema,
5076: Wf_Engine.Current_Schema);
5077:
5078: else
5079:
5080: raise;
5084: end;
5085:
5086: -- Finally set an itemkey to record what this originated from
5087: begin
5088: Wf_Engine.AddItemAttr(copy_itemtype, new_itemkey, '#FORKED_FROM',
5089: copy_itemkey);
5090: exception
5091: when others then
5092: --
5093: -- If item attribute already exists then ignore the error
5094: --
5095: if ( wf_core.error_name = 'WFENG_ITEM_ATTR_UNIQUE' ) then
5096: wf_core.clear;
5097: Wf_Engine.SetItemAttrText(copy_itemtype, new_itemkey,
5098: '#FORKED_FROM', copy_itemkey);
5099: else
5100: raise;
5101: end if;
5104: if (masterdetail) then
5105: --The caller has signaled that this is a master/detail process
5106: --We first will attempt to zero out any #WAITFORDETAIL attribute that may be
5107: --on this forked process (it is a master itself).
5108: dummyNum := WF_ENGINE.AddToItemAttrNumber(copy_itemType, new_itemKey,
5109: '#WAITFORDETAIL',
5110: to_number(NULL));
5111:
5112: if ((l_parent_itemType is NOT null) and (l_parent_itemKey is NOT null)) then
5111:
5112: if ((l_parent_itemType is NOT null) and (l_parent_itemKey is NOT null)) then
5113: --There is a parent item to this forked item, so we will validate and
5114: --increment the parent's #WAITFORDETAIL counter.
5115: if (WF_ENGINE.AddToItemAttrNumber(l_parent_itemType, l_parent_itemKey,
5116: '#WAITFORDETAIL', 1) is NOT null) then
5117: --The parent has a #WAITFORDETAIL, so we can proceed on to check for
5118: --parent context.
5119: if (l_parent_context is NOT null) then
5120: --There is a parent context, so we will add the #LBL_ attribute to
5121: --the child flow, and will increment the corresponding #CNT_ attribute
5122: --in the parent flow.
5123: begin
5124: WF_ENGINE.AddItemAttr(itemtype=>copy_itemType, itemkey=>new_itemkey,
5125: aname=>'#LBL_'||l_parent_context,
5126: text_value=>l_parent_context);
5127:
5128: --Since there was a parent context in the forked_from flow, we know
5126: text_value=>l_parent_context);
5127:
5128: --Since there was a parent context in the forked_from flow, we know
5129: --The parent has a counter for this label, so we can just increment.
5130: dummyNum := WF_ENGINE.AddToItemAttrNumber(l_parent_itemType,
5131: l_parent_itemKey,
5132: '#CNT_'||l_parent_context,
5133: 1);
5134: exception
5132: '#CNT_'||l_parent_context,
5133: 1);
5134: exception
5135: when ValTooLarge OR ValTooLargeNew then
5136: Wf_Core.Context('WF_ENGINE', 'CreateForkProcess', copy_itemtype,
5137: copy_itemkey, new_itemkey, l_parent_itemtype,
5138: l_parent_itemkey, l_parent_context, 'TRUE');
5139: WF_CORE.Token('LABEL', l_parent_context);
5140: WF_CORE.Token('LENGTH', 30);
5154: end if; --There is a parent item to this forked process.
5155: end if; --The caller signalled that this is a master/detail process.
5156: exception
5157: when others then
5158: Wf_Core.Context('Wf_Engine', 'CreateForkProcess');
5159: raise;
5160: end CreateForkProcess;
5161:
5162:
5246:
5247: -- get the forked_from attribute: if it doesnt exist then this cannot be
5248: -- a forked item
5249: begin
5250: copy_itemkey := Wf_Engine.GetItemAttrText(itemtype, itemkey,'#FORKED_FROM');
5251: exception when others then
5252: Wf_Core.Raise('WF_NOFORK');
5253: end;
5254:
5253: end;
5254:
5255:
5256: -- Not allowed in synch mode
5257: if (itemkey = wf_engine.eng_synch)
5258: or (copy_itemkey = wf_engine.eng_synch) then
5259: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
5260: wf_core.raise('WFENG_SYNCH_DISABLED');
5261: end if;
5254:
5255:
5256: -- Not allowed in synch mode
5257: if (itemkey = wf_engine.eng_synch)
5258: or (copy_itemkey = wf_engine.eng_synch) then
5259: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
5260: wf_core.raise('WFENG_SYNCH_DISABLED');
5261: end if;
5262:
5255:
5256: -- Not allowed in synch mode
5257: if (itemkey = wf_engine.eng_synch)
5258: or (copy_itemkey = wf_engine.eng_synch) then
5259: wf_core.token('OPERATION', 'Wf_Engine.SuspendProcess');
5260: wf_core.raise('WFENG_SYNCH_DISABLED');
5261: end if;
5262:
5263:
5305: if copy_root_process <> new_root_process
5306: or copy_process_version <> new_process_version
5307: or copy_active_date <> new_active_date then
5308: begin
5309: wf_engine.startprocess(itemtype,itemkey);
5310: exception when others then
5311: Wf_Core.raise('WF_CANNOT_FORK');
5312: end;
5313: return;
5322:
5323: if act.notification_id is not null then
5324:
5325: --if complete then copy else ignore (we re-execute later)
5326: if act.activity_status = wf_engine.eng_completed then
5327: wf_engine_util.notification_copy (act.notification_id,
5328: act.item_key, itemkey, nid);
5329: end if;
5330:
5323: if act.notification_id is not null then
5324:
5325: --if complete then copy else ignore (we re-execute later)
5326: if act.activity_status = wf_engine.eng_completed then
5327: wf_engine_util.notification_copy (act.notification_id,
5328: act.item_key, itemkey, nid);
5329: end if;
5330:
5331: elsif act.activity_status = wf_engine.eng_deferred then
5327: wf_engine_util.notification_copy (act.notification_id,
5328: act.item_key, itemkey, nid);
5329: end if;
5330:
5331: elsif act.activity_status = wf_engine.eng_deferred then
5332:
5333: --process defered activity
5334: act_fname:= Wf_Activity.activity_function
5335: (act.item_type,act.item_key,act.process_activity);
5407: for hist in all_activities_hist loop
5408:
5409: nid := null;
5410: if hist.notification_id is not null then
5411: wf_engine_util.notification_copy (hist.notification_id,
5412: hist.item_key, itemkey, nid);
5413: end if;
5414:
5415: -- now insert the status
5431:
5432: -- update any active functions to notified state
5433: begin
5434: update wf_item_activity_statuses ias
5435: set activity_status = wf_engine.eng_notified
5436: where item_type = itemtype
5437: and item_key = itemkey
5438: and activity_status = 'ACTIVE'
5439: and activity_status = wf_engine.eng_active
5435: set activity_status = wf_engine.eng_notified
5436: where item_type = itemtype
5437: and item_key = itemkey
5438: and activity_status = 'ACTIVE'
5439: and activity_status = wf_engine.eng_active
5440: and exists (select 'its a function, not subprocess'
5441: from wf_process_activities pa,
5442: wf_activities ac
5443: where pa.activity_name = ac.name
5448: end;
5449:
5450:
5451: -- update item attributes on all copied notifications
5452: wf_engine_util.notification_refresh(itemtype,itemkey);
5453:
5454:
5455: -- as last step, launch all notifications still open
5456: -- keep this as last step because routing rules may allow
5456: -- keep this as last step because routing rules may allow
5457: -- continuation of thread.
5458:
5459: for ntf in ntf_open loop
5460: Wf_Engine_Util.Process_Activity(itemtype, itemkey,
5461: ntf.process_activity,wf_engine.threshold);
5462: end loop;
5463:
5464:
5457: -- continuation of thread.
5458:
5459: for ntf in ntf_open loop
5460: Wf_Engine_Util.Process_Activity(itemtype, itemkey,
5461: ntf.process_activity,wf_engine.threshold);
5462: end loop;
5463:
5464:
5465: exception
5463:
5464:
5465: exception
5466: when others then
5467: Wf_Core.Context('Wf_Engine', 'StartForkProcess');
5468: raise;
5469: end StartForkProcess;
5470:
5471:
5490: actdate date; -- Active date of item
5491: actid pls_integer; -- activity instance id
5492: begin
5493: -- Not allowed in synch mode
5494: if (itemkey = wf_engine.eng_synch) then
5495: wf_core.token('OPERATION', 'Wf_Engine.BeginActivity');
5496: wf_core.raise('WFENG_SYNCH_DISABLED');
5497: end if;
5498:
5491: actid pls_integer; -- activity instance id
5492: begin
5493: -- Not allowed in synch mode
5494: if (itemkey = wf_engine.eng_synch) then
5495: wf_core.token('OPERATION', 'Wf_Engine.BeginActivity');
5496: wf_core.raise('WFENG_SYNCH_DISABLED');
5497: end if;
5498:
5499: -- Argument validation
5521: -- Note must do this here, instead of relying on CreateProcess
5522: -- to call the selector, because CreateProcess can't take the
5523: -- start activity as an argument to implicitly choose a root
5524: -- process when no selector function is defined.
5525: root := Wf_Engine_Util.Get_Root_Process(itemtype, itemkey, activity);
5526: if (root is null) then
5527: Wf_Core.Token('TYPE', itemtype);
5528: Wf_Core.Token('KEY', itemkey);
5529: Wf_Core.Raise('WFENG_ITEM_ROOT_SELECTOR');
5532: else
5533: -- Item exists. Must be case (2).
5534: -- Check that the activity is currently notified.
5535: actid := Wf_Process_Activity.ActiveInstanceId(itemtype, itemkey,
5536: activity, wf_engine.eng_notified);
5537:
5538: -- Any other status, or no status at all, is an error.
5539: if (actid is null) then
5540: Wf_Core.Token('TYPE', itemtype);
5545:
5546: end if;
5547: exception
5548: when others then
5549: Wf_Core.Context('Wf_Engine', 'BeginActivity', itemtype, itemkey, activity);
5550: raise;
5551: end BeginActivity;
5552:
5553: --
5620: -- Note must do this here, instead of relying on CreateProcess
5621: -- to call the selector, because CreateProcess can't take the
5622: -- start activity as an argument to implicitly choose a root
5623: -- process when no selector function is defined.
5624: root := Wf_Engine_Util.Get_Root_Process(itemtype, itemkey, activity);
5625: if (root is null) then
5626: Wf_Core.Token('TYPE', itemtype);
5627: Wf_Core.Token('KEY', itemkey);
5628: Wf_Core.Raise('WFENG_ITEM_ROOT_SELECTOR');
5628: Wf_Core.Raise('WFENG_ITEM_ROOT_SELECTOR');
5629: end if;
5630:
5631: -- Create new process
5632: Wf_Engine.CreateProcess(itemtype, itemkey, root);
5633:
5634: --Bug 2259039
5635: -- Start the process for this activity.
5636: -- The activity to be completed will be left in NOTIFIED status
5634: --Bug 2259039
5635: -- Start the process for this activity.
5636: -- The activity to be completed will be left in NOTIFIED status
5637: -- as a side-effect of this call.
5638: Wf_Engine_Util.Start_Process_Internal(
5639: itemtype => itemtype,
5640: itemkey => itemkey,
5641: runmode => 'ACTIVITY');
5642:
5648: activity);
5649:
5650: -- Create a status row for new activity
5651: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, actid,
5652: wf_engine.eng_active, wf_engine.eng_null, sysdate, null, newStatus=>TRUE);
5653: else
5654:
5655: --Bug 2607770
5656: --Its only in the else condition that you need to get
5659:
5660: -- Item exists. Must be case (2).
5661: -- Check that the activity is currently notified.
5662: actid := Wf_Process_Activity.ActiveInstanceId(itemtype, itemkey,
5663: activity, wf_engine.eng_notified);
5664:
5665: -- Any other status, or no status at all, is an error.
5666: if (actid is null) then
5667: Wf_Core.Token('TYPE', itemtype);
5672:
5673: --If acquire lock returns true we will continue
5674: --If it returns false we raise exception to the user
5675: --Any other exception we let the caller decide what to do
5676: if (itemkey <> wf_engine.eng_synch) then
5677: --If its an async process and you cannot acquire a lock
5678: --raise the exception to the user
5679: l_lock := wf_item.acquire_lock(itemtype,itemkey,true);
5680: end if;
5698: end if;
5699: end if;
5700:
5701: -- Finally, complete our lovely new activity.
5702: if (itemkey = wf_engine.eng_synch) then
5703: -- SYNCHMODE: No error trapping in synchmode.
5704: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result);
5705: else
5706: begin
5700:
5701: -- Finally, complete our lovely new activity.
5702: if (itemkey = wf_engine.eng_synch) then
5703: -- SYNCHMODE: No error trapping in synchmode.
5704: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result);
5705: else
5706: begin
5707: savepoint wf_savepoint;
5708: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result);
5704: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result);
5705: else
5706: begin
5707: savepoint wf_savepoint;
5708: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result);
5709: exception
5710: when trig_savepoint or dist_savepoint then
5711: -- You must be in a restricted environment,
5712: -- no fancy error processing for you!
5714: -- deferring directly, because the activity must be marked as
5715: -- complete. Any following activities started by completing
5716: -- this activity will be caught and deferred in another
5717: -- savepoint trap in process_activity.
5718: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result);
5719: when others then
5720: -- If anything in this process raises an exception:
5721: -- 1. rollback any work in this process thread
5722: -- 2. set this activity to error status
5728: -- errors. If FALSE default behavior goes on
5729: if raise_engine_exception then
5730: raise;
5731: else
5732: Wf_Core.Context('Wf_Engine', 'CompleteActivity', itemtype, itemkey,
5733: activity, result);
5734: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
5735: wf_engine.eng_exception, FALSE);
5736: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
5731: else
5732: Wf_Core.Context('Wf_Engine', 'CompleteActivity', itemtype, itemkey,
5733: activity, result);
5734: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
5735: wf_engine.eng_exception, FALSE);
5736: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
5737: wf_engine.eng_exception);
5738: Wf_Core.Clear;
5739: end if;
5732: Wf_Core.Context('Wf_Engine', 'CompleteActivity', itemtype, itemkey,
5733: activity, result);
5734: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
5735: wf_engine.eng_exception, FALSE);
5736: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
5737: wf_engine.eng_exception);
5738: Wf_Core.Clear;
5739: end if;
5740: end;
5733: activity, result);
5734: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
5735: wf_engine.eng_exception, FALSE);
5736: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
5737: wf_engine.eng_exception);
5738: Wf_Core.Clear;
5739: end if;
5740: end;
5741: end if;
5745: wf_core.token('TYPE',itemtype);
5746: wf_core.token('KEY',itemkey);
5747: wf_core.raise('WFENG_RESOURCE_BUSY');
5748: when others then
5749: Wf_Core.Context('Wf_Engine', 'CompleteActivity', itemtype, itemkey,
5750: activity, result);
5751: raise;
5752: end CompleteActivity;
5753:
5783: label varchar2(30);
5784: begin
5785: WF_CORE.TAG_DB_SESSION(WF_CORE.CONN_TAG_WF, CompleteActivityInternalName.itemtype);
5786: -- Not allowed in synch mode
5787: if (itemkey = wf_engine.eng_synch) then
5788: wf_core.token('OPERATION', 'Wf_Engine.CompleteActivityInternalName');
5789: wf_core.raise('WFENG_SYNCH_DISABLED');
5790: end if;
5791:
5784: begin
5785: WF_CORE.TAG_DB_SESSION(WF_CORE.CONN_TAG_WF, CompleteActivityInternalName.itemtype);
5786: -- Not allowed in synch mode
5787: if (itemkey = wf_engine.eng_synch) then
5788: wf_core.token('OPERATION', 'Wf_Engine.CompleteActivityInternalName');
5789: wf_core.raise('WFENG_SYNCH_DISABLED');
5790: end if;
5791:
5792: -- Argument validation
5815: into process, label
5816: from WF_ITEM_ACTIVITY_STATUSES WIAS, WF_PROCESS_ACTIVITIES WPA
5817: where WIAS.ITEM_TYPE = itemtype
5818: and WIAS.ITEM_KEY = itemkey
5819: and WIAS.ACTIVITY_STATUS = wf_engine.eng_notified
5820: and WIAS.PROCESS_ACTIVITY = WPA.INSTANCE_ID
5821: and WPA.ACTIVITY_NAME = actname
5822: and WPA.PROCESS_NAME = nvl(process, WPA.PROCESS_NAME);
5823: exception
5828: Wf_Core.Raise('WFENG_NOT_NOTIFIED');
5829: end;
5830:
5831: -- Complete activity with the correct arguments
5832: Wf_Engine.CompleteActivity(itemtype, itemkey, process||':'||label,
5833: result, CompleteActivityInternalName.raise_engine_exception);
5834:
5835: exception
5836: when others then
5833: result, CompleteActivityInternalName.raise_engine_exception);
5834:
5835: exception
5836: when others then
5837: Wf_Core.Context('Wf_Engine', 'CompleteActivityInternalName',
5838: itemtype, itemkey, activity, result);
5839: raise;
5840: end CompleteActivityInternalName;
5841:
5873: msgtype varchar2(8);
5874: expand_role varchar2(1);
5875: begin
5876: -- Not allowed in synch mode
5877: if (itemkey = wf_engine.eng_synch) then
5878: wf_core.token('OPERATION', 'Wf_Engine.AssignActivity');
5879: wf_core.raise('WFENG_SYNCH_DISABLED');
5880: end if;
5881:
5874: expand_role varchar2(1);
5875: begin
5876: -- Not allowed in synch mode
5877: if (itemkey = wf_engine.eng_synch) then
5878: wf_core.token('OPERATION', 'Wf_Engine.AssignActivity');
5879: wf_core.raise('WFENG_SYNCH_DISABLED');
5880: end if;
5881:
5882: -- Argument validation
5919: end if;
5920:
5921: -- Check if this activity is a notification type of activity
5922: acttype := Wf_Activity.Type(itemtype, activity, actdate);
5923: if (acttype <> wf_engine.eng_notification) then
5924: Wf_Core.Token('NAME', activity);
5925: Wf_Core.Raise('WFENG_NOTIFICATION_NAME');
5926: end if;
5927:
5930:
5931: if (status is null) then
5932: -- Insert one row with the performer
5933: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, actid,
5934: wf_engine.eng_waiting, '', null, null, newStatus=>TRUE);
5935: Wf_Item_Activity_Status.Update_Notification(itemtype, itemkey, actid,
5936: '', performer);
5937: elsif (status = wf_engine.eng_waiting) then
5938: Wf_Item_Activity_Status.Update_Notification(itemtype, itemkey, actid,
5933: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, actid,
5934: wf_engine.eng_waiting, '', null, null, newStatus=>TRUE);
5935: Wf_Item_Activity_Status.Update_Notification(itemtype, itemkey, actid,
5936: '', performer);
5937: elsif (status = wf_engine.eng_waiting) then
5938: Wf_Item_Activity_Status.Update_Notification(itemtype, itemkey, actid,
5939: '', performer);
5940: elsif (status in (wf_engine.eng_notified, wf_engine.eng_error)) then
5941: -- Check this is not a voting activity.
5936: '', performer);
5937: elsif (status = wf_engine.eng_waiting) then
5938: Wf_Item_Activity_Status.Update_Notification(itemtype, itemkey, actid,
5939: '', performer);
5940: elsif (status in (wf_engine.eng_notified, wf_engine.eng_error)) then
5941: -- Check this is not a voting activity.
5942: -- Voting activities cannot be re-assigned.
5943: Wf_Activity.Notification_Info(itemtype, itemkey, actid, msg, msgtype,
5944: expand_role);
5955: notid, performer);
5956:
5957: if (notid is not null) then
5958: -- 16-DEC-03 shanjgik bug fix 2722369 check for reassignType added
5959: if (reassignType = Wf_Engine.eng_delegate) then
5960: -- delegate the notification
5961: Wf_Notification.Forward(notid, performer, ntfComments);
5962: else -- case reassignType is TRANSFER or null
5963: -- Call Wf_Notification.Transfer(notid, performer) to transfer
5975: end if;
5976:
5977: EXCEPTION
5978: when OTHERS then
5979: Wf_Core.Context('Wf_Engine', 'AssignActivity', itemtype, itemkey,
5980: activity, performer);
5981: raise;
5982: end AssignActivity;
5983:
6035: -- This reset behaves similar to loop reset, cancelling activities,
6036: -- moving rows to history, etc. It then resets the activity status
6037: -- to active, AND resets or creates status rows for any parent process
6038: -- to active if necessary.
6039: if (not Wf_Engine_Util.Reset_Tree(itemtype, itemkey, rootid,
6040: actid, actdate)) then
6041: Wf_Core.Token('TYPE', itemtype);
6042: Wf_Core.Token('KEY', itemkey);
6043: Wf_Core.Token('NAME', activity);
6043: Wf_Core.Token('NAME', activity);
6044: Wf_Core.Raise('WFENG_ITEM_ACTIVITY');
6045: end if;
6046:
6047: if (command = wf_engine.eng_skip) then
6048: -- *** SKIP ***
6049: -- Mark activity complete with given result
6050: begin
6051: savepoint wf_savepoint;
6054: funcname := Wf_Activity.Activity_Function(itemtype, itemkey, actid);
6055:
6056: if (funcname is not null) then -- <6636968>
6057:
6058: Wf_Engine_Util.Function_Call(funcname, itemtype, itemkey, actid, wf_engine.eng_skip,
6059: resultout);
6060:
6061: -- Check if skip is allowed on this activity
6062: if (resultout = wf_engine.eng_noskip) then
6058: Wf_Engine_Util.Function_Call(funcname, itemtype, itemkey, actid, wf_engine.eng_skip,
6059: resultout);
6060:
6061: -- Check if skip is allowed on this activity
6062: if (resultout = wf_engine.eng_noskip) then
6063: Wf_Core.Token('LABEL', Wf_Engine.GetActivityLabel(actid));
6064: Wf_Core.Raise('WFENG_NOSKIP');
6065: end if;
6066: end if;-- 6636968>
6059: resultout);
6060:
6061: -- Check if skip is allowed on this activity
6062: if (resultout = wf_engine.eng_noskip) then
6063: Wf_Core.Token('LABEL', Wf_Engine.GetActivityLabel(actid));
6064: Wf_Core.Raise('WFENG_NOSKIP');
6065: end if;
6066: end if;-- 6636968>
6067:
6064: Wf_Core.Raise('WFENG_NOSKIP');
6065: end if;
6066: end if;-- 6636968>
6067:
6068: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid, result, FALSE);
6069:
6070: exception
6071: when trig_savepoint or dist_savepoint then
6072: -- You must be in a restricted environment,
6070: exception
6071: when trig_savepoint or dist_savepoint then
6072: -- You must be in a restricted environment,
6073: -- no fancy error processing for you! Try running directly.
6074: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actid,
6075: result, FALSE);
6076: when others then
6077: if (Wf_Core.Error_Name = 'WFENG_NOSKIP') then
6078: -- No processing. Raise to the caller that the activity cannot be skipped.
6083: -- 2. set this activity to error status
6084: -- 3. execute the error process (if any)
6085: -- 4. clear the error to continue with next activity
6086: rollback to wf_savepoint;
6087: Wf_Core.Context('Wf_Engine', 'HandleErrorInternal', itemtype, itemkey,
6088: activity, command, result);
6089: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
6090: wf_engine.eng_exception, FALSE);
6091: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
6086: rollback to wf_savepoint;
6087: Wf_Core.Context('Wf_Engine', 'HandleErrorInternal', itemtype, itemkey,
6088: activity, command, result);
6089: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
6090: wf_engine.eng_exception, FALSE);
6091: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
6092: wf_engine.eng_exception);
6093: Wf_Core.Clear;
6094: end if;
6087: Wf_Core.Context('Wf_Engine', 'HandleErrorInternal', itemtype, itemkey,
6088: activity, command, result);
6089: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
6090: wf_engine.eng_exception, FALSE);
6091: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
6092: wf_engine.eng_exception);
6093: Wf_Core.Clear;
6094: end if;
6095: end;
6088: activity, command, result);
6089: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
6090: wf_engine.eng_exception, FALSE);
6091: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
6092: wf_engine.eng_exception);
6093: Wf_Core.Clear;
6094: end if;
6095: end;
6096: --We will raise the skip event here .
6093: Wf_Core.Clear;
6094: end if;
6095: end;
6096: --We will raise the skip event here .
6097: event_name := 'oracle.apps.wf.engine.skip';
6098: else
6099: -- *** RETRY ***
6100: if (actid = rootid) then
6101: -- Restart root process from beginnning
6098: else
6099: -- *** RETRY ***
6100: if (actid = rootid) then
6101: -- Restart root process from beginnning
6102: Wf_Engine.StartProcess(itemtype, itemkey);
6103: else
6104: -- Start at given activity
6105: begin
6106: savepoint wf_savepoint;
6103: else
6104: -- Start at given activity
6105: begin
6106: savepoint wf_savepoint;
6107: Wf_Engine_Util.Process_Activity(itemtype, itemkey, actid,
6108: Wf_Engine.Threshold, TRUE);
6109: exception
6110: when trig_savepoint or dist_savepoint then
6111: -- You must be in a restricted environment,
6104: -- Start at given activity
6105: begin
6106: savepoint wf_savepoint;
6107: Wf_Engine_Util.Process_Activity(itemtype, itemkey, actid,
6108: Wf_Engine.Threshold, TRUE);
6109: exception
6110: when trig_savepoint or dist_savepoint then
6111: -- You must be in a restricted environment,
6112: -- no fancy error processing for you!
6111: -- You must be in a restricted environment,
6112: -- no fancy error processing for you!
6113: -- Immediately defer activity to background engine.
6114: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey,
6115: actid, wf_engine.eng_deferred, wf_engine.eng_null,
6116: SYSDATE, null);
6117: when others then
6118: -- If anything in this process raises an exception:
6119: -- 1. rollback any work in this process thread
6120: -- 2. set this activity to error status
6121: -- 3. execute the error process (if any)
6122: -- 4. clear the error to continue with next activity
6123: rollback to wf_savepoint;
6124: Wf_Core.Context('Wf_Engine', 'HandleErrorInternal',itemtype,itemkey,
6125: activity, command, result);
6126: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
6127: wf_engine.eng_exception, FALSE);
6128: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
6123: rollback to wf_savepoint;
6124: Wf_Core.Context('Wf_Engine', 'HandleErrorInternal',itemtype,itemkey,
6125: activity, command, result);
6126: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
6127: wf_engine.eng_exception, FALSE);
6128: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
6129: wf_engine.eng_exception);
6130: Wf_Core.Clear;
6131: end;
6124: Wf_Core.Context('Wf_Engine', 'HandleErrorInternal',itemtype,itemkey,
6125: activity, command, result);
6126: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
6127: wf_engine.eng_exception, FALSE);
6128: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
6129: wf_engine.eng_exception);
6130: Wf_Core.Clear;
6131: end;
6132: end if;
6125: activity, command, result);
6126: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actid,
6127: wf_engine.eng_exception, FALSE);
6128: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actid,
6129: wf_engine.eng_exception);
6130: Wf_Core.Clear;
6131: end;
6132: end if;
6133: event_name := 'oracle.apps.wf.engine.retry';
6129: wf_engine.eng_exception);
6130: Wf_Core.Clear;
6131: end;
6132: end if;
6133: event_name := 'oracle.apps.wf.engine.retry';
6134: end if;
6135:
6136: -- Store the info for Audit (Bug 5903106 - moved from HandleError to here)
6137: Wf_Item_Activity_Status.Audit(itemtype, itemkey, actid, upper(command), null);
6151: p_parameters => l_parameterlist);
6152:
6153: exception
6154: when others then
6155: Wf_Core.Context('Wf_Engine', 'HandleErrorInternal', itemtype, itemkey,
6156: activity, command, result);
6157: raise;
6158: end HandleErrorInternal;
6159:
6189: pragma exception_init(dist_savepoint, -02074);
6190: begin
6191: WF_CORE.TAG_DB_SESSION(WF_CORE.CONN_TAG_WF, HandleError.itemtype);
6192: -- Not allowed in synch mode
6193: if (itemkey = wf_engine.eng_synch) then
6194: wf_core.token('OPERATION', 'Wf_Engine.HandleError');
6195: wf_core.raise('WFENG_SYNCH_DISABLED');
6196: end if;
6197:
6190: begin
6191: WF_CORE.TAG_DB_SESSION(WF_CORE.CONN_TAG_WF, HandleError.itemtype);
6192: -- Not allowed in synch mode
6193: if (itemkey = wf_engine.eng_synch) then
6194: wf_core.token('OPERATION', 'Wf_Engine.HandleError');
6195: wf_core.raise('WFENG_SYNCH_DISABLED');
6196: end if;
6197:
6198: -- Argument validation
6196: end if;
6197:
6198: -- Argument validation
6199: if ((itemtype is null) or (itemkey is null) or (activity is null) or
6200: (upper(command) not in (wf_engine.eng_skip, wf_engine.eng_retry))) then
6201: Wf_Core.Token('ITEMTYPE', itemtype);
6202: Wf_Core.Token('ITEMKEY', itemkey);
6203: Wf_Core.Token('ACTIVITY', activity);
6204: Wf_Core.Token('COMMAND', command);
6247: actdate, upper(command), result);
6248:
6249: exception
6250: when others then
6251: Wf_Core.Context('Wf_Engine', 'HandleError', itemtype, itemkey, activity,
6252: command, result);
6253: raise;
6254: end HandleError;
6255:
6264: -- [
6265: -- command - SKIP or RETRY.
6266: --
6267: -- docommit - True if you want a commit for every n iterations.
6268: -- n is defined as wf_engine.commit_frequency
6269: --
6270: procedure HandleErrorAll(itemtype in varchar2,
6271: itemkey in varchar2,
6272: activity in varchar2,
6322: exit outer_handle;
6323: end if;
6324:
6325: -- Not allowed in synch mode
6326: if (c_item_key = wf_engine.eng_synch) then
6327: wf_core.token('OPERATION', 'Wf_Engine.HandleErrorAll');
6328: wf_core.raise('WFENG_SYNCH_DISABLED');
6329: end if;
6330:
6323: end if;
6324:
6325: -- Not allowed in synch mode
6326: if (c_item_key = wf_engine.eng_synch) then
6327: wf_core.token('OPERATION', 'Wf_Engine.HandleErrorAll');
6328: wf_core.raise('WFENG_SYNCH_DISABLED');
6329: end if;
6330:
6331: -- Argument validation
6329: end if;
6330:
6331: -- Argument validation
6332: if ((itemtype is null) or (c_item_key is null) or (c_activity is null) or
6333: (upper(command) not in (wf_engine.eng_skip, wf_engine.eng_retry)))
6334: then
6335: Wf_Core.Token('ITEMTYPE', itemtype);
6336: Wf_Core.Token('ITEMKEY', c_item_key);
6337: Wf_Core.Token('ACTIVITY', c_activity);
6361: HandleErrorInternal(itemtype, c_item_key, root, rootid, c_activity,
6362: c_actid, actdate, upper(command), result);
6363:
6364: exit handle_loop when
6365: (docommit and (actc%rowcount = wf_engine.commit_frequency));
6366:
6367: end loop handle_loop;
6368:
6369: if (actc%ISOPEN) then
6386: end if;
6387:
6388: exception
6389: when others then
6390: Wf_Core.Context('Wf_Engine', 'HandleErrorAll', itemtype, itemkey);
6391: raise;
6392: end HandleErrorAll;
6393:
6394: --
6418:
6419: wf_item_activity_status.root_status(itemtype,itemkey,status,result);
6420: exception
6421: when others then
6422: Wf_Core.Context('Wf_Engine', 'ItemStatus', itemtype, itemkey);
6423: raise;
6424: end ItemStatus;
6425:
6426: -- API to reterive more granular information from the
6468: wf_items i,
6469: wf_notifications ntf
6470: where ias.item_type = p_itemtype
6471: and ias.item_key = p_itemkey
6472: and ias.activity_status = wf_engine.eng_completed
6473: and ias.process_activity = pa.instance_id
6474: and pa.activity_name = ac.name
6475: and pa.activity_item_type = ac.item_type
6476: and pa.process_name = ap.name
6486:
6487: begin
6488: --Get the item status
6489: --Use the API above for the same
6490: wf_engine.ItemStatus(itemtype ,itemkey ,l_status,l_result);
6491:
6492: --Now check the status if root has completed
6493: --we do not want to go further lower
6494: --Else if the root is still active , lets find
6509: activity_result_code
6510: from wf_item_activity_statuses
6511: where item_type = itemtype
6512: and item_key = itemkey
6513: and activity_status <> wf_engine.eng_completed
6514: order by decode(activity_status, 'ERROR',1, 'NOTIFIED',2, 'DEFERRED',3,
6515: 'SUSPEND',4, 'WAITING',5, 'ACTIVE',6, 7) asc,
6516: begin_date desc, execution_time desc
6517: )
6537: result := l_result ;
6538: end if;
6539: exception
6540: when others then
6541: Wf_Core.Context('Wf_Engine', 'ItemInfo', itemtype, itemkey);
6542: raise;
6543: end ItemInfo;
6544:
6545:
6582: when OTHERS then
6583: raise;
6584: end;
6585:
6586: return(Wf_Engine.Activity_Exist(
6587: p_process_item_type=>p_item_type,
6588: p_process_name=>rootactivity,
6589: p_activity_item_type=>p_activity_item_type,
6590: p_activity_name=>p_activity_name,
6591: active_date=>active_date));
6592:
6593: exception
6594: when others then
6595: Wf_Core.Context('Wf_Engine', 'Activity_Exist_In_Process',
6596: p_item_type, p_item_key,
6597: nvl(p_activity_item_type, p_item_type),
6598: p_activity_name);
6599: raise;
6673:
6674: if (n = 0) then
6675: -- recursively check subprocesses
6676: for actr in actcur(m_version) loop
6677: if (Wf_Engine.Activity_Exist(
6678: actr.activity_item_type,
6679: actr.activity_name,
6680: nvl(p_activity_item_type, p_process_item_type),
6681: p_activity_name,
6692: end if;
6693:
6694: exception
6695: when OTHERS then
6696: Wf_Core.Context('Wf_Engine', 'Activity_Exist',
6697: p_process_item_type, p_process_name,
6698: nvl(p_activity_item_type, p_process_item_type),
6699: p_activity_name);
6700: raise;
6774: Wf_Core.Raise('WFSQL_ARGS');
6775: end if;
6776:
6777: -- Not allowed in synch mode
6778: if (itemkey = wf_engine.eng_synch) then
6779: Wf_Core.Token('OPERATION', 'Wf_Engine.Set_Item_Parent');
6780: Wf_Core.Raise('WFENG_SYNCH_DISABLED');
6781: end if;
6782:
6775: end if;
6776:
6777: -- Not allowed in synch mode
6778: if (itemkey = wf_engine.eng_synch) then
6779: Wf_Core.Token('OPERATION', 'Wf_Engine.Set_Item_Parent');
6780: Wf_Core.Raise('WFENG_SYNCH_DISABLED');
6781: end if;
6782:
6783: -- Retrieve event name from message
6811:
6812: else
6813: -- Process not running yet, create it.
6814: -- If process_name is null then will use selector function.
6815: Wf_Engine.CreateProcess(itemtype, itemkey, process_name);
6816: actdate := WF_Item.Active_Date(itemtype, itemkey);
6817:
6818: -- Bug 2259039
6819: -- Start the new process
6816: actdate := WF_Item.Active_Date(itemtype, itemkey);
6817:
6818: -- Bug 2259039
6819: -- Start the new process
6820: Wf_Engine_Util.Start_Process_Internal(
6821: itemtype => itemtype,
6822: itemkey => itemkey,
6823: runmode => 'EVENT');
6824:
6826: actdate := WF_Item.Active_Date(itemtype, itemkey);
6827: for act in evtacts loop
6828: actarr(i) := act.actid;
6829: Wf_Item_Activity_Status.Create_Status(itemtype, itemkey, act.actid,
6830: wf_engine.eng_notified, wf_engine.eng_null, sysdate, null);
6831: i := i + 1;
6832: end loop;
6833: actarr(i) := '';
6834: end if;
6860: WHERE item_type = itemtype
6861: AND item_key = itemkey;
6862:
6863: if (parent_itemtype is null and parent_itemkey is null ) then
6864: Wf_Engine.SetItemParent(itemtype => itemtype,
6865: itemkey => itemkey,
6866: parent_itemtype =>
6867: substr(avalue,1,
6868: instr(avalue,':')-1),
6874: elsif aname = '#OWNER_ROLE' then
6875: --Bug 2388634
6876: --This is for the applications to set their item owner
6877: --by including a #OWNER_ROLE parameter for the event
6878: wf_engine.SetItemowner(itemtype,itemkey,avalue);
6879:
6880: else
6881: -- event item attributes may use canonical masks.
6882: Wf_Engine.SetEventItemAttr(itemtype, itemkey, aname, avalue);
6878: wf_engine.SetItemowner(itemtype,itemkey,avalue);
6879:
6880: else
6881: -- event item attributes may use canonical masks.
6882: Wf_Engine.SetEventItemAttr(itemtype, itemkey, aname, avalue);
6883: end if;
6884: exception
6885: when others then
6886: if (wf_core.error_name = 'WFENG_ITEM_ATTR') then
6885: when others then
6886: if (wf_core.error_name = 'WFENG_ITEM_ATTR') then
6887: -- If attr doesn't exist create runtime itemattr
6888: Wf_Core.Clear;
6889: Wf_Engine.AddItemAttr(itemtype, itemkey, aname, avalue);
6890: else
6891: raise; -- All other errors are raised up.
6892: end if;
6893: end;
6900: begin
6901: savepoint wf_savepoint;
6902: -- Save event data to itemattrs requested by this activity.
6903: -- #EVENTNAME
6904: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6905: wf_engine.eng_eventname);
6906: if (aname is not null) then
6907: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, event_name);
6908: end if;
6901: savepoint wf_savepoint;
6902: -- Save event data to itemattrs requested by this activity.
6903: -- #EVENTNAME
6904: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6905: wf_engine.eng_eventname);
6906: if (aname is not null) then
6907: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, event_name);
6908: end if;
6909: -- #EVENTKEY
6903: -- #EVENTNAME
6904: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6905: wf_engine.eng_eventname);
6906: if (aname is not null) then
6907: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, event_name);
6908: end if;
6909: -- #EVENTKEY
6910: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6911: wf_engine.eng_eventkey);
6906: if (aname is not null) then
6907: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, event_name);
6908: end if;
6909: -- #EVENTKEY
6910: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6911: wf_engine.eng_eventkey);
6912: if (aname is not null) then
6913: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname,
6914: event_message.GetEventKey);
6907: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname, event_name);
6908: end if;
6909: -- #EVENTKEY
6910: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6911: wf_engine.eng_eventkey);
6912: if (aname is not null) then
6913: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname,
6914: event_message.GetEventKey);
6915: end if;
6909: -- #EVENTKEY
6910: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6911: wf_engine.eng_eventkey);
6912: if (aname is not null) then
6913: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname,
6914: event_message.GetEventKey);
6915: end if;
6916: -- #EVENTMESSAGE
6917: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6913: Wf_Engine.SetItemAttrText(itemtype, itemkey, aname,
6914: event_message.GetEventKey);
6915: end if;
6916: -- #EVENTMESSAGE
6917: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6918: wf_engine.eng_eventmessage);
6919: if (aname is not null) then
6920: Wf_Engine.SetItemAttrEvent(itemtype, itemkey, aname, event_message);
6921: end if;
6914: event_message.GetEventKey);
6915: end if;
6916: -- #EVENTMESSAGE
6917: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6918: wf_engine.eng_eventmessage);
6919: if (aname is not null) then
6920: Wf_Engine.SetItemAttrEvent(itemtype, itemkey, aname, event_message);
6921: end if;
6922:
6916: -- #EVENTMESSAGE
6917: aname := Wf_Engine.GetActivityAttrText(itemtype, itemkey, actarr(i),
6918: wf_engine.eng_eventmessage);
6919: if (aname is not null) then
6920: Wf_Engine.SetItemAttrEvent(itemtype, itemkey, aname, event_message);
6921: end if;
6922:
6923: -- Execute our lovely event activity (result is always null).
6924: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actarr(i),
6920: Wf_Engine.SetItemAttrEvent(itemtype, itemkey, aname, event_message);
6921: end if;
6922:
6923: -- Execute our lovely event activity (result is always null).
6924: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actarr(i),
6925: wf_engine.eng_null);
6926: exception
6927: when others then
6928: -- If anything in this process raises an exception:
6921: end if;
6922:
6923: -- Execute our lovely event activity (result is always null).
6924: Wf_Engine_Util.Complete_Activity(itemtype, itemkey, actarr(i),
6925: wf_engine.eng_null);
6926: exception
6927: when others then
6928: -- If anything in this process raises an exception:
6929: -- 1. rollback any work in this process thread
6930: -- 2. set this activity to error status
6931: -- 3. execute the error process (if any)
6932: -- 4. clear the error to continue with next activity
6933: rollback to wf_savepoint;
6934: Wf_Core.Context('Wf_Engine', 'Event', itemtype, itemkey,
6935: process_name, event_name);
6936: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actarr(i),
6937: wf_engine.eng_exception, FALSE);
6938: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actarr(i),
6933: rollback to wf_savepoint;
6934: Wf_Core.Context('Wf_Engine', 'Event', itemtype, itemkey,
6935: process_name, event_name);
6936: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actarr(i),
6937: wf_engine.eng_exception, FALSE);
6938: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actarr(i),
6939: wf_engine.eng_exception);
6940: Wf_Core.Clear;
6941: end;
6934: Wf_Core.Context('Wf_Engine', 'Event', itemtype, itemkey,
6935: process_name, event_name);
6936: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actarr(i),
6937: wf_engine.eng_exception, FALSE);
6938: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actarr(i),
6939: wf_engine.eng_exception);
6940: Wf_Core.Clear;
6941: end;
6942: i := i + 1;
6935: process_name, event_name);
6936: Wf_Item_Activity_Status.Set_Error(itemtype, itemkey, actarr(i),
6937: wf_engine.eng_exception, FALSE);
6938: Wf_Engine_Util.Execute_Error_Process(itemtype, itemkey, actarr(i),
6939: wf_engine.eng_exception);
6940: Wf_Core.Clear;
6941: end;
6942: i := i + 1;
6943: end loop;
6943: end loop;
6944:
6945: exception
6946: when others then
6947: Wf_Core.Context('Wf_Engine', 'Event', itemtype, itemkey,
6948: process_name, event_name);
6949: raise;
6950: end Event;
6951:
7058: aname := plist(i).GetName;
7059: avalue := plist(i).GetValue;
7060: begin
7061: if aname = '#CONTEXT' then
7062: Wf_Engine.SetItemParent(itemtype => evtacts_rec.item_type,
7063: itemkey => evtacts_rec.item_key,
7064: parent_itemtype =>substr(avalue,1,instr(avalue,':')-1),
7065: parent_itemkey =>substr(avalue,instr(avalue,':')+1),
7066: parent_context => null);
7065: parent_itemkey =>substr(avalue,instr(avalue,':')+1),
7066: parent_context => null);
7067: else
7068: -- event item attributes may use canonical masks.
7069: Wf_Engine.SetEventItemAttr(evtacts_rec.item_type,
7070: evtacts_rec.item_key, aname, avalue);
7071: end if;
7072: exception
7073: when others then
7074: if (wf_core.error_name = 'WFENG_ITEM_ATTR') then
7075: -- If attr doesn't exist create runtime itemattr
7076: Wf_Core.Clear;
7077:
7078: Wf_Engine.AddItemAttr(evtacts_rec.item_type,
7079: evtacts_rec.item_key,
7080: aname, avalue);
7081: else
7082: raise; -- All other errors are raised up.
7088: begin
7089: savepoint wf_savepoint;
7090: -- Save event data to itemattrs requested by this activity.
7091: -- #EVENTNAME
7092: aname := Wf_Engine.GetActivityAttrText(evtacts_rec.item_type,
7093: evtacts_rec.item_key,
7094: evtacts_rec.actid,
7095: wf_engine.eng_eventname);
7096: if (aname is not null) then
7091: -- #EVENTNAME
7092: aname := Wf_Engine.GetActivityAttrText(evtacts_rec.item_type,
7093: evtacts_rec.item_key,
7094: evtacts_rec.actid,
7095: wf_engine.eng_eventname);
7096: if (aname is not null) then
7097: Wf_Engine.SetItemAttrText(evtacts_rec.item_type,
7098: evtacts_rec.item_key,
7099: aname,
7093: evtacts_rec.item_key,
7094: evtacts_rec.actid,
7095: wf_engine.eng_eventname);
7096: if (aname is not null) then
7097: Wf_Engine.SetItemAttrText(evtacts_rec.item_type,
7098: evtacts_rec.item_key,
7099: aname,
7100: event_name);
7101: end if;
7099: aname,
7100: event_name);
7101: end if;
7102: -- #EVENTKEY
7103: aname := Wf_Engine.GetActivityAttrText(evtacts_rec.item_type,
7104: evtacts_rec.item_key,
7105: evtacts_rec.actid,
7106: wf_engine.eng_eventkey);
7107: if (aname is not null) then
7102: -- #EVENTKEY
7103: aname := Wf_Engine.GetActivityAttrText(evtacts_rec.item_type,
7104: evtacts_rec.item_key,
7105: evtacts_rec.actid,
7106: wf_engine.eng_eventkey);
7107: if (aname is not null) then
7108: Wf_Engine.SetItemAttrText(evtacts_rec.item_type,
7109: evtacts_rec.item_key, aname,
7110: event_message.GetEventKey);
7104: evtacts_rec.item_key,
7105: evtacts_rec.actid,
7106: wf_engine.eng_eventkey);
7107: if (aname is not null) then
7108: Wf_Engine.SetItemAttrText(evtacts_rec.item_type,
7109: evtacts_rec.item_key, aname,
7110: event_message.GetEventKey);
7111: end if;
7112: -- #EVENTMESSAGE
7109: evtacts_rec.item_key, aname,
7110: event_message.GetEventKey);
7111: end if;
7112: -- #EVENTMESSAGE
7113: aname := Wf_Engine.GetActivityAttrText(evtacts_rec.item_type,
7114: evtacts_rec.item_key,
7115: evtacts_rec.actid,
7116: wf_engine.eng_eventmessage);
7117: if (aname is not null) then
7112: -- #EVENTMESSAGE
7113: aname := Wf_Engine.GetActivityAttrText(evtacts_rec.item_type,
7114: evtacts_rec.item_key,
7115: evtacts_rec.actid,
7116: wf_engine.eng_eventmessage);
7117: if (aname is not null) then
7118: Wf_Engine.SetItemAttrEvent(evtacts_rec.item_type,
7119: evtacts_rec.item_key,
7120: aname,
7114: evtacts_rec.item_key,
7115: evtacts_rec.actid,
7116: wf_engine.eng_eventmessage);
7117: if (aname is not null) then
7118: Wf_Engine.SetItemAttrEvent(evtacts_rec.item_type,
7119: evtacts_rec.item_key,
7120: aname,
7121: event_message);
7122: end if;
7121: event_message);
7122: end if;
7123:
7124: -- Execute our lovely event activity (result is always null).
7125: Wf_Engine_Util.Complete_Activity(evtacts_rec.item_type,
7126: evtacts_rec.item_key, evtacts_rec.actid,
7127: wf_engine.eng_null);
7128: exception
7129: when others then
7123:
7124: -- Execute our lovely event activity (result is always null).
7125: Wf_Engine_Util.Complete_Activity(evtacts_rec.item_type,
7126: evtacts_rec.item_key, evtacts_rec.actid,
7127: wf_engine.eng_null);
7128: exception
7129: when others then
7130: -- If anything in this process raises an exception:
7131: -- 1. rollback any work in this process thread
7132: -- 2. set this activity to error status
7133: -- 3. execute the error process (if any)
7134: -- 4. clear the error to continue with next activity
7135: rollback to wf_savepoint;
7136: Wf_Core.Context('Wf_Engine', 'Event2', evtacts_rec.item_type,
7137: evtacts_rec.item_key, event_name);
7138: Wf_Item_Activity_Status.Set_Error(evtacts_rec.item_type,
7139: evtacts_rec.item_key,
7140: evtacts_rec.actid,
7137: evtacts_rec.item_key, event_name);
7138: Wf_Item_Activity_Status.Set_Error(evtacts_rec.item_type,
7139: evtacts_rec.item_key,
7140: evtacts_rec.actid,
7141: wf_engine.eng_exception, FALSE);
7142: Wf_Engine_Util.Execute_Error_Process(evtacts_rec.item_type,
7143: evtacts_rec.item_key,
7144: evtacts_rec.actid,
7145: wf_engine.eng_exception);
7138: Wf_Item_Activity_Status.Set_Error(evtacts_rec.item_type,
7139: evtacts_rec.item_key,
7140: evtacts_rec.actid,
7141: wf_engine.eng_exception, FALSE);
7142: Wf_Engine_Util.Execute_Error_Process(evtacts_rec.item_type,
7143: evtacts_rec.item_key,
7144: evtacts_rec.actid,
7145: wf_engine.eng_exception);
7146: Wf_Core.Clear;
7141: wf_engine.eng_exception, FALSE);
7142: Wf_Engine_Util.Execute_Error_Process(evtacts_rec.item_type,
7143: evtacts_rec.item_key,
7144: evtacts_rec.actid,
7145: wf_engine.eng_exception);
7146: Wf_Core.Clear;
7147: end;
7148:
7149: i := i + 1;
7160: --Rollback to ensure that we aren't locking anything here
7161: rollback to wf_savepoint_event2;
7162: raise;
7163: when others then
7164: Wf_Core.Context('Wf_Engine', 'Event2', businesskey, event_name);
7165: raise;
7166: end Event2;
7167:
7168: --
7199: Wf_Core.Token('P_ANAME', nvl(p_aname, 'NULL'));
7200: Wf_Core.Raise('WFSQL_ARGS');
7201: end if;
7202:
7203: if (p_itemkey = wf_engine.eng_synch) then
7204: WF_CACHE.GetItemAttrValue(p_itemtype, p_itemKey, p_aname, iStatus,
7205: wiavIND);
7206:
7207: if (iStatus <> WF_CACHE.task_SUCCESS) then
7247: when no_data_found then
7248: return NULL;
7249:
7250: when others then
7251: Wf_Core.Context('Wf_Engine', 'AddToItemAttrNumber', p_itemtype, p_itemkey,
7252: p_aname, to_char(p_addend));
7253: raise;
7254: end AddToItemAttrNumber;
7255:
7268: -- p_start_date - Errored On or After date
7269: -- p_end_date - Errored On or Before date
7270: -- p_max_retry - Maximum retries allowed on an activity
7271: -- p_docommit - Y (Yes) if you want a commit for every n iterations.
7272: -- n is defined as wf_engine.commit_frequency
7273: --
7274: procedure HandleErrorConcurrent(p_errbuf out nocopy varchar2,
7275: p_retcode out nocopy varchar2,
7276: p_itemtype in varchar2,
7345:
7346: l_max_retry := to_number(nvl(p_max_retry, '5'));
7347:
7348: -- Write parameters to log file
7349: Fnd_File.Put_Line(Fnd_File.Log, 'Wf_Engine.HandleErrorConcurrent');
7350: Fnd_File.Put_Line(Fnd_File.Log, 'p_itemtype - '||p_itemtype);
7351: Fnd_File.Put_Line(Fnd_File.Log, 'p_itemkey - '||p_itemkey);
7352: Fnd_File.Put_Line(Fnd_File.Log, 'p_process - '||p_process);
7353: Fnd_File.Put_Line(Fnd_File.Log, 'p_activity - '||p_activity);
7375: l_end_date,
7376: l_max_retry)
7377: loop
7378:
7379: Wf_Engine.HandleError(itemtype => p_itemtype,
7380: itemkey => l_rec.item_key,
7381: activity => l_rec.process_name||':'||l_rec.activity,
7382: command => wf_engine.eng_retry,
7383: result => '');
7378:
7379: Wf_Engine.HandleError(itemtype => p_itemtype,
7380: itemkey => l_rec.item_key,
7381: activity => l_rec.process_name||':'||l_rec.activity,
7382: command => wf_engine.eng_retry,
7383: result => '');
7384:
7385: if (l_docommit and c_err_acts%rowcount = wf_engine.commit_frequency) then
7386: commit;
7381: activity => l_rec.process_name||':'||l_rec.activity,
7382: command => wf_engine.eng_retry,
7383: result => '');
7384:
7385: if (l_docommit and c_err_acts%rowcount = wf_engine.commit_frequency) then
7386: commit;
7387: Fnd_Concurrent.Set_Preferred_RBS;
7388: end if;
7389: l_count := c_err_acts%rowcount;
7412: -- bug 6161171
7413: procedure AbortProcess2(itemtype in varchar2,
7414: itemkey in varchar2,
7415: process in varchar2 default '',
7416: result in varchar2 default wf_engine.eng_force,
7417: verify_lock in binary_integer default 0,
7418: cascade in binary_integer default 0)
7419: is
7420: l_verify_lock boolean;
7429: if (cascade <> 0) then
7430: l_cascade := true;
7431: end if;
7432:
7433: wf_engine.AbortProcess(itemtype, itemkey, process, result, l_verify_lock, l_cascade);
7434:
7435: end AbortProcess2;
7436:
7437: end Wf_Engine;
7433: wf_engine.AbortProcess(itemtype, itemkey, process, result, l_verify_lock, l_cascade);
7434:
7435: end AbortProcess2;
7436:
7437: end Wf_Engine;