From e33a455154fba29100ce1ab816f0ce564928743b Mon Sep 17 00:00:00 2001 From: "Dzmitry_Tamashevich@epam.com" Date: Tue, 29 Sep 2020 16:35:55 +0300 Subject: [PATCH] creating cds model of chinook db --- certificates/certificates.db | Bin 0 -> 45056 bytes certificates/media-store/.cdsrc.json | 1 + certificates/media-store/.eslintrc | 24 +++++ certificates/media-store/.gitignore | 29 +++++++ .../media-store/.vscode/extensions.json | 20 +++++ certificates/media-store/.vscode/launch.json | 15 ++++ .../media-store/.vscode/settings.json | 7 ++ certificates/media-store/.vscode/tasks.json | 25 ++++++ certificates/media-store/README.md | 25 ++++++ certificates/media-store/package.json | 18 ++++ media-store/.cdsrc.json | 1 + media-store/.eslintrc | 24 +++++ media-store/.gitignore | 29 +++++++ media-store/.vscode/extensions.json | 20 +++++ media-store/.vscode/launch.json | 15 ++++ media-store/.vscode/settings.json | 7 ++ media-store/.vscode/tasks.json | 25 ++++++ media-store/README.md | 25 ++++++ media-store/db/schema.cds | 82 ++++++++++++++++++ media-store/package.json | 28 ++++++ media-store/srv/media-service.cds | 5 ++ 21 files changed, 425 insertions(+) create mode 100644 certificates/certificates.db create mode 100644 certificates/media-store/.cdsrc.json create mode 100644 certificates/media-store/.eslintrc create mode 100644 certificates/media-store/.gitignore create mode 100644 certificates/media-store/.vscode/extensions.json create mode 100644 certificates/media-store/.vscode/launch.json create mode 100644 certificates/media-store/.vscode/settings.json create mode 100644 certificates/media-store/.vscode/tasks.json create mode 100644 certificates/media-store/README.md create mode 100644 certificates/media-store/package.json create mode 100644 media-store/.cdsrc.json create mode 100644 media-store/.eslintrc create mode 100644 media-store/.gitignore create mode 100644 media-store/.vscode/extensions.json create mode 100644 media-store/.vscode/launch.json create mode 100644 media-store/.vscode/settings.json create mode 100644 media-store/.vscode/tasks.json create mode 100644 media-store/README.md create mode 100644 media-store/db/schema.cds create mode 100644 media-store/package.json create mode 100644 media-store/srv/media-service.cds diff --git a/certificates/certificates.db b/certificates/certificates.db new file mode 100644 index 0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Mq(O<>f%EpOtWRs<@lNZ%?)i~->8Ep|XsS*Uh zPJSqYOq2u_6hoY9<`_rka+pkrKYmhL=X3|2PDJSItvO=qb*@;28x#{1nCNiZu)}`+3f~{ zHHI51Cx(_Vn*cGt!o4xWzqkrbhfOk>!^1@Xb=-8Om4uXeV=pNgup(u?)j5PFQv`TT zs-M;9+h18^GUamO=}R<-NWZ7SA^X~SwxK|VV-T4G=F_naXE2RV*Lfq&m@YUrg(#<{ zbjPakX%KnRI_WxX^Zpdg!wy;q%^uxI2QUNj8qJ2Q43jMuqy0_CXdK&N%M9GdX6X`s zO;iiFcZ;Em6`TvZhNk(_HoJGPP}zFBP+61Ib$0JgmEEiD?&1;-v9r}uxwu~~l%XUe{+KsSC5Ti@nVSCR-{+`=>L(dvilrPM$VS1>c`|t_FT@)ytOl zs>Qd86}Nszt6H?!8`TVI9#}n5G4ICX*>>ro72{8}p;hDQnO-u+WDO(QtIw<)vMYJx zbXY}ATFz5d+GIMn|Cr&h0)5GGSIz;L0X<1InCErYON+XIGtXqt7~`U-CtVNk5tFtH zy~8MzMcd;KGt^Z;1Ap$q*su10oq<`Z~B zkMI9yn7>3)|6Tdp@?V#JpM1JlMwg4eegXZ)&k|(ND~?|90|cH=0=>w!7k&Tiq@Tfb zvDizdE_=qNTjNenW&i&f`(WjA7OhNgb@|8GEzm7kpTph4yGxh1C|&4nCV#9Q1Kr|t zv}5QeUt%&lJBg?1kTWr|)lWGYBh~%_%srJq#}u~gwtFy1;zL_@1>>>>>>> Add CDS Editor here as soon it is available of vscode marketplace!, + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "mechatroner.rainbow-csv", + "humao.rest-client", + "alexcvzz.vscode-sqlite", + "hbenl.vscode-mocha-test-adapter", + "sdras.night-owl" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [ + + ] +} diff --git a/certificates/media-store/.vscode/launch.json b/certificates/media-store/.vscode/launch.json new file mode 100644 index 00000000..3f308a6c --- /dev/null +++ b/certificates/media-store/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "command": "cds run --with-mocks --in-memory?", + "name": "cds run", + "request": "launch", + "type": "node-terminal", + "skipFiles": [ "/**" ] + } + ] +} diff --git a/certificates/media-store/.vscode/settings.json b/certificates/media-store/.vscode/settings.json new file mode 100644 index 00000000..9fefa082 --- /dev/null +++ b/certificates/media-store/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "files.exclude": { + "**/.gitignore": true, + "**/.git": true, + "**/.vscode": true + } +} diff --git a/certificates/media-store/.vscode/tasks.json b/certificates/media-store/.vscode/tasks.json new file mode 100644 index 00000000..622da99a --- /dev/null +++ b/certificates/media-store/.vscode/tasks.json @@ -0,0 +1,25 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "cds watch", + "command": "cds", + "args": ["watch"], + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "type": "shell", + "label": "cds run", + "command": "cds", + "args": ["run", "--with-mocks", "--in-memory?"], + "problemMatcher": [] + } + ] +} diff --git a/certificates/media-store/README.md b/certificates/media-store/README.md new file mode 100644 index 00000000..d1847423 --- /dev/null +++ b/certificates/media-store/README.md @@ -0,0 +1,25 @@ +# Getting Started + +Welcome to your new project. + +It contains these folders and files, following our recommended project layout: + +File or Folder | Purpose +---------|---------- +`app/` | content for UI frontends goes here +`db/` | your domain models and data go here +`srv/` | your service models and code go here +`package.json` | project metadata and configuration +`readme.md` | this getting started guide + + +## Next Steps + +- Open a new terminal and run `cds watch` +- (in VS Code simply choose _**Terminal** > Run Task > cds watch_) +- Start adding content, for example, a [db/schema.cds](db/schema.cds). + + +## Learn More + +Learn more at https://cap.cloud.sap/docs/get-started/. diff --git a/certificates/media-store/package.json b/certificates/media-store/package.json new file mode 100644 index 00000000..cf19c1f2 --- /dev/null +++ b/certificates/media-store/package.json @@ -0,0 +1,18 @@ +{ + "name": "media-store", + "version": "1.0.0", + "description": "A simple CAP project.", + "repository": "", + "license": "UNLICENSED", + "private": true, + "dependencies": { + "@sap/cds": "^4", + "express": "^4" + }, + "devDependencies": { + "sqlite3": "^5" + }, + "scripts": { + "start": "npx cds run" + } +} diff --git a/media-store/.cdsrc.json b/media-store/.cdsrc.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/media-store/.cdsrc.json @@ -0,0 +1 @@ +{} diff --git a/media-store/.eslintrc b/media-store/.eslintrc new file mode 100644 index 00000000..639d13a0 --- /dev/null +++ b/media-store/.eslintrc @@ -0,0 +1,24 @@ +{ + "extends": "eslint:recommended", + "env": { + "node": true, + "es6": true, + "jest": true + }, + "parserOptions": { + "ecmaVersion": 2017 + }, + "globals": { + "SELECT": true, + "INSERT": true, + "UPDATE": true, + "DELETE": true, + "CREATE": true, + "DROP": true, + "cds": true + }, + "rules": { + "no-console": "off", + "require-atomic-updates": "off" + } +} diff --git a/media-store/.gitignore b/media-store/.gitignore new file mode 100644 index 00000000..74ce3610 --- /dev/null +++ b/media-store/.gitignore @@ -0,0 +1,29 @@ +# CAP media-store +_out +*.db +connection.properties +default-*.json +gen/ +node_modules/ +target/ + +# Web IDE, App Studio +.che/ +.gen/ + +# MTA +*_mta_build_tmp +*.mtar +mta_archives/ + +# Other +.DS_Store +*.orig +*.log + +*.iml +*.flattened-pom.xml + +# IDEs +# .vscode +# .idea diff --git a/media-store/.vscode/extensions.json b/media-store/.vscode/extensions.json new file mode 100644 index 00000000..1daacbd8 --- /dev/null +++ b/media-store/.vscode/extensions.json @@ -0,0 +1,20 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + // >>>>>>>> Add CDS Editor here as soon it is available of vscode marketplace!, + "dbaeumer.vscode-eslint", + "esbenp.prettier-vscode", + "mechatroner.rainbow-csv", + "humao.rest-client", + "alexcvzz.vscode-sqlite", + "hbenl.vscode-mocha-test-adapter", + "sdras.night-owl" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [ + + ] +} diff --git a/media-store/.vscode/launch.json b/media-store/.vscode/launch.json new file mode 100644 index 00000000..3f308a6c --- /dev/null +++ b/media-store/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "command": "cds run --with-mocks --in-memory?", + "name": "cds run", + "request": "launch", + "type": "node-terminal", + "skipFiles": [ "/**" ] + } + ] +} diff --git a/media-store/.vscode/settings.json b/media-store/.vscode/settings.json new file mode 100644 index 00000000..9fefa082 --- /dev/null +++ b/media-store/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "files.exclude": { + "**/.gitignore": true, + "**/.git": true, + "**/.vscode": true + } +} diff --git a/media-store/.vscode/tasks.json b/media-store/.vscode/tasks.json new file mode 100644 index 00000000..622da99a --- /dev/null +++ b/media-store/.vscode/tasks.json @@ -0,0 +1,25 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "cds watch", + "command": "cds", + "args": ["watch"], + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "type": "shell", + "label": "cds run", + "command": "cds", + "args": ["run", "--with-mocks", "--in-memory?"], + "problemMatcher": [] + } + ] +} diff --git a/media-store/README.md b/media-store/README.md new file mode 100644 index 00000000..d1847423 --- /dev/null +++ b/media-store/README.md @@ -0,0 +1,25 @@ +# Getting Started + +Welcome to your new project. + +It contains these folders and files, following our recommended project layout: + +File or Folder | Purpose +---------|---------- +`app/` | content for UI frontends goes here +`db/` | your domain models and data go here +`srv/` | your service models and code go here +`package.json` | project metadata and configuration +`readme.md` | this getting started guide + + +## Next Steps + +- Open a new terminal and run `cds watch` +- (in VS Code simply choose _**Terminal** > Run Task > cds watch_) +- Start adding content, for example, a [db/schema.cds](db/schema.cds). + + +## Learn More + +Learn more at https://cap.cloud.sap/docs/get-started/. diff --git a/media-store/db/schema.cds b/media-store/db/schema.cds new file mode 100644 index 00000000..614d6e3f --- /dev/null +++ b/media-store/db/schema.cds @@ -0,0 +1,82 @@ +namespace sap.capire.media.store; + +aspect NamedEntityAspect { + key ID : Integer; + name : String(120); +} + +aspect ContactInfoAspect { + firstName : String(40); + lastName : String(20); + city : String(40); + state : String(40); + adress : String(70); + country : String(40); + postalCode : String(10); + phone : String(24); + fax : String(24); + email : String(60); +} + +entity MediaTypes : NamedEntityAspect {} +entity Genres : NamedEntityAspect {} +entity Playlists : NamedEntityAspect {} + +entity PlaylistTrack { + key playlist : Association to Playlists; + key track : Association to Tracks; +} + +entity Artists : NamedEntityAspect {} + +entity Albums { + key ID : Integer; + title : String(120); + artist : Association to Artists; +} + +entity Employees : ContactInfoAspect { + key ID : Integer; + reportsTo : Association to Employees; + title : String(20); + birthDate : DateTime; + hireDate : DateTime; +} + +entity Customers : ContactInfoAspect { + key ID : Integer; + company : String(80); + supportRepId : Association to Employees; +} + +entity Invoices { + key ID : Integer; + customer : Association to Customers; + invoiceDate : DateTime; + billingAdress : String(70); + billingCity : String(40); + billingState : String(40); + bilingCountry : String(40); + billingPostalCode : String(40); + total : Decimal(10, 2); +} + +entity InvoiceItems { + key ID : Integer; + invoice : Association to Invoices; + track : Association to Tracks; + unitPrice : Decimal(10, 2); + quantity : Integer; +} + +entity Tracks { + key ID : Integer; + name : String(200); + album : Association to Albums; + mediaType : Association to MediaTypes; + genre : Association to Genres; + composer : String(220); + milliseconds : Integer; + bytes : Integer; + unitPrice : Decimal(10, 2); +} diff --git a/media-store/package.json b/media-store/package.json new file mode 100644 index 00000000..a36c641d --- /dev/null +++ b/media-store/package.json @@ -0,0 +1,28 @@ +{ + "name": "media-store", + "version": "1.0.0", + "description": "A simple CAP project.", + "repository": "", + "license": "UNLICENSED", + "private": true, + "dependencies": { + "@sap/cds": "^4", + "express": "^4" + }, + "devDependencies": { + "sqlite3": "^5" + }, + "scripts": { + "start": "npx cds run" + }, + "cds": { + "requires": { + "db": { + "kind": "sqlite", + "credentials": { + "database": "mychinook.db" + } + } + } + } +} \ No newline at end of file diff --git a/media-store/srv/media-service.cds b/media-store/srv/media-service.cds new file mode 100644 index 00000000..56865f9f --- /dev/null +++ b/media-store/srv/media-service.cds @@ -0,0 +1,5 @@ +using {sap.capire.media.store as my} from '../db/schema'; + +service MediaService { + entity Employees as projection on my.Employees; +}