rem rem NAME rem ckcremen.hpb - Create a menu hierarchy as a copy of an existing one. rem rem DESCRIPTION rem Create a menu hierarchy as a copy of an existing one. rem rem Spec. from bug 508695 : rem rem The DE lets users copy module networks by drag and drop. rem It needs to be able to copy the module network as follows - rem 1. For a given module all the module networks from that module rem are copied if they link to a non-menu module. rem 2. If the link is to a menu module then a new menu module - with the rem same properties, apart from the short_name, is created and rem linked to the module. rem 3. The links from each menu module are copied as in steps 1 and 2 above. rem rem NOTES rem rem When Menu Module are copied the package does not do navigation i.e rem looking for children. rem Doen only copy Modules not Module Components. rem rem PUBLIC rem Create_As rem rem bug 1119969 - updated for 6.5 jkchow 13jan00 prompt prompt Creating Stored Package CkoMenu create or replace package body ckoMenu as /*---------------------------- Local procedures ----------------------------*/ function copy_menu(trans_seq in number, parent_id in number, name in varchar2, element_type_name in varchar2, module_type in varchar2, general_module_type in varchar2, top_level in boolean) return number; /*------------------------------ Create As ---------------------------------*/ /* Name Create As Description Main procedure. Calls copy menu which recursively copies the menu modules; */ procedure create_as(old_id in number, new_id out number) is proc varchar2(100) := 'Create_As '; element_type_name ci_modules.element_type_name%type; name ci_modules.name%type; module_type ci_modules.module_type%type; general_module_type ci_modules.general_module_type%type; trans_seq number; cursor module_properties is select m.name , m.element_type_name , m.module_type , m.general_module_type from ci_modules m where m.id = old_id; begin rmdbg.trace(proc || 'is started ' || to_char(old_id)); rmmes.clear; open module_properties; fetch module_properties into name, element_type_name, module_type, general_module_type; if (module_properties%notfound) then close module_properties; ciierr.fatal(6019); end if; close module_properties; trans_seq := ckuxx.get_current_trans_ref; if (trans_seq is null) then trans_seq := ckuxx.get_trans_ref; end if; rmdbg.trace(proc || 'loc 1. Seq ' || to_char(trans_seq)); ckuxx.cleanup_temporary_set(trans_seq); new_id := copy_menu(trans_seq, old_id, name, element_type_name, module_type, general_module_type, true); rmdbg.trace(proc || 'loc 2. Ni ' || to_char(new_id)); ckuxx.cleanup_temporary_set(trans_seq); rmdbg.trace(proc || 'loc 3 Finish'); rmdbg.flush_trace; end create_as; /*------------------- Copy_Menu ---------------------------------*/ /* Name Copy_Menu Description Recursively copies the modules if it is either a menu general module or it is the top level general module. Returns The new id of the copied module */ function copy_menu(trans_seq in number, parent_id in number, name in varchar2, element_type_name in varchar2, module_type in varchar2, general_module_type in varchar2, top_level in boolean) return number is fun_name varchar2(100) := 'Copy_Menu '; is_dup boolean := false; new_id number := 0; child_id number := 0; pl ciogeneral_module.data; cursor mod_network is select mn.id mn_id , m.irid , m.name , m.element_type_name , m.module_type , m.general_module_type from ci_module_networks mn , ci_modules m where mn.parent_module_reference = pl.v.irid and mn.child_module_reference = m.irid and m.element_type_name = 'MOD' and m.module_type = 'GEM' and m.general_module_type = 'MENU' order by mn.called_sequence; begin rmdbg.trace (fun_name || 'loc 10. Ts ' || to_char(trans_seq) || ' pi ' || to_char(parent_id) || ' n ' || name || ' etn ' || element_type_name || ' mt ' || module_type || ' gmt ' || general_module_type); if (element_type_name = 'MOD') then rmdbg.trace (fun_name || 'loc 11'); /* Insert into temporary table of the module id we're going to copy */ if ((element_type_name = 'MOD' and module_type = 'GEM' and general_module_type = 'MENU') or (element_type_name = 'MOD' and module_type = 'GEM' and top_level = true)) then begin /* Make a note we have seen this module */ insert into ck_temporary_set (trans_ref, id, type_of, el_str, marked) values(trans_seq, parent_id, element_type_name, 'E', 'Y'); rmdbg.trace (fun_name || 'loc 12',sql%rowcount); exception /* Object already has been inserted */ when dup_val_on_index then is_dup := true; rmdbg.trace (fun_name || 'loc 13'); end; else /* non-menu or non-top level module */ return parent_id; end if; rmdbg.trace (fun_name || 'loc 14'); if (is_dup = false) then /* deep copy the module */ ciogeneral_module.copy_pac(parent_id, null, pl); /* update the id in the temporary table */ update ck_temporary_set set new_id = pl.v.irid where trans_ref = trans_seq and id = parent_id; /* for each of the children... */ for cm in mod_network loop /* perform the copy menu function */ child_id := copy_menu(trans_seq, cm.irid, cm.name, cm.element_type_name, cm.module_type, cm.general_module_type, false); /* update the module network to point to the new child */ update ci_module_networks set child_module_reference = child_id where id = cm.mn_id; end loop; /* ensure the return value is correct */ new_id := pl.v.irid; else /* return the id of the previously copied module */ select t.new_id into new_id from ck_temporary_set t where t.trans_ref = trans_seq and t.id = parent_id; end if; end if; rmdbg.trace (fun_name || 'loc 17'); return new_id; end copy_menu; end ckomenu; /