Rodolfo Vazquez
Rodolfo Vazquez

Reputation: 23

MPS Many to Many model transformation

I'm planning to migrate a tool I build some time ago to Jetbrains Mps, I'm evaluating it but have some doubts.

The main one is if model transformation in Mps is only 1 model to 1 model. Or can I combine several models to generate some others.

Think I have a certain language called "Page language" that represent Page structures. It lets you define general layout of a kind of page. For example, I define two models "List page" (list records of a given entity) and "Instance Page" (pages for "crud" operations).

There is another language called "Entities language", this one lets you define entities. In a Solution I create 3 models of this language: Person, City and Country to represent 3 entities.

The generation process I need to build must combine the 3 entity's models and the 2 page's models to produces 6 models of some other language, which will represent every page complete, with de structure from the Page Model and the entity's fields from the Entity Model.

Is this possible with Mps?

For example, can I iterate through Entities models and for each perform a nested iteration of Pages models, then fire one model transformation that combine the current entity with the current Pages model?

Thank you very much.

Upvotes: 0

Views: 140

Answers (1)

Vaclav Pech
Vaclav Pech

Reputation: 1441

In MPS terminology we call these entities not models but "root nodes". You can certainly generate such combinations of nodes - I'd perhaps use a pre-processing script to generate the six combinations as new root nodes referring to the original entities. The concept for it could look somewhat like this:

concept TemporaryCombination extends BaseConcept ... references: page:Page[1] entity:Entity[1] ... Then a root mapping rule for the TemporaryCombination concept could drive the generation of your target nodes.

Upvotes: 0

Related Questions