ORM

Main interface
Database structure synchronization
Data preview
Data backups
Creating and editing ORM objects
- configuration
- indexes
- fields
Additional interface elements
Dictionaries
Database connections
Object import

ORM Management Interface

Allows for maintaining the system objects. ORM objects validate input data as well as the relations on their own.

The main interface

The main interface shows information on the existing system objects:

  • Title - object title;
  • Object - object name;
  • Data table - the name of the table in the database;
  • DB Engine - the type of database storage;
  • Properties - the number of object properties;
  • Вb Status - the storage status:
    • Records - the number of records in the database;
    • Data size;
    • Index size;
    • Space usage - the space used;
  • Version control - defines whether the object is versioned or not;
  • Valid DB - defines whether the database corresponds to the object structure;
  • Is System - defines whether the object is a system object.

The object may be edited by clicking twice on the corresponding line in the table of objects or by clicking the icon, while the icon will delete the object.

Please keep in mind that deleting an object will also delete the related table from the database.

Database Structure Synchronization

The button marked by the icon in every line is used to rebuild the structure of the database table if it is not valid. Besides, there is the “Build All” button in the upper menu.

Data Preview

The button marked by the  icon in every line is used for previewing and editing DB data without creating a special visual interface. It opens the following interface:

Data Backups

To backup the ORM data, it is enough just to click the button. The copies will be zip archived by default, however, if the necessary extension has not been set up on your server, the copy will be saved into a folder the regular way. Copies of both the types can be restored. The backup copy includes system objects, dictionaries, sql dump.

To restore the previously saved system version, click the button. A window listing the available copies will show up. Upon selecting the necessary one and clicking 'Restore', you will be able to specify whether to restore the saved sql database dump or just to copy the system files.

The mechanism creating backups is temporarily disabled in o.9.1 and 0.9.2 releases due to changes in ORM architecture (external tables support added). The feature will be restored in 0.9.3 - 0.9.4 releases.

Creating and editing ORM objects

To create an object in the ORM interface, click 'Add object'. In the first place, describe the object configuration:

Configuration

  • Version control – a checkbox used to enable/ diable the document version control, which makes it possible to switch between versions after a new document modification has been added, publish an old document version, modify or create new versions based on the old ones (more details on document version control may be found in the respective chapter);
  • History log – a checkbox defining whether the object actions are to be logged;
  • Object name - alpanum symbols and the underscore sign may be used;
  • Title – the object name to be displayed in user interfaces;
  • Table name – the name of database table (a system prefix will be added automatically);
  • Table engine – the type of database storage (when using InnoDb, ORM will use transactions while dealing with the objects);

Please pay attention that the type of storage may limit the number of allowed field types and indexes.

  • Field used as title for link – a field used as a title when displaying links to the object.
  • Database Connection – selecting a database connection;
  • Primary Key – the primary key of a database table;
  • Use DB Table Prefix – a checkbox used to allow a prefix in table names. It affects the table name input and allows using various prefixes for different application setups. It also boosts the application security. If the checkbox is not ticked, the table name is to be entered the following way: prefix_tablename. Otherwise, it is just tablename.
  • Read Only – a checkbox used to prevent ORM from making changes in a database table;
  • Lock Table Structure – a checkbox preventing ORM from changing the database structure, but allowing to read and write data.

Upon successfully saving the object, there become available additional tabs such as Fields and Indexes.

Indexes

The Indexes tab shows information on the existing indexes.

User indexes may be edited by clicking the icon and may be removed by clicking the icon. Here, we also see system indexes, which have the sign and can't be edited or removed. The number of system fields may vary depending on the object configuration.

Field indexes are added upon clicking the 'Add index' button. Therein, a window shows up:

  • Name – index name;
  • Columns – a field with a button on the right opening a list of all available fields of the object being modified. There might be several fields selected for indexing;
  • Unique – a unique index;
  • Fulltext – a fulltext index.

Fields

The 'Fields' tab shows the information on the existing fields.

User fields may be edited by clicking the button or removed by pressing . Here, we can also see system fields, which have the by the side and can't be edited or removed. The number of system fields may vary depending on the object configuration.

Each object contains 'ID' system field - unsigned integer autoincrement.

Versioned objects contain additional system fields:

  • author_id – the identifier of the User, who has created the record;
  • date_created – the date of record creation;
  • date_published - the date of record publication;
  • editor_id – the identifier of the User, who was the last to edit the document;
  • published – states whether the document has been published or not;
  • published_version – a published document version.

The 'Type' field displays the type of the object field and may contain regular types (such as int, char and others) as well as link (specifies the object, which the field links to) and dictionary link (specifies the dictionary, which the field links to). Besides, clicking the dictionary link will open the window for editing the dictionary, which the field links to.

Fields are added by clicking the 'Add field' button. Therein, a window shows up:

General fields:

  • Field name – the name of the field (alphanum + _) in the database;
  • Field title – the name of the field in the interface;
  • Unique Group – the name of a group of unique fields (a unique ORM index may serve for one as well as for several fields, just specify one group if necessary).

Depending on the Field Type selected, the following fields become available:

- Standart field – standard database fields; additional settings become available as per the field type selected:

  • int, bigint, bit, tinyint, smallint, mediumint:
    • Validator;
    • Default;
    • unsigned;
    • Required;
    • IsNull;
  • datetime, date, timestamp, time:
    • IsNull;
    • Validator;
    • Required;
  • boolean:
    • Default;
    • IsNull;
  • char, varchar:
    • Validator;
    • DB length;
    • Default;
    • Allow HTML;
    • isSearch;
    • Required;
    • IsNull;
  • tinytext, text, mediumtext, longtext:
    • Validator;
    • Allow HTML;
    • isSearch;
    • Required;
    • IsNull;
  • float, double, decimal:
    • Validator;
    • scale;
    • precision;
    • Default;
    • unsigned;
    • Required;
    • IsNull.

- Link – a link, which might be a link to an object, a multilink to an object, a link to the dictionary definition (a certain list, which is defined also in the ORM chapter), whereas links may also be characterized as 'required'.

Settings definitions:

  • IsNull (e.g. NULL) – whether the field value may be null;
  • Required - the field is required;
  • isSearch – the field may be used for string search;
  • Allow HTML – the field allows for storing the HTML-code;
  • scale - the length of the text representation (the overall number of symbols)
  • precision - the number of symbols of non-integral part;
  • unsigned – with no signs;
  • Validator – it is possible to choose a validator to check the data stored in the field; if the checkup fails, the data won't be saved, you are also free to write your own validators (more details on this will follow);
  • Default – a default value;
  • DB length.

Additional interface elements

  • Add object – please see above;
  • Dictionaries – dictionaries, please find more details below;
  • Object Map – clicking this button will open a window with a UML diagram of the system object relations;
  • Database connections - setting up external DB connections;
  • Connect external DB table - interface for connecting external DB tables;
  • Show log.

Dictionaries

Clicking the Dictionaries button will open the window for managing the system dictionaries:

A dictionary may be added by clicking the 'Add' button, which will open a window for entering the dictionary name. The dictionary may be removed by clicking the icon.

Please keep in mind when removing a dictionary that the existing data is not being validated over again, which may consequently lead to a situating when a record is linking to a dictionary, which no longer exists.

To rename a dictionary, select one from the list and click the 'Rename' button.

To view and edit the dictionary, select the one you need and wait for its parameters to show up in the right-hand part of the window. A single click on the cell will enable you to edit the value. To add another line, click 'Add' in the right-hand side of the window. A new line will show up enabling you to modify it as per the above instructions.

A dictionary record may be removed by clicking .

Unlike editing, removing dictionary records comes into action immediately after the confirmation has been received.

Please note that the record keys are to be unique. The updated cells have a red triangle in the left-hand top corner. The modifications are saved only upon clicking Save. If this has not been done and another dictionary is selected or the window is closed, the updates will get lost.

Database Connections

The interface allows to set up external database connections. Please note that a separate connection should be set up for each system operating mode. Thus, connections in various modes have a common name, but different settings.

Object Import

ORM management interface allows to import objects from external databases. Herewith, a file describing the object structure (meta data) is the only thing created on the server side, while the data is provided by the database specified in the connection settings. Thus, external databases can be easily connected. To avoid changes in an external database, such ORM object settings as readonly / lock table structure should be used.