From f4252922b2f1cc80f9f185323524d80453e0f7a0 Mon Sep 17 00:00:00 2001 From: Steffen Weinstock <79531202+stewsk@users.noreply.github.com> Date: Wed, 2 Apr 2025 09:25:14 +0200 Subject: [PATCH 1/5] Prep: turn mgd assoc into unmanaged Temporary workaround, as annotation expressions can't yet handle paths to implicit FKs --- db/master-data.cds | 10 +++++++--- db/schema.cds | 38 +++++++++++++++++++++++++++----------- srv/analytics-service.cds | 2 ++ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/db/master-data.cds b/db/master-data.cds index 950fada3..0586a7b6 100644 --- a/db/master-data.cds +++ b/db/master-data.cds @@ -25,7 +25,8 @@ entity Airport : MasterData { entity Supplement : managed, MasterData { key SupplementID : String(10); Price : Decimal(16, 3); - Type : Association to SupplementType; + Type_code : String(2); + Type : Association to SupplementType on Type.code = Type_code; Description : localized String(1024); CurrencyCode : Currency; }; @@ -57,8 +58,11 @@ entity FlightConnection : MasterData { // and will be replaced with the generated FK key ConnectionID : String(4); key AirlineID : String(3); - DepartureAirport : Association to Airport; - DestinationAirport : Association to Airport; + + DepartureAirport_AirportID : String(3); + DepartureAirport : Association to Airport on DepartureAirport.AirportID = DepartureAirport_AirportID; + DestinationAirport_AirportID : String(3); + DestinationAirport : Association to Airport on DestinationAirport.AirportID = DestinationAirport_AirportID; DepartureTime : Time; ArrivalTime : Time; Distance : Integer; diff --git a/db/schema.cds b/db/schema.cds index ee6ab76c..07036343 100644 --- a/db/schema.cds +++ b/db/schema.cds @@ -18,9 +18,14 @@ entity Travel : managed { TotalPrice : Decimal(16,3) @readonly; CurrencyCode : Currency default 'EUR'; Description : String(1024); - TravelStatus : Association to TravelStatus default 'O' @readonly; - to_Agency : Association to TravelAgency @mandatory; - to_Customer : Association to Passenger @mandatory; + + TravelStatus_code : TravelStatusCode default 'O' @readonly; + TravelStatus : Association to TravelStatus on TravelStatus.code = TravelStatus_code; + + to_Agency_AgencyID : String(6) @mandatory; + to_Agency : Association to TravelAgency on to_Agency.AgencyID = to_Agency_AgencyID; + to_Customer_CustomerID : String(6) @mandatory; + to_Customer : Association to Passenger on to_Customer.CustomerID = to_Customer_CustomerID; to_Booking : Composition of many Booking on to_Booking.to_Travel = $self; }; @@ -38,12 +43,19 @@ entity Booking : managed { FlightDate : Date @mandatory; FlightPrice : Decimal(16,3) @mandatory; CurrencyCode : Currency; - BookingStatus : Association to BookingStatus default 'N' @mandatory; + + BookingStatus_code : BookingStatusCode default 'N' @mandatory; + BookingStatus : Association to BookingStatus on BookingStatus.code = BookingStatus_code; to_BookSupplement : Composition of many BookingSupplement on to_BookSupplement.to_Booking = $self; - to_Carrier : Association to Airline @mandatory; - to_Customer : Association to Passenger @mandatory; - to_Travel : Association to Travel; - to_Flight : Association to Flight on to_Flight.AirlineID = to_Carrier.AirlineID + + to_Carrier_AirlineID : String(3) @mandatory; + to_Carrier : Association to Airline on to_Carrier.AirlineID = to_Carrier_AirlineID; + to_Customer_CustomerID : String(6) @mandatory; + to_Customer : Association to Passenger on to_Customer.CustomerID = to_Customer_CustomerID; + to_Travel_TravelUUID : UUID; + to_Travel : Association to Travel on to_Travel.TravelUUID = to_Travel_TravelUUID; + + to_Flight : Association to Flight on to_Flight.AirlineID = to_Carrier_AirlineID and to_Flight.FlightDate = FlightDate and to_Flight.ConnectionID = ConnectionID; }; @@ -53,9 +65,13 @@ entity BookingSupplement : managed { BookingSupplementID : Integer @Core.Computed; Price : Decimal(16,3) @mandatory; CurrencyCode : Currency; - to_Booking : Association to Booking; - to_Travel : Association to Travel; - to_Supplement : Association to Supplement @mandatory; + + to_Booking_BookingUUID : UUID; + to_Booking : Association to Booking on to_Booking.BookingUUID = to_Booking_BookingUUID; + to_Travel_TravelUUID : UUID; + to_Travel : Association to Travel on to_Travel.TravelUUID = to_Travel_TravelUUID; + to_Supplement_SupplementID : String(10) @mandatory; + to_Supplement : Association to Supplement on to_Supplement.SupplementID = to_Supplement_SupplementID; }; diff --git a/srv/analytics-service.cds b/srv/analytics-service.cds index 4a2ab1d0..b428a728 100644 --- a/srv/analytics-service.cds +++ b/srv/analytics-service.cds @@ -37,7 +37,9 @@ service AnalyticsService @(path:'/analytics') { BookingDate, + to_Travel_TravelUUID, to_Travel, + to_Carrier_AirlineID, to_Carrier, // Java has a problem with this association From 691616d2b38a9fb8a84810044b9db56abb572ef2 Mon Sep 17 00:00:00 2001 From: Steffen Weinstock <79531202+stewsk@users.noreply.github.com> Date: Wed, 2 Apr 2025 09:49:45 +0200 Subject: [PATCH 2/5] Replace existing edmJson expressions by CDS anno xprs --- app/travel_processor/field-control.cds | 6 +++--- app/travel_processor/layouts.cds | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/app/travel_processor/field-control.cds b/app/travel_processor/field-control.cds index 5deeabe9..8fdf9793 100644 --- a/app/travel_processor/field-control.cds +++ b/app/travel_processor/field-control.cds @@ -22,15 +22,15 @@ annotate TravelService.Travel with @(Common : { } actions { rejectTravel @( - Core.OperationAvailable : { $edmJson: { $Ne: [{ $Path: 'in/TravelStatus_code'}, 'X']}}, + Core.OperationAvailable : ($self.TravelStatus_code != 'X'), Common.SideEffects.TargetProperties : ['in/TravelStatus_code'], ); acceptTravel @( - Core.OperationAvailable : { $edmJson: { $Ne: [{ $Path: 'in/TravelStatus_code'}, 'A']}}, + Core.OperationAvailable : ($self.TravelStatus_code != 'A'), Common.SideEffects.TargetProperties : ['in/TravelStatus_code'], ); deductDiscount @( - Core.OperationAvailable : { $edmJson: { $Eq: [{ $Path: 'in/TravelStatus_code'}, 'O']}} + Core.OperationAvailable : ($self.TravelStatus_code = 'O'), ); } diff --git a/app/travel_processor/layouts.cds b/app/travel_processor/layouts.cds index 5802b5c8..a58d5812 100644 --- a/app/travel_processor/layouts.cds +++ b/app/travel_processor/layouts.cds @@ -60,8 +60,7 @@ annotate TravelService.Travel with @UI : { { Value : TotalPrice, @HTML5.CssDefaults: {width:'12em'} }, { Value : TravelStatus_code, - Criticality : { $edmJson: { $If: [{$Eq: [{ $Path: 'TravelStatus_code'}, 'O']}, 2, - { $If: [{$Eq: [{ $Path: 'TravelStatus_code'}, 'A']}, 3, 0] }] } }, + Criticality : ($self.TravelStatus_code = 'O' ? 2 : ($self.TravelStatus_code = 'A' ? 3 : 0)), @UI.Importance : #High, @HTML5.CssDefaults: {width:'10em'} } @@ -105,8 +104,7 @@ annotate TravelService.Travel with @UI : { { $Type : 'UI.DataField', Value : TravelStatus_code, - Criticality : { $edmJson: { $If: [{$Eq: [{ $Path: 'TravelStatus_code'}, 'O']}, 2, - { $If: [{$Eq: [{ $Path: 'TravelStatus_code'}, 'A']}, 3, 0] }] } }, + Criticality : ($self.TravelStatus_code = 'O' ? 2 : ($self.TravelStatus_code = 'A' ? 3 : 0)), Label : '{i18n>Status}' // label only necessary if differs from title of element } ]}, @@ -167,8 +165,7 @@ annotate TravelService.Booking with @UI : { { Value : FlightDate }, { Value : FlightPrice }, { Value : BookingStatus_code, - Criticality : { $edmJson: { $If: [{$Eq: [{ $Path: 'BookingStatus_code'}, 'N']}, 2, - { $If: [{$Eq: [{ $Path: 'BookingStatus_code'}, 'B']}, 3, 0] }] } } + Criticality : ($self.BookingStatus_code = 'N' ? 2 : ($self.BookingStatus_code = 'B' ? 3 : 0)), } ], Facets : [{ @@ -198,9 +195,8 @@ annotate TravelService.Booking with @UI : { { Value : to_Customer_CustomerID }, { Value : BookingDate, }, { Value : BookingStatus_code, - Criticality : { $edmJson: { $If: [{$Eq: [{ $Path: 'BookingStatus_code'}, 'N']}, 2, - { $If: [{$Eq: [{ $Path: 'BookingStatus_code'}, 'B']}, 3, 0] }] } } - } + Criticality : ($self.BookingStatus_code = 'N' ? 2 : ($self.BookingStatus_code = 'B' ? 3 : 0)), + } ]}, FieldGroup #Flight : { Data : [ { Value : to_Carrier_AirlineID }, From efea1ac15635d42d8b0c626751071b06a8676835 Mon Sep 17 00:00:00 2001 From: Steffen Weinstock <79531202+stewsk@users.noreply.github.com> Date: Wed, 2 Apr 2025 17:24:06 +0200 Subject: [PATCH 3/5] addendum for mgd assoc -> unmgd --- app/labels.cds | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/labels.cds b/app/labels.cds index a1c7080c..25a73636 100644 --- a/app/labels.cds +++ b/app/labels.cds @@ -16,8 +16,8 @@ annotate schema.Travel with @title: '{i18n>Travel}' { GreenFee @title: '{i18n>GreenFee}' @Measures.ISOCurrency: CurrencyCode_code; TreesPlanted @title: '{i18n>TreesPlanted}'; TravelStatus @title: '{i18n>TravelStatus}' @Common.Text: TravelStatus.name @Common.TextArrangement: #TextOnly; - to_Customer @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; - to_Agency @title: '{i18n>AgencyID}' @Common.Text: to_Agency.Name; + to_Customer_CustomerID @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; + to_Agency_AgencyID @title: '{i18n>AgencyID}' @Common.Text: to_Agency.Name; } annotate schema.TravelStatus with { @@ -33,9 +33,9 @@ annotate schema.Booking with @title: '{i18n>Booking}' { CurrencyCode @title: '{i18n>CurrencyCode}'; FlightDate @title: '{i18n>FlightDate}'; FlightPrice @title: '{i18n>FlightPrice}' @Measures.ISOCurrency: CurrencyCode_code; - BookingStatus @title: '{i18n>BookingStatus}' @Common.Text: BookingStatus.name @Common.TextArrangement: #TextOnly; - to_Carrier @title: '{i18n>AirlineID}' @Common.Text: to_Carrier.Name; - to_Customer @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; + BookingStatus_code @title: '{i18n>BookingStatus}' @Common.Text: BookingStatus.name @Common.TextArrangement: #TextOnly; + to_Carrier_AirlineID @title: '{i18n>AirlineID}' @Common.Text: to_Carrier.Name; + to_Customer_CustomerID @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; } annotate schema.BookingStatus with { From 066ce05f46180a607e44bbfc334ce0f8a089c80a Mon Sep 17 00:00:00 2001 From: Steffen Weinstock <79531202+stewsk@users.noreply.github.com> Date: Wed, 2 Apr 2025 17:24:51 +0200 Subject: [PATCH 4/5] use expressions for field control --- app/travel_processor/field-control.cds | 58 ++++++++++++++------------ app/travel_processor/layouts.cds | 10 +++++ db/schema.cds | 6 +++ 3 files changed, 48 insertions(+), 26 deletions(-) diff --git a/app/travel_processor/field-control.cds b/app/travel_processor/field-control.cds index 8fdf9793..03215cb4 100644 --- a/app/travel_processor/field-control.cds +++ b/app/travel_processor/field-control.cds @@ -14,11 +14,13 @@ annotate TravelService.Travel with @(Common : { TargetProperties: ['TotalPrice', 'GreenFee', 'TreesPlanted'] } }){ - BookingFee @Common.FieldControl : TravelStatus.fieldControl; - BeginDate @Common.FieldControl : TravelStatus.fieldControl; - EndDate @Common.FieldControl : TravelStatus.fieldControl; - to_Agency @Common.FieldControl : TravelStatus.fieldControl; - to_Customer @Common.FieldControl : TravelStatus.fieldControl; + BookingFee @Common.FieldControl : TravelStatus_ctrl; + BeginDate @Common.FieldControl : TravelStatus_ctrl; + EndDate @Common.FieldControl : TravelStatus_ctrl; + to_Agency_AgencyID @Common.FieldControl : TravelStatus_ctrl; + to_Customer_CustomerID @Common.FieldControl : TravelStatus_ctrl; + + field_A @Common.FieldControl: (field_Ctr = 'readonly' ? 1 : (field_Ctr = 'inapplicable' ? 0 : (field_Ctr = 'mandatory' ? 7 : 3))); } actions { rejectTravel @( @@ -35,26 +37,30 @@ annotate TravelService.Travel with @(Common : { } annotate TravelService.Travel @( - Common.SideEffects#ReactonItemCreationOrDeletion : { - SourceEntities : [ - to_Booking - ], - TargetProperties : ['TotalPrice' - ] - } + Common.SideEffects#ReactonItemCreationOrDeletion : { + SourceEntities : [to_Booking], + TargetProperties : ['TotalPrice'] + } ); -annotate TravelService.Booking with @UI.CreateHidden : to_Travel.TravelStatus.createDeleteHidden; -annotate TravelService.Booking with @UI.DeleteHidden : to_Travel.TravelStatus.createDeleteHidden; +annotate TravelService.Booking with @UI.CreateHidden : ($self.to_Travel.TravelStatus_code != 'O'); +annotate TravelService.Booking with @UI.DeleteHidden : ($self.to_Travel.TravelStatus_code != 'O'); + +// code;createDeleteHidden;insertDeleteRestriction +// O; false; true +// A; true; false +// X; true; false + + annotate TravelService.Booking { BookingDate @Core.Computed; - ConnectionID @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - FlightDate @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - FlightPrice @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - BookingStatus @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Carrier @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Customer @Common.FieldControl : to_Travel.TravelStatus.fieldControl; + ConnectionID @Common.FieldControl : to_Travel.TravelStatus_ctrl; + FlightDate @Common.FieldControl : to_Travel.TravelStatus_ctrl; + FlightPrice @Common.FieldControl : to_Travel.TravelStatus_ctrl; + BookingStatus_code @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Carrier_AirlineID @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Customer_CustomerID @Common.FieldControl : to_Travel.TravelStatus_ctrl; }; annotate TravelService.Booking with @( @@ -63,10 +69,10 @@ annotate TravelService.Booking with @( { NavigationProperty : to_BookSupplement, InsertRestrictions : { - Insertable : to_Travel.TravelStatus.insertDeleteRestriction + Insertable : ($self.to_Travel.TravelStatus_code = 'O') }, DeleteRestrictions : { - Deletable : to_Travel.TravelStatus.insertDeleteRestriction + Deletable : ($self.to_Travel.TravelStatus_code = 'O') } } ] @@ -75,9 +81,9 @@ annotate TravelService.Booking with @( annotate TravelService.BookingSupplement { - Price @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Supplement @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Booking @Common.FieldControl : to_Travel.TravelStatus.fieldControl; - to_Travel @Common.FieldControl : to_Travel.TravelStatus.fieldControl; + Price @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Supplement_SupplementID @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Booking_BookingUUID @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Travel_TravelUUID @Common.FieldControl : to_Travel.TravelStatus_ctrl; }; diff --git a/app/travel_processor/layouts.cds b/app/travel_processor/layouts.cds index a58d5812..196e5588 100644 --- a/app/travel_processor/layouts.cds +++ b/app/travel_processor/layouts.cds @@ -76,6 +76,12 @@ annotate TravelService.Travel with @UI : { Target : '@UI.FieldGroup#TravelData', Label : '{i18n>GeneralInformation}' }, + { // experimental + $Type : 'UI.ReferenceFacet', + ID : 'ExperimentalData', + Target : '@UI.FieldGroup#ExperimentalData', + Label : 'Experimental' + }, { // price information $Type : 'UI.ReferenceFacet', ID : 'PriceData', @@ -108,6 +114,10 @@ annotate TravelService.Travel with @UI : { Label : '{i18n>Status}' // label only necessary if differs from title of element } ]}, + FieldGroup #ExperimentalData : {Data : [ + { $Type : 'UI.DataField', Value : field_A }, + { $Type : 'UI.DataField', Value : field_Ctr } + ]}, FieldGroup #DateData : {Data : [ { $Type : 'UI.DataField', Value : BeginDate }, { $Type : 'UI.DataField', Value : EndDate } diff --git a/db/schema.cds b/db/schema.cds index 07036343..d6b332d1 100644 --- a/db/schema.cds +++ b/db/schema.cds @@ -22,11 +22,17 @@ entity Travel : managed { TravelStatus_code : TravelStatusCode default 'O' @readonly; TravelStatus : Association to TravelStatus on TravelStatus.code = TravelStatus_code; + TravelStatus_ctrl: Int16 @odata.Type:'Edm.Byte' /*enum {Inapplicable = 0; ReadOnly = 1; Optional = 3; Mandatory = 7;}*/ + = (TravelStatus_code = 'A' ? 1 : 7 ); + to_Agency_AgencyID : String(6) @mandatory; to_Agency : Association to TravelAgency on to_Agency.AgencyID = to_Agency_AgencyID; to_Customer_CustomerID : String(6) @mandatory; to_Customer : Association to Passenger on to_Customer.CustomerID = to_Customer_CustomerID; to_Booking : Composition of many Booking on to_Booking.to_Travel = $self; + + field_A: String @label: 'controlled'; + field_Ctr : String @label: 'controlling'; }; annotate Travel with @Capabilities.FilterRestrictions.FilterExpressionRestrictions: [ From 1b08c9c5d05ea18684c6ebb3740239cc896ef229 Mon Sep 17 00:00:00 2001 From: Steffen Weinstock <79531202+stewsk@users.noreply.github.com> Date: Tue, 13 May 2025 14:12:29 +0200 Subject: [PATCH 5/5] use more xprs --- app/labels.cds | 28 ++++++----- app/travel_processor/field-control.cds | 70 +++++++++++++++++--------- app/travel_processor/layouts.cds | 60 +++++++++++++--------- db/master-data.cds | 9 ++-- db/schema.cds | 42 +++++++--------- srv/analytics-service.cds | 2 - 6 files changed, 117 insertions(+), 94 deletions(-) diff --git a/app/labels.cds b/app/labels.cds index 25a73636..a5fc7fdb 100644 --- a/app/labels.cds +++ b/app/labels.cds @@ -10,14 +10,15 @@ annotate schema.Travel with @title: '{i18n>Travel}' { BeginDate @title: '{i18n>BeginDate}'; EndDate @title: '{i18n>EndDate}'; Description @title: '{i18n>Description}'; - BookingFee @title: '{i18n>BookingFee}' @Measures.ISOCurrency: CurrencyCode_code; - TotalPrice @title: '{i18n>TotalPrice}' @Measures.ISOCurrency: CurrencyCode_code; + BookingFee @title: '{i18n>BookingFee}' @Measures.ISOCurrency: (CurrencyCode.code); + TotalPrice @title: '{i18n>TotalPrice}' @Measures.ISOCurrency: (CurrencyCode.code); GoGreen @title: '{i18n>GoGreen}'; - GreenFee @title: '{i18n>GreenFee}' @Measures.ISOCurrency: CurrencyCode_code; + GreenFee @title: '{i18n>GreenFee}' @Measures.ISOCurrency: (CurrencyCode.code); TreesPlanted @title: '{i18n>TreesPlanted}'; - TravelStatus @title: '{i18n>TravelStatus}' @Common.Text: TravelStatus.name @Common.TextArrangement: #TextOnly; - to_Customer_CustomerID @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; - to_Agency_AgencyID @title: '{i18n>AgencyID}' @Common.Text: to_Agency.Name; + TravelStatus @title: '{i18n>TravelStatus}' @Common.Text: TravelStatus.name + @Common.TextArrangement: #TextOnly; + to_Customer @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; + to_Agency @title: '{i18n>AgencyID}' @Common.Text: to_Agency.Name; } annotate schema.TravelStatus with { @@ -32,10 +33,11 @@ annotate schema.Booking with @title: '{i18n>Booking}' { ConnectionID @title: '{i18n>ConnectionID}'; CurrencyCode @title: '{i18n>CurrencyCode}'; FlightDate @title: '{i18n>FlightDate}'; - FlightPrice @title: '{i18n>FlightPrice}' @Measures.ISOCurrency: CurrencyCode_code; - BookingStatus_code @title: '{i18n>BookingStatus}' @Common.Text: BookingStatus.name @Common.TextArrangement: #TextOnly; - to_Carrier_AirlineID @title: '{i18n>AirlineID}' @Common.Text: to_Carrier.Name; - to_Customer_CustomerID @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; + FlightPrice @title: '{i18n>FlightPrice}' @Measures.ISOCurrency: (CurrencyCode.code); + BookingStatus @title: '{i18n>BookingStatus}' @Common.Text: BookingStatus.name + @Common.TextArrangement: #TextOnly; + to_Carrier @title: '{i18n>AirlineID}' @Common.Text: to_Carrier.Name; + to_Customer @title: '{i18n>CustomerID}' @Common.Text: to_Customer.LastName; } annotate schema.BookingStatus with { @@ -47,7 +49,7 @@ annotate schema.BookingSupplement with @title: '{i18n>BookingSupplement}' { to_Booking @UI.Hidden; to_Travel @UI.Hidden; to_Supplement @title: '{i18n>SupplementID}' @Common.Text: to_Supplement.Description; - Price @title: '{i18n>Price}' @Measures.ISOCurrency: CurrencyCode_code; + Price @title: '{i18n>Price}' @Measures.ISOCurrency: (CurrencyCode.code); BookingSupplementID @title: '{i18n>BookingSupplementID}'; CurrencyCode @title: '{i18n>CurrencyCode}'; } @@ -88,7 +90,7 @@ annotate schema.Flight with @title: '{i18n>Flight}' { FlightDate @title: '{i18n>FlightDate}'; ConnectionID @title: '{i18n>ConnectionID}'; CurrencyCode @title: '{i18n>CurrencyCode}'; - Price @title: '{i18n>Price}' @Measures.ISOCurrency: CurrencyCode_code; + Price @title: '{i18n>Price}' @Measures.ISOCurrency: (CurrencyCode.code); PlaneType @title: '{i18n>PlaneType}'; MaximumSeats @title: '{i18n>MaximumSeats}'; OccupiedSeats @title: '{i18n>OccupiedSeats}'; @@ -96,7 +98,7 @@ annotate schema.Flight with @title: '{i18n>Flight}' { annotate schema.Supplement with @title: '{i18n>Supplement}' { SupplementID @title: '{i18n>SupplementID}' @Common.Text: Description; - Price @title: '{i18n>Price}' @Measures.ISOCurrency: CurrencyCode_code; + Price @title: '{i18n>Price}' @Measures.ISOCurrency: (CurrencyCode.code); CurrencyCode @title: '{i18n>CurrencyCode}'; Description @title: '{i18n>Description}'; } diff --git a/app/travel_processor/field-control.cds b/app/travel_processor/field-control.cds index 03215cb4..a64ad00f 100644 --- a/app/travel_processor/field-control.cds +++ b/app/travel_processor/field-control.cds @@ -12,27 +12,36 @@ annotate TravelService.Travel with @(Common : { SideEffects #GoGreen:{ SourceProperties: [GoGreen], TargetProperties: ['TotalPrice', 'GreenFee', 'TreesPlanted'] + }, + SideEffects #Exp:{ + SourceProperties: [field_BCtr, field_BCtrCalc], + TargetProperties: ['field_B'] } }){ - BookingFee @Common.FieldControl : TravelStatus_ctrl; - BeginDate @Common.FieldControl : TravelStatus_ctrl; - EndDate @Common.FieldControl : TravelStatus_ctrl; - to_Agency_AgencyID @Common.FieldControl : TravelStatus_ctrl; - to_Customer_CustomerID @Common.FieldControl : TravelStatus_ctrl; + BookingFee @Common.FieldControl : TravelStatus_ctrl; + BeginDate @Common.FieldControl : TravelStatus_ctrl; + EndDate @Common.FieldControl : TravelStatus_ctrl; + to_Agency @Common.FieldControl : TravelStatus_ctrl; + to_Customer @Common.FieldControl : TravelStatus_ctrl; - field_A @Common.FieldControl: (field_Ctr = 'readonly' ? 1 : (field_Ctr = 'inapplicable' ? 0 : (field_Ctr = 'mandatory' ? 7 : 3))); + // field_A @Common.FieldControl: (field_ACtr = 'readonly' ? 1 : (field_ACtr = 'inapplicable' ? 0 : (field_ACtr = 'mandatory' ? 7 : 3))) + // @readonly: (field_ACtr = 'readonly') + // @mandatory: (field_ACtr = 'mandatory') + // @enabled: (field_ACtr != 'inapplicable'); + field_A @Common.FieldControl: (field_ACtr = 'readonly' and to_Agency.City = 'Sydney' ? 1 : 3); + field_B @Common.FieldControl: field_BCtrCalc; } actions { rejectTravel @( - Core.OperationAvailable : ($self.TravelStatus_code != 'X'), + Core.OperationAvailable : ($self.TravelStatus.code != 'X'), Common.SideEffects.TargetProperties : ['in/TravelStatus_code'], ); acceptTravel @( - Core.OperationAvailable : ($self.TravelStatus_code != 'A'), + Core.OperationAvailable : ($self.TravelStatus.code != 'A'), Common.SideEffects.TargetProperties : ['in/TravelStatus_code'], ); deductDiscount @( - Core.OperationAvailable : ($self.TravelStatus_code = 'O'), + Core.OperationAvailable : ($self.TravelStatus.code = 'O'), ); } @@ -43,8 +52,22 @@ annotate TravelService.Travel @( } ); -annotate TravelService.Booking with @UI.CreateHidden : ($self.to_Travel.TravelStatus_code != 'O'); -annotate TravelService.Booking with @UI.DeleteHidden : ($self.to_Travel.TravelStatus_code != 'O'); + +annotate TravelService.Booking with @UI.CreateHidden : (to_Travel.TravelStatus.code != 'O'); +annotate TravelService.Booking with @UI.DeleteHidden : (to_Travel.TravelStatus.code != 'O'); + +// ok +// annotate TravelService.Booking with @UI.CreateHidden : (not to_Travel.TravelStatus.createDeleteHidden); +// annotate TravelService.Booking with @UI.DeleteHidden : (not to_Travel.TravelStatus.createDeleteHidden); + +// ok +// annotate TravelService.Booking with @UI.CreateHidden : { $edmJson: { $Path: 'to_Travel/TravelStatus/createDeleteHidden'} }; +// annotate TravelService.Booking with @UI.DeleteHidden : { $edmJson: { $Path: 'to_Travel/TravelStatus/createDeleteHidden'} }; + +// ok +// annotate TravelService.Booking with @UI.CreateHidden : { $edmJson: {$Not: { $Path: 'to_Travel/TravelStatus/createDeleteHidden'} } }; +// annotate TravelService.Booking with @UI.DeleteHidden : { $edmJson: {$Not: { $Path: 'to_Travel/TravelStatus/createDeleteHidden'} } }; + // code;createDeleteHidden;insertDeleteRestriction // O; false; true @@ -55,12 +78,12 @@ annotate TravelService.Booking with @UI.DeleteHidden : ($self.to_Travel.TravelSt annotate TravelService.Booking { BookingDate @Core.Computed; - ConnectionID @Common.FieldControl : to_Travel.TravelStatus_ctrl; - FlightDate @Common.FieldControl : to_Travel.TravelStatus_ctrl; - FlightPrice @Common.FieldControl : to_Travel.TravelStatus_ctrl; - BookingStatus_code @Common.FieldControl : to_Travel.TravelStatus_ctrl; - to_Carrier_AirlineID @Common.FieldControl : to_Travel.TravelStatus_ctrl; - to_Customer_CustomerID @Common.FieldControl : to_Travel.TravelStatus_ctrl; + ConnectionID @Common.FieldControl : to_Travel.TravelStatus_ctrl; + FlightDate @Common.FieldControl : to_Travel.TravelStatus_ctrl; + FlightPrice @Common.FieldControl : to_Travel.TravelStatus_ctrl; + BookingStatus @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Carrier @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Customer @Common.FieldControl : to_Travel.TravelStatus_ctrl; }; annotate TravelService.Booking with @( @@ -69,10 +92,10 @@ annotate TravelService.Booking with @( { NavigationProperty : to_BookSupplement, InsertRestrictions : { - Insertable : ($self.to_Travel.TravelStatus_code = 'O') + Insertable : (to_Travel.TravelStatus.code = 'O') }, DeleteRestrictions : { - Deletable : ($self.to_Travel.TravelStatus_code = 'O') + Deletable : (to_Travel.TravelStatus.code = 'O') } } ] @@ -81,9 +104,8 @@ annotate TravelService.Booking with @( annotate TravelService.BookingSupplement { - Price @Common.FieldControl : to_Travel.TravelStatus_ctrl; - to_Supplement_SupplementID @Common.FieldControl : to_Travel.TravelStatus_ctrl; - to_Booking_BookingUUID @Common.FieldControl : to_Travel.TravelStatus_ctrl; - to_Travel_TravelUUID @Common.FieldControl : to_Travel.TravelStatus_ctrl; - + Price @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Supplement @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Booking @Common.FieldControl : to_Travel.TravelStatus_ctrl; + to_Travel @Common.FieldControl : to_Travel.TravelStatus_ctrl; }; diff --git a/app/travel_processor/layouts.cds b/app/travel_processor/layouts.cds index 196e5588..26015978 100644 --- a/app/travel_processor/layouts.cds +++ b/app/travel_processor/layouts.cds @@ -46,11 +46,11 @@ annotate TravelService.Travel with @UI : { @UI.Importance : #High }, { - Value : to_Agency_AgencyID, + Value : (to_Agency.AgencyID), @HTML5.CssDefaults: {width:'16em'} }, { - Value : to_Customer_CustomerID, + Value : (to_Customer.CustomerID), @UI.Importance : #High, @HTML5.CssDefaults: {width:'14em'} }, @@ -59,8 +59,8 @@ annotate TravelService.Travel with @UI : { { Value : BookingFee, @HTML5.CssDefaults: {width:'10em'} }, { Value : TotalPrice, @HTML5.CssDefaults: {width:'12em'} }, { - Value : TravelStatus_code, - Criticality : ($self.TravelStatus_code = 'O' ? 2 : ($self.TravelStatus_code = 'A' ? 3 : 0)), + Value : (TravelStatus.code), + Criticality : (TravelStatus.code = 'O' ? 2 : (TravelStatus.code = 'A' ? 3 : 0)), @UI.Importance : #High, @HTML5.CssDefaults: {width:'10em'} } @@ -76,11 +76,17 @@ annotate TravelService.Travel with @UI : { Target : '@UI.FieldGroup#TravelData', Label : '{i18n>GeneralInformation}' }, - { // experimental + { // experimental A $Type : 'UI.ReferenceFacet', - ID : 'ExperimentalData', - Target : '@UI.FieldGroup#ExperimentalData', - Label : 'Experimental' + ID : 'ExperimentalDataA', + Target : '@UI.FieldGroup#ExperimentalDataA', + Label : 'FC via edmXpr' + }, + { // experimental B + $Type : 'UI.ReferenceFacet', + ID : 'ExperimentalDataB', + Target : '@UI.FieldGroup#ExperimentalDataB', + Label : 'FC via CalcElem' }, { // price information $Type : 'UI.ReferenceFacet', @@ -104,19 +110,23 @@ annotate TravelService.Travel with @UI : { }], FieldGroup#TravelData : { Data : [ { Value : TravelID }, - { Value : to_Agency_AgencyID }, - { Value : to_Customer_CustomerID }, + { Value : (to_Agency.AgencyID) }, + { Value : (to_Customer.CustomerID) }, { Value : Description }, { $Type : 'UI.DataField', - Value : TravelStatus_code, - Criticality : ($self.TravelStatus_code = 'O' ? 2 : ($self.TravelStatus_code = 'A' ? 3 : 0)), + Value : (TravelStatus.code), + Criticality : (TravelStatus.code = 'O' ? 2 : (TravelStatus.code = 'A' ? 3 : 0)), Label : '{i18n>Status}' // label only necessary if differs from title of element } ]}, - FieldGroup #ExperimentalData : {Data : [ + FieldGroup #ExperimentalDataA : {Data : [ { $Type : 'UI.DataField', Value : field_A }, - { $Type : 'UI.DataField', Value : field_Ctr } + { $Type : 'UI.DataField', Value : field_ACtr } + ]}, + FieldGroup #ExperimentalDataB : {Data : [ + { $Type : 'UI.DataField', Value : field_B }, + { $Type : 'UI.DataField', Value : field_BCtr } ]}, FieldGroup #DateData : {Data : [ { $Type : 'UI.DataField', Value : BeginDate }, @@ -125,7 +135,7 @@ annotate TravelService.Travel with @UI : { FieldGroup #PriceData : {Data : [ { $Type : 'UI.DataField', Value : BookingFee }, { $Type : 'UI.DataField', Value : TotalPrice }, - { $Type : 'UI.DataField', Value : CurrencyCode_code } + { $Type : 'UI.DataField', Value : (CurrencyCode.code) } ]}, FieldGroup #i18nSustainability: { $Type: 'UI.FieldGroupType', @@ -169,13 +179,13 @@ annotate TravelService.Booking with @UI : { { Value : to_Carrier.AirlinePicURL, Label : ' '}, { Value : BookingID }, { Value : BookingDate }, - { Value : to_Customer_CustomerID }, - { Value : to_Carrier_AirlineID }, + { Value : (to_Customer.CustomerID) }, + { Value : (to_Carrier.AirlineID) }, { Value : ConnectionID, Label : '{i18n>FlightNumber}' }, { Value : FlightDate }, { Value : FlightPrice }, - { Value : BookingStatus_code, - Criticality : ($self.BookingStatus_code = 'N' ? 2 : ($self.BookingStatus_code = 'B' ? 3 : 0)), + { Value : (BookingStatus.code), + Criticality : (BookingStatus.code = 'N' ? 2 : (BookingStatus.code = 'B' ? 3 : 0)), } ], Facets : [{ @@ -202,14 +212,14 @@ annotate TravelService.Booking with @UI : { FieldGroup #GeneralInformation : { Data : [ { Value : BookingID }, { Value : BookingDate, }, - { Value : to_Customer_CustomerID }, + { Value : (to_Customer.CustomerID) }, { Value : BookingDate, }, - { Value : BookingStatus_code, - Criticality : ($self.BookingStatus_code = 'N' ? 2 : ($self.BookingStatus_code = 'B' ? 3 : 0)), + { Value : (BookingStatus.code), + Criticality : (BookingStatus.code = 'N' ? 2 : (BookingStatus.code = 'B' ? 3 : 0)), } ]}, FieldGroup #Flight : { Data : [ - { Value : to_Carrier_AirlineID }, + { Value : (to_Carrier.AirlineID) }, { Value : ConnectionID }, { Value : FlightDate }, { Value : FlightPrice } @@ -237,7 +247,7 @@ annotate TravelService.BookingSupplement with @UI : { }, LineItem : [ { Value : BookingSupplementID }, - { Value : to_Supplement_SupplementID, Label : '{i18n>ProductID}' }, - { Value : Price, Label : '{i18n>ProductPrice}' } + { Value : (to_Supplement.SupplementID), Label : '{i18n>ProductID}' }, + { Value : Price, Label : '{i18n>ProductPrice}' } ], }; diff --git a/db/master-data.cds b/db/master-data.cds index 0586a7b6..302c2afb 100644 --- a/db/master-data.cds +++ b/db/master-data.cds @@ -25,8 +25,7 @@ entity Airport : MasterData { entity Supplement : managed, MasterData { key SupplementID : String(10); Price : Decimal(16, 3); - Type_code : String(2); - Type : Association to SupplementType on Type.code = Type_code; + Type : Association to SupplementType; Description : localized String(1024); CurrencyCode : Currency; }; @@ -59,10 +58,8 @@ entity FlightConnection : MasterData { key ConnectionID : String(4); key AirlineID : String(3); - DepartureAirport_AirportID : String(3); - DepartureAirport : Association to Airport on DepartureAirport.AirportID = DepartureAirport_AirportID; - DestinationAirport_AirportID : String(3); - DestinationAirport : Association to Airport on DestinationAirport.AirportID = DestinationAirport_AirportID; + DepartureAirport : Association to Airport; + DestinationAirport : Association to Airport; DepartureTime : Time; ArrivalTime : Time; Distance : Integer; diff --git a/db/schema.cds b/db/schema.cds index d6b332d1..68a24269 100644 --- a/db/schema.cds +++ b/db/schema.cds @@ -19,20 +19,21 @@ entity Travel : managed { CurrencyCode : Currency default 'EUR'; Description : String(1024); - TravelStatus_code : TravelStatusCode default 'O' @readonly; - TravelStatus : Association to TravelStatus on TravelStatus.code = TravelStatus_code; + TravelStatus : Association to TravelStatus default 'O' @readonly; TravelStatus_ctrl: Int16 @odata.Type:'Edm.Byte' /*enum {Inapplicable = 0; ReadOnly = 1; Optional = 3; Mandatory = 7;}*/ - = (TravelStatus_code = 'A' ? 1 : 7 ); + = (TravelStatus.code = 'A' ? 1 : 7 ); - to_Agency_AgencyID : String(6) @mandatory; - to_Agency : Association to TravelAgency on to_Agency.AgencyID = to_Agency_AgencyID; - to_Customer_CustomerID : String(6) @mandatory; - to_Customer : Association to Passenger on to_Customer.CustomerID = to_Customer_CustomerID; + to_Agency : Association to TravelAgency @mandatory; + to_Customer : Association to Passenger @mandatory; to_Booking : Composition of many Booking on to_Booking.to_Travel = $self; - field_A: String @label: 'controlled'; - field_Ctr : String @label: 'controlling'; + field_A: String @label: 'controlled A'; + field_ACtr : String @label: 'controlling A'; + + field_B: String @label: 'controlled B'; + field_BCtr : String @label: 'controlling B'; + field_BCtrCalc : Int16 @odata.Type:'Edm.Byte' = (field_BCtr = 'readonly' ? 1 : (field_BCtr = 'inapplicable' ? 0 : (field_BCtr = 'mandatory' ? 7 : 3))); }; annotate Travel with @Capabilities.FilterRestrictions.FilterExpressionRestrictions: [ @@ -50,18 +51,14 @@ entity Booking : managed { FlightPrice : Decimal(16,3) @mandatory; CurrencyCode : Currency; - BookingStatus_code : BookingStatusCode default 'N' @mandatory; - BookingStatus : Association to BookingStatus on BookingStatus.code = BookingStatus_code; + BookingStatus : Association to BookingStatus default 'N' @mandatory; to_BookSupplement : Composition of many BookingSupplement on to_BookSupplement.to_Booking = $self; - to_Carrier_AirlineID : String(3) @mandatory; - to_Carrier : Association to Airline on to_Carrier.AirlineID = to_Carrier_AirlineID; - to_Customer_CustomerID : String(6) @mandatory; - to_Customer : Association to Passenger on to_Customer.CustomerID = to_Customer_CustomerID; - to_Travel_TravelUUID : UUID; - to_Travel : Association to Travel on to_Travel.TravelUUID = to_Travel_TravelUUID; + to_Carrier : Association to Airline @mandatory; + to_Customer : Association to Passenger @mandatory; + to_Travel : Association to Travel; - to_Flight : Association to Flight on to_Flight.AirlineID = to_Carrier_AirlineID + to_Flight : Association to Flight on to_Flight.AirlineID = to_Carrier.AirlineID and to_Flight.FlightDate = FlightDate and to_Flight.ConnectionID = ConnectionID; }; @@ -72,12 +69,9 @@ entity BookingSupplement : managed { Price : Decimal(16,3) @mandatory; CurrencyCode : Currency; - to_Booking_BookingUUID : UUID; - to_Booking : Association to Booking on to_Booking.BookingUUID = to_Booking_BookingUUID; - to_Travel_TravelUUID : UUID; - to_Travel : Association to Travel on to_Travel.TravelUUID = to_Travel_TravelUUID; - to_Supplement_SupplementID : String(10) @mandatory; - to_Supplement : Association to Supplement on to_Supplement.SupplementID = to_Supplement_SupplementID; + to_Booking : Association to Booking; + to_Travel : Association to Travel; + to_Supplement : Association to Supplement @mandatory; }; diff --git a/srv/analytics-service.cds b/srv/analytics-service.cds index b428a728..4a2ab1d0 100644 --- a/srv/analytics-service.cds +++ b/srv/analytics-service.cds @@ -37,9 +37,7 @@ service AnalyticsService @(path:'/analytics') { BookingDate, - to_Travel_TravelUUID, to_Travel, - to_Carrier_AirlineID, to_Carrier, // Java has a problem with this association