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

View File

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