Rem Copyright (c) 1994 by Oracle Corporation Rem NAME Rem ciaen.mpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem cvanes 11/02/99 - Creation CREATE OR REPLACE PACKAGE BODY cimaen IS cursor ass_c(conid rm.reference) is select d.element from rm_deferred_checks d where d.assertion = conid; --============================ CIHAEN_CLASS_AGGREGATE =============================-- -- %0!s: %1!s may only be a role in one 'STRONG' Association End PROCEDURE check_cihaene_class_aggregate(conid rm.reference) IS dummy number; classifier_ref number; BEGIN for assertion in ass_c(conid) loop select nvl( nvl(aen.entity_object_reference, aen.generic_class_reference), aen.interface_classifier_reference) into classifier_ref from ci_association_ends aen where aen.id = assertion.element; select count (*) into dummy from ci_association_ends other_aen where (other_aen.entity_object_reference = classifier_ref OR other_aen.generic_class_reference = classifier_ref OR other_aen.interface_classifier_reference = classifier_ref) and other_aen.aggregation = 'STRONG'; if dummy > 1 then rmman.record_check(conid,assertion.element,null,null,false,'Y', ciiutl.identify(assertion.element, 'AEN'), ciiutl.identify(classifier_ref, 'CLA')); else rmman.record_check(conid,assertion.element,null,null,true); end if; end loop; END check_cihaene_class_aggregate; --========================= GET_UNIQUENESS_REFERENCE ==========================-- --Returns UNIQUENESS_REFERENCE for an AEN -- (In a function as it is called twice and it will save a parse) FUNCTION get_uniqueness_reference(aen_ref number) RETURN number IS unique_ref number; BEGIN select uniqueness_rule_reference into unique_ref from ci_association_ends aen where aen.id = aen_ref; return (unique_ref); EXCEPTION WHEN NO_DATA_FOUND THEN return (null); -- Not a valid aen_ref END; --============================ CIHAENE_UNIQUENESS =============================-- -- %0!s: UNIQUENESS_REFERENCE is only valid in binary Associations PROCEDURE check_cihaene_uniqueness(conid rm.reference) IS BEGIN for assertion in ass_c(conid) loop if get_uniqueness_reference(assertion.element) is not null then if cimass.get_other_aen(assertion.element) is null then -- Only returns null if not a binary association rmman.record_check(conid,assertion.element,null,null,false,'Y', ciiutl.identify(assertion.element, 'AEN')); else rmman.record_check(conid,assertion.element,null,null,true); end if; else -- UNIQUENESS_RULE_REFERENCE not set, so all OK rmman.record_check(conid,assertion.element,null,null,true); end if; end loop; END check_cihaene_uniqueness; --============================ CIHAENE_UNIQUENESS_2 =============================-- -- %0!s: Uniqueness Rule must be one owned by %1!s PROCEDURE check_cihaene_uniqueness_2(conid rm.reference) IS my_unique_ref number; other_aen_ref number; other_unique_ref number; aen_class_ref number; unr_class_ref number; aen_ref_1 number; aen_ref_2 number; unique_ref number; BEGIN for assertion in ass_c(conid) loop other_aen_ref := cimass.get_other_aen(assertion.element); if other_aen_ref is null then -- Not binary - leave reporting this to CIHAENE_UNIQUENESS rmman.record_check(conid,assertion.element,null,null,true); goto end_loop; end if; my_unique_ref := get_uniqueness_reference(assertion.element); other_unique_ref := get_uniqueness_reference(other_aen_ref); if my_unique_ref is not null then aen_ref_1 := assertion.element; aen_ref_2 := other_aen_ref; unique_ref := my_unique_ref; elsif other_unique_ref is not null then aen_ref_1 := other_aen_ref; aen_ref_2 := assertion.element; unique_ref := other_unique_ref; else -- Neither AEN has UNIQUENESS_REFERENCE set rmman.record_check(conid,assertion.element,null,null,true); goto end_loop; end if; select nvl(nvl(aen.entity_object_reference, aen.generic_class_reference), aen.interface_classifier_reference) into aen_class_ref from ci_association_ends aen where aen.id = aen_ref_2; select nvl(nvl(unr.entity_object_reference, unr.generic_class_reference), unr.interface_classifier_reference) into unr_class_ref from ci_uniqueness_rules unr where unr.id = unique_ref; if aen_class_ref = unr_class_ref then rmman.record_check(conid,assertion.element,null,null,true); else rmman.record_check(conid,assertion.element,null,null,false,'Y', ciiutl.identify(assertion.element, 'AEN'), ciiutl.identify(aen_class_ref, 'CLA')); end if; <> null; end loop; END check_cihaene_uniqueness_2; --============================ CIHAENE_UNIQUENESS_3 =============================-- -- %0!s: Uniqueness Rule may only be specified on one end of an Association PROCEDURE check_cihaene_uniqueness_3(conid rm.reference) IS BEGIN for assertion in ass_c(conid) loop if get_uniqueness_reference(assertion.element) is not null then if get_uniqueness_reference(cimass.get_other_aen(assertion.element)) is not null then -- Both ends have UNIQUENESS_RULE_REFERENCE set rmman.record_check(conid,assertion.element,null,null,false,'Y', ciiutl.identify(assertion.element, 'AEN')); else rmman.record_check(conid,assertion.element,null,null,true); end if; else rmman.record_check(conid,assertion.element,null,null,true); end if; end loop; END check_cihaene_uniqueness_3; --========================== IS_AEN_ATT_MET_NAME_UNIQUE ========================-- FUNCTION is_aen_att_met_name_unique(elem_ref number, class_ref number, elem_name varchar2, elem_type varchar2, clash_id out number, clash_type out varchar2) RETURN boolean IS clashing_id number; clashing_type varchar2(10); BEGIN FOR clashes in ( select met.id clashing_id, 'MET' clashing_type from ci_methods met where met.classifier_reference = class_ref and met.name = elem_name and met.id <> elem_ref and elem_type <> 'MET' --do not check method against itself UNION select eat.id, 'EAT' from ci_entity_object_attributes eat where eat.entity_object_reference = class_ref and eat.name = elem_name and eat.id <> elem_ref and elem_type <> 'GAT' --do not check GATs against EATs UNION select gat.id, 'GAT' from ci_general_attributes gat where class_ref IN (gat.event_classifier_reference ,gat.generic_class_reference ,gat.attribute_domain_reference ,gat.interface_classifier_reference) and gat.name = elem_name and gat.id <> elem_ref and elem_type <> 'EAT' --do not check EATs against GATs UNION select other_aen.id, 'AEN' from ci_association_ends this_aen , ci_association_ends other_aen where (this_aen.entity_object_reference = class_ref or this_aen.generic_class_reference = class_ref or this_aen.interface_classifier_reference = class_ref) and this_aen.association_reference = other_aen.association_reference and other_aen.name = elem_name and other_aen.id <> this_aen.id and elem_type <> 'AEN' ) LOOP --do not check AEN against itself clash_id := clashes.clashing_id; clash_type := clashes.clashing_type; return(false); END LOOP; clash_id := null; clash_type := null; return(true); END is_aen_att_met_name_unique; --============================ CIHAENE_NAME_UNIQUENESS =============================-- -- %0!s: PROCEDURE check_cihaene_name_uniqueness(conid rm.reference) IS aen_name sdd_aen.name%type; clash_id number; clash_type varchar2(10); BEGIN for assertion in ass_c(conid) loop select name into aen_name from ci_association_ends aen where aen.id = assertion.element; for the_other_aen in cimaen.get_all_other_aens(assertion.element) loop if aen_name is null or is_aen_att_met_name_unique(assertion.element, the_other_aen.role_in_classifier_reference, aen_name, 'AEN', clash_id, clash_type) then rmman.record_check(conid,assertion.element,null,null,true); else rmman.record_check(conid,assertion.element,null,null,false,'Y', ciiutl.identify(assertion.element, 'AEN'), ciiutl.identify(clash_id, clash_type) ); end if; end loop; end loop; end check_cihaene_name_uniqueness; END; /