REM *************************************************************************** REM Hand-carved package body for GENERAL ATTRIBUTE created on 07-DEC-98 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihgat IS -- Generic post-process routines PROCEDURE check_delete(id number); sac_type constant varchar2(6) := 'CAT'; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id number, pl in out NOCOPY ciogeneral_attribute.data) IS dummy varchar2(30) := 0; pac_type varchar2(6); pac_reference number; BEGIN -- Calculate the PAC reference which determines access control rights pac_reference := nvl(nvl(nvl(pl.v.event_classifier_reference, pl.v.attribute_domain_reference), pl.v.generic_class_reference), pl.v.interface_classifier_reference); select classifier_subtype into pac_type from ci_classifiers where irid = pac_reference; -- Access rights for general attribute derive from the reference -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(pac_reference, 'CLA', 'UPD'); -- 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; pl.v.classifier_attribute_subtype := 'GAT'; pl.i.classifier_attribute_subtype := true; pl.v.general_attribute_for := pac_type; pl.i.general_attribute_for := true; if not pl.i.sequence then pl.v.sequence :=ciiexp.default_seq(pac_reference, sac_type); pl.i.sequence :=true; end if; --Check if the GAT is for an Interface Classifer and if so do not default --the maximum length or prompt because we want this to remain at NULL select count(*) into dummy from ci_interface_classifiers where irid = pl.v.interface_classifier_reference and rich_interface_flag = 'N'; if dummy = 0 then if not pl.i.maximum_length then pl.v.maximum_length := '38'; pl.i.maximum_length := true; end if; if not pl.i.prompt then pl.v.prompt := INITCAP(REPLACE(pl.v.name, '_',NULL)); pl.i.prompt := true; end if; else pl.v.visibility := 'PUBLIC'; pl.i.visibility := true; pl.v.static_flag := 'Y'; pl.i.static_flag := true; pl.v.change_restriction := 'FROZEN'; pl.i.change_restriction := true; pl.v.retrievable_flag := 'N'; pl.i.retrievable_flag := true; pl.v.updatable_flag := 'N'; pl.i.updatable_flag := true; pl.v.minimum_multiplicity := '1'; pl.i.minimum_multiplicity := true; end if; end if; if pl.i.scalar_datatype and pl.v.scalar_datatype is not NULL then pl.v.datatype_format := 'SCALAR'; pl.i.datatype_format := true; pl.v.classifier_reference := null; pl.i.classifier_reference := true; elsif pl.i.classifier_reference and pl.v.classifier_reference is not NULL then pl.v.datatype_format := 'CLASSIFIER'; pl.i.datatype_format := true; pl.v.scalar_datatype := null; pl.i.scalar_datatype := false; elsif pl.v.scalar_datatype is NULL and pl.v.classifier_reference is NULL then pl.v.datatype_format := 'SCALAR'; pl.i.datatype_format := true; pl.v.scalar_datatype := 'int'; pl.i.scalar_datatype := true; if not pl.i.maximum_length and dummy = 0 then pl.v.maximum_length := '38'; pl.i.maximum_length := true; end if; end if; --remove spaces from name if pl.i.name then pl.v.name := REPLACE (pl.v.name, ' ', NULL); end if; --Maintain the out_of_sync_flag for a corresponding file_usage ciheoc.maintain_sync_flag(pl.v.pac_reference); END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id number) IS BEGIN -- Access rights for general attribute derive from the reference -- 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); end if; END; --===================== POST-PROCESS (INS,UPD,SEL) ==========================-- PROCEDURE post_process(operation varchar2,id number, pl ciogeneral_attribute.data) IS error_flag boolean := false; dummy number; CURSOR att_dom_c(classifier_ref number) IS select decimal_places ,default_column_datatype ,default_value ,maximum_length ,queryable_flag ,updatable_flag ,mandatory_flag from ci_attribute_domains where irid = classifier_ref; BEGIN -- Bug 1024673, remove constraints on external_flag if operation = 'INS' or (operation = 'UPD' and pl.i.name) then --deferred unique name check rmman.log_change('CIHGATE_UNIQUE_NAME',pl.v.id); end if; select count(*) into dummy from ci_interface_classifiers where irid = pl.v.interface_classifier_reference and rich_interface_flag = 'N'; if dummy > 0 then if pl.v.default_value IS NULL then --%0!s: Default Value is mandatory for an Attribute in an Interface Classifier ciierr.post(2096,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.visibility != 'PUBLIC' then --%0!s: Visibility property must be 'PUBLIC in Interface Classifier attribute ciierr.post(2172,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.static_flag != 'Y' then --%0!s: Static_Flag property must equal 'Y' for Interface Classifier attribute. ciierr.post(2097,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.change_restriction != 'FROZEN' then --%0!s: Change_Restriction must equal 'FROZEN' for Interface attribute ciierr.post(2173,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.retrievable_flag != 'N' then --%0!s: Retrievable_Flag must equal 'N' for Interface attribute ciierr.post(2174,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.updatable_flag != 'N' then --%0!s: Updatable_Flag must equal 'N' for Interface attribute ciierr.post(2175,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.decimal_places IS NOT NULL then --%0!s: Decimal_Places must be NULL for Interface attribute ciierr.post(2176,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.maximum_length IS NOT NULL then --%0!s: Maximum_Length must be NULL for Interface attribute ciierr.post(2177,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.prompt IS NOT NULL then --%0!s: Prompt must be NULL for Interface attribute ciierr.post(2178,ciiutl.identify(id, 'GAT')); error_flag := true; end if; if pl.v.minimum_multiplicity != '1' then --%0!s: Minimum_Multiplicity must equal '1' for Interface attribute ciierr.post(2179,ciiutl.identify(id, 'GAT')); error_flag := true; end if; end if; --Check constraints for a General Attribute in an Attribute Domain --should only ever iterate once or not at all FOR att_dom_rec in att_dom_c(pl.v.attribute_domain_reference) LOOP if att_dom_rec.mandatory_flag = 'N' then if pl.v.minimum_multiplicity != '0' then --%0!s: Attribute in mandatory Attribute Domain Minimum_Multplicity mismatch ciierr.post(2099,ciiutl.identify(id, 'GAT')); error_flag := true; end if; elsif att_dom_rec.mandatory_flag = 'Y' then if pl.v.minimum_multiplicity != '1' then --%0!s: Attribute in mandatory Attribute Domain Minimum_Multplicity mismatch ciierr.post(2099,ciiutl.identify(id, 'GAT')); error_flag := true; end if; end if; END LOOP; if operation != 'SEL' then cihgat.check_multiplicity(pl.v.id, sac_type, pl.v.minimum_multiplicity, pl.v.maximum_multiplicity); end if; if error_flag then raise cdapi.apierror; end if; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id number) IS BEGIN null; END; --============================= CHECK DELETE ================================-- PROCEDURE check_delete(id number) IS dummy number; error_flag boolean := false; CURSOR file_c(irid_ref number) IS select pac_reference cla from ci_classifier_attributes where irid = irid_ref; BEGIN FOR file_rec IN file_c(check_delete.id) LOOP --Maintain the out_of_sync_flag for a corresponding file_usage ciheoc.maintain_sync_flag(file_rec.cla); END LOOP; select count (*) into dummy from ci_generic_classes class ,ci_general_attributes attribute where class.irid = attribute.generic_class_reference and class.external_flag = 'Y' and attribute.irid = check_delete.id; if dummy > 0 then --%0!s: Cannot be deleted. Refers to an external Generic Class ciierr.post(110,ciiutl.identify(id, 'INC'),'Interface Classifier'); error_flag := true; end if; if error_flag then raise cdapi.apierror; end if; END; --================================== ISINTERFACEATTRIBUTE ====================================-- FUNCTION isInterfaceAttribute(irid_ref number) RETURN boolean IS dummy number; BEGIN select count(*) into dummy from ci_general_attributes where interface_classifier_reference IS NOT NULL and irid = isInterfaceAttribute.irid_ref; if dummy > 0 then return true; else return false; end if; END; --========================= CHECK_MULTIPLICITY ==============================-- PROCEDURE check_multiplicity(id number, type varchar2, minimum_multiplicity in varchar2, maximum_multiplicity in varchar2) IS err_cnt number := 0; BEGIN if minimum_multiplicity < 0 then --%0!s: MINIMUM_MULTIPLICITY must a number >= 0 ciierr.post(2192,ciiutl.identify(id, type)); err_cnt := err_cnt +1; end if; if maximum_multiplicity != '*' then if minimum_multiplicity > TO_NUMBER(maximum_multiplicity) then --%0!s: Maximum must be greater than or equal to the minimum multiplicity ciierr.post(2170,ciiutl.identify(id, type)); err_cnt := err_cnt +1; end if; if TO_NUMBER(maximum_multiplicity) <= 0 then --%0!s: MAXIMUM_MULTIPLICITY must be either '*' or a number > 0 ciierr.post(2191,ciiutl.identify(id, type)); err_cnt := err_cnt +1; end if; end if; if err_cnt > 0 then raise cdapi.apierror; end if; EXCEPTION WHEN VALUE_ERROR THEN --One of the TO_NUMBERs failed --%0!s: MAXIMUM_MULTIPLICITY must be either '*' or a number > 0 ciierr.fatal(2191,ciiutl.identify(id, type)); END; --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /