Thursday, September 10, 2015

Pragmatic MDD: Workflows and more

So the last time we were facing 2 problems: A lot of code in a file for just one transformation (and part of this code could be potentially reusable later) and definition of workflows.

Let's begin with the solution for the first problem. It's an easy one.

We proceed here exactly like before: We define a separate transformation for the setting of meaningful defaults. Since there is not model-to-text transformation, result of the runner is just another model, that gets saved in the output folder.

This changes things slightly - Since the input model of the PojoWithAutoupdate transformation is not our original model anymore (remember, we just moved all the default settings to a separate transformation), but the output of the previous step (the new default setting transformation), we also need to change the setup of PojoWithAutoupdate a bit: From this to this, the model name and model path have changed.

So now we have 2 transformations and somehow they need to be executed one after another.. How can we do that?

But before we answer this question, let's solve one more problem. Since Java wants to have package names consistent with the folder structure where files are, at the very beginning we have to setup all the missing folders and, before that, remove all the old files still remaining there. This is done in one more workflow step. This is for sure not the most elegant way, but it does its job.

So now we have even 3 workflow steps that need to be triggered one after another. And this is exactly what we do here: Just triggering one step after another, passing all the overrides as parameters the same way we did before over the command line.