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

SCHEMA Scheme_xim;

USE FROM Activity_method_xim;    -- ISO/TS 10303-1049

USE FROM Activity_method_assignment_xim;    -- ISO/TS 10303-1249

USE FROM Date_time_assignment_xim;    -- ISO/TS 10303-1014

USE FROM Person_organization_assignment_xim;    -- ISO/TS 10303-1013

USE FROM Time_interval_xim;    -- ISO/TS 10303-1065

USE FROM Time_interval_assignment_xim;    -- ISO/TS 10303-1365

USE FROM Classification_assignment_xim; -- Needed because of Classification_assignment (in xims replaced by applied_classification_assignment).

USE FROM support_resource_schema(text);

(* It is available from MIM
TYPE scheme_date_and_time_item = SELECT BASED_ON date_and_time_item WITH 
   (Scheme_entry);
END_TYPE; 
*)
TYPE scheme_date_item = SELECT BASED_ON date_item WITH 
   (Scheme_entry);
END_TYPE; 

TYPE scheme_entry_item_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON action_method_items;
END_TYPE; 
(* It is available from MIM
TYPE scheme_person_and_organization_item = SELECT BASED_ON person_and_organization_item WITH 
   (Scheme, 
    Scheme_entry);
END_TYPE; 
*)
TYPE scheme_organization_item = SELECT BASED_ON organization_item WITH 
   (Scheme, 
    Scheme_entry);
END_TYPE; 

TYPE scheme_subject_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON action_method_items;
END_TYPE; 
(* It is available from MIM
TYPE scheme_time_interval_item = SELECT BASED_ON time_interval_item WITH 
   (Scheme_entry_relationship);
END_TYPE; 
*)
TYPE scheme_version_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON action_method_items;
END_TYPE; 

ENTITY Scheme
  (* CONNOTATIONAL *) SUBTYPE OF (action_method);
  DERIVE
   SELF\action_method.purpose: text :='scheme';
END_ENTITY;

ENTITY Scheme_entry
  (* CONNOTATIONAL *) SUBTYPE OF (action_method);
  scheme : Scheme_version;
  DERIVE
   SELF\action_method.purpose: text :='scheme entry';
END_ENTITY;

ENTITY Scheme_entry_assignment
  (* CONNOTATIONAL *) SUBTYPE OF (applied_action_method_assignment);
  SELF\action_method_assignment.assigned_action_method RENAMED assigned_entry : Scheme_entry;
  SELF\applied_action_method_assignment.items : SET[1:?] OF scheme_entry_item_select;
END_ENTITY;

ENTITY Scheme_relationship
  (* CONNOTATIONAL *) SUBTYPE OF (action_method_relationship);
  SELF\action_method_relationship.relating_method RENAMED relating_scheme : Scheme;
  SELF\action_method_relationship.related_method RENAMED related_scheme : Scheme;
END_ENTITY;

ENTITY Scheme_subject_assignment
  (* CONNOTATIONAL *) SUBTYPE OF (applied_action_method_assignment);
  SELF\action_method_assignment.assigned_action_method RENAMED assigned_scheme : Scheme;
  SELF\applied_action_method_assignment.items : SET[1:?] OF scheme_subject_select;
END_ENTITY;

ENTITY Scheme_version
  (* CONNOTATIONAL *) SUBTYPE OF (action_method);
  of_scheme : Scheme;
  DERIVE
   SELF\action_method.purpose: text :='scheme version';
END_ENTITY;

ENTITY Scheme_version_assignment
  (* CONNOTATIONAL *) SUBTYPE OF (applied_action_method_assignment);
  SELF\action_method_assignment.assigned_action_method RENAMED assigned_scheme_version : Scheme_version;
  SELF\applied_action_method_assignment.items : SET[1:?] OF scheme_version_select;
END_ENTITY;

ENTITY Scheme_version_relationship
  (* CONNOTATIONAL *) SUBTYPE OF (action_method_relationship);
  SELF\action_method_relationship.relating_method RENAMED relating_scheme_version : Scheme_version;
  SELF\action_method_relationship.related_method RENAMED related_scheme_version : Scheme_version;
END_ENTITY;

(* Remove according email from Lothar
ENTITY Sequencing_relationship
  SUBTYPE OF (Scheme_entry_relationship);
   SELF\action_method_relationship.description RENAMED sequencing_type : STRING;
   time_lag : OPTIONAL Time_interval; -- SEDS
  DERIVE
   SELF\action_method_relationship.name : label := 'sequencing relationship';
END_ENTITY; *)

(* Introduced in email from Lothar *)

ENTITY Scheme_entry_relationship
	ABSTRACT SUPERTYPE OF (ONEOF(
		Scheme_entry_relationship__decomposition,
		Scheme_entry_relationship__exclusiveness,
		Scheme_entry_relationship__precedence,
		Scheme_entry_relationship__sequence,
		Scheme_entry_relationship__simultaneity,
		Scheme_entry_relationship__other))
  (* CONNOTATIONAL *) SUBTYPE OF (action_method_relationship);
  SELF\action_method_relationship.relating_method RENAMED relating_entry : Scheme_entry;
  SELF\action_method_relationship.related_method RENAMED related_entry : Scheme_entry;
 WHERE
  WR1: SIZEOF (relating_entry.schemes * related_entry.schemes) >= 1;
END_ENTITY;

ENTITY Scheme_entry_relationship__decomposition
 SUBTYPE OF (Scheme_entry_relationship);
DERIVE
 SELF\action_method_relationship.name : label := 'decomposition';
END_ENTITY;

ENTITY Scheme_entry_relationship__exclusiveness
 SUBTYPE OF (Scheme_entry_relationship);
DERIVE
 SELF\action_method_relationship.name : label := 'exclusiveness';
END_ENTITY;

ENTITY Scheme_entry_relationship__precedence
 SUBTYPE OF (Scheme_entry_relationship);
DERIVE
 SELF\action_method_relationship.name : label := 'precedence';
END_ENTITY;

ENTITY Scheme_entry_relationship__sequence
 SUBTYPE OF (Scheme_entry_relationship);
DERIVE
 SELF\action_method_relationship.name : label := 'sequence';
END_ENTITY;

TYPE simultaneity_type = ENUMERATION OF (
  -- all entires have ugly terms, need to improve them
  SAME,
  FIRST_ONE_TEN_TWO,
  FIRST_TWO_THEN_ONE);
END_TYPE;  
-- this is to cover end-to-end, start-to-start, start-to-end etc.

ENTITY Scheme_entry_relationship__simultaneity
 SUBTYPE OF (Scheme_entry_relationship);
 start_condition : OPTIONAL simultaneity_type;
 end_condition : OPTIONAL simultaneity_type;
DERIVE
 SELF\action_method_relationship.name : label := 'simultaneity';
END_ENTITY;

ENTITY Scheme_entry_relationship__other
 SUBTYPE OF (Scheme_entry_relationship);
DERIVE
 SELF\action_method_relationship.name : label := 'other';
INVERSE
 classifications : SET [1:?] of applied_classification_assignment FOR items;
END_ENTITY;


END_SCHEMA;  -- Scheme_xim