(* $Id: external_reference_schema.exp,v 1.13 2014/03/04 00:30:36 Exp $ ISO 10303 TC184/SC4/WG12 N8369 EXPRESS Source: ISO 10303-41 ed4 Fundamentals of product description and support - External reference schema The following permission notice and disclaimer shall be included in all copies of this EXPRESS schema ("the Schema"), and derivations of the Schema: Copyright ISO 2014 All rights reserved Permission is hereby granted, free of charge in perpetuity, to any person obtaining a copy of the Schema, to use, copy, modify, merge and distribute free of charge, copies of the Schema for the purposes of developing, implementing, installing and using software based on the Schema, and to permit persons to whom the Schema is furnished to do so, subject to the following conditions: THE SCHEMA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SCHEMA OR THE USE OR OTHER DEALINGS IN THE SCHEMA. In addition, any modified copy of the Schema shall include the following notice: THIS SCHEMA HAS BEEN MODIFIED FROM THE SCHEMA DEFINED IN ISO 10303-41 ed4 Fundamentals of product description and support - External reference schema AND SHOULD NOT BE INTERPRETED AS COMPLYING WITH THAT STANDARD *) SCHEMA external_reference_schema '{iso standard 10303 part(41) version(7) object(1) external_reference_schema(11)}'; REFERENCE FROM basic_attribute_schema ( description_attribute, description_attribute_select, get_description_value); REFERENCE FROM support_resource_schema ( label, text, identifier, bag_to_set); TYPE ers_description_attribute_select = SELECT BASED_ON description_attribute_select WITH ( external_source); END_TYPE; TYPE message = STRING; END_TYPE; TYPE source_item = SELECT (identifier, message); END_TYPE; ENTITY external_source; source_id : source_item; DERIVE description : text := get_description_value(SELF); WHERE WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'DESCRIPTION_ATTRIBUTE.DESCRIBED_ITEM')) <= 1; END_ENTITY; ENTITY external_source_relationship; name : label; description : OPTIONAL text; relating_source : external_source; related_source : external_source; END_ENTITY; ENTITY externally_defined_item; item_id : source_item; source : external_source; END_ENTITY; ENTITY externally_defined_item_relationship; name : label; description : OPTIONAL text; relating_item : externally_defined_item; related_item : externally_defined_item; END_ENTITY; ENTITY externally_defined_item_with_multiple_references SUBTYPE OF (externally_defined_item); references : LIST[1:?] OF UNIQUE source_item; UNIQUE UR1: references; WHERE WR1: NOT(SELF\externally_defined_item.item_id IN references); END_ENTITY; ENTITY pre_defined_item; name : label; END_ENTITY; FUNCTION acyclic_external_source_relationship (relation : external_source_relationship; relatives : SET [1:?] OF external_source; specific_relation : STRING):BOOLEAN; LOCAL x : SET OF external_source_relationship; END_LOCAL; IF relation.relating_source IN relatives THEN RETURN (FALSE); END_IF; x := QUERY(es <* bag_to_set(USEDIN(relation.relating_source, 'EXTERNAL_REFERENCE_SCHEMA.' + 'EXTERNAL_SOURCE_RELATIONSHIP.' + 'RELATED_SOURCE')) | specific_relation IN TYPEOF(es)); REPEAT i := 1 TO HIINDEX(x); IF NOT acyclic_external_source_relationship(x[i], relatives + relation.relating_source, specific_relation) THEN RETURN (FALSE); END_IF; END_REPEAT; RETURN (TRUE); END_FUNCTION; FUNCTION acyclic_externally_defined_item_relationship (relation : externally_defined_item_relationship; relatives : SET [1:?] OF externally_defined_item; specific_relation : STRING):BOOLEAN; LOCAL x : SET OF externally_defined_item_relationship; END_LOCAL; IF relation.relating_item IN relatives THEN RETURN (FALSE); END_IF; x := QUERY(edi <* bag_to_set(USEDIN(relation.relating_item, 'EXTERNAL_REFERENCE_SCHEMA.' + 'EXTERNALLY_DEFINED_ITEM_RELATIONSHIP.' + 'RELATED_ITEM')) | specific_relation IN TYPEOF(edi)); REPEAT i := 1 TO HIINDEX(x); IF NOT acyclic_externally_defined_item_relationship(x[i], relatives + relation.relating_item, specific_relation) THEN RETURN (FALSE); END_IF; END_REPEAT; RETURN (TRUE); END_FUNCTION; END_SCHEMA;