rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\cimcn.hpb 1.4 1998/12/14 18:11:23 cvanes Exp $ rem Rem Copyright (c) 1996 by Oracle Corporation Rem NAME Rem cimcn.hpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem cvanes 07/10/96 - Creation REM *************************************************************************** REM Hand-carved package body for MODULE COMPONENT INCLUSION created on 10-JAN-96 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihmcn IS -- Generic post-process routines PROCEDURE check_delete(id number); FUNCTION unique_win_name(win_name in varchar2, gem_ref in number) RETURN varchar2; sac_type constant varchar2(6) := 'MCN'; pac_type constant varchar2(6) := 'MOD'; -- ck_language_properties magic number SupportsModuleLevelComponent constant number := 502; save_del_mco_id number; -- Save the mco to be deleted for post_process save_del_sub_id number; -- Save the sub to be deleted for post_process save_del_gem_id number; -- Save the parent gem for post_process deletion code --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id number, pl in out NOCOPY ciomodule_component_inclusion.data) IS dummy number; win ciowindow.data; BEGIN -- Access rights for module component inclusion derive from the module component -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(pl.v.general_module_reference,pac_type, -- 'UPD','SHR'); -- Validate user-defined properties if cieval.is_extended then cieval.check_element(id,pl.v.types,(operation='UPD') ,pl.v.user_defined_property_0,pl.i.user_defined_property_0 ,pl.v.user_defined_property_1,pl.i.user_defined_property_1 ,pl.v.user_defined_property_2,pl.i.user_defined_property_2 ,pl.v.user_defined_property_3,pl.i.user_defined_property_3 ,pl.v.user_defined_property_4,pl.i.user_defined_property_4 ,pl.v.user_defined_property_5,pl.i.user_defined_property_5 ,pl.v.user_defined_property_6,pl.i.user_defined_property_6 ,pl.v.user_defined_property_7,pl.i.user_defined_property_7 ,pl.v.user_defined_property_8,pl.i.user_defined_property_8 ,pl.v.user_defined_property_9,pl.i.user_defined_property_9 ,pl.v.user_defined_property_10,pl.i.user_defined_property_10 ,pl.v.user_defined_property_11,pl.i.user_defined_property_11 ,pl.v.user_defined_property_12,pl.i.user_defined_property_12 ,pl.v.user_defined_property_13,pl.i.user_defined_property_13 ,pl.v.user_defined_property_14,pl.i.user_defined_property_14 ,pl.v.user_defined_property_15,pl.i.user_defined_property_15 ,pl.v.user_defined_property_16,pl.i.user_defined_property_16 ,pl.v.user_defined_property_17,pl.i.user_defined_property_17 ,pl.v.user_defined_property_18,pl.i.user_defined_property_18 ,pl.v.user_defined_property_19,pl.i.user_defined_property_19 ); end if; -- Initialize unassigned properties with default values on INSERT if operation = 'INS' then pl.v.element_type_name := sac_type; pl.i.element_type_name := true; if pl.v.module_component_reference is not null then pl.v.mcn_for := 'MCO'; else pl.v.mcn_for := 'SUB'; end if; pl.i.mcn_for := true; -- For module components check no existing Module -- Component Inclusion already exists for this SMC if pl.v.module_component_reference is not null then for clashes in ( SELECT NULL FROM sdd_mcn mcn , sdd_mun mun1 WHERE mcn.module_component_ref = pl.v.module_component_reference AND mun1.irid = mcn.module_component_ref AND mun1.module_unit_subtype = 'SMC' AND mcn.general_module_ref = pl.v.general_module_reference ) loop ciierr.fatal(1358,ciiutl.identify(pl.v.id, pl.v.types)); end loop; -- For subcomponents check no existing Module -- Component Inclusion already exists for this SUB -- NB: If the subcomponent is a subcomponent in an RMC -- then there may be other MCNs but they must be for inclusions -- in different modules. else for clashes in ( SELECT NULL FROM sdd_mcn mcn , sdd_mun mun1 WHERE mcn.subcomponent_ref = pl.v.subcomponent_reference AND mun1.irid = mcn.subcomponent_ref AND mun1.module_unit_subtype = 'SUB' AND mcn.general_module_ref = pl.v.general_module_reference ) loop ciierr.fatal(1358,ciiutl.identify(pl.v.id, pl.v.types)); end loop; end if; if not cdapi.load_mode then begin update sdd_mun mco set mco.general_module_ref = pl.v.general_module_reference where mco.irid = pl.v.module_component_reference and mco.module_unit_subtype = 'SMC'; exception WHEN NO_DATA_FOUND THEN null; -- It's perfectly fine if the MCO is not SPECIFIC end; /* Default Window Ref */ if pl.v.window_reference is null then select count(*) into dummy from ci_general_modules gem ,ci_languages lan where lan.id = gem.language_reference and gem.id = pl.v.general_module_reference and (lan.internal_name in ('VB', 'OPO', 'Web') or (lan.internal_name = 'Forms' and gem.general_module_type = 'DEFAULT')); if dummy > 0 then win.v.name := cihmcn.unique_win_name('WINDOW', pl.v.general_module_reference); win.i.name := true; win.v.general_module_reference := pl.v.general_module_reference; win.i.general_module_reference := true; ciowindow.ins(null, win); pl.v.window_reference := win.v.id; pl.i.window_reference := true; end if; end if; end if; -- load_mode if pl.v.usage_sequence is null then select nvl(max(usage_sequence),0) + 100 into pl.v.usage_sequence from ci_module_component_inclusions mcn where mcn.general_module_reference = pl.v.general_module_reference; pl.i.usage_sequence := true; end if; end if; END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id number) IS BEGIN -- Access rights for module component inclusion derive from the module component -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(id,sac_type,operation,'SAC'); -- if operation is 'DELETE', make sure no non-cascading references exist if operation = 'DEL' then check_delete(id); -- Then delete specific module components -- Save the mco to be deleted for post_process select max(mcn.module_component_reference) ,max(mcn.subcomponent_reference) ,max(mcn.general_module_reference) into save_del_mco_id ,save_del_sub_id ,save_del_gem_id from ci_module_component_inclusions mcn where mcn.id = pre_process.id; end if; END; --===================== POST-PROCESS (INS,UPD,SEL) ==========================-- PROCEDURE post_process(operation varchar2,id number, pl ciomodule_component_inclusion.data) IS dummy number; mco2_ref number; mco1_types number; mco2_types number; app_ref number; other_win_ref number; other_win_name varchar2(100); mco_name varchar(100); usage_seq number; nai cionavigation_action_item.data; BEGIN -- You cannot have two MCNs within the same GEM where the MUN name is the same if operation = 'INS' and cimmun.dont_check_mcn_unique = false then rmdbg.trace('In CIHMCN.post_process'); rmdbg.trace('Operation is : ' ||operation); rmman.log_change('CIHMUNE_UNIQUE',nvl(pl.v.module_component_reference, pl.v.subcomponent_reference)); end if; -- Reports may not have subcomponents (Bug 962990), so only do this if module_component_reference is set. if (operation='INS' or (operation='UPD' and pl.i.window_reference)) then if pl.v.module_component_reference is not null then rmdbg.trace('In CIHMCN.post_process, generating NAIs'); -- Generate NAI from WIN->MCN for Reports modules... select count(*) into dummy from ci_general_modules gem, ci_languages lang where lang.internal_name='Reports' and lang.id=gem.language_reference and gem.id=pl.v.general_module_reference and NOT EXISTS (select null from ci_navigation_action_items nai --Don't generate NAI if a WIN->MCN NAI where nai.mcn_reference_to = pl.v.id --already exists for this MCN. and nai.window_reference is not null); -- If MCN is in Reports module, and is connected to a window... rmdbg.trace('Dummy is :' ||to_char(dummy)); rmdbg.trace('Window ref is :' ||to_char(pl.v.window_reference)); if (dummy > 0) and (pl.v.window_reference is not null) then select max(win.id) into other_win_ref from ci_windows win where win.general_module_reference = pl.v.general_module_reference and win.id < pl.v.window_reference;--Looking for windows created previously to the one containing this MCN --...and another window was previously created in this module... rmdbg.trace('Other Window ref is :' ||to_char(other_win_ref)); if other_win_ref is not null then select win.name, mco.name --get names of previous window, and the MCO this MCN is connected to. into other_win_name, mco_name from ci_windows win, ci_module_components mco where win.id=other_win_ref and mco.id=pl.v.module_component_reference; rmdbg.trace('Other Window name is :' ||other_win_name); rmdbg.trace('MCO name is :' ||mco_name); --...then create a NAI that links from the most recently created (by ID no) other window to this MCN. nai.v.name := cihkbl.unique_aci_name( other_win_name || '_' || mco_name, other_win_ref); nai.i.name := true; nai.v.window_reference := other_win_ref; nai.i.window_reference := true; nai.v.mcn_reference_to := pl.v.id; nai.i.mcn_reference_to := true; cionavigation_action_item.ins(null, nai); end if; end if; else -- Taken from spec in bug 923848 -- if the inclusion is for a subcomponent -- then find out which window the parent inclusion -- is in as we will want to create the NAI in this -- window. The NAI goes from the owning window of -- the inclusion for the MODULE_COMPONENT, to the -- inclusion of the SUBCOMPONENT -- 26-02-02 Removed outer join to ci_windows as causing FT scan for windows in ( select par_mcn.window_reference other_win_ref ,win.name other_win_name from ci_module_component_inclusions par_mcn ,ci_windows win where win.id = par_mcn.window_reference and par_mcn.id = pl.v.parent_mcn_reference) loop if (windows.other_win_ref != pl.v.window_reference) then select sub.name into mco_name from sdd_mun sub where sub.irid = pl.v.subcomponent_reference ; select nvl(max(nai.usage_sequence), 0) + 10 into usage_seq from ci_navigation_action_items nai where nai.window_reference = windows.other_win_ref; -- create a new NAI 'nai' nai.v.WINDOW_REFERENCE := windows.other_win_ref; nai.i.WINDOW_REFERENCE := true; nai.v.MCN_REFERENCE_TO := pl.v.id; nai.i.MCN_REFERENCE_TO := true; nai.v.name := cihkbl.unique_aci_name( windows.other_win_name || '_' || mco_name, windows.other_win_ref); nai.i.name := true; nai.v.USAGE_SEQUENCE := usage_seq; nai.i.USAGE_SEQUENCE := true; cionavigation_action_item.ins(null, nai); end if; end loop; end if; end if; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id number) IS -- Finds MCNs which are for SUBcomponents of this MCN cursor sibling_mcns (mco_id number, gem_id number) is select mcn.irid from ci_module_component_inclusions mcn ,ci_subcomponents sub where mcn.subcomponent_reference = sub.irid and sub.module_component_reference = mco_id and mcn.general_module_reference = gem_id; mun_subtype varchar2(3); mun_subtype2 varchar2(3); BEGIN if operation = 'DEL' then select module_unit_subtype into mun_subtype from sdd_mun where irid = nvl(save_del_mco_id, save_del_sub_id); if mun_subtype = 'SUB' then select mco.module_unit_subtype into mun_subtype2 from ci_module_components mco ,ci_subcomponents sub where mco.irid = sub.module_component_reference and sub.irid = save_del_sub_id; if mun_subtype2 = 'SMC' then ciosubcomponent.del(save_del_sub_id); end if; elsif mun_subtype = 'SMC' then ciospecific_mco.del(save_del_mco_id); -- Any subcomponents will be deleted from here elsif mun_subtype = 'RMC' then for mcn in sibling_mcns(save_del_mco_id, save_del_gem_id) loop ciomodule_component_inclusion.del(mcn.irid); end loop; end if; end if; END; --============================= CHECK DELETE ================================-- PROCEDURE check_delete(id number) IS dummy number; dummy_types number; error_count number := 0; BEGIN /* Request to remove this check - Bug 819177 select count(*) into dummy from ci_module_component_inclusions mcn ,ci_specific_mcos mco where mco.id = mcn.module_component_reference and mcn.id = check_delete.id and mco.module_level_flag = 'Y'; if dummy > 0 then -- %0!s: Cannot delete if Module Component is MODULE_LEVEL ciierr.post(1359, ciiutl.identify(id, 'MCN')); error_count := 1; end if; */ /* -- Check if any PVLs depend on me select min(pvl.id), min(pvl.types) into dummy, dummy_types from ci_module_networks modmod ,ci_passed_values pvl ,ci_items ite ,ci_module_component_inclusions mcn where pvl.item_reference = ite.id and pvl.module_network_reference = modmod.id and mcn.general_module_reference = modmod.parent_module_reference and mcn.module_component_reference = ite.module_component_reference and mcn.id = check_delete.id; if dummy is not null then -- %0!s: Cannot delete this Module Component Inclusion as %1!s depends on it ciierr.post(1191,ciiutl.identify(id, 'MCN'), ciiutl.identify(dummy, dummy_types)); error_count := 1; end if; */ if error_count > 0 then raise cdapi.apierror; end if; END; --========================== UNIQUE WIN NAME ================================-- -- Returns win_name with a number appended to it so that it obeys -- uniqueness constraint of WINs FUNCTION unique_win_name(win_name in varchar2, gem_ref in number) RETURN varchar2 IS cursor win_names(gem_reference number) is select name from ci_windows win where win.general_module_reference = gem_reference; NamesList ciiutl.NameTabTyp; Cnt number := 1; BEGIN for win_name in win_names(gem_ref) loop NamesList(Cnt) := win_name.name; Cnt := Cnt + 1; end loop; return(ciiutl.unique_name(win_name, NamesList, 'WIN')); END; --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /