Customizing entities

In this page you will find information on how to create and customize entities.

Create entities

In order to create an entity you will first need to create a Customization set. To do that, in the Develop app, click on Develop and select Customization sets from the menu that appears. In the page that opens click the Add button. You will see a page like the one from figure 1.

Here you can do the following actions:

  • Fill the Name of the customization set (under the Edit section).
  • Add a new entity (in the Entities tab).
  • Add properties for the entities (in the Properties tab)
  • Add relationships between entities (can be added in the Relationships tab).

Fig.1: Adding new customization set

Entities tab

To add an entity you will have to click the Add button and fill in the Entity name field. Usually here you will add only one entity. There are only two cases when you will add more then one entity:

  1. If the already created entity will have a parent-child relationship with other entities. Those entities will be added also in this tab and their properties will be put in the properties tab. The idea is to have the entities that are in a parent-child/child-parent relationship in the same customization set.
  2.  If the created entity will have relationships with entities from other customization sets. Those entities will be added in this tab without setting their properties in the properties tab.

The name of the entity cannot be in Cammel Case and it should be a singular noun.

Properties tab

Here you will add properties for the entities. To do that click on the Add button. For each property that you add you will have to fill the Entity name field, the Property name field and the Property type field. Optionally you can fill in other fields like:

- Is required - check the box if that property is mandatory to be set

- Default value - here you can add a default value for the corresponding property.

In order to delete a property you only have to click on the trash icon that can be found at the end of the row.

The name of the properties can only contain ascii letters ([a-z0-9]), numbers and the character "_". Another thing to mention here is that they cannot be in Cammel Case and cannot start with a number or with the "id_".

Relationships tab

When the entity will have relationships you will have to add them in this tab by clicking the Add button. Here you will have to fill the following fields:

  • Relationship name -  The name of the relationship. Relationship names are case sensitive and usually they should be composed by putting together the names of the entities that form the relation. This is optional. The system will set the name for you if don't set it.
  • Entity name - The entity on the left-side of the relationship.
  • Type name - The type of the relationship. There are four types of relationships: One-To-Many(1:n), Many-To-One(n:1), Parent-Child(p:c) and Child-Parent(c:p). From structural point of view the Parent-Child and Child-Parent relationships are identical with One-To-Many and Many-To-One relationships. The difference resides in the fact that they are managed in the same life cycle and not separately. This means that child entities are not saved or updated separately but within parent entity. 
  • Property name -  The property for the key of entity on the right-side on the entity on the left-side of the relationship. This field is optional, if not set then the key parameter of entities it will be used.
  • Foreign entity name - The entity on the right-side of the relationship.
  • Foreign property name - The property for the foreign key. This field is optional.
  • Is required - Check this if you want the relation to be mandatory.
  • Sort property - Only for parent-child relationships. The property on the child if the children are to be sorted when the parent entity is read. ???
  • Sort asc Check this if you want to sort children in an ascending order.

In order to delete a relationship you only have to click on the trash icon that can be found at the end of the row. 

After you finish setting all this click on the Save button to persist the changes

Publish entities

In order to be able to use the entities created they need to be published as database tables. To publish the entities you have to follow this steps:

  1. If you are not already in the Customization sets menu click on Develop and select Customization sets from the menu that appears;
  2. Select the row containing the customization set that you have just created;
  3. Click the Publish button located above the list.

After you clicked on Publish, if you've set all things correctly you will receive the following message on screen: "Action 'Publish' was executed". 

An important thing to mention here is that every time you change something in the customization set you will have to Publish again the customization set.

Deleting entities

Every entities resides in a customization set. If you want to delete an entity and create another one, you will have to do the following:

  • go to the Entities tab of the customization set and click on the trash icon corresponding to the entity that you want to remove;
  • Add a new entity;
  • click on the Save button;
  • publish again the customization set;

In the customization set under the History tab you can see what actions was done on the customization set so far. The list is ordered descending by the time when the changes were applied.

An important thing to mention here is that the database table corresponding to the entity that you deleted was not dropped. In order to do that you will have to go to the History tab and select the item that contained the creation of the entity that you deleted. After selecting it, you have to click on Unpublish. Be careful though that if you in the meantime did other changes to the customization set you will have to unpublish all this changes first, otherwise an error will appear.


More information about entities can be found HERE