Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: aram on June 14, 2006, 05:57:24 am
-
I'm writing a model transformation templates which should merge several models. However I don't see how can I do the following.
I have a class X associated with Y (X->Y). The class Y is associated with Z. So what I have is X->Y->Z. I need to transform this to X associated with Z. Y should be deleted.
So what I don't know is how do I lets say get all the associations that have the current class as a Target.
Also where could I find more information on model transformations as the tutorial is not 100% helpful.
Thanks.
-
Hi aram,
I also had trouble in doing more complicated things than just a simple transformation. Thus I gave up using this tool (in these cases) and I use the automation with EA_EXE_ADDIN (search for this keyword here). This allows you to use the programming language of your choice instead of having a tricky transformation which nobody can understand.
-
Thanks for the info Thomaskilian
The only thing is - i've tried to search for the keyword EA_EXE_ADDIN however it doesn't find any results.
could you help me out.
thanks a lot.
-
My fault. I misspelled the word and here's the thread (http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=Automation;action=display;num=1145911636;start=0#0).
-
Thomas,
Can I see a couple of sample perl files. How do you access the model and all? It is still pretty obscure for me.
Moreover, I still do not see how could I transform behavior models and generate code from them.
-
It's indeed not so easy :-[ So I try to give a clue what needs to be done:
- The transformation uses an intermediate file with an unpublished syntax. However, it is relatively easy to guess.
- Use one of the existing transformations and use the logging checkbox to create a dump of the intermeditate files. Apply the transformation to stepwise more complicated class structures in order to get a feeling for it.
- Once you understood the syntax, you can take the next big step.
- Writing an Add-in for EA is explained in the help quite good. I also have published something on EA Usergroup written in Perl. You need the add-in to make use of the automation interface.
- This is the next step. Make sure you can extract information from EA's model by using the automation. Once you understood that, it's easy. But it needs some learning curve.
- Now step back to the transformation. Use the EXEC_ADD_IN to create the intermediate file. This is done "simply" by returning a string with the appropriate contents. This contents is created using the model information and a control parameter passed on. The resulting string will be placed at the position in the transformation. (In my example it will be the entire contents)
This sounds like a lot of work and indeed it is not less. But I found it worth while since you can do almost everything when doing it that way.
-
Thomas,
seems indeed too much work. I still need a couple of things and maybe I can fix it without the "hack" you suggested.
The documentation of the current transformation language is huge but still seems incomplete. Like I don't understand the semantics of
$var = %Class__X%. What I'd like to have is to be able to obtain a reference or classGUID of the newly generated class.
Another thing - is there any function that could retrieve classGUID by class name?
Last question - can I pass parameters to list macros? E.g.:
%list="Class($parameter1, $parameter2)" @separator="\n" @indent=" "%
Thanks.
-
I'm definitely out with that. So you have to wait for Simon (from Sparx) who usually gives a hand with these matters.
-
The documentation of the current transformation language is huge but still seems incomplete. Like I don't understand the semantics of
$var = %Class__X%. What I'd like to have is to be able to obtain a reference or classGUID of the newly generated class.
Another thing - is there any function that could retrieve classGUID by class name?
No, you can't get the GUID of any class being created in the transformation, because it hasn't been created yet. When you need to reference it you can use the TRANSFORM_REFERENCE macro to refer to classes that are created in the transform. I'd recommend looking at http://www.sparxsystems.com/EAUserGuide/index.html?crossreferences2.htm. If you still need more information try searching the forum for TRANSFORM_REFERENCE as I have explained it further in some other threads.
Last question - can I pass parameters to list macros? E.g.:
%list="Class($parameter1, $parameter2)" @separator="\n" @indent=" "%.
No you can't. But all macros available from the parent template should be available from within each part of the list, and you can create an arbitrary number of templates to call.