// Entity Driver
// Defines a person who is able to drive a car
Driver {
id : long { @Id } ;
firstName : string { @SizeMax(20), @NotEmpty } ;
lastName : string { @SizeMax(20), @NotEmpty } ;
birthDate : date { @Past };
certified : boolean ;
}
// Entity Car
Car {
id : int { @Id, @AutoIncremented } ; // this id is autoincremented
name : string { @SizeMax(40) } ;
year : short { @Min(1900),
@Max(2020) } ;
price : float { @Min(500), @Max(99999) };
brand : Brand { @NotNull } ;
driver : Driver[] ;
}
Comments
A comment starts with "//"
All the end of line is the comment
Comments are only "single line"
Entity structure
The entity's structure is composed of the entity name
followed by a block containing all the entity's attributes.
The block of attributes starts with '{' and ends with '}'.
"End Of Line" characters are not significant. They are used only for readability.
Potentially all the entity can be described in a single line.
Structure :
EntityName {
// attributes list
}
Entity name
The entity name can be composed of : letters, numbers, "_" (underscore)
Other characters are not allowed.
By convention the name usually starts with an upper case character.
The entity name must be the same as the file name ( "Car.entity" => "Car" ).
Examples of valid entity names :
. Car
. Car123
. CarOwner
. Car_owner
Examples of invalid entity names :
. Car#12 ( "#" not allowed )
. Car+Owner ( "+" not allowed )
Attribute structure
An attribute structure is composed of
. attribute name
. ":" separator
. attribute type (basic type or reference)
. optional annotations defined between '{' and '}'
. ";" separator (closing the attribute definition)
Structure :
attributeName : attributeType { annotations } ;
An attribute definition can span over multiple lines
Attribute name
The attribute name can be composed of : letters, numbers, "_" (underscore).
Other characters are not allowed.
By convention the name usually starts with a lower case character.
Examples of valid attribute names :
. age
. firstName
. first_name
. flag12
Examples of invalid attribute names :
. flag#12 ( "#" not allowed )
. first-name ( "-" not allowed )
. $code ( "$" not allowed )
Attribute type
The attribute type can be a "basic type" or a "reference to another entity".
A "basic type" is a "neutral type" independent of any programming language.
Available basic types :
. binary
. boolean
. byte
. date
. decimal
. double
. float
. int
. long
. short
. string
. time
. timestamp
All of these "neutral types" are converted into the target language types during generation.
Telosys offers automatic conversion for most used languages (Java, C#, etc).
A "reference" is defined by using an entity name instead of the basic type.
The referenced entity must exist in the model (at least the entity file).
To reference a collection of entities just add "[ ]" after the entity name.
Examples :
. Driver (to reference a single Driver instance, "0..1" cardinality)
. Driver[ ] (to reference a collection of Driver instances, "0..N" cardinality)
Attribute annotations
Each attribute can have 0 to N annotations.
Annotations provide additional information usable during the code generation.
An annotation is a predefined word starting with "@".
Some annotations may have values specified between "(" and ")".
All the annotations must be enclosed between "{" and "}"
Available annotations :
. @AutoIncremented : the attribute is supposed to be auto-incremented (typically for a key, with "@Id" annotation)
. @Embedded : the entity referenced by the attribute must be embedded (typically for NoSQL databases)
. @Future : the attribute value (for "date" type) must be in the future
. @Id : the attribute is the ID for the current entity (only one @Id annotation in the same entity)
. @LongText : the attribute value (for "string" type) is a long text (typically for a "text area" or "CLOB")
. @Max(int value) : the attribute max value (for numeric types)
. @Min(int value) : the attribute min value (for numeric types)
. @NotBlank : the attribute value cannot be blank
. @NotEmpty : the attribute value cannot be empty
. @NotNull : the attribute value cannot be null
. @ObjectType : the attribute basic type must be converted to "object/wrapper type" (if possible with the target language)
. @Past : the attribute value (for "date" type) must be in the past
. @PrimitiveType : the attribute basic type must be converted to "primitive type" (if possible with the target language)
. @SizeMax(int value) : the attribute max size (typically for input field or string size)
. @SizeMin(int value) : the attribute min size (typically for input field or string size)
. @SqlType : the attribute basic type must be converted to "sql type" (typically for Java language)
. @UnsignedType : the attribute basic type must be converted to "unsigned type" (if possible with the target language)