CAA160 exercise 3 final state
This commit is contained in:
123
bookstore/srv/pom.xml
Normal file
123
bookstore/srv/pom.xml
Normal file
@@ -0,0 +1,123 @@
|
||||
<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>
|
||||
</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
|
||||
Reference in New Issue
Block a user