Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » New version of Groovy EMFBuilder supports UML2 models
New version of Groovy EMFBuilder supports UML2 models [message #415035] Wed, 28 November 2007 14:32 Go to next message
Joern Dinkla is currently offline Joern DinklaFriend
Messages: 8
Registered: July 2009
Junior Member
Hi all,

The new version of the Groovy EMFBuilder (see
http://www.dinkla.net/groovy/emf.html) now supports UML2 models.

The Groovy programming language allows the creation of domain specific
languages with its "BuilderSupport" class. This is used by EMFBuilder to
create a language defined by an Ecore EFactory. Because UML2 uses EMF,
UML2 models can be created using the EMFBuilder.

See the following examples and compare with the "Getting Started with
UML2" article at
http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Getti ng_Started_with_UML2/article.html.

We use the UMLFactory for the EMFBuilder.

def builder = new EMFBuilder(UMLFactory)

We create a model as the root node and we create primitive types and
store them in Groovy variables because we have to reference them later on.

def epo2Model = builder.Model(name: 'epo2') {
packagedElement {
def intPrimType = PrimitiveType(name: 'int')
def stringPrimType = PrimitiveType(name: 'String')

We define an enumeration OrderStatus with three literals.

def orderStatusEnumeration = Enumeration(name: 'OrderStatus') {
ownedLiteral {
EnumerationLiteral(name: 'Pending')
EnumerationLiteral(name: 'Back Order')
EnumerationLiteral(name: 'Complete')
}
}

The following code snippet shows the definition of the classes Address
and USAddress. All the attributes are defined as a Property. The
primitive types stringPrimType and intPrimType defined above are used.
The class USAddress is a subclass of the abstract class Address. This is
expressed with the Generalization object.

def addressClass = Class(name: 'Address' ,isAbstract: true) {
ownedAttribute {
Property(name: 'name', type: stringPrimType, lower: 0, upper: 1)
Property(name: 'country', type: stringPrimType, lower: 0,upper: 1)
}
}
def usAddressClass = Class(name: 'USAddress') {
generalization {
Generalization(general: addressClass)
}
ownedAttribute {
Property(name: 'street', type: stringPrimType, lower: 0, upper: 1)
Property(name: 'city', type: stringPrimType, lower: 0, upper: 1)
Property(name: 'state', type: stringPrimType, lower: 0, upper: 1)
Property(name: 'zip', type: intPrimType, lower: 0, upper: 1)
}
}

The code is a direct representation of the UML2 diagram.

See the homepage of the UML2 Builder for further details at
http://www.dinkla.net/groovy/uml2.html.

Best regards,

Joern Dinkla

--
Dipl.-Inform. Jörn Dinkla
Freelancer - http://www.dinkla.net
Dorotheenstrasse 133, 22299 Hamburg, Germany
Re: New version of Groovy EMFBuilder supports UML2 models [message #415038 is a reply to message #415035] Wed, 28 November 2007 14:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Joern,

This sounds too cool. I wish I had time to explore. I wonder if this
might make an interesting EMFT component? Are you interested in that?
There's a proposal for a C#-based version of EMF so this seems kind of
like a similar thing...


Joern Dinkla wrote:
> Hi all,
>
> The new version of the Groovy EMFBuilder (see
> http://www.dinkla.net/groovy/emf.html) now supports UML2 models.
>
> The Groovy programming language allows the creation of domain specific
> languages with its "BuilderSupport" class. This is used by EMFBuilder
> to create a language defined by an Ecore EFactory. Because UML2 uses
> EMF, UML2 models can be created using the EMFBuilder.
>
> See the following examples and compare with the "Getting Started with
> UML2" article at
> http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Getti ng_Started_with_UML2/article.html.
>
>
> We use the UMLFactory for the EMFBuilder.
>
> def builder = new EMFBuilder(UMLFactory)
>
> We create a model as the root node and we create primitive types and
> store them in Groovy variables because we have to reference them later
> on.
>
> def epo2Model = builder.Model(name: 'epo2') {
> packagedElement {
> def intPrimType = PrimitiveType(name: 'int')
> def stringPrimType = PrimitiveType(name: 'String')
>
> We define an enumeration OrderStatus with three literals.
>
> def orderStatusEnumeration = Enumeration(name: 'OrderStatus') {
> ownedLiteral {
> EnumerationLiteral(name: 'Pending')
> EnumerationLiteral(name: 'Back Order')
> EnumerationLiteral(name: 'Complete')
> }
> }
>
> The following code snippet shows the definition of the classes Address
> and USAddress. All the attributes are defined as a Property. The
> primitive types stringPrimType and intPrimType defined above are used.
> The class USAddress is a subclass of the abstract class Address. This
> is expressed with the Generalization object.
>
> def addressClass = Class(name: 'Address' ,isAbstract: true) {
> ownedAttribute {
> Property(name: 'name', type: stringPrimType, lower: 0, upper: 1)
> Property(name: 'country', type: stringPrimType, lower: 0,upper: 1)
> }
> }
> def usAddressClass = Class(name: 'USAddress') {
> generalization {
> Generalization(general: addressClass)
> }
> ownedAttribute {
> Property(name: 'street', type: stringPrimType, lower: 0, upper: 1)
> Property(name: 'city', type: stringPrimType, lower: 0, upper: 1)
> Property(name: 'state', type: stringPrimType, lower: 0, upper: 1)
> Property(name: 'zip', type: intPrimType, lower: 0, upper: 1)
> }
> }
>
> The code is a direct representation of the UML2 diagram.
>
> See the homepage of the UML2 Builder for further details at
> http://www.dinkla.net/groovy/uml2.html.
>
> Best regards,
>
> Joern Dinkla
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: New version of Groovy EMFBuilder supports UML2 models [message #415044 is a reply to message #415038] Wed, 28 November 2007 15:41 Go to previous message
Joern Dinkla is currently offline Joern DinklaFriend
Messages: 8
Registered: July 2009
Junior Member
Yes Ed,

I am interested, but I think the EMFBuilder is too small in scope for a regular EMFT
component. The EMFBuilder basically is just a wrapper around the createXXX() methods of an
EFactory.

I will add a reference to the Modeling Corner.

Best regards,

Joern

Ed Merks wrote:
> Joern,
>
> This sounds too cool. I wish I had time to explore. I wonder if this
> might make an interesting EMFT component? Are you interested in that?
> There's a proposal for a C#-based version of EMF so this seems kind of
> like a similar thing...
>
>
> Joern Dinkla wrote:
>> Hi all,
>>
>> The new version of the Groovy EMFBuilder (see
>> http://www.dinkla.net/groovy/emf.html) now supports UML2 models.
>>
>> The Groovy programming language allows the creation of domain specific
>> languages with its "BuilderSupport" class. This is used by EMFBuilder
>> to create a language defined by an Ecore EFactory. Because UML2 uses
>> EMF, UML2 models can be created using the EMFBuilder.
>>
>> See the following examples and compare with the "Getting Started with
>> UML2" article at
>> http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Getti ng_Started_with_UML2/article.html.
>>
>>
>> We use the UMLFactory for the EMFBuilder.
>>
>> def builder = new EMFBuilder(UMLFactory)
>>
>> We create a model as the root node and we create primitive types and
>> store them in Groovy variables because we have to reference them later
>> on.
>>
>> def epo2Model = builder.Model(name: 'epo2') {
>> packagedElement {
>> def intPrimType = PrimitiveType(name: 'int')
>> def stringPrimType = PrimitiveType(name: 'String')
>>
>> We define an enumeration OrderStatus with three literals.
>>
>> def orderStatusEnumeration = Enumeration(name: 'OrderStatus') {
>> ownedLiteral {
>> EnumerationLiteral(name: 'Pending')
>> EnumerationLiteral(name: 'Back Order')
>> EnumerationLiteral(name: 'Complete')
>> }
>> }
>>
>> The following code snippet shows the definition of the classes Address
>> and USAddress. All the attributes are defined as a Property. The
>> primitive types stringPrimType and intPrimType defined above are used.
>> The class USAddress is a subclass of the abstract class Address. This
>> is expressed with the Generalization object.
>>
>> def addressClass = Class(name: 'Address' ,isAbstract: true) {
>> ownedAttribute {
>> Property(name: 'name', type: stringPrimType, lower: 0, upper: 1)
>> Property(name: 'country', type: stringPrimType, lower: 0,upper: 1)
>> }
>> }
>> def usAddressClass = Class(name: 'USAddress') {
>> generalization {
>> Generalization(general: addressClass)
>> }
>> ownedAttribute {
>> Property(name: 'street', type: stringPrimType, lower: 0, upper: 1)
>> Property(name: 'city', type: stringPrimType, lower: 0, upper: 1)
>> Property(name: 'state', type: stringPrimType, lower: 0, upper: 1)
>> Property(name: 'zip', type: intPrimType, lower: 0, upper: 1)
>> }
>> }
>>
>> The code is a direct representation of the UML2 diagram.
>>
>> See the homepage of the UML2 Builder for further details at
>> http://www.dinkla.net/groovy/uml2.html.
>>
>> Best regards,
>>
>> Joern Dinkla
>>


--
Dipl.-Inform. Jörn Dinkla
Freelancer - http://www.dinkla.net
Dorotheenstrasse 133, 22299 Hamburg, Germany
Previous Topic:Custom code for list of enums
Next Topic:IllegalStateException : no transaction is active
Goto Forum:
  


Current Time: Thu Mar 28 19:35:23 GMT 2024

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

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

Back to the top