Skip to content

Commit f44e736

Browse files
CAP service to mock northwind products
1 parent c65c51c commit f44e736

10 files changed

+437
-0
lines changed

cap-service/.cdsrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

cap-service/.gitignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# CAP cap-service
2+
_out
3+
*.db
4+
connection.properties
5+
default-*.json
6+
gen/
7+
node_modules/
8+
target/
9+
10+
# Web IDE, App Studio
11+
.che/
12+
.gen/
13+
14+
# MTA
15+
*_mta_build_tmp
16+
*.mtar
17+
mta_archives/
18+
19+
# Other
20+
.DS_Store
21+
*.orig
22+
*.log
23+
24+
*.iml
25+
*.flattened-pom.xml
26+
27+
# IDEs
28+
.vscode
29+
.idea

cap-service/README.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Getting Started
2+
3+
This CAP project mocks the Northwind Product service available at:
4+
`https://services.odata.org/v2/Northwind/Northwind.svc/Products`
5+
6+
After the deploy of the MTA the service response at the same path `/v2/Northwind/Northwind.svc/Products`, this means that you can replace the address in the BTP service destination `Northwind` created by the `managed-html5-runtime-fiori-mta` sample and you will get the same results.
7+
8+
This package contains the same sample data of the original Northwind service.
9+
10+
As defined in the file `srv/cat-service.cds` the CAP service requires authentication, so in the `Northwind` destination you have to change the address and you have to set the `HTML5.ForwardAuthToken` additional property too.
11+
This property is documented at [Configure Destinations](https://help.sap.com/viewer/ad4b9f0b14b0458cad9bd27bf435637d/LATEST/en-US/fab4035652cb4fc48503c65dc841d335.html)
12+
13+
The MTA file bind the CAP service to the xsuaa service already created by the `managed-html5-runtime-fiori-mta` package.
14+
15+
## Deployment
16+
17+
1. Deploy the `managed-html5-runtime-fiori-mta` to you BTP subaccount as explained in the package documentation
18+
2. Add the entitlement `hana hdi-shared` to your subaccount if you haven't done so before
19+
3. Build the project:
20+
```
21+
mbt build
22+
```
23+
4. Deploy the package in the same subaccount/space of the `managed-html5-runtime-fiori-mta` package:
24+
```
25+
cf deploy mta_archives/cap-service_1.0.0.mtar
26+
```
27+
5. See the URL of the CAP service:
28+
```
29+
cf app cap-service-srv
30+
```
31+
6. Set the address of the `Northwind` destination to the URL of CAP service
32+
7. Set the additional property `HTML5.ForwardAuthToken` to `true`
33+
34+
## Check the Result
35+
36+
### Check the HTML5 App
37+
To be sure to use the new address set in the destination open a incognito browser window and access the URL of the HTML5 App of the `managed-html5-runtime-fiori-mta` package, you should see the same data, however the product name of the product with ID 1 will be *Hello from CAP*, this is the mark that the data are read from the CAP service.

cap-service/db/data-model.cds

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace my.bookshop;
2+
3+
entity Products {
4+
key ProductID: Integer;
5+
ProductName: String;
6+
SupplierID: Integer;
7+
CategoryID: Integer;
8+
QuantityPerUnit: String;
9+
UnitPrice: Decimal;
10+
UnitsInStock: Integer;
11+
UnitsOnOrder: Integer;
12+
ReorderLevel: Integer;
13+
Discontinued: Boolean;
14+
}
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
ProductID;CategoryID;Discontinued;ProductName;QuantityPerUnit;ReorderLevel;SupplierID;UnitPrice;UnitsInStock;UnitsOnOrder
2+
1;1;False;Hello from CAP;10 boxes x 20 bags;10;1;18.0000;39;0
3+
2;1;False;Chang;24 - 12 oz bottles;25;1;19.0000;17;40
4+
3;2;False;Aniseed Syrup;12 - 550 ml bottles;25;1;10.0000;13;70
5+
4;2;False;Chef Anton's Cajun Seasoning;48 - 6 oz jars;0;2;22.0000;53;0
6+
5;2;True;Chef Anton's Gumbo Mix;36 boxes;0;2;21.3500;0;0
7+
6;2;False;Grandma's Boysenberry Spread;12 - 8 oz jars;25;3;25.0000;120;0
8+
7;7;False;Uncle Bob's Organic Dried Pears;12 - 1 lb pkgs.;10;3;30.0000;15;0
9+
8;2;False;Northwoods Cranberry Sauce;12 - 12 oz jars;0;3;40.0000;6;0
10+
9;6;True;Mishi Kobe Niku;18 - 500 g pkgs.;0;4;97.0000;29;0
11+
10;8;False;Ikura;12 - 200 ml jars;0;4;31.0000;31;0
12+
11;4;False;Queso Cabrales;1 kg pkg.;30;5;21.0000;22;30
13+
12;4;False;Queso Manchego La Pastora;10 - 500 g pkgs.;0;5;38.0000;86;0
14+
13;8;False;Konbu;2 kg box;5;6;6.0000;24;0
15+
14;7;False;Tofu;40 - 100 g pkgs.;0;6;23.2500;35;0
16+
15;2;False;Genen Shouyu;24 - 250 ml bottles;5;6;15.5000;39;0
17+
16;3;False;Pavlova;32 - 500 g boxes;10;7;17.4500;29;0
18+
17;6;True;Alice Mutton;20 - 1 kg tins;0;7;39.0000;0;0
19+
18;8;False;Carnarvon Tigers;16 kg pkg.;0;7;62.5000;42;0
20+
19;3;False;Teatime Chocolate Biscuits;10 boxes x 12 pieces;5;8;9.2000;25;0
21+
20;3;False;Sir Rodney's Marmalade;30 gift boxes;0;8;81.0000;40;0
22+
21;3;False;Sir Rodney's Scones;24 pkgs. x 4 pieces;5;8;10.0000;3;40
23+
22;5;False;Gustaf's Knäckebröd;24 - 500 g pkgs.;25;9;21.0000;104;0
24+
23;5;False;Tunnbröd;12 - 250 g pkgs.;25;9;9.0000;61;0
25+
24;1;True;Guaraná Fantástica;12 - 355 ml cans;0;10;4.5000;20;0
26+
25;3;False;NuNuCa Nuß-Nougat-Creme;20 - 450 g glasses;30;11;14.0000;76;0
27+
26;3;False;Gumbär Gummibärchen;100 - 250 g bags;0;11;31.2300;15;0
28+
27;3;False;Schoggi Schokolade;100 - 100 g pieces;30;11;43.9000;49;0
29+
28;7;True;Rössle Sauerkraut;25 - 825 g cans;0;12;45.6000;26;0
30+
29;6;True;Thüringer Rostbratwurst;50 bags x 30 sausgs.;0;12;123.7900;0;0
31+
30;8;False;Nord-Ost Matjeshering;10 - 200 g glasses;15;13;25.8900;10;0
32+
31;4;False;Gorgonzola Telino;12 - 100 g pkgs;20;14;12.5000;0;70
33+
32;4;False;Mascarpone Fabioli;24 - 200 g pkgs.;25;14;32.0000;9;40
34+
33;4;False;Geitost;500 g;20;15;2.5000;112;0
35+
34;1;False;Sasquatch Ale;24 - 12 oz bottles;15;16;14.0000;111;0
36+
35;1;False;Steeleye Stout;24 - 12 oz bottles;15;16;18.0000;20;0
37+
36;8;False;Inlagd Sill;24 - 250 g jars;20;17;19.0000;112;0
38+
37;8;False;Gravad lax;12 - 500 g pkgs.;25;17;26.0000;11;50
39+
38;1;False;Côte de Blaye;12 - 75 cl bottles;15;18;263.5000;17;0
40+
39;1;False;Chartreuse verte;750 cc per bottle;5;18;18.0000;69;0
41+
40;8;False;Boston Crab Meat;24 - 4 oz tins;30;19;18.4000;123;0
42+
41;8;False;Jack's New England Clam Chowder;12 - 12 oz cans;10;19;9.6500;85;0
43+
42;5;True;Singaporean Hokkien Fried Mee;32 - 1 kg pkgs.;0;20;14.0000;26;0
44+
43;1;False;Ipoh Coffee;16 - 500 g tins;25;20;46.0000;17;10
45+
44;2;False;Gula Malacca;20 - 2 kg bags;15;20;19.4500;27;0
46+
45;8;False;Rogede sild;1k pkg.;15;21;9.5000;5;70
47+
46;8;False;Spegesild;4 - 450 g glasses;0;21;12.0000;95;0
48+
47;3;False;Zaanse koeken;10 - 4 oz boxes;0;22;9.5000;36;0
49+
48;3;False;Chocolade;10 pkgs.;25;22;12.7500;15;70
50+
49;3;False;Maxilaku;24 - 50 g pkgs.;15;23;20.0000;10;60
51+
50;3;False;Valkoinen suklaa;12 - 100 g bars;30;23;16.2500;65;0
52+
51;7;False;Manjimup Dried Apples;50 - 300 g pkgs.;10;24;53.0000;20;0
53+
52;5;False;Filo Mix;16 - 2 kg boxes;25;24;7.0000;38;0
54+
53;6;True;Perth Pasties;48 pieces;0;24;32.8000;0;0
55+
54;6;False;Tourtière;16 pies;10;25;7.4500;21;0
56+
55;6;False;Pâté chinois;24 boxes x 2 pies;20;25;24.0000;115;0
57+
56;5;False;Gnocchi di nonna Alice;24 - 250 g pkgs.;30;26;38.0000;21;10
58+
57;5;False;Ravioli Angelo;24 - 250 g pkgs.;20;26;19.5000;36;0
59+
58;8;False;Escargots de Bourgogne;24 pieces;20;27;13.2500;62;0
60+
59;4;False;Raclette Courdavault;5 kg pkg.;0;28;55.0000;79;0
61+
60;4;False;Camembert Pierrot;15 - 300 g rounds;0;28;34.0000;19;0
62+
61;2;False;Sirop d'érable;24 - 500 ml bottles;25;29;28.5000;113;0
63+
62;3;False;Tarte au sucre;48 pies;0;29;49.3000;17;0
64+
63;2;False;Vegie-spread;15 - 625 g jars;5;7;43.9000;24;0
65+
64;5;False;Wimmers gute Semmelknödel;20 bags x 4 pieces;30;12;33.2500;22;80
66+
65;2;False;Louisiana Fiery Hot Pepper Sauce;32 - 8 oz bottles;0;2;21.0500;76;0
67+
66;2;False;Louisiana Hot Spiced Okra;24 - 8 oz jars;20;2;17.0000;4;100
68+
67;1;False;Laughing Lumberjack Lager;24 - 12 oz bottles;10;16;14.0000;52;0
69+
68;3;False;Scottish Longbreads;10 boxes x 8 pieces;15;8;12.5000;6;10
70+
69;4;False;Gudbrandsdalsost;10 kg pkg.;15;15;36.0000;26;0
71+
70;1;False;Outback Lager;24 - 355 ml bottles;30;7;15.0000;15;10
72+
71;4;False;Flotemysost;10 - 500 g pkgs.;0;15;21.5000;26;0
73+
72;4;False;Mozzarella di Giovanni;24 - 200 g pkgs.;0;14;34.8000;14;0
74+
73;8;False;Röd Kaviar;24 - 150 g jars;5;17;15.0000;101;0
75+
74;7;False;Longlife Tofu;5 kg pkg.;5;4;10.0000;4;20
76+
75;1;False;Rhönbräu Klosterbier;24 - 0.5 l bottles;25;12;7.7500;125;0
77+
76;1;False;Lakkalikööri;500 ml;20;23;18.0000;57;0
78+
77;2;False;Original Frankfurter grüne Soße;12 boxes;15;12;13.0000;32;0

cap-service/db/src/.hdiconfig

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"file_suffixes": {
3+
"csv": {
4+
"plugin_name": "com.sap.hana.di.tabledata.source"
5+
},
6+
"hdbafllangprocedure": {
7+
"plugin_name": "com.sap.hana.di.afllangprocedure"
8+
},
9+
"hdbanalyticprivilege": {
10+
"plugin_name": "com.sap.hana.di.analyticprivilege"
11+
},
12+
"hdbcalculationview": {
13+
"plugin_name": "com.sap.hana.di.calculationview"
14+
},
15+
"hdbcollection": {
16+
"plugin_name": "com.sap.hana.di.collection"
17+
},
18+
"hdbconstraint": {
19+
"plugin_name": "com.sap.hana.di.constraint"
20+
},
21+
"hdbdropcreatetable": {
22+
"plugin_name": "com.sap.hana.di.dropcreatetable"
23+
},
24+
"hdbflowgraph": {
25+
"plugin_name": "com.sap.hana.di.flowgraph"
26+
},
27+
"hdbfunction": {
28+
"plugin_name": "com.sap.hana.di.function"
29+
},
30+
"hdbgraphworkspace": {
31+
"plugin_name": "com.sap.hana.di.graphworkspace"
32+
},
33+
"hdbhadoopmrjob": {
34+
"plugin_name": "com.sap.hana.di.virtualfunctionpackage.hadoop"
35+
},
36+
"hdbindex": {
37+
"plugin_name": "com.sap.hana.di.index"
38+
},
39+
"hdblibrary": {
40+
"plugin_name": "com.sap.hana.di.library"
41+
},
42+
"hdbmigrationtable": {
43+
"plugin_name": "com.sap.hana.di.table.migration"
44+
},
45+
"hdbprocedure": {
46+
"plugin_name": "com.sap.hana.di.procedure"
47+
},
48+
"hdbprojectionview": {
49+
"plugin_name": "com.sap.hana.di.projectionview"
50+
},
51+
"hdbprojectionviewconfig": {
52+
"plugin_name": "com.sap.hana.di.projectionview.config"
53+
},
54+
"hdbreptask": {
55+
"plugin_name": "com.sap.hana.di.reptask"
56+
},
57+
"hdbresultcache": {
58+
"plugin_name": "com.sap.hana.di.resultcache"
59+
},
60+
"hdbrole": {
61+
"plugin_name": "com.sap.hana.di.role"
62+
},
63+
"hdbroleconfig": {
64+
"plugin_name": "com.sap.hana.di.role.config"
65+
},
66+
"hdbsearchruleset": {
67+
"plugin_name": "com.sap.hana.di.searchruleset"
68+
},
69+
"hdbsequence": {
70+
"plugin_name": "com.sap.hana.di.sequence"
71+
},
72+
"hdbstatistics": {
73+
"plugin_name": "com.sap.hana.di.statistics"
74+
},
75+
"hdbstructuredprivilege": {
76+
"plugin_name": "com.sap.hana.di.structuredprivilege"
77+
},
78+
"hdbsynonym": {
79+
"plugin_name": "com.sap.hana.di.synonym"
80+
},
81+
"hdbsynonymconfig": {
82+
"plugin_name": "com.sap.hana.di.synonym.config"
83+
},
84+
"hdbsystemversioning": {
85+
"plugin_name": "com.sap.hana.di.systemversioning"
86+
},
87+
"hdbtable": {
88+
"plugin_name": "com.sap.hana.di.table"
89+
},
90+
"hdbtabledata": {
91+
"plugin_name": "com.sap.hana.di.tabledata"
92+
},
93+
"hdbtabletype": {
94+
"plugin_name": "com.sap.hana.di.tabletype"
95+
},
96+
"hdbtrigger": {
97+
"plugin_name": "com.sap.hana.di.trigger"
98+
},
99+
"hdbview": {
100+
"plugin_name": "com.sap.hana.di.view"
101+
},
102+
"hdbvirtualfunction": {
103+
"plugin_name": "com.sap.hana.di.virtualfunction"
104+
},
105+
"hdbvirtualfunctionconfig": {
106+
"plugin_name": "com.sap.hana.di.virtualfunction.config"
107+
},
108+
"hdbvirtualpackagehadoop": {
109+
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
110+
},
111+
"hdbvirtualpackagesparksql": {
112+
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
113+
},
114+
"hdbvirtualprocedure": {
115+
"plugin_name": "com.sap.hana.di.virtualprocedure"
116+
},
117+
"hdbvirtualprocedureconfig": {
118+
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
119+
},
120+
"hdbvirtualtable": {
121+
"plugin_name": "com.sap.hana.di.virtualtable"
122+
},
123+
"hdbvirtualtableconfig": {
124+
"plugin_name": "com.sap.hana.di.virtualtable.config"
125+
},
126+
"properties": {
127+
"plugin_name": "com.sap.hana.di.tabledata.properties"
128+
},
129+
"tags": {
130+
"plugin_name": "com.sap.hana.di.tabledata.properties"
131+
},
132+
"txt": {
133+
"plugin_name": "com.sap.hana.di.copyonly"
134+
}
135+
}
136+
}

cap-service/mta.yaml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## Generated mta.yaml based on template version 0.4.0
2+
## appName = cap-service
3+
## language=nodejs; multitenant=false
4+
## approuter=
5+
_schema-version: "3.1"
6+
ID: cap-service
7+
version: 1.0.0
8+
description: "A simple CAP project."
9+
parameters:
10+
enable-parallel-deployments: true
11+
12+
build-parameters:
13+
before-all:
14+
- builder: custom
15+
commands:
16+
- npm install --production
17+
- npx -p @sap/cds-dk cds build --production
18+
19+
modules:
20+
# --------------------- SERVER MODULE ------------------------
21+
- name: cap-service-srv
22+
# ------------------------------------------------------------
23+
type: nodejs
24+
path: gen/srv
25+
build-parameters:
26+
ignore: ["default-env.json", "node_modules/"]
27+
parameters:
28+
buildpack: nodejs_buildpack
29+
memory: 256M
30+
disk-quota: 1GB
31+
requires:
32+
# Resources extracted from CAP configuration
33+
- name: cap-service-db
34+
- name: managed-fiori-uaa
35+
provides:
36+
- name: srv-api # required by consumers of CAP services (e.g. approuter)
37+
properties:
38+
srv-url: ${default-url}
39+
40+
# -------------------- SIDECAR MODULE ------------------------
41+
- name: cap-service-db-deployer
42+
# ------------------------------------------------------------
43+
type: hdb
44+
path: gen/db
45+
build-parameters:
46+
ignore: ["default-env.json", "node_modules/"]
47+
parameters:
48+
buildpack: nodejs_buildpack
49+
memory: 256M
50+
disk-quota: 256M
51+
requires:
52+
# 'hana' and 'xsuaa' resources extracted from CAP configuration
53+
- name: cap-service-db
54+
55+
resources:
56+
# services extracted from CAP configuration
57+
# 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
58+
# ------------------------------------------------------------
59+
- name: cap-service-db
60+
# ------------------------------------------------------------
61+
type: com.sap.xs.hdi-container
62+
parameters:
63+
service: hana # or 'hanatrial' on trial landscapes
64+
service-plan: hdi-shared
65+
properties:
66+
hdi-service-name: ${service-name}
67+
68+
# services extracted from CAP configuration
69+
- name: managed-fiori-uaa
70+
type: org.cloudfoundry.existing-service
71+
parameters:
72+
service-name: managed-fiori-uaa

0 commit comments

Comments
 (0)