Linking transformation output to other transformations

You can link output from a transformation with another transformation to create combinations of model-to-model transformations and Java Emitter Templates (JET) model-to-text transformations. This functionality enables you to create more complex transformations, such as the UML-to-Java transformation.

Before you begin

The transformation to which you link must be registered before or when you run your model-to-model transformation.

About this task

To link model-to-model transformation output to another transformation:

Procedure

  1. In the Project Explorer view, in the transformation mapping project, double-click the generated TransformationProvider Java file. For example, if the mapping model in the mapping project is called Source2Target, double-click the Source2TargetTransformationProvider.java file.
  2. In the createRootTransformation method, invoke the addPostProcessingRules method.
  3. In the addPostProcessingRules method, add a rule to link to the appropriate transformation.
    • To link to a model-to-model transformation, create an instance of the ChainRule class.
    • To link to a JET model-to-text transformation, create an instance of the JETRule class.
    To see the parameters that the constructors of these classes require, see the related links at the end of this topic.
    Note: Some information, such as links to Eclipse documentation or to developer guides, is available only from the help topics that are installed with the product.
  4. Remove or edit the @generated tag for the createRootTransformation method.
  5. Click File > Save.

Results

The next time that you run the model-to-model transformation, the target model that the transformation generates becomes input to the transformation that you specify in the processing rule.

Example

The following code fragments show a modified @generated tag in the createRootTransformation method, and an add post-processing rule that invokes another transformation:
  • The add post-processing rule in the code fragment below invokes a model-to-model transformation with a transformation ID that is set to MyM2MTransformation:
    /**
         * Creates a root transformation. You may add more rules to the transformation here
         * <!-- begin-user-doc -->
         * <!-- end-user-doc -->
         * @param transform The root transformation
         * @generated NOT
         */
        protected RootTransformation createRootTransformation(ITransformationDescriptor descriptor) {
            return new RootTransformation(descriptor, new MainTransform()) {
                protected void addPostProcessingRules() {
                    add(new ChainRule("MyM2MTransformation", TARGET_CONTAINER)); //$NON-NLS-1$
                }
            };
        }
  • The add post-processing rule in the code fragment below invokes a JET transformation with a transformation ID that is set to MyJetTransformation:
    /**
         * Creates a root transformation. You may add more rules to the transformation here
         * <!-- begin-user-doc -->
         * <!-- end-user-doc -->
         * @param transform The root transformation
         * @generated NOT
         */
        protected RootTransformation createRootTransformation(ITransformationDescriptor descriptor) {
            return new RootTransformation(descriptor, new MainTransform()) {
                protected void addPostProcessingRules() {
                    add(new JETRule(“MyJetTransformation")); //$NON-NLS-1$
                }
            };
        }

Feedback