<?xml version="1.0" encoding="UTF-8"?>
<GlobalViewScript>

set autoderef off

cm global

\
<view name="EmployeeGlobalDef">
<mainView>
add view EmployeeGlobalDef {
	virtual EmployeeGlobal: record {
		idGlobal: integer;
		nameGlobal: string;
		surnameGlobal: string;
		sexGlobal: string;
		salaryGlobal: real;
		infoGlobal: string;
		birthDateGlobal: date;
		worksInGlobal: DepartmentGlobal;
	}[0..*] ;
		
	seed : record {e: EmployeeIntegr;  }[0..*]  
		{ return EmployeeIntegr as e; } 
		
	on_retrieve { 
	  return e.(
	  	idIntegr as idGlobal, 
	  	nameIntegr as nameGlobal, 
	  	surnameIntegr as surnameGlobal, 
	  	sexIntegr as sexGlobal, 
	  	salaryIntegr as salaryGlobal, 
	  	infoIntegr as infoGlobal, 
	  	birthDateIntegr as birthDateGlobal),
	  	(DepartmentGlobal where idGlobal = e.worksInIntegr.DepartmentIntegr.idIntegr) as worksInGlobal ;
	}	
	on_delete { 
		delete e; }
	
	on_update { e := value.(
		idGlobal as idIntegr, 
		nameGlobal as nameIntegr, 
		surnameGlobal as surnameIntegr,
		sexGlobal as sexIntegr, 
		salaryGlobal as salaryIntegr, 
		infoGlobal as infoIntegr, 
		birthDateGlobal as birthDateIntegr,
		ref( DepartmentIntegr where idIntegr = worksInGlobal.idGlobal) as worksInIntegr); }
	
	on_new { create permanent EmployeeIntegr(value.(
		idGlobal as idIntegr, 
		nameGlobal as nameIntegr,
		surnameGlobal as surnameIntegr, 
		sexGlobal as sexIntegr, 
		salaryGlobal as salaryIntegr, 
		infoGlobal as infoIntegr,
		birthDateGlobal as birthDateIntegr,
		ref(DepartmentIntegr where idIntegr = worksInGlobal.idGlobal) as worksInIntegr)); }
</mainView>

<subView>
	view idGlobalDef {  
		virtual idGlobal: integer;
		seed: record { _id: EmployeeIntegr.idIntegr; } { return e.idIntegr as _id; } 
		on_retrieve { return _id; }
		on_update {_id := value; }
	}
</subView>

<subView>
	view nameGlobalDef {  
		virtual nameGlobal: string;
		seed: record { _name: EmployeeIntegr.nameIntegr; } { return e.nameIntegr as _name; } 
		on_retrieve { return _name; }
		on_update { _name := value; }
	}
</subView>

<subView>
	view surnameGlobalDef {  
		virtual surnameGlobal: string;
		seed: record { _surname: EmployeeIntegr.surnameIntegr; } { return e.surnameIntegr as _surname; } 
		on_retrieve { return _surname; }
		on_update { _surname := value; }
	}
</subView>

<subView>
	view sexGlobalDef {  
		virtual sexGlobal: string;
		seed: record { _sex: EmployeeIntegr.sexIntegr; } { return e.sexIntegr as _sex; } 
		on_retrieve { return _sex; }
		on_update { _sex := value; }
	}
</subView>

<subView>
	view salaryGlobalDef {  
		virtual salaryGlobal: real;
		seed: record { _salary: EmployeeIntegr.salaryIntegr; } { return e.salaryIntegr as _salary; } 
		on_retrieve { return _salary; }
		on_update { _salary := value; }
	}
</subView>

<subView>
	view infoGlobalDef {  
		virtual infoGlobal: string;
		seed: record { _info: EmployeeIntegr.infoIntegr; } { return e.infoIntegr as _info; } 
		on_retrieve { return _info; }
		on_update { _info := value; }
	}
</subView>

<subView>
	view birthDateGlobalDef {  
		virtual birthDateGlobal: date;
		seed: record { _birthDate: EmployeeIntegr.birthDateIntegr; } { return e.birthDateIntegr as _birthDate; } 
		on_retrieve { return _birthDate; }
		on_update { _birthDate := value; }
	}
</subView>

<subView>
	view worksInGlobalDef {
		virtual worksInGlobal: DepartmentGlobal[0..*];
		seed: record { _worksIn: DepartmentGlobal; }[0..*]
			{ return (DepartmentGlobal where idGlobal = (e.worksInIntegr.DepartmentIntegr.idIntegr)) as _worksIn; } 
		on_retrieve { return _worksIn;}
		on_navigate { return _worksIn;}
	}
</subView>
}
</view>
.
\
<view name="DepartmentGlobalDef">
<mainView>
add view DepartmentGlobalDef {
	virtual DepartmentGlobal: record {
		idGlobal: integer;
		nameGlobal: string;
		isLocatedInGlobal: LocationGlobal;
	}[0..*] ;
		
	seed : record {d: DepartmentIntegr;  }[0..*]  
		{ return DepartmentIntegr as d; } 
		
	on_retrieve { 
	  return d.(
	  	idIntegr as idGlobal, 
	  	nameIntegr as nameGlobal),
	  	(LocationGlobal where idGlobal = (d.isLocatedInIntegr.LocationIntegr.idIntegr)) as isLocatedInGlobal ;
	}	
	on_delete { 
		delete d; 
	}
</mainView>

<subView>
	view idGlobalDef {  
		virtual idGlobal: integer;
		seed: record { _id: DepartmentIntegr.idIntegr; } { return d.idIntegr as _id; } 
		on_retrieve { return _id; }
	}
</subView>

<subView>
	view nameGlobalDef {  
		virtual nameGlobal: string;
		seed: record { _name: DepartmentIntegr.nameIntegr; } { return d.nameIntegr as _name; } 
		on_retrieve { return _name; }
		on_update { _name := value; }
	}
</subView>

<subView>
/*virtual pointer*/
	view isLocatedInGlobalDef {
		virtual isLocatedInGlobal: LocationGlobal;
		seed: record { _isLocatedIn: LocationGlobal; }
			{ return (LocationGlobal where idGlobal = (d.isLocatedInIntegr.LocationIntegr.idIntegr)) as _isLocatedIn; } 
		on_retrieve { return _isLocatedIn;}
		on_navigate { return _isLocatedIn;}
	}
 
</subView>
}
</view>
.

\
<view name="LocationGlobalDef">
<mainView>
add view LocationGlobalDef {
	virtual LocationGlobal: record {
		idGlobal: integer;
		nameGlobal: string;
	}[0..*] ;
		
	seed : record {l: LocationIntegr;  }[0..*]  
		{ return LocationIntegr as l; } 
		
	on_retrieve { 
	  return l.(
	  	idIntegr as idGlobal, 
	  	nameIntegr as nameGlobal);
	}	
	on_delete { 
		delete l; 
	}
</mainView>

<subView>
	view idGlobalDef {  
		virtual idGlobal: integer;
		seed: record { _id: LocationIntegr.idIntegr; } { return l.idIntegr as _id; } 
		on_retrieve { return deref(_id); }
	}
</subView>

<subView>
	view nameGlobalDef {  
		virtual nameGlobal: string;
		seed: record { _name: LocationIntegr.nameIntegr; } { return l.nameIntegr as _name; } 
		on_retrieve { return deref(_name); }
		on_update { _name := value; }
	}
</subView>
}
</view>
.

\
<view name="CarGlobalDef">
<mainView>
add view CarGlobalDef {
	virtual CarGlobal: record {
		idGlobal: integer;
		colourGlobal: string;
		yearGlobal: integer;
		isModelGlobal: ModelGlobal;
		isOwnedByGlobal: EmployeeGlobal; 
		
	}[0..*] ;
		
	seed : record {c: CarIntegr;  }[0..*]  
		{ return CarIntegr as c; } 
		
	on_retrieve { 
	  return c.(
	  	idIntegr as idGlobal, 
	  	colourIntegr as colourGlobal,
	  	yearIntegr as yearGlobal),
	  	(ModelGlobal where idGlobal = (c.isModelIntegr.ModelIntegr.idIntegr)) as isModelGlobal,
	  	(EmployeeGlobal where idGlobal = (c.isOwnedByIntegr.EmployeeIntegr.idIntegr)) as isOwnedByGlobal ;
	}	
	on_delete { 
		delete c; 
	}
</mainView>

<subView>
	view idGlobalDef {  
		virtual idGlobal: integer;
		seed: record { _id: CarIntegr.idIntegr; } { return c.idIntegr as _id; } 
		on_retrieve { return deref(_id); }
	}
</subView>

<subView>
	view colourGlobalDef {  
		virtual colourGlobal: string;
		seed: record { _colour: CarIntegr.colourIntegr; } { return c.colourIntegr as _colour; } 
		on_retrieve { return deref(_colour); }
		on_update { _colour := value; }
	}
</subView>

<subView>
	view yearGlobalDef {  
		virtual yearGlobal: integer;
		seed: record { _year: CarIntegr.yearIntegr; } { return c.yearIntegr as _year; } 
		on_retrieve { return deref(_year); }
		on_update { _year := value; }
	}
</subView>

<subView>
	view isModelGlobalDef {
		virtual isModelGlobal: ModelGlobal;
		seed: record { _isModel: ModelGlobal; }
			{ return (ModelGlobal where idGlobal = (c.isModelIntegr.ModelIntegr.idIntegr)) as _isModel; } 
		on_retrieve { return _isModel;}
		on_navigate { return _isModel;}
	}
</subView>

<subView>
	view isOwnedByGlobalDef {
		virtual isOwnedByGlobal: EmployeeGlobal;
		seed: record { _isOwnedBy: EmployeeGlobal; }
			{ return (EmployeeGlobal where idGlobal = (c.isOwnedByIntegr.EmployeeIntegr.idIntegr)) as _isOwnedBy; } 
		on_retrieve { return _isOwnedBy;}
		on_navigate { return _isOwnedBy;}
	}
</subView>
}
</view>
.
\
<view name="ModelGlobalDef">
<mainView>
add view ModelGlobalDef {
	virtual ModelGlobal: record {
		idGlobal: integer;
		nameGlobal: string;
		isMakeGlobal: MakeGlobal;
	}[0..*] ;
		
	seed : record {m: ModelIntegr;  }[0..*]  
		{ return ModelIntegr as m; } 
		
	on_retrieve { 
	  return m.(
	  	idIntegr as idGlobal, 
	  	nameIntegr as nameGlobal),
	  	(MakeGlobal where idGlobal = (m.isMakeIntegr.MakeIntegr.idIntegr)) as isMakeGlobal ;
	}	
	on_delete { 
		delete m; 
	}
</mainView>

<subView>
	view idGlobalDef {  
		virtual idGlobal: integer;
		seed: record { _id: ModelIntegr.idIntegr; } { return m.idIntegr as _id; } 
		on_retrieve { return deref(_id); }
	}
</subView>

<subView>
	view nameGlobalDef {  
		virtual nameGlobal: string;
		seed: record { _name: ModelIntegr.nameIntegr; } { return m.nameIntegr as _name; } 
		on_retrieve { return deref(_name); }
		on_update { _name := value; }
	}
</subView>

<subView>
	view isMakeGlobalDef {
		virtual isMakeGlobal: MakeGlobal;
		seed: record { _isMake: MakeGlobal; }
			{ return (MakeGlobal where idGlobal = (m.isMakeIntegr.MakeIntegr.idIntegr)) as _isMake; } 
		on_retrieve { return _isMake;}
		on_navigate { return _isMake;}
	}
</subView>
}
</view>
.

\
<view name="MakeGlobalDef">
<mainView>
add view MakeGlobalDef {
	virtual MakeGlobal: record {
		idGlobal: integer;
		nameGlobal: string;
	}[0..*] ;
		
	seed : record {m: MakeIntegr;  }[0..*]  
		{ return MakeIntegr as m; } 
		
	on_retrieve { 
	  return m.(
	  	idIntegr as idGlobal, 
	  	nameIntegr as nameGlobal);
	}	
	on_delete { 
		delete m; 
	}
</mainView>

<subView>
	view idGlobalDef {  
		virtual idGlobal: integer;
		seed: record { _id: MakeIntegr.idIntegr; } { return m.idIntegr as _id; } 
		on_retrieve { return deref(_id); }
	}
</subView>

<subView>
	view nameGlobalDef {  
		virtual nameGlobal: string;
		seed: record { _name: MakeIntegr.nameIntegr; } { return m.nameIntegr as _name; } 
		on_retrieve { return deref(_name); }
		on_update { _name := value; }
	}
</subView>
}
</view>
.

</GlobalViewScript>