Up Previous Next Title Page Contents

3.1 Creating a Graph

In this tutorial we will create the metamodel in a top-down fashion, starting from the graph type and proceeding with objects, relationships and roles. It is also possible to follow a bottom-up approach, starting from the language fragments, but for learning purposes we consider the top-down approach better.

As a top-level or root component of our modeling language, a graph in this case encapsulates the concept of family within a simple diagram notation. To start creating a new graph type for our family tree language, open the Graph Tool (shown in Figure 3-1) by pressing the Graph Tool toolbar button or selecting Metamodel | Graph Tool in the MetaEdit+ launcher.

Figure 3-1. Graph Tool.

First, enter the name for our modeling language (‘Family Tree’) in the Name field. Also make sure that the project for your new graph type is ‘Family Tree’ (if not, select it from Project’s pull-down list).

Next, we need to state what information can be stored about a family on the level of the whole graph, e.g. the Family name. In GOPPRR such information is stored in a property. To add a property to our Family Tree graph, move the mouse over the area of the Properties list in the Graph Tool and press the right mouse button. From the pop-up menu that opens, select Add Property... to add a property. As there are no property types defined yet, MetaEdit+ automatically chooses to create a new property type (if there are already some property types, you will be offered the choice of using them, but should choose ‘New Property Type’ from the dialog that opens). This opens a Property Tool for defining a new property type (shown in Figure 3-2).

Figure 3-2. Property Tool.

In the Property Tool, enter the name for the property (‘Family name’). Quite often the other values within the Property Tool would be correct by default, but in this case we want to set a different widget type to be used with Family names. As we want to reuse the Family name property value while populating the Family Tree with family members, it would be useful if the user could select previously entered values from a pull-down list, into which each new name will be added. The widget for this is called an Editable List: choose it from the possible widget types from the Widget list. Press Save and Close on the toolbar to accept the changes and to close the Property Tool. As this is the first time you have generated a type in this session, MetaEdit+ will run a check on all types in the database. As there are many types in the demo repository, this will take several seconds – but only for this first time.

Figure 3-3. Graph Tool with the basic definition for Family Tree graph type.

The basic definition of our Family Tree graph type being complete, the Graph Tool should now look as in Figure 3-3. You can proceed now by pressing the Save button in the toolbar (not Save and Close, because we will continue working with the Graph Tool).

The next step for us is to create the individual language fragments. This will be done in Graph Tool’s Types page (shown in Figure 3-4).

Figure 3-4. Graph Tool’s Types page.

As we can see, the Types page provides lists for objects, relationships and roles. The creation of the types will be discussed in the following chapters.

Up Previous Next Title Page Contents