(*
 * $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 physical_unit_design_view(Physical_unit_design_view_arm, Physical_unit_design_view_mim);*)


entity_mapping Assembly_alternate_product(Assembly_alternate_product, alternate_product_relationship);

mapping_constraints;
{alternate_product_relationship
alternate_product_relationship.basis = 'assembly alternate product'}

end_mapping_constraints;

attribute_mapping basis_context(basis_context, $PATH, Part_design_view);
alternate_product_relationship
alternate_product_relationship.base ->
product <-
product_definition_formation.of_product
product_definition_formation <-
product_definition.formation
product_definition <-
product_definition_relationship.related_product_definition
{product_definition_relationship =>
product_definition_usage =>
assembly_component_usage}
product_definition_relationship
product_definition_relationship.relating_product_definition ->
product_definition =>
physical_unit

end_attribute_mapping;

end_entity_mapping;

entity_mapping Assembly_component_armx(Assembly_component_armx, assembly_component);

mapping_constraints;
assembly_component <=
component_definition <=
product_definition

end_mapping_constraints;
(* Probably will be removed according SEDS-1921
attribute_mapping derived_from(derived_from, $PATH, Generic_footprint_definition_armx);
assembly_component <=
component_definition <=
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 =>
part_template_definition =>
geometric_template =>
structured_template =>
multi_stratum_structured_template =>
generic_footprint_definition

end_attribute_mapping;

attribute_mapping derived_from(derived_from, $PATH, Padstack_definition_armx);
assembly_component <=
component_definition <=
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 =>
part_template_definition =>
geometric_template =>
structured_template =>
multi_stratum_structured_template =>
padstack_definition

end_attribute_mapping;
*)
attribute_mapping derived_from(derived_from, $PATH, Template_definition);
assembly_component <=
component_definition <=
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 =>
part_template_definition

end_attribute_mapping;

attribute_mapping derived_from(derived_from, $PATH, Part_view_definition);
assembly_component <=
component_definition <=
product_definition <-
product_definition_relationship.related_product_definition
{product_definition_relationship
product_definition_relationship.name = 'definition usage'}
product_definition_relationship
product_definition_relationship.relating_product_definition ->
product_definition =>
physical_unit

end_attribute_mapping;

end_entity_mapping;

entity_mapping Assembly_item_number_armx(Assembly_item_number_armx, assembly_item_number);

mapping_constraints;
		[assembly_item_number <=
		group]
		[assembly_item_number <=
		applied_group_assignment]
end_mapping_constraints;

attribute_mapping item_number(item_number, group.name);
    assembly_item_number <=
    group
		group.name
end_attribute_mapping;

attribute_mapping assembly_usage(assembly_usage, $PATH, assembly_component_usage);
		assembly_item_number <=
		applied_group_assignment
		applied_group_assignment.items[i] ->
		groupable_item *> pudv_groupable_item
		pudv_groupable_item = assembly_component_usage
end_attribute_mapping;

end_entity_mapping;

entity_mapping Component_material_relationship_armx(Component_material_relationship_armx, component_material_relationship);

mapping_constraints;
		[component_material_relationship <=
		property_definition]
		[component_material_relationship <=
		group]
end_mapping_constraints;

attribute_mapping associated_design(associated_design, $PATH, Part_design_view);
		component_material_relationship <=
		property_definition
		property_definition.definition ->
		characterized_definition
		characterized_definition = characterized_product_definition
		characterized_product_definition
		characterized_product_definition = product_definition
		product_definition =>
		physical_unit
end_attribute_mapping;

attribute_mapping component_1(component_1, $PATH, assembly_component_or_item_number);
		component_material_relationship <=
	  group <-
		group_assignment.assigned_group
		group_assignment
	  group_assignment =>
	  component_material_relationship_assignment
	  {component_material_relationship_assignment <=
	  role_association
	  role_association.role -> 
	  object_role
	  object_role.name = 'component 1'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		(component_material_relationship_assignment_item = assembly_item_number)
		(component_material_relationship_assignment_item = assembly_component_usage)
end_attribute_mapping;

attribute_mapping component_1(component_1, $PATH, Assembly_item_number_armx);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'component 1'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		component_material_relationship_assignment_item = assembly_item_number
end_attribute_mapping;

attribute_mapping component_1(component_1, $PATH, assembly_component_usage);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'component 1'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		component_material_relationship_assignment_item = assembly_component_usage
end_attribute_mapping;

attribute_mapping component_2(component_2, $PATH, assembly_component_or_item_number);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'component 2'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		(component_material_relationship_assignment_item = assembly_item_number)
		(component_material_relationship_assignment_item = assembly_component_usage)
end_attribute_mapping;

attribute_mapping component_2(component_2, $PATH, Assembly_item_number_armx);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'component 2'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		component_material_relationship_assignment_item = assembly_item_number
end_attribute_mapping;

attribute_mapping component_2(component_2, $PATH, assembly_component_usage);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'component 2'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		component_material_relationship_assignment_item = assembly_component_usage
end_attribute_mapping;

attribute_mapping material(material, $PATH, assembly_component_or_item_number);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'material'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		(component_material_relationship_assignment_item = assembly_item_number)
		(component_material_relationship_assignment_item = assembly_component_usage)
end_attribute_mapping;

attribute_mapping material(material, $PATH, Assembly_item_number_armx);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'material'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		component_material_relationship_assignment_item = assembly_item_number
end_attribute_mapping;

attribute_mapping material(material, $PATH, assembly_component_usage);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'material'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		component_material_relationship_assignment_item = assembly_component_usage
end_attribute_mapping;

attribute_mapping role(role, group.name);
		component_material_relationship <=
		group
		group.name
		(group.name = 'bonding')
		(group.name = 'coating')
end_attribute_mapping;

attribute_mapping specification(specification, $PATH, assembly_item_number_or_process_specification);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'specification'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		(component_material_relationship_assignment_item = assembly_item_number)
		(component_material_relationship_assignment_item = specification_definition)
end_attribute_mapping;

attribute_mapping specification(specification, $PATH, Assembly_item_number_armx);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'specification'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		component_material_relationship_assignment_item = assembly_item_number
end_attribute_mapping;

attribute_mapping specification(specification, $PATH, Process_specification);
		component_material_relationship <=
		group <-
		group_assignment.assigned_group
		group_assignment
		group_assignment =>
		component_material_relationship_assignment
		{component_material_relationship_assignment <=
		role_association
		role_association.role -> 
		object_role
		object_role.name = 'specification'}
		component_material_relationship_assignment.items[i] ->
		component_material_relationship_assignment_item
		component_material_relationship_assignment_item = specification_definition
end_attribute_mapping;


end_entity_mapping;


entity_mapping Component_make_from_relationship(Component_make_from_relationship, make_from_usage_option);

mapping_constraints;
make_from_usage_option

end_mapping_constraints;

attribute_mapping resultant_component(resultant_component, $PATH, Assembly_component_armx);
make_from_usage_option <=
product_definition_usage <=
product_definition_relationship
product_definition_relationship.related_product_definition ->
product_definition =>
component_definition =>
assembly_component

end_attribute_mapping;

attribute_mapping reusable_component(reusable_component, $PATH, Assembly_component_armx);
make_from_usage_option <=
product_definition_usage <=
product_definition_relationship
product_definition_relationship.relating_product_definition ->
product_definition =>
component_definition =>
assembly_component

end_attribute_mapping;

end_entity_mapping;

entity_mapping Component_to_physical_usage_view_assignment(Component_to_physical_usage_view_assignment, product_definition_relationship);

mapping_constraints;
{product_definition_relationship
product_definition_relationship.name = 'component to physical usage view assignment'}

end_mapping_constraints;

attribute_mapping usage_view_component(usage_view_component, $PATH, Assembly_component_armx);
product_definition_relationship
product_definition_relationship.related_product_definition ->
product_definition =>
component_definition =>
assembly_component

end_attribute_mapping;

attribute_mapping design_view_component(design_view_component, $PATH, Assembly_component_armx);
product_definition_relationship
product_definition_relationship.relating_product_definition ->
product_definition =>
component_definition =>
assembly_component

end_attribute_mapping;

end_entity_mapping;

entity_mapping Connection_zone_in_design_view(Connection_zone_in_design_view, shape_aspect);

mapping_constraints;
{shape_aspect
shape_aspect.name = 'connection zone in design view'}

end_mapping_constraints;

end_entity_mapping;

entity_mapping Next_assembly_usage_occurrence_relationship_armx(Next_assembly_usage_occurrence_relationship_armx, next_assembly_usage_occurrence_relationship);

mapping_constraints;
[next_assembly_usage_occurrence_relationship <=
next_assembly_usage_occurrence]
[next_assembly_usage_occurrence_relationship <=
product_definition_occurrence_relationship]


end_mapping_constraints;

(* GL - Workarround mapping *)
attribute_mapping related_product_definition(related_product_definition, $PATH, Definition_based_product_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 <-
product_definition_relationship.related_product_definition
{product_definition_relationship
product_definition_relationship.name = 'definition usage'}
product_definition_relationship
product_definition_relationship.relating_product_definition ->
product_definition}

end_attribute_mapping;

end_entity_mapping;


entity_mapping Part_design_view(Part_design_view, physical_unit);

mapping_constraints;
physical_unit <=
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 <=
application_context_element
application_context_element.name = 'physical design'}


end_mapping_constraints;

attribute_mapping usage_view(usage_view, $PATH, Part_usage_view);
physical_unit <=
product_definition <-
product_definition_relationship.related_product_definition
{product_definition_relationship
product_definition_relationship.name = 'design usage'}
product_definition_relationship
product_definition_relationship.relating_product_definition ->
product_definition =>
physical_unit

end_attribute_mapping;

end_entity_mapping;

entity_mapping Physical_component_armx(Physical_component_armx, physical_component);

mapping_constraints;
physical_component <=
assembly_component <=
component_definition <=
product_definition

end_mapping_constraints;

end_entity_mapping;

entity_mapping Product_occurrence_with_quantity(Product_occurrence_with_quantity, product_definition)
extended;

attribute_mapping occurrence_quantity(occurrence_quantity, , textual_quantity_specification);

					product_definition <- 
					product_definition_occurrence_relationship.occurrence
					product_definition_occurrence_relationship.occurrence_usage ->
					assembly_component_usage
					assembly_component_usage => quantified_assembly_component_usage
					quantified_assembly_component_usage.quantity ->
					measure_with_unit
					measure_with_unit.value_component ->
					measure_value
					measure_value = descriptive_measure
			
end_attribute_mapping;

end_entity_mapping;


entity_mapping Requirement_assignment_armx(Requirement_assignment_armx, requirement_assignment)
extended;

attribute_mapping assigned_to(assigned_to, , assembly_component_usage);

					requirement_assigned_item *> pudv_requirement_assigned_item
					pudv_requirement_assigned_item = 
					assembly_component_usage
				
end_attribute_mapping;

attribute_mapping assigned_to(assigned_to, , Assembly_item_number_armx);

					requirement_assigned_item *> pudv_requirement_assigned_item
					pudv_requirement_assigned_item = 
					assembly_item_number
				
end_attribute_mapping;

attribute_mapping assigned_to(assigned_to, , Component_material_relationship_armx);

					requirement_assigned_item *> pudv_requirement_assigned_item
					pudv_requirement_assigned_item = 
					component_material_relationship
				
end_attribute_mapping;


end_entity_mapping;

entity_mapping Thermal_component_armx(Thermal_component_armx, thermal_component);

mapping_constraints;
thermal_component <=
assembly_component <=
component_definition <=
product_definition

end_mapping_constraints;

end_entity_mapping;
(*end_schema_mapping;*)
