-- {{ $Header: \\ukst76\rcsroot.7_0\model\jin\config\RCS\jricfgd.jpb 40.7 1998/12/17 11:12:35 wstallar Exp wstallar $ -- {{ ------------------------------------------------------------------------ -- File: $Workfile: jrpbcfgd.sql $ -- Author: $Author: wstallar $ -- Date: $Date: 1998/12/17 11:12:35 $ -- Version: $Revision: 40.7 $ -- Status: $State: Exp $ -- Locked_by: $Locker: wstallar $ -- Project: The Oracle Common Repository -- Description: PL/SQL for Configuration Definition - Body -- Notes: -- RealAuth: dcaruana -- IncepDate: 1/15/1998 -- Copyright: (c) Oracle Corporation 1997. All Rights Reserved. -- Tagline: -- Oracle Repository: Managing *all* your data -- -- ---------------------------------------------------------------------------- -- Log of Changes from Source Control System -- ---------------------------------------------------------------------------- -- $Log: jricfgd.jpb $ -- Revision 40.7 1998/12/17 11:12:35 wstallar -- 780836 ALLOW POPULATION OF CONFIG FROM TEXT-BASED LIST OF RULES -- Added populate_from_spec(). -- -- Revision 40.6 1998/10/08 11:16:30 cwilliam -- removed obsolete code -- -- Revision 40.5 1998/07/03 17:31:45 cwilliam -- use functions to generate irid, ivid values -- -- Revision 40.4 1998/06/24 14:25:39 rmolland -- Missing declaration fix -- -- Revision 40.3 1998/06/11 10:21:35 rmolland -- Updated jr_config_def.add_member so that a configuration cannot be added to another configuration (i.e. prevent nested configurations) -- -- Revision 40.2 1998/05/27 13:07:57 eharding -- Moved reference JR_* PL/SQL from ClearCase -- -- -- Rev 1.2 15 Jan 1998 16:38:02 dcaruana -- Remove explicit maintenance of i$object_versions -- -- Rev 1.1 15 Jan 1998 13:55:40 dcaruana -- Add Header -- }} ------------------------------------------------------------------------ -- prompt Package Body: jr_configuration_def create or replace package body jr_configuration_def is -- package variable to make common functions simpler constraints_were_enabled boolean; -- -- Private Function Prototypes -- -- Helpers procedure add_children(config_irid in number ,config_ivid in number ,object_irid in number ,object_ivid in number ,ref_kind in varchar2); procedure remove_children(config_irid in number ,config_ivid in number ,object_irid in number); function get_children(config_ivid in number ,object_ivid in number) return jr_name.objver_list; procedure check_config_exists(config_irid in number,config_ivid in number) is dummy number; begin select irid into dummy from I$SDD_CONFIGURATIONS where (config_irid is NULL OR irid=config_irid) and config_ivid=ivid; exception when NO_DATA_FOUND then --Configuration with IVID = %0!s does not exist. rmmes.post('CDR',104,TO_CHAR(config_ivid)); raise INVALID_CONFIG; end; --------------------------------------------------------------- -- start_update_config_members -- -- Record setting of constraints, check that the workarea is -- valid and that the user has access rights to update. --------------------------------------------------------------- procedure start_update_config_members ( config_irid in number , config_ivid in number , workarea_id in number default -1 ) is begin -- Record the constraints setting constraints_were_enabled := jr_context.constraints_enabled; --Check config OK for update. check_config_for_update(config_irid,config_ivid); --Disable constraints before inserting into config jr_context.disable_constraints; end; --------------------------------------------------------------- -- end_update_config_members -- -- Update the config NOTM flag and reset constraints flag --------------------------------------------------------------- procedure end_update_config_members ( config_ivid in number , in_error in boolean := false ) is begin if not in_error then -- update the config's NOTM flag since there are no SAC triggers on CM's update i$sdd_object_versions o set o.obj_notm = o.obj_notm + 1 where o.ivid = config_ivid; -- -- CM's can NOT have any dependents (such app logic, MLT etc) and -- can NOT be a dependency (as in Dependency Management) so no -- special delete processing required, phew lucky! -- end if; --Re-enable constraints, if necessary. if constraints_were_enabled then jr_context.enable_constraints; end if; end; -- -- Public Functions -- ------------------------------------------------------------- -- jr_configuration_def.CHECK_CONFIG_FOR_UPDATE() -- -- Test if configuration is OK for update -- operations. Will raise exceptions and post appropriate -- errors. ------------------------------------------------------------- procedure check_config_for_update(config_irid in number ,config_ivid in number ,object_irid in number default NULL ,object_ivid in number default NULL) is config_kind varchar2(32); config_name varchar2(300); object_name varchar2(300); n_objConfig number; begin -- Check config is valid check_config_exists(config_irid,config_ivid); -- Check that configuration is not checked-in (cannot alter checked-in configs) if jr_version.is_checked_in(config_irid,config_ivid) then --Configuration %0!s is checked in. select name into config_name from I$SDD_CONFIGURATIONS where ivid=config_ivid; rmmes.post('CDR',1041,config_name); RAISE ALTER_CONFIG_ERROR; end if; select kind into config_kind from I$SDD_CONFIGURATIONS where ivid=config_ivid; --Check access rights for 'ordinary configs' --don't check ar for private/sytem configs - --these are created when creating/compiling --workareas - and user may have access rights --on workarea, but not config. if config_kind is null then --Check user can manage configurations jr_sys_privs.check_manage(USER,'CFG'); --Check user has UPD access rights on configuration if not jr_acc_rights.has_access(config_irid,USER,'UPD') then --Insufficient access rights to update configuration rmmes.post('CDR',2068); raise jr_acc_rights.ACCESS_RIGHTS_ERROR; end if; end if; --If we have an object irid and ivid, then check it's OK to add... if object_ivid is not null then -- Check that object being added IS checked in. if ((config_kind is NULL) or (config_kind!='PRIVATE')) and (NOT jr_version.is_checked_in(object_irid,object_ivid)) then object_name:=jr_name.get_CRN(object_ivid,'NAME'); --Cannot add %0!s to configuration. Version not checked in. rmmes.post('CDR',1042,object_name); RAISE ALTER_CONFIG_ERROR; end if; -- check to make sure the given irid is not a configuration (no nested -- configurations allowed) select COUNT(*) into n_objConfig from i$sdd_configurations where irid = object_irid; if n_objConfig > 0 then --Nested configurations are illegal rmmes.post('CDR',1043); RAISE ALTER_CONFIG_ERROR; end if; end if; end; ------------------------------------------------------------------------- --- jr_configuration_def.CREATE_CONFIGURATION() --- --- Creates a new configuration. -------------------------------------------------------------------------- procedure create_configuration( config_name in varchar2, config_irid out number, config_ivid out number, description in varchar2 := NULL) is new_irid number; new_ivid number; ar_irid number; existing_name I$SDD_CONFIGURATIONS.NAME%TYPE; begin -- Check user can manage confiurations jr_sys_privs.check_manage(USER,'CFG'); if config_name is null then --Configuration names cannot be NULL rmmes.post('CDR',1049); raise ALTER_CONFIG_ERROR; end if; -- Retrieve new irid and ivid new_irid := jr_util.get_new_irid; new_ivid := jr_system_util.get_new_ivid; --Check that the name is unique select MIN(cfg.name) into existing_name from I$SDD_CONFIGURATIONS cfg ,I$SDD_OBJECT_VERSIONS ov where NLS_UPPER(cfg.name)=NLS_UPPER(config_name) and ov.ivid=cfg.ivid and ov.wastebasket='N'; if existing_name is not null then --Configuration with name %0!s already exists. rmmes.post('CDR',1044,existing_name); raise CREATE_CONFIG_ERROR; end if; insert into i$sdd_configurations (irid, ivid, name, description) values (new_irid, new_ivid, config_name, description); --Create access rights on config (could do this in a trigger) ar_irid:=jr_acc_rights.ins(new_irid ,'CFG' ,jr_acc_rights.full_access_rights); -- Assign out parameters config_irid := new_irid; config_ivid := new_ivid; end create_configuration; ------------------------------------------------------------------------- --- jr_configuration_def.REMOVE_CONFIGURATION() --- --- Deletes a non-versioned or checked-out configuration. -------------------------------------------------------------------------- procedure remove_configuration( config_irid in number, config_ivid in number ) is nls_type_name varchar2(240); begin --Check manage of config is allowed jr_sys_privs.check_manage(USER,'CFG'); --Check user has access rights to delete config if not jr_acc_rights.has_access(config_irid,USER,'DEL') then --Insufficient access rights to delete configuration. rmmes.post('CDR',2609); RAISE ALTER_CONFIG_ERROR; end if; -- Delete configuration -- Put config in wastebasket, unless config is a private/system config, -- in which case, we delete it straight away... jr_wastebasket.remove(config_ivid); exception when OTHERS then select nls.nls_name into nls_type_name from rm_element_type_extensions nls where nls.for_type=384781276385787681422765648005056569; --CDR-2000 Cannot delete %0!s %1!s rmmes.post('CDR',2000,nls_type_name,jr_name.get_CRN(config_ivid,'NAME')); raise; end remove_configuration; ------------------------------------------------------------------------- --- jr_configuration_def.RENAME_CONFIGURATION() --- --- Changes the name of the configuration. -------------------------------------------------------------------------- procedure rename_configuration(config_irid in number ,config_ivid in number ,new_name in varchar2) is existing_name I$SDD_CONFIGURATIONS.NAME%TYPE; begin if new_name is null then --Configuration names cannot be NULL rmmes.post('CDR',1049); raise ALTER_CONFIG_ERROR; end if; --Check update of config allowed check_config_for_update(config_irid,config_ivid); --Check that new name is unique select MIN(cfg.name) into existing_name from I$SDD_CONFIGURATIONS cfg ,I$SDD_OBJECT_VERSIONS ov where NLS_UPPER(cfg.name)=NLS_UPPER(new_name) and ov.ivid=cfg.ivid and ov.wastebasket='N' and cfg.irid!=config_irid;--Allow renaming of config to same name as --another version of the same config if existing_name is not null then --Configuration with name %0!s already exists rmmes.post('CDR',1044,existing_name); raise ALTER_CONFIG_ERROR; end if; update I$SDD_CONFIGURATIONS set name = new_name where ivid = config_ivid; end rename_configuration; ------------------------------------------------------------------------- --- jr_configuration_def.CHANGE_CONFIGURATION_DESC() --- --- Changes the description of the configuration. -------------------------------------------------------------------------- procedure change_configuration_desc(config_irid in number ,config_ivid in number ,new_desc in varchar2) is begin --Check update of config allowed check_config_for_update(config_irid,config_ivid); update I$SDD_CONFIGURATIONS set description = new_desc where ivid = config_ivid; end change_configuration_desc; ------------------------------------------------------------------------- --- jr_configuration_def.ADD_MEMBER() --- --- Adds specified object to configuration, if possible. --- If object is a container and RECURSE is TRUE, then add all children -------------------------------------------------------------------------- procedure add_member( config_irid in number, config_ivid in number, object_irid in number, object_ivid in number, ref_kind in varchar2 default null, recurse in boolean default FALSE) is config_name varchar2(256); obj_path varchar2(500); begin constraints_were_enabled:=jr_context.constraints_enabled; -- Check that the configuration is valid for update check_config_for_update(config_irid,config_ivid,object_irid,object_ivid); -- Need SELECT access rights on object to add to a configuration if jr_acc_Rights.can_sel(object_ivid) = 'N' then return; end if; -- Disable constraint checking on insert into config. jr_context.disable_constraints; -- create member assignment begin insert into i$sdd_configuration_members (config_irid ,config_ivid ,object_irid ,object_ivid ,kind) values (add_member.config_irid ,add_member.config_ivid ,add_member.object_irid ,add_member.object_ivid ,add_member.ref_kind); exception when DUP_VAL_ON_INDEX then select name into config_name from I$SDD_CONFIGURATIONS where ivid=config_ivid; obj_path:=jr_name.get_path(object_ivid,'NAME'); --Object %0!s is already in configuration %1!s rmmes.post('CDR',1045,obj_path,config_name); raise ALTER_CONFIG_ERROR; end; --If recurse option is set to true, and the object is a container element, --then also add all it's children... if recurse then add_children(config_irid,config_ivid,object_irid,object_ivid,ref_kind); end if; -- tidy up end_update_config_members(config_ivid); exception when OTHERS then end_update_config_members(null, in_error=>true); RAISE; end add_member; ------------------------------------------------------------------------- --- jr_configuration_def.ADD_CHILDREN() --- --- PRIVATE HELPER METHOD --- Adds children of specifed container element to configuration -------------------------------------------------------------------------- procedure add_children( config_irid in number, config_ivid in number, object_irid in number, object_ivid in number, ref_kind in varchar2) is object_kind varchar2(30); children jr_name.objver_list:=jr_name.objver_list(); branch_id number; i number; child_ivid number; ci_state varchar2(1); begin select et2.short_name into object_kind from RM_ELEMENT_TYPES et1 ,RM_ELEMENT_TYPES et2 ,I$SDD_OBJECT_VERSIONS ov where et2.irid=et1.supertypes and et1.irid=ov.logical_type_id and ov.ivid=object_ivid; --Can only get children for container elements! if object_kind!='CEL' then return; end if; --If we have a workarea context set, then use it to determine the children if jr_context.workarea is not null then children:=jr_name.folder_contents(object_ivid,TRUE); else --Otherwise, get the latest versions on main branch... branch_id:=jr_version.get_branch_id('MAIN'); children:=jr_name.folder_latest_contents(object_ivid,branch_id,TRUE); end if; --Add the children to the config.... i:=children.first; while i is not null loop --Need to check the state of the object we're adding select ov.state into ci_state from I$SDD_OBJECT_VERSIONS ov where ov.ivid=children(i).ivid; if ci_state='O' then --Child is checked out, so get the checked in version child_ivid:=jr_version.get_original_of_checkout(children(i).irid ,children(i).ivid); else child_ivid:=children(i).ivid; end if; --Just skip over any non-versioned children... if ci_state != 'N' then begin insert into i$sdd_configuration_members (config_irid ,config_ivid ,object_irid ,object_ivid ,kind) values (add_children.config_irid ,add_children.config_ivid ,children(i).irid ,child_ivid ,add_children.ref_kind); exception when DUP_VAL_ON_INDEX then --Skip over any duplicates NULL; end; end if; i:=children.next(i); end loop; end; ------------------------------------------------------------------------- --- jr_configuration_def.REMOVE_MEMBER() --- --- Removes specified object from configuration, if possible. --- If object is a container and RECURSE is TRUE, then remove all children -------------------------------------------------------------------------- procedure remove_member( config_irid in number, config_ivid in number, object_irid in number, recurse in boolean default FALSE) is config_name varchar2(256); dummy integer; begin -- Do initial checks and setup start_update_config_members(config_irid, config_ivid); --Check object really is a member of the configuration select COUNT(*) into dummy from I$SDD_CONFIGURATION_MEMBERS cm where cm.config_ivid=remove_member.config_ivid and cm.object_irid=remove_member.object_irid; if dummy = 0 then select name into config_name from I$SDD_CONFIGURATIONS where ivid=config_ivid; --No such object exists in configuration %1!s rmmes.post('CDR',112,config_name); raise ALTER_CONFIG_ERROR; end if; -- remove member assignment delete from i$sdd_configuration_members cm where cm.config_irid = remove_member.config_irid and cm.config_ivid = remove_member.config_ivid and cm.object_irid = remove_member.object_irid; --If recurse option is set to true, and the object is a container element, --then also remove all it's children... if recurse then remove_children(config_irid,config_ivid,object_irid); end if; -- tidy up end_update_config_members(config_ivid); exception when OTHERS then end_update_config_members(null, in_error=>true); RAISE; end remove_member; ------------------------------------------------------------------------- --- jr_configuration_def.REMOVE_CHILDREN() --- --- PRIVATE HELPER METHOD --- Removes children of specifed container element from configuration -------------------------------------------------------------------------- procedure remove_children( config_irid in number, config_ivid in number, object_irid in number) is object_ivid number; object_kind varchar2(30); children jr_name.objver_list:=jr_name.objver_list(); i number; begin select ov.ivid,et2.short_name into object_ivid,object_kind from RM_ELEMENT_TYPES et1 ,RM_ELEMENT_TYPES et2 ,I$SDD_OBJECT_VERSIONS ov ,I$SDD_CONFIGURATION_MEMBERS cm where et2.irid=et1.supertypes and et1.irid=ov.logical_type_id and ov.ivid=cm.object_ivid and cm.object_irid=remove_children.object_irid and cm.config_ivid=remove_children.config_ivid; --Can only remove children for container elements! if object_kind!='CEL' then return; end if; --Get hold of the children children:=get_children(config_ivid,object_ivid); --Remove the children from the config.... i:=children.first; while i is not null loop delete i$sdd_configuration_members cm where cm.object_ivid=children(i).ivid and cm.config_ivid=remove_children.config_ivid; i:=children.next(i); end loop; end; ------------------------------------------------------------------------- --- jr_configuration_def.GET_CHILDREN() --- --- PRIVATE HELPER METHOD --- Retrieves children of specifed container element in configuration -------------------------------------------------------------------------- function get_children( config_ivid in number, object_ivid in number) return jr_name.objver_list is contents jr_name.objver_list:=jr_name.objver_list(); sub_contents jr_name.objver_list:=jr_name.objver_list(); i number; --Cursor to get hold of children in config. cursor list_children is select ov.irid as ov_irid,ov.ivid as ov_ivid, tab.name as ov_tab from I$SDD_OBJECT_VERSIONS ov ,I$SDD_FOLDER_MEMBERS fm ,I$SDD_CONFIGURATION_MEMBERS cm ,RM_SQL_TABLES tab where cm.object_irid = fm.member_object and ov.ivid=cm.object_ivid and cm.config_ivid=get_children.config_ivid and fm.parent_ivid = get_children.object_ivid and tab.id = ov.table_irid; begin for children in list_children loop --Add each of the children to contents contents.extend(); contents(contents.last).irid:=children.ov_irid; contents(contents.last).ivid:=children.ov_ivid; --Recurse through any sub-folders if (children.ov_tab='SDD_FOLDERS') then sub_contents:=get_children(config_ivid,children.ov_ivid); i:=sub_contents.first; -- Add the sub-folder contents to our list while i IS NOT NULL loop contents.extend(); contents(contents.last).irid:=sub_contents(i).irid; contents(contents.last).ivid:=sub_contents(i).ivid; i:=sub_contents.next(i); end loop; end if; end loop; return contents; end; ------------------------------------------------------------------------- --- jr_configuration_def.REMOVE_ALL_MEMBERS() --- --- Removes all objects from the configuration. -------------------------------------------------------------------------- procedure remove_all_members(config_irid in number ,config_ivid in number) is begin -- Do initial checks and setup start_update_config_members(config_irid, config_ivid); -- remove all member assignments for the specified configuration delete from i$sdd_configuration_members cm where cm.config_irid = remove_all_members.config_irid and cm.config_ivid = remove_all_members.config_ivid; -- tidy up end_update_config_members(config_ivid); exception when OTHERS then end_update_config_members(null, in_error=>true); RAISE; end remove_all_members; --------------------------------------------------------------- -- jr_configuration_def.MERGE_CONFIGS() -- -- Procedure adds any members in the source config that are -- not in the target config to the target. --------------------------------------------------------------- procedure merge_configs(target_ivid in number, source_ivid in number) is target_irid number; cursor source_members is select object_irid, object_ivid, kind from I$SDD_CONFIGURATION_MEMBERS where config_ivid=source_ivid; begin --Get hold of target irid. begin select irid into target_irid from I$SDD_CONFIGURATIONS where ivid = target_ivid; exception when NO_DATA_FOUND then --Configuration with IVID = %0!s does not exist. rmmes.post('CDR',104,TO_CHAR(100)); raise INVALID_CONFIG; end; -- Do initial checks and setup start_update_config_members(target_irid, target_ivid); --Check source is valid check_config_exists(NULL,source_ivid); for source in source_members loop begin --Insert into tables directly for performance insert into i$sdd_configuration_members (config_irid ,config_ivid ,object_irid ,object_ivid ,kind) values (target_irid ,target_ivid ,source.object_irid ,source.object_ivid ,source.kind); exception when DUP_VAL_ON_INDEX then --Simply skip over any duplicates... NULL; end; end loop; -- tidy up end_update_config_members(target_ivid); exception when OTHERS then end_update_config_members(null, in_error=>true); RAISE; end; --------------------------------------------------------------- -- jr_configuration_def.SUBTRACT_CONFIGS() -- -- Procedure remove any members from the target config that -- are in the source config. --------------------------------------------------------------- procedure subtract_configs(target_ivid in number, source_ivid in number) is target_irid number; cursor source_members is select object_irid, object_ivid from I$SDD_CONFIGURATION_MEMBERS where config_ivid=source_ivid; begin --Get hold of target irid. begin select irid into target_irid from I$SDD_CONFIGURATIONS where ivid = target_ivid; exception when NO_DATA_FOUND then --Configuration with IVID = %0!s does not exist. rmmes.post('CDR',104,TO_CHAR(100)); raise INVALID_CONFIG; end; -- Do initial checks and setup start_update_config_members(target_irid, target_ivid); --Check source is valid check_config_exists(NULL,source_ivid); for source in source_members loop --Delete directly from table for performance --(avoid error checking overhead in remove member). delete from i$sdd_configuration_members cm where cm.config_irid = target_irid and cm.config_ivid = target_ivid and cm.object_ivid = source.object_ivid; end loop; -- tidy up end_update_config_members(target_ivid); exception when OTHERS then end_update_config_members(null, in_error=>true); RAISE; end; --------------------------------------------------------------- -- jr_configuration_def.POPULATE_FROM_WORKAREA -- -- Procedure adds members of the specified workarea to a -- configuration. If workarea members are checked-out, then -- the checked-in versions are added. Workarea members not -- under change control are skipped. -- Optionally, just the 'private' members of the workarea --------------------------------------------------------------- procedure populate_config_from_workarea(config_irid in number ,config_ivid in number ,workarea_id in number ,private_only in boolean default FALSE) is begin --Check workarea is valid. jr_workarea.check_workarea_exists(workarea_id); -- Do initial checks and setup start_update_config_members(config_irid, config_ivid); -- Ensure the configuration is empty before populating it (B1293708) delete I$SDD_CONFIGURATION_MEMBERS cm where cm.config_ivid=populate_config_from_workarea.config_ivid; if private_only then --'Private' Objects in workarea insert into I$SDD_CONFIGURATION_MEMBERS ( config_irid , config_ivid , object_irid , object_ivid ) select config_irid , config_ivid , ov.irid , DECODE(ov.state, 'I', ov.ivid, jr_version.get_original_of_checkout(ov.irid,ov.ivid) ) from I$SDD_OBJECT_VERSIONS ov , I$SDD_WA_CONTEXT ctxt where ov.ivid = ctxt.object_ivid and ctxt.workarea_irid = workarea_id and ctxt.wastebasket = 'N' and ctxt.spec_entry is null and ( ov.state = 'I' or ov.state = 'O' ); else --Objects in entire workrea insert into I$SDD_CONFIGURATION_MEMBERS ( config_irid , config_ivid , object_irid , object_ivid ) select config_irid , config_ivid , ov.irid , DECODE(ov.state, 'I', ov.ivid, jr_version.get_original_of_checkout(ov.irid,ov.ivid) ) from I$SDD_OBJECT_VERSIONS ov , I$SDD_WA_CONTEXT ctxt where ov.ivid = ctxt.object_ivid and ctxt.workarea_irid = workarea_id and ctxt.wastebasket = 'N' and ( ov.state = 'I' or ov.state = 'O' ); end if; -- tidy up end_update_config_members(config_ivid); exception when OTHERS then end_update_config_members(null, in_error=>true); RAISE; end; --------------------------------------------------------------- -- jr_configuration_def.SUBTRACT_WORKAREA_FROM_CONFIG -- -- Procedure removes any members of the specified workarea that -- occur in the specified configuration from the configuration. -- If workarea members are checked-out, then the checked-in versions -- are removed. Workarea members not under change control are -- skipped. -- Optionally, just the 'private' members of the workarea --------------------------------------------------------------- procedure subtract_workarea_from_config(config_irid in number ,config_ivid in number ,workarea_id in number ,private_only in boolean:=FALSE) is begin --Check workarea is valid. jr_workarea.check_workarea_exists(workarea_id); -- Do initial checks and setup start_update_config_members(config_irid, config_ivid, workarea_id); if private_only then --'Private' Objects in workarea delete I$SDD_CONFIGURATION_MEMBERS cm where cm.config_ivid = config_ivid and cm.object_ivid in ( select ov.ivid from I$SDD_OBJECT_VERSIONS ov , I$SDD_WA_CONTEXT ctxt where ov.ivid = ctxt.object_ivid and ctxt.workarea_irid = workarea_id and ctxt.wastebasket = 'N' and ctxt.spec_entry is null and ( ov.state = 'I' or ov.state = 'O' ) ); else --Objects in entire workrea delete I$SDD_CONFIGURATION_MEMBERS cm where cm.config_ivid = config_ivid and cm.object_ivid in ( select ov.ivid from I$SDD_OBJECT_VERSIONS ov , I$SDD_WA_CONTEXT ctxt where ov.ivid = ctxt.object_ivid and ctxt.workarea_irid = workarea_id and ctxt.wastebasket = 'N' and ( ov.state = 'I' or ov.state = 'O' ) ); end if; -- tidy up end_update_config_members(config_ivid); exception when OTHERS then end_update_config_members(null, in_error=>true); RAISE; end; --------------------------------------------------------------- -- jr_configuration_def.POPULATE_FROM_SPEC() -- -- Procedure create a config by executing the -- rules supplied in a text-based spec. -- Format is: -- RULE_NAME(PARAM1_VALUE,PARAM2_VALUE,PARAM3_VALUE) -- OTHER_RULE(PARAM1_VALUE) -- etc.. -- May also MERGE/SUBTRACT other configs with this one -- using INCLUDE_CONFIG and EXCLUDE_CONFIG -- -- Spec may include comments, indicated by: -- '-- ', '//', '--', and '/*' '*/' --------------------------------------------------------------- procedure populate_from_spec(config_ivid in number ,spec in varchar2) is config_irid number; other_cfg_ivid number; rule varchar2(30); param1 varchar2(3000); param2 varchar2(3000); param3 varchar2(3000); l_spec varchar2(30000); rule_irid number; begin l_spec:=spec; --Check config OK for update. select irid into config_irid from I$SDD_CONFIGURATIONS where ivid=config_ivid; check_config_for_update(config_irid,config_ivid); --Ensure configuration is empty berfore trying to populate. delete I$SDD_CONFIGURATION_MEMBERS cm where cm.config_ivid=populate_from_spec.config_ivid; while l_spec is not null loop --Get hold of a rule and it's parameters from the spec jr_rule.parse_spec(l_spec ,rule ,param1 ,param2 ,param3); if rule in ('INCLUDE_CONFIG','EXCLUDE_CONFIG') then --Get the config specifed by the parameter other_cfg_ivid:=jr_name.get_vid(param1); if other_cfg_ivid is null then --Invalid config name --Failed to process rule specification rmmes.post('CDR',1006); raise SPEC_PARSE_ERROR; end if; if rule='INCLUDE_CONFIG' then --Merge specified config with this config merge_configs(config_ivid,other_cfg_ivid); elsif rule='EXCLUDE_CONFIG' then --Subtract specified config from this config subtract_configs(config_ivid,other_cfg_ivid); end if; else --Get hold of the ID for the rule rule_irid:=jr_rule.get_irid(rule); if rule_irid is null then --Failed to process rule specification rmmes.post('CDR',1006); raise SPEC_PARSE_ERROR; end if; --Execute the rule against the specified configuration. jr_rule.execute_rule(rule_irid ,config_ivid ,param1 ,param2 ,param3); end if; end loop; end populate_from_spec; --------------------------------------------------------------- -- jr_configuration_def.UPDATE_FROM_SPEC() -- -- Procedure adds members to a config by executing -- rules supplied in a text-based spec. -- Format is: -- RULE_NAME(PARAM1_VALUE,PARAM2_VALUE,PARAM3_VALUE) -- OTHER_RULE(PARAM1_VALUE) -- etc.. -- May also MERGE/SUBTRACT other configs with this one -- using INCLUDE_CONFIG and EXCLUDE_CONFIG -- -- Spec may include comments, indicated by: -- '-- ', '//', '--', and '/*' '*/' --------------------------------------------------------------- procedure update_from_spec(config_ivid in number ,spec in varchar2) is config_irid number; other_cfg_ivid number; rule varchar2(30); param1 varchar2(3000); param2 varchar2(3000); param3 varchar2(3000); l_spec varchar2(30000); rule_irid number; begin l_spec:=spec; --Check config OK for update. select irid into config_irid from I$SDD_CONFIGURATIONS where ivid=config_ivid; check_config_for_update(config_irid,config_ivid); while l_spec is not null loop --Get hold of a rule and it's parameters from the spec jr_rule.parse_spec(l_spec ,rule ,param1 ,param2 ,param3); if rule in ('INCLUDE_CONFIG','EXCLUDE_CONFIG') then --Get the config specifed by the parameter other_cfg_ivid:=jr_name.get_vid(param1); if other_cfg_ivid is null then --Invalid config name --Failed to process rule specification rmmes.post('CDR',1006); raise SPEC_PARSE_ERROR; end if; if rule='INCLUDE_CONFIG' then --Merge specified config with this config merge_configs(config_ivid,other_cfg_ivid); elsif rule='EXCLUDE_CONFIG' then --Subtract specified config from this config subtract_configs(config_ivid,other_cfg_ivid); end if; else --Get hold of the ID for the rule rule_irid:=jr_rule.get_irid(rule); if rule_irid is null then --Failed to process rule specification rmmes.post('CDR',1006); raise SPEC_PARSE_ERROR; end if; --Execute the rule against the specified configuration. jr_rule.execute_rule(rule_irid ,config_ivid ,param1 ,param2 ,param3); end if; end loop; end update_from_spec; end jr_configuration_def; / -- -- ---------------------------------------------------------------------------+ -- }} End of file $Workfile: jrpbcfgd.sql $ $$Header_is_done -- ---------------------------------------------------------------------------+