Products Downloads


French version


 

This object is used to describe a typical structure made of simple Adelia types, arrays and classes.

The class has a 4GL source used to describe all of its attributes.


The Adelia source of the class can be modified via the 4GL editor.


Like the other objects of the Adelia repository, the class can be created, modified, copied, deleted, etc.


It therefore has its own life cycle: correction setting, rights management, etc.


Once created, the class can be handled in Visual Adelia Batch programs to be generated as a RESTful Web service or in Visual Adelia programs to be generated in Adelia Cloud.

The class can be handled via the REF_CLASS declarative instruction and via the NEW instance creation operator.


To be usable in execution, the class must be generated in the form of a POJO (Plain Old Java Object).



Adelia syntax of a class

Class

-> *ATTRIBUTES SerClsOptions { Attributes }


SerClsOptions

-> SerClsOption SerClsOptions



-> nothing


SerClsOption

*SER_NAME('ElemName'):



-> *SER_DESC('Description')


Attributes

-> Attribute AttributesSeries


SeriesAttributes

-> Attribute AttributesSeries



-> nothing


Attribute

-> DefAttribute SerOptions


DefAttribute

-> ALPHA (n)

AttributeName


-> NUM_E(x,y)

AttributeName


-> NUM_BIN_2

AttributeName


-> NUM_BIN_4

AttributeName


-> NUM_BIN_8

AttributeName


-> BOOL

AttributeName


-> DATE

AttributeName


-> TIME

AttributeName


-> TIMESTAMP

AttributeName


-> IMAGE

AttributeName


-> REF_CLASS(class)

AttributeName


-> REF_LDM(entity)



-> REF(LogicalProperty Entity)

AttributeName

SerOptions

-> SerOptions SerOptions



-> nothing


SerOption

-> *SER_NAME('ElemName')



-> *SER_OPTIONAL



-> *SER_OPTIONAL('DefaultVal')



-> *SER_MODE(SerMode)



-> *SER_WRAPPER('WrapperElemName')



-> *SER_DESC('Description')



-> *SER_EXAMPLE('Value')



-> *SER_EXAMPLE()

SerMode

-> *VERBOSE



-> *COMPACT



The various attributes of the class are separated by a semicolon.


A comment starts with "/*" and finishes with "*/".


REF_CLASS makes it possible to include a subclass as an attribute.

You can specify *OBJECT as a class name (ClassName) in order to include a generic subclass (object) as an attribute.


REF_LDM is used to set as attributes all logical properties referring to the specified entity.


REF is used to define an attribute referring to an LDM logical property and logical entity.


Additionally, each attribute can be a one- or two-dimensional array.


In the case of a one-dimensional array, the size cannot be specified in the declaration of the attribute, using the syntax () without specifying a number.

For example: NUM_BIN_2 AttributeBin2DynamicArray();


This table can be dynamically allocated (via the order NEW) if necessary, its size can be consulted via the predefined function &ARRAY_DIM the number of elements can be consulted via the predefined function &NBR_ELT.

In addition, it will be possible to add an element at the end of the array, thanks to a setter and to the *LAST index.


Specific information can be provided on each attribute to adapt the XML/JSON serialization of an Adelia class.

  • *SER_NAME('ElemName'): By default, the serialization uses the class name or attribute name as an element name. The *SER_NAME directive is used to change this name.
  • *SER_OPTIONAL or *SER_OPTIONAL('DefaultVal'): By default, an element is always presented as required. The *SER_OPTIONAL directive is used to describe an element as optional by possibly assigning it a default value (apart from for the IMAGE type).
    Values are always in quotes. For DATE, TIME and TIMESTAMP types, values must be in ISO format. The BOOL type takes 'true' or 'false' values.

  • *SER_MODE: This directive is used to choose a serialization mode. This directive is currently only applicable to IMAGE type with one of the following two options:
    • *VERBOSE: default mode before V13 PTF07 Fix01. This mode is now depreciated, only to be used to ensure compatibility with an existing one.
    • *COMPACT: default mode from V13 PTF07 Fix01. IMAGE type is serialized in the form of a single element with a base64-encoded string value.
  • *SER_WRAPPER: In the case of XML serialization, this is used to add an encompassing element of the specified name for ARRAY-type attributes. For JSON serialization, this directive gives the same result as the *SER_NAME directive.
  • *SER_DESC: Used to associate a description (for the class or class attribute) for presentation in swagger.
    • *SER_EXAMPLE: Used to associate an example value for the attribute; this example value is used in swagger. 

      Values are always in quotes. For DATE, TIME and TIMESTAMP types, values must be in ISO format. The BOOL type takes 'true' or 'false' values. For the IMAGE type, pass a base64-encoded string (up to 5000 characters).
      If no value is specified [*SER_EXAMPLE()], an example value is generated by default.


      Note: ARRAY-type attributes cannot benefit from an example value.


↑ Top of page

Example 4GL sources of classes

*ATTRIBUTES

{

ALPHA(31)       Surname;

ALPHA(32)       Firstname;    

DATE                DateBirth *SER_OPTIONAL('1901-01-01');

TIME                 TimeBirth *SER_OPTIONAL('01:01:01');

TIMESTAMP     TMSBirth *SER_OPTIONAL('1901-01-01T01:01:01.000');

BOOL               Emma *SER_OPTIONAL('true');


}

}


*ATTRIBUTES

{

/* Free comment possible */

REF_CLASS(PERSON)        Father;

REF_CLASS(PERSON)        Mother;

ALPHA(32)                            Address;

NUM_E(8,2)                          Size1;

NUM_P(8,3)                          Size2;

NUM_BIN_4                          PostCode*SER_OPTIONAL('38000');

NUM_BIN_4                          MyArray1D(11);

ALPHA ( 13 )                         MyArray2D(11);

NUM_E ( 6 , 0 )                     MyArrayInfinite();

REF_CLASS(PERSON)       ChildrenArray();

ALPHA ( 31 )                         CarsArray(5);

REF_LDM(STOCK);

}


*attributes

{

ALPHA(15)    Brand;

ALPHA(250)  Model;

REF(LP_NBHP LENT_CARDEF) NbHp;

NUM_BIN_2  NbHp;

DATE             DatePurch;

}


*ATTRIBUTES *SER_NAME('NameModel') *SER_DESC('Definition of a person')

{

ALPHA(31)        Name *SER_NAME('LastName') *SER_DESC('Person's last name');

ALPHA(32)        FirstName *SER_NAME('FirstName') *SER_DESC('Person's first name');

ALPHA(15)        Country *SER_NAME('Country') *SER_OPTIONAL('France');

IMAGE              Picture *SER_MODE(*VERBOSE) *SER_DESC('Person's profile picture');

REF_CLASS(PERSON)   TableChildren() *SER_WRAPPER('Children') *SER_NAME('Child') *SERC_DESC ('Person's children');

}

↑ Top of page

  • Aucune étiquette