diff --git a/orders/db/data/sap.capire.orders-OrderItems.csv b/orders/db/data/sap.capire.orders-Orders_Items.csv similarity index 100% rename from orders/db/data/sap.capire.orders-OrderItems.csv rename to orders/db/data/sap.capire.orders-Orders_Items.csv diff --git a/orders/db/schema.cds- b/orders/db/schema.cds- new file mode 100644 index 00000000..ec0e6cf6 --- /dev/null +++ b/orders/db/schema.cds- @@ -0,0 +1,26 @@ +using { Currency, User, managed, cuid } from '@sap/cds/common'; +using from '@capire/common'; +namespace sap.capire.orders; + +entity Orders : cuid, managed { + OrderNo : String @title:'Order Number'; //> readable key + Items : Composition of many Orders_Items on Items.up_ = $self; + buyer : User; + currency : Currency; +} + +entity Orders_Items { + up_ : Association to Orders not null; //> IMPORTANT for Draft: not key(!) + key ID : UUID; + @assert.integrity:false // REVISIT: this is a temporary workaround for a glitch in cds-runtime + product : Association to Products; + amount : Integer; + title : String; + price : Double; +} + +/** This is a stand-in for arbitrary ordered Products */ +@cds.persistence.skip:'always' +entity Products { + key ID : String; +} diff --git a/orders/managed-comp.xml b/orders/managed-comp.xml index a1b9f107..5e9f4bfb 100644 --- a/orders/managed-comp.xml +++ b/orders/managed-comp.xml @@ -12,20 +12,11 @@ - - - - - + - - - - - @@ -38,22 +29,16 @@ - - - - - - + + - - @@ -79,9 +64,7 @@ - - - + @@ -95,14 +78,10 @@ - - - - - + @@ -161,10 +140,6 @@ - - - - @@ -438,13 +413,6 @@ - - - - - - - diff --git a/orders/metadata.xml b/orders/metadata.xml index d02d01c8..8f88e9fd 100644 --- a/orders/metadata.xml +++ b/orders/metadata.xml @@ -18,13 +18,13 @@ - + - - - + + + @@ -79,7 +79,7 @@ - + @@ -93,14 +93,14 @@ - + - - - + + + @@ -111,18 +111,18 @@ - + - - - - - + + + + + @@ -391,7 +391,7 @@ - + @@ -437,26 +437,26 @@ - + - + - + - + - + - + diff --git a/orders/package.json b/orders/package.json index e1c683af..13085c12 100644 --- a/orders/package.json +++ b/orders/package.json @@ -4,5 +4,10 @@ "dependencies": { "@capire/common": "*", "@sap/cds": "^4.3.0" + }, + "cds": { + "odata": { + "--containment": true + } } } \ No newline at end of file diff --git a/orders/test/model.cds b/orders/test/model.cds new file mode 100644 index 00000000..221ee841 --- /dev/null +++ b/orders/test/model.cds @@ -0,0 +1,14 @@ +service WithDraft { + @odata.draft.enabled + entity Boo as projection on Foo; +} +service WithoutDraft { + entity Boo as projection on Foo; +} + +entity Foo { + key ID : UUID; + bar : Composition of many { + key pos : Integer; //> meant to be a local key only + } +} diff --git a/orders/test/with-containment/WithDraft.xml b/orders/test/with-containment/WithDraft.xml new file mode 100644 index 00000000..edee7c85 --- /dev/null +++ b/orders/test/with-containment/WithDraft.xml @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/orders/test/with-containment/WithoutDraft.xml b/orders/test/with-containment/WithoutDraft.xml new file mode 100644 index 00000000..a18b86fd --- /dev/null +++ b/orders/test/with-containment/WithoutDraft.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/orders/test/without-containment-fixed/WithDraft.xml b/orders/test/without-containment-fixed/WithDraft.xml new file mode 100644 index 00000000..87c8b4f1 --- /dev/null +++ b/orders/test/without-containment-fixed/WithDraft.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/orders/test/without-containment-fixed/WithoutDraft.xml b/orders/test/without-containment-fixed/WithoutDraft.xml new file mode 100644 index 00000000..96b30473 --- /dev/null +++ b/orders/test/without-containment-fixed/WithoutDraft.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/orders/test/without-containment/WithDraft.xml b/orders/test/without-containment/WithDraft.xml new file mode 100644 index 00000000..301512b1 --- /dev/null +++ b/orders/test/without-containment/WithDraft.xml @@ -0,0 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/orders/test/without-containment/WithoutDraft.xml b/orders/test/without-containment/WithoutDraft.xml new file mode 100644 index 00000000..96b30473 --- /dev/null +++ b/orders/test/without-containment/WithoutDraft.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file