/*=======================================================================+
| Copyright (c) 2000 Oracle Corporation Redwood Shores, California, USA|
| All rights reserved. |
+=======================================================================+
| FILENAME
| wfehtmb.pls
| DESCRIPTION
| PL/SQL body for package: WF_EVENT_HTML
| NOTE
| There is a dependency on dynamic sql.
| Must have Oracle 8.1.5 or above.
| MODIFICATION LOG:
| 06 JUN 2001 JWSMITH BUG 1819232 ADA ENHANCEMENT
| - Added ALT attr for img tags
| - Added ID attr for TD tags
| - Added summary attr for table tag
| - Changed Simple Table to take tdattr
|
| Bug 1904844 12/03 CTILLEY - Passing the key for p_display_name
| and p_display_key='Y' to display_lov
| display_lov_find, and display_lov_details
| to resolve NLS issue
|
| 04 DEC 2001 JWSMITH BUG 1831892 - Changed the select statement
| in wf_agent_val to filter out WF_DEFERRED
|
| 02 JAN 2002 JWSMITH BUG 2001012 - Increased username, admin_role,
| l_name to varchar2(320), realname to 360
|
| 10.09.2002 varrajar Bug: 2558446. Implemented Customization Support
|
| 12-03-2002 kma Add NOCOPY hint to OUT or IN OUT parameter.
| 20-02-2003 kma Added code in EditSubscription procedure to
| display the list of values for customization level
| Bug 2756800
*=======================================================================*/
REM Added driver autogenrate instructions
REM dbdrv: sql ~PROD ~PATH ~FILE none none none package &phase=plb \
REM dbdrv: checkfile:~PROD:~PATH:~FILE
SET VERIFY OFF
WHENEVER SQLERROR EXIT FAILURE ROLLBACK;
WHENEVER OSERROR EXIT FAILURE ROLLBACK;
set arraysize 1
set scan off
create or replace package body WF_EVENT_HTML as
/* $Header: wfehtmb.pls 26.57 2005/03/11 06:31:33 anachatt ship $ */
--
-- isDeletable
-- Find out if a particular entity is deletable or not
-- IN
-- x_guid - global unique id for that entity
-- x_type - type of such entity 'EVENT|GROUP|SYSTEM|AGENT|SUBSCRIP'
-- RET
-- True if it is ok to delete.
-- False otherwise.
--
function isDeletable (
x_guid in raw,
x_type in varchar2
) return boolean
is
member_count pls_integer := 0;
begin
if (x_type = 'EVENT_S' or x_type = 'EVENT') then
-- If the Event is of a Custom Level of Core or Limit you cannot delete it
select count(1) into member_count
from WF_EVENTS
where GUID = x_guid
and CUSTOMIZATION_LEVEL in ('C','L');
-- do not bother to check further if the event is of type Core/Limit
if (member_count > 0) then
return(FALSE);
end if;
-- if there is any subscription, it has detail and is not deletable.
select count(1) into member_count
from WF_EVENT_SUBSCRIPTIONS
where EVENT_FILTER_GUID = x_guid;
-- do not bother to check further if there are subscriptions.
if (member_count > 0) then
return(FALSE);
end if;
elsif (x_type = 'SYSTEM_S' or x_type = 'SYSTEM') then
-- SYSTEM_S is for checking subscription only.
-- if there is any subscrption, it is not deletable.
select count(1) into member_count
from WF_EVENT_SUBSCRIPTIONS
where SYSTEM_GUID = x_guid;
-- SYSTEM_S also needs to check the new MASTER requirement
-- to see if it is a master of some body else
if (member_count = 0) then
select count(1) into member_count
from WF_SYSTEMS
where MASTER_GUID = x_guid;
end if;
if (member_count > 0) then
return(FALSE); -- do not bother to check further if there are members.
end if;
elsif (x_type = 'AGENT') then
select count(1) into member_count
from WF_EVENT_SUBSCRIPTIONS
where SOURCE_AGENT_GUID = x_guid
or OUT_AGENT_GUID = x_guid
or TO_AGENT_GUID = x_guid;
elsif (x_type = 'SUBSCRIPTION') then
-- there is no dependency at this moment
-- but later on, we may check the runtime table
select count(1) into member_count
from WF_EVENT_SUBSCRIPTIONS
where GUID = x_guid
and CUSTOMIZATION_LEVEL in ('C','L');
-- do not bother to check further if the event is of type Core/Limit
if (member_count > 0) then
return(FALSE);
end if;
return TRUE;
end if;
-- also check the following if type is SYSTEM
if (x_type = 'SYSTEM') then
-- if there is any agent reference, it is not deletable.
select count(1) into member_count
from WF_AGENTS
where SYSTEM_GUID = x_guid;
end if;
-- also check if it is the Local System
if (x_type = 'SYSTEM') then
-- Compare the GUID against the Local System GUID
if x_guid = wf_core.translate('WF_SYSTEM_GUID') then
return false;
end if;
end if;
-- Need to also check if the Event is part of an Event Group
if (x_type = 'EVENT') then
-- if it is part of a event group, it is not deletable
select count(1) into member_count
from wf_event_groups
where member_guid = x_guid;
end if;
if (member_count > 0) then
return FALSE;
end if;
return TRUE;
exception
when OTHERS then
wf_core.context('WF_EVENT_HTML', 'isDeletable', rawtohex(x_guid), x_type);
raise;
end isDeletable;
--
-- isAccessible
-- Determines if Screen is accessible
-- IN
-- x_type: SYSTEM, AGENTS, EVENTS, SUBSCRIPTIONS
-- NOTE
--
procedure isAccessible (
x_type in varchar2)
is
l_count number := 0;
begin
-- check there is a record in the system table
-- that matched the WF_SYSTEM_GUID
-- this is always checked
select count(*) into l_count
from wf_systems
where guid = wf_core.translate('WF_SYSTEM_GUID');
if l_count = 0 then
wf_core.raise('WFE_NO_SYSTEM');
end if;
-- SYSTEM: in case we think of any additional checks
if x_type = 'SYSTEM' then
null;
end if;
-- AGENTS: check if any exist for Local System
if x_type = 'AGENTS' then
select count(*) into l_count
from wf_agents
where system_guid = wf_core.translate('WF_SYSTEM_GUID');
end if;
-- EVENTS: check if any events
if x_type = 'EVENTS' then
select count(*) into l_count
from wf_events;
end if;
-- SUBSCRIPTIONS: check if any event subscriptions for LOCAL
if x_type = 'SUBSCRIPTIONS' then
select count(*) into l_count
from wf_event_subscriptions
where system_guid = wf_core.translate('WF_SYSTEM_GUID');
end if;
-- If the count is zero, we didn't find what we were looking for
if l_count = 0 then
wf_core.raise('WFE_NO_SEEDDATA_LOADED');
end if;
exception
when OTHERS then
wf_core.context('WF_EVENT_HTML', 'isAccessible', x_type);
raise;
end isAccessible;
-- ListEvents
-- List events
-- NOTE
--
procedure ListEvents (
h_display_name in varchar2 default null,
h_name in varchar2 default null,
h_status in varchar2 default '*',
h_type in varchar2 default '*',
resetcookie in varchar2 default 'F')
is
cursor evcurs(xn varchar2, xdn varchar2, xt varchar2, xs varchar2) is
select GUID, DISPLAY_NAME, NAME, TYPE, STATUS
from WF_EVENTS_VL
where (xt = '*' or TYPE = xt)
and (xdn is null or lower(DISPLAY_NAME) like '%'||lower(xdn)||'%')
and (xn is null or lower(NAME) like '%'||lower(xn)||'%')
and (xs = '*' or STATUS = xs)
order by NAME;
hTab wfe_html_util.headerTabType;
dTab wfe_html_util.dataTabType;
i pls_integer;
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
c pls_integer;
c2 pls_integer;
cookie owa_cookie.cookie;
l_name varchar2(240);
l_display_name varchar2(80);
l_type varchar2(8);
l_status varchar2(8);
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('EVENTS');
l_name := h_name;
l_display_name := h_display_name;
l_type := h_type;
l_status := h_status;
-- try to get the values from cookie if nothing is set
if (resetcookie='F' and l_name is null and l_display_name is null and
l_type = '*' and l_status = '*') then
cookie := owa_cookie.get('WF_EVENT_COOKIE');
-- ignore if more than one value was set
if (cookie.num_vals = 1) then
c := instr(cookie.vals(1), ':');
if (c <= 1) then
l_name := null;
else
l_name := substr(cookie.vals(1), 1, c-1);
end if;
c2:= instr(cookie.vals(1), ':', 1, 2);
if (c2-c <= 1) then
l_display_name := null;
else
l_display_name := substr(cookie.vals(1), c+1, c2-c-1);
end if;
c := c2;
c2:= instr(cookie.vals(1), ':', 1, 3);
if (c2-c <= 1) then
l_type := '*';
else
l_type := substr(cookie.vals(1), c+1, c2-c-1);
end if;
l_status := substr(cookie.vals(1), c2+1);
if (l_status = '') then
l_status := '*';
end if;
end if;
-- set cookie
else
owa_util.mime_header('text/html', FALSE);
owa_cookie.send('WF_EVENT_COOKIE',
l_name||':'||
l_display_name||':'||
l_type||':'||
l_status);
owa_util.http_header_close;
end if;
-- populate the data table
i := 0;
for event in evcurs(l_name, l_display_name, l_type, l_status) loop
i := i+1;
dTab(i).guid := event.guid;
dTab(i).col01:= event.name;
dTab(i).col02:= event.display_name;
dTab(i).col03:= wf_core.translate(event.type);
dTab(i).col04:= wf_core.translate(event.status);
dTab(i).selectable := FALSE;
dTab(i).hasdetail := not Wf_Event_Html.isDeletable(event.guid, 'EVENT_S');
-- when there is subscription, it is not deletable
if (dTab(i).hasdetail) then
dTab(i).deletable := FALSE;
-- otherwise, we need to check further
else
dTab(i).deletable := Wf_Event_Html.isDeletable(event.guid, 'EVENT');
end if;
end loop;
-- Render page
htp.htmlOpen;
-- Set page title
htp.headOpen;
-- list does not get updated after editevent, so we add the
-- following tag to force the reload of page.
htp.p('');
htp.title(wf_core.translate('WFE_LIST_EVENTS_TITLE'));
wfa_html.create_help_function('wf/links/def.htm?'||'DEFEVT');
fnd_document_management.get_open_dm_display_window;
Wfe_Html_Util.generate_confirm;
htp.headClose;
-- Page header
wfa_sec.Header(FALSE,
owa_util.get_owa_service_path||'wf_event_html.FindEvent',
wf_core.translate('WFE_LIST_EVENTS_TITLE'),
TRUE);
htp.br; -- add some space between header and table
-- populate the header table
i := 1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.DeleteEvent?h_guid=';
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.ListSubscriptions?use_guid_only=T&'||
'h_event_guid=';
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.EditEvent?h_guid=';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('SUBSCRIPTIONS');
hTab(i).attr := 'id="'||wf_core.translate('SUBSCRIPTIONS')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('EDIT');
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('NAME');
hTab(i).attr := 'id="'||wf_core.translate('NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('DISPLAY_NAME');
hTab(i).attr := 'id="'||wf_core.translate('DISPLAY_NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('TYPE');
hTab(i).attr := 'id="'||wf_core.translate('TYPE')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('STATUS');
hTab(i).attr := 'id="'||wf_core.translate('STATUS')||'"';
-- render table
Wfe_Html_Util.Simple_Table(hTab, dTab);
htp.tableopen (calign=>'CENTER ', cattributes=>'summary""');
htp.tableRowOpen;
htp.p('
');
htp.tableRowClose;
htp.tableClose;
wfa_sec.Footer;
htp.htmlClose;
exception
when OTHERS then
rollback;
wf_core.context('WF_EVENT_HTML', 'ListEvents');
wfe_html_util.Error;
end ListEvents;
--
-- ListSystems
-- List systems
-- NOTE
--
procedure ListSystems (
h_display_name in varchar2 default null,
h_name in varchar2 default null,
display_master in varchar2 default null,
h_master_guid in varchar2 default null,
resetcookie in varchar2 default 'F'
)
is
cursor syscurs(mguid raw, xn varchar2, xdn varchar2) is
select GUID, DISPLAY_NAME, NAME, MASTER_GUID
from WF_SYSTEMS
where (xdn is null or lower(DISPLAY_NAME) like '%'||lower(xdn)||'%')
and (xn is null or lower(NAME) like '%'||lower(xn)||'%')
and (mguid is null or MASTER_GUID = mguid)
order by NAME;
hTab wfe_html_util.headerTabType;
dTab wfe_html_util.dataTabType;
i pls_integer;
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
acnt number; -- counter for something
l_mguid raw(16); -- master guid
l_mname varchar2(80); -- master name
l_message varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFPREF_LOV'));
l_url varchar2(1000);
l_media varchar2(240) := wfa_html.image_loc;
l_icon varchar2(30) := 'FNDILOV.gif';
l_localsys raw(16);
c pls_integer;
c2 pls_integer;
cookie owa_cookie.cookie;
l_name varchar2(30);
l_display_name varchar2(80);
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('SYSTEM');
l_mguid := hextoraw(h_master_guid);
Wf_Event_Html.Validate_System_Name(display_master, l_mguid);
-- find the local system guid
begin
select hextoraw(TEXT)
into l_localsys
from WF_RESOURCES
where NAME = 'WF_SYSTEM_GUID'
and LANGUAGE = userenv('LANG');
exception
when NO_DATA_FOUND then
l_localsys := null;
end;
l_name := h_name;
l_display_name := h_display_name;
-- try to get the values from cookie if nothing is set
if (resetcookie='F' and l_mguid is null and l_name is null and
l_display_name is null) then
cookie := owa_cookie.get('WF_SYSTEM_COOKIE');
-- ignore if more than one value was set
if (cookie.num_vals = 1) then
c := instr(cookie.vals(1), ':');
if (c <= 1) then
l_mguid := hextoraw(null);
else
l_mguid := hextoraw(substr(cookie.vals(1), 1, c-1));
end if;
c2:= instr(cookie.vals(1), ':', 1, 2);
if (c2-c <= 1) then
l_name := null;
else
l_name := substr(cookie.vals(1), c+1, c2-c-1);
end if;
l_display_name := substr(cookie.vals(1), c2+1);
if (l_display_name = '') then
l_display_name := null;
end if;
end if;
-- set cookie
else
owa_util.mime_header('text/html', FALSE);
owa_cookie.send('WF_SYSTEM_COOKIE',
rawtohex(l_mguid)||':'||
l_name||':'||
l_display_name);
owa_util.http_header_close;
end if;
-- populate the data table
i := 0;
for asystem in syscurs(l_mguid, l_name, l_display_name) loop
i := i+1;
dTab(i).guid := asystem.guid;
dTab(i).col01:= asystem.name;
-- this is a local system
if (l_localsys = dTab(i).guid) then
dTab(i).col01 := dTab(i).col01||'*';
end if;
dTab(i).col02:= asystem.display_name;
-- find out the master display name
if (asystem.master_guid is not null) then
-- do the following select only if
-- l_mguid is null, that is a general query
-- or
-- l_mname is null, that query is being run the first time
--
if (l_mguid is null or l_mname is null) then
begin
select NAME
into l_mname
from WF_SYSTEMS
where GUID = asystem.master_guid;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(asystem.master_guid));
l_mname := wf_core.translate('WFE_SYSTEM_NOGUID');
end;
end if;
dTab(i).col03 := l_mname;
-- put a space there, if no master
else
dTab(i).col03 := ' ';
end if;
dTab(i).selectable := FALSE;
select count(1) into acnt
from WF_EVENT_SUBSCRIPTIONS
where SYSTEM_GUID = asystem.guid;
if (acnt = 0) then
dTab(i).deletable := Wf_Event_Html.isDeletable(asystem.guid, 'SYSTEM');
dTab(i).hasdetail := FALSE;
else
dTab(i).deletable := FALSE; -- has reference from subscriptions
dTab(i).hasdetail := TRUE;
end if;
end loop;
-- Render page
htp.htmlOpen;
-- Set page title
htp.headOpen;
-- list does not get updated after editevent, so we add the
-- following tag to force the reload of page.
htp.p('');
htp.title(wf_core.translate('WFE_LIST_SYSTEMS_TITLE'));
wfa_html.create_help_function('wf/links/def.htm?'||'DEFEVSYS');
fnd_document_management.get_open_dm_display_window;
Wfe_Html_Util.generate_confirm;
htp.headClose;
-- Page header
wfa_sec.Header(FALSE,
owa_util.get_owa_service_path||'wf_event_html.FindSystem',
wf_core.translate('WFE_LIST_SYSTEMS_TITLE'),
TRUE);
htp.br; -- add some space between header and table
-- popluate the header table
i := 1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.DeleteSystem?h_guid=';
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.ListSubscriptions?use_guid_only=T&h_system_guid=';
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.EditSystem?h_guid=';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('SUBSCRIPTIONS');
hTab(i).attr := 'id="'||wf_core.translate('SUBSCRIPTIONS')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('EDIT');
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('NAME');
hTab(i).attr := 'id="'||wf_core.translate('NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('DISPLAY_NAME');
hTab(i).attr := 'id="'||wf_core.translate('DISPLAY_NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('MASTER');
hTab(i).attr := 'id="'||wf_core.translate('MASTER')||'"';
-- render table
Wfe_Html_Util.Simple_Table(headerTab=>hTab, dataTab=>dTab,
tabattr=>'border=1 cellpadding=3 bgcolor=white width=100% summary="' ||
wf_core.translate('WFE_LIST_SYSTEMS_TITLE') || '"');
-- message to indicate local system
htp.tableopen(calign=>'CENTER', cattributes=>'WIDTH=100%
summary="' || wf_core.translate('WFE_INDICATE_LOCAL_SYS') || '"');
htp.tableRowOpen;
htp.p('
');
htp.tableRowClose;
htp.tableClose;
wfa_sec.Footer;
htp.htmlClose;
exception
when OTHERS then
rollback;
wf_core.context('WF_EVENT_HTML', 'ListSystems');
wfe_html_util.Error;
end ListSystems;
--
-- ListAgents
-- List agents
-- NOTE
--
procedure ListAgents (
h_name in varchar2 default null,
h_protocol in varchar2 default null,
h_address in varchar2 default null,
display_system in varchar2 default null,
h_system_guid in varchar2 default null,
h_direction in varchar2 default '*',
h_status in varchar2 default '*',
use_guid_only in varchar2 default 'F',
resetcookie in varchar2 default 'F'
)
is
cursor agcurs(sguid raw, xn varchar2, xp varchar2, xa varchar2,
xd varchar2, xs varchar2) is
select A.GUID, A.NAME, A.PROTOCOL, A.ADDRESS,
S.NAME SYSTEM_NAME,
A.DIRECTION, A.STATUS
from WF_AGENTS A, WF_SYSTEMS S
where (xn is null or lower(A.NAME) like '%'||lower(xn)||'%')
and (xp is null or A.PROTOCOL = xp)
and (xa is null or A.ADDRESS = xa)
and (sguid is null or S.GUID = sguid)
and A.SYSTEM_GUID = S.GUID
and (xd = '*' or A.DIRECTION = xd)
and (xs = '*' or A.STATUS = xs)
order by SYSTEM_NAME, A.NAME, A.ADDRESS, A.PROTOCOL;
hTab wfe_html_util.headerTabType;
dTab wfe_html_util.dataTabType;
i pls_integer;
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
l_sguid raw(16); -- system guid
l_sname varchar2(80); -- system name
prev_sname varchar2(80); -- previous system name
c pls_integer;
c2 pls_integer;
cookie owa_cookie.cookie;
l_name varchar2(30);
l_protocol varchar2(30);
l_address varchar2(240);
l_direction varchar2(8);
l_status varchar2(8);
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('AGENTS');
l_sguid := hextoraw(h_system_guid);
if (use_guid_only = 'F') then
Wf_Event_Html.Validate_System_Name(display_system, l_sguid);
end if;
l_name := h_name;
l_protocol := h_protocol;
l_address := h_address;
l_direction:= h_direction;
l_status := h_status;
-- try to get the values from cookie if nothing is set
if (resetcookie='F' and l_sguid is null and l_name is null and
l_protocol is null and l_direction = '*' and l_status = '*') then
cookie := owa_cookie.get('WF_AGENT_COOKIE');
-- ignore if more than one value was set
if (cookie.num_vals = 1) then
c := instr(cookie.vals(1), ':');
if (c <= 1) then
l_sguid := hextoraw(null);
else
l_sguid := hextoraw(substr(cookie.vals(1), 1, c-1));
end if;
c2:= instr(cookie.vals(1), ':', 1, 2);
if (c2-c <= 1) then
l_name := null;
else
l_name := substr(cookie.vals(1), c+1, c2-c-1);
end if;
c := c2;
c2:= instr(cookie.vals(1), ':', 1, 3);
if (c2-c <= 1) then
l_protocol := null;
else
l_protocol := substr(cookie.vals(1), c+1, c2-c-1);
end if;
c := c2;
c2:= instr(cookie.vals(1), ':', 1, 4);
if (c2-c <= 1) then
l_address := null;
else
l_address := substr(cookie.vals(1), c+1, c2-c-1);
end if;
c := c2;
c2:= instr(cookie.vals(1), ':', 1, 5);
if (c2-c <= 1) then
l_direction := '*';
else
l_direction := substr(cookie.vals(1), c+1, c2-c-1);
end if;
l_status := substr(cookie.vals(1), c2+1);
if (l_status = '') then
l_status := '*';
end if;
end if;
-- set cookie
else
owa_util.mime_header('text/html', FALSE);
owa_cookie.send('WF_AGENT_COOKIE',
rawtohex(l_sguid)||':'||
l_name||':'||
l_protocol||':'||
l_address||':'||
l_direction||':'||
l_status);
owa_util.http_header_close;
end if;
-- populate the data table
prev_sname := null;
i := 0;
for agent in agcurs(l_sguid,l_name,l_protocol,l_address,
l_direction,l_status) loop
if (prev_sname is null or prev_sname <> agent.system_name) then
-- add a blank row
if (prev_sname is not null) then
i := i+1;
dTab(i).guid := agent.guid;
dTab(i).level := 1;
dTab(i).trattr := 'VALIGN=TOP bgcolor=#CCCCCC';
dTab(i).col01 := ' ';
end if;
i := i+1;
dTab(i).guid := agent.guid;
dTab(i).level := 1;
dTab(i).trattr := 'VALIGN=TOP bgcolor=#CCCCCC';
dTab(i).col01 := ''||wf_core.translate('SYSTEM')||': '||
agent.system_name||'';
dTab(i).tdattr := 'id="' || WF_CORE.Translate('SYSTEM') || '"';
prev_sname := agent.system_name;
-- print title here
i := i+1;
dTab(i).guid := agent.guid;
dTab(i).level:= 0;
dTab(i).showtitle := TRUE;
end if;
i := i+1;
dTab(i).guid := agent.guid;
dTab(i).level := 0;
dTab(i).trattr := 'VALIGN=TOP bgcolor=white';
dTab(i).col01:= agent.name;
if (agent.address is null) then
dTab(i).col02:= ' ';
else
dTab(i).col02:= agent.address;
end if;
dTab(i).col03:= agent.protocol;
dTab(i).col04:= wf_core.translate(agent.direction);
dTab(i).col05:= wf_core.translate(agent.status);
dTab(i).selectable := FALSE;
dTab(i).deletable := Wf_Event_Html.isDeletable(agent.guid, 'AGENT');
dTab(i).hasdetail := FALSE;
end loop;
-- Render page
htp.htmlOpen;
-- Set page title
htp.headOpen;
-- list does not get updated after editevent, so we add the
-- following tag to force the reload of page.
htp.p('');
htp.title(wf_core.translate('WFE_LIST_AGENTS_TITLE'));
wfa_html.create_help_function('wf/links/def.htm?'||'DEFEVAGT');
fnd_document_management.get_open_dm_display_window;
Wfe_Html_Util.generate_confirm;
htp.headClose;
-- Page header
wfa_sec.Header(FALSE,
owa_util.get_owa_service_path||'wf_event_html.FindAgent',
wf_core.translate('WFE_LIST_AGENTS_TITLE'),
TRUE);
htp.br; -- add some space between header and table
-- popluate the header table
i := 1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.DeleteAgent?h_guid=';
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := null; -- never has detail page
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.EditAgent?h_guid=';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := null; -- no detail title
hTab(i).level := 0;
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('EDIT');
hTab(i).level := 0;
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('SYSTEM');
hTab(i).level := 1;
hTab(i).span := 5;
hTab(i).trattr := 'bgcolor=#006699';
hTab(i).attr := 'bgcolor=#CCCCCC';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('NAME');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('ADDRESS');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('ADDRESS')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('PROTOCOL');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('PROTOCOL')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('DIRECTION');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('DIRECTION')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('STATUS');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('STATUS')||'"';
-- render table
-- for an empty table, show only the level 0 title
if (dTab.COUNT = 0) then
Wfe_Html_Util.Simple_Table(headerTab=>hTab, dataTab=>dTab,
tabattr=>'border=0 cellpadding=3 cellspacing=2 bgcolor=#CCCCCC
width=100%
summary="' || wf_core.translate('WFE_LIST_AGENTS_TITLE') || '"',
show_1st_title=>TRUE, show_level=>0);
-- show the full table
else
Wfe_Html_Util.Simple_Table(headerTab=>hTab, dataTab=>dTab,
tabattr=>'border=0 cellpadding=3 cellspacing=2 bgcolor=#CCCCCC
width=100%
summary="' || wf_core.translate('WFE_LIST_AGENTS_TITLE') || '"',
show_1st_title=>FALSE);
end if;
htp.tableopen (calign=>'CENTER', cattributes=>'summary=""');
htp.tableRowOpen;
htp.p('
');
htp.tableRowClose;
htp.tableClose;
wfa_sec.Footer;
htp.htmlClose;
exception
when OTHERS then
rollback;
wf_core.context('WF_EVENT_HTML', 'ListAgents');
wfe_html_util.Error;
end ListAgents;
--
-- ListSubscriptions
-- List subscriptions
-- NOTE
--
procedure ListSubscriptions (
display_event in varchar2 default null,
h_event_guid in varchar2 default null,
h_source_type in varchar2 default '*',
display_system in varchar2 default null,
h_system_guid in varchar2 default null,
h_status in varchar2 default '*',
use_guid_only in varchar2 default 'F',
resetcookie in varchar2 default 'F'
)
is
cursor sscurs(eguid raw, sguid raw, xt varchar2, xs varchar2) is
select ES.GUID,
ES.SYSTEM_GUID, ES.SOURCE_TYPE, ES.EVENT_FILTER_GUID,
ES.STATUS,
ES.OUT_AGENT_GUID, ES.TO_AGENT_GUID,
ES.RULE_FUNCTION, ES.WF_PROCESS_TYPE, ES.WF_PROCESS_NAME,
SY.NAME SYSTEM_NAME, E.NAME EVENT_NAME
from WF_EVENT_SUBSCRIPTIONS ES, WF_EVENTS E, WF_SYSTEMS SY
where (eguid is null or ES.EVENT_FILTER_GUID = eguid)
and (xt = '*' or ES.SOURCE_TYPE = xt)
and (sguid is null or ES.SYSTEM_GUID = sguid)
and (xs = '*' or ES.STATUS = xs)
and E.GUID (+)= ES.EVENT_FILTER_GUID
and SY.GUID (+)= ES.SYSTEM_GUID
order by SYSTEM_NAME, EVENT_NAME, ES.PHASE;
hTab wfe_html_util.headerTabType;
dTab wfe_html_util.dataTabType;
cTab wfe_html_util.tmpTabType; -- temporary column table
i pls_integer;
j pls_integer;
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
l_eguid raw(16); -- event guid
l_ename varchar2(240); -- event name
l_sguid raw(16); -- system guid
l_sname varchar2(80); -- system name
l_name varchar2(240); -- internal name for event/system
from_system boolean := FALSE;
from_event boolean := FALSE;
l_url varchar2(3200);
prev_sguid raw(16); -- previous system guid
prev_eguid raw(16); -- previous event guid
c pls_integer;
c2 pls_integer;
cookie owa_cookie.cookie;
l_source_type varchar2(8);
l_status varchar2(8);
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('SUBSCRIPTIONS');
l_eguid := hextoraw(h_event_guid);
l_sguid := hextoraw(h_system_guid);
if (use_guid_only = 'F') then
Wf_Event_Html.Validate_Event_Name(display_event, l_eguid);
Wf_Event_Html.Validate_System_Name(display_system, l_sguid);
end if;
l_source_type := h_source_type;
l_status := h_status;
-- try to get the values from cookie if nothing is set
if (resetcookie='F' and l_eguid is null and l_sguid is null and
l_source_type = '*' and l_status = '*') then
cookie := owa_cookie.get('WF_SUBSCRIPTION_COOKIE');
-- ignore if more than one value was set
if (cookie.num_vals = 1) then
c := instr(cookie.vals(1), ':');
if (c <= 1) then
l_eguid := hextoraw(null);
else
l_eguid := hextoraw(substr(cookie.vals(1), 1, c-1));
end if;
c2:= instr(cookie.vals(1), ':', 1, 2);
if (c2-c <= 1) then
l_sguid := hextoraw(null);
else
l_sguid := hextoraw(substr(cookie.vals(1), c+1, c2-c-1));
end if;
c := c2;
c2:= instr(cookie.vals(1), ':', 1, 3);
if (c2-c <= 1) then
l_source_type := '*';
else
l_source_type := substr(cookie.vals(1), c+1, c2-c-1);
end if;
l_status := substr(cookie.vals(1), c2+1);
if (l_status = '') then
l_status := '*';
end if;
end if;
-- set cookie to event and system guid
else
owa_util.mime_header('text/html', FALSE);
owa_cookie.send('WF_SUBSCRIPTION_COOKIE',
rawtohex(l_eguid)||':'||
rawtohex(l_sguid)||':'||
l_source_type||':'||
l_status);
owa_util.http_header_close;
end if;
-- determine if this is from system or from event
if (l_sguid is not null) then
-- from system
begin
select NAME
into l_name
from WF_SYSTEMS
where GUID = l_sguid;
exception
when OTHERS then
l_name := null;
end;
from_system := TRUE;
end if;
if (l_eguid is not null) then
-- from event
begin
select NAME
into l_name
from WF_EVENTS
where GUID = l_eguid;
exception
when OTHERS then
l_name := null;
end;
from_event := TRUE;
end if;
-- populate the data table
prev_sguid := null;
prev_eguid := null;
i := 0;
for ssr in sscurs(l_eguid, l_sguid, l_source_type, l_status) loop
if (prev_sguid is null or prev_sguid <> ssr.system_guid) then
-- add a blank row
if (prev_sguid is not null and prev_eguid is not null) then
i := i+1;
dTab(i).guid := ssr.guid;
dTab(i).level := 2;
dTab(i).trattr := 'VALIGN=TOP bgcolor=#CCCCCC';
dTab(i).col01 := ' ';
end if;
-- System Name (level 2)
i := i+1;
dTab(i).guid := ssr.guid;
dTab(i).level := 2;
dTab(i).trattr := 'VALIGN=TOP bgcolor=#CCCCCC';
-- put a space there if no system is defined
if (ssr.system_guid is null) then
dTab(i).col01 := ''||wf_core.translate('SYSTEM')||':  ';
-- find the system name
else
if (ssr.system_name is null) then
wf_core.token('GUID', rawtohex(ssr.system_guid));
dTab(i).col01 := wf_core.translate('WFE_SYSTEM_NOGUID');
else
dTab(i).col01 := ''||wf_core.translate('SYSTEM')||':'||
ssr.system_name||'';
end if;
prev_sguid := ssr.system_guid;
end if;
prev_eguid := null; -- reset this with a new system
end if;
if (prev_eguid is null or prev_eguid <> ssr.event_filter_guid) then
-- add a blank row
if (prev_eguid is not null) then
i := i+1;
dTab(i).guid := ssr.guid;
dTab(i).level := 1;
dTab(i).trattr := 'VALIGN=TOP bgcolor=#CCCCCC';
dTab(i).col01 := ''; -- indentation
dTab(i).col02 := ' ';
end if;
-- Event Name (level 1)
i := i+1;
dTab(i).guid := ssr.guid;
dTab(i).level := 1;
-- indentation
dTab(i).col01 := '';
-- put a space there if no event filter is defined
if (ssr.event_filter_guid is null) then
dTab(i).col02 := ''||wf_core.translate('EVENT')||':  ';
-- find the event name
else
if (ssr.event_name is null) then
wf_core.token('GUID', rawtohex(ssr.event_filter_guid));
dTab(i).col02 := wf_core.translate('WFE_EVENT_NOGUID');
else
dTab(i).col02 := ''||wf_core.translate('EVENT')||': '||
ssr.event_name||'';
end if;
prev_eguid := ssr.event_filter_guid;
end if;
-- print title here
i := i+1;
dTab(i).guid := ssr.guid;
dTab(i).level:= 0;
dTab(i).showtitle := TRUE;
end if;
i := i+1;
dTab(i).guid := ssr.guid;
dTab(i).level := 0;
dTab(i).trattr := 'VALIGN=TOP bgcolor=white';
-- indentation
dTab(i).col01 := '';
-- source type
if (ssr.source_type is null) then
dTab(i).col02 := ' ';
else
dTab(i).col02 := wf_core.translate(ssr.source_type);
end if;
-- put a space there if no "out agent" is defined
if (ssr.out_agent_guid is null) then
dTab(i).col03 := ' ';
-- find the agent name
else
-- find the system name
begin
select S.NAME
into dTab(i).col03
from WF_AGENTS A, WF_SYSTEMS S
where A.GUID = ssr.out_agent_guid
and A.SYSTEM_GUID = S.GUID;
exception
when OTHERS then
dTab(i).col03 := null;
end;
begin
if (dTab(i).col03 is null) then
select NAME
into dTab(i).col03
from WF_AGENTS
where GUID = ssr.out_agent_guid;
else
select A.NAME||'@'||dTab(i).col03
into dTab(i).col03
from WF_AGENTS A
where A.GUID = ssr.out_agent_guid;
end if;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(ssr.out_agent_guid));
dTab(i).col03 := wf_core.translate('WFE_AGENT_NOGUID');
end;
end if;
-- put a space there if no "to agent" is defined
if (ssr.to_agent_guid is null) then
dTab(i).col04 := ' ';
-- find the agent name
else
-- find the system name
begin
select S.NAME
into dTab(i).col04
from WF_AGENTS A, WF_SYSTEMS S
where A.GUID = ssr.to_agent_guid
and A.SYSTEM_GUID = S.GUID;
exception
when OTHERS then
dTab(i).col04 := null;
end;
begin
if (dTab(i).col04 is null) then
select A.NAME
into dTab(i).col04
from WF_AGENTS A
where A.GUID = ssr.to_agent_guid;
else
select A.NAME||'@'||dTab(i).col04
into dTab(i).col04
from WF_AGENTS A
where A.GUID = ssr.to_agent_guid;
end if;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(ssr.to_agent_guid));
dTab(i).col04 := wf_core.translate('WFE_AGENT_NOGUID');
end;
end if;
-- function
if (ssr.rule_function is not null) then
dTab(i).col05 := ssr.rule_function;
else
dTab(i).col05 := ' ';
end if;
-- Workflow process
if (ssr.wf_process_type is null and ssr.wf_process_name is null) then
dTab(i).col06 := ' ';
else
dTab(i).col06 := ssr.wf_process_type||'/'||ssr.wf_process_name;
end if;
dTab(i).col07 := wf_core.translate(ssr.status);
dTab(i).selectable := FALSE;
-- dTab(i).deletable := TRUE;
dTab(i).deletable := Wf_Event_Html.isDeletable(ssr.guid, 'SUBSCRIPTION');
dTab(i).hasdetail := FALSE;
end loop;
-- Render page
htp.htmlOpen;
-- Set page title
htp.headOpen;
-- list does not get updated after editevent, so we add the
-- following tag to force the reload of page.
htp.p('');
htp.title(wf_core.translate('WFE_LIST_SUBSC_TITLE'));
wfa_html.create_help_function('wf/links/def.htm?'||'DEFEVSUB');
fnd_document_management.get_open_dm_display_window;
Wfe_Html_Util.generate_confirm;
htp.headClose;
-- Page header
wfa_sec.Header(FALSE,
owa_util.get_owa_service_path||'wf_event_html.FindSubscription',
wf_core.translate('WFE_LIST_SUBSC_TITLE'),
TRUE);
htp.br; -- add some space between header and table
-- popluate the header table
i := 1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.DeleteSubscription?h_guid=';
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := null; -- never has detail page
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.EditSubscription?h_guid=';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := null; -- no detail title
hTab(i).level := 0;
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('EDIT');
hTab(i).level := 0;
-- if (not from_system) then
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('SYSTEM');
hTab(i).level := 2;
hTab(i).span := 7;
hTab(i).trattr := 'bgcolor=#006699';
hTab(i).attr := 'bgcolor=#CCCCCC';
-- end if;
-- if (not from_event) then
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := null; -- indentation
hTab(i).level := 1;
hTab(i).span := 1;
hTab(i).trattr := 'bgcolor=#006699';
hTab(i).attr := 'bgcolor=#CCCCCC';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('EVENT');
hTab(i).level := 1;
hTab(i).span := 6;
hTab(i).attr := 'id="'||wf_core.translate('EVENT')||'"';
-- end if;
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := null; -- indentation
hTab(i).level := 0;
hTab(i).trattr := 'bgcolor=#006699';
hTab(i).attr := 'bgcolor=#CCCCCC';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('SOURCE_TYPE');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('SOURCE_TYPE')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('OUT_AGENT');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('OUT_AGENT')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('TO_AGENT');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('TO_AGENT')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('FUNCTION');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('FUNCTION')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('WORKFLOW');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('WORKFLOW')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('STATUS');
hTab(i).level := 0;
hTab(i).attr := 'id="'||wf_core.translate('STATUS')||'"';
-- render table
if (dTab.COUNT = 0) then
Wfe_Html_Util.Simple_Table(headerTab=>hTab, dataTab=>dTab,
tabattr=>'border=0 cellpadding=3 cellspacing=2 bgcolor=#CCCCCC
width=100% summary="' ||
wf_core.translate('WFE_LIST_SUBSC_TITLE') || '"',
show_1st_title=>TRUE, show_level=>0);
-- show the full table
else
Wfe_Html_Util.Simple_Table(headerTab=>hTab, dataTab=>dTab,
tabattr=>'border=0 cellpadding=3 cellspacing=2 bgcolor=#CCCCCC
width=100% summary="' ||
wf_core.translate('WFE_LIST_SUBSC_TITLE') || '"',
show_1st_title=>FALSE);
end if;
htp.tableopen (calign=>'CENTER', cattributes=>'summary=""');
htp.tableRowOpen;
htp.p('
');
-- construct the url for add subscription
l_url := wfa_html.base_url||'/Wf_Event_Html.EditSubscription';
if (from_system) then
l_url := l_url||'?h_sguid='||rawtohex(l_sguid);
if (from_event) then
l_url := l_url||'&h_eguid='||rawtohex(l_eguid); -- both system & event
end if;
elsif (from_event) then
l_url := l_url||'?h_eguid='||rawtohex(l_eguid);
end if;
wfa_html.create_reg_button (l_url,
wf_core.translate('WFE_ADD_SUBSCRIPTION'),
wfa_html.image_loc,
null,
wf_core.translate('WFE_ADD_SUBSCRIPTION'));
htp.p('
');
htp.tableRowClose;
htp.tableClose;
wfa_sec.Footer;
htp.htmlClose;
exception
when OTHERS then
rollback;
wf_core.context('WF_EVENT_HTML', 'ListSubscriptions');
wfe_html_util.Error;
end ListSubscriptions;
--
-- EditEvent
-- Create/Update an event
-- IN
-- h_guid - Global unique id for an event
-- NOTE
--
procedure EditEvent(
h_guid in raw default null,
h_type in varchar2 default 'EVENT'
)
is
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
template varchar2(4000); -- Use for construct form select list
l_name varchar2(240);
l_type varchar2(8);
l_status varchar2(8);
l_gfunc varchar2(240);
l_ownname varchar2(30);
l_owntag varchar2(30);
l_dname varchar2(80);
l_desc varchar2(2000);
l_customization_level varchar2(1);
select_enable varchar2(8);
select_disable varchar2(8);
select_event varchar2(8) := 'SELECTED';
select_group varchar2(8);
select_custom_core varchar2(8);
select_custom_limit varchar2(8);
select_custom_extend varchar2(8);
select_custom_user varchar2(8);
eventcount pls_integer;
edittype boolean := TRUE;
-- deletable event cursor
-- all events belong to the group
cursor devcurs is
select E.GUID, E.DISPLAY_NAME, E.NAME, E.STATUS
from WF_EVENTS_VL E, WF_EVENT_GROUPS EG
where EG.GROUP_GUID = h_guid
and E.GUID = EG.MEMBER_GUID;
hTab wfe_html_util.headerTabType;
dTab wfe_html_util.dataTabType;
i pls_integer;
aligntext varchar2(240);
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('EVENTS');
-- populate the appropriate values in the form if editing an exist guid
if (h_guid is not null) then
begin
select NAME, DISPLAY_NAME, DESCRIPTION, TYPE, STATUS,
GENERATE_FUNCTION, OWNER_NAME, OWNER_TAG, NVL(CUSTOMIZATION_LEVEL, 'L')
into l_name, l_dname, l_desc, l_type, l_status,
l_gfunc, l_ownname, l_owntag, l_customization_level
from WF_EVENTS_VL
where GUID = h_guid;
-- take care of the double quote problem
-- There should be no any kind of quote for name and generate_function.
-- Description is handle entirely differently, no need for substitution.
-- Single quote is ok becuase html does not treat it special.
l_dname := replace(l_dname, '"', '\"');
l_ownname := replace(l_ownname, '"', '\"');
l_owntag := replace(l_owntag, '"', '\"');
if (l_status = 'ENABLED') then
select_enable := 'SELECTED';
select_disable := null;
else
select_enable := null;
select_disable := 'SELECTED';
end if;
-- Stuff for Customization Level
if l_customization_level = 'C' then
select_custom_core := 'SELECTED';
select_custom_limit := null;
select_custom_extend := null;
select_custom_user := null;
elsif l_customization_level = 'L' then
select_custom_core := null;
select_custom_limit := 'SELECTED';
select_custom_extend := null;
select_custom_user := null;
elsif l_customization_level = 'U' then
select_custom_core := null;
select_custom_limit := null;
select_custom_extend := null;
select_custom_user := 'SELECTED';
end if;
if (l_type = 'GROUP') then
select_group := 'SELECTED';
select_event := null;
-- check if we can change a group type to an event type
-- allow this only when a group does not has any child event.
select count(1) into eventcount
from WF_EVENT_GROUPS
where GROUP_GUID = h_guid;
if (eventcount > 0) then
edittype := FALSE;
end if;
end if;
exception
when NO_DATA_FOUND then
wf_core.raise('WFE_EVENT_NOTEXIST');
end;
else
if (h_type <> 'EVENT') then
l_type := 'GROUP';
else
l_type := 'EVENT';
end if;
l_customization_level := 'U';
end if;
-- Set page title
htp.htmlOpen;
htp.headOpen;
-- list does not get updated after editevent, so we add the
-- following tag to force the reload of page.
htp.p('');
htp.title(wf_core.translate('WFE_EDIT_'||l_type||'_TITLE'));
if (l_type <> 'EVENT') then
wfa_html.create_help_function('wf/links/t_d.htm?T_DEFEVGPM');
else
wfa_html.create_help_function('wf/links/t_d.htm?T_DEFEVT');
end if;
fnd_document_management.get_open_dm_display_window;
Wfe_Html_Util.generate_check_all;
htp.headClose;
-- Page header
wfa_sec.Header(FALSE,
owa_util.get_owa_service_path||'wf_event_html.FindEvent',
wf_core.translate('WFE_EDIT_'||l_type||'_TITLE'),
TRUE);
-- Form
htp.formOpen(curl=>owa_util.get_owa_service_path||
'wf_event_html.SubmitEvent',
cmethod=>'Get',
cattributes=>'TARGET="_top" NAME="WF_EVENT_EDIT"');
-- GUID
-- do not display it if it is null
if (h_guid is not null) then
htp.p('');
end if;
htp.formHidden('h_guid', rawtohex(h_guid));
htp.tableOpen(calign=>'CENTER', cattributes=>'border=0 summary=""');
-- Name
htp.tableRowOpen;
htp.tableData(cvalue=>'', calign=>'Right',
cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_name', csize=>40,
cmaxlength=>240,
cvalue=>l_name,
cattributes=>'id="i_name"'),
calign=>'Left',
cattributes=>'id=""');
htp.tableRowClose;
-- Display Name
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right', cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_display_name', csize=>60,
cmaxlength=>80,
cattributes=>'id="i_display_name"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Description
htp.tableRowOpen;
htp.tableData(cvalue=>'', calign=>'Right',
cattributes=>'id=""');
htp.tableData(cvalue=>htf.formTextareaOpen2(
cname=>'h_description',
nrows=>2,
ncolumns=>60,
cwrap=>'SOFT',
cattributes=>'maxlength=2000 id="i_description"')
||l_desc
||htf.formTextareaClose,
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Type
template := wf_core.translate(l_type);
htp.formHidden('h_type', l_type);
-- Status
template := htf.formSelectOpen('h_status',cattributes=>'id="i_status"')
||wf_core.newline||
htf.formSelectOption(wf_core.translate('ENABLED'),
select_enable,'VALUE="ENABLED"')
||wf_core.newline||
htf.formSelectOption(wf_core.translate('DISABLED'),
select_disable,'VALUE="DISABLED"')
||wf_core.newline||
htf.formSelectClose;
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>template, calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Generate Function
-- no generate function for group
if (l_type <> 'GROUP') then
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_generate_function', csize=>60,
cmaxlength=>240, cvalue=>l_gfunc,
cattributes=>'id="i_generate_function"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
else
htp.formHidden('h_generate_function', null);
end if;
-- Owner Name
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_owner_name', csize=>30,
cmaxlength=>30,
cattributes=>'id="i_owner_name"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Owner Tag
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_owner_tag', csize=>30,
cmaxlength=>30,
cattributes=>'id="i_owner_tag"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Customization Level
if wf_events_pkg.g_Mode = 'FORCE' then
template := htf.formSelectOpen('h_custom_level',cattributes=>'id="i_custom_level"')
||wf_core.newline||
htf.formSelectOption(wf_core.translate('WFE_CUSTOM_LEVEL_C'),
select_custom_core,'VALUE="C"')
||wf_core.newline||
htf.formSelectOption(wf_core.translate('WFE_CUSTOM_LEVEL_L'),
select_custom_limit,'VALUE="L"')
||wf_core.newline||
htf.formSelectOption(wf_core.translate('WFE_CUSTOM_LEVEL_U'),
select_custom_user,'VALUE="U"')
||wf_core.newline||
htf.formSelectClose;
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>template, calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
else
htp.tableRowOpen;
htp.tableData(cvalue=>wf_core.translate('WFE_CUSTOM_LEVEL'),
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>wf_core.translate('WFE_CUSTOM_LEVEL_'||l_customization_level), calign=>'Left',cattributes=>'id=""');
htp.formHidden('h_custom_level', l_customization_level);
end if;
-- URL to go back to
if (h_guid is null and l_type = 'GROUP') then
htp.formHidden('url', ''); -- signal the coming back to this screen
else
htp.formHidden('url', 'Wf_Event_Html.ListEvents');
end if;
htp.tableClose;
htp.formClose;
-- add values that may contain double quote back through javascript
if (h_guid is not null) then
htp.p('');
end if;
-- if is group, display events for deletion
if (h_guid is not null and l_type = 'GROUP') then
i := 0;
for event in devcurs loop
i := i+1;
dTab(i).guid := event.guid;
dTab(i).col01:= '';
dTab(i).col02:= event.display_name;
dTab(i).col03:= event.status;
dTab(i).selectable := TRUE;
dTab(i).deletable := FALSE; -- do not allow deletion
-- it is deletable when there is no subscription; that is,
-- there is no detail.
dTab(i).hasdetail := not Wf_Event_Html.isDeletable(event.guid, 'EVENT');
end loop;
htp.p(wf_core.translate('WFE_EVENTS_IN_GROUP'));
-- Submit Form for Add/Delete
htp.formOpen(curl=>owa_util.get_owa_service_path||
'Wf_Event_Html.SubmitSelectedGEvents',
cmethod=>'Post',
cattributes=>'TARGET="_top" NAME="WF_GROUP_EDIT"');
htp.formHidden('h_gguid', rawtohex(h_guid));
-- Hide the fields for which option you selected. ADD or DELETE
htp.formHidden(cname=>'action', cvalue=>'');
-- Url to come back to later
htp.formHidden(cname=>'url',
cvalue=>'Wf_Event_Html.EditEvent?h_guid='||rawtohex(h_guid));
-- Add dummy fields to start both array-type input fields.
-- These dummy values are needed so that the array parameters to
-- the submit procedure will not be null even if there are no real
-- response fields. This would cause a pl/sql error, because array
-- parameters can't be defaulted.
htp.formHidden('h_guids', '-1');
-- popluate the header table
i := 1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := null; -- delete is not allowed here
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.ListSubscriptions?use_guid_only=T&'||
'h_event_guid=';
i := i+1;
hTab(i).def_type := 'FUNCTION';
hTab(i).value := 'Wf_Event_Html.EditEvent?h_guid=';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('SUBSCRIPTIONS');
hTab(i).attr := 'id="'||wf_core.translate('SUBSCRIPTIONS')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('EDIT');
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('NAME');
hTab(i).attr := 'id="'||wf_core.translate('NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('DISPLAY_NAME');
hTab(i).attr := 'id="'||wf_core.translate('DISPLAY_NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('STATUS');
hTab(i).attr := 'id="'||wf_core.translate('STATUS')||'"';
-- render table
Wfe_Html_Util.Simple_Table(hTab, dTab);
htp.formClose;
htp.tableOpen(cattributes=>'WIDTH=100%
summary="' || wf_core.translate('WFE_EVENTS_IN_GROUP') || '"');
htp.tableRowOpen;
htp.p('
');
htp.tableOpen (calign=>'RIGHT', cattributes=>'summary=""');
htp.tableRowOpen;
-- If table is not empty, we allow check/uncheck all/delete.
if (dTab.COUNT > 0) then
htp.p('
');
htp.tableRowClose;
htp.tableClose;
end if;
wfa_sec.Footer;
htp.htmlClose;
exception
when others then
rollback;
wf_core.context('WF_EVENT_HTML', 'EditEvent', h_guid);
wfe_html_util.Error;
end EditEvent;
--
-- EditGroup
-- Delete/Add events from/to group
-- IN
-- h_guid - Global unique id for an event
-- h_func - DELETE|ADD
-- NOTE
--
procedure EditGroup(
h_guid in raw,
h_func in varchar2 default 'DELETE',
h_display_name in varchar2 default null,
h_name in varchar2 default null,
h_status in varchar2 default '*',
h_type in varchar2 default '*'
)
is
-- addable event cursor
-- all events meet the query criteria excluding the group itself
cursor aevcurs is
select GUID, DISPLAY_NAME, NAME, TYPE, STATUS
from WF_EVENTS_VL
where (h_type = '*' or TYPE = h_type)
and (h_display_name is null or lower(DISPLAY_NAME) like
'%'||lower(h_display_name)||'%')
and (h_name is null or lower(NAME) like '%'||lower(h_name)||'%')
and (h_status = '*' or STATUS = h_status)
and GUID <> h_guid
order by NAME;
-- deletable event cursor
-- all events belong to the group
cursor devcurs is
select E.GUID, E.DISPLAY_NAME, E.NAME, E.STATUS
from WF_EVENTS_VL E, WF_EVENT_GROUPS EG
where EG.GROUP_GUID = h_guid
and E.GUID = EG.MEMBER_GUID;
hTab wfe_html_util.headerTabType;
dTab wfe_html_util.dataTabType;
i pls_integer;
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
l_name varchar2(240);
l_dname varchar2(80);
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('EVENTS');
-- Render page
htp.htmlOpen;
-- Set page title
htp.headOpen;
-- list does not get updated after edit, so we add the
-- following tag to force the reload of page.
htp.p('');
htp.title(wf_core.translate('WFE_EDIT_GROUP_TITLE'));
wfa_html.create_help_function('wf/links/t_d.htm?T_DEFEVGPM');
fnd_document_management.get_open_dm_display_window;
Wfe_Html_Util.generate_check_all;
htp.headClose;
-- Page header
wfa_sec.Header(FALSE, null,
wf_core.translate('WFE_EDIT_GROUP_TITLE'),
TRUE);
-- Group to edit
begin
select NAME, DISPLAY_NAME
into l_name, l_dname
from WF_EVENTS_VL
where GUID = h_guid;
-- take care of the double quote problem
-- l_dname := replace(l_dname, '"', '\"');
exception
when NO_DATA_FOUND then
wf_core.raise('WFE_EVENT_NOTEXIST');
end;
htp.tableOpen(calign=>'CENTER',cattributes=>'WIDTH=100% summary=""');
htp.tableRowOpen;
wf_core.token('GROUP',''||l_name||'');
htp.tableData(cvalue=>wf_core.translate('WFE_ADD_SELECTED_TO_GRP'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
htp.tableClose;
-- populate the data table
i := 0;
if (h_func = 'DELETE') then
for event in devcurs loop
i := i+1;
dTab(i).guid := event.guid;
dTab(i).col01:= event.display_name;
dTab(i).col02:= event.name;
dTab(i).col03:= event.status;
dTab(i).selectable := TRUE;
dTab(i).deletable := FALSE;
dTab(i).hasdetail := FALSE;
end loop;
else
for event in aevcurs loop
i := i+1;
dTab(i).guid := event.guid;
dTab(i).col01:= event.display_name;
dTab(i).col02:= event.name;
dTab(i).col03:= event.status;
dTab(i).selectable := TRUE;
dTab(i).deletable := FALSE;
dTab(i).hasdetail := FALSE;
end loop;
end if;
-- Submit Form for Add/Delete
htp.formOpen(curl=>owa_util.get_owa_service_path||
'Wf_Event_Html.SubmitSelectedGEvents',
cmethod=>'Get',
cattributes=>'TARGET="_top" NAME="WF_GROUP_EDIT"');
htp.formHidden('h_gguid', rawtohex(h_guid));
-- Hide the fields for which option you selected. ADD or DELETE
htp.formHidden(cname=>'action', cvalue=>'');
-- Url to come back to later
htp.formHidden(cname=>'url',
cvalue=>'Wf_Event_Html.EditEvent?h_guid='||rawtohex(h_guid));
-- Add dummy fields to start both array-type input fields.
-- These dummy values are needed so that the array parameters to
-- the submit procedure will not be null even if there are no real
-- response fields. This would cause a pl/sql error, because array
-- parameters can't be defaulted.
htp.formHidden('h_guids', '-1');
-- popluate the header table
i := 1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('DISPLAY_NAME');
hTab(i).attr := 'id="'||wf_core.translate('DISPLAY_NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('NAME');
hTab(i).attr := 'id="'||wf_core.translate('NAME')||'"';
i := i+1;
hTab(i).def_type := 'TITLE';
hTab(i).value := wf_core.translate('STATUS');
hTab(i).attr := 'id="'||wf_core.translate('STATUS')||'"';
-- render table
Wfe_Html_Util.Simple_Table(hTab, dTab);
htp.formClose;
-- If we generate simple table, we create this check/uncheck all.
if (i > 0) then
htp.tableOpen (calign=>'CENTER',cattributes=>'WIDTH=100% summary=""');
htp.tableRowOpen;
htp.p('
');
htp.tableRowClose;
htp.tableClose;
end if;
htp.tableOpen (calign=>'CENTER', cattributes=>'summary=""');
htp.tableRowOpen;
if (h_func = 'DELETE') then
-- Delete Screen
-- Allow user to delete selected events
-- or add some more event through the find screen.
htp.p('
');
end if;
htp.tableRowClose;
htp.tableClose;
wfa_sec.Footer;
htp.htmlClose;
exception
when others then
rollback;
wf_core.context('WF_EVENT_HTML', 'EditGroup', rawtohex(h_guid));
wfe_html_util.Error;
end EditGroup;
--
-- EditSystem
-- Create/Update an event
-- IN
-- h_guid - Global unique id for a system
-- NOTE
--
procedure EditSystem(
h_guid in raw default null)
is
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
template varchar2(4000); -- Use for construct form select list
l_name varchar2(240);
l_dname varchar2(80);
l_desc varchar2(2000);
l_mname varchar2(80);
l_mguid raw(16);
l_message varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFPREF_LOV'));
l_url varchar2(1000);
l_media varchar2(240) := wfa_html.image_loc;
l_icon varchar2(30) := 'FNDILOV.gif';
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('SYSTEM');
-- Set page title
htp.htmlOpen;
htp.headOpen;
htp.title(wf_core.translate('WFE_EDIT_SYSTEM_TITLE'));
wfa_html.create_help_function('wf/links/t_d.htm?T_DEFEVSYS');
fnd_document_management.get_open_dm_display_window;
htp.headClose;
-- Page header
wfa_sec.Header(FALSE,
owa_util.get_owa_service_path||'wf_event_html.FindEvent',
wf_core.translate('WFE_EDIT_SYSTEM_TITLE'),
TRUE);
-- populate the appropriate values in the form if editing an exist guid
if (h_guid is not null) then
begin
select NAME, DISPLAY_NAME, DESCRIPTION, MASTER_GUID
into l_name, l_dname, l_desc, l_mguid
from WF_SYSTEMS
where GUID = h_guid;
exception
when NO_DATA_FOUND then
wf_core.raise('WFE_SYSTEM_NOTEXIST');
end;
if (l_mguid is not null) then
begin
select NAME
into l_mname
from WF_SYSTEMS
where GUID = l_mguid;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(l_mguid));
l_mname := wf_core.translate('WFE_EVENT_NOGUID');
end;
end if;
-- take care of the double quote problem
-- There should be no any kind of quote for name and generate_function.
-- Description is handle entirely differently, no need for substitution.
-- Single quote is ok becuase html does not treat it special.
l_dname := replace(l_dname, '"', '\"');
l_mname := replace(l_mname, '"', '\"');
end if;
-- Form
htp.formOpen(curl=>owa_util.get_owa_service_path||
'wf_event_html.SubmitSystem',
cmethod=>'Get',
cattributes=>'TARGET="_top" NAME="WF_SYSTEM_EDIT"');
-- GUID
-- do not display it if it is null
if (h_guid is not null) then
htp.p('');
end if;
htp.formHidden('h_guid', rawtohex(h_guid));
htp.tableOpen(calign=>'CENTER', cattributes=>'border=0 summary=""');
-- Name
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right', cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_name', csize=>40,
cmaxlength=>240, cvalue=>l_name,
cattributes=>'id="i_name"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Display Name
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right', cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_display_name', csize=>60,
cmaxlength=>80,
cattributes=>'id="i_display_name"'),
calign=>'Left', cattributes=>'id=""');
htp.tableRowClose;
-- Description
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right', cattributes=>'id=""');
htp.tableData(cvalue=>htf.formTextareaOpen2(
cname=>'h_description',
nrows=>2,
ncolumns=>60,
cwrap=>'SOFT',
cattributes=>'maxlength=2000
id="i_description"')
||l_desc
||htf.formTextareaClose,
calign=>'Left',
cattributes=>'id=""');
htp.tableRowClose;
-- Master GUID
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'right',cattributes=>'id=""');
htp.formHidden('h_master_guid', l_mguid);
-- add LOV here:
-- Note: The REPLACE function replaces all the space characters with
-- the proper escape sequence.
l_url := 'javascript:fnd_open_dm_display_window('||''''||
REPLACE('wf_lov.display_lov?p_lov_name='||'h_master_guid'||
'&p_display_name='||'SYSTEM'||
'&p_validation_callback=wf_event_html.wf_system_val'||
'&p_dest_hidden_field=top.opener.parent.document.WF_SYSTEM_EDIT.h_master_guid.value'||
'&p_current_value=top.opener.parent.document.WF_SYSTEM_EDIT.display_master.value'||
'&p_display_key='||'Y'||
'&p_dest_display_field=top.opener.parent.document.WF_SYSTEM_EDIT.display_master.value',
' ', '%20')||''''||',500,500)';
-- print everything together so there is no gap.
htp.tabledata(htf.formText(cname=>'display_master', csize=>32,
cmaxlength=>240,
cattributes=>'id="i_master"')||
''||
'',
cattributes=>'id=""');
htp.tableRowClose;
-- URL to go back to
htp.formHidden('url', 'Wf_Event_Html.ListSystems');
htp.tableClose;
htp.formClose;
-- add values that may contain double quote back through javascript
if (h_guid is not null) then
htp.p('');
end if;
-- Add submit button
htp.tableopen (calign=>'CENTER', cattributes=>'summary=""');
htp.tableRowOpen;
htp.p('
');
htp.tableRowClose;
htp.tableClose;
wfa_sec.Footer;
htp.htmlClose;
exception
when others then
rollback;
wf_core.context('WF_EVENT_HTML', 'EditSystem', h_guid);
wfe_html_util.Error;
end EditSystem;
--
-- EditAgent
-- Create/Update an agent
-- IN
-- h_guid - Global unique id for an agent
-- NOTE
--
procedure EditAgent(
h_guid in raw default null)
is
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
template varchar2(4000); -- Use for construct form select list
l_name varchar2(80);
l_dname varchar2(80);
l_desc varchar2(2000);
l_protocol varchar2(8);
l_address varchar2(80);
l_system varchar2(80); -- display_system
l_sysguid raw(16);
l_qhandler varchar2(240);
l_qname varchar2(80);
l_direction varchar2(8);
l_status varchar2(8);
l_message varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFPREF_LOV'));
l_url varchar2(1000);
l_media varchar2(240) := wfa_html.image_loc;
l_icon varchar2(30) := 'FNDILOV.gif';
l_onmouseover varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate('FIND'));
select_in varchar2(8);
select_out varchar2(8);
select_enable varchar2(8);
select_disable varchar2(8);
cursor protocurs is
select LOOKUP_CODE, MEANING
from WF_LOOKUPS
where LOOKUP_TYPE = 'WF_AQ_PROTOCOLS'
order by lookup_code desc;
selected boolean := FALSE; -- indicator if a lookup has been selected.
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('AGENTS');
-- Set page title
htp.htmlOpen;
htp.headOpen;
htp.title(wf_core.translate('WFE_EDIT_AGENT_TITLE'));
wfa_html.create_help_function('wf/links/t_d.htm?T_DEFEVAGT');
fnd_document_management.get_open_dm_display_window;
htp.headClose;
-- Page header
wfa_sec.Header(FALSE,
owa_util.get_owa_service_path||'wf_event_html.FindAgent',
wf_core.translate('WFE_EDIT_AGENT_TITLE'),
TRUE);
-- populate the appropriate values in the form if editing an exist guid
if (h_guid is not null) then
begin
select A.NAME, A.DISPLAY_NAME, A.DESCRIPTION, A.PROTOCOL, A.ADDRESS,
A.SYSTEM_GUID, A.QUEUE_HANDLER, A.QUEUE_NAME,
A.DIRECTION, A.STATUS, S.NAME
into l_name, l_dname, l_desc, l_protocol, l_address,
l_sysguid, l_qhandler, l_qname,
l_direction, l_status, l_system
from WF_AGENTS A, WF_SYSTEMS S
where A.GUID = h_guid
and A.SYSTEM_GUID = S.GUID;
-- take care of the double quote problem
-- Description is handle entirely differently, no need for substitution.
-- Single quote is ok becuase html does not treat it special.
l_dname := replace(l_dname, '"', '\"');
l_system := replace(l_system, '"', '\"');
if (l_direction = 'IN') then
select_in := 'SELECTED';
-- elsif (l_direction = 'OUT') then
else
select_out := 'SELECTED';
-- else
-- select_any := 'SELECTED';
end if;
if (l_status = 'ENABLED') then
select_enable := 'SELECTED';
select_disable := null;
else
select_enable := null;
select_disable := 'SELECTED';
end if;
exception
when NO_DATA_FOUND then
wf_core.raise('WFE_AGENT_NOTEXIST');
end;
end if;
-- Form
htp.formOpen(curl=>owa_util.get_owa_service_path||
'wf_event_html.SubmitAgent',
cmethod=>'Get',
cattributes=>'TARGET="_top" NAME="WF_AGENT_EDIT"');
-- GUID
-- do not display it if it is null
if (h_guid is not null) then
htp.p('');
end if;
htp.formHidden('h_guid', rawtohex(h_guid));
htp.tableOpen(calign=>'CENTER', cattributes=>'border=0 summary=""');
-- Name
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_name', csize=>60,
cmaxlength=>80, cvalue=>l_name,
cattributes=>'id="i_name"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Display Name
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_display_name', csize=>60,
cmaxlength=>80,
cattributes=>'id="i_display_name"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Description
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right', cattributes=>'id=""');
htp.tableData(cvalue=>htf.formTextareaOpen2(
cname=>'h_description',
nrows=>2,
ncolumns=>60,
cwrap=>'SOFT',
cattributes=>'maxlength=2000 id="i_description"')
||l_desc
||htf.formTextareaClose,
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Protocol
template := htf.formSelectOpen('h_protocol',cattributes=>'id="i_protocol"')
||wf_core.newline;
for prtr in protocurs loop
if (h_guid is not null and l_protocol is not null) then
if (prtr.lookup_code = l_protocol) then
template := template||htf.formSelectOption(prtr.meaning, 'SELECTED',
'VALUE="'||prtr.lookup_code||'"')||wf_core.newline;
selected := TRUE;
else
template := template||htf.formSelectOption(prtr.meaning, '',
'VALUE="'||prtr.lookup_code||'"')||wf_core.newline;
end if;
else
if (not selected) then
template := template||htf.formSelectOption(prtr.meaning, 'SELECTED',
'VALUE="'||prtr.lookup_code||'"')||wf_core.newline;
selected := TRUE;
else
template := template||htf.formSelectOption(prtr.meaning, '',
'VALUE="'||prtr.lookup_code||'"')||wf_core.newline;
end if;
end if;
end loop;
-- if it is still not selected, this must be a custom code not yet in
-- WF_AQ_PROTOCOLS, preserve it.
if (not selected) then
template := template||htf.formSelectOption(l_protocol, 'SELECTED',
'VALUE="'||l_protocol||'"')||wf_core.newline;
selected := TRUE;
end if;
template := template||htf.formSelectClose;
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right', cattributes=>'id=""');
htp.tableData(cvalue=>template, calign=>'Left',cattributes=>'id=""');
-- htp.tableData(cvalue=>htf.formText(cname=>'h_protocol', csize=>8,
-- cmaxlength=>8, cvalue=>l_protocol),
-- calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Address
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_address', csize=>80,
cmaxlength=>240, cvalue=>l_address,
cattributes=>'id="i_address"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- System
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'right',cattributes=>'id=""');
htp.formHidden('h_system_guid', null);
-- add LOV here:
-- Note: The REPLACE function replaces all the space characters with
-- the proper escape sequence.
l_url := 'javascript:fnd_open_dm_display_window('||''''||
REPLACE('wf_lov.display_lov?p_lov_name='||'h_system_guid'||
'&p_display_name='||'SYSTEM'||
'&p_validation_callback=wf_event_html.wf_system_val'||
'&p_dest_hidden_field=top.opener.parent.document.WF_AGENT_EDIT.h_system_guid.value'||
'&p_current_value=top.opener.parent.document.WF_AGENT_EDIT.display_system.value'||
'&p_display_key='||'Y'||
'&p_dest_display_field=top.opener.parent.document.WF_AGENT_EDIT.display_system.value',
' ', '%20')||''''||',500,500)';
-- print everything together so there is no gap.
htp.tabledata(htf.formText(cname=>'display_system', csize=>32,
cmaxlength=>240,cattributes=>'id="i_system"')||
''||
'',
cattributes=>'id=""');
htp.tableRowClose;
-- Queue Handler
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_qhandler', csize=>60,
cmaxlength=>240, cvalue=>l_qhandler,
cattributes=>'id="i_queue_handler"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Queue Name
htp.tableRowOpen;
htp.tableData(cvalue=>'', calign=>'Right',
cattributes=>'id=""');
htp.tableData(cvalue=>htf.formText(cname=>'h_qname', csize=>60,
cmaxlength=>80, cvalue=>l_qname,
cattributes=>'id="i_queue_name"'),
calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Direction
template := htf.formSelectOpen('h_direction', cattributes=>'id="i_direction"')||wf_core.newline||
/*
htf.formSelectOption(wf_core.translate('ANY'),
select_any,'VALUE="ANY"')
||wf_core.newline||
*/
htf.formSelectOption(wf_core.translate('IN'),
select_in,'VALUE="IN"')
||wf_core.newline||
htf.formSelectOption(wf_core.translate('OUT'),
select_out,'VALUE="OUT"')
||wf_core.newline||
htf.formSelectClose;
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>template, calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- Status
template := htf.formSelectOpen('h_status',cattributes=>'id="i_status"')
||wf_core.newline||
htf.formSelectOption(wf_core.translate('ENABLED'),
select_enable,'VALUE="ENABLED"')||
wf_core.newline||
htf.formSelectOption(wf_core.translate('DISABLED'),
select_disable,'VALUE="DISABLED"')
||wf_core.newline||
htf.formSelectClose;
htp.tableRowOpen;
htp.tableData(cvalue=>'',
calign=>'Right',cattributes=>'id=""');
htp.tableData(cvalue=>template, calign=>'Left',cattributes=>'id=""');
htp.tableRowClose;
-- URL to go back to
htp.formHidden('url', 'Wf_Event_Html.ListAgents');
htp.tableClose;
htp.formClose;
-- add values that may contain double quote back through javascript
if (h_guid is not null) then
htp.p('');
end if;
-- Add submit button
htp.tableopen (calign=>'CENTER', cattributes=>'summary=""');
htp.tableRowOpen;
htp.p('
');
htp.tableRowClose;
htp.tableClose;
wfa_sec.Footer;
htp.htmlClose;
exception
when others then
rollback;
wf_core.context('WF_EVENT_HTML', 'EditAgent', h_guid);
wfe_html_util.Error;
end EditAgent;
--
-- EditSubscription
-- Create/Update a subscription
-- IN
-- h_guid - Global unique id for a subscription
-- NOTE
--
procedure EditSubscription(
h_guid in raw default null,
h_sguid in raw default null,
h_eguid in raw default null)
is
username varchar2(320); -- Username to query
admin_role varchar2(320); -- Role for admin mode
template varchar2(4000); -- Use for construct form select list
l_sysguid raw(16);
l_srctype varchar2(8);
l_srcagnguid raw(16);
l_evtguid raw(16);
l_phase number;
l_status varchar2(8);
l_ruled varchar2(8);
l_outagnguid raw(16);
l_toagnguid raw(16);
l_priority number;
l_rulef varchar2(240);
l_wfptype varchar2(30);
l_wfpname varchar2(30);
l_param varchar2(4000);
l_ownname varchar2(30);
l_owntag varchar2(30);
l_customization_level varchar2(1);
l_desc varchar2(240);
l_system_name varchar2(80);
l_event_name varchar2(240);
l_srcagn_dname varchar2(240);
l_outagn_dname varchar2(240);
l_toagn_dname varchar2(240);
l_wfptype_dname varchar2(80);
l_wfpname_dname varchar2(80);
select_enable varchar2(8);
select_disable varchar2(8);
select_any varchar2(8);
select_local varchar2(8);
select_external varchar2(8);
select_error varchar2(8);
select_key varchar2(8);
select_message varchar2(8);
select_function varchar2(8);
select_agent varchar2(8);
select_workflow varchar2(8);
select_low varchar2(8);
select_high varchar2(8);
select_normal varchar2(8);
select_custom_core varchar2(8);
select_custom_limit varchar2(8);
select_custom_extend varchar2(8);
select_custom_user varchar2(8);
-- priority values
l_low varchar2(6) := '99';
l_normal varchar2(6) := '50';
l_high varchar2(6) := '1';
l_message varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate('WFPREF_LOV'));
l_url varchar2(1000);
l_media varchar2(240) := wfa_html.image_loc;
l_icon varchar2(30) := 'FNDILOV.gif';
l_onmouseover varchar2(240) := wfa_html.replace_onMouseOver_quotes(wf_core.translate('FIND'));
begin
-- Check session and current user
wfa_sec.GetSession(username);
username := upper(username);
wf_events_pkg.setMode;
-- Check Admin Priviledge
admin_role := wf_core.translate('WF_ADMIN_ROLE');
if (admin_role = '*' or
Wf_Directory.IsPerformer(username, admin_role)) then
-- Have admin privledge, do nothing.
null;
else
wf_core.raise('WF_NOTADMIN');
end if;
-- Check if Accessible
wf_event_html.isAccessible('SUBSCRIPTIONS');
-- Set page title
htp.headOpen;
htp.title(wf_core.translate('WFE_EDIT_SUBSC_TITLE'));
wfa_html.create_help_function('wf/links/t_d.htm?'||'T_DEFEVSUB');
fnd_document_management.get_open_dm_display_window;
-- JavaScript for checkagent
/** No longer required - XML Gateway has single consumer queues
which do not require a To Agent
htp.p('');
**/
htp.headClose;
-- Page header
wfa_sec.Header(FALSE,
owa_util.get_owa_service_path||'wf_event_html.FindSubscription',
wf_core.translate('WFE_EDIT_SUBSC_TITLE'),
TRUE);
-- populate the appropriate values in the form if editing an exist guid
if (h_guid is not null) then
begin
select SYSTEM_GUID,
SOURCE_TYPE,
SOURCE_AGENT_GUID,
EVENT_FILTER_GUID,
PHASE,
STATUS,
OWNER_NAME,
OWNER_TAG,
RULE_DATA,
RULE_FUNCTION,
OUT_AGENT_GUID,
TO_AGENT_GUID,
PRIORITY,
WF_PROCESS_TYPE,
WF_PROCESS_NAME,
PARAMETERS,
CUSTOMIZATION_LEVEL,
DESCRIPTION
into l_sysguid,
l_srctype,
l_srcagnguid,
l_evtguid,
l_phase,
l_status,
l_ownname,
l_owntag,
l_ruled,
l_rulef,
l_outagnguid,
l_toagnguid,
l_priority,
l_wfptype,
l_wfpname,
l_param,
l_customization_level,
l_desc
from WF_EVENT_SUBSCRIPTIONS
where GUID = h_guid;
-- take care of the double quote problem
-- Description is handle entirely differently, no need for substitution.
-- Single quote is ok becuase html does not treat it special.
l_ownname := replace(l_ownname, '"', '\"');
l_owntag := replace(l_owntag, '"', '\"');
-- Select From System
if (l_srctype = 'EXTERNAL') then
select_external := 'SELECTED';
elsif (l_srctype = 'LOCAL') then
select_local := 'SELECTED';
else
select_error := 'SELECTED';
end if;
-- Select Status
if (l_status = 'ENABLED') then
select_enable := 'SELECTED';
else
select_disable := 'SELECTED';
end if;
-- Select Rule Data
if (l_ruled = 'MESSAGE') then
select_message := 'SELECTED';
else
select_key := 'SELECTED';
end if;
-- Stuff for Customization Level
if l_customization_level = 'C' then
select_custom_core := 'SELECTED';
select_custom_limit := null;
select_custom_extend := null;
select_custom_user := null;
elsif l_customization_level = 'L' then
select_custom_core := null;
select_custom_limit := 'SELECTED';
select_custom_extend := null;
select_custom_user := null;
elsif l_customization_level = 'U' then
select_custom_core := null;
select_custom_limit := null;
select_custom_extend := null;
select_custom_user := 'SELECTED';
end if;
-- Use the same priority criteria as in notification
if (l_priority < 34) then
select_high := 'SELECTED';
l_high := to_char(l_priority); -- to preserve the priority
elsif (l_priority > 67) then
select_low := 'SELECTED';
l_low := to_char(l_priority);
else
select_normal := 'SELECTED';
l_normal := to_char(l_priority);
end if;
exception
when NO_DATA_FOUND then
wf_core.raise('WFE_SUBSC_NOTEXIST');
end;
-- Get System Name
if (l_sysguid is not null) then
begin
select NAME
into l_system_name
from WF_SYSTEMS
where GUID = l_sysguid;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(l_sysguid));
l_system_name := wf_core.translate('WFE_SYSTEM_NOGUID');
end;
l_system_name := replace(l_system_name, '"', '\"');
end if;
-- Get Event Name
if (l_evtguid is not null) then
begin
select NAME
into l_event_name
from WF_EVENTS_VL
where GUID = l_evtguid;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(l_evtguid));
l_event_name := wf_core.translate('WFE_EVENT_NOGUID');
end;
end if;
-- Get Agent Name
if (l_srcagnguid is not null) then
begin
select A.NAME||'@'||S.NAME
into l_srcagn_dname
from WF_AGENTS A, WF_SYSTEMS S
where A.GUID = l_srcagnguid
and A.SYSTEM_GUID (+)= S.GUID;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(l_srcagnguid));
l_srcagn_dname := wf_core.translate('WFE_AGENT_NOGUID');
end;
end if;
if (l_outagnguid is not null) then
begin
select A.NAME||'@'||S.NAME
into l_outagn_dname
from WF_AGENTS A, WF_SYSTEMS S
where A.GUID = l_outagnguid
and A.SYSTEM_GUID (+)= S.GUID;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(l_outagnguid));
l_outagn_dname := wf_core.translate('WFE_AGENT_NOGUID');
end;
end if;
if (l_toagnguid is not null) then
begin
select A.NAME||'@'||S.NAME
into l_toagn_dname
from WF_AGENTS A, WF_SYSTEMS S
where A.GUID = l_toagnguid
and A.SYSTEM_GUID (+)= S.GUID;
exception
when NO_DATA_FOUND then
wf_core.token('GUID', rawtohex(l_toagnguid));
l_toagn_dname := wf_core.translate('WFE_AGENT_NOGUID');
end;
end if;
-- Get WF Process Type Name
if (l_wfptype is not null) then
begin
select DISPLAY_NAME
into l_wfptype_dname
from WF_ITEM_TYPES_VL
where NAME = l_wfptype;
exception
when NO_DATA_FOUND then
l_wfptype_dname := NULL;
-- it is ok if this process does not exist in the local system
end;
l_wfptype_dname := replace(l_wfptype_dname, '"', '\"');
end if;
-- new subscription, default some values
else
l_customization_level := 'U';
select_local := 'SELECTED';
select_enable := 'SELECTED';
select_normal := 'SELECTED';
-- populate the system info
if (h_sguid is not null) then
begin
select NAME
into l_system_name
from WF_SYSTEMS
where GUID = h_sguid;
exception
when NO_DATA_FOUND then
null; -- do not do anything
end;
l_system_name := replace(l_system_name, '"', '\"');
end if;
-- populate the event filter info
if (h_eguid is not null) then
begin
select NAME
into l_event_name
from WF_EVENTS_VL
where GUID = h_eguid;
exception
when NO_DATA_FOUND then
null; -- do not do anything
end;
end if;
end if;
-- Hidden Form
htp.p('