(*
   $Id$
   ISO TC184/SC4/WG12 N4167 - ISO/TS 10303-1740 Requirement decomposition - EXPRESS ARM
   Supersedes ISO TC184/SC4/WG12 N3591
*)

SCHEMA Requirement_decomposition_arm;

	USE FROM Conductivity_material_aspects_arm;	-- ISO/TS 10303-1756
	USE FROM Elemental_geometric_shape_arm;	-- ISO/TS 10303-1004
	USE FROM Functional_specification_arm;	-- ISO/TS 10303-1679
	USE FROM Production_rule_arm;	-- ISO/TS 10303-1739

	REFERENCE FROM Specification_document_arm(get_document_definition);	-- ISO/TS 10303-1747
	REFERENCE FROM Characterizable_object_arm(bag_to_set);  -- ISO/TS 10303-1765

    TYPE rd_requirement_assignment_item = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON requirement_assignment_item WITH
     (Group,
      Group_relationship);
    END_TYPE;

    TYPE material_conductivity_classification = ENUMERATION OF
     (conductive,
      resistive,
      semi_conductive,
      non_conductive);
    END_TYPE;

	TYPE characteristic_select = SELECT
      (characteristic,
       Boolean_representation_item,
       Date_time_representation_item,
       Integer_representation_item,
       Logical_representation_item,
       Property_value_representation,
       Rational_representation_item,
       Real_representation_item,
       Sequence_representation_item,
       Set_representation_item);
	END_TYPE; 

	TYPE rd_documented_element_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON documented_element_select WITH 
	   (Predefined_requirement_view_definition);
	END_TYPE; 

	TYPE rd_material_item_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON material_item_select WITH
		(Predefined_requirement_view_definition);
	END_TYPE;

	TYPE rd_property_assignment_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON property_assignment_select WITH
		(Requirement_view_definition);
	END_TYPE;

	TYPE relationship_operation = ENUMERATION OF
    	(and_operation,
		or_operation);
	END_TYPE;

  ENTITY Constraint_occurrence
    SUPERTYPE OF (View_based_constraint_occurrence)
    SUBTYPE OF (Predefined_requirement_view_definition);
      logical_relation : OPTIONAL Complex_clause;
    WHERE
      WR1 : (('REQUIREMENT_DECOMPOSITION_ARM.' + 'VIEW_BASED_CONSTRAINT_OCCURRENCE') IN TYPEOF(SELF)) OR EXISTS(logical_relation);
      WR2 : NOT EXISTS(SELF\Product_view_definition.id);
  END_ENTITY;

  ENTITY Design_characteristic_occurrence
    SUBTYPE OF (Predefined_requirement_view_definition);
  END_ENTITY;

  ENTITY View_based_constraint_occurrence
    SUPERTYPE OF (Shape_and_view_based_constraint_occurrence)
    SUBTYPE OF (Constraint_occurrence);
      constraining_part : Product_view_definition;
  END_ENTITY;

  ENTITY Material_electrical_conductivity_requirement_occurrence
    SUBTYPE OF (Predefined_requirement_view_definition);
      electrical_conductivity_characteristic : material_conductivity_classification;
  END_ENTITY;

  ENTITY Operational_requirement_occurrence_relationship
     SUBTYPE OF (Assigned_property, View_definition_relationship);
       SELF\View_definition_relationship.relating_view RENAMED operand_1 : Requirement_view_definition;
       SELF\View_definition_relationship.related_view RENAMED operand_2  : Requirement_view_definition;
       SELF\Assigned_property.described_element RENAMED result           : Requirement_view_definition;
       relationship_type                                                 : relationship_operation;
    WHERE
      WR1 : operand_1 :<>: operand_2;
  END_ENTITY;

  ENTITY Predefined_requirement_view_definition
	SUPERTYPE OF(ONEOF(Constraint_occurrence,
		 Design_characteristic_occurrence))
    SUBTYPE OF(Requirement_view_definition);
      required_analytical_representation  : OPTIONAL SET[1:?] OF Analytical_model_application;
      required_functional_specification   : OPTIONAL SET[1:?] OF Functional_specification;
      required_characteristic             : OPTIONAL characteristic_select;
    DERIVE
		requirement_specification: SET[1:?] OF Document_definition :=
  			get_document_definition(SELF, 'requirement specification', 
  			'SPECIFICATION_DOCUMENT_ARM.SPECIFICATION_DEFINITION');
		reference_clause: SET[0:1] OF Document_definition :=
  			get_document_definition(SELF, 'reference clause', 
  			'SPECIFICATION_DOCUMENT_ARM.DOCUMENT_DEFINITION');
   INVERSE
	  required_material : SET [0:1] OF material_identification FOR items;      
    WHERE  
	  WR1 : NOT (SIZEOF(required_material) = 1) OR
            ('CONDUCTIVITY_MATERIAL_ASPECTS_ARM.'+ 'MATERIAL_IDENTIFICATION_WITH_CONDUCTIVITY_CLASSIFICATION' IN TYPEOF (required_material));
      WR2: SELF\Product_view_definition.initial_context.application_domain IN 
          ['mechanical', 'thermal', 'electromechancial', 'electromagnetic compatibility', 'electrical'];
      WR3: SELF\Product_view_definition.initial_context.life_cycle_stage in ['design', 'qualify', 'inspect', 'test'];
      WR4 : NOT EXISTS(SELF\Product_view_definition.name);
  END_ENTITY;

  ENTITY Requirement_view_definition_relationship
     SUBTYPE OF (View_definition_relationship);
       SELF\View_definition_relationship.relating_view RENAMED primary  : Requirement_view_definition;
       SELF\View_definition_relationship.related_view RENAMED secondary : Requirement_view_definition;
       SELF\View_definition_relationship.relation_type                  : STRING;
     WHERE
       WR1 : primary :<>: secondary;
       WR2 : SELF\View_definition_relationship.relation_type IN ['derived from', 'precedence', 'reference to', 'supplemental'];
  END_ENTITY;

  ENTITY Shape_and_view_based_constraint_occurrence
    SUBTYPE OF (View_based_constraint_occurrence);
      constraining_shape : SET[1:?] OF Geometric_model;
    WHERE
      WR1 : valid_constraining_shape(constraining_shape,
 SELF\View_based_constraint_occurrence.constraining_part);
  END_ENTITY;

  FUNCTION valid_constraining_shape(
    sd   : SET OF Geometric_model ;
    eepd : Product_view_definition
  ) : BOOLEAN;

    RETURN(TRUE);
  END_FUNCTION;

FUNCTION get_rvd(
	input : requirement_assignment_item;
	id : STRING
) : SET OF Requirement_view_definition; 

LOCAL
	rvd : SET[0:?] OF Requirement_view_definition := [];  --this gives us access to the information base
	ra : SET[0:?] OF Requirement_assignment :=[];
END_LOCAL;
	ra := bag_to_set((QUERY(rai <* USEDIN (input, 'REQUIREMENT_ASSIGNMENT_ARM.'+
	'REQUIREMENT_ASSIGNMENT.ASSIGNED_TO') | (rai.id = id))));

	-- iterate over ra
	REPEAT i := 1 to SIZEOF(ra) by 1;
		rvd := rvd + ra[i].assigned_requirement;
	END_REPEAT;

	RETURN(rvd);
END_FUNCTION;


END_SCHEMA;

