Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » New version of Groovy EMFBuilder supports UML2 models
New version of Groovy EMFBuilder supports UML2 models [message #625653] Wed, 28 November 2007 14:32
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
Previous Topic:Re: UMLProfile vs Ecore
Next Topic:New version of Groovy EMFBuilder supports UML2 models
Goto Forum:
  


Current Time: Wed Apr 24 20:42:32 GMT 2024

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

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

Back to the top