(*
  $Id$
  ISO TC184/SC4/WG12 N2887 - ISO/IS 10303-41 Fundamentals of product description and support - EXPRESS
*) 


SCHEMA management_resources_schema;

REFERENCE FROM action_schema;    -- ISO 10303-41

REFERENCE FROM application_context_schema   -- ISO 10303-41
  (library_context); 

REFERENCE FROM approval_schema;    -- ISO 10303-41

REFERENCE FROM basic_attribute_schema   -- ISO 10303-41
  (get_role,
   object_role,
   role_association); 

REFERENCE FROM certification_schema;    -- ISO 10303-41

REFERENCE FROM contract_schema;    -- ISO 10303-41

REFERENCE FROM date_time_schema;    -- ISO 10303-41

REFERENCE FROM document_schema;    -- ISO 10303-41

REFERENCE FROM effectivity_schema;    -- ISO 10303-41

REFERENCE FROM experience_schema;    -- ISO 10303-41

REFERENCE FROM external_reference_schema   -- ISO 10303-41
  (external_source); 

REFERENCE FROM group_schema;    -- ISO 10303-41

REFERENCE FROM location_schema;    -- ISO 10303-41

REFERENCE FROM person_organization_schema;    -- ISO 10303-41

REFERENCE FROM qualifications_schema;    -- ISO 10303-41

REFERENCE FROM security_classification_schema;    -- ISO 10303-41

REFERENCE FROM support_resource_schema;    -- ISO 10303-41


TYPE attribute_type = SELECT
   (label, 
    text);
END_TYPE; 

ENTITY action_assignment
  ABSTRACT SUPERTYPE ;
  assigned_action : action;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF (USEDIN (SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY action_method_assignment
  ABSTRACT SUPERTYPE ;
  assigned_action_method : action_method;
  role : action_method_role;
END_ENTITY;

ENTITY action_method_role;
  name : label;
  description : OPTIONAL text;
END_ENTITY;

ENTITY action_request_assignment
  ABSTRACT SUPERTYPE ;
  assigned_action_request : versioned_action_request;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF (USEDIN (SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY approval_assignment
  ABSTRACT SUPERTYPE ;
  assigned_approval : approval;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY attribute_classification_assignment
  ABSTRACT SUPERTYPE ;
  assigned_class : group;
  attribute_name : label;
  role : classification_role;
END_ENTITY;

ENTITY attribute_value_assignment
  ABSTRACT SUPERTYPE ;
  attribute_name : label;
  attribute_value : attribute_type;
  role : attribute_value_role;
END_ENTITY;

ENTITY attribute_value_role;
  name : label;
  description : OPTIONAL text;
END_ENTITY;

ENTITY certification_assignment
  ABSTRACT SUPERTYPE ;
  assigned_certification : certification;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY classification_assignment
  ABSTRACT SUPERTYPE ;
  assigned_class : group;
  role : classification_role;
END_ENTITY;

ENTITY classification_role;
  name : label;
  description : OPTIONAL text;
END_ENTITY;

ENTITY contract_assignment
  ABSTRACT SUPERTYPE ;
  assigned_contract : contract;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY date_and_time_assignment
  ABSTRACT SUPERTYPE ;
  assigned_date_and_time : date_and_time;
  role : date_time_role;
END_ENTITY;

ENTITY date_assignment
  ABSTRACT SUPERTYPE ;
  assigned_date : date;
  role : date_role;
END_ENTITY;

ENTITY document_reference
  ABSTRACT SUPERTYPE ;
  assigned_document : document;
  source : label;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY document_usage_constraint_assignment
  ABSTRACT SUPERTYPE ;
  assigned_document_usage : document_usage_constraint;
  role : document_usage_role;
END_ENTITY;

ENTITY document_usage_role;
  name : label;
  description : OPTIONAL text;
END_ENTITY;

ENTITY effectivity_assignment
  ABSTRACT SUPERTYPE ;
  assigned_effectivity : effectivity;
DERIVE
  role : object_role := get_role(SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY effectivity_context_assignment
  ABSTRACT SUPERTYPE ;
  assigned_effectivity_assignment : effectivity_assignment;
  role : effectivity_context_role;
END_ENTITY;

ENTITY effectivity_context_role;
  name : label;
  description : OPTIONAL text;
END_ENTITY;

ENTITY event_occurrence_assignment
  ABSTRACT SUPERTYPE ;
  assigned_event_occurrence : event_occurrence;
  role : event_occurrence_role;
END_ENTITY;

ENTITY event_occurrence_context_assignment
  ABSTRACT SUPERTYPE ;
  assigned_event_occurrence_assignment : event_occurrence_assignment;
  role : event_occurrence_context_role;
END_ENTITY;

ENTITY experience_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_experience : experience;
  role : experience_role;
END_ENTITY;

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

ENTITY experience_type_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_experience_type : experience_type;
  role : experience_type_role;
END_ENTITY;

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

ENTITY external_identification_assignment
  ABSTRACT SUPERTYPE 
  SUBTYPE OF (identification_assignment);
  source : external_source;
END_ENTITY;

ENTITY external_referent_assignment
    ABSTRACT SUPERTYPE;
    assigned_name : label;
  DERIVE
    role : object_role := get_role(SELF);
  UNIQUE
    UR1: assigned_name;
  WHERE
    WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
  END_ENTITY;

ENTITY group_assignment
  ABSTRACT SUPERTYPE ;
  assigned_group : group;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY identification_assignment
  ABSTRACT SUPERTYPE ;
  assigned_id : identifier;
  role : identification_role;
END_ENTITY;

ENTITY identification_assignment_relationship;
  name : label;
  description : OPTIONAL text;
  relating_identification_assignment : identification_assignment;
  related_identification_assignment : identification_assignment;
END_ENTITY;

ENTITY identification_role;
  name : label;
  description : OPTIONAL text;
END_ENTITY;

ENTITY library_assignment
  ABSTRACT SUPERTYPE 
  SUBTYPE OF (external_referent_assignment);
  frame_of_reference : library_context;
UNIQUE
  UR1: frame_of_reference;
END_ENTITY;

ENTITY location_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_location : location;
  role : location_role;
END_ENTITY;

ENTITY location_representation_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  represented_location : location;
  role : location_representation_role;
END_ENTITY;

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

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

ENTITY name_assignment
  ABSTRACT SUPERTYPE ;
  assigned_name : label;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF (USEDIN (SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1 ;
END_ENTITY;

ENTITY organization_assignment
  ABSTRACT SUPERTYPE ;
  assigned_organization : organization;
  role : organization_role;
END_ENTITY;

ENTITY organization_type_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_organization_type : organization_type;
  role : organization_type_role;
END_ENTITY;

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

ENTITY organizational_project_assignment
  ABSTRACT SUPERTYPE ;
  assigned_organizational_project : organizational_project;
  role : organizational_project_role;
END_ENTITY;

ENTITY organizational_project_role;
  name : label;
  description : OPTIONAL text;
END_ENTITY;

ENTITY person_and_organization_assignment
  ABSTRACT SUPERTYPE ;
  assigned_person_and_organization : person_and_organization;
  role : person_and_organization_role;
END_ENTITY;

ENTITY person_assignment
  ABSTRACT SUPERTYPE ;
  assigned_person : person;
  role : person_role;
END_ENTITY;

ENTITY person_type_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_person_type : person_type;
  role : person_type_role;
END_ENTITY;

ENTITY person_type_definition_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_person_type_definition : person_type_definition;
  role : person_type_definition_role;
END_ENTITY;

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

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

ENTITY position_in_organization_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_position_in_organization : position_in_organization;
  role : position_in_organization_role;
END_ENTITY;

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

ENTITY position_in_organization_type_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_position_in_organization_type : position_in_organization_type;
  role : position_in_organization_type_role;
END_ENTITY;

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

ENTITY qualification_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_qualification : qualification;
  role : qualification_role;
END_ENTITY;

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

ENTITY qualification_type_assignment
  ABSTRACT SUPERTYPE ;
  id : identifier;
  name : label;
  description : OPTIONAL text;
  assigned_qualification_type : qualification_type;
  role : qualification_type_role;
END_ENTITY;

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

ENTITY security_classification_assignment
  ABSTRACT SUPERTYPE ;
  assigned_security_classification : security_classification;
DERIVE
  role : object_role := get_role (SELF);
WHERE
  WR1: SIZEOF(USEDIN(SELF, 'BASIC_ATTRIBUTE_SCHEMA.' + 'ROLE_ASSOCIATION.ITEM_WITH_ROLE')) <= 1;
END_ENTITY;

ENTITY time_assignment
  ABSTRACT SUPERTYPE ;
  assigned_time : local_time;
  role : time_role;
END_ENTITY;

ENTITY time_interval_assignment
  ABSTRACT SUPERTYPE ;
  assigned_time_interval : time_interval;
  role : time_interval_role;
END_ENTITY;

FUNCTION acyclic_identification_assignment_relationship
 (relation : identification_assignment_relationship; relatives : SET[1:?] OF identification_assignment; specific_relation : STRING) : BOOLEAN; 
 LOCAL
      x : SET OF identification_assignment_relationship;
    END_LOCAL;

    IF relation.relating_identification_assignment IN relatives THEN
      RETURN (FALSE);
    END_IF;
    x := QUERY(ia <* bag_to_set(USEDIN(relation.relating_identification_assignment, 'MANAGEMENT_RESOURCES_SCHEMA.' + 'IDENTIFICATION_ASSIGNMENT_RELATIONSHIP.' + 'RELATED_IDENTIFICATION_ASSIGNMENT')) | specific_relation IN TYPEOF(ia));
    REPEAT i := 1 TO HIINDEX(x);
      IF NOT acyclic_identification_assignment_relationship(x[i], relatives + relation.relating_identification_assignment, specific_relation) THEN
        RETURN (FALSE);
      END_IF;
    END_REPEAT;
    RETURN (TRUE);

END_FUNCTION; 

END_SCHEMA;  -- management_resources_schema



