In A3, we did not need workflows because the order of the transformations did not matter as the transformations inside the cartridges were independent. In A4, this is different. It is very important in which sequence the different transformations take place because they depend on each other.
A4 contains a workflow execution plugin that can invoke scripts that are written in the Groovy scripting language. A workflow typically loads some metamodels, then some models based on those metamodels, then executes some transformations to get the generated source code.
These are the most important lines from a test workflow that generates code for the test model we have seen on the transformations page:
chainModel = emfModelReader.readModel(
modelName: "chain",
uri: "file:$env.basedir/src/main/uml/chain.uml2",
metamodelName: "UML2"
);
eappModel = emfModelCreator.createModel (
modelName: "chainEnterprise",
uri: "chainEnterprise.ecore",
metamodelName: "EnterpriseApp"
);
atlTransformer.transform (
name: "UML2EnterpriseApp",
inputModels: [IN:chainModel, PRO:eappProfileModel,
MDPRO:magicDrawProfile, UMLPRO: umlStandardProfile,
UMLPROV:umlStandardValidationProfile,
MDPRODSL:magicDrawDSLProfile
],
outputModels: [OUT:eappModel]
);
.
. <snip> <snip> <snip> ...
.
configurationModel = modelLookup.lookupModel("AndroMDAConfiguration");
mofScriptTransformer.transform (
name: "SpringDao2Java",
inputModels: [oop:oopModel, config: configurationModel]
);I have removed the other statements to keep the picture simple.
In a workflow script, the workflow execution plugin has already pre-registered references to all important other plugins. For example, you see the emfModelReader, emfModelCreator, modelLookup, atlTransformer references above which have not been declared in this script. The reason is that the ATL transformer plugin and the EMF repository plugins, etc. have contributed these references to the workflow context. (By the way: You can write your own workflow contribution plugins or simply instantiate your own Groovy or Java classes inside a workflow script!).
So, what the test workflow does, is:
Read the file CodeGenWorkflow.groovy thoroughly - you will learn how to write a workflow script quite quickly.