(*
 * $Id$
 *
 * JSDAI(TM), a way to implement STEP, ISO 10303
 * Copyright (C) 1997-2008, LKSoftWare GmbH, Germany
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License
 * version 3 as published by the Free Software Foundation (AGPL v3).
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * JSDAI is a registered trademark of LKSoftWare GmbH, Germany
 * This software is also available under commercial licenses.
 * See also http://www.jsdai.net/
 *)

(*schema_mapping item_definition_structure(Item_definition_structure_arm, Item_definition_structure_mim);*)

uof_mapping Item_definition_structure(Item_definition_structure);

entity_mapping Assembled_part_association(Assembled_part_association, assembly_component_usage);

mapping_constraints;
assembly_component_usage <= 
product_definition_usage <= 
product_definition_relationship 
(* Security constraint in order to avoid wrong hits *)
{product_definition_relationship.name != 'interconnect module stratum assembly relationship'}
end_mapping_constraints;

attribute_mapping relating_view(relating_view, $PATH, Assembly_definition_armx);
 	 assembly_component_usage <= product_definition_usage <= product_definition_relationship 
product_definition_relationship.relating_product_definition -> product_definition  
{product_definition <- product_definition_context_association.definition 
product_definition_context_association 
{product_definition_context_association.frame_of_reference -> product_definition_context <= application_context_element  
application_context_element.name = 'assembly definition'} 
product_definition_context_association.role -> product_definition_context_role 
product_definition_context_role.name = 'part definition type'}  	 
end_attribute_mapping;

end_entity_mapping;

entity_mapping assembly_definition_armx(assembly_definition_armx, product_definition);

mapping_constraints;
 product_definition 
{product_definition <- 
product_definition_context_association.definition 
product_definition_context_association 
{product_definition_context_association.role -> product_definition_context_role 
product_definition_context_role.name = 'part definition type'} 
product_definition_context_association.frame_of_reference -> product_definition_context 
product_definition_context <= application_context_element  
application_context_element.name = 'assembly definition' }
end_mapping_constraints;

end_entity_mapping;
(* Mapping is to exactly product_definition_relationship and not subtypes in order to distinguish this mapping from
next_assembly_usage_occurrence *)

entity_mapping Part_definition_relationship(Part_definition_relationship, |product_definition_relationship|);

mapping_constraints;
(* GL added additional constraints - mainly AP210 specific links already covered directly *)
{[product_definition_relationship.name != 'design usage']
[product_definition_relationship.name != 'used package']
[product_definition_relationship.name != 'definition usage']}
end_mapping_constraints;

attribute_mapping relating_view(relating_view, $PATH, Part_view_definition);
 product_definition_relationship.relating_product_definition -> product_definition  
{product_definition.frame_of_reference -> product_definition_context 
product_definition_context <= application_context_element 
application_context_element.name = 'part definition'} 	 
end_attribute_mapping;

attribute_mapping related_view(related_view, $PATH, Part_view_definition);
 product_definition_relationship.related_product_definition -> product_definition  
{product_definition.frame_of_reference -> product_definition_context 
product_definition_context <= application_context_element 
application_context_element.name = 'part definition'} 	 
end_attribute_mapping;

end_entity_mapping;
(* Moved to Ida_STEP_schema
entity_mapping Part_definition_relationship__tool_part_relationship(Part_definition_relationship__tool_part_relationship, |product_definition_relationship|);

mapping_constraints;
{product_definition_relationship.name = 'tool part relationship'}
end_mapping_constraints;

end_entity_mapping;
*)

entity_mapping Geometrical_relationship(Geometrical_relationship, product_definition_relationship);

mapping_constraints;
{product_definition_relationship.name = 'geometrical relationship'} 	
end_mapping_constraints;

attribute_mapping definition_placement(definition_placement, $PATH, Geometric_placement_operation);
product_definition_relationship 
{product_definition_relationship.name = 'geometrical relationship' } 	
[product_definition_relationship.relating_product_definition -> product_definition 
characterized_product_definition = product_definition 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation  
{representation => shape_representation} 
representation.items[i] -> representation_item =>] 
[product_definition_relationship.related_product_definition -> product_definition 
characterized_product_definition = product_definition 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation <-  {representation => shape_representation} 
representation_map.mapped_representation 
representation_map <- mapped_item.mapping_source] 
[characterized_product_definition = product_definition_relationship 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation 
{representation => shape_representation} 
representation.items[i] -> representation_item =>]  
mapped_item
end_attribute_mapping;

(* Removed option
attribute_mapping definition_placement(definition_placement, $PATH, Mapping_based_template_instance__rr);
product_definition_relationship 
{product_definition_relationship.name = 'geometrical relationship' }  
[product_definition_relationship.relating_product_definition -> product_definition 
characterized_product_definition = product_definition 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation <- {representation => shape_representation} 
representation_relationship.rep_2] 
[product_definition_relationship.related_product_definition -> product_definition 
characterized_product_definition = product_definition 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation <-  {representation => shape_representation} 
representation_relationship.rep_1] 
[characterized_product_definition = product_definition_relationship 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition => product_definition_shape <-  context_dependent_shape_representation.represented_product_relation 
context_dependent_shape_representation 
context_dependent_shape_representation.representation_relation -> shape_representation_relationship <=]  
representation_relationship =>  representation_relationship_with_transformation
end_attribute_mapping;

attribute_mapping definition_placement(definition_placement, $PATH, Transformation_based_template_instance__mi);
product_definition_relationship 
{product_definition_relationship.name = 'geometrical relationship' } 	
[product_definition_relationship.relating_product_definition -> product_definition 
characterized_product_definition = product_definition 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation  
{representation => shape_representation} 
representation.items[i] -> representation_item =>] 
[product_definition_relationship.related_product_definition -> product_definition 
characterized_product_definition = product_definition 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation <-  {representation => shape_representation} 
representation_map.mapped_representation 
representation_map <- mapped_item.mapping_source] 
[characterized_product_definition = product_definition_relationship 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation 
{representation => shape_representation} 
representation.items[i] -> representation_item =>]  
mapped_item
end_attribute_mapping;
*)
attribute_mapping definition_placement(definition_placement, $PATH, Geometric_model_relationship_with_transformation);
product_definition_relationship 
{product_definition_relationship.name = 'geometrical relationship' }  
[product_definition_relationship.relating_product_definition -> product_definition 
characterized_product_definition = product_definition 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation <- {representation => shape_representation} 
representation_relationship.rep_2] 
[product_definition_relationship.related_product_definition -> product_definition 
characterized_product_definition = product_definition 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition  
{property_definition => product_definition_shape} 
represented_definition = property_definition 
represented_definition <- property_definition_representation.definition 
property_definition_representation  
{property_definition_representation => shape_definition_representation} 
property_definition_representation.used_representation -> representation <-  {representation => shape_representation} 
representation_relationship.rep_1] 
[characterized_product_definition = product_definition_relationship 
characterized_definition = characterized_product_definition 
characterized_definition <- property_definition.definition 
property_definition => product_definition_shape <-  context_dependent_shape_representation.represented_product_relation 
context_dependent_shape_representation 
context_dependent_shape_representation.representation_relation -> shape_representation_relationship <=]  
representation_relationship =>  representation_relationship_with_transformation
end_attribute_mapping;

end_entity_mapping;

end_uof_mapping;

(*end_schema_mapping;*)
