1: package body WF_CACHE as
2: /* $Header: WFCACHEB.pls 120.2 2006/02/22 16:40:17 rwunderl ship $ */
3:
4:
5: /*======================================+
33: p_HashSize in NUMBER ) is
34:
35:
36: BEGIN
37: WF_CACHE.Clear;
38: HashBase := p_HashBase;
39: HashSize := p_HashSize;
40:
41: END;
126: PROCEDURE CacheManager (TableName in PLS_INTEGER,
127: NumRows in NUMBER) is
128:
129: BEGIN
130: if (TableName = WF_CACHE.TAB_Activities) then
131: if (Activities.COUNT + NumRows >= MaxActivities) then
132: Activities.DELETE;
133:
134: end if;
133:
134: end if;
135:
136:
137: elsif (TableName = WF_CACHE.TAB_ActivityTransitions) then
138: if (ActivityTransitions.COUNT + NumRows >= MaxActivityTransitions) then
139: ActivityTransitions.DELETE;
140:
141: end if;
140:
141: end if;
142:
143:
144: elsif (TableName = WF_CACHE.TAB_ActivityAttributes) then
145: if (ActivityAttributes.COUNT + NumRows >= MaxActivityAttrs) then
146: ActivityAttributes.DELETE;
147:
148: end if;
156: ProcessActivities.DELETE;
157:
158: end if;
159:
160: elsif (TableName = WF_CACHE.TAB_ActivityAttrValues) then
161: if (ActivityAttrValues.COUNT + NumRows >= MaxActivityAttrValues) then
162: ActivityAttrValues.DELETE;
163:
164: end if;
162: ActivityAttrValues.DELETE;
163:
164: end if;
165:
166: elsif (TableName = WF_CACHE.TAB_ItemAttributes) then
167: if (ItemAttributes.COUNT + NumRows >= MaxItemAttributes) then
168: ItemAttributes.DELETE;
169:
170: end if;
168: ItemAttributes.DELETE;
169:
170: end if;
171:
172: elsif (TableName = WF_CACHE.TAB_ItemTypes) then
173: if (ItemTypes.COUNT + NumRows >= MaxItemTypes) then
174: ItemTypes.DELETE;
175:
176: end if;
174: ItemTypes.DELETE;
175:
176: end if;
177:
178: elsif (TableName = WF_CACHE.TAB_ProcessActivities) then
179: if (ProcessActivities.COUNT + NumRows >= MaxProcessActivities) then
180: ProcessActivities.DELETE;
181:
182: end if;
180: ProcessActivities.DELETE;
181:
182: end if;
183: --
184: elsif (TableName = WF_CACHE.TAB_ProcessStartActivities) then
185: if (ProcessStartActivities.COUNT + NumRows >=
186: MaxProcessStartActivities) then
187: ProcessStartActivities.DELETE;
188:
213: l_UpdateTime DATE;
214:
215: BEGIN
216:
217: if( WF_CACHE.CacheSessionID is NOT NULL ) then
218:
219: /*----------------------------------------+
220: | Checking to see when the itemType was |
221: | last updated. |
228: and LANGUAGE = 'US';
229:
230: exception
231: when NO_DATA_FOUND then
232: WF_CACHE.Reset;
233: return TRUE;
234:
235: when others then
236: raise;
244: | Clear the cache and reset our |
245: | CacheSessionID for a new Caching |
246: | session |
247: +---------------------------------------*/
248: WF_CACHE.Clear;
249: WF_CACHE.CacheSessionID := sysdate;
250: return TRUE;
251:
252: end if;
245: | CacheSessionID for a new Caching |
246: | session |
247: +---------------------------------------*/
248: WF_CACHE.Clear;
249: WF_CACHE.CacheSessionID := sysdate;
250: return TRUE;
251:
252: end if;
253:
258: | the cache for this DB session. |
259: | Setting the CacheSessionID to sysdate |
260: | and Clearing the cache. |
261: +---------------------------------------*/
262: WF_CACHE.CacheSessionID := sysdate;
263: WF_CACHE.Clear;
264: return TRUE;
265:
266: end if;
259: | Setting the CacheSessionID to sysdate |
260: | and Clearing the cache. |
261: +---------------------------------------*/
262: WF_CACHE.CacheSessionID := sysdate;
263: WF_CACHE.Clear;
264: return TRUE;
265:
266: end if;
267:
290: WF_ENGINE.date_format)
291: where name = 'WFCACHE_META_UPD';
292:
293: if (sql%notfound) then
294: -- When WF_CACHE.Reset is called for the very first time on a system
295: -- we will jump into this code to insert the record.
296: begin
297: insert into WF_RESOURCES (TYPE, NAME, LANGUAGE,SOURCE_LANG, ID,
298: TEXT, PROTECT_LEVEL, CUSTOM_LEVEL)
305: null;
306: end;
307: end if;
308: end if;
309: WF_CACHE.Clear;
310:
311: END;
312:
313:
370: +========================================================*/
371:
372: if ((itemType <> Activities(iKey).item_type) or
373: (name <> Activities(iKey).name)) then
374: raise WF_CACHE.HashCollision;
375:
376: else
377:
378: /*========================================================+
380: | waIND to the caller. |
381: +========================================================*/
382:
383:
384: status := WF_CACHE.task_SUCCESS;
385:
386:
387:
388: end if;
388: end if;
389:
390: else -- Activity Record is not the proper version.
391:
392: status := WF_CACHE.task_FAILED;
393: CacheManager(TAB_Activities);
394:
395: end if;
396:
395: end if;
396:
397: else -- We did not find an Activity Record in cache.
398:
399: status := WF_CACHE.task_FAILED;
400: CacheManager(TAB_Activities);
401:
402: end if;
403:
402: end if;
403:
404: EXCEPTION
405: when NO_DATA_FOUND then
406: status := WF_CACHE.task_FAILED;
407: CacheManager(TAB_Activities);
408:
409: when HashCollision then
410: if not (ErrorOnCollision) then
407: CacheManager(TAB_Activities);
408:
409: when HashCollision then
410: if not (ErrorOnCollision) then
411: status := WF_CACHE.task_FAILED;
412:
413: else
414: raise;
415:
449: l_status PLS_INTEGER;
450:
451:
452: BEGIN
453: WF_CACHE.GetProcessActivity(actid, l_status);
454:
455: -- First we will check to see if the ProcessActivity is in cache.
456: -- Then we will use the ACTIVITY_NAME to check the other cache records.
457:
454:
455: -- First we will check to see if the ProcessActivity is in cache.
456: -- Then we will use the ACTIVITY_NAME to check the other cache records.
457:
458: if (l_status <> WF_CACHE.task_SUCCESS) then
459: status := WF_CACHE.task_FAILED;
460: CacheManager(TAB_ActivityAttributes);
461: return;
462:
455: -- First we will check to see if the ProcessActivity is in cache.
456: -- Then we will use the ACTIVITY_NAME to check the other cache records.
457:
458: if (l_status <> WF_CACHE.task_SUCCESS) then
459: status := WF_CACHE.task_FAILED;
460: CacheManager(TAB_ActivityAttributes);
461: return;
462:
463: end if;
472:
473: -- We will now check to see if we have an activity in cache that is the
474: -- proper version.
475:
476: WF_CACHE.GetActivity( ProcessActivities(actid).ACTIVITY_ITEM_TYPE,
477: ProcessActivities(actid).ACTIVITY_NAME,
478: actdate, l_status, l_WAIndex );
479:
480: if (l_status <> WF_CACHE.task_SUCCESS) then
476: WF_CACHE.GetActivity( ProcessActivities(actid).ACTIVITY_ITEM_TYPE,
477: ProcessActivities(actid).ACTIVITY_NAME,
478: actdate, l_status, l_WAIndex );
479:
480: if (l_status <> WF_CACHE.task_SUCCESS) then
481: status := WF_CACHE.task_FAILED;
482: CacheManager(TAB_ActivityAttributes);
483: return;
484:
477: ProcessActivities(actid).ACTIVITY_NAME,
478: actdate, l_status, l_WAIndex );
479:
480: if (l_status <> WF_CACHE.task_SUCCESS) then
481: status := WF_CACHE.task_FAILED;
482: CacheManager(TAB_ActivityAttributes);
483: return;
484:
485: end if;
511: end if;
512:
513: else
514:
515: status := WF_CACHE.task_FAILED;
516: CacheManager(TAB_ActivityAttributes);
517:
518: return;
519:
521:
522: EXCEPTION
523: when HashCollision then
524: if not (ErrorOnCollision) then
525: status := WF_CACHE.task_FAILED;
526: CacheManager(TAB_ActivityAttributes);
527:
528: else
529: raise;
569: (name <> ActivityAttrValues(iKey).name)) then
570: raise HashCollision;
571:
572: else
573: status := WF_CACHE.task_SUCCESS;
574:
575: end if;
576:
577: else
574:
575: end if;
576:
577: else
578: status := WF_CACHE.task_FAILED;
579: CacheManager(TAB_ActivityAttrValues);
580:
581: end if;
582:
581: end if;
582:
583: EXCEPTION
584: when NO_DATA_FOUND then
585: status := WF_CACHE.task_FAILED;
586: CacheManager(TAB_ActivityAttrValues);
587:
588: when HashCollision then
589: if not (ErrorOnCollision) then
586: CacheManager(TAB_ActivityAttrValues);
587:
588: when HashCollision then
589: if not (ErrorOnCollision) then
590: status := WF_CACHE.task_FAILED;
591: CacheManager(TAB_ActivityAttrValues);
592:
593: else
594: raise;
619: is
620: iKey NUMBER;
621:
622: begin
623: iKey := WF_CACHE.HashKey(FromActID||':'|| result);
624: watIND := iKey;
625:
626: if (WF_CACHE.ActivityTransitions.EXISTS(iKey)) then
627: if ((WF_CACHE.ActivityTransitions(iKey).FROM_PROCESS_ACTIVITY <> FromActID)
622: begin
623: iKey := WF_CACHE.HashKey(FromActID||':'|| result);
624: watIND := iKey;
625:
626: if (WF_CACHE.ActivityTransitions.EXISTS(iKey)) then
627: if ((WF_CACHE.ActivityTransitions(iKey).FROM_PROCESS_ACTIVITY <> FromActID)
628: or (WF_CACHE.ActivityTransitions(iKey).RESULT_CODE not in
629: (result, WF_ENGINE.eng_trans_default, WF_ENGINE.eng_trans_any))) then
630: raise HashCollision;
623: iKey := WF_CACHE.HashKey(FromActID||':'|| result);
624: watIND := iKey;
625:
626: if (WF_CACHE.ActivityTransitions.EXISTS(iKey)) then
627: if ((WF_CACHE.ActivityTransitions(iKey).FROM_PROCESS_ACTIVITY <> FromActID)
628: or (WF_CACHE.ActivityTransitions(iKey).RESULT_CODE not in
629: (result, WF_ENGINE.eng_trans_default, WF_ENGINE.eng_trans_any))) then
630: raise HashCollision;
631:
624: watIND := iKey;
625:
626: if (WF_CACHE.ActivityTransitions.EXISTS(iKey)) then
627: if ((WF_CACHE.ActivityTransitions(iKey).FROM_PROCESS_ACTIVITY <> FromActID)
628: or (WF_CACHE.ActivityTransitions(iKey).RESULT_CODE not in
629: (result, WF_ENGINE.eng_trans_default, WF_ENGINE.eng_trans_any))) then
630: raise HashCollision;
631:
632: else
629: (result, WF_ENGINE.eng_trans_default, WF_ENGINE.eng_trans_any))) then
630: raise HashCollision;
631:
632: else
633: status := WF_CACHE.task_SUCCESS;
634:
635:
636: end if;
637:
635:
636: end if;
637:
638: else
639: status := WF_CACHE.task_FAILED;
640: CacheManager(TAB_ActivityTransitions);
641: end if;
642:
643: exception
642:
643: exception
644: when HashCollision then
645: if not (ErrorOnCollision) then
646: status := WF_CACHE.task_FAILED;
647: --Normally we can just report a failure so the calling api will store
648: --a new record in the current slot and move on. However since
649: --activity transitions are interrelated, we have to clear the whole
650: --table to ensure consistency. This condition should not occur in
648: --a new record in the current slot and move on. However since
649: --activity transitions are interrelated, we have to clear the whole
650: --table to ensure consistency. This condition should not occur in
651: --normal processing and is just a safegard against the extreme.
652: WF_CACHE.ActivityTransitions.DELETE;
653:
654: else
655: raise;
656:
690: (name <> ItemAttributes(iKey).name)) then
691: raise HashCollision;
692:
693: else
694: status := WF_CACHE.task_SUCCESS;
695:
696: end if;
697:
698: else
695:
696: end if;
697:
698: else
699: status := WF_CACHE.task_FAILED;
700: CacheManager(TAB_ItemAttributes);
701:
702: end if;
703:
702: end if;
703:
704: EXCEPTION
705: when NO_DATA_FOUND then
706: status := WF_CACHE.task_FAILED;
707: CacheManager(TAB_ItemAttributes);
708:
709: when HashCollision then
710: if not (ErrorOnCollision) then
707: CacheManager(TAB_ItemAttributes);
708:
709: when HashCollision then
710: if not (ErrorOnCollision) then
711: status := WF_CACHE.task_FAILED;
712: CacheManager(TAB_ItemAttributes);
713:
714: else
715: raise;
756: (ItemAttrValues(iKey).NAME <> name)) then
757: raise hashcollision;
758:
759: else
760: status := WF_CACHE.task_SUCCESS;
761:
762: end if;
763:
764: else
761:
762: end if;
763:
764: else
765: status := WF_CACHE.task_FAILED;
766:
767: end if;
768:
769: exception
768:
769: exception
770: when HashCollision then
771: if not (ErrorOnCollision) then
772: status := WF_CACHE.task_FAILED;
773:
774: else
775: raise;
776:
804: raise HashCollision;
805:
806: else
807:
808: status := WF_CACHE.task_SUCCESS;
809:
810: end if;
811:
812: else
809:
810: end if;
811:
812: else
813: status := WF_CACHE.task_FAILED;
814: CacheManager(TAB_ItemTypes);
815:
816: end if;
817:
816: end if;
817:
818: EXCEPTION
819: when NO_DATA_FOUND then
820: status := WF_CACHE.task_FAILED;
821: CacheManager(TAB_ItemTypes);
822:
823: when HashCollision then
824: if not (ErrorOnCollision) then
821: CacheManager(TAB_ItemTypes);
822:
823: when HashCollision then
824: if not (ErrorOnCollision) then
825: status := WF_CACHE.task_FAILED;
826: CacheManager(TAB_ItemTypes);
827:
828: else
829: raise;
852: BEGIN
853:
854: if (ProcessActivities.EXISTS(actid)) then
855:
856: status := WF_CACHE.task_SUCCESS;
857:
858: else
859: status := WF_CACHE.task_FAILED;
860:
855:
856: status := WF_CACHE.task_SUCCESS;
857:
858: else
859: status := WF_CACHE.task_FAILED;
860:
861: end if;
862:
863: EXCEPTION
861: end if;
862:
863: EXCEPTION
864: when NO_DATA_FOUND then
865: status := WF_CACHE.task_FAILED;
866: CacheManager(TAB_ProcessActivities);
867:
868: when OTHERS then
869: raise;
891: BEGIN
892:
893: if (ProcessActivities.EXISTS(actid)) then
894:
895: WF_CACHE.GetActivity(ProcessActivities(actid).ACTIVITY_ITEM_TYPE,
896: ProcessActivities(actid).ACTIVITY_NAME, actdate,
897: l_status, l_waIND);
898:
899: waIND := l_waIND;
897: l_status, l_waIND);
898:
899: waIND := l_waIND;
900:
901: if ((l_status <> WF_CACHE.task_SUCCESS)
902:
903: or
904:
905: ((ProcessActivities(actid).ACTIVITY_ITEM_TYPE <>
907:
908: (ProcessActivities(actid).ACTIVITY_NAME <>
909: Activities(l_waIND).NAME)) ) then
910:
911: status := WF_CACHE.task_FAILED;
912: CacheManager(TAB_Activities);
913: CacheManager(TAB_ProcessActivities);
914: return;
915:
913: CacheManager(TAB_ProcessActivities);
914: return;
915:
916: else
917: status := WF_CACHE.task_SUCCESS;
918:
919: end if;
920:
921: else
918:
919: end if;
920:
921: else
922: status := WF_CACHE.task_FAILED;
923: CacheManager(TAB_Activities);
924: CacheManager(TAB_ProcessActivities);
925: return;
926:
927: end if;
928:
929: EXCEPTION
930: when NO_DATA_FOUND then
931: status := WF_CACHE.task_FAILED;
932: CacheManager(TAB_ProcessActivities);
933:
934: when OTHERS then
935: raise;
958: if (Parameter <> NLSParameters(iKey).PARAMETER) then
959: raise HashCollision;
960:
961: else
962: status := WF_CACHE.task_SUCCESS;
963:
964: end if;
965:
966: else
963:
964: end if;
965:
966: else
967: status := WF_CACHE.task_FAILED;
968: --We do not really need to cache manage NLS Parameters, the plsql table
969: --should remain small.
970:
971: end if;
971: end if;
972:
973: EXCEPTION
974: when NO_DATA_FOUND then
975: status := WF_CACHE.task_FAILED;
976:
977: when HashCollision then
978: if not (ErrorOnCollision) then
979: status := WF_CACHE.task_FAILED;
975: status := WF_CACHE.task_FAILED;
976:
977: when HashCollision then
978: if not (ErrorOnCollision) then
979: status := WF_CACHE.task_FAILED;
980:
981: else
982: raise;
983:
1018: (Version <> ProcessStartActivities(iKey).PROCESS_VERSION)) then
1019: raise HashCollision;
1020:
1021: else
1022: status := WF_CACHE.task_SUCCESS;
1023:
1024: end if;
1025:
1026: else
1023:
1024: end if;
1025:
1026: else
1027: status := WF_CACHE.task_FAILED;
1028: CacheManager(TAB_ProcessStartActivities);
1029: end if;
1030:
1031: exception
1030:
1031: exception
1032: when HashCollision then
1033: if not (ErrorOnCollision) then
1034: status := WF_CACHE.task_FAILED;
1035: --Normally we can just report a failure so the calling api will store
1036: --a new record in the current slot and move on. However since
1037: --starting process activites are interrelated, we have to clear the
1038: --whole table to ensure consistency. This condition should not occur
1036: --a new record in the current slot and move on. However since
1037: --starting process activites are interrelated, we have to clear the
1038: --whole table to ensure consistency. This condition should not occur
1039: --in normal processing and is just a safegard against the extreme.
1040: WF_CACHE.ProcessStartActivities.DELETE;
1041:
1042: else
1043: raise;
1044:
1084: return TRUE;
1085: end if;
1086: end;
1087:
1088: END WF_CACHE;
1089: