Compare commits
9 Commits
CAA160-ini
...
CAA160-ex3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
481a05e036 | ||
|
|
296ef8b43e | ||
|
|
7619bb43e8 | ||
|
|
113ff266a7 | ||
|
|
8e55780c5a | ||
|
|
654aebfdc7 | ||
|
|
e0ad269b49 | ||
|
|
b603a4bf48 | ||
|
|
7b3f8ac974 |
24
bookstore/.gitignore
vendored
Normal file
24
bookstore/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
gen/
|
||||
edmx/
|
||||
schema.sql
|
||||
*.db
|
||||
|
||||
bin/
|
||||
target/
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
|
||||
node/
|
||||
node_modules/
|
||||
|
||||
.mta/
|
||||
*.mtar
|
||||
|
||||
*.log*
|
||||
gc_history*
|
||||
hs_err*
|
||||
*.tgz
|
||||
|
||||
default-env.json
|
||||
connection.properties
|
||||
3
bookstore/.npmrc
Normal file
3
bookstore/.npmrc
Normal file
@@ -0,0 +1,3 @@
|
||||
package-lock=false
|
||||
registry = https://registry.npmjs.org
|
||||
@sap:registry = https://npm.sap.com
|
||||
5
bookstore/db/data/sap.capire.bookstore-Authors.csv
Normal file
5
bookstore/db/data/sap.capire.bookstore-Authors.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
ID;firstname;lastname
|
||||
6061f01b-7fa6-43c3-a6d7-12adb9d25198;Emily;Brontë
|
||||
2db38772-235e-432c-92a0-ce09ca340728;Charlotte;Brontë
|
||||
286ae4b1-b845-4af8-9827-4eb04fe5f380;Edgar Allen;Poe
|
||||
cbfec09e-0ff4-4cfc-adf1-0a37500da750;Richard;Carpenter
|
||||
|
6
bookstore/db/data/sap.capire.bookstore-Books.csv
Normal file
6
bookstore/db/data/sap.capire.bookstore-Books.csv
Normal file
@@ -0,0 +1,6 @@
|
||||
ID;title;descr;author_ID;stock;price;currency_code;category_ID;createdAt
|
||||
abed2f7a-c50e-4bc5-89fd-9a00a54b4b16;Wuthering Heights;"Wuthering Heights, Emily Brontë's only novel, was published in 1847 under the pseudonym ""Ellis Bell"". It was written between October 1845 and June 1846. Wuthering Heights and Anne Brontë's Agnes Grey were accepted by publisher Thomas Newby before the success of their sister Charlotte's novel Jane Eyre. After Emily's death, Charlotte edited the manuscript of Wuthering Heights and arranged for the edited version to be published as a posthumous second edition in 1850.";6061f01b-7fa6-43c3-a6d7-12adb9d25198;12;11.11;GBP;9;2019-09-20 10:10:10.000
|
||||
6869961b-c533-42b7-9d60-30fae4f46ab6;Jane Eyre;"Jane Eyre /ɛər/ (originally published as Jane Eyre: An Autobiography) is a novel by English writer Charlotte Brontë, published under the pen name ""Currer Bell"", on 16 October 1847, by Smith, Elder & Co. of London. The first American edition was published the following year by Harper & Brothers of New York. Primarily a bildungsroman, Jane Eyre follows the experiences of its eponymous heroine, including her growth to adulthood and her love for Mr. Rochester, the brooding master of Thornfield Hall. The novel revolutionised prose fiction in that the focus on Jane's moral and spiritual development is told through an intimate, first-person narrative, where actions and events are coloured by a psychological intensity. The book contains elements of social criticism, with a strong sense of Christian morality at its core and is considered by many to be ahead of its time because of Jane's individualistic character and how the novel approaches the topics of class, sexuality, religion and feminism.";2db38772-235e-432c-92a0-ce09ca340728;11;12.34;GBP;10;2019-09-20 10:10:10.000
|
||||
fd0c5fda-8811-4e20-bcff-3a776abc290a;The Raven;"“The Raven"" is a narrative poem by American writer Edgar Allan Poe. First published in January 1845, the poem is often noted for its musicality, stylized language, and supernatural atmosphere. It tells of a talking raven's mysterious visit to a distraught lover, tracing the man's slow fall into madness. The lover, often identified as being a student, is lamenting the loss of his love, Lenore. Sitting on a bust of Pallas, the raven seems to further distress the protagonist with its constant repetition of the word ""Nevermore"". The poem makes use of folk, mythological, religious, and classical references.";286ae4b1-b845-4af8-9827-4eb04fe5f380;333;13.13;USD;1;2019-09-20 10:10:10.000
|
||||
b7bca6dd-0497-465e-9a5a-56f244174c8c;Eleonora;"""Eleonora"" is a short story by Edgar Allan Poe, first published in 1842 in Philadelphia in the literary annual The Gift. It is often regarded as somewhat autobiographical and has a relatively ""happy"" ending.";286ae4b1-b845-4af8-9827-4eb04fe5f380;555;14.14;USD;5;2019-09-20 10:10:10.000
|
||||
5e69a718-d86b-4461-8953-0edadcd87960;Catweazle;Catweazle is a British fantasy television series, starring Geoffrey Bayldon in the title role, and created by Richard Carpenter for London Weekend Television. The first series, produced and directed by Quentin Lawrence, was screened in the UK on ITV in 1970. The second series, directed by David Reid and David Lane, was shown in 1971. Each series had thirteen episodes, most but not all written by Carpenter, who also published two books based on the scripts.;cbfec09e-0ff4-4cfc-adf1-0a37500da750;22;15.15;EUR;3;2019-09-20 10:10:10.000
|
||||
|
7
bookstore/db/data/sap.capire.bookstore-Books_texts.csv
Normal file
7
bookstore/db/data/sap.capire.bookstore-Books_texts.csv
Normal file
@@ -0,0 +1,7 @@
|
||||
ID;locale;title;descr
|
||||
abed2f7a-c50e-4bc5-89fd-9a00a54b4b16;de;Sturmhöhe;Sturmhöhe (Originaltitel: Wuthering Heights) ist der einzige Roman der englischen Schriftstellerin Emily Brontë (1818–1848). Der 1847 unter dem Pseudonym Ellis Bell veröffentlichte Roman wurde vom viktorianischen Publikum weitgehend abgelehnt, heute gilt er als ein Klassiker der britischen Romanliteratur des 19. Jahrhunderts.
|
||||
abed2f7a-c50e-4bc5-89fd-9a00a54b4b16;es;Cumbres Borrascosas;Cumbres Borrascosas (Título original: Wuthering Heights) es la única novela de Emily Brontë (1818–1848). Fue publicada por primera vez en 1847 bajo el seudónimo de Ellis Bell. Aunque ahora se considera un clásico de la literatura inglesa, el recibimiento inicial de Cumbres Borrascosas fue tibio en el mejor de los casos.
|
||||
6869961b-c533-42b7-9d60-30fae4f46ab6;de;Jane Eyre;Jane Eyre. Eine Autobiographie (Originaltitel: Jane Eyre. An Autobiography), erstmals erschienen im Jahr 1847 unter dem Pseudonym Currer Bell, ist der erste veröffentlichte Roman der britischen Autorin Charlotte Brontë und ein Klassiker der viktorianischen Romanliteratur des 19. Jahrhunderts. Der Roman erzählt in Form einer Ich-Erzählung die Lebensgeschichte von Jane Eyre (ausgesprochen /ˌdʒeɪn ˈɛə/), die nach einer schweren Kindheit eine Stelle als Gouvernante annimmt und sich in ihren Arbeitgeber verliebt, jedoch immer wieder um ihre Freiheit und Selbstbestimmung kämpfen muss. Als klein, dünn, blass, stets schlicht dunkel gekleidet und mit strengem Mittelscheitel beschrieben, gilt die Heldin des Romans Jane Eyre nicht zuletzt aufgrund der Kino- und Fernsehversionen der melodramatischen Romanvorlage als die bekannteste englische Gouvernante der Literaturgeschichte
|
||||
6869961b-c533-42b7-9d60-30fae4f46ab6;es;Jane Eyre;Jane Eyre. Una autobiografía (Título original: Jane Eyre. An Autobiography), se publicó por primera vez en 1847 bajo el pseudónimo de Currer Bell. Es la primera novela publicada por la escritora británica Charlotte Brontë y es considerada un clásico de la literatura inglesa. La novela es narrada por Jane Eyre, contada en primera persona, y cuenta su histora de vida. Luego de una infancia dificil, a los 18 años comienza a trabajar como institutriz en Thornfield Hall y se enamora de su empleador. Durante su vida, Jane lucha por su libertad e independencia. Pequeña, delgada, pálida y vestida siempre de negro, la heroína Jane Eyre se transformó, gracias al cine y televisión, en uno de los personajes mas famosos de la literatura.
|
||||
b7bca6dd-0497-465e-9a5a-56f244174c8c;de;Eleonora;“Eleonora” ist eine Erzählung von Edgar Allan Poe. Sie wurde 1842 erstveröffentlicht.
|
||||
b7bca6dd-0497-465e-9a5a-56f244174c8c;es;Eleonora;“Eleonora” es un cuento de Edgar Allan Poe. Se publicó por primera vez en 1842. Es considerado por algunos como un cuento autobiográfico y tiene un final relativamente feliz.
|
||||
|
11
bookstore/db/data/sap.capire.products-Categories.csv
Normal file
11
bookstore/db/data/sap.capire.products-Categories.csv
Normal file
@@ -0,0 +1,11 @@
|
||||
ID;parent_ID;name
|
||||
1;;Poetry
|
||||
2;;Biography
|
||||
3;;Fantasy
|
||||
4;;Science Fiction
|
||||
5;;Romance
|
||||
6;;Mystery
|
||||
7;;Thriller
|
||||
8;;Dystopia
|
||||
9;;Tragedy
|
||||
10;;Novel
|
||||
|
30
bookstore/db/schema.cds
Normal file
30
bookstore/db/schema.cds
Normal file
@@ -0,0 +1,30 @@
|
||||
namespace sap.capire.bookstore;
|
||||
|
||||
using { Currency, cuid, managed } from '@sap/cds/common';
|
||||
using { sap.capire.products.Products } from '@sap/capire-products';
|
||||
|
||||
entity Books as projection on Products; extend Products with {
|
||||
// Note: we map Books to Products to allow reusing AdminService as is
|
||||
author : Association to Authors;
|
||||
}
|
||||
|
||||
entity Authors : cuid {
|
||||
firstname : String(111);
|
||||
lastname : String(111);
|
||||
books : Association to many Books on books.author = $self;
|
||||
}
|
||||
|
||||
@Capabilities.Updatable: false
|
||||
entity Orders : cuid, managed {
|
||||
items : Composition of many OrderItems on items.parent = $self;
|
||||
total : Decimal(9,2) @readonly;
|
||||
currency : Currency;
|
||||
}
|
||||
|
||||
@Capabilities.Updatable: false
|
||||
entity OrderItems : cuid {
|
||||
parent : Association to Orders not null;
|
||||
book_ID : UUID;
|
||||
amount : Integer;
|
||||
netAmount : Decimal(9,2) @readonly;
|
||||
}
|
||||
42
bookstore/package.json
Normal file
42
bookstore/package.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "bookstore",
|
||||
"version": "1.0.0",
|
||||
"description": "Generated by cds-services-archetype",
|
||||
"license": "ISC",
|
||||
"repository": "<Add your repository here>",
|
||||
"scripts": {
|
||||
"build": "cds build/all --clean",
|
||||
"schema": "cds compile srv --to sql > srv/src/main/resources/schema.sql",
|
||||
"deploy": "cds deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": "3.21.2",
|
||||
"@sap/capire-products": "file:sap-capire-products-1.0.0.tgz"
|
||||
},
|
||||
"devDependencies": {
|
||||
"sqlite3": "^4.1.1"
|
||||
},
|
||||
"cds": {
|
||||
"build": {
|
||||
"target": "."
|
||||
},
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "sqlite",
|
||||
"model": [
|
||||
"db",
|
||||
"srv"
|
||||
],
|
||||
"credentials": {
|
||||
"database": "sqlite.db"
|
||||
},
|
||||
"[production]": {
|
||||
"kind": "hana"
|
||||
}
|
||||
}
|
||||
},
|
||||
"odata": {
|
||||
"version": "v4"
|
||||
}
|
||||
}
|
||||
}
|
||||
136
bookstore/pom.xml
Normal file
136
bookstore/pom.xml
Normal file
@@ -0,0 +1,136 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.sap.teched.cap</groupId>
|
||||
<artifactId>bookstore-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>bookstore parent</name>
|
||||
|
||||
<properties>
|
||||
<!-- OUR VERSION -->
|
||||
<revision>1.0-SNAPSHOT</revision>
|
||||
|
||||
<!-- DEPENDENCIES VERSION -->
|
||||
<jdk.version>1.8</jdk.version>
|
||||
<cds.services.version>1.2.0</cds.services.version>
|
||||
<cds4j.version>1.6.0</cds4j.version>
|
||||
<spring.boot.version>2.2.3.RELEASE</spring.boot.version>
|
||||
|
||||
<node.version>v10.4.1</node.version>
|
||||
<node.url>https://nodejs.org/dist/</node.url>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>srv</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- CDS SERVICES -->
|
||||
<dependency>
|
||||
<groupId>com.sap.cds</groupId>
|
||||
<artifactId>cds-services-bom</artifactId>
|
||||
<version>${cds.services.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- SPRING BOOT -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!-- STEPS TO GENERATE CDS ARTIFACTS -->
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install-node-and-npm</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>install-node-and-npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<downloadRoot>${node.url}</downloadRoot>
|
||||
<nodeVersion>${node.version}</nodeVersion>
|
||||
<npmInheritsProxyConfigFromMaven>true</npmInheritsProxyConfigFromMaven>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>npm install</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>install</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>cds build</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>run build</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>cds schema</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>run schema</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<!-- JAVA VERSION -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>${jdk.version}</source>
|
||||
<target>${jdk.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- MAKE SPRING BOOT PLUGIN RUNNABLE FROM ROOT -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
<fork>false</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
124
bookstore/srv/pom.xml
Normal file
124
bookstore/srv/pom.xml
Normal file
@@ -0,0 +1,124 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>bookstore-parent</artifactId>
|
||||
<groupId>com.sap.teched.cap</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>bookstore</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>bookstore</name>
|
||||
|
||||
<!-- ACTUAL DEPENDENCIES -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sap.cds</groupId>
|
||||
<artifactId>cds-starter-spring-boot-odata</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- SPRING BOOT PLUGIN -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- STEPS TO GENERATE CDS ARTIFACTS IMPORTED FROM PARENT -->
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<!-- CONFIGURE ADDITIONAL SOURCE DIRECTORY FOR GENERATED CLASSES -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/gen/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- GENERATE POJO INTERFACES -->
|
||||
<plugin>
|
||||
<groupId>com.sap.cds</groupId>
|
||||
<artifactId>cds4j-maven-plugin</artifactId>
|
||||
<version>${cds4j.version}</version>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}/src/gen</outputDirectory>
|
||||
<basePackage>cds.gen</basePackage>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>cds4j-generate-model</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<csnFile>${project.basedir}/src/main/resources/edmx/csn.json</csnFile>
|
||||
<excludes>
|
||||
<exclude>localized.*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- CLEAN GENERATED ARTIFACTS -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src/gen</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
<fileset>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>edmx/**</include>
|
||||
<include>schema.sql</include>
|
||||
</includes>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
19
bookstore/srv/services.cds
Normal file
19
bookstore/srv/services.cds
Normal file
@@ -0,0 +1,19 @@
|
||||
using { sap.capire.bookstore as db } from '../db/schema';
|
||||
|
||||
// Define Books Service
|
||||
service BooksService {
|
||||
@readonly entity Books as projection on db.Books { *, category as genre } excluding { category, createdBy, createdAt, modifiedBy, modifiedAt };
|
||||
@readonly entity Authors as projection on db.Authors;
|
||||
}
|
||||
|
||||
// Define Orders Service
|
||||
service OrdersService {
|
||||
entity Orders as projection on db.Orders;
|
||||
// OrderItems are auto exposed
|
||||
}
|
||||
|
||||
// Reuse Admin Service
|
||||
using { AdminService } from '@sap/capire-products';
|
||||
extend service AdminService with {
|
||||
entity Authors as projection on db.Authors;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sap.teched.cap.bookstore;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
7
bookstore/srv/src/main/resources/application.yaml
Normal file
7
bookstore/srv/src/main/resources/application.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
spring:
|
||||
profiles: default
|
||||
datasource:
|
||||
url: "jdbc:sqlite:sqlite.db"
|
||||
driver-class-name: org.sqlite.JDBC
|
||||
initialization-mode: never
|
||||
24
products-service/.gitignore
vendored
Normal file
24
products-service/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
gen/
|
||||
edmx/
|
||||
schema.sql
|
||||
*.db
|
||||
|
||||
bin/
|
||||
target/
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
|
||||
node/
|
||||
node_modules/
|
||||
|
||||
.mta/
|
||||
*.mtar
|
||||
|
||||
*.log*
|
||||
gc_history*
|
||||
hs_err*
|
||||
*.tgz
|
||||
|
||||
default-env.json
|
||||
connection.properties
|
||||
3
products-service/.npmrc
Normal file
3
products-service/.npmrc
Normal file
@@ -0,0 +1,3 @@
|
||||
package-lock=false
|
||||
registry = https://registry.npmjs.org
|
||||
@sap:registry = https://npm.sap.com
|
||||
18
products-service/db/schema.cds
Normal file
18
products-service/db/schema.cds
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace sap.capire.products;
|
||||
|
||||
using { Currency, cuid, managed, sap.common.CodeList } from '@sap/cds/common';
|
||||
|
||||
entity Products : cuid, managed {
|
||||
title : localized String(111);
|
||||
descr : localized String(1111);
|
||||
stock : Integer;
|
||||
price : Decimal(9,2);
|
||||
currency : Currency;
|
||||
category : Association to Categories;
|
||||
}
|
||||
|
||||
entity Categories : CodeList {
|
||||
key ID : Integer;
|
||||
parent : Association to Categories;
|
||||
children : Composition of many Categories on children.parent = $self;
|
||||
}
|
||||
2
products-service/index.cds
Normal file
2
products-service/index.cds
Normal file
@@ -0,0 +1,2 @@
|
||||
using from './db/schema';
|
||||
using from './srv/admin-service';
|
||||
38
products-service/package.json
Normal file
38
products-service/package.json
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "@sap/capire-products",
|
||||
"version": "1.0.0",
|
||||
"description": "A reuse package providing domain models and services to manage product catalogs.",
|
||||
"license": "ISC",
|
||||
"repository": "https://github.wdf.sap.corp/cap/samples",
|
||||
"scripts": {
|
||||
"build": "cds build/all --clean",
|
||||
"schema": "cds compile srv --to sql > srv/src/main/resources/schema.sql",
|
||||
"deploy": "cds deploy"
|
||||
},
|
||||
"dependencies": {
|
||||
"@sap/cds": "3.21.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"sqlite3": "^4.1.1"
|
||||
},
|
||||
"cds": {
|
||||
"build": {
|
||||
"target": "."
|
||||
},
|
||||
"requires": {
|
||||
"db": {
|
||||
"kind": "sqlite",
|
||||
"model": [
|
||||
"db",
|
||||
"srv"
|
||||
],
|
||||
"credentials": {
|
||||
"database": "sqlite.db"
|
||||
}
|
||||
}
|
||||
},
|
||||
"odata": {
|
||||
"version": "v4"
|
||||
}
|
||||
}
|
||||
}
|
||||
136
products-service/pom.xml
Normal file
136
products-service/pom.xml
Normal file
@@ -0,0 +1,136 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.sap.teched.cap</groupId>
|
||||
<artifactId>products-service-parent</artifactId>
|
||||
<version>${revision}</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>products-service parent</name>
|
||||
|
||||
<properties>
|
||||
<!-- OUR VERSION -->
|
||||
<revision>1.0-SNAPSHOT</revision>
|
||||
|
||||
<!-- DEPENDENCIES VERSION -->
|
||||
<jdk.version>1.8</jdk.version>
|
||||
<cds.services.version>1.2.0</cds.services.version>
|
||||
<cds4j.version>1.6.0</cds4j.version>
|
||||
<spring.boot.version>2.2.3.RELEASE</spring.boot.version>
|
||||
|
||||
<node.version>v10.4.1</node.version>
|
||||
<node.url>https://nodejs.org/dist/</node.url>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>srv</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- CDS SERVICES -->
|
||||
<dependency>
|
||||
<groupId>com.sap.cds</groupId>
|
||||
<artifactId>cds-services-bom</artifactId>
|
||||
<version>${cds.services.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- SPRING BOOT -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!-- STEPS TO GENERATE CDS ARTIFACTS -->
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install-node-and-npm</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>install-node-and-npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<downloadRoot>${node.url}</downloadRoot>
|
||||
<nodeVersion>${node.version}</nodeVersion>
|
||||
<npmInheritsProxyConfigFromMaven>true</npmInheritsProxyConfigFromMaven>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>npm install</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>install</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>cds build</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>run build</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
<id>cds schema</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>run schema</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<!-- JAVA VERSION -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>${jdk.version}</source>
|
||||
<target>${jdk.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- MAKE SPRING BOOT PLUGIN RUNNABLE FROM ROOT -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
<fork>false</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
6
products-service/srv/admin-service.cds
Normal file
6
products-service/srv/admin-service.cds
Normal file
@@ -0,0 +1,6 @@
|
||||
using { sap.capire.products as db } from '../db/schema';
|
||||
|
||||
service AdminService {
|
||||
entity Products as projection on db.Products;
|
||||
entity Categories as projection on db.Categories;
|
||||
}
|
||||
124
products-service/srv/pom.xml
Normal file
124
products-service/srv/pom.xml
Normal file
@@ -0,0 +1,124 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>products-service-parent</artifactId>
|
||||
<groupId>com.sap.teched.cap</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>products-service</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>products-service</name>
|
||||
|
||||
<!-- ACTUAL DEPENDENCIES -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sap.cds</groupId>
|
||||
<artifactId>cds-starter-spring-boot-odata</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- SPRING BOOT PLUGIN -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<configuration>
|
||||
<skip>false</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- STEPS TO GENERATE CDS ARTIFACTS IMPORTED FROM PARENT -->
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<!-- CONFIGURE ADDITIONAL SOURCE DIRECTORY FOR GENERATED CLASSES -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>src/gen/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- GENERATE POJO INTERFACES -->
|
||||
<plugin>
|
||||
<groupId>com.sap.cds</groupId>
|
||||
<artifactId>cds4j-maven-plugin</artifactId>
|
||||
<version>${cds4j.version}</version>
|
||||
<configuration>
|
||||
<outputDirectory>${project.basedir}/src/gen</outputDirectory>
|
||||
<basePackage>cds.gen</basePackage>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>cds4j-generate-model</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<csnFile>${project.basedir}/src/main/resources/edmx/csn.json</csnFile>
|
||||
<excludes>
|
||||
<exclude>localized.*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- CLEAN GENERATED ARTIFACTS -->
|
||||
<plugin>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>src/gen</directory>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
<fileset>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>edmx/**</include>
|
||||
<include>schema.sql</include>
|
||||
</includes>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.sap.teched.cap.productsservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
7
products-service/srv/src/main/resources/application.yaml
Normal file
7
products-service/srv/src/main/resources/application.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
spring:
|
||||
profiles: default
|
||||
datasource:
|
||||
url: "jdbc:sqlite:sqlite.db"
|
||||
driver-class-name: org.sqlite.JDBC
|
||||
initialization-mode: never
|
||||
Reference in New Issue
Block a user