
035: Recycling-Heroes - New entity (Document)
After generating the app, the actual development phase begins. The app needs to be adapted and expanded for our use in order to meet our specific requirements. Therefore, we are extending the data model with a new entity.
Table of contents
Introduction
In the last episode, we generated our app with relatively little effort. We used various generators for the data model and the RAP stack, which significantly increased development time. However, the real work only begins with customizing the application and defining our own use case.
Entity
The standard RAP generator can only generate a single entity. However, our data model also includes a child entity. Therefore, we will extend our data model with another entity for the tags. Since we've already created the table with the generator, we can start defining the Core Data Service directly. Right-clicking the table starts the wizard, and the table is automatically defined as a reference object. After entering the name and description, always make sure you're using the correct type for generation; here, we'll almost always define a VIEW ENTITY. After generation, we clean up the view and activate the object.
Next, we need to establish the relationship in the data model. We'll use small code snippets to help us define the relationship between the objects. From root to child, we need a composition and specify the other view in the definition. Then we assign a descriptive alias and propagate the association externally. At the child level, we define an "Association to parent" to our root entity. After changing the alias and the link, we also specify the association in the field list. Then we can activate both views, thus defining the relationship at the lowest level.
Now we can begin creating the core data service for the projection. Here, you can start the interface view directly and create the new core data service by right-clicking. After assigning a name and description, we select the correct type from the templates and create the view. At this level, we override the association from the interface and redirect to the appropriate core data service at the projection level. We perform this step on both levels and then activate the two views, thus connecting the projection.
Behavior
Now that we have extended the data model, we need to adjust the behavior so that the objects can interact with each other and also know which relationships exist. You will also find an entry in the RAP Generator that defines the relationships accordingly. We copy the code snippet to define another entity in the behavior. Now we need to adapt the components to our current data model. We replace the Core Data Service and assign a descriptive alias. We also have our own table in the data model, as well as a new draft table. Here we assign the name, but we still need to generate the table later. In this case, we obtain the locking and permissions via the association from our root entity. We should set the key fields to read-only, as these should no longer be editable in the event of modifications. Next, we define the mapping from Core Data Service to the table so that the database is also populated during write operations. Before we can activate this behavior, we generate the draft table using Quick Fix. This table is automatically created in the system and uses our data table as its basis. To enable us to create new tags later, we must define the association at the root level using Create and then activate the object.
We also need to perform the extension at the projection level. To do this, we define the new entity and the association in the root entity. Finally, we replace the placeholders with the actual objects and relationships and can activate the object.
Service
Currently, there is only one entity in the service, and the relationship is not visible in the service binding. Therefore, we also need to make the new entity in the service accessible. To do this, we extend the service definition, specify our entity, and finally activate the service.
Summary
In today's episode, we focused on extending an existing data model. Last time, the generator provided us with a simple app, but not the complete data model. As of today, there is no automatic adjustment or wizard, which is why we have to perform the adjustment manually. So we are at the end of this session. Thanks for watching and see you next time.
YouTube
Video