5.2. Model Reference

MetaFactory supports both XML (recommended) and YAML to contain the model data. This document describes the required structure of the file and its child elements.

Glasses M To learn more on how to access and manipulate this file from within your code instructions, please check the Model API reference.

5.2.1. Model structure

The MetaFactory model file contains a ‘model’ element as root, which has one or more packages that are used to group data objects (entities). Every object can have attributes and references to other objects inside the model, which is equivalent in functionality to Java’s entity properties.

By using the model and code instructions, MetaFactory is able to generate (‘to MetaFactor’) the code for all the entities of the model. While executing code instructions MetaFactory reads the model by iterating through the element hierarchy. During these iterations the code instructions and model data are combined to create the actual output code. The hierarchy of the model data file is fixed and looks as follows in XML, which file would be ‘model.xml’.

Listing 5.13 Model structure
 1<model>
 2    <metadata>
 3        <someproperty>property1</someproperty>
 4    </metadata>
 5    <package name="bookstore">
 6        <metadata>...</metadata>
 7        <object name="book">
 8            <attribute name="title" type="String" notnull="false">
 9                <metadata>...</metadata>
10            </attribute>
11            <reference name="author" type="Person">
12                <metadata>...</metadata>
13            </reference>
14        </object>
15        <object name="Person">...</object>
16    </package>
17</model>

For example one code instruction might generate the java POJO’s (back-end) while the second code instruction would generate the front-end in order to visualize and manipulate the data in the back-end. All these code instructions use the same model.

Sub elements

Table 5.13 sub elements of <model>

Name

Details

Number

metadata

With metadata the code instruction logic can make decisions. The logic can also add metadata itself.

0..n

package

Used to group objects (entities in the data model)

0..n

5.2.2. Child elements

The tree of the model root element <model> can contain the following child elements which will be explained separately: