rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\ciuett.opb 1.1 1998/05/28 16:57:40 mfrobins Exp $ rem rem Copyright (c) Oracle Corporation 1991. All Rights Reserved. rem NAME rem ciuett.opb - Operation Package Body rem DESCRIPTION rem This package is responsible for managing UE text type rem extensions to the CASE Repository. rem PUBLIC PROCEDURE(S) rem ins - INSert a new extended text type rem upd - UPDate an existing text type rem del - DELete an existing text type rem publish - PUBLISH an extended text type rem PRIVATE PROCEDURE(S) rem tt_validate - Validate a text type name rem tt_exists - Make sure a text type exists rem NOTES rem MODIFIED (MM/DD/YY) Rem aheath 02/14/95 - Creation rem bferris 12/19/94 - Creation CREATE OR REPLACE PACKAGE BODY cioue_text_type IS /* PRIVATE PROCEDURE PROTOTYPES */ /*-------------------------------- tt_validate -----------------------------*/ /* tt_validate - Validate a text type name */ procedure tt_validate(text_type IN varchar2); /*-------------------------------- tt_exists -------------------------------*/ /* tt_exists - Make sure a text type exists */ procedure tt_exists(text_type IN varchar2); /* PUBLIC PROCEDURES */ /* ^L */ /*-------------------------------- ins -------------------------------------*/ /* NAME ins - INSert a new extended text type DESCRIPTION This procedure create a new extended text type. The text_type parameter should contain the text type's name. The pdesc parameter should indicate the descriptive name for the text type. NOTES For now we will allow the caller to insert new 'non-user' text types. EXCEPTION uett_invalid_type - Invalid text type uett_exists - Text type already exists RETURNS */ procedure ins(text_type IN varchar2, pdesc IN varchar2) is dummy varchar2(1); nls_language rm$repositories.nls_language%type; begin -- Validate text type name tt_validate(text_type); -- Make sure it doesn't already exist begin select null into dummy from rm_text_types where text_type = ins.text_type; raise uett_exists; exception when no_data_found then null; end; -- Get the current dictionary language select nls_language into nls_language from rm$repositories; -- Create RM$TEXT_TYPES row insert into rm$text_types (text_type, is_extended, is_published) values (text_type, 'Y', 'N'); -- Create RM$NLS_TEXT_TYPES row(s) if nls_language != 'US' then insert into rm$nls_text_types (nls_language,text_type,nls_desc) values (nls_language,text_type,pdesc); end if; insert into rm$nls_text_types (nls_language,text_type,nls_desc) values ('US' ,text_type,pdesc); return; -- -- Exceptions -- exception -- Invalid text type when uett_invalid_type then rmmes.post(uett_fac,uett_invalid_type_code,text_type); raise; -- Already exists when uett_exists then rmmes.post(uett_fac,uett_exists_code,text_type); raise; end ins; /* ^L */ /*-------------------------------- upd -------------------------------------*/ /* NAME upd - UPDate an existing text type DESCRIPTION This procedure updates the details for an existing text type. The text_type parameter should contain the name of the text type to update. If the pdesc parameter is not null the text type's description will be updated. NOTES EXCEPTION uett_invalid_type - Invalid text type uett_unknown_type - Unknown text type (it doesn't exist) RETURNS */ procedure upd(text_type IN varchar2, pdesc IN varchar2) is begin -- Validate the text type and make sure it exists tt_validate(text_type); tt_exists(text_type); -- Update description if pdesc is not null then update rm$nls_text_types set nls_desc = pdesc where text_type = upd.text_type; end if; -- -- Exceptions -- exception -- Invalid text type when uett_invalid_type then rmmes.post(uett_fac,uett_invalid_type_code,text_type); raise; -- Text type doesn't exist when uett_unknown_type then rmmes.post(uett_fac,uett_unknown_type_code,text_type); raise; end upd; /* ^L */ /*-------------------------------- del -------------------------------------*/ /* NAME del - DELete an existing text type DESCRIPTION This procedure deletes the details for a given text type if it is a user text type and it has not been published. The text_type parameter should indicate the text type to delete. NOTES EXCEPTION uett_invalid_type - Invalid text type uett_unknown_type - Unknown text type (it doesn't exist) uett_not_user_type - Denied: Not a user extended type uett_is_published - Denied: Text type is published RETURNS */ procedure del(text_type IN varchar2) is is_ext varchar2(1); is_pub varchar2(1); begin -- Validate the text type and make sure it exists tt_validate(text_type); tt_exists(text_type); -- Validate operation select is_extended,is_published into is_ext, is_pub from rm_text_types where text_type = del.text_type; if is_ext = 'N' then raise uett_not_user_type; end if; if is_pub = 'Y' then raise uett_is_published; end if; -- Do the delete delete from rm$text_usages where text_type = del.text_type; delete from rm$nls_text_types where text_type = del.text_type; delete from rm$text_types where text_type = del.text_type; return; -- -- Exceptions -- exception -- Invalid text type when uett_invalid_type then rmmes.post(uett_fac,uett_invalid_type_code,text_type); raise; -- Text type doesn't exist when uett_unknown_type then rmmes.post(uett_fac,uett_unknown_type_code,text_type); raise; -- Text type is not a user type when uett_not_user_type then rmmes.post(uett_fac,uett_not_user_type_code,text_type); raise; -- Text type is published when uett_is_published then rmmes.post(uett_fac,uett_is_published_code,text_type); raise; end del; /* ^L */ /*-------------------------------- publish ---------------------------------*/ /* NAME publish - PUBLISH an existing text type DESCRIPTION This procedure publishes the details for a given text type if it is a user text type and it has not been published. The text_type parameter should indicate the text type to publish. NOTES EXCEPTION uett_invalid_type - Invalid text type uett_unknown_type - Unknown text type (it doesn't exist) uett_not_user_type - Denied: Not a user extended type uett_is_published - Denied: Text type is published RETURNS */ procedure publish(text_type IN varchar2) is is_ext varchar2(1); is_pub varchar2(1); begin -- Validate the text type and make sure it exists tt_validate(text_type); tt_exists(text_type); -- Validate operation select is_extended,is_published into is_ext, is_pub from rm_text_types where text_type = publish.text_type; if is_ext = 'N' then raise uett_not_user_type; end if; if is_pub = 'Y' then raise uett_is_published; end if; -- Do the publish update rm$text_types set is_published = 'Y' where text_type = publish.text_type; -- -- Exceptions -- exception -- Invalid text type when uett_invalid_type then rmmes.post(uett_fac,uett_invalid_type_code,text_type); raise; -- Text type doesn't exist when uett_unknown_type then rmmes.post(uett_fac,uett_unknown_type_code,text_type); raise; -- Text type is not a user type when uett_not_user_type then rmmes.post(uett_fac,uett_not_user_type_code,text_type); raise; -- Text type is published when uett_is_published then rmmes.post(uett_fac,uett_is_published_code,text_type); raise; end publish; /* ^L */ /*------------------------------ unpublish ---------------------------------*/ /* NAME unpublish - UNPUBLISH an existing text type DESCRIPTION This procedure unpublishes the details for a given text type if it is a user text type and it has been published. The text_type parameter should indicate the text type to publish. NOTES EXCEPTION uett_invalid_type - Invalid text type uett_unknown_type - Unknown text type (it doesn't exist) uett_not_user_type - Denied: Not a user extended type uett_is_published - Denied: Text type is published RETURNS */ procedure unpublish(text_type IN varchar2) is is_ext varchar2(1); is_pub varchar2(1); dummy number; begin -- Validate the text type and make sure it exists tt_validate(text_type); tt_exists(text_type); -- Validate operation select is_extended,is_published into is_ext, is_pub from rm_text_types where text_type = unpublish.text_type; if is_ext = 'N' then raise uett_not_user_type; end if; if is_pub = 'N' then raise uett_is_not_published; end if; select count(*) into dummy from ciue_text_usages where text_type = unpublish.text_type; if dummy != 0 then raise uett_data_exists; end if; -- Do the unpublish update rm$text_types set is_published = 'N' where text_type = unpublish.text_type; -- -- Exceptions -- exception -- Invalid text type when uett_invalid_type then rmmes.post(uett_fac,uett_invalid_type_code,text_type); raise; -- Text type doesn't exist when uett_unknown_type then rmmes.post(uett_fac,uett_unknown_type_code,text_type); raise; -- Text type is not a user type when uett_not_user_type then rmmes.post(uett_fac,uett_not_user_type_code,text_type); raise; -- Text type is not published when uett_is_not_published then rmmes.post(uett_fac,uett_is_not_published_code,text_type); raise; -- Text usages exist when uett_data_exists then rmmes.post(uett_fac,uett_data_exists_code,text_type); raise; end unpublish; /* ^L */ /*------------------------------ remap -------------------------------------*/ /* NAME remap - REMAP an existing text type to another text type. DESCRIPTION This procedure remaps an existing text type old_text_type is the existing text_type new_text_type is the new text_type NOTES EXCEPTION RETURNS */ procedure remap(old_text_type IN varchar2, new_text_type IN varchar2) is ex_error boolean; is_ext varchar2(1); dummy number; begin -- Preprocess and check constraints tt_validate(old_text_type); tt_validate(new_text_type); tt_exists(old_text_type); ex_error := true; begin tt_exists(new_text_type); exception when uett_unknown_type then ex_error := false; end; if ex_error then raise uett_exists; end if; -- Validate operation select is_extended into is_ext from rm_text_types where text_type = remap.old_text_type; if is_ext = 'N' then raise uett_not_user_type; end if; -- -- Update the element type rows -- jr_context.disable(jr_context.NO_CHECKIN_UPDATE); jr_context.disable(jr_context.ACCESS_RIGHTS); update rm$nls_text_types set text_type = remap.new_text_type where text_type = remap.old_text_type; update rm$text_types set text_type = remap.new_text_type where text_type = remap.old_text_type; -- update instance data update rm_text_lines set txt_text = remap.new_text_type where txt_text = remap.old_text_type; -- update text usages update rm$text_usages set text_type = remap.new_text_type where text_type = remap.old_text_type; jr_context.enable(jr_context.NO_CHECKIN_UPDATE); jr_context.enable(jr_context.ACCESS_RIGHTS); exception -- Already exists when uett_exists then rmmes.post(uett_fac,uett_exists_code,new_text_type); raise; -- Text type is not a user type when uett_not_user_type then rmmes.post(uett_fac,uett_not_user_type_code,old_text_type); raise; end remap; /* END OF PUBLIC PROCEDURES */ /* PRIVATE PROCEDURE */ /* ^L */ /*-------------------------------- tt_validate -----------------------------*/ /* NAME tt_validate - Validate that a text type name is valid DESCRIPTION This procedure validates a text type name. The text_type parameter should contain the text type name to validate. If this is valid, this procedure simply returns. If it is invalid the exception uett_invalid_type will be raised. NOTES If an exception is raised it will *not* have been posted on the error stack. EXCEPTION uett_invalid_type - Invalid text type RETURNS */ procedure tt_validate(text_type IN varchar2) is begin if text_type is null or lengthb(text_type) > 6 then raise uett_invalid_type; end if; end tt_validate; /* ^L */ /*-------------------------------- tt_exists -------------------------------*/ /* NAME tt_exists - Make sure a text type exists DESCRIPTION This procedure checks to see if a given text type exists. The text_type parameter should contain the text type name to search for. If it exists, this procedure simply returns. It it does not exist the exception uett_unknown_type will be raised. NOTES If an exception is raised it will *not* have been posted on the error stack. EXCEPTION uett_unknown_type - Unknown text type RETURNS */ procedure tt_exists(text_type IN varchar2) is dummy varchar2(1); begin select 'Y' into dummy from rm_text_types where text_type = tt_exists.text_type; exception when no_data_found then raise uett_unknown_type; end tt_exists; /* END OF PRIVATE PROCEDURES */ end cioue_text_type; /