You
can link output from a transformation to 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.
The transformation to which you link must
be registered before or when you run your model-to-model transformation.
To link model-to-model transformation output to another transformation:
- 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.
- Specify an add post-processing rule in the createRootTransformation
method.
- In the post-processing rule, specify the ID of the transformation
to invoke.
- Remove or edit the @generated tag for the createRootTransformation
method.
- Click .
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.
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 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$
}
};
}
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 TransformRule("MyM2MTransformation")); //$NON-NLS-1$
}
};
}