Define Metadata
Before generating codes, you need to create the metadata of you Aggregate Root inside the metadata folder. Inside the latter, you can find the XML grammar “DomainDrivenDesign.xsd” inside the templates folder.
1. Example
Here an example, we have the Student AR with 2 Children (Grade and Diploma) and the Foreign Key CLUB.
<?xml version="1.0" encoding="UTF-8"?>
<DomainModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="templates/DomainDrivenDesign.xsd">
<AggregateRoot
Namespace="ClassManagement"
ClassName="Student"
ClassIdentityProperty="IdStudent"
TableName="students"
TableIdentityColumn="IdStudent"
PluralName="Students"
>
<DefiningProperties>
<Property Name="FirstName" Column="FirstName" Type="string" Label="Nom"/>
<Property Name="LastName" Column="LastName" Type="string" Label="Prénom" />
<Property Name="Birthdate" Column="Birthdate" Type="date" Label="Date de naissance" />
</DefiningProperties>
<Properties>
<Property Name="Gender" Column="Gender" Type="integer" Label="Sexe"/>
<Property Name="RegistrationDate" Column="RegistrationDate" Type="datetime" Label="Date d'inscription" />
<Property Name="Photo" Column="Photo" Type="upload" Label="Photo" />
</Properties>
<ForeignKeys>
<ForeignKey
ForeignKeyProperty="IdClub"
ForeignKeyTextProperty="club"
ForeignKeyColumn="IdClub"
ParentClass="Club"
ParentPlural="Clubs"
ParentIdentityProperty="IdClub"
ParentDefiningProperty="Name"
ParentTable="clubs"
ParentIdentityColumn="IdClub"
ParentDefiningColumn="Name"
Label="Club"
Namespace="ClassManagement"
uiUrlDataSource="/clubs/combo"
uiSelectMode="select"
uiDefaultLabel="Choisir un club"
/>
</ForeignKeys>
<Collections>
<Collection
ClassName="Grade"
ClassIdentityProperty="IdGrade"
TableName="grades"
TableIdentityColumn="IdGrade"
CollectionName="grades"
Cardinality="OneToMany"
ExposedName="grades"
TableParentForeignKey="IdStudent"
TabTitle="Notes"
>
<Property Name="Subject" Column="Subject" Type="string" Label="Matière"/>
<Property Name="Score" Column="Score" Type="float" Label="Note" />
</Collection>
<Collection
ClassName="Diploma"
ClassIdentityProperty="IdDiploma"
TableName="diplomas"
TableIdentityColumn="IdDiploma"
CollectionName="diplomas"
Cardinality="OneToMany"
ExposedName="diplomas"
TableParentForeignKey="IdStudent"
TabTitle="Diplômes"
>
<Property Name="Name" Column="Name" Type="string" Label="Diplôme"/>
</Collection>
</Collections>
<UserInterface>
<List Title="Liste des étudiants" />
<Form
CreationTitle="Nouveau étudiant"
UpdateTitle="Modification étudiant"
/>
</UserInterface>
</AggregateRoot>
</DomainModel>
<?xml version="1.0" encoding="UTF-8"?>
<DomainModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="templates/DomainDrivenDesign.xsd">
<Entity
ClassName="Grade"
ClassIdentityProperty="IdGrade"
TableName="grades"
TableIdentityColumn="IdGrade"
CollectionName="grades"
ParentAggregateRootName="Student"
ParentNamespace="ClassManagement"
>
<DefiningProperties>
<Property Name="Subject" Column="Subject" Type="string"/>
<Property Name="Score" Column="Score" Type="float" />
</DefiningProperties>
</Entity>
</DomainModel>
<?xml version="1.0" encoding="UTF-8"?>
<DomainModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="templates/DomainDrivenDesign.xsd">
<Entity
ClassName="Diploma"
ClassIdentityProperty="IdDiploma"
TableName="diplomas"
TableIdentityColumn="IdDiploma"
CollectionName="diplomas"
ParentAggregateRootName="Student"
ParentNamespace="ClassManagement"
>
<DefiningProperties>
<Property Name="Name" Column="Name" Type="string"/>
</DefiningProperties>
</Entity>
</DomainModel>
<?xml version="1.0" encoding="UTF-8"?>
<DomainModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="templates/DomainDrivenDesign.xsd">
<AggregateRoot
Namespace="ClassManagement"
ClassName="Club"
ClassIdentityProperty="IdClub"
TableName="clubs"
TableIdentityColumn="IdClub"
PluralName="Clubs"
>
<DefiningProperties>
<Property Name="Name" Column="Name" Type="string" Label="Nom"/>
</DefiningProperties>
<UserInterface>
<List Title="Liste des clubs" />
<Form
CreationTitle="Nouveau club"
UpdateTitle="Modification club"
/>
</UserInterface>
</AggregateRoot>
</DomainModel>
We have a single generic root, “DomainModel”, whose children are either an Aggregate Root or an Entity
* in property name means that the property is required.
2. AggregateRoot, Entity
AggregateRoot tag
| Property name | Description |
|---|---|
| Namespace | Namespace or package (for java) under which to put this root aggregate. |
| ClassName* | Name of aggregate root or entity. |
| ClassdIdentityProperty* | Property unique for identifying the object. |
| TableName* | Name of the database table in which the aggregate root or entity is stored. |
| TableIdentityColumn* | Name of the identifier in the database table on which the aggregate root or entity is based. |
| PluralName* | Plural form of the aggregate root name. Used to generate class and file names such as for controllers, repository, finder and list view. |
Entity tag
| Property name | Description |
|---|---|
| ClassName* | Name of aggregate root or entity. |
| ClassIdentityProperty* | Property unique for identifying the object. |
| TableName* | Name of the database table in which the aggregate root or entity is stored. |
| TableIdentityColumn* | Name of the identifier in the database table on which the aggregate root or entity is based. |
| CollectionName* | Name the collection of children's objects. |
| ParentAggregateRootName* | Name of the parent root aggregate containing this entity. |
| ParentNamespace | Namespace of the parent root aggregate. |
3. Base type
AggregateRoot and Entity have base types with common denominators.
DefiningProperties tag
A list of mandatory properties that define the entity, required in its constructor. Each property must be assigned a value. The identifier is already specified elsewhere and no longer needs to be listed.
| Property name | Description |
|---|---|
| Name* | Property name in class |
| Column* | Property name in database |
| Type* | Enumeration that can take the values: boolean, integer, float, decimal, string, date, time, datetime, password, upload, enum, telephone, email. |
| Label | Text used in the UI, such as for field labels, especially for column names in tables and for inputs |
| CategoryColumn | Name of the column that categorize the entity, to specify that the field with it is used to categorize the entity. |
Properties tag
These are the other properties that are not mandatory in the constructor. It contains the list of optional properties of the entity, and filling in an optional property is not mandatory.
The propertyType is the same as in DefiningProperty
ForeignKeys tag
This is the list of entity properties that refer to a parent object.
| Property name | Description |
|---|---|
| Namespace* | Namespace or package (for java) under which to put this root aggregate. |
| ForeignKeyProperty* | The name of the key property to be exposed |
| ForeignKeyTextProperty* | The name of the string property under which the unencrypted reference is displayed |
| ForeignKeyColumn* | The name of the foreign key column in the table (not in the source table!) |
| ParentClass* | The source class where to find the value to be copied |
| ParentPlural* | The plural name of the source class, for example, can be used to reconstruct the name of its Finder. |
| ParentIdentityProperty* | The identity property of the source class |
| ParentDefiningProperty* | The property in the source class whose value is to be copied |
| ParentTable* | The reference table |
| ParentIdentityColumn* | The identifier column in the reference table. Useful for <select><option value=“%here%”/></select>, among other things. |
| ParentDefiningColumn* | The column representing the reference table. Useful for <select><option/>%here%</option></select>, among other things. |
| Label | Text used in the UI, such as for field labels, especially for column names in tables and for inputs |
| uiUrlDataSource | url of endpoint used to retrieve select data |
| uiSelectMode | Enum: select, radio. By default, select is used if none is specified |
| uiDefaultLabel | The text used for the default option. For example, you have any select, which consists of 2 options, but allow the user to choose nothing. |
| uiBooleanState | Use to indicate the boolean state, either 2 states or 3 states . Only for boolean input. |
| CategoryColumn | Name of the column that categorize the entity, to specify that the field with it is used to categorize the entity. |
Collections tag
Exists only for an Aggregate Root. This is the list of existing child collections for this aggregate root.
| Property name | Description |
|---|---|
| ClassName* | The name of the child class in the collection |
| ClassIdentityProperty* | The identifier exposed by the class; different from the table identifier column. |
| TableName* | Database table name |
| TableIdentityColumn* | The name of the primary key in this child table |
| TableParentForeignKey* | The name of the foreign key pointing to the parent in the table (not the name in the parent table) |
| CollectionName* | The name of the collection class to be used |
| Cardinality* | Enumeration: OneToMany, ManyToMany |
| ExposedName* | The name under which the collection is displayed in the AR |
| TabTitle | Title of collection tabs |
The defining property of the collection entity is returned to the collection.
UserInterface tag
-
List tag
Property name Description Title List title in UI -
Form tag
Property name Description CreationTitle Creation form title UpdateTitle Update form title