Schema: location_schema

Source : ISO 10303-41



SCHEMA location_schema;

REFERENCE FROM support_resource_schema   -- ISO 10303-41
  (identifier,
   label,
   text,
   bag_to_set);


ENTITY location;
  id : identifier;
  name : label;
  description : OPTIONAL text;
END_ENTITY;

ENTITY location_relationship;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  relating_location : location;
  related_location : location;
END_ENTITY;

FUNCTION acyclic_location_relationship
 (relation : location_relationship; relatives : SET[0:?] OF location; specific_relation : STRING) : BOOLEAN;
LOCAL
      x : SET OF location_relationship;
    END_LOCAL;

    IF relation.relating_location IN relatives THEN
      RETURN (FALSE);
    END_IF;
    x := QUERY(lctn <* bag_to_set(USEDIN(relation.relating_location, 'LOCATION_SCHEMA.' + 'LOCATION_RELATIONSHIP.' + 'RELATED_LOCATION')) | specific_relation IN TYPEOF(lctn));
    REPEAT i := 1 TO HIINDEX(x);
      IF NOT acyclic_location_relationship(x[i], relatives + relation.relating_location, specific_relation) THEN
        RETURN (FALSE);
      END_IF;
    END_REPEAT;
    RETURN (TRUE);
END_FUNCTION;

END_SCHEMA;  -- location_schema