Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Code generation for the UML
Code generation for the UML [message #15867] Thu, 10 May 2007 17:02 Go to next message
Andrew Carton is currently offline Andrew CartonFriend
Messages: 104
Registered: July 2009
Senior Member
Hi,

I was wondering if anyone could point me towards some kind of M2T tool
support that would enable me to generate code from a UML 2 model (EMF
based). Is JET2 suitable for transforming UML2? I had a quick look at a
tutorial and it appears to be based on XML (XPath etc.), so I was
wondering if tools are advanced enough yet to allow the generation of
UML 2 models, at the same abstraction. I don't want to create a
dependency on a specific XMI representation as that specification might
change with later updates to the library. In particular, I need support
for behavioural transformations. Would mapping from code (via the UML2
libraries) be the easiest solution?

If anyone could offer advice on this for possible alternative solutions
I would be grateful.

Thanks,
Andrew.
Re: Code generation for the UML [message #15885 is a reply to message #15867] Fri, 11 May 2007 13:04 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Andrew:

JET2 can read UML models. Some tips:

1) XPath child steps: $someVar/aChildStep or $someVar/child::aChildStep
attempt to match 'aChildStep' to a UML2 feature name. For example,
$aUMLClass/type/@name would access the 'type' feature of Class (and then
return its name).

Failing a feature map, the XPath engine will attempt to use the step name as
an EClass name, and match any instances with-in the parents contents. For
example, $aUMLPackage/Class would match all Class instances (but not
subclasses). This can be quite useful in a massive meta-model such as UML2.

2) There is no special support for UML profiles, so accessing profile
attributes is not obvious. The best approach I can think of is to write some
custom XPath functions.


BUT, A BIG WARNING!

Although JET can read UML models, in the observing the development of many
UML-to-XXX transformations, it has been generally better to factor the
problem into two parts:

1) Create a code generator (with JET, if you like) that is fed by an
intermediate model that exposes only the elements of interest to the code
generator. Typically, this model is also structured to make code generation
easy.

2) Create a UML to intermediate model transformation, and, as a last step,
invoke the code generator.

This approach has a number of advantages:
1) Code generator creation is often best accomplished as a bottom-up
exercise: create a reference output for the code generator, and create
templates and an intermediate model that generates it.

2) UML is a massive meta-model. The exercise of determining how to represent
concepts needed by your code generator is not trivial. In fact, there may be
several valid representations. Determining this mapping independently of the
actual code generation has proved very useful.

Hope this helps, and thanks for considering JET.

Paul

"Andrew Carton" <cartona@cs.tcd.ie> wrote in message
news:f1vj7f$vmc$1@build.eclipse.org...
> Hi,
>
> I was wondering if anyone could point me towards some kind of M2T tool
> support that would enable me to generate code from a UML 2 model (EMF
> based). Is JET2 suitable for transforming UML2? I had a quick look at a
> tutorial and it appears to be based on XML (XPath etc.), so I was
> wondering if tools are advanced enough yet to allow the generation of UML
> 2 models, at the same abstraction. I don't want to create a dependency on
> a specific XMI representation as that specification might change with
> later updates to the library. In particular, I need support for
> behavioural transformations. Would mapping from code (via the UML2
> libraries) be the easiest solution?
>
> If anyone could offer advice on this for possible alternative solutions I
> would be grateful.
>
> Thanks,
> Andrew.
Re: Code generation for the UML [message #15974 is a reply to message #15867] Mon, 14 May 2007 14:25 Go to previous messageGo to next message
Vladimir Sosnin is currently offline Vladimir SosninFriend
Messages: 19
Registered: July 2009
Junior Member
Hello, Andrew,

Seems like the only support JET needs to support UML is convenient query
and iteration tag. For this purpose I developed a simple plugin for JET
that allows to query UML models using OCL expressions. This plugin uses
Eclipse OCL plugin as engine. After getting UML element you can inspect
it using method used for access content of EMF models. It was enough for
me to get UML models transformed into things I needed.

Example:
<ocl:iterate query="Class.allInstances()->select(c |
c.parents()->exists(name='Number'))" var="umlClass" >
UMLClass: <c:get select="$umlClass/@name"/>
Parents: <ocl:iterate query="self.parents()" var="par"
modelroot="$umlClass"><c:get select="$par/@name"/>, </ocl:iterate>
</ocl:iterate>

I haven't published this plugin but it's pretty simple (<200 lines).

Regards,
Vladimir

Andrew Carton wrote:
> Hi,
>
> I was wondering if anyone could point me towards some kind of M2T tool
> support that would enable me to generate code from a UML 2 model (EMF
> based). Is JET2 suitable for transforming UML2? I had a quick look at a
> tutorial and it appears to be based on XML (XPath etc.), so I was
> wondering if tools are advanced enough yet to allow the generation of
> UML 2 models, at the same abstraction. I don't want to create a
> dependency on a specific XMI representation as that specification might
> change with later updates to the library. In particular, I need support
> for behavioural transformations. Would mapping from code (via the UML2
> libraries) be the easiest solution?
>
> If anyone could offer advice on this for possible alternative solutions
> I would be grateful.
>
> Thanks,
> Andrew.
Re: Code generation for the UML [message #16105 is a reply to message #15974] Thu, 17 May 2007 12:38 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Vladimir:

This is very cool. Would you consider contributing it to JET?

Paul

"Vladimir Sosnin" <antiso@gmail.com> wrote in message
news:f29rho$6gp$1@build.eclipse.org...
> Hello, Andrew,
>
> Seems like the only support JET needs to support UML is convenient query
> and iteration tag. For this purpose I developed a simple plugin for JET
> that allows to query UML models using OCL expressions. This plugin uses
> Eclipse OCL plugin as engine. After getting UML element you can inspect
> it using method used for access content of EMF models. It was enough for
> me to get UML models transformed into things I needed.
>
> Example:
> <ocl:iterate query="Class.allInstances()->select(c |
> c.parents()->exists(name='Number'))" var="umlClass" >
> UMLClass: <c:get select="$umlClass/@name"/>
> Parents: <ocl:iterate query="self.parents()" var="par"
> modelroot="$umlClass"><c:get select="$par/@name"/>, </ocl:iterate>
> </ocl:iterate>
>
> I haven't published this plugin but it's pretty simple (<200 lines).
>
> Regards,
> Vladimir
>
> Andrew Carton wrote:
>> Hi,
>>
>> I was wondering if anyone could point me towards some kind of M2T tool
>> support that would enable me to generate code from a UML 2 model (EMF
>> based). Is JET2 suitable for transforming UML2? I had a quick look at a
>> tutorial and it appears to be based on XML (XPath etc.), so I was
>> wondering if tools are advanced enough yet to allow the generation of
>> UML 2 models, at the same abstraction. I don't want to create a
>> dependency on a specific XMI representation as that specification might
>> change with later updates to the library. In particular, I need support
>> for behavioural transformations. Would mapping from code (via the UML2
>> libraries) be the easiest solution?
>>
>> If anyone could offer advice on this for possible alternative solutions
>> I would be grateful.
>>
>> Thanks,
>> Andrew.
Re: Code generation for the UML [message #16973 is a reply to message #16105] Sun, 20 May 2007 20:51 Go to previous messageGo to next message
Vladimir Sosnin is currently offline Vladimir SosninFriend
Messages: 19
Registered: July 2009
Junior Member
Yes, I consider it. Could you please provide me with a starting point(s)
for contributing it to JET?

Regards,
Vladimir

Paul Elder wrote:
> Vladimir:
>
> This is very cool. Would you consider contributing it to JET?
>
> Paul
>
> "Vladimir Sosnin" <antiso@gmail.com> wrote in message
> news:f29rho$6gp$1@build.eclipse.org...
>> Hello, Andrew,
>>
>> Seems like the only support JET needs to support UML is convenient query
>> and iteration tag. For this purpose I developed a simple plugin for JET
>> that allows to query UML models using OCL expressions. This plugin uses
>> Eclipse OCL plugin as engine. After getting UML element you can inspect
>> it using method used for access content of EMF models. It was enough for
>> me to get UML models transformed into things I needed.
>>
>> Example:
>> <ocl:iterate query="Class.allInstances()->select(c |
>> c.parents()->exists(name='Number'))" var="umlClass" >
>> UMLClass: <c:get select="$umlClass/@name"/>
>> Parents: <ocl:iterate query="self.parents()" var="par"
>> modelroot="$umlClass"><c:get select="$par/@name"/>, </ocl:iterate>
>> </ocl:iterate>
>>
>> I haven't published this plugin but it's pretty simple (<200 lines).
>>
>> Regards,
>> Vladimir
>>
>> Andrew Carton wrote:
>>> Hi,
>>>
>>> I was wondering if anyone could point me towards some kind of M2T tool
>>> support that would enable me to generate code from a UML 2 model (EMF
>>> based). Is JET2 suitable for transforming UML2? I had a quick look at a
>>> tutorial and it appears to be based on XML (XPath etc.), so I was
>>> wondering if tools are advanced enough yet to allow the generation of
>>> UML 2 models, at the same abstraction. I don't want to create a
>>> dependency on a specific XMI representation as that specification might
>>> change with later updates to the library. In particular, I need support
>>> for behavioural transformations. Would mapping from code (via the UML2
>>> libraries) be the easiest solution?
>>>
>>> If anyone could offer advice on this for possible alternative solutions
>>> I would be grateful.
>>>
>>> Thanks,
>>> Andrew.
>
>
Re: Code generation for the UML [message #17064 is a reply to message #16973] Tue, 22 May 2007 13:44 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Vladimir:

A contribution from a non-committer must follow the Eclipse Legal Process.
Although it seems complex, the goal is to ensure that code contributed to
Eclipse is 'clean', and will not create legal risks for the Eclipse
Foundation, its members or users. The contribution process is summarized in
the Eclipse Legal Process poster:

http://www.eclipse.org/legal/EclipseLegalProcessPoster.pdf

As you can see, there are many paths through the process. I think the first
questions to ask are:

1) Did you write the code yourself from scratch?
2) Do you have the right to contribute it to Eclipse? The answer to the
second question may depend on your employment contract.
3) Is the code being contributed under the Eclipse Public License (EPL)?

The process can tolerate answers other than 'Yes'; a 'no' just means more
time and process to follow.

If you want to proceed, contact me by e-mail, and we can figure out together
what steps to take first.

Paul

"Vladimir Sosnin" <antiso@gmail.com> wrote in message
news:f2qcd2$nf8$1@build.eclipse.org...
> Yes, I consider it. Could you please provide me with a starting point(s)
> for contributing it to JET?
>
> Regards,
> Vladimir
>
> Paul Elder wrote:
>> Vladimir:
>>
>> This is very cool. Would you consider contributing it to JET?
>>
>> Paul
>>
>> "Vladimir Sosnin" <antiso@gmail.com> wrote in message
>> news:f29rho$6gp$1@build.eclipse.org...
>>> Hello, Andrew,
>>>
>>> Seems like the only support JET needs to support UML is convenient query
>>> and iteration tag. For this purpose I developed a simple plugin for JET
>>> that allows to query UML models using OCL expressions. This plugin uses
>>> Eclipse OCL plugin as engine. After getting UML element you can inspect
>>> it using method used for access content of EMF models. It was enough for
>>> me to get UML models transformed into things I needed.
>>>
>>> Example:
>>> <ocl:iterate query="Class.allInstances()->select(c |
>>> c.parents()->exists(name='Number'))" var="umlClass" >
>>> UMLClass: <c:get select="$umlClass/@name"/>
>>> Parents: <ocl:iterate query="self.parents()" var="par"
>>> modelroot="$umlClass"><c:get select="$par/@name"/>, </ocl:iterate>
>>> </ocl:iterate>
>>>
>>> I haven't published this plugin but it's pretty simple (<200 lines).
>>>
>>> Regards,
>>> Vladimir
>>>
>>> Andrew Carton wrote:
>>>> Hi,
>>>>
>>>> I was wondering if anyone could point me towards some kind of M2T tool
>>>> support that would enable me to generate code from a UML 2 model (EMF
>>>> based). Is JET2 suitable for transforming UML2? I had a quick look at a
>>>> tutorial and it appears to be based on XML (XPath etc.), so I was
>>>> wondering if tools are advanced enough yet to allow the generation of
>>>> UML 2 models, at the same abstraction. I don't want to create a
>>>> dependency on a specific XMI representation as that specification might
>>>> change with later updates to the library. In particular, I need support
>>>> for behavioural transformations. Would mapping from code (via the UML2
>>>> libraries) be the easiest solution?
>>>>
>>>> If anyone could offer advice on this for possible alternative solutions
>>>> I would be grateful.
>>>>
>>>> Thanks,
>>>> Andrew.
>>
Re: Code generation for the UML [message #17301 is a reply to message #15867] Fri, 25 May 2007 19:11 Go to previous message
Eclipse UserFriend
Originally posted by: carrasco.ModelDrivenDevelopment.co.uk

Indeed, MOFscript,
http://www.eclipse.org/gmt/mofscript/
http://modelbased.net/mofscript/

With syntax assisted editor.
Runs on any EMF models and UML.
I just love it, and develop in no other Model to Text language.
Cheers!
ACV






"Andrew Carton" <cartona@cs.tcd.ie> wrote in message
news:f1vj7f$vmc$1@build.eclipse.org...
> Hi,
>
> I was wondering if anyone could point me towards some kind of M2T tool
> support that would enable me to generate code from a UML 2 model (EMF
> based). Is JET2 suitable for transforming UML2? I had a quick look at a
> tutorial and it appears to be based on XML (XPath etc.), so I was
> wondering if tools are advanced enough yet to allow the generation of UML
> 2 models, at the same abstraction. I don't want to create a dependency on
> a specific XMI representation as that specification might change with
> later updates to the library. In particular, I need support for
> behavioural transformations. Would mapping from code (via the UML2
> libraries) be the easiest solution?
>
> If anyone could offer advice on this for possible alternative solutions I
> would be grateful.
>
> Thanks,
> Andrew.
Previous Topic:Trying to use count() on subset of nodes
Next Topic:Multiple Files
Goto Forum:
  


Current Time: Mon Dec 22 10:51:16 GMT 2014

Powered by FUDForum. Page generated in 0.02733 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software