Rem Copyright (c) 1994 by Oracle Corporation Rem NAME Rem ciass.mpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem cheaps 06/11/99 - Creation CREATE OR REPLACE PACKAGE BODY cimass IS cursor ass_c(conid rm.reference) is select d.element from rm_deferred_checks d where d.assertion = conid; cursor aens_c(class_ref number) is select aen.id from ci_association_ends aen where aen.entity_object_reference = class_ref or aen.generic_class_reference = class_ref; --============================ COUNT_ENDS =============================-- -- Private function - returns number of Association Ends for this Association FUNCTION count_ends(assoc_ref number) RETURN number IS dummy number; BEGIN select count(*) into dummy from ci_association_ends aen where aen.association_reference = assoc_ref; return dummy; END; --============================ CIHASSE_TWO_MIN =============================-- -- %0!s: An Association may not have less than two Association Ends PROCEDURE check_cihasse_two_min(conid rm.reference) IS BEGIN for assertions in ass_c(conid) loop if count_ends(assertions.element) < 2 then rmman.record_check(conid,assertions.element,null,null,false,'Y', ciiutl.identify(assertions.element, 'ASS')); else rmman.record_check(conid,assertions.element,null,null,true); end if; end loop; END check_cihasse_two_min; --============================ CIHASSE_N_ARRAY =============================-- --%0!s: An n-array Association must be Analysis only PROCEDURE check_cihasse_n_array(conid rm.reference) IS flag char; BEGIN for assertions in ass_c(conid) loop select analysis_type_flag into flag from ci_associations where irid = assertions.element; if count_ends(assertions.element) > 2 and flag != 'Y' then rmman.record_check(conid,assertions.element,null,null,false,'Y', ciiutl.identify(assertions.element, 'ASS')); else rmman.record_check(conid,assertions.element,null,null,true); end if; end loop; END check_cihasse_n_array; --============================ CIHASSE_MANY_MANY =============================-- --%0!s: A many to many Association must be Analysis only PROCEDURE check_cihasse_many_many(conid rm.reference) IS dummy number; cursor many_c(ass_id number) is select assoc.analysis_type_flag ,assend.maximum_multiplicity from ci_associations assoc ,ci_association_ends assend where assend.association_reference = ass_id and assoc.id = ass_id; BEGIN for assertions in ass_c(conid) loop if count_ends(assertions.element) = 2 then for many in many_c(assertions.element) loop if many.analysis_type_flag = 'N' or (many.analysis_type_flag = 'Y' and many.maximum_multiplicity = '0') or (many.analysis_type_flag = 'Y' and many.maximum_multiplicity = '1') then --everything ok rmman.record_check(conid,assertions.element,null,null,true); else --error condition rmman.record_check(conid,assertions.element,null,null,false,'Y', ciiutl.identify(assertions.element, 'ASS')); end if; end loop; end if; end loop; END check_cihasse_many_many; --============================ CIHASSE_AGGREGATE_2 =============================-- -- %0!s: Only one end of a binary Association may be an aggregation PROCEDURE check_cihasse_aggregate_2(conid rm.reference) IS dummy number; BEGIN for assertions in ass_c(conid) loop if count_ends(assertions.element) = 2 then -- This test is only for binary associations select count (*) into dummy from ci_association_ends aen where aen.association_reference = assertions.element and aen.aggregation != 'NONE'; if dummy = 2 then rmman.record_check(conid,assertions.element,null,null,false,'Y', ciiutl.identify(assertions.element, 'ASS')); else rmman.record_check(conid,assertions.element,null,null,true); end if; else rmman.record_check(conid,assertions.element,null,null,true); end if; end loop; END check_cihasse_aggregate_2; --============================ CIHASSE_AGGREGATE_3 =============================-- -- %0!s: Aggregation is not permitted in a N-ary Association PROCEDURE check_cihasse_aggregate_3(conid rm.reference) IS dummy number; BEGIN for assertions in ass_c(conid) loop if count_ends(assertions.element) > 2 then -- This test is only for N-ary associations select count (*) into dummy from ci_association_ends aen where aen.association_reference = assertions.element and aen.aggregation != 'NONE'; if dummy > 0 then rmman.record_check(conid,assertions.element,null,null,false,'Y', ciiutl.identify(assertions.element, 'ASS')); else rmman.record_check(conid,assertions.element,null,null,true); end if; else rmman.record_check(conid,assertions.element,null,null,true); end if; end loop; END check_cihasse_aggregate_3; --========================== GET_OTHER_AEN =========================-- -- Return ID of the other AEN which is part of this binary Association -- Returns null if not a binary association (ie 1 or 3+ AENs) function get_other_aen(aen_ref number) return number is other_aen_ref number default null; begin for aen in cimaen.get_all_other_aens(aen_ref) loop if other_aen_ref is null then other_aen_ref := aen.id; else -- 2nd 'other' end found so an N-ary Assoc return (null); end if; end loop; return other_aen_ref; end; --========================== GET_OWNING_ASSOCIATION =========================-- -- Return ID of Association that owns this Association Class -- Returns NULL if no Association owns this class (ie it is not an Association Class) function get_owning_association(class_ref number) return number is association_ref number; begin select ass.id into association_ref from ci_associations ass where ass.entity_object_reference = class_ref or ass.generic_class_reference = class_ref; return association_ref; exception when no_data_found then return null; when too_many_rows then -- Should never happen return null; end; --========================== GET_ASSOCIATION_CLASS =========================-- -- Return ID of Classifer that is owned by this Association -- Returns NULL if no Classifers are owned by this Association function get_association_class(ass_ref number) return number is assoc_class number; begin select nvl(ass.entity_object_reference, ass.generic_class_reference) into assoc_class from ci_associations ass where ass.id = ass_ref; return assoc_class; end; --============================ CIHASS_ASSOC_CLASS_1 =============================-- -- %0!s: An Association Class may only play a role in a binary Association PROCEDURE check_cihasse_assoc_class_1(conid rm.reference) IS assoc_class number; BEGIN -- Only Association Classes get referred here for assertion in ass_c(conid) loop assoc_class := get_association_class(assertion.element); if assoc_class is null then -- This is not an Association Class rmman.record_check(conid,assertion.element,null,null,true); else -- Get all AENs that refer to me for aen in aens_c(assoc_class) loop if get_other_aen(aen.id) is null then rmman.record_check(conid,assertion.element,null,null,false,'Y', ciiutl.identify(assoc_class, 'CLA')); else rmman.record_check(conid,assertion.element,null,null,true); end if; end loop; end if; end loop; END check_cihasse_assoc_class_1; --============================ CIHASS_ASSOC_CLASS_2 =============================-- -- %0!s: An Association Class may only play a role in a binary Association PROCEDURE check_cihasse_assoc_class_2(conid rm.reference) IS assoc_class number; other_aen_ref number; dummy number; BEGIN -- Only Association Classes get referred here for assertion in ass_c(conid) loop assoc_class := get_association_class(assertion.element); if assoc_class is null then -- This is not an Association Class rmman.record_check(conid,assertion.element,null,null,true); else -- Get all AENs that refer to me for aen in aens_c(assoc_class) loop other_aen_ref := get_other_aen(aen.id); if other_aen_ref is null then -- Not binary so picked up by other test rmman.record_check(conid,assertion.element,null,null,true); else begin select aen1.id into dummy from ci_association_ends aen1 ,ci_association_ends aen2 where aen1.association_reference = assertion.element and aen2.id = other_aen_ref and (aen1.entity_object_reference = aen2.entity_object_reference or aen1.generic_class_reference = aen2.generic_class_reference or aen1.interface_classifier_reference = aen2.interface_classifier_reference); -- Only get here if we select ONE row rmman.record_check(conid,assertion.element,null,null,true); exception when no_data_found then rmman.record_check(conid,assertion.element,null,null,false,'Y', ciiutl.identify(assoc_class, 'CLA')); when too_many_rows then -- Should never happen rmman.record_check(conid,assertion.element,null,null,false,'Y', ciiutl.identify(assoc_class, 'CLA')); end; end if; end loop; end if; end loop; END check_cihasse_assoc_class_2; END; /