4.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.

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

4.2.2. Child elements

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