(*
 * $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/
 *)

(*
   Derived from ISO TC184/SC4/WG12 N4272 - ISO/TS 10303-1111 Classification with attributes - EXPRESS ARM
   by LKSoftWare GmbH for implementation purpose within IDA-STEP(TM)
*)

(* Based on ARM *)

SCHEMA Classification_with_attributes_xim;

USE FROM Classification_assignment_xim;

USE FROM Extended_measure_representation_xim; -- ~ARM

USE FROM Plib_class_reference_xim; -- ISO/CD-TS 10303-1291

USE FROM Product_view_definition_xim;

USE FROM Independent_property_xim;

USE FROM Identification_assignment_xim;

USE FROM Classification_with_attributes_mim;
	
USE FROM group_schema(group_relationship);

USE FROM product_property_definition_schema(
	general_property,
	property_definition);

USE FROM support_resource_schema(identifier);

USE FROM external_reference_schema(externally_defined_item);

-- The same extension is available via MIM
-- TYPE classification_item_extended = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON classification_item WITH (
--	Part, 
--	Part_version,
--	Part_view_definition) ;
-- END_TYPE;

TYPE classified_element_select = EXTENSIBLE GENERIC_ENTITY SELECT (
	product, 
	product_definition_formation,
	Product_view_definition) ;
END_TYPE;

TYPE externally_defined_class_select = SELECT(
	Plib_class_reference, 
	externally_defined_class 
);
END_TYPE;

TYPE definable_objects = SELECT (
	product, 
	product_definition_formation,
	Product_view_definition) ;
END_TYPE;

ENTITY Class_with_attributes
 (* CONNOTATIONAL *) SUBTYPE OF (Class_armx, characterized_class);
  version_id: OPTIONAL STRING;
  used_classification_system: OPTIONAL Class_system;
INVERSE
  characterization_attributes: SET[0:?] OF Classification_attribute FOR characterized_class;
END_ENTITY;

ENTITY Class_hierarchy
(* CONNOTATIONAL *) SUBTYPE OF (group_relationship);
  SELF\Group_relationship.relating_group RENAMED super_class: Class_with_attributes;
  SELF\Group_relationship.related_group RENAMED sub_class: Class_with_attributes;
DERIVE
  SELF\group_relationship.description : text := ?;
  SELF\group_relationship.name : label := ?;
END_ENTITY;

ENTITY Classification_association
(* CONNOTATIONAL *) SUBTYPE OF (applied_classification_assignment);
   SELF\Classification_assignment.assigned_class: Class_with_attributes;
   definitional: LOGICAL;
 DERIVE
   -- Overlaps with definitional attribute
   SELF\classification_assignment.role : classification_role := ?;
WHERE
WR1: SIZEOF(QUERY(it<* SELF\Classification_assignment.items |
     NOT('Classification_with_attributes_xim.DEFINABLE_OBJECTS' IN TYPEOF(it)) AND definitional ))=0;
WR2: SIZEOF(QUERY(it<* SELF\Classification_assignment.items |
     NOT('Classification_with_attributes_xim.CLASSIFIED_ELEMENT_SELECT' IN TYPEOF(it)) )) =0;
END_ENTITY;

ENTITY Classification_attribute
(* CONNOTATIONAL *) SUBTYPE OF (property_definition);
   id_x: STRING;
   allowed_values: OPTIONAL SET[1:?] OF measure_representation_item;
   SELF\property_definition.definition RENAMED characterized_class: Class_with_attributes;
   attribute_definition: general_property;
  DERIVE
   SELF\property_definition.id : identifier := id_x;
END_ENTITY;

ENTITY External_class_with_attributes
(* CONNOTATIONAL *) SUBTYPE OF (Class_with_attributes, externally_defined_class);
  source_x : externally_defined_class_select;
  DERIVE
  	SELF\Externally_defined_item.source : external_source :=?;
END_ENTITY;

(** GL - moved from product_data_management_....specializations *)
  ENTITY classification_association__class_system_membership
    SUBTYPE OF (classification_association);
    DERIVE
      SELF\classification_assignment.role : classification_role := classification_role('class system membership', ?); 
  END_ENTITY; -- classification_association

END_SCHEMA;

