(*
  $Id$
  ISO TC184/SC4/WG3 N2374 - ISO/CD-TS 10303-403 AP203 configuration controlled 3d design of mechanical parts and assemblies - EXPRESS MIM
  Supersedes ISO TC184/SC4/WG3 N1872
*) 


SCHEMA Ap203_configuration_controlled_3d_design_of_mechanical_parts_and_assemblies_mim;

-- MODULES ON CONFIGURATION CONTROL (AP214CC8)
USE FROM Design_product_data_management_mim; -- ISO/CD-TS 10303-1628

-- GD&T REPRESENTATION
USE FROM Default_tolerance_mim; -- ISO/TS 10303-1052
USE FROM Dimension_tolerance_mim; -- ISO/TS 10303-1050
USE FROM Geometric_tolerance_mim; -- ISO/TS 10303-1051

-- GD&T PRESENTATION
USE FROM Associative_text_mim; -- ISO/CD-TS 10303-1132
USE FROM Group_mim; -- ISO/TS 10303-1113
USE FROM Dimension_and_tolerance_callouts_mim; -- ISO/CD-TS 10303-1362
USE FROM Mechanical_design_presentation_representation_with_draughting_mim; -- ISO/CD-TS 10303-1315
USE FROM Mechanical_design_geometric_presentation_mim; -- ISO/CD-TS 10303-1313 
USE FROM Mechanical_design_shaded_presentation_mim; -- ISO/CD-TS 10303-1314 
USE FROM Presentation_hierarchy_mim; -- ISO/CD-TS 10303-1330
USE FROM Text_representation_mim;	-- ISO/TS 10303-1750

-- SOLID MODELS for parts
USE FROM Advanced_boundary_representation_mim; -- ISO/CD-TS 10303-1514
USE FROM Elementary_boundary_representation_mim; -- ISO/CD-TS 10303-1329
USE FROM Faceted_boundary_representation_mim; -- ISO/TS 10303-1512
USE FROM Curve_swept_solid_mim; -- ISO/TS 10303-1659
USE FROM Modified_swept_solid_mim; -- ISO/TS 10303-1322
USE FROM Thickened_face_solid_mim; -- ISO/CD-TS 10303-1320
USE FROM Solid_with_local_modification_mim; -- ISO/CD-TS 10303-1319
USE FROM Constructive_solid_geometry_3d_mim; -- ISO/TS 10303-1068

-- OTHER SPECIALIZED 3D MODELS for parts
USE FROM Manifold_surface_mim; -- ISO/CD-TS 10303-1509
USE FROM Non_manifold_surface_mim; -- ISO/CD-TS 10303-1324
USE FROM Geometrically_bounded_surface_mim; -- ISO/TS 10303-1507
USE FROM Geometrically_bounded_wireframe_mim; -- ISO/TS 10303-1510
USE FROM Edge_based_wireframe_mim; -- ISO/TS 10303-1501
USE FROM Shell_based_wireframe_mim; -- ISO/TS 10303-1502
USE FROM Compound_shape_representation_mim; -- ISO/CD-TS 10303-1327
USE FROM Wireframe_2d_mim; -- ISO/TS 10303-1347

-- OTHER GEOMETRY RELATED
USE FROM Representation_with_uncertainty_mim; -- ISO/TS 10303-1228
USE FROM Manifold_subsurface_mim; -- ISO/TS 10303-1702
USE FROM Geometric_validation_property_representation_mim; -- ISO/TS 10303-1039

USE FROM Inertia_characteristics_mim; --10303-1350
USE FROM Part_collection_mim; --10303-1115 
USE FROM Surface_conditions_mim; --10303-1110 
USE FROM Chemical_substance_mim; --10303-1655 
USE FROM Information_product_mim; --10303-1761 
USE FROM Planned_characteristic_mim; --10303-1733
USE FROM Specification_document_mim; --10303-1747
USE FROM Physical_breakdown_mim;    -- ISO/TS 10303-1215
USE FROM Shape_feature_mim;    -- ISO/TS 10303-1764
USE FROM Drawing_definition_mim;  -- ISO/TS 10303-1309
USE FROM Picture_representation_mim;  -- ISO/TS 10303-1308

-- Cataloguing modules
USE FROM Basic_data_representation_mim; -- ISO/CD-TS 10303-1773
USE FROM Extended_date_mim; -- ISO/CD-TS 10303-1776
USE FROM External_currency_mim; -- ISO/CD-TS 10303-1777
USE FROM External_library_mim; -- ISO/CD-TS 10303-1778
USE FROM External_representation_item_mim; -- ISO/CD-TS 10303-1779
USE FROM External_unit_mim; -- ISO/CD-TS 10303-1780
USE FROM Qualified_measure_mim; -- ISO/CD-TS 10303-1780

-- Composite material structures and properties 
USE FROM Composite_material_aspects_mim; -- ISO/CD-TS 10303-1768
USE FROM Composite_constituent_shape_mim;  -- ISO/CD-TS 10303-1767
USE FROM Part_and_zone_laminate_tables_mim;  -- ISO/CD-TS 10303-1770
USE FROM Ply_orientation_specification_mim;  -- ISO/CD-TS 10303-1772
USE FROM Stock_material_mim;  -- ISO/CD-TS 10303-1771

USE FROM application_context_schema   -- ISO 10303-41
  (application_context,
   application_protocol_definition,
   product_context,
   product_definition_context); 

USE FROM product_concept_schema(product_concept_relationship); 

REFERENCE FROM support_resource_schema   -- ISO 10303-41
  (type_check_function); 


  CONSTANT
    deprecated_interfaced_data_types : SET OF STRING := 
      ['document_with_class',
       'ordinal_date', 
       'product_definition_formation_with_specified_source', 
       'week_of_year_and_day_date']; 
    deprecated_constructed_data_types : SET OF STRING := 
      ['approved_item',
       'certified_item', 
       'change_request_item', 
       'contracted_item', 
       'cc_classified_item', 
       'date_time_item', 
       'cc_person_organization_item', 
       'cc_specified_item', 
       'start_request_item', 
       'work_item']; 
    deprecated_entity_data_types : SET OF STRING := 
      ['cc_design_approval',
       'cc_design_certification', 
       'cc_design_contract', 
       'cc_design_date_and_time_assignment', 
       'cc_design_person_and_organization_assignment', 
       'cc_design_security_classification', 
       'cc_design_specification_reference', 
       'change', 
       'change_request', 
       'design_context', 
       'design_make_from_relationship', 
       'mechanical_context', 
       'start_request', 
       'start_work', 
       'supplied_part_relationship']; 
  END_CONSTANT; 

  TYPE action_item_203e2 = SELECT BASED_ON action_items WITH 
    (product_definition_formation_relationship);
  END_TYPE; 

  TYPE action_request_item_203e2 = SELECT BASED_ON action_request_item WITH 
    (product_definition_formation_relationship);
  END_TYPE; 

  TYPE aliasable_item_203e2 = SELECT BASED_ON aliasable_item WITH 
    (approval_status, 
    general_property, 
    organization, 
    product, 
    product_definition, 
    product_definition_formation, 
    security_classification,
    shape_representation);
  END_TYPE; 

  TYPE approval_item_203e2 = SELECT BASED_ON approval_item WITH 
    (alternate_product_relationship, 
    assembly_component_usage_substitute, 
    certification, 
    contract, 
    document_file, 
    executed_action, 
    product, 
    product_definition, 
    product_definition_formation, 
    product_definition_relationship);
  END_TYPE; 

  TYPE approved_item = SELECT
    (certification, 
    change, 
    change_request, 
    configuration_effectivity, 
    configuration_item, 
    contract, 
    product, 
    security_classification, 
    start_request, 
    start_work);
  END_TYPE; 

  TYPE attribute_language_item_203e2 = SELECT BASED_ON attribute_language_item WITH 
    (alternate_product_relationship, 
    application_context, 
    applied_certification_assignment, 
    applied_identification_assignment, 
    applied_security_classification_assignment, 
    assembly_component_usage_substitute, 
    attribute_value_assignment, 
    configuration_design, 
    configuration_item, 
    descriptive_representation_item, 
    effectivity, 
    effectivity_relationship, 
    event_occurrence, 
    external_source, 
    general_property, 
    general_property_relationship, 
    geometric_representation_item, 
    geometric_tolerance, 
    make_from_usage_option, 
    mapped_item, 
    organization_role, 
    person_and_organization_role, 
    product_concept, 
    product_concept_relationship, 
    product_definition_context, 
    product_definition_formation, 
    product_definition_formation_relationship, 
    product_definition_shape, 
    product_related_product_category, 
    property_definition, 
    representation, 
    security_classification, 
    security_classification_assignment, 
    shape_aspect, 
    shape_aspect_relationship, 
    shape_representation, 
    time_interval_role, 
    topological_representation_item, 
    uncertainty_measure_with_unit, 
    uncertainty_qualifier);
  END_TYPE; 

  TYPE certification_item_203e2 = SELECT BASED_ON certification_item;
  END_TYPE; 

  TYPE certified_item = SELECT
    (supplied_part_relationship);
  END_TYPE; 

  TYPE change_request_item = SELECT
    (product_definition_formation);
  END_TYPE; 

  TYPE cc_classified_item = SELECT 
    (assembly_component_usage, 
    product_definition_formation);
  END_TYPE; 

  TYPE contract_item_203e2 = SELECT BASED_ON contract_item WITH 
    (executed_action, 
    product_definition_formation);
  END_TYPE; 

  TYPE contracted_item = SELECT
    (product_definition_formation);
  END_TYPE; 

  TYPE date_and_time_item_203e2 = SELECT BASED_ON date_and_time_item WITH 
    (applied_organization_assignment, 
    applied_person_and_organization_assignment, 
    approval_person_organization, 
    certification, 
    contract, 
    organizational_project, 
    product_definition, 
    product_definition_formation, 
    security_classification);
  END_TYPE; 

  TYPE date_item_203e2 = SELECT BASED_ON date_item WITH 
    (applied_organization_assignment, 
    applied_person_and_organization_assignment, 
    approval_person_organization, 
    certification, 
    contract, 
    organizational_project, 
    product_definition, 
    product_definition_formation, 
    security_classification);
  END_TYPE; 

  TYPE date_time_item = SELECT
    (approval_person_organization, 
    certification, 
    change, 
    change_request, 
    contract, 
    product_definition, 
    security_classification, 
    start_request, 
    start_work);
  END_TYPE; 

  TYPE document_reference_item_203e2 = SELECT BASED_ON document_reference_item WITH 
    (product, 
    product_definition, 
    product_definition_formation, 
    product_definition_relationship);
  END_TYPE; 

  TYPE effectivity_item_203e2 = SELECT BASED_ON effectivity_item WITH 
    (assembly_component_usage_substitute, 
    product, 
    product_definition, 
    product_definition_formation, 
    product_definition_relationship);
  END_TYPE; 

  TYPE event_occurrence_item_203e2 = SELECT BASED_ON event_occurrence_item WITH 
    (organizational_project);
  END_TYPE; 

  TYPE external_identification_item_203e2 = SELECT BASED_ON external_identification_item WITH 
    (document_file, 
    product_definition);
  END_TYPE; 

  TYPE groupable_item_203e2 = SELECT BASED_ON groupable_item WITH 
    (geometric_representation_item,
     shape_representation_relationship, 
     representation_relationship_with_transformation, 
     mapped_item,
     shape_aspect, 
     styled_item, 
     topological_representation_item);
  END_TYPE; 

  TYPE identification_item_203e2 = SELECT BASED_ON identification_item WITH 
    (approval_status, 
    document_file, 
    general_property, 
    organization, 
    product, 
    product_definition, 
    product_definition_formation, 
    security_classification, 
    security_classification_level, 
    shape_representation);
  END_TYPE; 

  TYPE multi_language_attribute_item_203e2 = SELECT BASED_ON multi_language_attribute_item WITH 
    (alternate_product_relationship, 
    application_context, 
    applied_certification_assignment, 
    applied_identification_assignment, 
    assembly_component_usage_substitute, 
    attribute_value_assignment, 
    colour, 
    configuration_design, 
    configuration_item, 
    descriptive_representation_item, 
    effectivity, 
    effectivity_relationship, 
    event_occurrence, 
    external_source, 
    general_property, 
    general_property_relationship, 
    geometric_representation_item, 
    geometric_tolerance, 
    make_from_usage_option, 
    mapped_item, 
    organization_role, 
    person_and_organization_role, 
    product_concept, 
    product_concept_relationship, 
    product_definition_context, 
    product_definition_formation, 
    product_definition_formation_relationship, 
    product_definition_shape, 
    product_related_product_category, 
    property_definition, 
    representation, 
    representation_relationship, 
    security_classification, 
    security_classification_assignment, 
    shape_aspect, 
    shape_aspect_relationship, 
    shape_representation, 
    time_interval_role, 
    topological_representation_item, 
    uncertainty_measure_with_unit);
  END_TYPE; 

  TYPE organization_item_203e2 = SELECT BASED_ON organization_item WITH 
    (alternate_product_relationship, 
    applied_action_assignment, 
    applied_identification_assignment, 
    applied_security_classification_assignment, 
    assembly_component_usage_substitute, 
    certification, 
    document_file, 
    general_property, 
    organizational_project, 
    product, 
    product_definition, 
    product_definition_formation, 
    product_definition_formation_relationship, 
    property_definition, 
    shape_representation);
  END_TYPE; 

  TYPE organizational_project_item_203e2 = SELECT BASED_ON project_item WITH 
    (executed_action, 
    product_concept);
  END_TYPE; 

  TYPE person_and_organization_item_203e2 = SELECT BASED_ON person_and_organization_item WITH 
    (alternate_product_relationship, 
    applied_action_assignment, 
    applied_security_classification_assignment, 
    assembly_component_usage_substitute, 
    certification, 
    document_file, 
    general_property, 
    organizational_project, 
    product, 
    product_definition, 
    product_definition_formation, 
    product_definition_formation_relationship, 
    property_definition, 
    shape_representation);
  END_TYPE; 

  TYPE cc_person_organization_item = SELECT
    (change, 
    change_request, 
    configuration_item, 
    contract, 
    product, 
    product_definition, 
    product_definition_formation, 
    security_classification, 
    start_request, 
    start_work);
  END_TYPE; 

  TYPE presented_item_select_203e2 = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON presented_item_select WITH 
    (action,
    action_method,
    action_relationship,
    product_concept,
    product_concept_feature,
    product_concept_feature_category,
    product_definition,
    product_definition_formation,
    product_definition_relationship);
  END_TYPE;

  TYPE security_classification_item_203e2 = SELECT BASED_ON security_classification_item WITH 
    (document_file, 
    product_definition, 
    product_definition_formation, 
    product_definition_usage);
  END_TYPE; 

  TYPE cc_specified_item = SELECT
    (product_definition, 
    shape_aspect);
  END_TYPE; 

  TYPE start_request_item = SELECT
    (product_definition_formation);
  END_TYPE; 

  TYPE time_interval_item_203e2 = SELECT BASED_ON time_interval_item WITH 
    (time_interval_based_effectivity);
  END_TYPE; 

  TYPE work_item = SELECT
    (product_definition_formation);
  END_TYPE; 

  ENTITY cc_design_approval
    SUBTYPE OF (approval_assignment);
      items : SET[1:?] OF approved_item;
  END_ENTITY;

  ENTITY cc_design_certification
    SUBTYPE OF (certification_assignment);
      items : SET[1:?] OF certified_item;
  END_ENTITY;

  ENTITY cc_design_contract
    SUBTYPE OF (contract_assignment);
      items : SET[1:?] OF contracted_item;
  END_ENTITY;

  ENTITY cc_design_date_and_time_assignment
    SUBTYPE OF (date_and_time_assignment);
      items : SET[1:?] OF date_time_item;
  END_ENTITY;

  ENTITY cc_design_person_and_organization_assignment
    SUBTYPE OF (person_and_organization_assignment);
      items : SET[1:?] OF cc_person_organization_item;
    WHERE
      WR1: cc_design_person_and_organization_correlation(SELF);
  END_ENTITY;

  ENTITY cc_design_security_classification
    SUBTYPE OF (security_classification_assignment);
      items : SET[1:?] OF cc_classified_item; 
  END_ENTITY;

  ENTITY cc_design_specification_reference
    SUBTYPE OF (document_reference);
      items : SET[1:?] OF cc_specified_item; 
  END_ENTITY;

  ENTITY change
    SUBTYPE OF (action_assignment);
      items : SET[1:?] OF work_item;
  END_ENTITY;

  ENTITY change_request
    SUBTYPE OF (action_request_assignment);
      items : SET[1:?] OF change_request_item;
  END_ENTITY;

  ENTITY design_context
    SUBTYPE OF (product_definition_context);
    WHERE
      WR1: SELF.life_cycle_stage = 'design';
  END_ENTITY;

  ENTITY design_make_from_relationship
    SUBTYPE OF (product_definition_relationship);
  END_ENTITY;

  ENTITY mechanical_context
    SUBTYPE OF (product_context);
    WHERE
      WR1: SELF.discipline_type = 'mechanical';
  END_ENTITY;

  ENTITY start_request
    SUBTYPE OF (action_request_assignment);
      items : SET[1:?] OF start_request_item;
  END_ENTITY;

  ENTITY start_work
    SUBTYPE OF (action_assignment);
      items : SET[1:?] OF work_item;
  END_ENTITY;

  ENTITY supplied_part_relationship
    SUBTYPE OF (product_definition_relationship);
  END_ENTITY;

  RULE application_protocol_definition_required FOR 
      (application_context); 
    WHERE 
      WR1:  SIZEOF( QUERY( ac <* application_context | 
              (SIZEOF (QUERY (apd <* USEDIN(ac,'APPLICATION_CONTEXT_SCHEMA.APPLICATION_PROTOCOL_DEFINITION.APPLICATION') | 
                apd.application_interpreted_model_schema_name = 'ap203_configuration_controlled_3d_design_of_mechanical_parts_and_assemblies' 
                )) > 0) 
              )) > 0;    
 
  END_RULE; 

  FUNCTION cc_design_person_and_organization_correlation
   (e : cc_design_person_and_organization_assignment) : BOOLEAN; 
    LOCAL
      po_role : STRING;
    END_LOCAL;
      po_role := e\person_and_organization_assignment.role.name;
    CASE po_role OF
      'request_recipient'      : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 SIZEOF(['AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'CHANGE_REQUEST',
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'START_REQUEST'] *
                                 TYPEOF (x)) = 1))
                                 THEN RETURN(FALSE);
                               END_IF;
      'initiator'              : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 SIZEOF(['AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'CHANGE_REQUEST',
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'START_REQUEST',
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'START_WORK',
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'CHANGE'] *
                                 TYPEOF (x)) = 1))
                                 THEN RETURN(FALSE);
                               END_IF;
      'creator'                : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 SIZEOF (['AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'PRODUCT_DEFINITION_FORMATION',
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'PRODUCT_DEFINITION'] *
                                 TYPEOF (x)) = 1))
                                 THEN RETURN (FALSE);
                               END_IF;
      'part_supplier'          : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'PRODUCT_DEFINITION_FORMATION'
                                 IN TYPEOF (x)))
                                 THEN RETURN(FALSE);
                               END_IF;
      'design_supplier'        : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'PRODUCT_DEFINITION_FORMATION'
                                 IN TYPEOF (x)))
                                 THEN RETURN(FALSE);
                               END_IF;
      'design_owner'           : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.PRODUCT'
                                 IN TYPEOF (x)))
                                 THEN RETURN(FALSE);
                               END_IF;
      'configuration_manager'  : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'CONFIGURATION_ITEM'
                                 IN TYPEOF (x)))
                                 THEN RETURN(FALSE);
                               END_IF;
      'contractor'             : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.CONTRACT'
                                 IN TYPEOF (x)))
                                 THEN RETURN(FALSE);
                               END_IF;
      'classification_officer' : IF SIZEOF (e.items) <>
                                 SIZEOF (QUERY (x <* e.items |
                                 'AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM.' +
                                 'SECURITY_CLASSIFICATION'
                                 IN TYPEOF (x))) THEN
                                 RETURN(FALSE);
                               END_IF;
    OTHERWISE : RETURN(TRUE);
  END_CASE;
  RETURN (TRUE);
  END_FUNCTION; 

END_SCHEMA;  
