Compare commits
10 Commits
openSAP-we
...
CAA265-nod
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
926a3eaa9a | ||
|
|
de871e11cb | ||
|
|
b5684841e6 | ||
|
|
00f118deed | ||
|
|
fb8f6acac7 | ||
|
|
1e28cb217f | ||
|
|
2fc2cea260 | ||
|
|
bfaaf36e14 | ||
|
|
33b24c8d96 | ||
|
|
387b25b1bf |
1
.npmrc
1
.npmrc
@@ -1 +1,2 @@
|
|||||||
|
@sap:registry=https://npm.sap.com
|
||||||
package-lock=false
|
package-lock=false
|
||||||
|
|||||||
59
README.md
59
README.md
@@ -1,58 +1,3 @@
|
|||||||
# cloud-cap-samples
|
# Final state of exercise 4 for CAA265 - Rapid Service Development with SAP Cloud Application Programming Model
|
||||||
|
|
||||||
This is a monorepository for sample projects on [SAP Cloud Application Programming Model](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/00823f91779d4d42aa29a498e0535cdf.html?q=cloud%20application%20programming%20model).
|
|
||||||
|
|
||||||
## Description
|
|
||||||
|
|
||||||
This repository provides a list of samples and reusable packages created based on SAP Cloud Application Programming Model.
|
|
||||||
The SAP Cloud Application Programming Model enables you to quickly create business applications by allowing you to focus on your domain logic. It offers a consistent end-to-end programming model that includes languages, libraries and APIs tailored for full-stack development on SAP Cloud Platform.
|
|
||||||
|
|
||||||
The samples provided can be run in a local setup on SQLite Database.
|
|
||||||
|
|
||||||
#### Samples:
|
|
||||||
* [bookstore](./packages/bookstore) - A variant of the bookshop application, built in a modular fashion on top of products-service and common reuse packages.
|
|
||||||
* [products-service](./packages/products-service) - A reuse package providing domain models and services to manage product catalogs.
|
|
||||||
|
|
||||||
## Requirements
|
|
||||||
* [Node.js](https://nodejs.org/en/) v8 or higher
|
|
||||||
* [Git](https://git-scm.com)
|
|
||||||
* [SQLite DB](https://www.sqlite.org/download.html) (Windows only; pre-installed on Mac/Linux)
|
|
||||||
|
|
||||||
#### Optional (if you want to import the code into an editor)
|
|
||||||
* [VS Code](https://code.visualstudio.com)
|
|
||||||
* [Add CDS extension to VS](https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/be944d6d51f343f6b3f53c29c44ff00a.html)
|
|
||||||
|
|
||||||
## Download and Installation
|
|
||||||
|
|
||||||
#### Clone and build the application
|
|
||||||
`git clone https://github.com/SAP-samples/cloud-cap-samples.git`
|
|
||||||
|
|
||||||
`cd samples`
|
|
||||||
|
|
||||||
`npm install`
|
|
||||||
|
|
||||||
#### Run the samples
|
|
||||||
|
|
||||||
`npm run <sample name>`
|
|
||||||
|
|
||||||
|
|
||||||
## Limitations
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
## Known Issues
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
## How to obtain support
|
|
||||||
|
|
||||||
In case you find a bug, or you need additional support, please open an issue [here](https://github.wdf.sap.corp/staging-for-SAP-samples-public/cloud-cap-samples/issues) in GitHub.
|
|
||||||
|
|
||||||
## To-Do (upcoming changes)
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under SAP Sample Code License Agreement, except as noted otherwise in the [LICENSE](/LICENSE) file.
|
|
||||||
|
|
||||||
|
**DO NOT MERGE IN MASTER**
|
||||||
|
|||||||
3
packages/.cdsrc.json
Normal file
3
packages/.cdsrc.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"cds_version": "^3.17.4"
|
||||||
|
}
|
||||||
12
packages/bookstore/app/bookList/webapp/Component.js
Normal file
12
packages/bookstore/app/bookList/webapp/Component.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/* global hasher */
|
||||||
|
sap.ui.define([
|
||||||
|
"sap/fe/AppComponent"
|
||||||
|
], function (AppComponent) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
return AppComponent.extend("ns.bookList.Component", {
|
||||||
|
metadata: {
|
||||||
|
"manifest": "json"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
118
packages/bookstore/app/bookList/webapp/WEB-INF/web.xml
Normal file
118
packages/bookstore/app/bookList/webapp/WEB-INF/web.xml
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||||
|
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||||
|
version="2.5"
|
||||||
|
xmlns="http://java.sun.com/xml/ns/javaee">
|
||||||
|
|
||||||
|
<display-name>OData v4</display-name>
|
||||||
|
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
<!-- UI5 resource servlet used to handle application resources -->
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<display-name>ResourceServlet</display-name>
|
||||||
|
<servlet-name>ResourceServlet</servlet-name>
|
||||||
|
<servlet-class>com.sap.ui5.resource.ResourceServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>ResourceServlet</servlet-name>
|
||||||
|
<url-pattern>/resources/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>ResourceServlet</servlet-name>
|
||||||
|
<url-pattern>/test-resources/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<!-- enable CORS -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>com.sap.ui5.resource.ACCEPTED_ORIGINS</param-name>
|
||||||
|
<param-value>*</param-value>
|
||||||
|
</context-param>
|
||||||
|
|
||||||
|
<!-- BEGIN: DEV MODE -->
|
||||||
|
<!-- DEV MODE switched off by default and can be switched on during development -->
|
||||||
|
<!-- but has to be switched off for productive use on a Java server! -->
|
||||||
|
<context-param>
|
||||||
|
<param-name>com.sap.ui5.resource.DEV_MODE</param-name>
|
||||||
|
<param-value>true</param-value>
|
||||||
|
</context-param>
|
||||||
|
<!-- END: DEV MODE -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
<!-- Cache Control Filter to prevent caching of any resource -->
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<display-name>CacheControlFilter</display-name>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<filter-class>com.sap.ui5.resource.CacheControlFilter</filter-class>
|
||||||
|
</filter>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.html</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.js</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.css</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.json</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.xml</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.gif</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.png</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.jpg</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.properties</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>CacheControlFilter</filter-name>
|
||||||
|
<url-pattern>*.tmpl</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
<!-- UI5 proxy servlet -->
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>SimpleProxyServlet</servlet-name>
|
||||||
|
<servlet-class>com.sap.ui5.proxy.SimpleProxyServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>SimpleProxyServlet</servlet-name>
|
||||||
|
<url-pattern>/proxy/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
<!-- Welcome file list -->
|
||||||
|
<!-- ============================================================== -->
|
||||||
|
|
||||||
|
<welcome-file-list>
|
||||||
|
<welcome-file>test.html</welcome-file>
|
||||||
|
</welcome-file-list>
|
||||||
|
|
||||||
|
|
||||||
|
</web-app>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# This is the resource bundle for bookList#Texts for manifest.json
|
||||||
|
|
||||||
|
#XTIT: Application name
|
||||||
|
appTitle=bookList
|
||||||
|
|
||||||
|
#YDES: Application description
|
||||||
|
appDescription=bookList
|
||||||
39
packages/bookstore/app/bookList/webapp/index.html
Normal file
39
packages/bookstore/app/bookList/webapp/index.html
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>{{appTitle}}</title>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window["sap-ushell-config"] = {
|
||||||
|
defaultRenderer: "fiori2",
|
||||||
|
applications: {
|
||||||
|
"fe-lrop-v4": {
|
||||||
|
title: "bookList",
|
||||||
|
description: "bookList",
|
||||||
|
additionalInformation: "SAPUI5.Component=ns.bookList",
|
||||||
|
applicationType : "URL",
|
||||||
|
url: "./",
|
||||||
|
navigationMode: "embedded"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="https://sapui5.hana.ondemand.com/test-resources/sap/ushell/bootstrap/sandbox.js"></script>
|
||||||
|
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
|
||||||
|
data-sap-ui-libs="sap.m, sap.ushell"
|
||||||
|
data-sap-ui-compatVersion="edge"
|
||||||
|
data-sap-ui-theme="sap_belize"
|
||||||
|
data-sap-ui-frameOptions="allow"
|
||||||
|
></script>
|
||||||
|
<script>
|
||||||
|
sap.ui.getCore().attachInit(()=> sap.ushell.Container.createRenderer().placeAt("content"))
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body class="sapUiBody" id="content"></body>
|
||||||
|
</html>
|
||||||
134
packages/bookstore/app/bookList/webapp/manifest.json
Normal file
134
packages/bookstore/app/bookList/webapp/manifest.json
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"_version": "1.15.0",
|
||||||
|
"sap.app": {
|
||||||
|
"id": "ns.bookList",
|
||||||
|
"type": "application",
|
||||||
|
"i18n": "i18n/i18n.properties",
|
||||||
|
"applicationVersion": {
|
||||||
|
"version": "1.0"
|
||||||
|
},
|
||||||
|
"title": "{{appTitle}}",
|
||||||
|
"description": "{{appDescription}}",
|
||||||
|
"ach": "CA-UI5-FE",
|
||||||
|
"dataSources": {
|
||||||
|
"mainService": {
|
||||||
|
"uri": "catalog/",
|
||||||
|
"type": "OData",
|
||||||
|
"settings": {
|
||||||
|
"odataVersion": "4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"offline": false,
|
||||||
|
"resources": "resources.json",
|
||||||
|
"sourceTemplate": {
|
||||||
|
"id": "ui5template.fiorielements.v4.lrop",
|
||||||
|
"version": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.ui": {
|
||||||
|
"technology": "UI5",
|
||||||
|
"icons": {
|
||||||
|
"icon": "",
|
||||||
|
"favIcon": "",
|
||||||
|
"phone": "",
|
||||||
|
"phone@2": "",
|
||||||
|
"tablet": "",
|
||||||
|
"tablet@2": ""
|
||||||
|
},
|
||||||
|
"deviceTypes": {
|
||||||
|
"desktop": true,
|
||||||
|
"tablet": true,
|
||||||
|
"phone": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.ui5": {
|
||||||
|
"resources": {
|
||||||
|
"js": [],
|
||||||
|
"css": []
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"minUI5Version": "1.60.1",
|
||||||
|
"libs": {
|
||||||
|
"sap.fe": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"models": {
|
||||||
|
"i18n": {
|
||||||
|
"type": "sap.ui.model.resource.ResourceModel",
|
||||||
|
"uri": "i18n/i18n.properties"
|
||||||
|
},
|
||||||
|
"": {
|
||||||
|
"dataSource": "mainService",
|
||||||
|
"settings": {
|
||||||
|
"synchronizationMode": "None",
|
||||||
|
"operationMode": "Server",
|
||||||
|
"autoExpandSelect": true,
|
||||||
|
"earlyRequests": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"routing": {
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"pattern": "",
|
||||||
|
"name": "BooksList",
|
||||||
|
"target": "BooksList"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pattern": "Books({key})",
|
||||||
|
"name": "BooksObjectPage",
|
||||||
|
"target": "BooksObjectPage"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"targets": {
|
||||||
|
"BooksList": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "BooksList",
|
||||||
|
"name": "sap.fe.templates.ListReport",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet" : "Books",
|
||||||
|
"variantManagement": "Page",
|
||||||
|
"navigation" : {
|
||||||
|
"Books" : {
|
||||||
|
"detail" : {
|
||||||
|
"route" : "BooksObjectPage"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"BooksObjectPage": {
|
||||||
|
"type": "Component",
|
||||||
|
"id": "BooksObjectPage",
|
||||||
|
"name": "sap.fe.templates.ObjectPage",
|
||||||
|
"options": {
|
||||||
|
"settings" : {
|
||||||
|
"entitySet" : "Books"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contentDensities": {
|
||||||
|
"compact": true,
|
||||||
|
"cozy": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sap.platform.abap": {
|
||||||
|
"_version": "1.1.0",
|
||||||
|
"uri": ""
|
||||||
|
},
|
||||||
|
"sap.platform.hcp": {
|
||||||
|
"_version": "1.1.0",
|
||||||
|
"uri": ""
|
||||||
|
},
|
||||||
|
"sap.fiori": {
|
||||||
|
"_version": "1.1.0",
|
||||||
|
"registrationIds": [],
|
||||||
|
"archeType": "transactional"
|
||||||
|
}
|
||||||
|
}
|
||||||
23
packages/bookstore/app/bookList/xs-app.json
Normal file
23
packages/bookstore/app/bookList/xs-app.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"welcomeFile": "/index.html",
|
||||||
|
"authenticationMethod": "none",
|
||||||
|
"logout": {
|
||||||
|
"logoutEndpoint": "/do/logout"
|
||||||
|
},
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"source": "^/catalog/(.*)$",
|
||||||
|
"target": "$1",
|
||||||
|
"destination": "srv-api",
|
||||||
|
"csrfProtection": false,
|
||||||
|
"authenticationType": "none"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "^(.*)$",
|
||||||
|
"target": "$1",
|
||||||
|
"service": "html5-apps-repo-rt",
|
||||||
|
"authenticationType": "xsuaa"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
66
packages/bookstore/app/booksAnnotation.cds
Normal file
66
packages/bookstore/app/booksAnnotation.cds
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using sap.capire.bookstore.CatalogService as CatalogService from '../srv/services';
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Lists
|
||||||
|
//
|
||||||
|
annotate CatalogService.Books with @(
|
||||||
|
UI: {
|
||||||
|
HeaderFacets: [
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: 'Description', Target: '@UI.FieldGroup#Descr'},
|
||||||
|
],
|
||||||
|
Facets: [
|
||||||
|
{$Type: 'UI.ReferenceFacet', Label: 'Details', Target: '@UI.FieldGroup#Price'},
|
||||||
|
],
|
||||||
|
FieldGroup#Descr: {
|
||||||
|
Data: [
|
||||||
|
{Value: descr},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
FieldGroup#Price: {
|
||||||
|
Data: [
|
||||||
|
{Value: price},
|
||||||
|
{Value: currency.symbol, Label: 'Currency'},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
Identification: [{Value:title}],
|
||||||
|
SelectionFields: [ ID, price, currency_code ],
|
||||||
|
LineItem: [
|
||||||
|
{Value: ID},
|
||||||
|
{Value: title},
|
||||||
|
{Value: author_ID, Label:'Author ID'},
|
||||||
|
{Value: stock},
|
||||||
|
{Value: price},
|
||||||
|
{Value: currency.symbol, Label:''},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Details
|
||||||
|
//
|
||||||
|
annotate CatalogService.Books with @(
|
||||||
|
UI: {
|
||||||
|
HeaderInfo: {
|
||||||
|
TypeName: 'Book',
|
||||||
|
TypeNamePlural: 'Books',
|
||||||
|
Title: {Value: title},
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Books Elements
|
||||||
|
//
|
||||||
|
annotate CatalogService.Books with {
|
||||||
|
ID @title:'ID' @UI.HiddenFilter;
|
||||||
|
title @title:'Title';
|
||||||
|
author @title:'Author ID';
|
||||||
|
price @title:'Price';
|
||||||
|
stock @title:'Stock';
|
||||||
|
descr @UI.MultiLineText;
|
||||||
|
}
|
||||||
5
packages/bookstore/db/csv/sap.capire.bookstore-Authors.csv
Executable file
5
packages/bookstore/db/csv/sap.capire.bookstore-Authors.csv
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
ID;name;dateOfBirth;placeOfBirth;dateOfDeath;placeOfDeath
|
||||||
|
101;Emily Brontë;1818-07-30;Thornton, Yorkshire;1848-12-19;Haworth, Yorkshire
|
||||||
|
107;Charlotte Brontë;1818-04-21;Thornton, Yorkshire;1855-03-31;Haworth, Yorkshire
|
||||||
|
150;Edgar Allen Poe;1809-01-19;Boston, Massachusetts;1849-10-07;Baltimore, Maryland
|
||||||
|
170;Richard Carpenter;1929-08-14;King’s Lynn, Norfolk;2012-02-26;Hertfordshire, England
|
||||||
|
500 Internal Server Error
Gitea Version: 1.24.4 |