-
Notifications
You must be signed in to change notification settings - Fork 2
wip: data federation #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BobdenOs
wants to merge
35
commits into
main
Choose a base branch
from
cafe
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
350bbaa
Workaround for xtravels
BobdenOs a223f50
Add hybrid profile and Data Sphere export script
BobdenOs 156cdd0
Merged main into cafe
danjoa b16ebfc
Merge branch 'main' into cafe
danjoa 9cf85e6
Remove unused 'textAspect' symbol from Data Sphere index
danjoa 0ada422
Adopt simple comments
BobdenOs 94a40d7
Merge branch 'main' into cafe
danjoa f9b432a
.
danjoa 36def81
Switch to generating .env files
BobdenOs c5b5c2f
version 0.1.2
danjoa afc2c6b
API readonly
danjoa 71d789c
cleanup
danjoa cb71c24
.
danjoa 57d84fb
.
danjoa eb95bdc
rm exported apis
danjoa a3d549b
add generated apis to .gitignore
danjoa d2aae4f
-> .cdsrc.yaml
danjoa e66fd93
Merge branch 'main' into cafe
danjoa 451febb
Added readme
danjoa 662770f
Merge branch 'main' into cafe
danjoa 9553ecf
Merge remote-tracking branch 'origin/main' into cafe
danjoa 7e915bc
Merge branch 'main' into cafe
danjoa 8ded31b
Merge branch 'main' into cafe
danjoa 3e59b85
Restored readme from main
danjoa e9c01d0
Merge branch 'main' into cafe
danjoa d36d1f0
named apis
danjoa 2efbb58
Merge branch 'main' into cafe
danjoa 96d62a3
Merge branch 'main' into cafe
danjoa da5959f
rm .cdsrc.yaml
danjoa 8bdeb03
Merge branch 'main' into cafe
danjoa 9b0d47e
Merge branch 'main' into cafe
danjoa b2ce706
Merge branch 'main' into cafe
danjoa 2e8be40
Merge branch 'main' into cafe
danjoa 7ebc8a5
Merge branch 'main' into cafe
danjoa 0007187
Merge branch 'main' into cafe
danjoa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| const model = require('../../csn.json') | ||
|
|
||
| // Remove includes as Data Sphere doesn't support them | ||
| for (const name in model.definitions) { | ||
| const def = model.definitions[name] | ||
| const includes = def.includes | ||
| if (!includes) continue | ||
| for (const include of includes) { | ||
| const i = model.definitions[include] | ||
| def.elements = { ...def.elements, ...i.elements } | ||
| } | ||
| delete def.includes | ||
| } | ||
|
|
||
| // Inline custom types to simplify managed association removal | ||
| for (const name in model.definitions) { | ||
| const def = model.definitions[name] | ||
| const elements = def.elements | ||
| if (!elements) continue | ||
| for (const col in elements) { | ||
| const element = elements[col] | ||
| const customType = model.definitions[element.type] | ||
| if (!customType) continue | ||
| elements[col] = { ...customType, kind: undefined } | ||
| } | ||
| } | ||
|
|
||
| // Remove managed association as Data Sphere doesn't support them | ||
| for (const name in model.definitions) { | ||
| const def = model.definitions[name] | ||
| const elements = def.elements | ||
| if (!elements) continue | ||
| for (const col in elements) { | ||
| const element = elements[col] | ||
|
|
||
| // Data Sphere doesn't know that value.xpr is a thing that is supposed to be supported | ||
| if (element.value && element.value.xpr) { | ||
| element.xpr = element.value.xpr | ||
| delete element.value | ||
| } | ||
| if (!(element.type in { 'cds.Association': 1, 'cds.Composition': 1 })) continue | ||
| if (!element.keys) continue | ||
| const keys = element.keys | ||
| const on = [] | ||
| let first = true | ||
| for (const k of keys) { | ||
| if (first) first = false | ||
| else on.push('and') | ||
| const foreignKey = `${col}_${k.ref[0]}` | ||
| on.push( | ||
| { ref: [col, k.ref[0]] }, | ||
| '=', | ||
| { ref: [foreignKey] }, | ||
| ) | ||
| const target = model.definitions[element.target] | ||
| elements[foreignKey] = { ...target.elements[k.ref[0]], key: element.key } | ||
| } | ||
| delete element.keys | ||
| delete element.key | ||
| element.on = on | ||
| } | ||
| } | ||
|
|
||
| // Collect all @data.product service to convert to Data Sphere annotation | ||
| const dataProductServices = [] | ||
| for (const name in model.definitions) { | ||
| const def = model.definitions[name] | ||
| if (def.kind !== 'service' || !def['@data.product']) continue | ||
| dataProductServices.push(name) | ||
| } | ||
|
|
||
| // Just keep entities as Data Sphere doesn't handle the other types | ||
| for (const name in model.definitions) { | ||
| const def = model.definitions[name] | ||
| if (def.kind === 'entity') continue | ||
| delete model.definitions[name] | ||
| } | ||
|
|
||
| // Enhance all the entities with Data Sphere annotations for compatibility | ||
| for (const name in model.definitions) { | ||
| const def = model.definitions[name] | ||
| if (def.kind !== 'entity') continue | ||
| // Data Sphere delta deployment doesn't guarantee that these annotation are computed correctly | ||
| delete def['@cds.autoexpose'] | ||
| delete def['@cds.persistence.skip'] | ||
|
|
||
| def['@DataWarehouse.consumption.external'] = dataProductServices.some(s => name.startsWith(s)) | ||
| def['@ObjectModel.modelingPattern'] = { '#': 'DATA_STRUCTURE' } | ||
| def['@ObjectModel.supportedCapabilities'] = [{ '#': 'DATA_STRUCTURE' }] | ||
| if (def.projection) def['@DataWarehouse.sqlEditor.query'] = `SELECT * FROM "${def.projection.from.ref[0]}"` | ||
| } | ||
|
|
||
|
|
||
|
|
||
| const fs = require('node:fs') | ||
| const path = require('node:path') | ||
|
|
||
| const dataSphereString = JSON.stringify(model, null, 2) | ||
| .replace(/\.texts"/g, '_texts"') | ||
|
|
||
| fs.writeFileSync( | ||
| path.resolve(path.dirname(require.resolve('../../gen/index.json')), 'datasphere.json'), | ||
| dataSphereString | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "file_suffixes": { | ||
| "hdbrole": { | ||
| "plugin_name": "com.sap.hana.di.role" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move that to |
||
| "role": { | ||
| "name": "PUBLIC#", | ||
| "object_privileges": [ | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_AIRLINES", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_AIRPORTS", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_COUNTRIES", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_COUNTRIES_TEXTS", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_CURRENCIES", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_CURRENCIES_TEXTS", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_FLIGHTS", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_LANGUAGES", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_LANGUAGES_TEXTS", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_SUPPLEMENTTYPES", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_SUPPLEMENTTYPES_TEXTS", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_SUPPLEMENTS", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| }, | ||
| { | ||
| "name": "SAP_CAPIRE_FLIGHTS_DATA_SUPPLEMENTS_TEXTS", | ||
| "type": "VIEW", | ||
| "privileges_with_grant_option": [ | ||
| "SELECT" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move that to
gen