Skip to content

Commit

Permalink
Merge pull request #52 from cap-js/actions-for-test
Browse files Browse the repository at this point in the history
inherit from main workflow
  • Loading branch information
DanSchlachter committed Mar 11, 2024
1 parent 26beb62 commit 38d69a6
Show file tree
Hide file tree
Showing 20 changed files with 4,860 additions and 128 deletions.
18 changes: 18 additions & 0 deletions app/incidents/field.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using ProcessorService as service from '../../srv/services.cds';
using from './annotations.cds';
annotate service.Incidents with @(
/*adding email to the object page enables users to view the
changes recieved via Messaging/Eventing*/
UI.FieldGroup #GeneratedGroup1 : {
Data : [...,
{
$Type : 'UI.DataField',
Value : customer.email,
Label : '{i18n>email}'
}
]
});

annotate service.Customers with {
email @readonly
};
3 changes: 2 additions & 1 deletion app/services.cds
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

using from './incidents/annotations';
using from './incidents/annotations';
using from './incidents/field';
166 changes: 103 additions & 63 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,109 @@
{
"name": "@capire/incidents",
"version": "1.0.0",
"calesi": {
"@cap-js/audit-logging": "*",
"@cap-js/change-tracking": "*",
"@cap-js/notifications": "*",
"@cap-js/attachments": "*",
"@cap-js/telemetry": "*",
"@sap/ams": "*",
"@sap/ams-dev": "*",
"dummy": 0
},
"dependencies": {
"@sap/cds": ">=7",
"express": "^4"
},
"devDependencies": {
"@cap-js/sqlite": "^1.0.1",
"@sap/ux-specification": "^1.108.4",
"axios": "^1.4.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0"
},
"scripts": {
"watch": "cds watch",
"start": "cds-serve",
"test": "npx jest --silent",
"add-change-tracking": "npm add @cap-js/change-tracking && cp xmpls/change-tracking.cds ./srv && cp xmpls/change-tracking.test.js ./test",
"add-telemetry": "npm add @cap-js/telemetry",
"clone-and-add-attachments": "git clone https://github.com/cap-js/attachments.git && npm add ./attachments && npm run add-attachments",
"add-attachments": "cp -r xmpls/attachments/ ./",
"add-notifications": "npm add @cap-js/notifications && cp xmpls/alert-notifications.js ./srv && cp xmpls/notification-types.json ./srv",
"add-audit-log": "npm add @cap-js/audit-logging && cp xmpls/data-privacy.cds ./srv && cp xmpls/audit-log.test.js ./test",
"add-remote-service": "cp -r xmpls/remote-service/* .",
"add-messaging": "cp -r xmpls/messaging/* .",
"add-all-xmpls": "npm run add-remote-service && npm run add-messaging && npm run add-change-tracking && npm run add-audit-log",
"reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi"
},
"jest": {
"modulePathIgnorePatterns": ["<rootDir>/xmpls/"]
},
"sapux": [
"app/incidents"
],
"cds": {
"requires": {
"auth": {
"[development]": {
"users": {
"alice": {
"roles": [
"support",
"admin"
]
"name": "@capire/messaging",
"version": "1.0.0",
"dependencies": {
"@cap-js/audit-logging": "^0.6.0",
"@cap-js/change-tracking": "^1.0.5",
"@sap-cloud-sdk/connectivity": "^3.6.0",
"@sap-cloud-sdk/http-client": "^3.6.0",
"@sap-cloud-sdk/resilience": "^3.6.0",
"@sap-cloud-sdk/util": "^3.6.0",
"@sap/cds": ">=7",
"@sap/cds-hana": "^2",
"@sap/xb-msg-amqp-v100": "^0",
"@sap/xssec": "^3",
"express": "^4",
"passport": "^0"
},
"devDependencies": {
"@cap-js/sqlite": "^1.0.1",
"@sap/cds-dk": "^7",
"@sap/ux-specification": "^1.108.4",
"axios": "^1.4.0",
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"chai-subset": "^1.6.0",
"jest": "^29.5.0",
"rimraf": "^3.0.2"
},
"scripts": {
"watch": "cds watch",
"start": "cds-serve",
"test": "npx jest --silent",
"add-change-tracking": "npm add @cap-js/change-tracking && cp xmpls/change-tracking.cds ./srv && cp xmpls/change-tracking.test.js ./test",
"add-telemetry": "npm add @cap-js/telemetry",
"add-attachments": "npm add @cap-js/attachments && cp xmpls/attachments.cds ./srv && cp -r xmpls/content ./db/data/content",
"clone-add-attachments": "git clone https://github.com/cap-js/attachments.git && cp -r attachments/xmpl/db . && cp -r attachments/xmpl/app . && npm add https://github.com/cap-js/attachments.git",
"add-notifications": "npm add @cap-js/notifications && cp xmpls/alert-notifications.js ./srv && cp xmpls/notification-types.json ./srv",
"add-audit-log": "npm add @cap-js/audit-logging && cp xmpls/data-privacy.cds ./srv && cp xmpls/audit-log.test.js ./test",
"add-remote-service": "cp -r xmpls/remote-service/* .",
"add-messaging": "cp -r xmpls/messaging/* .",
"add-all-xmpls": "npm run add-remote-service && npm run add-messaging && npm run add-change-tracking && npm run add-audit-log",
"reset": "read -p 'This will irreversibly reset your working directory including ALL files in this git repo. Continue?' -n 1 -r && echo && if [[ $REPLY =~ ^[Yy]$ ]]; then git clean -fd && git reset --hard && npm i; fi"
},
"private": true,
"sapux": [
"app/incidents"
],
"jest": {
"modulePathIgnorePatterns": [
"<rootDir>/xmpls/"
]
},
"cds": {
"requires": {
"incidents-app": {
"model": "@capire/incidents"
},
"bob": {
"roles": [
"support"
]
"[production]": {
"db": {
"kind": "hana-cloud"
},
"auth": {
"kind": "xsuaa"
},
"approuter": {
"kind": "cloudfoundry"
}
},
"[development]": {
"auth": {
"kind": "mocked",
"users": {
"alice": {
"roles": [
"support",
"admin"
]
},
"bob": {
"roles": [
"support"
]
}
}
}
},
"db": {
"kind": "sql"
},
"API_BUSINESS_PARTNER": {
"kind": "odata-v2",
"model": "srv/external/API_BUSINESS_PARTNER",
"[production]": {
"credentials": {
"destination": "incidents-api-access",
"path": "/sap/opu/odata/sap/API_BUSINESS_PARTNER"
}
}
},
"messaging": {
"kind": "local-messaging",
"[production]": {
"kind": "enterprise-messaging-shared",
"format": "cloudevents"
}
}
}
}
}
}
},
"private": true
}
70 changes: 27 additions & 43 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,42 @@
# Incident Management
# Remote Service - Sample

Welcome to the Incident Management reference sample application for CAP and development recommendations provided by the SAP BTP Developer Guide.
Sample app based on [Incident Management](https://github.com/cap-js/incidents-app) for showcasing how to integrate a remote service into a CAP based application.

## Domain Model
## Business Use Case

The application support team members to create and process incidents on behalf of registered customers. The basic domain model is depicted below.
In this tutorial, we will integrate SAP S/4 HANA Cloud Business Partner API to the Incident Management Application.

![domain drawio](xmpls/schema.drawio.svg)
When a new incident is created by the processor, he/she has to assign the incident to a customer on behalf of whom they are receiving the phone call. This option to choose customer will be given as a value help and the list of customers in the value help will be fetched from SAP S/4HANA Cloud system. We will be using S/4HANA Business Partner API for the same.

### Setup

1. Clone the calesi repository

## Setup
```sh
git clone https://github.com/cap-js/calesi.git --recursive
```
2. Navigate to the folder samples/remote-service

Assumed you prepared for CAP development as documented in capire's *[Getting Started > Jumpstart](https://cap.cloud.sap/docs/get-started/jumpstart)* page, ...
3. Run the below command to copy files from remote service sample to the incident management application.

Clone the repository and install dependencies:
```sh
cp -r ./db ./srv ./tests package.json ../../incidents-app
```

```sh
git clone https://github.com/cap-js/incidents-app
cd incidents-app
```
4. Navigate to incidents-app and open package.json file.

```sh
npm install
```
5. Change the name in package.json file to `incident-management`

6. [Run a developer test with Mock Data](https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/develop/test-with-mock.md#run-the-incident-management-application)

### Deploy and Run the application in SAP BTP

## Run
* [Make sure prerequisites are fulfilled and all required systems are in place](https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/mission-prerequisites/README.md)
* [Configure the connectivity between SAP S/4HANA Cloud and SAP BTP](https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/s4hana-cloud-to-btp-connectivity/README.md)
* [Prepare the app for Production](https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/deploy/prep-for-prod/prep-for-prod.md)
* [Configure Mock Server - optional](https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/install-mock-server/README.md)
* [Option 1 - Deploy to SAP BTP Cloud Foundry](https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/deploy/cf/README.md)
* [Option 2 - Deploy to SAP BTP Kyma Runtime](https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/deploy/kyma/README.md)
* [Test the end to end flow](https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/test-the-application/test-the-app.md)

Run the application locally:

```sh
cds watch
```
Then open http://localhost:4004 and navigate to [/incidents/webapp](http://localhost:4004/incidents/webapp/index.html). <br>
(login as `alice`, no password required).

<details>
<summary> Troubleshooting </summary>
If you get a 403 Forbidden Error and the logon popup doesn't show, try to open a browser in an incognito mode or clear the browser cache.
</details>



## Test

Run enclosed tests with:

```sh
npm test
```


## Deploy

See: *[BTP Developer Guidelines Deployment Guides](https://help.sap.com/docs/btp/btp-developers-guide/deploy-cap)*

21 changes: 21 additions & 0 deletions req.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### Change Email Address

PATCH http://localhost:4004/odata/v4/api-business-partner/A_BusinessPartner('1004155')
Content-Type: application/json

{
"to_BusinessPartnerAddress": [
{
"BusinessPartner": "1004155",
"AddressID": "123",
"to_EmailAddress": [{
"AddressID": "123",
"Person": "Williams",
"OrdinalNumber": "123",
"EmailAddress": "[email protected]"

}
]
}
]
}
11 changes: 11 additions & 0 deletions srv/change-tracking.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using { ProcessorService.Incidents } from './services';

annotate Incidents with {
customer @changelog: [customer.name];
title @changelog;
status @changelog;
}

annotate Incidents.conversation with @changelog: [author, timestamp] {
message @changelog @Common.Label: 'Message';
}
20 changes: 20 additions & 0 deletions srv/data-privacy.cds
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using { sap.capire.incidents as my } from './services';

annotate my.Customers with @PersonalData : {
EntitySemantics: 'DataSubject',
DataSubjectRole: 'Customer'
} {
ID @PersonalData.FieldSemantics: 'DataSubjectID';
firstName @PersonalData.IsPotentiallyPersonal;
lastName @PersonalData.IsPotentiallyPersonal;
email @PersonalData.IsPotentiallyPersonal;
phone @PersonalData.IsPotentiallyPersonal;
creditCardNo @PersonalData.IsPotentiallySensitive;
}

annotate my.Addresses with @PersonalData : { EntitySemantics: 'DataSubjectDetails' } {
customer @PersonalData.FieldSemantics: 'DataSubjectID';
city @PersonalData.IsPotentiallyPersonal;
postCode @PersonalData.IsPotentiallyPersonal;
streetAddress @PersonalData.IsPotentiallyPersonal;
}
Loading

0 comments on commit 38d69a6

Please sign in to comment.