Book a Demo

Author Topic: MDA newbie  (Read 8229 times)

xhanness

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
MDA newbie
« on: February 27, 2009, 04:30:22 am »
Hi, i am trying a simple MDA transform to get working.

I am trying to modify all processed conectors.

1) The conditional Field Substitution Macro does not work
the code %connectorStereotype=="myOldStereotype1" ? "myNewStereotype1" : "myNewStereotype2"%
gives me parsing error: unexpected token myNewStereotype2. When I change the code to
%connectorStereotype=="myOldStereotype1" ? "myNewStereotype1"%
then I get parsing error again: unexpected token myNewStereotype2.


2) When I make a assignment as following stereotype="myNewStereotype2" and the previous connector has had a value myOldStereotype1, then after the transformation the connetor will have stereotype <<myOldStereotype1, myNewStereotype2>>. Why? And how can I "delete" previous one.

3) I also tried to set a tagged value of the connector with "connectorTag" macro, but I get parse error: unexpected connector tag
Code: [Select]
%connType%
{
  ...
  %connectorTag:"myTV" = "zzz"%
  ...
}



Could anybody make clear, what is wrong about that and how I can get arround this?


thanks !!

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: MDA newbie
« Reply #1 on: March 03, 2009, 02:14:45 am »
Hi!


1) I haven't used this construct but it looks C-like to me. In that case you need to use it as an expression, not a statement. In other words, it can't stand on its own, you need to put it into something like
Code: [Select]
stereotype = %qt%%connectorStereotype=="myOldStereotype1" ? "myNewStereotype1" : "myNewStereotype2"%%qt%Please note that I haven't tested that and you might need to fiddle around with " and % characters and the %qt% macro to get it right.
Either way, you should be alright using a branching control macro instead - that's an If statement to us mortals. Something like:
Code: [Select]
%if connectorStereotype == "myOldStereotype1"%
stereotype = "myNewStereotype1"
%else%
stereotype = "myNewStereotype2"
%endIf%
This is useful if you only want to do a few things differently depending on the stereotype. If, however, you find yourself in a situation where that %if% statement encloses the whole template, you might want to consider adding a stereotyped override template instead. A stereotyped override gets called instead of the base template for those elements where the stereotype is the one you've specified.


2) It looks like you've missed adding "stereotype" to the <listOfExcludedItems> in TRANSFORM_CURRENT.
TRANSFORM_CURRENT copies everything from the element being transformed into the new element except for the items you list, so in your case you should probably put in something like:
Code: [Select]
%TRANSFORM_CURRENT("stereotype")%You will still be able to use the old element's stereotype (%connectorStereotype%) in the template, it just won't be copied into the new element.


3) That's not what the connectorTag macro does. You can't set things with it, only extract. If the connector in the element being transformed has a string tag "Blarg" with the value "Honk", then
Code: [Select]
%connectorTag:"Blarg"%will result in the string "Honk" being placed in the newly transformed element. If you want to add a new Tagged Value to the element being created the keyword is Tag, as in
Code: [Select]
Tag
{
    name = "PapasGotA"
    value = "BrandNewTag"
}

Hope that helps. If not, holler.  :)

Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: MDA newbie
« Reply #2 on: March 03, 2009, 08:06:44 am »
Just and additional note to Uffe's great response.  The transform engine can't create tagged values on connectors at all.  Follow those instructions if you are wanting to add a tagged value to anything else.  It won't work for connectors.

xhanness

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: MDA newbie
« Reply #3 on: March 04, 2009, 01:11:39 am »
Hey hey Uffe,

thanks for your answer. It me helped lot.
The template frameworking seems to be little bit odd to me (e.g. no possibility to use variable on the right side of assignment, stupid sytnax and some other things), but I will have to deal with it.

tack

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: MDA newbie
« Reply #4 on: March 07, 2009, 01:22:01 am »
Well it is a little obscure in places, I'll give you that. It could be better documented. But it's very powerful once you wrap your mind around it.
I struggled with it until I finally realized I was trying to do regular imperative programming, and that's not what it does. If you think in terms of a (hierarchical) set of filters applied to a stream instead, things will fall into place.

Cheers,

/U
My theories are always correct, just apply them to the right reality.

xhanness

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: MDA newbie
« Reply #5 on: March 26, 2009, 12:09:15 am »
Hi I would have another 2 questions

1] is there a method in api, which enables me to invoke a transformation (instead of clicking on a package and using "Transform current package")

2] I created a MDG compliant plugin and implemented method MDG_NewClass. I would expect, when the method is providing all necessary information for code generatin process like providing file path for a new file and setting the language, that there will not be any dialog window after run the transformation. But there is one, forcing me cliking asnd clicking. I cant imagine to click 100 times for 100 source files ... ufff   :-?
« Last Edit: March 26, 2009, 12:11:12 am by xhanness »

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: MDA newbie
« Reply #6 on: March 26, 2009, 01:30:49 am »
Hi again,


I haven't used the API so no help there.

But regarding the file selection in code generation, if you select Auto Generate Files in the Generate Source Code dialog and provide it with a root directory, it shouldn't ask for any additional file names.

Regardless of whether you use Auto Generate Files or not, once you've generated code for a UML entity the file name is retained by EA so next time you generate code out of the same package it won't ask for the file names.

If you do want to change the file names, select the package, right-click, Code Engineering, Reset Options for this Package, select Clear Filenames and (usually) Process Child Packages.
Previously generated code files will not be removed, but the file names will be forgotten by EA so that you can specify a different set of file names next time.


/Uffe
My theories are always correct, just apply them to the right reality.

xhanness

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: MDA newbie
« Reply #7 on: March 26, 2009, 08:14:04 am »
Hi Uffe,

thanks again. I did no about that (I did not spot even "Code enginnering") menu item  :D
But still I would like to know, how to run MDG via API. I think I'll post it as a single topic.

best
xhanness

xhanness

  • EA User
  • **
  • Posts: 32
  • Karma: +0/-0
    • View Profile
Re: MDA newbie
« Reply #8 on: March 27, 2009, 04:12:08 am »
Well, there is the method:
The TransformPackage method in Project interface

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: MDA newbie
« Reply #9 on: March 27, 2009, 11:12:26 pm »
Quote
The transform engine can't create tagged values on connectors at all.  Follow those instructions if you are wanting to add a tagged value to anything else.  It won't work for connectors.

Simon, I have to add that this is an unfortunate situation especially for those working with XML schemas.
Actually the only way to create a reference link in a XSD model is to add two tagged values to one of the aggregation or association end.
Otherwise the link is treated as a composite.
If the XSD elements are the result of a transformation those tags are getting lost and you have to set them otherwise (mostly manually) on the transformed elements.
The alternative is to use no transformation at all to create XSD files.

I have filed a bug report but the answer was to set the tagged values to accomplish what I want. And here I stay again. :-?

Oliver