create or replace package body cdwp_dia is /***************************************************************************************** Purpose HTML Report of Diagrams for ODWA Usage Remarks Revision history When Who Construct Revision What ------------------------------------------------------------------------------------------ $REVISION_HISTORY$ 10-Dec-2002 Kannan Parthasarathy - B2701865 : Fixed. 07-feb-2001 SANDRA MULLER 3.3 fix for issue 164 02-feb-2001 SANDRA MULLER 3.2 fix for issue 169 08-dec-2000 Lucas Jellema 3.1 New public function: get_diagram_gif 11-sep-2000 Lucas Jellema 2.9 Tune queries, add + RULE hints 11-aug-2000 Lucas Jellema 2.8 Update to support 6i and the new ODWA Graphics and Hotspots scheme 20-jun-2000 Lucas Jellema 2.7 + help text not correct 31-may-2000 Lucas Jellema list_dia_definitions 2.6 + call to reset('all') did not work (uppercase/lowercase) 30-may-2000 Lucas Jellema list_dia_definitions 2.5 + IE/Netscape support 29-may-2000 Lucas Jellema list_dia_definitions 2.2 + write menu_bar (status bar) for one_file = 'Y' + Heading was diagrams is now Diagrams 28-may-2000 Lucas Jellema list_diagram_elements 2.1 no ote-display_name + gif, just report_link 25-may-2000 Lucas Jellema short_list_ and list_ 2.0 + all functional improvements, such as + app_summary + icon bar + set_context and set_app 24-may-2000 Lucas Jellema procedure normal_list_diagrams 1.4 - set_context and set_app - use report_link procedure list_diagram_elements Use report_link 23-may-2000 Lucas Jellema procedure short_list_diagrams 1.3 - show type of diagram in title - if no diagrams of indicated type available, display appropriate message procedure short_list_diagrams, list_diagrams , normal_list_diagrams Package Specification - add parameter p_mgt_mode which indicates whether the diagram may be edited 22-may-2000 Lucas Jellema procedure short_list_diagrams 1.2 - group by diagram type - added write_about - added parameter p_dia_type, to only list diagrams of indicated type package specification - spec procedure short_list_diagrams is changed procedure list_diagrams - added write_about 10-may-2000 Sandra Muller and Ton van Kooten several 1.1 - improved alignment a bit - added temporary instructions for linking .gif file to ODWA - changed where clause of cursors selecting diagram elements: when el_occur_type is D, E, N, R, or U use the el_type_of (probably function) 27-apr-2000 Lucas Jellema 1.0 Creation 1.3 For some reason we could not use p_mgt_mode with the OAS PL/SQL cartridge. Instead, we use p_one_file. Since editing diagrams is only allowed in Dynamic mode, and p_one_file has no meaning in this mode, we can use it to convey a different meaning. We choose the value of X to indicate Manager Mode. *****************************************************************************************/ -- -- private constants -- REVISION_LABEL constant varchar2(30) := '$x.y3.3 $'; PACKAGE_NAME constant varchar2(30) := 'CDWP_DIA'; type t_str_tbl is table of varchar2(200) index by binary_integer ; g_dia_name varchar2(100); g_dia_notes_tbl cdwp_txt.cdi_text_lines; g_dia_notes_tbl_ctr number(5); -- -- cursor to select properties of domains owned by and shared to -- a specific application system -- cursor c_dia ( b_dia_ivid in number ) is select dia.id , dia.name , dia.title , dia.diagram_type from ci_diagrams dia where dia.ivid = b_dia_ivid order by dia.name ; r_dia c_dia%rowtype; -- -- -- procedure short_list_diagrams ( p_session_id in number default null , p_dia_type in varchar2 := null ) is l_dia_type varchar2(10):= p_dia_type; procedure diagram_type ( p_diagram_type in varchar2 , p_diagram_type_title in varchar2 , p_diagram_gif in varchar2 ) is l_first boolean:= true; begin if nvl(l_dia_type, p_diagram_type) = p_diagram_type -- if no specific diagram type selected or the selected diagramtype is found then cdwp.bookmark(p_diagram_type); -- BOOKMARK for i in 1..cdwpbase.g_iridTab.count loop open c_dia( b_dia_ivid => cdwpbase.g_ividTab(i)); fetch c_dia into r_dia; close c_dia; if r_dia.diagram_type = p_diagram_type then if l_first then l_first:= false; cdwp.tableOpen; cdwp.tableRowOpen; cdwp.TableDataHeading(null); if l_dia_type is null -- only if all Diagram Types are requested, show diagram type headings then htp.fontOpen(csize => 5); cdwp.tableDataValue ( htf.underline ( cdwp.add_images( '{'||p_diagram_gif||'}') ||' '||htf.bold(p_diagram_type_title) ) ); htp.fontClose; end if; -- l_dia_type is null cdwp.tableRowClose; end if; cdwp.tableRowOpen; cdwp.TableDataHeading(null); cdwpbase.set_found; cdwp.TableDataValue ( cdwp.report_link ( p_el_id => r_dia.id , p_ivid => cdwpbase.g_ividTab(i) , p_type_of => 'DIA' , p_text => r_dia.name||' - '||r_dia.title ) ); cdwp.tableRowClose; end if; -- r_dia.diagram_type = p_diagram_type end loop; -- i in 1..cdwpbase.g_iridTab.count if not l_first then cdwp.tableClose; htp.nl; htp.nl; end if; end if; -- nvl(l_dia_type, p_diagram_type) = p_diagram_type end; -- diagram_type -- functions return the display title for the indicated diagram type; -- if p_dia_type is null, the function returns Diagram function diagram_title ( p_dia_type in varchar2 ) return varchar2 is begin if p_dia_type = 'ERD' then return ROB_msg.getMsg(Rob_msg.DSP117_CDWP_ERD, '', '', '', ''); elsif p_dia_type = 'FHD' then return ROB_msg.getMsg(Rob_msg.DSP118_CDWP_FHD, '', '', '', ''); elsif p_dia_type = 'BPA' then return ROB_msg.getMsg(Rob_msg.DSP119_CDWP_BPM, '', '', '', ''); elsif p_dia_type = 'MDD' then return ROB_msg.getMsg(Rob_msg.DSP120_CDWP_MDD, '', '', '', ''); elsif p_dia_type = 'DSD' then return ROB_msg.getMsg(Rob_msg.DSP121_CDWP_DSD, '', '', '', ''); elsif p_dia_type = 'DFD' then return ROB_msg.getMsg(Rob_msg.DSP122_CDWP_DFD, '', '', '', ''); elsif p_dia_type = 'MXD' then return ROB_msg.getMsg(Rob_msg.DSP123_CDWP_MXD, '', '', '', ''); end if; if p_dia_type is null then return ROB_msg.getMsg(Rob_msg.DSP124_CDWP_DIAGRAM, '', '', '', ''); end if; end; -- diagram_title begin odwactxt.update_context ( p_session_id => p_session_id , p_package_name => PACKAGE_NAME , p_procedure_name=> 'short_list_diagrams' ); cdwpbase.reset_found; htp.htmlOpen; htp.headOpen; cdwp.write_about(package_name, revision_label); cdwp.include_report_styles; htp.title(cdwpbase.get_el_name ( p_el_id => odwactxt.get_folder_irid , p_el_type_of => 'APP' ) ||' - '||diagram_title(l_dia_type)||'s' ); htp.headClose; htp.bodyOpen(cattributes=>'BGCOLOR="#FFFFFF"'); cdwp.menu_bar ( p_level => 2 , p_el_short_name=> 'DIA' , p_el_id => null ); cdwp.heading(2); cdwp.p ( cdwp.add_images('{'||cdwpbase.get_icon('DIA')||'}') ||diagram_title(l_dia_type)||'s' , p_style => 'reptitle' ); htp.nl; -- -- if the number of diagrams is large and there is more than one type -- then we should include a menu with hyperlinks for each of the diagram types -- BOOKMARKS are already provided (, for example: ERD, DFD) -- /* cdwp.link( p_app_name => p_app_name , p_app_version => p_app_version , p_one_file => p_one_file , p_static => p_static , p_element_type => 'DIA' , p_procedure => 'cdwp_dia.short_list_diagrams' , p_element_name => '#'|| , p_text => cdwp.add_images('{'||p_gif||'}', p_static) ||p_title ) */ -- list -- -- 1.2 cdwpbase.get_ivid_list ( p_app_id => odwactxt.get_folder_irid , p_ci_view_name => 'CI_DIAGRAMS' , p_order_by => 'NAME' , p_descriptor_column => 'NAME' , p_do_vlabel => true ); diagram_type( 'ERD', ROB_msg.getMsg(Rob_msg.DSP117_CDWP_ERD, '', '', '', ''), 'entity_relationship_diagrammer.gif'); diagram_type( 'FHD', ROB_msg.getMsg(Rob_msg.DSP118_CDWP_FHD, '', '', '', ''),'fh_diagram.gif'); diagram_type( 'BPA', ROB_msg.getMsg(Rob_msg.DSP119_CDWP_BPM, '', '', '', ''),'bpa_diagram.gif'); diagram_type( 'MXD', ROB_msg.getMsg(Rob_msg.DSP123_CDWP_MXD, '', '', '', ''), 'matrix_diagram.gif'); diagram_type( 'DFD', ROB_msg.getMsg(Rob_msg.DSP122_CDWP_DFD, '', '', '', ''),'dataflow_diagrammer.gif'); diagram_type( 'MDD', ROB_msg.getMsg(Rob_msg.DSP120_CDWP_MDD, '', '', '', ''),'mdd_diagram.gif'); diagram_type( 'DSD', ROB_msg.getMsg(Rob_msg.DSP121_CDWP_DSD, '', '', '', ''),'data_diagram.gif'); cdwpbase.write_no_found( p_message => ROB_msg.getMsg(Rob_msg.MSG211_CDWP_TITLENOTFOUND,diagram_title(l_dia_type),'','','')); htp.bodyClose; htp.htmlClose; end short_list_diagrams; function get_diagram_gif ( p_dia_type in varchar2 ) return varchar2 is begin return cdwpbase.ifThenElse ( p_dia_type = 'ERD' , 'entity_relationship_diagrammer.gif' , cdwpbase.ifThenElse ( p_dia_type = 'FHD' , 'fh_diagram.gif' , cdwpbase.ifThenElse ( p_dia_type = 'BPA' , 'bpa_diagram.gif' -- process_model_diagrammer.gif' , cdwpbase.ifThenElse ( p_dia_type = 'MXD' , 'matrix_diagram.gif' , cdwpbase.ifThenElse ( p_dia_type = 'DFD' , 'dataflow_diagrammer.gif' , cdwpbase.ifThenElse ( p_dia_type = 'DSD' , 'data_diagram.gif' , cdwpbase.ifThenElse ( p_dia_type = 'MDD' , 'mdd_diagram.gif' , 'diagram.gif' ) -- MDD ) -- DSD ) -- DFD ) -- MXD ) -- BPA ) -- FHD ); -- ERD end; -- get_diagram_gif function get_diagram_plural ( p_dia_type in varchar2 ) return varchar2 is begin return cdwpbase.ifThenElse ( p_dia_type = 'ERD' , ROB_msg.getMsg(Rob_msg.DSP117_CDWP_ERD, '', '', '', '') , cdwpbase.ifThenElse ( p_dia_type = 'FHD' , ROB_msg.getMsg(Rob_msg.DSP118_CDWP_FHD, '', '', '', '') , cdwpbase.ifThenElse ( p_dia_type = 'BPA' , ROB_msg.getMsg(Rob_msg.DSP119_CDWP_BPM, '', '', '', '') , cdwpbase.ifThenElse ( p_dia_type = 'MXD' , ROB_msg.getMsg(Rob_msg.DSP123_CDWP_MXD, '', '', '', '') , cdwpbase.ifThenElse ( p_dia_type = 'DFD' , ROB_msg.getMsg(Rob_msg.DSP122_CDWP_DFD, '', '', '', '') , cdwpbase.ifThenElse ( p_dia_type = 'DSD' , ROB_msg.getMsg(Rob_msg.DSP121_CDWP_DSD, '', '', '', '') , cdwpbase.ifThenElse ( p_dia_type = 'MDD' , ROB_msg.getMsg(Rob_msg.DSP120_CDWP_MDD, '', '', '', '') , 'Diagrams' ) -- MDD ) -- DSD ) -- DFD ) -- MXD ) -- BPA ) -- FHD ); -- ERD end; -- get_diagram_plural function get_dia_type ( p_irid in number ) return varchar2 is cursor c_dia(b_irid in number) is select dia.diagram_type diagram_type from i$sdd_dia dia where dia.irid = b_irid ; r_dia c_dia%rowtype; begin open c_dia( b_irid => p_irid); fetch c_dia into r_dia; close c_dia; return r_dia.diagram_type; end; -- get_dia_type -- this procedure produces a list of diagrams the indicated element p_el_id is part of procedure list_in_diagrams ( p_el_id in number default odwactxt.get_pac_irid -- irid of element we want diagram usages for ) is cursor c_dia(b_el_id in number) is select dia.name name , dia.diagram_type diagram_type , dia.irid , dia.irid id , dia.ivid , decode( dia.diagram_type , 'ERD', 'entity_relationship_diagrammer.gif' , 'FHD', 'fh_diagram.gif' , 'BPA', 'bpa_diagram.gif' -- process_model_diagrammer.gif' , 'MXD', 'matrix_diagram.gif' , 'DFD', 'dataflow_diagrammer.gif' , 'DSD', 'data_diagram.gif' , 'MDD', 'mdd_diagram.gif' , 'diagram.gif' ) gif_file from i$sdd_deu deu , i$sdd_dia dia where deu.cielement_ref = b_el_id and deu.diagram_ref = dia.irid and dia.ivid = cdwpbase.get_best_ivid( dia.irid) and deu.parent_ivid = dia.ivid order by dia.name ; l_first boolean := true; begin cdwp.bookmark('DEU'||to_char(p_el_id)); -- BOOKMARK cdwp.tableOpen('BORDER="0"'); l_first := true; for r_dia in c_dia(b_el_id => p_el_id) loop if l_first then cdwp.tableRowOpen; cdwp.TableDataHeading(Rob_msg.Getmsg(Rob_msg.DSP271_CDWP_INDIAGRAM,'','','','')); htp.print(''); cdwp.tableRowOpen; cdwp.TableDataValue('', 1); cdwp.tableRowClose; l_first := false; end if; cdwp.tableRowOpen; cdwp.TableDataHeading(''); -- 1,4 cdwp.tabledatavalue ( cdwp.report_link ( p_el_id => r_dia.id , p_ivid => r_dia.ivid , p_type_of => 'DIA' , p_text => cdwp.add_images (p_text => '{'||r_dia.gif_file||'}' ||' '||r_dia.name -- 3.3 removed: ||' '||r_dia.diagram_type ) ) ); cdwp.tableRowClose; end loop; -- r_dia if not l_first then cdwp.tableclose; htp.nl; end if; -- not l_first end list_in_diagrams; procedure list_diagram_elements is cursor c_deu ( b_dia_irid in number default odwactxt.get_pac_irid , b_dia_ivid in number default odwactxt.get_pac_ivid ) is select deu.cielement_reference el_id , deu.element_type_for el_type_of , jr_name.get_crn_from_irid ( deu.cielement_reference , 'NAME' , 0 ) name from ci_diagram_element_usages deu , pie_element_types pie where deu.diagram_reference = b_dia_irid and deu.parent_ivid = b_dia_ivid and pie.short_name = deu.element_type_for order by el_type_of , name ; l_first boolean := true; begin cdwp.bookmark('DEU'||to_char(odwactxt.get_pac_irid)); -- BOOKMARK l_first := true; for r_deu in c_deu ( b_dia_irid => odwactxt.get_pac_irid , b_dia_ivid => odwactxt.get_pac_ivid ) loop if l_first then cdwp.tableOpen('BORDER="0"'); cdwp.tableRowOpen; cdwp.TableDataHeading(Rob_msg.Getmsg(Rob_msg.DSP132_CDWP_DELEM,'','','','')); htp.print(''); cdwp.tableRowOpen; cdwp.TableDataValue('', 1); cdwp.tableRowClose; l_first := false; end if; cdwp.tableRowOpen; cdwp.TableDataHeading(''); cdwp.tabledatavalue ( cdwp.report_link ( p_el_id => r_deu.el_id , p_type_of => r_deu.el_type_of , p_text => '{gif}'||r_deu.name ) ); cdwp.tableRowClose; end loop; -- r_deu if not l_first then cdwp.tableclose; htp.nl; end if; -- not l_first end list_diagram_elements; function get_diagram_id ( p_app_name in varchar2 ,p_app_version in number default null ,p_dia_name in varchar2 ) return number is l_dia_id number(38); begin select dia.id into l_dia_id from ci_diagrams dia where dia.name like upper(p_dia_name) ; return l_dia_id; exception when others then return null; end get_diagram_id; procedure icon_bar ( p_irid in number default odwactxt.get_pac_irid , p_ivid in number default odwactxt.get_pac_ivid ) is begin odwarprt.init_short_cut_bar; cdwp.tableOpen('BORDER="0"'); cdwp.tableRowOpen; if odwaxist.exists_detail ( p_pac_irid => p_irid , p_pac_ivid => p_ivid , p_ref_column => 'DIAGRAM_REFERENCE' , p_el_type_of => 'DEU' ) then odwarprt.show_anchor ( p_anchor_name => 'deu'||to_char(p_irid) , p_gif => 'diagram.gif' , p_title => ROB_msg.getMsg(Rob_msg.DSP132_CDWP_DELEM, '', '', '', '') ); end if; -- DEU -- multiline text if cdwp.exists_mlt( p_id => p_irid, p_not_include1 => 'CDIDSC') then odwarprt.show_anchor ( p_anchor_name => 'dia_mlt'||to_char(p_irid) , p_gif => 'mlt.gif' , p_title =>ROB_msg.getMsg(Rob_msg.DSP131_CDWP_MLT, '', '', '', '') ); end if; cdwp.tableRowClose; cdwp.tableClose; htp.nl; end icon_bar; procedure list_diagrams ( p_session_id in number , p_irid in number default null , p_ivid in number default null ) is l_anchor_ctr number(2):=0; l_first boolean; l_menu_bar varchar2(5000); l_dia_notes varchar2(32000); l_pos_kw number(5); l_file_ref varchar2(5000); l_file_ref_found boolean:= false; begin -- normal_list_diagrams odwactxt.update_context ( p_session_id => p_session_id , p_package_name => PACKAGE_NAME , p_procedure_name=> 'list_diagrams' , P_PAC_IRID => cdwpbase.ifThenElse( p_ivid is not null, cdwpbase.get_irid( p_ivid), p_irid) , P_PAC_IvID => p_ivid , P_PAC_TYPE_ID => 4941 -- cdwpbase.short_name_to_type_id('DIA') ); cdwpbase.start_timer; htp.htmlOpen; htp.headOpen; -- 1.2 cdwp.write_about(package_name, revision_label); cdwp.include_report_styles; if odwactxt.get_one_file = 'Y' then htp.title ( cdwpbase.get_el_name ( p_el_id => odwactxt.get_folder_irid , p_el_type_of => 'APP' ) ||' - Diagrams' ); else htp.title ( cdwpbase.get_el_name ( p_el_id => odwactxt.get_folder_irid , p_el_type_of => 'APP' ) ||' - Diagrams - ' ||cdwpbase.get_el_name( p_el_id => p_irid, p_el_type_of => 'DIA') ); end if; htp.headClose; htp.bodyOpen(cattributes=>'BGCOLOR="#FFFFFF"'); cdwpbase.open_timer_form; if odwactxt.get_one_file = 'Y' then cdwp.menu_bar ( p_level => 2 , p_el_short_name=> 'DIA' , p_el_id => null ); cdwp.heading(2); cdwp.p ( cdwp.add_images('{'||cdwpbase.get_icon('DIA')||'}') ||'Diagrams' , p_style => 'reptitle' ); cdwp.tableOpen; cdwpbase.get_ivid_list ( p_app_id => odwactxt.get_folder_irid , p_ci_view_name => 'CI_DIAGRAMS' , p_order_by => 'NAME' , p_descriptor_column => 'NAME' ); for i in 1..cdwpbase.g_ividTab.count loop cdwp.tableRowOpen; cdwp.TableDataHeading(null); -- 2.1 cdwp.TableDataValue ( cdwpbase.local_link ( p_bookmark => cdwpbase.g_nameTab(i) , p_text => '{gif}'||cdwpbase.g_nameTab(i) , p_el_id => cdwpbase.g_iridTab(i) , p_type_of => 'DIA' ) ); cdwp.tableRowClose; end loop; cdwp.tableClose; htp.nl; htp.nl; else cdwpbase.get_ivid_list ( p_ivid => nvl( p_ivid, cdwpbase.get_ivid( p_irid)) ); end if; -- odwactxt.get_one_file = 'Y' for i in 1..cdwpbase.g_ividTab.count loop open c_dia( b_dia_ivid => cdwpbase.g_ividTab(i)); fetch c_dia into r_dia; close c_dia; odwactxt.update_context ( P_PAC_IRID => r_dia.id , P_PAC_IvID => cdwpbase.g_ividTab(i) , p_new_request => false ); g_dia_name:= r_dia.name; l_anchor_ctr:= 0; -- look for filename in Diagram Notes l_dia_notes:= cdwp_txt.get_mlt_block ( p_el_id => r_dia.id , p_text_type => 'CDINOT' , p_size => 32000 , p_start_pos => 1 ); cdwp.menu_bar ( p_level => 2 , p_el_short_name=> 'DIA' , p_el_id => r_dia.id ); cdwp.heading(3); cdwp.p ( cdwp.add_images('{'||cdwpbase.get_icon('DIA')||'}') ||r_dia.name||' - '||r_dia.title , p_style => 'partitle' ); cdwp.bookmark(r_dia.name); htp.nl; icon_bar ( P_IRID => r_dia.id , P_IvID => cdwpbase.g_ividTab(i) ); htp.nl; cdwp.tableOpen('BORDER="0"'); odwavrsn.version_status; cdwpbase.app_summary ( p_el_id => r_dia.id ); cdwp_txt.display_mlt ( p_el_id => r_dia.id ,p_txt_type => 'CDIDSC' ,p_mlt_prompt_name => 'Description' ,p_replace_entities => true ,p_replace_tables => true ,p_max_lines => null ,p_el_type => 'DIA' ); cdwp.tableClose; htp.nl; list_diagram_elements; if cdwp.exists_mlt( p_id => r_dia.id) then cdwp.bookmark('DIA_MLT'||to_char(r_dia.id)); -- BOOKMARK cdwp.tableOpen('BORDER="0"'); cdwp.tableRowOpen; cdwp_txt.display_all_mlt ( p_el_id => r_dia.id , p_max_lines => null , p_do_not_display1 => 'CDIDSC' , p_el_type => 'DIA' ); cdwp.tableRowClose; cdwp.tableClose; end if; -- cdwp.exists_mtl end loop; -- r_dia cdwpbase.write_timer; htp.formClose; htp.bodyClose; htp.htmlClose; end list_diagrams; end cdwp_dia; /