If you are looking for something fun yet educational this holiday season to play around with, might I suggest this new SAP Cloud Application Programming Model sample that was just released:
https://github.com/SAP-samples/cloud-cap-hana-swapi
I was recently looking around for a fun yet decently complex sample data model to reuse in an CAP example. I stubbled across SWAP - the Star Wars API. It had the interesting level of complexity I was looking for. It's filled with many-to-many bi-directional relationships. Yet the data model is easy to understand on the surface. There are Star Wars films that contain planets, characters, starships, etc. I also thought it make a good example of complex Fiori based maintenance. Going in I wasn't exactly sure how the many-to-many relationships would work with Fiori Draft and deep editing; but it turns out the functionality worked out nicely.
Although the Star Wars API had been abandoned, this also provided a good challenge. I kept the original project's data files as JSON and wrote converter scripts using CAP CQL to convert the data into the new version of the data model.
Overall I think this sample provides examples of a lot of deeper and more complex topics in the SAP Cloud Application Programming Model and Fiori area; but does so with some data that is a bit of fun to play around with.
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
I've used the
new openAPI functionality in CAP to generate both the Swagger UI test framework but also entity diagrams for the data model.
Films
StarWarsFilm Service
People
StarWarsPeople Service
Planets
StarWarsPlanet Service
Species
StarWarsSpecies Service
Starships
StarWarsStarship Service
Vehicles
StarWarsVechicle Service
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.
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 expolore 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.
CAP Preview Test Page
Fiori Preview List for Film Entity
Fiori Preview Overview Edit Mode for Film Entity
Note
Star Wars and all associated names are copyright Lucasfilm ltd. All data in this sample has been freely collected from
Wookiepedia under
CC-BY-SA.