Managing unresolved references to previously generated objects in model-to-model transformations

When a model-to-model transformation runs, it generates either objects or references to generated objects, depending on the feature settings in the metamodel. If the transformation generates objects, it records identifying information about those objects in a hash map. The transformation resolves references to objects during post-processing, based on the hash map. However, if the hash map does not contain sufficient information, you must manage the references.

About this task

In UML metamodels, features of elements have a Boolean property named containment. If the containment property is set to true, objects are placed in the feature of an instance of the element. If the containment property is set to false, only a reference to the object is placed in that feature of an instance. The transformation resolves the reference during post-processing.

During post-processing, the transformation uses a rule named FinalizeRule to search each deferred reference record to find an object to resolve the reference. If the transformation finds an object, it creates the reference in the designated output feature of the instance. If the transformation authoring runtime finds a hash map that has the ID of the transformation, it uses the source object to find the target object in the hash map. If the runtime finds more than one candidate object, it calls the output filter, if defined, to select one. If the submap does not have an output filter defined, the transformation uses the first target object that it finds to resolve the reference. If no target object is found, the transformation logs an error and displays a message.

Procedure

  1. Before you run the transformation, if you know that multiple candidate objects exist for a reference, create an output filter for the corresponding submaps so that the correct object is used to resolve the reference.

    For detailed instructions, see the topic "Specifying input object and output object filters in submap mapping rules."

  2. Run the transformation.
  3. If an error message is displayed that states that a target object is not found, create or modify the output filter so that the transformation can locate the correct object, if it was generated.
    Note: Often, a target object is not found because it was not generated. Make sure that all relevant transformations were run to make all necessary target objects available.
  4. Rerun the transformation to verify that all references are resolved.

Feedback