The MySQL code generator is a plug-out directly written in C++.
The generated sources follows the definition made in BOUML at the artifact / class / relation / attribute levels.
When the code generation is applied on a artifact associated to several tables, the code generation is made for all these tables, more the possible definition of the database. Nevertheless the the MySQL code generator produce first the code in memory and update the appropriate files only when it is necessary, to not change the last write date of the files for nothing. Depending on the toggle verbose code generation of the global menu Languages the code generator is verbose or not.
The MySQL code generator plug-out may be called on :
a class : in this case the code generation is in fact applied on the class's artifact, then on all the classes associated to this artifact
a artifact : in this case the code generation is in fact applied on all the classes associated to the artifact
a class view : the code generation will be applied on all the sub classes, then on all the artifacts associated to these classes
a deployment view : the code generation is applied on all the sub artifacts
a package (may be the project itself) : the code generation will be applied on all the sub class views and deployment views, then on all their sub classes and artifacts.
When the MySQL code generator is ask through the Tools menu, it is applied on the project, then on all the artifacts.
The name of the generated files depend on the artifact name, the extension depend on the language and is fixed for each by the generations settings (see below), the directory where the files are generated may be set in each package containing directly or indirectly the artifact (see generation directory).
The MySQL definition of a artifact is set through the Php source tabs of the artifact dialog.
The MySQL code generation is only done when the stereotype of the artifact is database
The generated file name is the artifact's name with the extension specified in the MySQL of the generations settings :
In BOUML the generated code is obtained by the substitution of macros in a text, the macros known by the Php code generator are :
${NAME} produce the artifact name capitalized, ${Name} produce the artifact name with the first letter capitalized, ${nAME} produce the artifact name forced in lowercase, at least ${name} produce the artifact name without modification.
${comment} is replaced by the artifact description adding # at the beginning of each line
${description} is replaced by the artifact description without adding #
${definition} is replaced by the definition of the tables and extra artifact definitions associated to the artifact.
@{xyz} is replaced by the user property value in case xyz is the key of this property. The property if searched first for the artifact, if not found for the deployment view containing the artifact, if not found in the package containing the deployment view etc ...
The MySQL definition of a class produce a table, it is set through the Uml, and MySQL tabs of the class dialog.
In BOUML the generated code is obtained by the substitution of macros in a text, the macros known by the Php code generator are :
${name} is replaced by the class's name
${definition} is replaced by the code generated for all the class's members (relations, attributes, operations and extra members) following the browser order.
${comment} is replaced by the description of the class as a string between '' after the keyword COMMENT quoting the characters if necessary
${description} is replaced by the description of the class as a string between '' after the keyword COMMENT without looking if it is necessary to quote the characters
@{xyz} is replaced by the user property value in case xyz is the key of this property. The property if searched first for the class, if not found for the container of the class (an other class of a class view) etc ...
The MySQL definition of an attribute is set through the Uml and MySQL tabs of the attribute dialog.
An attribute may be a column or a non foreign key.
In BOUML the generated code is obtained by the substitution of macros in a text, the macros known by the MySQL code generator are :
${name} is replaced by the attribute's name (see the UML tab)
${type} is replaced by the type of the attribute including the size when it is set
${notnull} is replaced by NOT NULL when it is set
${autoincr} is replaced by AUTO_INCREMENT when it is set
${default} is replaced by the initial value of the attribute (see the UML tab) in a string between '' after the keyword DEFAULT, as usual nothing is generated if the attribute doesn't have a default value
${comment} is replaced by the description of the class as a string between '' after the keyword COMMENT quoting the characters if necessary
${description} is replaced by the description of the class as a string between '' after the keyword COMMENT without looking if it is necessary to quote the characters
@{xyz} is replaced by the user property value in case xyz is the key of this property. The property if searched first for the attribute, if not found for the class containing the attribute etc …
${stereotype} is replaced by the stereotype (see the UML tab), probably for a documentation purpose
In BOUML the generated code is obtained by the substitution of macros in a text, the macros known by the MySQL code generator are :
${constraint} is replaced by the constraint
${modifier} adds the optional prefix depending on the kind of the key, allowing to have a simple key or a primary / unique / fulltext / spacial key
${name} is replaced by the attribute's name (see the UML tab)
${type} is replaced by the specified type of the key (nothing, USING BTREE or USING HASH)
${columns} is replaced by the columns of the key between ( )
${ref} produces nothing, it is relevant only for the foreign keys (relation)
${stereotype} is replaced by the stereotype (see the UML tab), probably for a documentation purpose
${comment} is replaced by the description of the class as a string between '' after the keyword COMMENT quoting the characters if necessary
${description} is replaced by the description of the class as a string between '' after the keyword COMMENT without looking if it is necessary to quote the characters
@{xyz} is replaced by the user property value in case xyz is the key of this property. The property if searched first for the attribute, if not found for the class containing the attribute etc ...
The MySQL definition of a relation is set through the Uml and MySQL tabs of the relation dialog. A relation represents a foreign key.
In BOUML the generated code is obtained by the substitution of macros in a text, the macros known by the MySQL code generator are :
${constraint} is replaced by the constraint
${modifier} is not managed here, it is relevant only for the non foreign keys (attributes)
${name} is replaced by the attribute's name (see the UML tab)
${type} is not managed here, it is relevant only for the non foreign keys (attribute)
${columns} is replaced by the columns of the key
${ref} is replaced by the keyword REFERENCES then the columns associated to the referenced key between ( ), then if specified the stereotype after the keyword MATCH, then by the optional delete / update actions
${comment} is replaced by the description of the class as a string between '' after the keyword COMMENT quoting the characters if necessary
${description} is replaced by the description of the class as a string between '' after the keyword COMMENT without looking if it is necessary to quote the characters
@{xyz} is replaced by the user property value in case xyz is the key of this property. The property if searched first for the attribute, if not found for the class containing the attribute etc ...
Previous : Idl generator
Next : MySQL reverse