Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » How to specify enum as attributes using Rational Software Modeler(EMF enum RSM)
How to specify enum as attributes using Rational Software Modeler [message #782615] Tue, 24 January 2012 03:52 Go to next message
Edmund Reinhardt is currently offline Edmund ReinhardtFriend
Messages: 8
Registered: January 2012
Junior Member
Hi Ed, it's been a while.
Last time I was using EMF, I used Rational Rose for the diagramming. I have persuaded a new project to go with EMF for the model and I have a couple of question.

1) enum
Now that Java 5 has been around for a while, can EMF generate the native Java enum for enum attributes?
I am using Rational Software Model now to create the class diagrams, how do I go about specifying that I want to use an enum for a particular attribute. I can't find the stereotype to make it work. Is there some features I need to install/configure?
I have researched on the internet and applied the ePackage stereotype but I still can't find the EMF <<enum>> stereotype. Can you tell me what modelling idiom to use to get this simple result?
If I use the Java enum, the EMF reload sees it as a java.lang.Object.
(see screen shots)
index.php/fa/6850/0/
index.php/fa/6851/0/
index.php/fa/6852/0/

2) How do I specify that a Class should implement an Interface. If I use the UML Interface
index.php/fa/6853/0/
A generalization relationship is not allowed and the realization relationship doesn't generate anything in the model .java.
Re: How to specify enum as attributes using Rational Software Modeler [message #782664 is a reply to message #782615] Tue, 24 January 2012 07:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Edmund,

Comments below.

On 24/01/2012 4:52 AM, Edmund Reinhardt wrote:
> Hi Ed, it's been a while.
> Last time I was using EMF, I used Rational Rose for the diagramming.
Not exactly an open source tool. :-P
> I have persuaded a new project to go with EMF for the model and I have a couple of question.
>
> 1) enum
> Now that Java 5 has been around for a while, can EMF generate the native Java enum for enum attributes?
Yes. It was even nice that we could generate them in a binary
compatible way.
> I am using Rational Software Model now to create the class diagrams, how do I go about specifying that I want to use an enum for a particular attribute.
So you're using UML2...
> I can't find the stereotype to make it work. Is there some features I need to install/configure?
Maybe UML2 has enumerations.
> I have researched on the internet and applied the ePackage stereotype but I still can't find the EMF<<enum>> stereotype. Can you tell me what modelling idiom to use to get this simple result?
> If I use the Java enum, the EMF reload sees it as a java.lang.Object.
> (see screen shots)
>
>
>
>
> 2) How do I specify that a Class should implement an Interface. If I use the UML Interface
Unfortunately I'm not sure how to do either, and these days I haven't
got UML2 source in my workspace.

There's Ecore Tools which you can use to create diagrams directly for
Ecore; it's not as polished as IBM's produce though.
>
> A generalization relationship is not allowed and the realization relationship doesn't generate anything in the model .java.
Here's a good way to get the tool to provide the answer. Take your
Ecore model, create a GenModel for it; from the context menu for the
resource using File->New->Other...->Eclipse Modeling Framework->EMF
Generator Model. Then open the Generator model, and from the context
menu of the root, use Export Model... to export it to UML2. I believe
that should produce a UML2 instance that, when reimported to Ecore, will
produce the original Ecore model again.

I'm pretty sure UML2 provides a specialized Ecore profile that's used to
record/specify details not directly specifiable in UML2; this will help
you discover it and how to use it.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to specify enum as attributes using Rational Software Modeler [message #782714 is a reply to message #782664] Tue, 24 January 2012 09:25 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI
>> I can't find the stereotype to make it work. Is there some
>> features I need to install/configure?
> Maybe UML2 has enumerations.
>>
See SimpleTypeEnum in /org.eclipse.ocl/model/OCLCST.uml which has an
EEnum stereotype.

Regards

Ed Willink
Re: How to specify enum as attributes using Rational Software Modeler [message #782933 is a reply to message #782714] Tue, 24 January 2012 19:07 Go to previous messageGo to next message
Edmund Reinhardt is currently offline Edmund ReinhardtFriend
Messages: 8
Registered: January 2012
Junior Member
Good news, for Interface extension, all you have to do is switch the type of Realization to Interface Realization and then it works.
Ed, your tip about working backwards helped me know what to look for.

When an ecore.genmodel exports, it exports to a .uml file which is not the same as the .emx file I am starting with, but it at least gave me a clue.


Re: How to specify enum as attributes using Rational Software Modeler [message #782941 is a reply to message #782933] Tue, 24 January 2012 19:26 Go to previous messageGo to next message
Edmund Reinhardt is currently offline Edmund ReinhardtFriend
Messages: 8
Registered: January 2012
Junior Member
index.php/fa/6860/0/
As you can see, the trick is switching the palette item to "Interface Realization"
  • Attachment: pallete.jpg
    (Size: 12.15KB, Downloaded 924 times)
Re: How to specify enum as attributes using Rational Software Modeler [message #782976 is a reply to message #782933] Tue, 24 January 2012 21:18 Go to previous messageGo to next message
Edmund Reinhardt is currently offline Edmund ReinhardtFriend
Messages: 8
Registered: January 2012
Junior Member
Here is the answer to the enum mystery
(Thanks for your help, both Eds)

In order to get access to the Ecore primitive types, you need import the model library.
But the instructions on the internet are dated because are for RSA 6.x and I am working with RSA 8.x.
{can put http because the forum doesn't trust me to put links in yet)//sdqweb.ipd.kit.edu/wiki/Creating_EMF-Models_with_RSA#Using_ECORE_data_types

To do this for 8.x, you need to open the model in an editor and go to the Details tab and hit the import button there.
See {can put http because the forum doesn't trust me to put links in yet)//www.ibm.com/developerworks/forums/thread.jspa?messageID=14644708

But there was one more wrinkle. The <<eenum>> stereotypes only apply to UML Enumerations, and none were visible on my palette, even after digging under the divoted Class icon.
But they were visible on the models I imported via Ed and Ed's advice. The problem was that by default on the package's properties, under the Capabilities tab, some of the UI elements were filtered out.
See
index.php/fa/6863/0/

By unchecking this filter, the Enumeration became visible on the palette and the eenum stereotypes could be applied.
index.php/fa/6864/0/

Thanks again for all your help.
Re: How to specify enum as attributes using Rational Software Modeler [message #783186 is a reply to message #782976] Wed, 25 January 2012 08:51 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Edmund,

Thanks for the details from your investigation. They will help the next
person who has the same problem!


On 24/01/2012 10:18 PM, Edmund Reinhardt wrote:
> Here is the answer to the enum mystery
> (Thanks for your help, both Eds)
>
> In order to get access to the Ecore primitive types, you need import the model library.
> But the instructions on the internet are dated because are for RSA 6.x and I am working with RSA 8.x.
> {can put http because the forum doesn't trust me to put links in yet)//sdqweb.ipd.kit.edu/wiki/Creating_EMF-Models_with_RSA#Using_ECORE_data_types
>
> To do this for 8.x, you need to open the model in an editor and go to the Details tab and hit the import button there.
> See {can put http because the forum doesn't trust me to put links in yet)//www.ibm.com/developerworks/forums/thread.jspa?messageID=14644708
>
> But there was one more wrinkle. The<<eenum>> stereotypes only apply to UML Enumerations, and none were visible on my palette, even after digging under the divoted Class icon.
> But they were visible on the models I imported via Ed and Ed's advice. The problem was that by default on the package's properties, under the Capabilities tab, some of the UI elements were filtered out.
> See
>
>
> By unchecking this filter, the Enumeration became visible on the palette and the eenum stereotypes could be applied.
>
>
> Thanks again for all your help.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EMF CP] NewModelElementWizard for non root elements
Next Topic:[Texo] Problem creating opposite relations
Goto Forum:
  


Current Time: Tue Apr 16 15:49:22 GMT 2024

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

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

Back to the top