Embarcadero’s RAD Server Enterprise Mobility Server (EMS) is a turn-key application foundation for rapidly building and deploying services based applications.
RAD Server’s core offerings include automated Delphi and C++ REST/JSON API publishing and management, Enterprise database integration middleware, IoT Edgeware and an array of application services such as User Directory and Authentication services, Push Notifications, Indoor/Outdoor Geolocation and JSON data storage.
RAD Server enables developers to quickly build new application back-ends or migrate existing Delphi or C++ client/server business logic to a modern services based architecture that is open, stateless, secure and scalable. RAD Server is easy to develop, deploy and operate making it ideally suited for ISVs and OEMs building re-deployable solutions.
Two important and useful features included with RAD Server are:
1. It’s important to note that a RAD Server single site license (included in Enterprise Edition) still allows you to deploy a solution based on multiple instances of the RAD Server engine, on multiple physical or virtual servers, for fail-over and load balancing, as long as they are backed by a single instance of the RAD Server database (the included InterBase database instance) which manages the RAD Server license itself.
2. It’s also important to note that Data Storage for Users in the form of JSON name/value pairs is part of the core RAD Server offering. But the use of the included RAD Server InterBase database as a relational DB is subject to a separate license (and also the installation of a separate InterBase server instance).
This post focuses on how to use RAD Server to add JSON data storage, to create some Custom Fields to store additional JSON name-value information for your RAD Server Users.
The included RAD Server InterBase database creates a USERS table.
The RAD Server USERS Table allows you to manage the RAD Server Users data that are stored in your RAD Server Engine (EMS Server). The USERS Table stores information about RAD Server Users in the RAD Server Engine (EMS Server): The RAD Server USERS table columns are listed here:
[crayon-676c6c4a16aec741956486/]
The UID is the USERID is a Unique identifier of a RAD Server User (UserID) in the RAD Server database. For example: “D5FA6E2F-AC92-479E-B917-FBBB7B4E0B45”
The USERNAME is RAD Server User name in the RAD Server database. For example: “Manager1”.
In addition to these default column data of the USERS table, a core RAD Server offering allows you to create Custom Fields for additional stored information for the RAD Server User. This included Data Storage is in the form of JSON name/value pairs.
Let’s now take a look at an example Use Case for needing to do this.
Here we have our sample User data in our RAD Server Users Table:
For our Tenant ID (TID) 1, we have Usernames Manager1, WaitStaff1, and WaitStaff2, each with its own unique USERID.
In our case, our RAD Server in Single-Tenant mode has these 3 users in our Users Table: localhost:8080/users
[{“username”:”Manager1″,”_id”:”D5FA6E2F-AC92-479E-B917-FBBB7B4E0B45″,,
{“username”:”Waitstaff1″,”_id”:”270B823B-2D81-4032-8FE8-6A81E8F9124A”,
{“username”:”Waitstaff2″,”_id”:”2127E78D-EDE1-49AA-8992-F4B8CBE0E1C3″,
For our example, let’s say we need to add Emergency Cell Phone Contact Information for User Manager1:
– Emergency Cell Number for Manager1. (Emergency_Cell)
This is one example of needing to create some Custom Fields to store additional JSON name-value information for the RAD Server User Manager1.
Here’s how we can do this with a Delphi or C++ Builder application.
The RAD Server database stores data about the registered users of your application. You can access this information by using the registered Users Resource as described here.
1. Retrieve the RAD Server Users
First, let’s use the TBackendQuery component to retrieve the RAD Server Users from the RAD Server Engine:
a. Drop a TBackendQuery component to your form.
b. In the Object Inspector, select Users as the BackendService property of the TBackendQuery:
c. Call BackendQuery1.Execute; to return your list of Users from the RAD Server Engine:
[crayon-676c6c4a16af3904136548/]
d. The BackendQuery1.JSONResult property collects the raw JSON data that we are querying via the BackendQuery component.
e. Next, you can connect any input control, such as a TMemo or TListView to the BackendQuery1.JSONResult property using the LiveBindings designer to display the JSON data of the RAD Server Users:
2. Adding Custom Fields and Custom Values for our RAD Server Users.
After selecting our User, in this case, we select Manager1, we can now create Custom Fields to store additional JSON name-value information for the RAD Server User Manager1.
We can use the RAD Server TBackendUser component to create our Custom Fields and Custom Values for our RAD Server Users. With the TBackendUser component, you can manage (create, update and delete) the RAD Server Users in the RAD Server Engine, plus also add new Custom Fields to store additional JSON name-value information for the RAD Server Users.
a. Drop a TBackendUsers component on the form.
b. We can use the RAD Server TBackendUsers component to create our Custom Fields and Custom Values for our RAD Server Users. Here is how we can add new Custom Field to store additional JSON name-value information for the RAD Server User, by using a TJSONObject and a TBackendEntityValue, coded like this:
[crayon-676c6c4a16af6275063217/]
With our Manager1 user selected, clicking the “Add or Update Custon Field / Value” button will add a new Custom Field called Emergency_Cell with Custom Value 212-555-1212 to the Manager1 user, or if the Custom Field Emergency_Cell already exists the Custom Value will be updated.
3. Retrieve Custom Field Values.
Now that we have a new Custom Field and Custom Value information for the RAD Server User Manager1, we can call BackendUsers1.Users.FindUser to retrieve the Custom Value for use in our applications:
[crayon-676c6c4a16af7163933051/]
Clicking the “Get Custom Value” for our Custom Field Emergency_Cell, displays the Custom Value in the EditValue.Text:
4. Delete Custom Value
Lastly, let’s see how we can delete the Custom Value from our Custom Field.
a. Here we can also call BackendUsers1.Users.UpdateUser to delete the Custom Value for our Custom Field, by also using a TJSONObject and a TBackendEntityValue, after we set the Custom Value for the Custom Field := TJSONNull.Create, with this code:
[crayon-676c6c4a16af8607796963/]
The Delphi 10.4.1 source code for this RAD Server create some Custom Fields to store additional JSON name-value information for your RAD Server Users is here.
Data Storage for Users in the form of JSON name/value pairs is part of the core RAD Server offering!