Schema: effectivity_schema

Source : ISO 10303-41



SCHEMA effectivity_schema;

REFERENCE FROM action_schema   -- ISO 10303-41
  (action_method);

REFERENCE FROM basic_attribute_schema   -- ISO 10303-41
  (description_attribute,
   description_attribute_select,
   get_description_value,
   get_name_value,
   name_attribute,
   name_attribute_select);

REFERENCE FROM date_time_schema   -- ISO 10303-41
  (date_time_or_event_occurrence,
   time_interval);

REFERENCE FROM measure_schema   -- ISO 10303-41
  (measure_with_unit);

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


TYPE effs_description_attribute_select = SELECT BASED_ON description_attribute_select WITH
   (effectivity);
END_TYPE;

TYPE effs_name_attribute_select = SELECT BASED_ON name_attribute_select WITH
   (effectivity);
END_TYPE;

ENTITY condition
  SUBTYPE OF (action_method);
END_ENTITY;

ENTITY conditional_configuration
  SUBTYPE OF (conditional_effectivity);
  configuration_type : STRING;
  inheritance_type : STRING;
END_ENTITY;

ENTITY conditional_effectivity
  SUBTYPE OF (condition, effectivity);
END_ENTITY;

ENTITY dated_effectivity
  SUBTYPE OF (effectivity);
  effectivity_end_date : OPTIONAL date_time_or_event_occurrence;
  effectivity_start_date : OPTIONAL date_time_or_event_occurrence;
WHERE
  WR1: EXISTS(effectivity_end_date) OR EXISTS(effectivity_start_date);
END_ENTITY;

ENTITY effectivity
  SUPERTYPE OF (ONEOF (serial_numbered_effectivity,
                       dated_effectivity,
                       lot_effectivity,
                       time_interval_based_effectivity));
  id : identifier;
DERIVE
  name : label := get_name_value(SELF);
  description : text := get_description_value(SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.NAME_ATTRIBUTE.NAMED_ITEM')) <= 1;
  WR2: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.DESCRIPTION_ATTRIBUTE.DESCRIBED_ITEM')) <= 1;
END_ENTITY;

ENTITY effectivity_relationship;
  name : label;
  description : OPTIONAL text;
  related_effectivity : effectivity;
  relating_effectivity : effectivity;
END_ENTITY;

ENTITY lot_effectivity
  SUBTYPE OF (effectivity);
  effectivity_lot_id : identifier;
  effectivity_lot_size : measure_with_unit;
END_ENTITY;

ENTITY serial_numbered_effectivity
  SUBTYPE OF (effectivity);
  effectivity_start_id : identifier;
  effectivity_end_id : OPTIONAL identifier;
END_ENTITY;

ENTITY time_interval_based_effectivity
  SUBTYPE OF (effectivity);
  effectivity_period : time_interval;
END_ENTITY;

FUNCTION acyclic_effectivity_relationship
 (relation : effectivity_relationship; relatives : SET[1:?] OF effectivity; specific_relation : STRING) : BOOLEAN;
  LOCAL
  x : SET OF effectivity_relationship;
    END_LOCAL;
      IF relation.relating_effectivity IN relatives
  THEN
    RETURN(FALSE);
  END_IF;
      x := QUERY(eff
                 <* bag_to_set(USEDIN(relation.relating_effectivity, 'EFFECTIVITY_SCHEMA.EFFECTIVITY_RELATIONSHIP.RELATED_EFFECTIVITY'))
                 | specific_relation IN TYPEOF(eff));
      REPEAT i := 1 TO HIINDEX(x);
    IF NOT acyclic_effectivity_relationship(x[i], relatives + relation.relating_effectivity, specific_relation)
    THEN
      RETURN(FALSE);
    END_IF;
  END_REPEAT;
      RETURN(TRUE);
END_FUNCTION;

END_SCHEMA;  -- effectivity_schema