Compare commits
7 Commits
deploy/mul
...
use-contex
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fc3462b24 | ||
|
|
efc2f3632f | ||
|
|
61ceb4a63a | ||
|
|
226ab2539e | ||
|
|
56a9796329 | ||
|
|
ece1962052 | ||
|
|
f90c43150a |
@@ -1,6 +0,0 @@
|
||||
// Add routes to UIs from imported packages
|
||||
module.exports = (app) => {
|
||||
app.serve ('/bookshop') .from ('@capire/bookshop','app/vue')
|
||||
app.serve ('/reviews') .from ('@capire/reviews','app/vue')
|
||||
app.serve ('/orders') .from('@capire/orders','app/orders')
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
const cds = require ('@sap/cds')
|
||||
|
||||
|
||||
// Add routes to UIs from imported packages
|
||||
if (!cds.env.production) cds.once ('bootstrap', require('../app/routes'))
|
||||
if (!cds.env.production) cds.once ('bootstrap', (app) => {
|
||||
app.serve ('/bookshop') .from ('@capire/bookshop','app/vue')
|
||||
app.serve ('/reviews') .from ('@capire/reviews','app/vue')
|
||||
app.serve ('/orders') .from('@capire/orders','app/orders')
|
||||
})
|
||||
|
||||
|
||||
// Mashing up bookshop services with required services...
|
||||
cds.once ('served', async ()=>{ // called by server.js
|
||||
cds.once ('served', async ()=>{
|
||||
|
||||
const CatalogService = await cds.connect.to ('CatalogService')
|
||||
const ReviewsService = await cds.connect.to ('ReviewsService')
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
"name": "sap.fe.templates.ObjectPage",
|
||||
"options": {
|
||||
"settings" : {
|
||||
"entitySet" : "Books",
|
||||
"contextPath" : "/Books",
|
||||
"navigation" : {
|
||||
"Authors" : {
|
||||
"detail" : {
|
||||
@@ -123,7 +123,7 @@
|
||||
"name": "sap.fe.templates.ObjectPage",
|
||||
"options": {
|
||||
"settings" : {
|
||||
"entitySet" : "Authors"
|
||||
"contextPath" : "/Authors"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
"name": "sap.fe.templates.ListReport",
|
||||
"options": {
|
||||
"settings": {
|
||||
"entitySet": "Books",
|
||||
"contextPath": "/Books",
|
||||
"initialLoad": true,
|
||||
"navigation": {
|
||||
"Books": {
|
||||
@@ -117,7 +117,7 @@
|
||||
"name": "sap.fe.templates.ObjectPage",
|
||||
"options": {
|
||||
"settings": {
|
||||
"entitySet": "Books"
|
||||
"contextPath": "/Books"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
const cds = require('@sap/cds/lib')
|
||||
if (cds.requires.db?.kind === 'sqlite') {
|
||||
cds.on ('serving:AdminService', srv => srv.prepend(() => {
|
||||
const {Genres} = srv.entities
|
||||
// Register a simplistic handler for hierarchical queries
|
||||
srv.on('READ', Genres, (req,next) => {
|
||||
const q = req.query
|
||||
// Expand query on a single row
|
||||
if (q.SELECT.recurse?.where?.[0].ref[0] === 'Distance') {
|
||||
q.SELECT.where[0] = 'parent_ID'
|
||||
// Initial query
|
||||
} else if (!q.SELECT.search && !is_count(q)) {
|
||||
q.SELECT.where ??= [ 'parent_ID is null' ]
|
||||
}
|
||||
// Use scalar subselect for DrillState
|
||||
q.SELECT.from.as = 'g'
|
||||
q.SELECT.columns = q.SELECT.columns.map (c => {
|
||||
if (c.ref == 'DrillState') return { xpr:[`
|
||||
CASE WHEN ( SELECT count(1) from ${Genres} where parent_ID = g.ID ) > 0
|
||||
THEN 'collapsed' ELSE 'leaf' END`
|
||||
], as: 'DrillState' }
|
||||
else return c
|
||||
})
|
||||
// Suppress error message: Feature "recurse" queries not supported.
|
||||
delete q.SELECT.__proto__.recurse
|
||||
delete q.SELECT.recurse
|
||||
return next()
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
const is_count = q => q.SELECT.columns?.length === 1 && q.SELECT.columns[0].func === 'count'
|
||||
11
package.json
11
package.json
@@ -5,8 +5,15 @@
|
||||
"repository": "https://github.com/sap-samples/cloud-cap-samples.git",
|
||||
"author": "daniel.hutzel@sap.com",
|
||||
"workspaces": [
|
||||
"./*",
|
||||
"./etc/*"
|
||||
"bookshop",
|
||||
"bookstore",
|
||||
"common",
|
||||
"fiori",
|
||||
"orders",
|
||||
"reviews",
|
||||
"shared-db",
|
||||
"etc/data-viewer",
|
||||
"etc/loggers"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@cap-js/cds-test": "^0"
|
||||
|
||||
@@ -3,7 +3,7 @@ module.exports = cds.service.impl (function(){
|
||||
|
||||
// Get the CSN definition for Reviews from the db schema for sub-sequent queries
|
||||
// ( Note: we explicitly specify the namespace to support embedded reuse )
|
||||
const { Reviews, Likes } = this.entities ('sap.capire.reviews')
|
||||
const { Reviews, Likes } = this.entities
|
||||
|
||||
this.before (['CREATE','UPDATE'], 'Reviews', req => {
|
||||
if (!req.data.rating) req.data.rating = Math.round(Math.random()*4)+1
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
"name": "@capire/shared-db",
|
||||
"version": "3.0.0",
|
||||
"description": "CAP Sample CDS model deployment for shared-db scenario",
|
||||
"dependencies": {
|
||||
"@capire/bookstore": "*",
|
||||
"@capire/orders": "*",
|
||||
"@capire/reviews": "*"
|
||||
},
|
||||
"cds": {
|
||||
"sql": {
|
||||
"native_hana_associations": false
|
||||
|
||||
Reference in New Issue
Block a user