DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_WORKFLOW_UTILITY

Source


1 PACKAGE BODY hr_workflow_utility as
2 /* $Header: hrewuweb.pkb 120.1 2005/09/23 14:56:46 svittal noship $ */
3   g_package     VARCHAR2(31)   := 'hr_workflow_utility_web.';
4 -- ----------------------------------------------------------------------------
5 -- |-------------------------< item_attribute_exists >------------------------|
6 -- ----------------------------------------------------------------------------
7 function item_attribute_exists
8   (p_item_type in varchar2
9   ,p_item_key  in varchar2
10   ,p_name      in varchar2) return boolean is
11   -- --------------------------------------------------------------------------
12   -- declare local variables
13   -- --------------------------------------------------------------------------
14   l_dummy  number(1);
15   l_return boolean := true;
16   -- cursor determines if an attribute exists
17   cursor csr_wiav is
18     select 1
19     from   wf_item_attribute_values wiav
20     where  wiav.item_type = p_item_type
21     and    wiav.item_key  = p_item_key
22     and    wiav.name      = p_name;
23   --
24 begin
25   -- open the cursor
26   open csr_wiav;
27   fetch csr_wiav into l_dummy;
28   if csr_wiav%notfound then
29     -- item attribute does not exist so return false
30     l_return := false;
31   end if;
32   close csr_wiav;
33   return(l_return);
34 end item_attribute_exists;
35 
36 -- ----------------------------------------------------------------------
37 -- |----------------< get_activity_details >------------------------|
38 -- ----------------------------------------------------------------------
39 -- Private procedure to get the activity details for a given activity
40 -- instance
41 -- The details contain
42 --  p_display_name      Display Name
43 --  p_name              Activity Name
44 --  p_description       Description
45 PROCEDURE get_activity_details
46   (p_actid          IN  wf_process_activities.instance_id%TYPE
47   ,p_name               OUT NOCOPY wf_activities_tl.name%TYPE
48   ,p_display_name   OUT NOCOPY wf_activities_tl.display_name%TYPE
49   ,p_description    OUT NOCOPY wf_activities_tl.description%TYPE
50   ,p_instance_label OUT NOCOPY wf_process_activities.instance_label%TYPE) is
51   -- --------------------------------------------------------------------------
52   -- local cursor definitions
53   -- --------------------------------------------------------------------------
54   -- csr_wf_activity_details    -> selects the activity details used by the
55   --                   package for the given activity instance
56   --
57   CURSOR csr_wf_activity_details IS
58     select wav.name
59           ,wav.display_name
60           ,wav.description
61       ,wpa.instance_label
62     from   wf_activities_vl      wav
63           ,wf_process_activities wpa
64     where  wav.item_type   = wpa.activity_item_type
65     and    wav.name        = wpa.activity_name
66     and    wpa.instance_id = p_actid
67     and    wav.version =
68           (select max(wav1.version)
69            from   wf_activities_vl wav1
70            where  wav1.item_type   = wpa.activity_item_type
71            and    wav1.name        = wpa.activity_name);
72   -- --------------------------------------------------------------------------
73   -- local exception declerations
74   -- --------------------------------------------------------------------------
75   no_activity_details   exception;
76   --
77 BEGIN
78   -- Get the details for the given activity
79   OPEN csr_wf_activity_details;
80   FETCH csr_wf_activity_details INTO
81     p_name
82    ,p_display_name
83    ,p_description
84    ,p_instance_label;
85   IF csr_wf_activity_details%notfound THEN
86     -- if no rows are returned then raise an exception
87     CLOSE csr_wf_activity_details;
88     RAISE no_activity_details;
89   END IF;
90   CLOSE csr_wf_activity_details;
91 EXCEPTION
92   when no_activity_details then
93     fnd_message.set_name('PER','HR_51761_WEB_NO_ACTIVITY_DETS');
94     hr_utility.raise_error;
95   --
96 END get_activity_details;
97 -- ----------------------------------------------------------------------
98 -- |----------------< get_activity_instance_label >----------------------|
99 -- ----------------------------------------------------------------------
100 FUNCTION get_activity_instance_label
101     (p_actid      IN    wf_process_activities.instance_id%TYPE)
102     RETURN wf_process_activities.instance_label%type IS
103   --
104   -- --------------------------------------------------------------------------
105   -- declare local variables
106   -- --------------------------------------------------------------------------
107   -- Used for error messages
108   l_proc_name  VARCHAR2(200) :=  g_package||'get_activity_name';
109   -- Variables to store the activity details
110   l_display_name wf_activities_tl.display_name%TYPE;
111   l_description wf_activities_tl.description%TYPE;
112   l_name wf_activities_tl.name%TYPE;
113   l_instance_label wf_process_activities.instance_label%TYPE;
114 BEGIN
115   -- Get the activity details for the given activity
116   get_activity_details
117     (p_actid => p_actid
118     ,p_name => l_name
119     ,p_display_name => l_display_name
120     ,p_description  => l_description
121     ,p_instance_label   => l_instance_label);
122   -- Return the activities label name
123   RETURN l_instance_label;
124 END get_activity_instance_label;
125 -- ----------------------------------------------------------------
126 -- |-----------------< workflow_transition >-----------------------|
127 -- ----------------------------------------------------------------
128 PROCEDURE workflow_transition
129   (p_result     IN varchar2
130   ,p_item_type          IN wf_items.item_type%TYPE
131   ,p_item_key           IN wf_items.item_key%TYPE
132   ,p_actid              IN wf_process_activities.instance_id%TYPE) IS
133   --
134   -- --------------------------------------------------------------------------
135   -- declare local variables
136   -- --------------------------------------------------------------------------
137   -- Used for error messages
138   l_proc_name  VARCHAR2(200) :=  g_package||'workflow_transition';
139   -- Instance label of current activity
140   l_instance_label wf_process_activities.instance_label%type;
141 begin
142   -- Get the name of the activity
143   l_instance_label := get_activity_instance_label(p_actid);
144   --
145   -- Complete the activity
146   wf_engine.completeactivity
147    (itemtype => p_item_type
148    ,itemkey  => p_item_key
149    ,activity => l_instance_label
150    ,result   => p_result);
151 END workflow_transition;
152 -- ----------------------------------------------------------------------
153 -- |----------------< get_activity_name >------------------------|
154 -- ----------------------------------------------------------------------
155 FUNCTION get_activity_name
156     (p_actid      IN    wf_process_activities.instance_id%TYPE)
157     RETURN wf_activities_tl.name%type IS
158   --
159   -- --------------------------------------------------------------------------
160   -- declare local variables
161   -- --------------------------------------------------------------------------
162   -- Used for error messages
163   l_proc_name  VARCHAR2(200) :=  g_package||'get_activity_name';
164   -- Variables to store the activity details
165   l_display_name wf_activities_tl.display_name%TYPE;
166   l_description wf_activities_tl.description%TYPE;
167   l_name wf_activities_tl.name%TYPE;
168   l_instance_label wf_process_activities.instance_label%TYPE;
169 BEGIN
170   -- Get the activity details for the given activity
171   get_activity_details
172     (p_actid => p_actid
173     ,p_name => l_name
174     ,p_display_name => l_display_name
175     ,p_description  => l_description
176     ,p_instance_label   => l_instance_label);
177   -- Return the activities name
178   RETURN l_name;
179 END get_activity_name;
180 END hr_workflow_utility;