Home » Modeling » M2T (model-to-text transformation) » JET beginner question
|
Re: JET beginner question [message #46257 is a reply to message #46232] |
Thu, 22 May 2008 13:12 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Timothy:
Let me summarize the approaches you mention.
1) JET1. You access your model using embedded Java, so you must have
familiarity with the UML APIs. In addition, JET1 provides no support for
writing files, so you need to know how to create Eclipse plug-ins and how
to use the Eclipse workspace APIs to save your results.
2) JET2 directly against a UML2 model. Again, you need to understand the
UML meta-model/APIs. Also, JET2 doesn't have built-in capabilities to
access Stereotype applications - you'd have to write XPath functions to
get access. I know of at least one user who wrote custom JET tags to
access the model via OCL. Key for success here: familiarity with UML2
3) JET2 against a simplified intermediate model chained with a
UML2-to-intermediate model transformation. This is the approach I
generally recommend because I believe it provides a good separation of
concerns:
* hide the complexities of UML from the code generator/templates
* an opporutunity to "de-normalize" the UML representation to simplify
code generation (as a motivator take a look at how UML2 represents
documentation on a model element).
* isolate the code generator from changes in representation. In my
experience, the UML representation is a much more challenging thing for
many people to build (many don't even know what the UML superstructure
is). It is not uncommon for that representation to evolve as experience is
gained.
As a downside, there is added complexity in introducing a model-to-model
transformation.
If you happen to be using my employer's products (IBM Rational), there is
a recently published 'Redbook' that covers this topic in some detail. If
you're interested, go directly to part 4.
http://www.redbooks.ibm.com/redpieces/abstracts/sg247529.htm l?Open
Paul
|
|
|
Re: JET beginner question [message #46313 is a reply to message #46257] |
Thu, 22 May 2008 14:32 |
Timothy Marc Messages: 547 Registered: July 2009 |
Senior Member |
|
|
Dear Paul,
thanks for your suggestions. The intermediate model, that only focusses
the generation-relevant information is a good way i think, even if it is
a bit of redundant work, because every information one need for the
generation is found in the UML meta-model.
However, I was wondering about that you said, that JET is not able to
create files. Another need for the university is to create all the code
from an UML class model, so i have to write a lot of different files,
classes, interfaces, abstract classes, enumerations, etc. I think you
know what i mean.
My first idea was:
1. Create the intermediate model and store all elements, which are
commonly created in separate files (classes, interfaces, etc.)in a vector.
2. Define several templates for classes, interfaces, enumerations
3. Pass the elements in the to-generated-vector to the templates,
depending on their kind. Write the generated string programmatically to
files.
Is the complettly non-sense or even undoable with JET? I don't want to
create a plugin but a standalone java/swing-application.
Thx again.
--tm
Paul Elder schrieb:
> Timothy:
>
> Let me summarize the approaches you mention.
>
> 1) JET1. You access your model using embedded Java, so you must have
> familiarity with the UML APIs. In addition, JET1 provides no support for
> writing files, so you need to know how to create Eclipse plug-ins and
> how to use the Eclipse workspace APIs to save your results.
>
> 2) JET2 directly against a UML2 model. Again, you need to understand the
> UML meta-model/APIs. Also, JET2 doesn't have built-in capabilities to
> access Stereotype applications - you'd have to write XPath functions to
> get access. I know of at least one user who wrote custom JET tags to
> access the model via OCL. Key for success here: familiarity with UML2
>
> 3) JET2 against a simplified intermediate model chained with a
> UML2-to-intermediate model transformation. This is the approach I
> generally recommend because I believe it provides a good separation of
> concerns:
> * hide the complexities of UML from the code generator/templates
> * an opporutunity to "de-normalize" the UML representation to simplify
> code generation (as a motivator take a look at how UML2 represents
> documentation on a model element).
> * isolate the code generator from changes in representation. In my
> experience, the UML representation is a much more challenging thing for
> many people to build (many don't even know what the UML superstructure
> is). It is not uncommon for that representation to evolve as experience
> is gained.
>
> As a downside, there is added complexity in introducing a model-to-model
> transformation.
>
> If you happen to be using my employer's products (IBM Rational), there
> is a recently published 'Redbook' that covers this topic in some detail.
> If you're interested, go directly to part 4.
>
> http://www.redbooks.ibm.com/redpieces/abstracts/sg247529.htm l?Open
>
> Paul
>
|
|
| |
Re: JET beginner question [message #46463 is a reply to message #46373] |
Wed, 28 May 2008 12:44 |
Timothy Marc Messages: 547 Registered: July 2009 |
Senior Member |
|
|
Dear Felix,
i've done it the way you've described and it works fine.
I'm curious about the JET2 template project. I think i will go on with this
version, because the template editor for JET1 projects are as useful as
notepad :) The jet2 project also seems to be not as fragile as the former
version.
Do you prefer JET2? IMHO, the xpath dependation is a kind a overhead
production, i think? But JET2 can iterate over any Ecore mm, right?
Cheers
timothy
"Felix Dorner" <felix_do@web.de> schrieb im Newsbeitrag
news:g14246$cp8$1@build.eclipse.org...
> Hi Timothy, we share the same boat. I have written a _very_ basic jet
> transformation directly against uml class models.
>
> What I did to make a direct transformation is to make extensive use of
> jet's ability to _annotate_ the model elements with additional variables.
> The general pattern is very well documented in the main.jet template which
> is automatically created when you start a new jet project.
>
> For the annotations, I give you an example:
>
> For mapping uml operations to method signatures, you'd need to do:
>
> for each parameter of the operation
> check out its multiplicity
> check out its type
> check out if it's a return or an argument.
>
> Doing all this directly in the output template makes it very hard to read.
> So I do an initial iteration over the model, and attach this data as ready
> to eat meatballs to every "operation" element.
|
|
| |
Re: JET beginner question [message #46782 is a reply to message #46664] |
Tue, 03 June 2008 08:32 |
Timothy Marc Messages: 547 Registered: July 2009 |
Senior Member |
|
|
Dear Paul,
what is the way to navigate through a UML Class diagramm, for example, with
JET2? May i have to browse the related XMI representation?
Thx
Timothy
"Paul Elder" <pelder@ca.ibm.com> schrieb im Newsbeitrag
news:g1mt78$93k$1@build.eclipse.org...
>
> "Timothy Marc" <timothymarc@freenet.de> wrote in message
> news:g1jk42$73u$1@build.eclipse.org...
>> Do you prefer JET2? IMHO, the xpath dependation is a kind a overhead
>> production, i think? But JET2 can iterate over any Ecore mm, right?
>
> Well, I prefer JET2, but I'm biased :-)
>
> But JET does read Ecore mm.
>
> I won't argue that XPath adds overhead. I'm sure it does. But the trade
> off is that templates can be written w/o Java code (not everyone who wants
> to write templates knows Java).
>
> If you want to write Java code in your templates, you can. All JET
> variables are accessible via
> context.getVariable("name-without-initial-$").
>
> You can import Java classes into a template with <%@jet imports="..." %>
> Remember to add appropriate depencies to MANIFEST.MF.
>
> Paul
>
|
|
| | | |
Goto Forum:
Current Time: Wed Jan 15 13:31:34 GMT 2025
Powered by FUDForum. Page generated in 0.03219 seconds
|