(*
 * $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 part_occurrence(Part_occurrence_arm, Part_occurrence_mim);*)


entity_mapping Definition_based_part_occurrence(Definition_based_part_occurrence,
(* We are not supporting those alternatives
 (assembly_component_usage) *)
 (product_definition));

mapping_constraints;
(* We are not supporting those alternatives
(
assembly_component_usage <= product_definition_usage
product_definition_usage <= product_definition_relationship
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'}
)
*)
(product_definition
(
 ({[product_definition.frame_of_reference ->
product_definition_context <= 
application_context_element 
application_context_element.name = 'part occurrence'] 
[product_definition
([product_definition <- 
product_definition_occurrence_relationship.occurrence 
product_definition_occurrence_relationship 
product_definition_occurrence_relationship.occurrence_usage ->] 
[product_definition <- 
product_definition_relationship.related_product_definition 
product_definition_relationship 
{product_definition_relationship.name = 'definition usage'} 
product_definition_relationship.relating_product_definition -> 
product_definition <- 
{product_definition.frame_of_reference ->
product_definition_context <= 
application_context_element 
application_context_element.name = 'part definition'} 
product_definition_relationship.related_product_definition 
product_definition_relationship =>
product_definition_usage =>] 
assembly_component_usage) 
([product_definition <- 
product_definition_relationship.related_product_definition 
product_definition_relationship 
product_definition_relationship.name = 'definition usage'] 
[product_definition <- 
product_definition_relationship.related_product_definition 
product_definition_relationship =>
product_definition_usage])]})
)(
product_definition
{product_definition.frame_of_reference -> product_definition_context
product_definition_context <= application_context_element 
application_context_element.name = 'part occurrence'}
product_definition <- product_definition_relationship.related_product_definition
product_definition_relationship
{product_definition_relationship.name = 'definition usage'}
))
end_mapping_constraints;

attribute_mapping derived_from(derived_from, ($IDENTICAL_MAPPING)($PATH), Part_view_definition);

product_definition
{product_definition.frame_of_reference -> product_definition_context
product_definition_context <= application_context_element 
application_context_element.name = 'part occurrence'}
product_definition <- product_definition_relationship.related_product_definition
product_definition_relationship
{product_definition_relationship.name = 'definition usage'}
{product_definition_relationship => product_definition_usage}
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;

end_entity_mapping;

entity_mapping Part_occurrence(Part_occurrence, 
			(/SUBTYPE(Definition_based_part_occurrence)/)
			(/SUBTYPE(Specification_based_part_occurrence)/)
		);

mapping_constraints;
			(/SUBTYPE(Definition_based_part_occurrence)/)
			(/SUBTYPE(Specification_based_part_occurrence)/)
end_mapping_constraints;


end_entity_mapping;

entity_mapping Part_occurrence_definition_relationship(Part_occurrence_definition_relationship, (assembly_component_usage)(* GL in our implementation we make it stricter (|product_definition_relationship|) *));

mapping_constraints;

assembly_component_usage <= product_definition_usage
product_definition_usage <= product_definition_relationship
(* GL added to avoid mathcing it by the mapping of definition_based_product_occurrence *)
{product_definition_relationship.name != 'definition usage'}

end_mapping_constraints;

attribute_mapping relating_product_definition(relating_product_definition, $PATH, Part_view_definition);
assembly_component_usage <= product_definition_usage
product_definition_usage <= product_definition_relationship
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;
(* GL - it works only in a complex with Next_assembly_usage_occurrence_armx *)
attribute_mapping related_product_definition(related_product_definition, $PATH, Part_occurrence);
assembly_component_usage =>
next_assembly_usage_occurrence =>
next_assembly_usage_occurrence_relationship <=
product_definition_occurrence_relationship
product_definition_occurrence_relationship.occurrence -> product_definition
(* GL - added more constraints in order to avoid mapping problems *)
{product_definition.frame_of_reference ->
product_definition_context <= 
application_context_element 
application_context_element.name = 'part occurrence'}


end_attribute_mapping;

end_entity_mapping;

entity_mapping Specification_based_part_occurrence(Specification_based_part_occurrence, product_definition);

mapping_constraints;

product_definition
{product_definition.frame_of_reference -> product_definition_context
product_definition_context <= application_context_element 
application_context_element.name = 'part occurrence'}
product_definition.formation -> product_definition_formation
{product_definition_formation.of_product -> product
product <- product_related_product_category.products[i]
product_related_product_category <= product_category
product_category.name = 'part'}
{product_definition_formation = configuration_design_item
configuration_design_item <- configuration_design.design
{configuration_design.name = 'product design'}
configuration_design.configuration -> configuration_item
(configuration_item => product_identification)
(configuration_item => product_identification
product_identification => product_specification)}

end_mapping_constraints;

end_entity_mapping;

(*end_schema_mapping;*)
