(*
 * $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 N3225 - ISO/TS 10303-1123 Document definition - EXPRESS ARM
by LKSoftWare GmbH for implementation purpose within IDA-STEP(TM)
*) 

(* Based on ARM *) 

SCHEMA Document_definition_xim;

USE FROM Document_and_version_identification_xim;    -- ISO/TS 10303-1121

USE FROM External_item_identification_assignment_xim;    -- ISO/TS 10303-1128

USE FROM File_identification_xim;    -- ISO/TS 10303-1127

USE FROM Product_view_definition_xim;    -- ISO/TS 10303-1019

USE FROM application_context_schema(application_context_element);

TYPE document_location_select_armx = SELECT BASED_ON external_identification_item WITH 
   (Document_definition);
END_TYPE; 

ENTITY Digital_document_definition
  (* CONNOTATIONAL *) SUBTYPE OF (Document_definition);
  files : OPTIONAL SET[1:?] OF Digital_file; (** Originally it is mandatory SET[0:?] **)
 WHERE
   WR1 : SELF\Product_view_definition.initial_context\application_context_element.name = 'digital document definition';
END_ENTITY;

ENTITY Document_definition
  SUPERTYPE OF (ONEOF (Digital_document_definition,
                       Physical_document_definition))
  (* CONNOTATIONAL *) SUBTYPE OF (Product_view_definition);
  SELF\Product_view_definition.defined_version RENAMED associated_document_version : Document_version;
  description_x : OPTIONAL text;
 DERIVE
  SELF\Product_view_definition.name_x : text := description_x;
 WHERE
  WR1 : SELF\Product_view_definition.initial_context\application_context_element.name IN ['digital document definition',
  	'physical document definition', 'generic document definition'];
END_ENTITY;

ENTITY Document_location_identification
  (* CONNOTATIONAL *) SUBTYPE OF (External_source_identification);
WHERE
  WR1: 'Document_definition_xim.DOCUMENT_DEFINITION' IN TYPEOF(SELF\External_source_identification.items);
END_ENTITY;

ENTITY Physical_document_definition
  (* CONNOTATIONAL *) SUBTYPE OF (Document_definition);
  components : OPTIONAL SET[1:?] OF Hardcopy; (** Originally it is mandatory SET[0:?] **)
 WHERE
   WR1 : SELF\Product_view_definition.initial_context\application_context_element.name = 'physical document definition';
END_ENTITY;

RULE document_definition_constraint FOR 
(Product_definition);
WHERE
  WR1: SIZEOF ( QUERY ( dd <* Product_definition | ( NOT ( 'Document_definition_xim.' + 'DOCUMENT_DEFINITION' IN TYPEOF (dd) ) ) AND ( 'Document_definition_xim.' + 'DOCUMENT_VERSION' IN TYPEOF ( dd.formation) ) ) ) =0;
END_RULE; 

END_SCHEMA;  -- Document_definition_xim

