(*
 * $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 project(Project_arm, Project_mim);*)

uof_mapping Project(Project);

entity_mapping Project(Project, organizational_project);

attribute_mapping id(id, organizational_project.id);

end_attribute_mapping;

attribute_mapping name(name, organizational_project.name);

end_attribute_mapping;

attribute_mapping description(description, organizational_project.description);

end_attribute_mapping;

attribute_mapping responsible_organizations(responsible_organizations, $PATH, Organization);

		organizational_project
		organizational_project.responsible_organizations[i] -> organization
			 
end_attribute_mapping;

attribute_mapping planned_start_date(planned_start_date, $PATH, Calendar_date);

		   organizational_project
			 date_item = organizational_project
			 date_item <- applied_date_assignment.items[i]
			 applied_date_assignment <=
			 date_assignment
			 {date_assignment.role -> date_role
			  date_role.name = 'planned start'}
			 date_assignment.assigned_date -> date
			 date => calendar_date
		 
end_attribute_mapping;

attribute_mapping planned_start_date(planned_start_date, $PATH, date_and_time);

		   organizational_project
			 date_and_time_item = organizational_project
			 date_and_time_item <- applied_date_and_time_assignment.items[i]
			 applied_date_and_time_assignment <=
			 date_and_time_assignment
			 {date_and_time_assignment.role -> date_time_role
			  date_time_role.name = 'planned start'}
			 date_and_time_assignment.assigned_date_and_time 
			 -> date_and_time
		 
end_attribute_mapping;

attribute_mapping planned_start_date(planned_start_date, $PATH, Event);

		   organizational_project
			 event_occurrence_item = organizational_project
			 event_occurrence_item <- applied_event_occurrence_assignment.items[i]
			 applied_event_occurrence_assignment <= event_occurrence_assignment
			 event_occurrence_assignment.role -> event_occurrence_role
			 {event_occurrence_role.name='planned start'}
		 
end_attribute_mapping;

attribute_mapping planned_end_date(planned_end_date, $PATH, Calendar_date);

		   organizational_project
			 date_item = organizational_project
			 date_item <- applied_date_assignment.items[i]
			 applied_date_assignment <=
			 date_assignment
			 {date_assignment.role -> date_role
			  date_role.name = 'planned end'}
			 date_assignment.assigned_date -> date
			 date => calendar_date
		 
end_attribute_mapping;

attribute_mapping planned_end_date(planned_end_date, $PATH, date_and_time);

		   organizational_project
			 date_and_time_item = organizational_project
			 date_and_time_item <- applied_date_and_time_assignment.items[i]
			 applied_date_and_time_assignment <=
			 date_and_time_assignment
			 {date_and_time_assignment.role -> date_time_role
			  date_time_role.name = 'planned end'}
			 date_and_time_assignment.assigned_date_and_time 
			 -> date_and_time
		 
end_attribute_mapping;

attribute_mapping planned_end_date(planned_end_date, $PATH, Event);

		   organizational_project
			 event_occurrence_item = organizational_project
			 event_occurrence_item <- applied_event_occurrence_assignment.items[i]
			 applied_event_occurrence_assignment <= event_occurrence_assignment
			 event_occurrence_assignment.role -> event_occurrence_role
			 {event_occurrence_role.name='planned end'}
		 
end_attribute_mapping;

attribute_mapping actual_start_date(actual_start_date, $PATH, Calendar_date);

		   organizational_project
			 date_item = organizational_project
			 date_item <- applied_date_assignment.items[i]
			 applied_date_assignment <=
			 date_assignment
			 {date_assignment.role -> date_role
			  date_role.name = 'actual start'}
			 date_assignment.assigned_date -> date
			 date => calendar_date
		 
end_attribute_mapping;

attribute_mapping actual_start_date(actual_start_date, $PATH, date_and_time);

		   organizational_project
			 date_and_time_item = organizational_project
			 date_and_time_item <- applied_date_and_time_assignment.items[i]
			 applied_date_and_time_assignment <=
			 date_and_time_assignment
			 {date_and_time_assignment.role -> date_time_role
			  date_time_role.name = 'actual start'}
			 date_and_time_assignment.assigned_date_and_time 
			 -> date_and_time
		 
end_attribute_mapping;

attribute_mapping actual_end_date(actual_end_date, $PATH, Calendar_date);

		   organizational_project
			 date_item = organizational_project
			 date_item <- applied_date_assignment.items[i]
			 applied_date_assignment <=
			 date_assignment
			 {date_assignment.role -> date_role
			  date_role.name = 'actual end'}
			 date_assignment.assigned_date -> date
			 date => calendar_date
		 
end_attribute_mapping;

attribute_mapping actual_end_date(actual_end_date, $PATH, date_and_time);

		   organizational_project
			 date_and_time_item = organizational_project
			 date_and_time_item <- applied_date_and_time_assignment.items[i]
			 applied_date_and_time_assignment <=
			 date_and_time_assignment
			 {date_and_time_assignment.role -> date_time_role
			  date_time_role.name = 'actual end'}
			 date_and_time_assignment.assigned_date_and_time -> date_and_time
      
end_attribute_mapping;

end_entity_mapping;

entity_mapping Project_assignment(Project_assignment, applied_organizational_project_assignment);

mapping_constraints;

		   applied_organizational_project_assignment <=
			 organizational_project_assignment
		 
end_mapping_constraints;

attribute_mapping assigned_project(assigned_project, organizational_project_assignment.assigned_organizational_project, Project);

end_attribute_mapping;

attribute_mapping role_x(role_x, organizational_project_role.name);

end_attribute_mapping;

attribute_mapping items(items, $PATH, project_item);

 	applied_organizational_project_assignment.items[i] -> project_item
	
end_attribute_mapping;

end_entity_mapping;

entity_mapping Project_relationship(Project_relationship, organizational_project_relationship);

attribute_mapping relation_type(relation_type, organizational_project_relationship.name);

end_attribute_mapping;

attribute_mapping description(description, organizational_project_relationship.description);

end_attribute_mapping;

attribute_mapping relating_project(relating_project, $PATH, Project);

	organizational_project_relationship.relating_organizational_project -> organizational_project
			 
end_attribute_mapping;

attribute_mapping related_project(related_project, $PATH, Project);

	organizational_project_relationship.related_organizational_project -> organizational_project
			 
end_attribute_mapping;

end_entity_mapping;

entity_mapping Project_relationship__succession(Project_relationship__succession, organizational_project_relationship);

mapping_constraints;

		   organizational_project_relationship
			 {organizational_project_relationship.name = 'succession'}
		 
end_mapping_constraints;

end_entity_mapping;

entity_mapping Project_relationship__sequence(Project_relationship__sequence, organizational_project_relationship);

mapping_constraints;

		   organizational_project_relationship
			 {organizational_project_relationship.name = 'sequence'}
		 
end_mapping_constraints;

end_entity_mapping;

entity_mapping Project_relationship__decomposition(Project_relationship__decomposition, organizational_project_relationship);

mapping_constraints;

		   organizational_project_relationship
			 {organizational_project_relationship.name = 'decomposition'}
		 
end_mapping_constraints;

end_entity_mapping;

entity_mapping Project_relationship__dependency(Project_relationship__dependency, organizational_project_relationship);

mapping_constraints;

		   organizational_project_relationship
			 {organizational_project_relationship.name = 'dependency'}
		 
end_mapping_constraints;

end_entity_mapping;


entity_mapping Project_assignment__work_program(Project_assignment__work_program, applied_organizational_project_assignment);

mapping_constraints;

		   applied_organizational_project_assignment <=
			 organizational_project_assignment
			 {organizational_project_assignment.role ->
			 organizational_project_role.name = 'work program'}
		 
end_mapping_constraints;

end_entity_mapping;

end_uof_mapping;
(*end_schema_mapping;*)
