The SQLDBRestBridge schema editor allows you to edit schema files for a SQLDBRestBridge SQLDBRestBridge schema.
The editor is implemented in the sqldbrestschemadesigner.lpk package and included in the Lazarus IDE if you register the lazsqldbrest.lpk package. It can also be compiled as a standalone application, the application is located in the schemaeditor project under the components/fpweb directory.
The standalone editor can be used to create schema files, which can be used to load schemas using the LoadFromFile method.
The schema editor has one form, which looks as follows when a schema is loaded.
The left side Available connections shows the known connections, and for each connection to a database, the tables in the database can be shown. Using drag & drop, the tables (you can select multiple tables at once) can be dragged to the middle part of the screen. The known connections can be hidden using the button above the tree.
The middle part of the screen Available Resources shows the resources defined in the schema. You can add new resources by dragging them from the connections, or using the 'Add resource' button.
The right part of the screen shows the details of the item selected in the Available resources. This can be one of 4 details
- When the schema node is selected, the list of tables is shown (see the above screenshot). You can double click a resource, and the selected resource will be shown for editing.
- When a resource node is selected, the resource editor is shown (see below)
- When the 'fields' node below a resource node is selected, the list of fields is shown. You can double click a field, and the selected field will be shown for editing.
- When a field node is selected, the field editor is shown.
Changes to a current node are automatically saved when selecting another node.
A double click on a selected node will show the same editor as selecting a node, but in a modal dialog.
You can add new resources by dragging them from the connections, or using the 'Add resource' button. The 'expose connection' above the list of connections will add all tables of a connection to the schema.
The menu allows several actions:
- Read connections Loads a list of connection details from an .ini file.
- Write connections Saves the list of connections shown in the left panel to an .ini file.
- New schema Creates a new empty schema.
- Load schema Loads a schema file and displays the resources.
- Save schema Saves the resources to a schema file.
- Recent schemas a MRU menu with recently loaded or saved schema files.
- Quit exits the program.
A schema file has the .srs extension, but this is not obligatory. It is a JSON file created by the SaveToFile method of the TSQLDBRestSchema class, and can be loaded with the LoadFromFile method.
The resource editor is shown when a resource is selected in the available resources tree. It looks as follows:
The various edits correspond to the properties of the TSQLDBRestResource class.
The 4 tabs at the bottom can be used to edit the SQL Statements.
The SELECT statement can be automatically generated from the table name. The entered statement can also be validated, to check if the SQL is correct. When the SQL SELECT Statement has changed, the list of published fields can be automatically refreshed using the 'Update Fields' button. This will reset the fields list, so any adjustments that were made to the list of fields will be lost.
The last tab displays the list of fields defined for the resource.
This list should be identical to the list in the treeview. Double-clicking a field will display the field editor.
The field editor shows the properties of a selected field. These are the properties of the TSQLDBRestField class. It looks as follows:
The fields editor is shown when the 'Fields' node is selected in the resource tree. It is currently read-only, and looks as follows:
Double clicking a field will take you to the field editor for the selected field.