How to Update Metamodels of Existing Graphs?

Background

When a graph file (.slg) is created, the current metamodel is saved as part of the graph. This allows you to open a graph without having the metamodel files. However, it also means that if you change the metamodel any previously created graph files are “outdated”, as they are not automatically updated to the new metamodel. This can cause problems if you want to use the graph as input data graph for rules or sequences that make use of the new metamodel. This article describes how to update metamodels.

The obvious way to “update'” your graph to your new metamodel is to recreate it from scratch. This is the most stable way, but depending on the runtime of your project you might not want to do this.

Two workarounds to “update” existing graph files to a new metamodel are:

  1. Running an “empty” rule on the old graph file and save the output graph to a new file. NOTE: This only works if your old metamodel is a subset of your new metamodel! Thus you can add to the old metamodel, e.g. add attributes, node/edge classes, … but that you cannot subtract from it.
  2. Exporting the graph to an Excel file and re-importing it to an empty and new graph file.

Update Metamodel of Graphs

1. Using an Empty Rule

Make a rule like this:

rule emptyRule{
  modify{
  }
}
  1. Use the old graph as Input Data Graph, run the rule in the Build and Run pad and save the resulting graph to a new file:
    Metamodel Update
  2. The generated graph will use the new metamodel.

2. Export and Re-Import

  1. Open the old graph which needs the update.
  2. Export all data to an Excel file using the Export function. You can find the Export button in the top menu bar:
    ExportImport
  3. Create an empty graph file in the Solution Explorer (right-click on Graphs folder -> Add -> Empty Graph File). It will have the current metamodel.
  4. Open this empty graph file and import your data using the Import function. You can find the Import button in the top menu bar:
    ExportImport
    The data import dialog will pop-up. Select the Excel file generated with the previous Export and map the information to your new classes and attributes as needed. Check this article on how to use the data import dialog.
  5. The generated graph will use the new metamodel.

 

Was this article helpful?

Related Articles