Git Product home page Git Product logo

sap-samples / cloud-cap-hana-swapi Goto Github PK

View Code? Open in Web Editor NEW
76.0 13.0 42.0 5.04 MB

SAP Cloud Application Programming Model fun sample to demonstrate many-to-many relationships.

License: Apache License 2.0

JavaScript 12.16% Jupyter Notebook 6.85% HTML 5.79% Dockerfile 0.39% Smarty 8.71% CAP CDS 55.75% Shell 1.07% TypeScript 8.71% CSS 0.59%
sample sample-code sap-cloud-platform sap-cap sap-hana nodejs owner-jung-thomas

cloud-cap-hana-swapi's Introduction

cloud-cap-hana-swapi - bi-directional, many-to-many SAP Cloud Application Programming Model example

REUSE status

Description

SWAPI - the Star Wars API. This sample is based upon the sample at swapi.dev which in turn was based upon swapi.co. The original source can be found at https://github.com/Juriy/swapi.

The original project was a data set and data model based in Python that exposed data from the Star Wars movies sourced originally from the community wiki: Wookiepedia. It encompasses data about the People, Films, Species, Starships, Vehicles and Planets from Star Wars.

The projects described above have fallen out of maintenance but still offered the opportunity for a fun yet challenging learning experience from a non-trivial data model. The many bi-directional, many-to-many relationships with the data provides a good basis for an SAP Cloud Application Programming Model and Fiori Draft UI sample.

Data Model

Films

film diagram

People

people diagram

Planets

planet diagram

Species

species diagram

Starships

starships diagram

Vehicles

vehicles diagram

Requirements

Download and Installation

The original data model and data source files are in in the oldPython\resources folder.

The rest of the operations can be performed within the cap folder and there are scripts in the package.json file major operations.

You can use npm run build to perform the cds build and should be ran before deployment to HANA or whenever you make changes to the data model.

You can run npm run hana to deploy the content to your HANA database. Just be sure from the terminal that you are logged into the cf/xs cli and targeting the Account/Org/Space where you want the content to live. By default this command will create an HDI Container instance named starwars. Note: due to some strange circumstances in the latest versions of CAP it seems the /gen/srv folder is getting cleared after any deployment to HANA. Therefore just execute a cds build or npm run build after any deployment to restore the /gen folder until we find the root cause of this issue.

You can run the command npm run load. This command will read the original JSON data files from the source project and load them into your HANA database using Cloud Application Programming Model CQL. The loading script is convertData.js

The command npm start or cds run will start the service running locally. It will open the standard CAP test page where you can explore the OData Services or the Fiori UI.

From the Cloud Application Programming Model preview (which opens locally when using npm start or cds run), you can access the Swagger UI test tool (with entity diagrams), test the OData services or metadata calls directly in the browser, or access the Fiori preview UI for each of the main entities.

CDS Test Page

Fiori Preview List

Fiori Preveiw Overview Edit

Known Issues

If you receive an error like the following when running the convertData script

[Error: SQLITE_BUSY: database is locked] {
  errno: 5,
  code: 'SQLITE_BUSY',
  query: 'DELETE FROM star_wars_People'
}

This is caused by the parallel nature of the loading of the data in SQLite. The default script with its parallel loading works fine when you use HANA as the target persistence. However if you are using SQLite for your tempoary testing persistence, then you can use the alternative convertDataLite script instead.

Note: due to some strange circumstances in the latest versions of CAP it seems the /gen/srv folder is getting cleared after any deployment to HANA. Therefore just execute a cds build or npm run build after any deployment to restore the /gen folder until we find the root cause of this issue.

How to obtain support

This project is provided "as-is": there is no guarantee that raised issues will be answered or addressed in future releases.

License

Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.

Star Wars and all associated names are copyright Lucasfilm ltd. All data in this sample has been freely collected from open sources such as Wookiepedia under CC-BY-SA .

cloud-cap-hana-swapi's People

Contributors

btbernard avatar jung-thomas avatar marianfoo avatar patricebender avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloud-cap-hana-swapi's Issues

FieldControl #ReadOnly not working?

Is it a bug that the FieldControl annotation is not working?
![@Common.FieldControl] : #ReadOnly

As a workaround you can define multiple services and set the entities to @readonly, as shown here with film-service, planet-service, starship-service etc..

What is your experience with the FieldControl annotation?

If my star wars data is residing on a SAP SYSTEM

Hello experts,

If my some STAR WARS data is residing on a SAP S/4HANA System on which i have created an OData service V2,
Like I have film entity data in my CAP model and other entities are residing on s/4 hana system, can i somehow consome them in my this CAP STAR WARS Application?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.