Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Modesto Vega on February 10, 2022, 01:45:05 am

Title: Model Transform using alias field
Post by: Modesto Vega on February 10, 2022, 01:45:05 am
Is it possible to write a model transform that reads a value from the alias field of both classes and attributes and creates another class as follows:

If so, what code do we need to use to read the contents of the alias fields?
Title: Re: Model Transform using alias field
Post by: Geert Bellekens on February 10, 2022, 03:13:37 am
Is it possible?

It might be.

Is it the best option? Not in my opinion.
I think in cases like this it's much faster and more flexible to simply write the transformation logic in a script, rather then trying to express your need in the transformation template language.

Geert
Title: Re: Model Transform using alias field
Post by: qwerty on February 10, 2022, 04:35:20 am
What Geert said. Using these templates gives you 0% flexibility as you already encountered. Doing a transformation via a script in contrast gives you all possiilities you need.

q.
Title: Re: Model Transform using alias field
Post by: Modesto Vega on February 10, 2022, 07:55:09 pm
When I asked the questions in the OP, I was looking for code examples of how to do this through a model transform; instead I got a very generic recommendation to use a script without any examples of how to do it.

This is a "problem" with Sparx EA (emphasis intentional), essentially users have to figure out way too many advanced to medium things.

P.S.: Model transforms have the advantages that 1) they create a relationships between the element to be transformed and the result of the transformation, and 2) next time they run they "automatically" (emphasis intentional) update what has changed and create new elements (and attributes). Can the same result be achieve with a script without writing reams of code to handle the logic.

P.S.2: A script is still an option.
Title: Re: Model Transform using alias field
Post by: Geert Bellekens on February 10, 2022, 08:06:49 pm
When I asked the questions in the OP, I was looking for code examples of how to do this through a model transform; instead I got a very generic recommendation to use a script without any examples of how to do it.

This is a "problem" with Sparx EA (emphasis intentional), essentially users have to figure out way too many advanced to medium things.

P.S.: Model transforms have the advantages that 1) they create a relationships between the element to be transformed and the result of the transformation, and 2) next time they run they "automatically" (emphasis intentional) update what has changed and create new elements (and attributes). Can the same result be achieve with a script without writing reams of code to handle the logic.

P.S.2: A script is still an option.
Yes, you can do all that with scripting, and depending on what you want to achieve it's not that complicated.
You'll have to write a bunch of code, but I think it will cost less time than to try and do it in the transformation template language.
With a script I'm certain you can get the result you are looking for. With transformation templates I can't be that certain.

Geert
Title: Re: Model Transform using alias field
Post by: qwerty on February 10, 2022, 09:34:33 pm
A model transformation is not a simple task. You always have a lot a constraints and rules that will guide the transformation. So (I think) it's impossible to have some scaffold that will do most of it and you just press a few buttons. I had played around with transformation but soon gave up with those EA macros. They made more a mess than helping in any way (in my case). The scripting itself took me a day or so to produce what I needed.

As a side note I completely lost transformation. I'm at the point where I think that a model shall aid communicating between stakeholders and not be some kind of factory.

q.
Title: Re: Model Transform using alias field
Post by: Paolo F Cantoni on February 10, 2022, 10:41:29 pm
A model transformation is not a simple task. You always have a lot of constraints and rules that will guide the transformation. So (I think) it's impossible to have some scaffold that will do most of it and you just press a few buttons. I had played around with transformation but soon gave up with those EA macros. They made more a mess than helping in any way (in my case). The scripting itself took me a day or so to produce what I needed.

As a side note, I completely lost transformation. I'm at the point where I think that a model shall aid in communicating between stakeholders and not be some kind of factory.

q.
The essential problem is that Model Transformations (like many Sparxian developed technologies is that they go about 80% of the way then stop.

Unfortunately, the new user doesn't know they are trying to cross a 10-foot chasm with an 8-foot ladder.

(I'll leave it as an exercise for the reader to figure out how to do it).

I don't agree that transformations within models aren't viable, you just have to use the right technology - scripting.

Paolo
Title: Re: Model Transform using alias field
Post by: qwerty on February 10, 2022, 11:24:31 pm
You break the leader and use the two halfs bound with rope to become some 15 or so foot long stick.

q.
Title: Re: Model Transform using alias field
Post by: Modesto Vega on February 14, 2022, 11:07:33 pm
I have written model transformations before and it wasn't a pleasant experience, there are some threads in these forums documenting the tortuous journey of the latest one. I am very hesitant to start that journey again.

Scripting is probably the way forward but it is going to take a significant amount of time, possibly as long as a writing a model transform. To be honest I wish there was an official way to manipulate data directly on the database, in many cases, it will be much easier than writing scripts calling the API.