Compare commits
3 Commits
CAA160-ini
...
CAA160-ex2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bf83b7e0b | ||
|
|
5eb730f088 | ||
|
|
7b3f8ac974 |
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