-
Notifications
You must be signed in to change notification settings - Fork 0
Generation
GallusHuber edited this page Oct 18, 2024
·
4 revisions
📖 Table of Contents
ER2CDS allows to generate a CDS view entity from a created ER2CDS model (specified in a *.er2cds
file). The generator can be invoked from the VS Code command palette using the ER2CDS Diagram: Generate CDS
command
The model-to-text transformation is one of the central features of ER2CDS. It allows the transformation of an ER2CDS model into a valid CDS view entity. We will use a template-based approach to generate the textual output. The template is illustrated below, with <...> denoting marker.
@AccessControl.authorizationCheck: #CHECK
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Generated by ER2CDS'
define view entity <name> as select
from <entity>
([inner join | left outer join | right outer join] <entity> (as <entityAlias>)? on ([<entity> | <entityAlias>].<firstAttribute> = [<entity> | <entityAlias>].<secondAttribute> (and)?)*)*
([association[1..1] | association[1..*] | association[0..1] | association[0..*]] to <entity> (as <entityAlias>)? on ($projection.<firstAttribute> = [<entity> | <entityAlias>].<secondAttribute> (and)?)*)*
([composition[1..1] | composition[1..*] | composition[0..1] | composition[0..*]] of <entity> (as <entityAlias>)?)*
(association to parent <entity> (as <entityAlias>)? on ($projection.<firstAttribute> = [<entity> | <entityAlias>].<secondAttribute> (and)?)*)*
{
((key)? [<entity> | <entityAlias>].<attribute>
(as <attributeAlias>))*
(<entity>)*
}
Using this template, the generated CDS view entity for the example presented here is displayed below:
@AccessControl.authorizationCheck: #CHECK
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Generated by ER2CDS'
define view entity ZER2CDS_MANAGER as select
from Employee
inner join Department on Employee.DEPARTMENT_ID = Department.DEPARTMENT_ID
{
key Employee.PERNR,
Employee.FNAME as FirstName,
Employee.LNAME as LastName,
Employee.DEPARTMENT_ID,
Department.NAME as DepartmentName,
Department.LOC as Location
}