Namespaces

This commit is contained in:
Wolfgang Koch
2021-05-06 17:12:45 +02:00
parent be657cbbcb
commit 66d792d76d
6 changed files with 29 additions and 29 deletions

View File

@@ -1,3 +1,3 @@
ID;createdAt;createdBy;buyer;OrderNo;currency_code;Customer_ID;priority ID;createdAt;createdBy;buyer;OrderNo;currency_code;Z_Customer_ID;Z_priority
7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;john.doe@test.com;1;EUR;8e2f2640-6866-4dcf-8f4d-3027aa831cad;high 7e2f2640-6866-4dcf-8f4d-3027aa831cad;2019-01-31;john.doe@test.com;john.doe@test.com;1;EUR;8e2f2640-6866-4dcf-8f4d-3027aa831cad;high
64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;jane.doe@test.com;2;EUR;74e718c9-ff99-47f1-8ca3-950c850777d4;low 64e718c9-ff99-47f1-8ca3-950c850777d4;2019-01-30;jane.doe@test.com;jane.doe@test.com;2;EUR;74e718c9-ff99-47f1-8ca3-950c850777d4;low
1 ID createdAt createdBy buyer OrderNo currency_code Customer_ID Z_Customer_ID priority Z_priority
2 7e2f2640-6866-4dcf-8f4d-3027aa831cad 2019-01-31 john.doe@test.com john.doe@test.com 1 EUR 8e2f2640-6866-4dcf-8f4d-3027aa831cad 8e2f2640-6866-4dcf-8f4d-3027aa831cad high high
3 64e718c9-ff99-47f1-8ca3-950c850777d4 2019-01-30 jane.doe@test.com jane.doe@test.com 2 EUR 74e718c9-ff99-47f1-8ca3-950c850777d4 74e718c9-ff99-47f1-8ca3-950c850777d4 low low

View File

@@ -7,17 +7,17 @@ using {
cuid, managed, Country cuid, managed, Country
} from '@sap/cds/common'; } from '@sap/cds/common';
namespace sap.bookshop.extension; namespace Z_bookshop.extension;
// extend existing entity // extend existing entity
extend orders.Orders with { extend orders.Orders with {
Customer : Association to one Customers; Z_Customer : Association to one Z_Customers;
Remarks : Composition of many Remarks on Remarks.parent = $self; Z_Remarks : Composition of many Z_Remarks on Z_Remarks.parent = $self;
priority : String @assert.range enum {high; medium; low} default 'medium'; Z_priority : String @assert.range enum {high; medium; low} default 'medium';
} }
// new entity - as association target // new entity - as association target
entity Customers : cuid, managed { entity Z_Customers : cuid, managed {
email : String; email : String;
firstName : String; firstName : String;
lastName : String; lastName : String;
@@ -25,18 +25,18 @@ entity Customers : cuid, managed {
dateOfBirth : Date; dateOfBirth : Date;
status : String @assert.range enum {platinum; gold; silver; bronze} default 'bronze'; status : String @assert.range enum {platinum; gold; silver; bronze} default 'bronze';
creditScore : Decimal @assert.range: [ 1.0, 100.0 ] default 50.0; creditScore : Decimal @assert.range: [ 1.0, 100.0 ] default 50.0;
PostalAddresses : Composition of many CustomerPostalAddresses on PostalAddresses.Customer = $self; PostalAddresses : Composition of many Z_CustomerPostalAddresses on PostalAddresses.Customer = $self;
} }
// new unique constraint (secondary index) // new unique constraint (secondary index)
annotate Customers with @assert.unique: { email: [ email ] } annotate Z_Customers with @assert.unique: { email: [ email ] }
{ {
email @mandatory; // mandatory check email @mandatory; // mandatory check
} }
// new entity - as composition target // new entity - as composition target
entity CustomerPostalAddresses : cuid, managed { entity Z_CustomerPostalAddresses : cuid, managed {
Customer : Association to one Customers; Customer : Association to one Z_Customers;
description : String; description : String;
street : String; street : String;
town : String; town : String;
@@ -44,7 +44,7 @@ entity CustomerPostalAddresses : cuid, managed {
}; };
// new entity - as composition target // new entity - as composition target
entity Remarks : cuid, managed entity Z_Remarks : cuid, managed
{ {
parent : Association to one orders.Orders; parent : Association to one orders.Orders;
number : Integer; number : Integer;

View File

@@ -2,8 +2,8 @@ using from '_base/srv/admin-service';
using from '_base/srv/cat-service'; using from '_base/srv/cat-service';
using from '_base/srv/orders-service'; using from '_base/srv/orders-service';
using { sap.bookshop.extension as ext } from '../db/extension'; using { Z_bookshop.extension as ext } from '../db/extension';
extend service OrdersService with { extend service OrdersService with {
entity Customers as projection on ext.Customers; entity Z_Customers as projection on ext.Z_Customers;
} }

View File

@@ -3,10 +3,10 @@ using OrdersService from './extension_service';
// new entity -- draft enabled // new entity -- draft enabled
annotate OrdersService.Customers with @odata.draft.enabled; annotate OrdersService.Z_Customers with @odata.draft.enabled;
// new entity -- titles // new entity -- titles
annotate OrdersService.Customers with { annotate OrdersService.Z_Customers with {
ID @( ID @(
UI.Hidden, UI.Hidden,
Common : {Text : email} Common : {Text : email}
@@ -21,7 +21,7 @@ annotate OrdersService.Customers with {
} }
// new entity -- titles // new entity -- titles
annotate OrdersService.CustomerPostalAddresses with { annotate OrdersService.Z_CustomerPostalAddresses with {
ID @( ID @(
UI.Hidden, UI.Hidden,
Common : {Text : description} Common : {Text : description}
@@ -33,13 +33,13 @@ annotate OrdersService.CustomerPostalAddresses with {
} }
// new entity -- titles // new entity -- titles
annotate OrdersService.Remarks with { annotate OrdersService.Z_Remarks with {
number @title: 'Remark Number'; number @title: 'Remark Number';
remarksLine @title: 'Remark'; remarksLine @title: 'Remark';
} }
// new entity in service -- UI // new entity in service -- UI
annotate OrdersService.Customers with @(UI : { annotate OrdersService.Z_Customers with @(UI : {
HeaderInfo : { HeaderInfo : {
TypeName : 'Customer', TypeName : 'Customer',
TypeNamePlural : 'Customers', TypeNamePlural : 'Customers',
@@ -69,7 +69,7 @@ annotate OrdersService.Customers with @(UI : {
} ) ; } ) ;
// new entity -- UI // new entity -- UI
annotate OrdersService.CustomerPostalAddresses with @(UI : { annotate OrdersService.Z_CustomerPostalAddresses with @(UI : {
HeaderInfo : { HeaderInfo : {
TypeName : 'CustomerPostalAddress', TypeName : 'CustomerPostalAddress',
TypeNamePlural : 'CustomerPostalAddresses', TypeNamePlural : 'CustomerPostalAddresses',
@@ -100,7 +100,7 @@ annotate OrdersService.CustomerPostalAddresses with @(UI : {
// new entity -- UI // new entity -- UI
annotate OrdersService.Remarks with @( annotate OrdersService.Z_Remarks with @(
UI: { UI: {
HeaderInfo: { HeaderInfo: {
TypeName: 'Remark', TypeName: 'Remark',
@@ -137,8 +137,8 @@ annotate OrdersService.Orders with @(
SelectionFields: [ createdAt, createdBy ], SelectionFields: [ createdAt, createdBy ],
LineItem: [ LineItem: [
{Value: OrderNo, Label:'OrderNo'}, {Value: OrderNo, Label:'OrderNo'},
{Value: Customer_ID, Label:'Customer'}, // extension field {Value: Z_Customer_ID, Label:'Customer'}, // extension field
{Value: priority, Label:'Priority'}, // extension field {Value: Z_priority, Label:'Priority'}, // extension field
{Value: createdAt, Label:'Date'} {Value: createdAt, Label:'Date'}
], ],
HeaderInfo: { HeaderInfo: {
@@ -161,13 +161,13 @@ annotate OrdersService.Orders with @(
Facets: [ Facets: [
{$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'}, {$Type: 'UI.ReferenceFacet', Label: '{i18n>Details}', Target: '@UI.FieldGroup#Details'},
{$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: 'Items/@UI.LineItem'}, {$Type: 'UI.ReferenceFacet', Label: '{i18n>OrderItems}', Target: 'Items/@UI.LineItem'},
{$Type: 'UI.ReferenceFacet', Label: 'Remarks', Target: 'Remarks/@UI.LineItem'} // new composition {$Type: 'UI.ReferenceFacet', Label: 'Remarks', Target: 'Z_Remarks/@UI.LineItem'} // new composition
], ],
FieldGroup#Details: { FieldGroup#Details: {
Data: [ Data: [
{Value: currency_code, Label:'Currency'}, // correction {Value: currency_code, Label:'Currency'}, // correction
{Value: Customer_ID, Label:'Customer'}, // extension field {Value: Z_Customer_ID, Label:'Customer'}, // extension field
{Value: priority, Label:'Priority'} // extension field {Value: Z_priority, Label:'Priority'} // extension field
] ]
}, },
FieldGroup#Created: { FieldGroup#Created: {
@@ -190,16 +190,16 @@ annotate OrdersService.Orders with @(
// new field in existing service -- exchange ID with text // new field in existing service -- exchange ID with text
annotate OrdersService.Orders with { annotate OrdersService.Orders with {
Customer @( Z_Customer @(
Common: { Common: {
//show email, not id for Customer in the context of Orders //show email, not id for Customer in the context of Orders
Text: Customer.email , TextArrangement: #TextOnly, Text: Z_Customer.email , TextArrangement: #TextOnly,
ValueList: { ValueList: {
Label: 'Customers', Label: 'Customers',
CollectionPath: 'Customers', CollectionPath: 'Z_Customers',
Parameters: [ Parameters: [
{ $Type: 'Common.ValueListParameterInOut', { $Type: 'Common.ValueListParameterInOut',
LocalDataProperty: Customer_ID, LocalDataProperty: Z_Customer_ID,
ValueListProperty: 'ID' ValueListProperty: 'ID'
}, },
{ $Type: 'Common.ValueListParameterDisplayOnly', { $Type: 'Common.ValueListParameterDisplayOnly',