(*
 * $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 default_tolerance(Default_tolerance_arm, Default_tolerance_mim);*)

uof_mapping Default_Tolerance(Default_Tolerance);

entity_mapping Default_setting_association(Default_setting_association, property_definition_representation);

mapping_constraints;
{property_definition_representation 
property_definition_representation.name = 'default setting association'} 

end_mapping_constraints;

attribute_mapping default_value(default_value, $PATH, default_setting_select);
property_definition_representation 
property_definition_representation.definition -> represented_definition 
represented_definition = property_definition
property_definition
end_attribute_mapping;

attribute_mapping default_value(default_value, $PATH, General_tolerances);
({property_definition_representation 
property_definition_representation.name = 'default setting association'}) 

end_attribute_mapping;

attribute_mapping default_context(default_context, $PATH, Item_shape);
property_definition_representation 
property_definition_representation.definition -> represented_definition 
represented_definition = property_definition 
property_definition => 
product_definition_shape
end_attribute_mapping;

end_entity_mapping;

entity_mapping General_tolerance_table(General_tolerance_table, default_tolerance_table);

mapping_constraints;
default_tolerance_table <= 
representation
end_mapping_constraints;

attribute_mapping tolerance_type(tolerance_type, representation.name);
default_tolerance_table <= 
representation
representation.name
end_attribute_mapping;

end_entity_mapping;

entity_mapping General_tolerances(General_tolerances, representation);

mapping_constraints;
representation 
{representation.name = 'default tolerances'}
representation.context_of_items -> 
representation_context 
{representation_context.context_type = 'default setting'}
end_mapping_constraints;

attribute_mapping table_definition(table_definition, $PATH, general_tolerance_table_select);
representation representation <- 
representation_relationship.rep_2 
representation_relationship
{representation_relationship.name = 'general tolerance definition'} 
representation_relationship.rep_1 -> 
representation
end_attribute_mapping;

attribute_mapping table_definition(table_definition, $PATH, General_tolerance_table);
representation representation <- 
representation_relationship.rep_2 
representation_relationship
{representation_relationship.name = 'general tolerance definition'} 
representation_relationship.rep_1 -> 
representation => 
default_tolerance_table
end_attribute_mapping;

attribute_mapping tolerance_class(tolerance_class, descriptive_representation_item.description);
representation 
representation.items[i] -> 
representation_item =>
{representation_item.name = 'tolerance class'} 
descriptive_representation_item 
descriptive_representation_item.description
end_attribute_mapping;

end_entity_mapping;

entity_mapping Plus_minus_toleranced_datum(Plus_minus_toleranced_datum, measure_representation_item);

mapping_constraints;
{measure_representation_item <= 
representation_item 
representation_item.name = 'plus minus tolerance value'}
end_mapping_constraints;

attribute_mapping tolerance_value(tolerance_value, $IDENTICAL_MAPPING, measure_representation_item);

end_attribute_mapping;

end_entity_mapping;

entity_mapping Significant_number_of_digits(Significant_number_of_digits, measure_representation_item);

mapping_constraints;
{measure_representation_item <= 
representation_item 
representation_item.name = 'significant number of digits'}
end_mapping_constraints;

attribute_mapping number_of_digits(number_of_digits, measure_with_unit.value_component);
measure_representation_item <= 
measure_with_unit 
measure_with_unit.value_component
{measure_with_unit.value_component -> 
measure_value 
measure_value = count_measure}
end_attribute_mapping;

end_entity_mapping;

entity_mapping Tolerance_table_cell(Tolerance_table_cell, default_tolerance_table_cell);

mapping_constraints;
default_tolerance_table_cell <= 
compound_representation_item
end_mapping_constraints;

attribute_mapping cell_value(cell_value, $PATH, Plus_minus_toleranced_datum);
default_tolerance_table_cell <= 
compound_representation_item 
compound_representation_item.item_element -> 
compound_item_definition 
compound_item_definition = set_representation_item 
set_representation_item[i] -> representation_item 
representation_item => 
measure_representation_item
end_attribute_mapping;

attribute_mapping cell_value(cell_value, $PATH, Upper_lower_toleranced_datum);
default_tolerance_table_cell <= 
compound_representation_item 
compound_representation_item.item_element -> 
compound_item_definition 
compound_item_definition = set_representation_item 
set_representation_item[i] -> representation_item 
representation_item => 
measure_representation_item

end_attribute_mapping;

attribute_mapping description(description, $PATH);
default_tolerance_table_cell <= 
compound_representation_item 
compound_representation_item.item_element -> 
compound_item_definition 
compound_item_definition = set_representation_item 
set_representation_item[i] -> representation_item 
representation_item =>
{representation_item.name = 'cell description'} 
descriptive_representation_item
descriptive_representation_item.description

end_attribute_mapping;

attribute_mapping limit(limit, $PATH, Significant_number_of_digits);
default_tolerance_table_cell <= 
compound_representation_item 
compound_representation_item.item_element ->
compound_item_definition 
compound_item_definition = set_representation_item 
set_representation_item[i] -> representation_item 
representation_item =>
measure_representation_item
end_attribute_mapping;

attribute_mapping limit(limit, $PATH, Upper_lower_limit);
default_tolerance_table_cell <= 
compound_representation_item 
compound_representation_item.item_element -> 
compound_item_definition 
compound_item_definition = set_representation_item 
set_representation_item[i] -> representation_item representation_item => 
measure_representation_item
end_attribute_mapping;

attribute_mapping tolerance_class(tolerance_class, representation_item.name);
default_tolerance_table_cell <= 
compound_representation_item <= 
representation_item 
representation_item.name
end_attribute_mapping;

attribute_mapping tolerance_table(tolerance_table, $PATH, General_tolerance_table);
default_tolerance_table_cell <= 
compound_representation_item <= 
representation_item 
representation_item <- 
representation.items[i] 
representation => 
default_tolerance_table
end_attribute_mapping;

end_entity_mapping;

entity_mapping Upper_lower_limit(Upper_lower_limit, [measure_representation_item]
[measure_representation_item]);

mapping_constraints;
[{measure_representation_item <= 
representation_item 
representation_item.name = 'lower limit'}]
[{measure_representation_item <= 
representation_item 
representation_item.name = 'upper limit'}]
end_mapping_constraints;

attribute_mapping upper_limit(upper_limit, $IDENTICAL_MAPPING, measure_representation_item);
measure_representation_item
measure_representation_item <= 
representation_item 
{representation_item.name = 'upper limit'} 

end_attribute_mapping;

attribute_mapping lower_limit(lower_limit, $IDENTICAL_MAPPING, measure_representation_item);
measure_representation_item
measure_representation_item <= 
representation_item 
{representation_item.name = 'lower limit'} 

end_attribute_mapping;

end_entity_mapping;

entity_mapping Upper_lower_toleranced_datum(Upper_lower_toleranced_datum, [measure_representation_item]
[measure_representation_item]);

mapping_constraints;
[measure_representation_item <= 
representation_item 
{representation_item.name = 'lower tolerance value'}]
[measure_representation_item <= 
representation_item 
{representation_item.name = 'upper tolerance value'}]
end_mapping_constraints;

attribute_mapping lower_tolerance_value(lower_tolerance_value, $IDENTICAL_MAPPING, measure_representation_item);
measure_representation_item
measure_representation_item <= 
representation_item 
{representation_item.name = 'lower tolerance value'}
end_attribute_mapping;

attribute_mapping upper_tolerance_value(upper_tolerance_value, $PATH, measure_representation_item);
measure_representation_item
measure_representation_item <= 
representation_item 
{representation_item.name = 'upper tolerance value'} 
end_attribute_mapping;

end_entity_mapping;
end_uof_mapping;

(*end_schema_mapping;*)
