Skip to end of metadata
Go to start of metadata

New topics covered by this example:

  • Export specific Descendant and Ancestor relations
  • The Both Must Exist constraint
  • The valueFilter attribute
  • The Different indicator

The inputs data for this example are:

  • The Rule Maker template (you can ask for it at arkitect-support@k-inside.com)

Descendant/Ancestor relations

This part focuses on Ancestor relation. As descendant is simply a reversed version of the Ancestor relation we will not develop it here.

Icon

The sense of the relation is important as it is explained in MG Tutorial - A Simple Import Export

Model Exported

In this tutorial the purpose is to export data concerning Continent, Country, Town and People movement flow which has a double type attribute called Number of people to specify how many move. The type diagram of the model is shown below:

Note that the ActionPanel and Action types are only here to facilitate the execution of export script.

Only one treeview is defined in the model. In the diagram is displayed three continents "Asia","Europe" and "Unknown continent". The first two continents contain countries which contain towns whereas "Unknown continent" is empty. An ActionPanel object is also present as shown below in order to execute the export script:

Preparing the Rule Model and Rule File

Refer to the instructions of the first tutorial. First we would like to determine the continent where every town of the model are located.The Parent of relation can not be used here as Town are not a direct child of Continent, there is Country in between. Hence the Ancestor of relation is used. Create a new Rule Model with a Location sheet as pictured below.

Export Ancestors

Now in the target model where are present the data to be exported the Model gateway export script will be run to create the output excel file. After running the export script select the Rule File at the File Open dialog. The Model Gateway will open Excel and create a new workbook with the exported data. To actually save the data to an Excel file, you need to use the Save command in Excel. With the Rule Model created above the excel file displayed below is obtained:

We can see that continent "Unknown continent" is exported even if it does not have towns in it. Sometimes we do not want to export these objects which does not strictly satisfy all relations described in the Rule Model. Indeed in the Rule Model we created an Ancestor of relation. In case of "Unknown continent" no towns are in it so that the Ancestor of relation does not exist. To avoid exporting these objects use the BothMustExist relation.

BothMustExist relation

Preparing the Rule Model and Rule File

In this part the same model introduced before will be used but only continents which have towns in it will be exported. To proceed refer to the instructions of the first tutorial and build the Rule Model displayed below:

Export Ancestors result

Now run the export script in the target model and the excel file below is obtained:

As seen above only the continent "Asia" and "Europe" have been exported as only these continents have towns in it.

The valueFilter attribute

Preparing the Rule Model and Rule File

It is possible to export specific objects using the valueFilter attribute. This attribute allows the user to specify which object identified by his name will be exported. Using the model displayed above we will now export only towns of the "Asia" continent. To perform this export refer to the instructions of the first tutorial and build the Rule Model below:


As seen above in the Column object continent the valueFilter attribute is specified as "Asia".

Export Ancestors result

Now run the export script in the target model and the excel file below is obtained:

Different relation

Model Exported

In the model shown below new objects have been created in the Model, the People movement flow objects. They describe movement of people between towns. Each People movement flow has a Number of people attribute to specify how many people are moving. Data will be exported from the model below:

We will do an export to know how many people move between towns in the "Asia" continent but we do not want to export data about people movement flow between towns of the same country. Hence refer to the instructions of the first tutorial and build the Rule Model below:

As can be seen the valueFilter attribute of the Column "Continent" is set as "Asia" and a Different indicator is created between the columns "Country of departure" and "Country of arrival" to specify that they must be different. Besides an Input of flow is used between the Column objects "People flow" and "Country of arrival" because the focus objects are objects of type People movement flow. We only want to export countries of arrival which consume People movement flow objects.

Export result

Now run the export script in the model and the excel file below is obtained:

  • No labels