Classes dictionaries
This document describes how a class can be declared by filling the class dictionary. This is a global description explaining how a class can be declared before it is used. A detailed description of the class dictionary can be found in Workbench reference Class Management.
Global Information | Methods and Operations | Mapping | Miscellaneous | Class Validation | Collections | Properties |
In Sage X3, a function designed with version 7 supervisor tools manages data classes. A class is a data structure managing properties and behaviors.
Creating a class is performed in the class dictionary. After a class is declared, it can be instantiated to be used. If the class instance is called CLASSINST, the property PROP1 of the instance will be accessed with the CLASSINST.PROP1 syntax.
A class is defined with the following characteristics:
This section describes the type of class that defines how the class is managed. It can use the following values: Persistent, Basic, Interface, Technical, and System. The following table summarizes the different characteristics of these classes:
Type of class | CRUD methods available | GET / CONTROL / PROPAGATE methods (also called accessors) available on properties | Can methods and operations be defined? | Snapshot management | Comment |
---|---|---|---|---|---|
Persistent | Yes | Yes | Yes | Yes, automatic | Associated to a main table |
Interface | Yes | Yes | Yes | Yes, but has to be managed by developer code | Used for CRUD-like operation on data not persisted in database (for example, logfile and processes in memory) |
Basic | No | Yes | Yes | Yes, but has to be managed by developer code | Used for child classes of persistent classes when the CRUD code is managed by the parent class |
Technical | No | No | Yes | No | |
System | No | No | No | No | For public classes: only direct access to properties is possible |
In every class definition, there is also a grid in which a collection of ordered scripts files can be entered. These scripts files are used by the development partners to add business logic to default logic involved by the class definition. Two dedicated labels, called $PROPERTIES
and $METHODS
, are invoked in these scripts (in the rank order of the scripts). This is the event mechanism that gives to standard, vertical, and specific code developers the ability to add dedicated code on a list of events (defined by the value of a variable called ACTION
). For detailed information, see Developer Guide Classes Events.
On persistent or interface classes, standard methods are supported by the supervisor. This includes the CRUD methods creation, read, update, and delete. For the persistent classes, the corresponding code can be generated and called by the supervisor layers if the corresponding check boxes have been set in the classes dictionary. These standard methods are defined in a dedicated section.
Other methods can be added, but will require additional code to be written for execution. Another section in the dictionary describes these methods as well as operations associated with the class.
Operations are described in the same manner as methods, but they also require additional information as there is no context when they are called (at least, the information needed to create and feed an instance of the class to perform the operation requested).
It defines how the CRUD operations, if they exist, are linked to the database tables for the main instance of the class, and the instances of child classes.
For every database table, you can define whether the code supporting the CRUD operation is created at validation time and are automatically called (check boxes are available for every method).
This defines filtering options on data set managed by the class.
After a class is created, the validation of the class will automatically generate codes that make the use of the class possible. The code is generated in a script file named 'C_classname.stc', where classname is the class name.
The code associated with methods used or operations in the class is generated in this script file, but includes a Gosub $PROPERTIES
or Gosub $METHODS
call to events. The different values for ACTION
are provided in Developer Guide Classes Events.
In a class, collections can be defined when properties have multiple value occurrences. A collection can be associated to a list of fields or to a reference to a child instance. When a collection is associated to a list of fields, an intermediate class instance is created with the name of the collection. The individual fields present in the collection cannot have the same name as the collection.
For example, if in a class instance called 'CLASSINST', a collection called 'DISCOUNT' includes two fields (a numerical field called 'RATE' and a char field called 'PAYTERM'), an intermediate 'DISCOUNT' instance will be created, and the 3rd. rate will be accessed with the following syntax:
CLASSINST.DISCOUNT(3).RATE
A class includes properties that can be simple fields, references to other entities usually managed by classes, or child classes instances. All these elements can also be a member of a collection. The difference between a reference and a child class is the following:
Any property associated with a collection code is implemented as a child class.
Child classes can be defined with four different relation types:
Relationship type | Collection characteristics | Array methods (ADDLINE, ADELLINE) available | Comments |
---|---|---|---|
(0,1) | Minimum= 0 and Maximum= 1 | Yes | The property is an instance of a class |
(1,1) | No collection code | No | |
(0,N) | Minimum= 0 and Maximum= N. If N is 0, N can be unlimited | Yes | Two things can happen: 1) The property is an instance of a class. 2) The property is a member of a set of properties with the same collection code. This collection is implemented as a technical class instance identified by the collection code. |
(1,N) | Minimum= 1 (or more) and Maximum= N. If N is 0, N can be unlimited | Yes | The supervisor does not control whether a line is present. Two things can happen: 1) The property is an instance of a class. 2) The property is a member of a set of properties with the same collection code. This collection is implemented as a technical class instance identified by the collection code. |
From a user interface view, a collection of properties is presented with the following rules: