Author Topic: Model Transform using alias field  (Read 3365 times)

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1142
  • Karma: +30/-8
    • View Profile
Model Transform using alias field
« 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:
  • uses the text in the alias field of the class been transformed as the name of the new class
  • for each attribute in the class been transformed, it creates an attribute in the new class with the name held in the alias field of each attribute
  • if a class has a blank/null alias, the class is ignored
  • if an attribute has a blank/null alias, the attribute is ignored

If so, what code do we need to use to read the contents of the alias fields?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13400
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Model Transform using alias field
« Reply #1 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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Model Transform using alias field
« Reply #2 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.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1142
  • Karma: +30/-8
    • View Profile
Re: Model Transform using alias field
« Reply #3 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.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13400
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Model Transform using alias field
« Reply #4 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

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Model Transform using alias field
« Reply #5 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.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8607
  • Karma: +257/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Model Transform using alias field
« Reply #6 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
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Model Transform using alias field
« Reply #7 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.

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1142
  • Karma: +30/-8
    • View Profile
Re: Model Transform using alias field
« Reply #8 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.