Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » dynamic EMF profiles
dynamic EMF profiles [message #476231] Thu, 27 September 2007 18:19 Go to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi all,

I would like to statically import a known profile to my uml-model -
therefore I'd like to generate model code. I looked over the uml2 code
but couldn't find where dynamic emf is used there and how I can avoid it
for a specific profile.

- -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG+/QyIYVWjMSpDwwRAle4AKC5gJhaFeID9BYHMy5HXNfr4/2a1wCg 1hIu
Fag/rAc/fXcVOd//S6xBXAs=
=2oib
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #476235 is a reply to message #476231] Fri, 28 September 2007 13:37 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Stefan,

I hope I'm interpreting this question correctly - you are asking how to do
static profile definition. I just wanted to point out that with a
statically defined profiles there is no need to "define" ( create an ecore
representation attached as an annotation ) your profile in the traditional
way and therefore, dynamic EMF doesn't come into the picture ( hence the
term "statically defined" ).

There are several steps involved...



----------- Create your Profile -------------
1. Create your uml profile as you would normally ( For example, create a
stereotype called MyExtendedClass that extends uml:Class ). (see the getting
started article for details ). (Call it My.profile.uml for example)
2. ** don't do the "define" step ***
3. On your profile, apply the <<ePackage>> stereotype from the existing
Ecore profile.
4. Set the nsURI to something ... say http://www.myOrg/MyProfile

------- Generate code ---------
1. Create an EMF project as you would from any other .uml model to generate
code from but specify your profile as the source ( My.profile.uml )
2. Select the "Process All" options when loading your My.profile.uml.
3. Generate code as you would normally from the resulting .genmodel.

------- Using your profile ------
Up to this point, things were pretty easy. Here comes the tricky part...

1. Move your previously generated code for your profile to your development
environment.
2. Create a new plugin in your development environment ( say a JUnit plugin
to get started with ).
3. In your JUnit plugin test, add the line:

UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is the
id of the profile in your model.
4. Create a resource set and load your My.profile.uml.
5. Next, Load your profile using..
Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
.... )
from the already generated MyProfilePackage from the "Generate Code"
step.
6. Next, obtain your stereotype with..
Stereotype myStereotype =
myProfile.getOwnedStereotype("MyExtendedClass");
7. This is the interesting part ... Apply your stereotype as follows:
MyExtendedClass myExtendedClass =
(MyExtendedClass)myClass.applyStereotype(myStereotype);
Notice how you do not get a stereotype application but rather a type of
"MyExtendedClass".
8. Now you have full access to setting variagbles to MyExtendedClass etc.
--- how cool is that ;) ----

Note: There is an extension point exposed to help with the registration
that we are doing in step 3 but I noticed that there is a bug ( I don't
think the schema was properly exported ... that will be fixed shortly ).

Cheers,

- James.





"SKuhn" <kuhn@oio.de> wrote in message
news:fdgs8p$c5d$1@build.eclipse.org...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> hi all,
>
> I would like to statically import a known profile to my uml-model -
> therefore I'd like to generate model code. I looked over the uml2 code
> but couldn't find where dynamic emf is used there and how I can avoid it
> for a specific profile.
>
> - -stefan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFG+/QyIYVWjMSpDwwRAle4AKC5gJhaFeID9BYHMy5HXNfr4/2a1wCg 1hIu
> Fag/rAc/fXcVOd//S6xBXAs=
> =2oib
> -----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #476243 is a reply to message #476235] Fri, 28 September 2007 16:09 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

awesome, that looks really good. Thanks a lot.
Could I've found these steps in any tutorial? What's the name of the
extension point and with which version will the problem be fixed?

- -stefan


James Bruck schrieb:
> Hi Stefan,
>
> I hope I'm interpreting this question correctly - you are asking how to do
> static profile definition. I just wanted to point out that with a
> statically defined profiles there is no need to "define" ( create an ecore
> representation attached as an annotation ) your profile in the traditional
> way and therefore, dynamic EMF doesn't come into the picture ( hence the
> term "statically defined" ).
>
> There are several steps involved...
>
>
>
> ----------- Create your Profile -------------
> 1. Create your uml profile as you would normally ( For example, create a
> stereotype called MyExtendedClass that extends uml:Class ). (see the getting
> started article for details ). (Call it My.profile.uml for example)
> 2. ** don't do the "define" step ***
> 3. On your profile, apply the <<ePackage>> stereotype from the existing
> Ecore profile.
> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>
> ------- Generate code ---------
> 1. Create an EMF project as you would from any other .uml model to generate
> code from but specify your profile as the source ( My.profile.uml )
> 2. Select the "Process All" options when loading your My.profile.uml.
> 3. Generate code as you would normally from the resulting .genmodel.
>
> ------- Using your profile ------
> Up to this point, things were pretty easy. Here comes the tricky part...
>
> 1. Move your previously generated code for your profile to your development
> environment.
> 2. Create a new plugin in your development environment ( say a JUnit plugin
> to get started with ).
> 3. In your JUnit plugin test, add the line:
>
> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is the
> id of the profile in your model.
> 4. Create a resource set and load your My.profile.uml.
> 5. Next, Load your profile using..
> Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
> ... )
> from the already generated MyProfilePackage from the "Generate Code"
> step.
> 6. Next, obtain your stereotype with..
> Stereotype myStereotype =
> myProfile.getOwnedStereotype("MyExtendedClass");
> 7. This is the interesting part ... Apply your stereotype as follows:
> MyExtendedClass myExtendedClass =
> (MyExtendedClass)myClass.applyStereotype(myStereotype);
> Notice how you do not get a stereotype application but rather a type of
> "MyExtendedClass".
> 8. Now you have full access to setting variagbles to MyExtendedClass etc.
> --- how cool is that ;) ----
>
> Note: There is an extension point exposed to help with the registration
> that we are doing in step 3 but I noticed that there is a bug ( I don't
> think the schema was properly exported ... that will be fixed shortly ).
>
> Cheers,
>
> - James.
>
>
>
>
>
> "SKuhn" <kuhn@oio.de> wrote in message
> news:fdgs8p$c5d$1@build.eclipse.org...
> hi all,
>
> I would like to statically import a known profile to my uml-model -
> therefore I'd like to generate model code. I looked over the uml2 code
> but couldn't find where dynamic emf is used there and how I can avoid it
> for a specific profile.
>
> -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG/Sc6IYVWjMSpDwwRAn6gAKDUBv0w4vwx2FZvbvXIP858egxisgCf ZA/n
mcixjiqqQFrHjvu644UhsR4=
=/La/
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #476244 is a reply to message #476235] Fri, 28 September 2007 16:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

In the last post, on 09/28 about 03h, "James" (James Bruck) wrote:
James> This is the interesting part ... Apply your stereotype as follows
James> [...] Notice how you do not get a stereotype application but
James> rather a type of "MyExtendedClass"

hello,

I have just read this post. I think it solves a lot of my problems. I didn't
really understand how to use static profile. I thought first, that it was
possible to extend the basic UML editor to get the behavior given by a genmodel
chain from a profile.

But, from what I can understand, in order to get the expected behavior we have
to extend/define our own editor to load the profile and create the appropriate
bindings. However, I may still use my profile as usual in the UML editor (with
no behavior). Both solution produce same UML xmi files and thus I can still
interchange my files. Is it right?

thanks.
--
F. Lagarde
Re: dynamic EMF profiles [message #476245 is a reply to message #476243] Fri, 28 September 2007 16:59 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Unfortunately there is no detailed tutorial yet ... it is being worked on
and should be a more detailed step by step guide.
The name of the extension point is: generated_package.exsd in
org.eclipse.uml2.uml plugin. If you get the source code there is some
more documentation etc.
The extension point will be fixed in 2.2 M2 ( unfortunately 2.1.1 was just
released before I noticed the mistake ).

- James.



"SKuhn" <kuhn@oio.de> wrote in message
news:fdj912$a3j$1@build.eclipse.org...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> awesome, that looks really good. Thanks a lot.
> Could I've found these steps in any tutorial? What's the name of the
> extension point and with which version will the problem be fixed?
>
> - -stefan
>
>
> James Bruck schrieb:
> > Hi Stefan,
> >
> > I hope I'm interpreting this question correctly - you are asking how to
do
> > static profile definition. I just wanted to point out that with a
> > statically defined profiles there is no need to "define" ( create an
ecore
> > representation attached as an annotation ) your profile in the
traditional
> > way and therefore, dynamic EMF doesn't come into the picture ( hence the
> > term "statically defined" ).
> >
> > There are several steps involved...
> >
> >
> >
> > ----------- Create your Profile -------------
> > 1. Create your uml profile as you would normally ( For example, create a
> > stereotype called MyExtendedClass that extends uml:Class ). (see the
getting
> > started article for details ). (Call it My.profile.uml for example)
> > 2. ** don't do the "define" step ***
> > 3. On your profile, apply the <<ePackage>> stereotype from the existing
> > Ecore profile.
> > 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
> >
> > ------- Generate code ---------
> > 1. Create an EMF project as you would from any other .uml model to
generate
> > code from but specify your profile as the source ( My.profile.uml )
> > 2. Select the "Process All" options when loading your My.profile.uml.
> > 3. Generate code as you would normally from the resulting .genmodel.
> >
> > ------- Using your profile ------
> > Up to this point, things were pretty easy. Here comes the tricky
part...
> >
> > 1. Move your previously generated code for your profile to your
development
> > environment.
> > 2. Create a new plugin in your development environment ( say a JUnit
plugin
> > to get started with ).
> > 3. In your JUnit plugin test, add the line:
> >
> >
UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
> > Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is
the
> > id of the profile in your model.
> > 4. Create a resource set and load your My.profile.uml.
> > 5. Next, Load your profile using..
> > Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
> > ... )
> > from the already generated MyProfilePackage from the "Generate Code"
> > step.
> > 6. Next, obtain your stereotype with..
> > Stereotype myStereotype =
> > myProfile.getOwnedStereotype("MyExtendedClass");
> > 7. This is the interesting part ... Apply your stereotype as follows:
> > MyExtendedClass myExtendedClass =
> > (MyExtendedClass)myClass.applyStereotype(myStereotype);
> > Notice how you do not get a stereotype application but rather a type
of
> > "MyExtendedClass".
> > 8. Now you have full access to setting variagbles to MyExtendedClass
etc.
> > --- how cool is that ;) ----
> >
> > Note: There is an extension point exposed to help with the registration
> > that we are doing in step 3 but I noticed that there is a bug ( I don't
> > think the schema was properly exported ... that will be fixed shortly ).
> >
> > Cheers,
> >
> > - James.
> >
> >
> >
> >
> >
> > "SKuhn" <kuhn@oio.de> wrote in message
> > news:fdgs8p$c5d$1@build.eclipse.org...
> > hi all,
> >
> > I would like to statically import a known profile to my uml-model -
> > therefore I'd like to generate model code. I looked over the uml2 code
> > but couldn't find where dynamic emf is used there and how I can avoid it
> > for a specific profile.
> >
> > -stefan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFG/Sc6IYVWjMSpDwwRAn6gAKDUBv0w4vwx2FZvbvXIP858egxisgCf ZA/n
> mcixjiqqQFrHjvu644UhsR4=
> =/La/
> -----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #476247 is a reply to message #476244] Sun, 30 September 2007 10:04 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi François,
> I thought first, that it was possible to extend the
> basic UML editor to get the behavior given by a genmodel
> chain from a profile.
well, I'm not quite sure if I got this right. A genmodel chain, you mean
the auto-gen. EMF-tree editor? It already supports profiles so there
would be performance and change of generated behaviour as benefit.
Actually I asked this for a GMF editor I'm making.

> But, from what I can understand, in order to get the expected behavior
> we have to extend/define our own editor to load the profile and create
> the appropriate bindings.
I hope for you not & don't think so. The editor should be able to load
the profile as normal (of course now in a runtime workbench) and the
changed behavior should work as long as you use this profile with an
eclipse based uml tool. I don't think you need to create appropriate
bindings, let us hope a registry takes care of this.

> However, I may still use my profile as usual in the UML editor (with
> no behavior).
no, you need to use your profile in a runtime-eclipse. That we didn't
'define' our profile might cause problems, too.

- -stefan


François Lagarde schrieb:
> In the last post, on 09/28 about 03h, "James" (James Bruck) wrote:
> James> This is the interesting part ... Apply your stereotype as follows
> James> [...] Notice how you do not get a stereotype application but
> James> rather a type of "MyExtendedClass"
>
> hello,
>
> I have just read this post. I think it solves a lot of my problems. I didn't
> really understand how to use static profile. I thought first, that it was
> possible to extend the basic UML editor to get the behavior given by a genmodel
> chain from a profile.
>
> But, from what I can understand, in order to get the expected behavior we have
> to extend/define our own editor to load the profile and create the appropriate
> bindings. However, I may still use my profile as usual in the UML editor (with
> no behavior). Both solution produce same UML xmi files and thus I can still
> interchange my files. Is it right?
>
> thanks.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG/3S0IYVWjMSpDwwRAjJYAKDT/K51Eme0gx9bzAaTMVcjg5wbjQCf ThMS
LtZdNvd+V7GU9Dg84P+ouew=
=fNfR
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #476268 is a reply to message #476235] Thu, 04 October 2007 15:38 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi james,

is it possible to generate/create an adapter/proxy class for
"MyExtendedClass" which decorates the stereotyped classifier + the
stereotype instance?

- -stefan


James Bruck schrieb:
> Hi Stefan,
>
> I hope I'm interpreting this question correctly - you are asking how to do
> static profile definition. I just wanted to point out that with a
> statically defined profiles there is no need to "define" ( create an ecore
> representation attached as an annotation ) your profile in the traditional
> way and therefore, dynamic EMF doesn't come into the picture ( hence the
> term "statically defined" ).
>
> There are several steps involved...
>
>
>
> ----------- Create your Profile -------------
> 1. Create your uml profile as you would normally ( For example, create a
> stereotype called MyExtendedClass that extends uml:Class ). (see the getting
> started article for details ). (Call it My.profile.uml for example)
> 2. ** don't do the "define" step ***
> 3. On your profile, apply the <<ePackage>> stereotype from the existing
> Ecore profile.
> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>
> ------- Generate code ---------
> 1. Create an EMF project as you would from any other .uml model to generate
> code from but specify your profile as the source ( My.profile.uml )
> 2. Select the "Process All" options when loading your My.profile.uml.
> 3. Generate code as you would normally from the resulting .genmodel.
>
> ------- Using your profile ------
> Up to this point, things were pretty easy. Here comes the tricky part...
>
> 1. Move your previously generated code for your profile to your development
> environment.
> 2. Create a new plugin in your development environment ( say a JUnit plugin
> to get started with ).
> 3. In your JUnit plugin test, add the line:
>
> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is the
> id of the profile in your model.
> 4. Create a resource set and load your My.profile.uml.
> 5. Next, Load your profile using..
> Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
> ... )
> from the already generated MyProfilePackage from the "Generate Code"
> step.
> 6. Next, obtain your stereotype with..
> Stereotype myStereotype =
> myProfile.getOwnedStereotype("MyExtendedClass");
> 7. This is the interesting part ... Apply your stereotype as follows:
> MyExtendedClass myExtendedClass =
> (MyExtendedClass)myClass.applyStereotype(myStereotype);
> Notice how you do not get a stereotype application but rather a type of
> "MyExtendedClass".
> 8. Now you have full access to setting variagbles to MyExtendedClass etc.
> --- how cool is that ;) ----
>
> Note: There is an extension point exposed to help with the registration
> that we are doing in step 3 but I noticed that there is a bug ( I don't
> think the schema was properly exported ... that will be fixed shortly ).
>
> Cheers,
>
> - James.
>
>
>
>
>
> "SKuhn" <kuhn@oio.de> wrote in message
> news:fdgs8p$c5d$1@build.eclipse.org...
> hi all,
>
> I would like to statically import a known profile to my uml-model -
> therefore I'd like to generate model code. I looked over the uml2 code
> but couldn't find where dynamic emf is used there and how I can avoid it
> for a specific profile.
>
> -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHBQkDIYVWjMSpDwwRApLBAKCubpp9dxa9MPDHTICuxqZZGdeccACf QavW
Ez3jM4lHwUFPcKQvU32aw+s=
=vJqO
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #476351 is a reply to message #476245] Tue, 09 October 2007 14:26 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030401020602020103040706
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi james,

I tried to follow your instructions but didn't succeed. I attached the
sources, maybe you can take a look at it or provide a working example.

- -stefan


James Bruck schrieb:
> Unfortunately there is no detailed tutorial yet ... it is being worked on
> and should be a more detailed step by step guide.
> The name of the extension point is: generated_package.exsd in
> org.eclipse.uml2.uml plugin. If you get the source code there is some
> more documentation etc.
> The extension point will be fixed in 2.2 M2 ( unfortunately 2.1.1 was just
> released before I noticed the mistake ).
>
> - James.
>
>
>
> "SKuhn" <kuhn@oio.de> wrote in message
> news:fdj912$a3j$1@build.eclipse.org...
> awesome, that looks really good. Thanks a lot.
> Could I've found these steps in any tutorial? What's the name of the
> extension point and with which version will the problem be fixed?
>
> -stefan
>
>
> James Bruck schrieb:
>>>> Hi Stefan,
>>>>
>>>> I hope I'm interpreting this question correctly - you are asking how to
>> do
>>>> static profile definition. I just wanted to point out that with a
>>>> statically defined profiles there is no need to "define" ( create an
>> ecore
>>>> representation attached as an annotation ) your profile in the
>> traditional
>>>> way and therefore, dynamic EMF doesn't come into the picture ( hence the
>>>> term "statically defined" ).
>>>>
>>>> There are several steps involved...
>>>>
>>>>
>>>>
>>>> ----------- Create your Profile -------------
>>>> 1. Create your uml profile as you would normally ( For example, create a
>>>> stereotype called MyExtendedClass that extends uml:Class ). (see the
>> getting
>>>> started article for details ). (Call it My.profile.uml for example)
>>>> 2. ** don't do the "define" step ***
>>>> 3. On your profile, apply the <<ePackage>> stereotype from the existing
>>>> Ecore profile.
>>>> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>>>>
>>>> ------- Generate code ---------
>>>> 1. Create an EMF project as you would from any other .uml model to
>> generate
>>>> code from but specify your profile as the source ( My.profile.uml )
>>>> 2. Select the "Process All" options when loading your My.profile.uml.
>>>> 3. Generate code as you would normally from the resulting .genmodel.
>>>>
>>>> ------- Using your profile ------
>>>> Up to this point, things were pretty easy. Here comes the tricky
>> part...
>>>> 1. Move your previously generated code for your profile to your
>> development
>>>> environment.
>>>> 2. Create a new plugin in your development environment ( say a JUnit
>> plugin
>>>> to get started with ).
>>>> 3. In your JUnit plugin test, add the line:
>>>>
>>>>
>> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
>>>> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is
>> the
>>>> id of the profile in your model.
>>>> 4. Create a resource set and load your My.profile.uml.
>>>> 5. Next, Load your profile using..
>>>> Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
>>>> ... )
>>>> from the already generated MyProfilePackage from the "Generate Code"
>>>> step.
>>>> 6. Next, obtain your stereotype with..
>>>> Stereotype myStereotype =
>>>> myProfile.getOwnedStereotype("MyExtendedClass");
>>>> 7. This is the interesting part ... Apply your stereotype as follows:
>>>> MyExtendedClass myExtendedClass =
>>>> (MyExtendedClass)myClass.applyStereotype(myStereotype);
>>>> Notice how you do not get a stereotype application but rather a type
>> of
>>>> "MyExtendedClass".
>>>> 8. Now you have full access to setting variagbles to MyExtendedClass
>> etc.
>>>> --- how cool is that ;) ----
>>>>
>>>> Note: There is an extension point exposed to help with the registration
>>>> that we are doing in step 3 but I noticed that there is a bug ( I don't
>>>> think the schema was properly exported ... that will be fixed shortly ).
>>>>
>>>> Cheers,
>>>>
>>>> - James.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> "SKuhn" <kuhn@oio.de> wrote in message
>>>> news:fdgs8p$c5d$1@build.eclipse.org...
>>>> hi all,
>>>>
>>>> I would like to statically import a known profile to my uml-model -
>>>> therefore I'd like to generate model code. I looked over the uml2 code
>>>> but couldn't find where dynamic emf is used there and how I can avoid it
>>>> for a specific profile.
>>>>
>>>> -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHC4+JIYVWjMSpDwwRAgDqAKDHEJnumbro1s4FDP728ilhILF63ACd FYpX
GtrTjvk9c9Cadmeg6U4A+y8=
=ov4b
-----END PGP SIGNATURE-----

--------------030401020602020103040706
Content-Type: text/x-java;
name="Bsp.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Bsp.java"

package umlExpl;

import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.common.util.UML2Util;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.UMLPlugin;
import org.eclipse.uml2.uml.resource.UMLResource;
import org.eclipse.uml2.uml.util.UMLUtil;

import Profile.Complex;
import Profile.POCPackage;

public class Bsp {
public static ResourceSet resourceSet = null;
/**
* @param args
*/
public static void main(String[] args) {
initResourceSet();
Model root = createModel("test");

Resource resource = createResource(fileURI());
resource.getContents().add(root);


Profile meinProfile = stereotypeTest();

Package myPackage = createPackage(root, "meinPacket");
Class myClass = createClass(myPackage, "meineKlasse");

// meinProfile= stdProfil();

root.applyProfile(meinProfile);
// myPackage.applyProfile(anderesProfil);
// for (Profile prof : myPackage.getAllAppliedProfiles()) {
// System.out.println(prof);
// }


printStereos(myClass);
// Stereotype meinStereo = meinProfile.getOwnedStereotype("MitTaggedV");
Stereotype meinStereo = meinProfile.getOwnedStereotype("Complex");


UMLUtil.safeApplyStereotype(myClass, meinStereo);
// myClass.applyStereotype(andererStereo);

save(resource);
// Complex complex = (Complex) myClass.applyStereotype(meinStereo);

}


private static Profile stdProfil(){
Resource stdUML = resourceSet.getResource(URI.createFileURI(" /home/qn/Coden/workspace-oAW/POC_Prof/model/POC_1.profile.um l "), true);
Profile meinProfil= (org.eclipse.uml2.uml.Profile) EcoreUtil.getObjectByType(stdUML.getContents(), UMLPackage.Literals.PROFILE);
return meinProfil;
}

private static void muell(){
try {
resourceSet.getResource(URI
.createURI(UMLResource.STANDARD_PROFILE_URI), true);

resourceSet.getResource(URI
.createURI(UMLResource.ECORE_PROFILE_URI), true);
} catch (Exception e) {
// ignore
}
}

private static void printStereos(Classifier myClass) {
System.out.println("Anwendbare Stereotypen: ");
for (Stereotype stereotyp : myClass.getApplicableStereotypes()) {
System.out.println("Stereotyp: " + stereotyp);
}
System.out.println("Anwendbare Stereotypen ende");
}

private static void printStereosApplied(Classifier myClass) {
System.out.println("Angewendete Stereotypen: ");
for (Stereotype stereotyp : myClass.getAppliedStereotypes()) {
System.out.println("Angewendete: " + stereotyp);
}
System.out.println("Anwendbare Stereotypen ende");
}

public static void save(Resource resource){
// Print the contents of the resource to System.out.
try
{
resource.save(Collections.EMPTY_MAP);
}
catch (IOException e) {
System.out.println("Fehler "+e.toString());
}
}

public static URI fileURI(){
File file = new File("testModelle/testModell.uml");
System.out.println("Datein mit Pfad "+file.getAbsolutePath()+ " erzeugt.");
URI fileURI = URI.createFileURI(file.getAbsolutePath());
return fileURI;
}

public static void initResourceSet(){
resourceSet = new ResourceSetImpl();

resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI,URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI(" jar:file:/home/qn/Coden/eclipse-oAW/plugins/org.eclipse.uml2 .uml.resources_2.1.0.v200706251652.jar!/ ");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
}

public static Resource createResource(URI location) {
Resource resource = resourceSet.createResource(location);
return resource;
}

public static Profile stereotypeTest() {
URI uri2file = URI
.createURI(" /home/qn/Coden/workspace-oAW/StaticProfile/model/default.pro file.uml ").appendFragment("_uy27sHWxEdyjl9eZlwzeuA");
//_V_rHMHW3Edyjl9eZlwzeuA
//_uy27sHWxEdyjl9eZlwzeuA sollte ok sein
System.out.println("File exists? " + new File(uri2file.path()).exists());

Resource profilResource = resourceSet.getResource(uri2file, true); //System.out.println("contains? "+resourceSet.getResources().contains(profilResource));

Map<URI,URI> uriMap = resourceSet.getURIConverter().getURIMap();
UMLPlugin.getEPackageNsURIToProfileLocationMap().put("de.oio.POC ",uri2file);
URI uri = URI.createURI(" /home/qn/Coden/workspace-oAW/StaticProfile/model/default.pro file.uml ");
uriMap.put(URI.createURI("de.oio.POC"), uri2file);

// uri.appendSegment("libraries").appendSegment(""));

// resourceSet.getPackageRegistry().put("de.oio.POC",POCPackage.eINSTANCE);
// System.out.println("profilResource.getURI()= "+profilResource.getURI());

Profile myProfile = UMLUtil.getProfile(POCPackage.eINSTANCE);
System.out.println("Profile == null? "+Boolean.toString(myProfile==null));


Profile meinProfil = null;
//Weg I (klappt bei mir aber zeigt nix)
//(Profile)profilResource.getAllContents().next();

//Weg II
meinProfil = (org.eclipse.uml2.uml.Profile) EcoreUtil.getObjectByType(profilResource.getContents(), UMLPackage.Literals.PROFILE);

if(true)
return meinProfil;
return myProfile;
}

public static Model createModel(String name) {
Model model = UMLFactory.eINSTANCE.createModel();
model.setName(name);

System.out.println("Model " + model.getQualifiedName() + " created");

return model;
}

public static Package createPackage(Package parentPackage, String name) {
Package newPackage = parentPackage.createNestedPackage(name);
// System.out.println("Package " + newPackage.getQualifiedName()
// + " created in " + parentPackage.getQualifiedName());
return newPackage;
}

public static Class createClass(Package parentPackage, String name) {
Class clazz = parentPackage.createOwnedClass(name, false);
// System.out.println("Klasse " + clazz.getQualifiedName()+" erzeugt");
return clazz;
}
}

--------------030401020602020103040706
Content-Type: text/xml;
name="default.umlprofile_diagram"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="default.umlprofile_diagram"

<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.1/notation" xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML" xmi:id="_u88r0HWxEdyjl9eZlwzeuA" type="UMLProfile" name="default.umlprofile_diagram" measurementUnit="Pixel">
<children xmi:type="notation:Node" xmi:id="_wCzgoHWxEdyjl9eZlwzeuA" type="2007">
<children xmi:type="notation:Node" xmi:id="_wC0uwHWxEdyjl9eZlwzeuA" type="5009"/>
<children xmi:type="notation:Node" xmi:id="_wC4ZIHWxEdyjl9eZlwzeuA" type="7005">
<styles xmi:type="notation:DrawerStyle" xmi:id="_wC5AMHWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_wC5AMXWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_wC5AMnWxEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_wCzgoXWxEdyjl9eZlwzeuA" fontName="Verdana"/>
<element xmi:type="uml:Profile" href="default.profile.uml#_uy27sHWxEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_wCzgonWxEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_zD8WYHWxEdyjl9eZlwzeuA" type="2001">
<children xmi:type="notation:Node" xmi:id="_zD89cHWxEdyjl9eZlwzeuA" type="5001"/>
<children xmi:type="notation:Node" xmi:id="_zD9kgHWxEdyjl9eZlwzeuA" type="7001">
<children xmi:type="notation:Node" xmi:id="_M-l6gHWyEdyjl9eZlwzeuA" type="3001">
<element xmi:type="uml:Property" href="default.profile.uml#_M-XRAHWyEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_M-l6gXWyEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_NyKsgHWyEdyjl9eZlwzeuA" type="3001">
<element xmi:type="uml:Property" href="default.profile.uml#_Nx8DAHWyEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_NyKsgXWyEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:DrawerStyle" xmi:id="_zD9kgXWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_zD9kgnWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_zD9kg3WxEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_zD-LkHWxEdyjl9eZlwzeuA" type="7002">
<styles xmi:type="notation:DrawerStyle" xmi:id="_zD-LkXWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_zD-LknWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_zD-Lk3WxEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_zD8WYXWxEdyjl9eZlwzeuA" fontName="Verdana"/>
<element xmi:type="uml:Stereotype" href="default.profile.uml#_zDHP8HWxEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_zD8WYnWxEdyjl9eZlwzeuA" x="251" y="203"/>
</children>
<children xmi:type="notation:Node" xmi:id="_1K5b0HWxEdyjl9eZlwzeuA" type="2001">
<children xmi:type="notation:Node" xmi:id="_1K5b03WxEdyjl9eZlwzeuA" type="5001"/>
<children xmi:type="notation:Node" xmi:id="_1K6C4HWxEdyjl9eZlwzeuA" type="7001">
<styles xmi:type="notation:DrawerStyle" xmi:id="_1K6C4XWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_1K6C4nWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_1K6C43WxEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_1K6C5HWxEdyjl9eZlwzeuA" type="7002">
<styles xmi:type="notation:DrawerStyle" xmi:id="_1K6C5XWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_1K6C5nWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_1K6C53WxEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_1K5b0XWxEdyjl9eZlwzeuA" fontName="Verdana"/>
<element xmi:type="uml:Stereotype" href="default.profile.uml#_1K1KYHWxEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_1K5b0nWxEdyjl9eZlwzeuA" x="592" y="220"/>
</children>
<children xmi:type="notation:Node" xmi:id="_3fG6IHWxEdyjl9eZlwzeuA" type="2003">
<children xmi:type="notation:Node" xmi:id="_3fHhMHWxEdyjl9eZlwzeuA" type="5005"/>
<children xmi:type="notation:Node" xmi:id="_3fIIQHWxEdyjl9eZlwzeuA" type="7004">
<children xmi:type="notation:Node" xmi:id="_Hea2gHWyEdyjl9eZlwzeuA" type="3005">
<element xmi:type="uml:EnumerationLiteral" href="default.profile.uml#_HeMNAHWyEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_Hea2gXWyEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_LxaVsHWyEdyjl9eZlwzeuA" type="3005">
<element xmi:type="uml:EnumerationLiteral" href="default.profile.uml#_LxJ3AHWyEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_LxaVsXWyEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:DrawerStyle" xmi:id="_3fIIQXWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_3fIIQnWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_3fIIQ3WxEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_3fG6IXWxEdyjl9eZlwzeuA" fontName="Verdana"/>
<element xmi:type="uml:Enumeration" href="default.profile.uml#_3e2bcHWxEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_3fG6InWxEdyjl9eZlwzeuA" x="352" y="48"/>
</children>
<children xmi:type="notation:Node" xmi:id="_7ujoYHX5EdyT4bcDFauwJQ" type="2001">
<children xmi:type="notation:Node" xmi:id="_7ukPcHX5EdyT4bcDFauwJQ" type="5001"/>
<children xmi:type="notation:Node" xmi:id="_7uk2gHX5EdyT4bcDFauwJQ" type="7001">
<styles xmi:type="notation:DrawerStyle" xmi:id="_7uk2gXX5EdyT4bcDFauwJQ"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_7uk2gnX5EdyT4bcDFauwJQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_7uk2g3X5EdyT4bcDFauwJQ"/>
</children>
<children xmi:type="notation:Node" xmi:id="_7uldkHX5EdyT4bcDFauwJQ" type="7002">
<styles xmi:type="notation:DrawerStyle" xmi:id="_7uldkXX5EdyT4bcDFauwJQ"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_7uldknX5EdyT4bcDFauwJQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_7uldk3X5EdyT4bcDFauwJQ"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_7ujoYXX5EdyT4bcDFauwJQ" fontName="Verdana"/>
<element xmi:type="uml:Stereotype" href="default.profile.uml#_7tqQgHX5EdyT4bcDFauwJQ"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_7ujoYnX5EdyT4bcDFauwJQ" x="328" y="395"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_u88r0XWxEdyjl9eZlwzeuA"/>
<element xmi:type="uml:Profile" href="default.profile.uml#_uy27sHWxEdyjl9eZlwzeuA"/>
</notation:Diagram>

--------------030401020602020103040706--
Re: dynamic EMF profiles [message #476358 is a reply to message #476351] Wed, 10 October 2007 19:18 Go to previous messageGo to next message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

any ideas?

- -stefan

SKuhn schrieb:
> hi james,
>
> I tried to follow your instructions but didn't succeed. I attached the
> sources, maybe you can take a look at it or provide a working example.
>
> -stefan
>
>
> James Bruck schrieb:
>> Unfortunately there is no detailed tutorial yet ... it is being worked on
>> and should be a more detailed step by step guide.
>> The name of the extension point is: generated_package.exsd in
>> org.eclipse.uml2.uml plugin. If you get the source code there is some
>> more documentation etc.
>> The extension point will be fixed in 2.2 M2 ( unfortunately 2.1.1 was just
>> released before I noticed the mistake ).
>
>> - James.
>
>
>
>> "SKuhn" <kuhn@oio.de> wrote in message
>> news:fdj912$a3j$1@build.eclipse.org...
>> awesome, that looks really good. Thanks a lot.
>> Could I've found these steps in any tutorial? What's the name of the
>> extension point and with which version will the problem be fixed?
>
>> -stefan
>
>
>> James Bruck schrieb:
>>>>> Hi Stefan,
>>>>>
>>>>> I hope I'm interpreting this question correctly - you are asking how to
>>> do
>>>>> static profile definition. I just wanted to point out that with a
>>>>> statically defined profiles there is no need to "define" ( create an
>>> ecore
>>>>> representation attached as an annotation ) your profile in the
>>> traditional
>>>>> way and therefore, dynamic EMF doesn't come into the picture ( hence the
>>>>> term "statically defined" ).
>>>>>
>>>>> There are several steps involved...
>>>>>
>>>>>
>>>>>
>>>>> ----------- Create your Profile -------------
>>>>> 1. Create your uml profile as you would normally ( For example, create a
>>>>> stereotype called MyExtendedClass that extends uml:Class ). (see the
>>> getting
>>>>> started article for details ). (Call it My.profile.uml for example)
>>>>> 2. ** don't do the "define" step ***
>>>>> 3. On your profile, apply the <<ePackage>> stereotype from the existing
>>>>> Ecore profile.
>>>>> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>>>>>
>>>>> ------- Generate code ---------
>>>>> 1. Create an EMF project as you would from any other .uml model to
>>> generate
>>>>> code from but specify your profile as the source ( My.profile.uml )
>>>>> 2. Select the "Process All" options when loading your My.profile.uml.
>>>>> 3. Generate code as you would normally from the resulting .genmodel.
>>>>>
>>>>> ------- Using your profile ------
>>>>> Up to this point, things were pretty easy. Here comes the tricky
>>> part...
>>>>> 1. Move your previously generated code for your profile to your
>>> development
>>>>> environment.
>>>>> 2. Create a new plugin in your development environment ( say a JUnit
>>> plugin
>>>>> to get started with ).
>>>>> 3. In your JUnit plugin test, add the line:
>>>>>
>>>>>
>>> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
>>>>> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is
>>> the
>>>>> id of the profile in your model.
>>>>> 4. Create a resource set and load your My.profile.uml.
>>>>> 5. Next, Load your profile using..
>>>>> Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
>>>>> ... )
>>>>> from the already generated MyProfilePackage from the "Generate Code"
>>>>> step.
>>>>> 6. Next, obtain your stereotype with..
>>>>> Stereotype myStereotype =
>>>>> myProfile.getOwnedStereotype("MyExtendedClass");
>>>>> 7. This is the interesting part ... Apply your stereotype as follows:
>>>>> MyExtendedClass myExtendedClass =
>>>>> (MyExtendedClass)myClass.applyStereotype(myStereotype);
>>>>> Notice how you do not get a stereotype application but rather a type
>>> of
>>>>> "MyExtendedClass".
>>>>> 8. Now you have full access to setting variagbles to MyExtendedClass
>>> etc.
>>>>> --- how cool is that ;) ----
>>>>>
>>>>> Note: There is an extension point exposed to help with the registration
>>>>> that we are doing in step 3 but I noticed that there is a bug ( I don't
>>>>> think the schema was properly exported ... that will be fixed shortly ).
>>>>>
>>>>> Cheers,
>>>>>
>>>>> - James.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> "SKuhn" <kuhn@oio.de> wrote in message
>>>>> news:fdgs8p$c5d$1@build.eclipse.org...
>>>>> hi all,
>>>>>
>>>>> I would like to statically import a known profile to my uml-model -
>>>>> therefore I'd like to generate model code. I looked over the uml2 code
>>>>> but couldn't find where dynamic emf is used there and how I can avoid it
>>>>> for a specific profile.
>>>>>
>>>>> -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHDSVxIYVWjMSpDwwRArn9AJ9nqf9nRjjDX8yt3H3jed3/h4uABQCe JMWs
/ZTEq/pDLyjDGUxFfIKtoQ4=
=HRVF
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #476359 is a reply to message #476358] Wed, 10 October 2007 22:20 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
I looks like you didn't attach default.profile.uml.
You did attach some diagram of the profile though (no nsURI set up with
<<ePackage>> stereotype).

I'll post a step-by-step guide as soon as I can.

Cheers,

- James.



"SKuhn" <kuhn@oio.de> wrote in message
news:fej8j0$961$2@build.eclipse.org...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> any ideas?
>
> - -stefan
>
> SKuhn schrieb:
>> hi james,
>>
>> I tried to follow your instructions but didn't succeed. I attached the
>> sources, maybe you can take a look at it or provide a working example.
>>
>> -stefan
>>
>>
>> James Bruck schrieb:
>>> Unfortunately there is no detailed tutorial yet ... it is being worked
>>> on
>>> and should be a more detailed step by step guide.
>>> The name of the extension point is: generated_package.exsd in
>>> org.eclipse.uml2.uml plugin. If you get the source code there is some
>>> more documentation etc.
>>> The extension point will be fixed in 2.2 M2 ( unfortunately 2.1.1 was
>>> just
>>> released before I noticed the mistake ).
>>
>>> - James.
>>
>>
>>
>>> "SKuhn" <kuhn@oio.de> wrote in message
>>> news:fdj912$a3j$1@build.eclipse.org...
>>> awesome, that looks really good. Thanks a lot.
>>> Could I've found these steps in any tutorial? What's the name of the
>>> extension point and with which version will the problem be fixed?
>>
>>> -stefan
>>
>>
>>> James Bruck schrieb:
>>>>>> Hi Stefan,
>>>>>>
>>>>>> I hope I'm interpreting this question correctly - you are asking how
>>>>>> to
>>>> do
>>>>>> static profile definition. I just wanted to point out that with a
>>>>>> statically defined profiles there is no need to "define" ( create an
>>>> ecore
>>>>>> representation attached as an annotation ) your profile in the
>>>> traditional
>>>>>> way and therefore, dynamic EMF doesn't come into the picture ( hence
>>>>>> the
>>>>>> term "statically defined" ).
>>>>>>
>>>>>> There are several steps involved...
>>>>>>
>>>>>>
>>>>>>
>>>>>> ----------- Create your Profile -------------
>>>>>> 1. Create your uml profile as you would normally ( For example,
>>>>>> create a
>>>>>> stereotype called MyExtendedClass that extends uml:Class ). (see the
>>>> getting
>>>>>> started article for details ). (Call it My.profile.uml for example)
>>>>>> 2. ** don't do the "define" step ***
>>>>>> 3. On your profile, apply the <<ePackage>> stereotype from the
>>>>>> existing
>>>>>> Ecore profile.
>>>>>> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>>>>>>
>>>>>> ------- Generate code ---------
>>>>>> 1. Create an EMF project as you would from any other .uml model to
>>>> generate
>>>>>> code from but specify your profile as the source ( My.profile.uml )
>>>>>> 2. Select the "Process All" options when loading your My.profile.uml.
>>>>>> 3. Generate code as you would normally from the resulting .genmodel.
>>>>>>
>>>>>> ------- Using your profile ------
>>>>>> Up to this point, things were pretty easy. Here comes the tricky
>>>> part...
>>>>>> 1. Move your previously generated code for your profile to your
>>>> development
>>>>>> environment.
>>>>>> 2. Create a new plugin in your development environment ( say a JUnit
>>>> plugin
>>>>>> to get started with ).
>>>>>> 3. In your JUnit plugin test, add the line:
>>>>>>
>>>>>>
>>>> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
>>>>>> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX
>>>>>> is
>>>> the
>>>>>> id of the profile in your model.
>>>>>> 4. Create a resource set and load your My.profile.uml.
>>>>>> 5. Next, Load your profile using..
>>>>>> Profile myProfile =
>>>>>> UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
>>>>>> ... )
>>>>>> from the already generated MyProfilePackage from the "Generate
>>>>>> Code"
>>>>>> step.
>>>>>> 6. Next, obtain your stereotype with..
>>>>>> Stereotype myStereotype =
>>>>>> myProfile.getOwnedStereotype("MyExtendedClass");
>>>>>> 7. This is the interesting part ... Apply your stereotype as
>>>>>> follows:
>>>>>> MyExtendedClass myExtendedClass =
>>>>>> (MyExtendedClass)myClass.applyStereotype(myStereotype);
>>>>>> Notice how you do not get a stereotype application but rather a
>>>>>> type
>>>> of
>>>>>> "MyExtendedClass".
>>>>>> 8. Now you have full access to setting variagbles to MyExtendedClass
>>>> etc.
>>>>>> --- how cool is that ;) ----
>>>>>>
>>>>>> Note: There is an extension point exposed to help with the
>>>>>> registration
>>>>>> that we are doing in step 3 but I noticed that there is a bug ( I
>>>>>> don't
>>>>>> think the schema was properly exported ... that will be fixed
>>>>>> shortly ).
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> - James.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> "SKuhn" <kuhn@oio.de> wrote in message
>>>>>> news:fdgs8p$c5d$1@build.eclipse.org...
>>>>>> hi all,
>>>>>>
>>>>>> I would like to statically import a known profile to my uml-model -
>>>>>> therefore I'd like to generate model code. I looked over the uml2
>>>>>> code
>>>>>> but couldn't find where dynamic emf is used there and how I can avoid
>>>>>> it
>>>>>> for a specific profile.
>>>>>>
>>>>>> -stefan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFHDSVxIYVWjMSpDwwRArn9AJ9nqf9nRjjDX8yt3H3jed3/h4uABQCe JMWs
> /ZTEq/pDLyjDGUxFfIKtoQ4=
> =HRVF
> -----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #476383 is a reply to message #476358] Thu, 11 October 2007 09:05 Go to previous messageGo to next message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Hello Stefan,

I succeeded with this, adapt it to your case first.

String s =
" D:\\workspace\\eclipse-europa\\TestProfile\\model\\MyProfile .profile.uml ";

ResourceSet set = new ResourceSetImpl();
set.getPackageRegistry().put(MyProfilePackage.eNS_URI,
MyProfilePackage.eINSTANCE);
set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
set.getResourceFactoryRegistry().getExtensionToFactoryMap(). put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Map uriMap = set.getURIConverter().getURIMap();
URI uri =
URI.createURI(" jar:file:/C:/Tools/eclipse-europa-modeling/eclipse/plugins/o rg.eclipse.uml2.uml.resources_2.1.0.v200706251652.jar!/ ");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
uri.appendSegment("profiles").appendSegment(""));

Resource res = set.getResource(URI.createFileURI(s), true);

Profile myProfile = (org.eclipse.uml2.uml.Profile)
EcoreUtil.getObjectByType(res.getContents(), UMLPackage.Literals.PROFILE);

Stereotype myStereotype = myProfile.getOwnedStereotype("MyStereotype");

org.eclipse.uml2.uml.Package myPackage =
UMLFactory.eINSTANCE.createPackage();
myPackage.applyProfile(myProfile);

org.eclipse.uml2.uml.Class myClass = UMLFactory.eINSTANCE.createClass();
myClass.setPackage(myPackage);
myClass.setName("Class");
MyStereotype myExtendedClass = (MyStereotype)
myClass.applyStereotype(myStereotype);
myExtendedClass.setAttribute(true);

System.out.println(myClass.getName()); // > Class
System.out.println(myExtendedClass.isAttribute()); // > true
Re: dynamic EMF profiles [message #476385 is a reply to message #476268] Thu, 11 October 2007 09:37 Go to previous message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Hello Stefan,

But what if a stereotype extend 2 metaclasses and each metaclass has
different attributes?

- With one decorator for both, you would have some attributes without
value.
- With two decorators, one for each metaclass, the handle of the types
would not be very appealing (to me, -particular opinion-)

I think I'd rather a get method in the stereotype class returning the
metaclass instance, because now we have to keep the reference to both: the
metaclass instance and the stereotype instance. It could return the common
supertype of the metaclasses (EObject or Object in the worst case).

Maybe also a method to query which metaclass is actually extending.

What do you think?
Re: dynamic EMF profiles [message #625042 is a reply to message #476231] Fri, 28 September 2007 13:37 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Stefan,

I hope I'm interpreting this question correctly - you are asking how to do
static profile definition. I just wanted to point out that with a
statically defined profiles there is no need to "define" ( create an ecore
representation attached as an annotation ) your profile in the traditional
way and therefore, dynamic EMF doesn't come into the picture ( hence the
term "statically defined" ).

There are several steps involved...



----------- Create your Profile -------------
1. Create your uml profile as you would normally ( For example, create a
stereotype called MyExtendedClass that extends uml:Class ). (see the getting
started article for details ). (Call it My.profile.uml for example)
2. ** don't do the "define" step ***
3. On your profile, apply the <<ePackage>> stereotype from the existing
Ecore profile.
4. Set the nsURI to something ... say http://www.myOrg/MyProfile

------- Generate code ---------
1. Create an EMF project as you would from any other .uml model to generate
code from but specify your profile as the source ( My.profile.uml )
2. Select the "Process All" options when loading your My.profile.uml.
3. Generate code as you would normally from the resulting .genmodel.

------- Using your profile ------
Up to this point, things were pretty easy. Here comes the tricky part...

1. Move your previously generated code for your profile to your development
environment.
2. Create a new plugin in your development environment ( say a JUnit plugin
to get started with ).
3. In your JUnit plugin test, add the line:

UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is the
id of the profile in your model.
4. Create a resource set and load your My.profile.uml.
5. Next, Load your profile using..
Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
.... )
from the already generated MyProfilePackage from the "Generate Code"
step.
6. Next, obtain your stereotype with..
Stereotype myStereotype =
myProfile.getOwnedStereotype("MyExtendedClass");
7. This is the interesting part ... Apply your stereotype as follows:
MyExtendedClass myExtendedClass =
(MyExtendedClass)myClass.applyStereotype(myStereotype);
Notice how you do not get a stereotype application but rather a type of
"MyExtendedClass".
8. Now you have full access to setting variagbles to MyExtendedClass etc.
--- how cool is that ;) ----

Note: There is an extension point exposed to help with the registration
that we are doing in step 3 but I noticed that there is a bug ( I don't
think the schema was properly exported ... that will be fixed shortly ).

Cheers,

- James.





"SKuhn" <kuhn@oio.de> wrote in message
news:fdgs8p$c5d$1@build.eclipse.org...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> hi all,
>
> I would like to statically import a known profile to my uml-model -
> therefore I'd like to generate model code. I looked over the uml2 code
> but couldn't find where dynamic emf is used there and how I can avoid it
> for a specific profile.
>
> - -stefan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFG+/QyIYVWjMSpDwwRAle4AKC5gJhaFeID9BYHMy5HXNfr4/2a1wCg 1hIu
> Fag/rAc/fXcVOd//S6xBXAs=
> =2oib
> -----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #625054 is a reply to message #476235] Fri, 28 September 2007 16:09 Go to previous message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

awesome, that looks really good. Thanks a lot.
Could I've found these steps in any tutorial? What's the name of the
extension point and with which version will the problem be fixed?

- -stefan


James Bruck schrieb:
> Hi Stefan,
>
> I hope I'm interpreting this question correctly - you are asking how to do
> static profile definition. I just wanted to point out that with a
> statically defined profiles there is no need to "define" ( create an ecore
> representation attached as an annotation ) your profile in the traditional
> way and therefore, dynamic EMF doesn't come into the picture ( hence the
> term "statically defined" ).
>
> There are several steps involved...
>
>
>
> ----------- Create your Profile -------------
> 1. Create your uml profile as you would normally ( For example, create a
> stereotype called MyExtendedClass that extends uml:Class ). (see the getting
> started article for details ). (Call it My.profile.uml for example)
> 2. ** don't do the "define" step ***
> 3. On your profile, apply the <<ePackage>> stereotype from the existing
> Ecore profile.
> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>
> ------- Generate code ---------
> 1. Create an EMF project as you would from any other .uml model to generate
> code from but specify your profile as the source ( My.profile.uml )
> 2. Select the "Process All" options when loading your My.profile.uml.
> 3. Generate code as you would normally from the resulting .genmodel.
>
> ------- Using your profile ------
> Up to this point, things were pretty easy. Here comes the tricky part...
>
> 1. Move your previously generated code for your profile to your development
> environment.
> 2. Create a new plugin in your development environment ( say a JUnit plugin
> to get started with ).
> 3. In your JUnit plugin test, add the line:
>
> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is the
> id of the profile in your model.
> 4. Create a resource set and load your My.profile.uml.
> 5. Next, Load your profile using..
> Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
> ... )
> from the already generated MyProfilePackage from the "Generate Code"
> step.
> 6. Next, obtain your stereotype with..
> Stereotype myStereotype =
> myProfile.getOwnedStereotype("MyExtendedClass");
> 7. This is the interesting part ... Apply your stereotype as follows:
> MyExtendedClass myExtendedClass =
> (MyExtendedClass)myClass.applyStereotype(myStereotype);
> Notice how you do not get a stereotype application but rather a type of
> "MyExtendedClass".
> 8. Now you have full access to setting variagbles to MyExtendedClass etc.
> --- how cool is that ;) ----
>
> Note: There is an extension point exposed to help with the registration
> that we are doing in step 3 but I noticed that there is a bug ( I don't
> think the schema was properly exported ... that will be fixed shortly ).
>
> Cheers,
>
> - James.
>
>
>
>
>
> "SKuhn" <kuhn@oio.de> wrote in message
> news:fdgs8p$c5d$1@build.eclipse.org...
> hi all,
>
> I would like to statically import a known profile to my uml-model -
> therefore I'd like to generate model code. I looked over the uml2 code
> but couldn't find where dynamic emf is used there and how I can avoid it
> for a specific profile.
>
> -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG/Sc6IYVWjMSpDwwRAn6gAKDUBv0w4vwx2FZvbvXIP858egxisgCf ZA/n
mcixjiqqQFrHjvu644UhsR4=
=/La/
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #625056 is a reply to message #476235] Fri, 28 September 2007 16:19 Go to previous message
Eclipse UserFriend
Originally posted by: firstname.name.gmail.com

In the last post, on 09/28 about 03h, "James" (James Bruck) wrote:
James> This is the interesting part ... Apply your stereotype as follows
James> [...] Notice how you do not get a stereotype application but
James> rather a type of "MyExtendedClass"

hello,

I have just read this post. I think it solves a lot of my problems. I didn't
really understand how to use static profile. I thought first, that it was
possible to extend the basic UML editor to get the behavior given by a genmodel
chain from a profile.

But, from what I can understand, in order to get the expected behavior we have
to extend/define our own editor to load the profile and create the appropriate
bindings. However, I may still use my profile as usual in the UML editor (with
no behavior). Both solution produce same UML xmi files and thus I can still
interchange my files. Is it right?

thanks.
--
F. Lagarde
Re: dynamic EMF profiles [message #625057 is a reply to message #476243] Fri, 28 September 2007 16:59 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Unfortunately there is no detailed tutorial yet ... it is being worked on
and should be a more detailed step by step guide.
The name of the extension point is: generated_package.exsd in
org.eclipse.uml2.uml plugin. If you get the source code there is some
more documentation etc.
The extension point will be fixed in 2.2 M2 ( unfortunately 2.1.1 was just
released before I noticed the mistake ).

- James.



"SKuhn" <kuhn@oio.de> wrote in message
news:fdj912$a3j$1@build.eclipse.org...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> awesome, that looks really good. Thanks a lot.
> Could I've found these steps in any tutorial? What's the name of the
> extension point and with which version will the problem be fixed?
>
> - -stefan
>
>
> James Bruck schrieb:
> > Hi Stefan,
> >
> > I hope I'm interpreting this question correctly - you are asking how to
do
> > static profile definition. I just wanted to point out that with a
> > statically defined profiles there is no need to "define" ( create an
ecore
> > representation attached as an annotation ) your profile in the
traditional
> > way and therefore, dynamic EMF doesn't come into the picture ( hence the
> > term "statically defined" ).
> >
> > There are several steps involved...
> >
> >
> >
> > ----------- Create your Profile -------------
> > 1. Create your uml profile as you would normally ( For example, create a
> > stereotype called MyExtendedClass that extends uml:Class ). (see the
getting
> > started article for details ). (Call it My.profile.uml for example)
> > 2. ** don't do the "define" step ***
> > 3. On your profile, apply the <<ePackage>> stereotype from the existing
> > Ecore profile.
> > 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
> >
> > ------- Generate code ---------
> > 1. Create an EMF project as you would from any other .uml model to
generate
> > code from but specify your profile as the source ( My.profile.uml )
> > 2. Select the "Process All" options when loading your My.profile.uml.
> > 3. Generate code as you would normally from the resulting .genmodel.
> >
> > ------- Using your profile ------
> > Up to this point, things were pretty easy. Here comes the tricky
part...
> >
> > 1. Move your previously generated code for your profile to your
development
> > environment.
> > 2. Create a new plugin in your development environment ( say a JUnit
plugin
> > to get started with ).
> > 3. In your JUnit plugin test, add the line:
> >
> >
UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
> > Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is
the
> > id of the profile in your model.
> > 4. Create a resource set and load your My.profile.uml.
> > 5. Next, Load your profile using..
> > Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
> > ... )
> > from the already generated MyProfilePackage from the "Generate Code"
> > step.
> > 6. Next, obtain your stereotype with..
> > Stereotype myStereotype =
> > myProfile.getOwnedStereotype("MyExtendedClass");
> > 7. This is the interesting part ... Apply your stereotype as follows:
> > MyExtendedClass myExtendedClass =
> > (MyExtendedClass)myClass.applyStereotype(myStereotype);
> > Notice how you do not get a stereotype application but rather a type
of
> > "MyExtendedClass".
> > 8. Now you have full access to setting variagbles to MyExtendedClass
etc.
> > --- how cool is that ;) ----
> >
> > Note: There is an extension point exposed to help with the registration
> > that we are doing in step 3 but I noticed that there is a bug ( I don't
> > think the schema was properly exported ... that will be fixed shortly ).
> >
> > Cheers,
> >
> > - James.
> >
> >
> >
> >
> >
> > "SKuhn" <kuhn@oio.de> wrote in message
> > news:fdgs8p$c5d$1@build.eclipse.org...
> > hi all,
> >
> > I would like to statically import a known profile to my uml-model -
> > therefore I'd like to generate model code. I looked over the uml2 code
> > but couldn't find where dynamic emf is used there and how I can avoid it
> > for a specific profile.
> >
> > -stefan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFG/Sc6IYVWjMSpDwwRAn6gAKDUBv0w4vwx2FZvbvXIP858egxisgCf ZA/n
> mcixjiqqQFrHjvu644UhsR4=
> =/La/
> -----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #625059 is a reply to message #476244] Sun, 30 September 2007 10:04 Go to previous message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi François,
> I thought first, that it was possible to extend the
> basic UML editor to get the behavior given by a genmodel
> chain from a profile.
well, I'm not quite sure if I got this right. A genmodel chain, you mean
the auto-gen. EMF-tree editor? It already supports profiles so there
would be performance and change of generated behaviour as benefit.
Actually I asked this for a GMF editor I'm making.

> But, from what I can understand, in order to get the expected behavior
> we have to extend/define our own editor to load the profile and create
> the appropriate bindings.
I hope for you not & don't think so. The editor should be able to load
the profile as normal (of course now in a runtime workbench) and the
changed behavior should work as long as you use this profile with an
eclipse based uml tool. I don't think you need to create appropriate
bindings, let us hope a registry takes care of this.

> However, I may still use my profile as usual in the UML editor (with
> no behavior).
no, you need to use your profile in a runtime-eclipse. That we didn't
'define' our profile might cause problems, too.

- -stefan


François Lagarde schrieb:
> In the last post, on 09/28 about 03h, "James" (James Bruck) wrote:
> James> This is the interesting part ... Apply your stereotype as follows
> James> [...] Notice how you do not get a stereotype application but
> James> rather a type of "MyExtendedClass"
>
> hello,
>
> I have just read this post. I think it solves a lot of my problems. I didn't
> really understand how to use static profile. I thought first, that it was
> possible to extend the basic UML editor to get the behavior given by a genmodel
> chain from a profile.
>
> But, from what I can understand, in order to get the expected behavior we have
> to extend/define our own editor to load the profile and create the appropriate
> bindings. However, I may still use my profile as usual in the UML editor (with
> no behavior). Both solution produce same UML xmi files and thus I can still
> interchange my files. Is it right?
>
> thanks.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG/3S0IYVWjMSpDwwRAjJYAKDT/K51Eme0gx9bzAaTMVcjg5wbjQCf ThMS
LtZdNvd+V7GU9Dg84P+ouew=
=fNfR
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #625082 is a reply to message #476235] Thu, 04 October 2007 15:38 Go to previous message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi james,

is it possible to generate/create an adapter/proxy class for
"MyExtendedClass" which decorates the stereotyped classifier + the
stereotype instance?

- -stefan


James Bruck schrieb:
> Hi Stefan,
>
> I hope I'm interpreting this question correctly - you are asking how to do
> static profile definition. I just wanted to point out that with a
> statically defined profiles there is no need to "define" ( create an ecore
> representation attached as an annotation ) your profile in the traditional
> way and therefore, dynamic EMF doesn't come into the picture ( hence the
> term "statically defined" ).
>
> There are several steps involved...
>
>
>
> ----------- Create your Profile -------------
> 1. Create your uml profile as you would normally ( For example, create a
> stereotype called MyExtendedClass that extends uml:Class ). (see the getting
> started article for details ). (Call it My.profile.uml for example)
> 2. ** don't do the "define" step ***
> 3. On your profile, apply the <<ePackage>> stereotype from the existing
> Ecore profile.
> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>
> ------- Generate code ---------
> 1. Create an EMF project as you would from any other .uml model to generate
> code from but specify your profile as the source ( My.profile.uml )
> 2. Select the "Process All" options when loading your My.profile.uml.
> 3. Generate code as you would normally from the resulting .genmodel.
>
> ------- Using your profile ------
> Up to this point, things were pretty easy. Here comes the tricky part...
>
> 1. Move your previously generated code for your profile to your development
> environment.
> 2. Create a new plugin in your development environment ( say a JUnit plugin
> to get started with ).
> 3. In your JUnit plugin test, add the line:
>
> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is the
> id of the profile in your model.
> 4. Create a resource set and load your My.profile.uml.
> 5. Next, Load your profile using..
> Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
> ... )
> from the already generated MyProfilePackage from the "Generate Code"
> step.
> 6. Next, obtain your stereotype with..
> Stereotype myStereotype =
> myProfile.getOwnedStereotype("MyExtendedClass");
> 7. This is the interesting part ... Apply your stereotype as follows:
> MyExtendedClass myExtendedClass =
> (MyExtendedClass)myClass.applyStereotype(myStereotype);
> Notice how you do not get a stereotype application but rather a type of
> "MyExtendedClass".
> 8. Now you have full access to setting variagbles to MyExtendedClass etc.
> --- how cool is that ;) ----
>
> Note: There is an extension point exposed to help with the registration
> that we are doing in step 3 but I noticed that there is a bug ( I don't
> think the schema was properly exported ... that will be fixed shortly ).
>
> Cheers,
>
> - James.
>
>
>
>
>
> "SKuhn" <kuhn@oio.de> wrote in message
> news:fdgs8p$c5d$1@build.eclipse.org...
> hi all,
>
> I would like to statically import a known profile to my uml-model -
> therefore I'd like to generate model code. I looked over the uml2 code
> but couldn't find where dynamic emf is used there and how I can avoid it
> for a specific profile.
>
> -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHBQkDIYVWjMSpDwwRApLBAKCubpp9dxa9MPDHTICuxqZZGdeccACf QavW
Ez3jM4lHwUFPcKQvU32aw+s=
=vJqO
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #625163 is a reply to message #476245] Tue, 09 October 2007 14:26 Go to previous message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030401020602020103040706
Content-Type: text/plain; charset=ISO-8859-15
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi james,

I tried to follow your instructions but didn't succeed. I attached the
sources, maybe you can take a look at it or provide a working example.

- -stefan


James Bruck schrieb:
> Unfortunately there is no detailed tutorial yet ... it is being worked on
> and should be a more detailed step by step guide.
> The name of the extension point is: generated_package.exsd in
> org.eclipse.uml2.uml plugin. If you get the source code there is some
> more documentation etc.
> The extension point will be fixed in 2.2 M2 ( unfortunately 2.1.1 was just
> released before I noticed the mistake ).
>
> - James.
>
>
>
> "SKuhn" <kuhn@oio.de> wrote in message
> news:fdj912$a3j$1@build.eclipse.org...
> awesome, that looks really good. Thanks a lot.
> Could I've found these steps in any tutorial? What's the name of the
> extension point and with which version will the problem be fixed?
>
> -stefan
>
>
> James Bruck schrieb:
>>>> Hi Stefan,
>>>>
>>>> I hope I'm interpreting this question correctly - you are asking how to
>> do
>>>> static profile definition. I just wanted to point out that with a
>>>> statically defined profiles there is no need to "define" ( create an
>> ecore
>>>> representation attached as an annotation ) your profile in the
>> traditional
>>>> way and therefore, dynamic EMF doesn't come into the picture ( hence the
>>>> term "statically defined" ).
>>>>
>>>> There are several steps involved...
>>>>
>>>>
>>>>
>>>> ----------- Create your Profile -------------
>>>> 1. Create your uml profile as you would normally ( For example, create a
>>>> stereotype called MyExtendedClass that extends uml:Class ). (see the
>> getting
>>>> started article for details ). (Call it My.profile.uml for example)
>>>> 2. ** don't do the "define" step ***
>>>> 3. On your profile, apply the <<ePackage>> stereotype from the existing
>>>> Ecore profile.
>>>> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>>>>
>>>> ------- Generate code ---------
>>>> 1. Create an EMF project as you would from any other .uml model to
>> generate
>>>> code from but specify your profile as the source ( My.profile.uml )
>>>> 2. Select the "Process All" options when loading your My.profile.uml.
>>>> 3. Generate code as you would normally from the resulting .genmodel.
>>>>
>>>> ------- Using your profile ------
>>>> Up to this point, things were pretty easy. Here comes the tricky
>> part...
>>>> 1. Move your previously generated code for your profile to your
>> development
>>>> environment.
>>>> 2. Create a new plugin in your development environment ( say a JUnit
>> plugin
>>>> to get started with ).
>>>> 3. In your JUnit plugin test, add the line:
>>>>
>>>>
>> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
>>>> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is
>> the
>>>> id of the profile in your model.
>>>> 4. Create a resource set and load your My.profile.uml.
>>>> 5. Next, Load your profile using..
>>>> Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
>>>> ... )
>>>> from the already generated MyProfilePackage from the "Generate Code"
>>>> step.
>>>> 6. Next, obtain your stereotype with..
>>>> Stereotype myStereotype =
>>>> myProfile.getOwnedStereotype("MyExtendedClass");
>>>> 7. This is the interesting part ... Apply your stereotype as follows:
>>>> MyExtendedClass myExtendedClass =
>>>> (MyExtendedClass)myClass.applyStereotype(myStereotype);
>>>> Notice how you do not get a stereotype application but rather a type
>> of
>>>> "MyExtendedClass".
>>>> 8. Now you have full access to setting variagbles to MyExtendedClass
>> etc.
>>>> --- how cool is that ;) ----
>>>>
>>>> Note: There is an extension point exposed to help with the registration
>>>> that we are doing in step 3 but I noticed that there is a bug ( I don't
>>>> think the schema was properly exported ... that will be fixed shortly ).
>>>>
>>>> Cheers,
>>>>
>>>> - James.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> "SKuhn" <kuhn@oio.de> wrote in message
>>>> news:fdgs8p$c5d$1@build.eclipse.org...
>>>> hi all,
>>>>
>>>> I would like to statically import a known profile to my uml-model -
>>>> therefore I'd like to generate model code. I looked over the uml2 code
>>>> but couldn't find where dynamic emf is used there and how I can avoid it
>>>> for a specific profile.
>>>>
>>>> -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHC4+JIYVWjMSpDwwRAgDqAKDHEJnumbro1s4FDP728ilhILF63ACd FYpX
GtrTjvk9c9Cadmeg6U4A+y8=
=ov4b
-----END PGP SIGNATURE-----

--------------030401020602020103040706
Content-Type: text/x-java;
name="Bsp.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Bsp.java"

package umlExpl;

import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.uml2.common.util.UML2Util;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Model;
import org.eclipse.uml2.uml.Profile;
import org.eclipse.uml2.uml.Stereotype;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.UMLPlugin;
import org.eclipse.uml2.uml.resource.UMLResource;
import org.eclipse.uml2.uml.util.UMLUtil;

import Profile.Complex;
import Profile.POCPackage;

public class Bsp {
public static ResourceSet resourceSet = null;
/**
* @param args
*/
public static void main(String[] args) {
initResourceSet();
Model root = createModel("test");

Resource resource = createResource(fileURI());
resource.getContents().add(root);


Profile meinProfile = stereotypeTest();

Package myPackage = createPackage(root, "meinPacket");
Class myClass = createClass(myPackage, "meineKlasse");

// meinProfile= stdProfil();

root.applyProfile(meinProfile);
// myPackage.applyProfile(anderesProfil);
// for (Profile prof : myPackage.getAllAppliedProfiles()) {
// System.out.println(prof);
// }


printStereos(myClass);
// Stereotype meinStereo = meinProfile.getOwnedStereotype("MitTaggedV");
Stereotype meinStereo = meinProfile.getOwnedStereotype("Complex");


UMLUtil.safeApplyStereotype(myClass, meinStereo);
// myClass.applyStereotype(andererStereo);

save(resource);
// Complex complex = (Complex) myClass.applyStereotype(meinStereo);

}


private static Profile stdProfil(){
Resource stdUML = resourceSet.getResource(URI.createFileURI(" /home/qn/Coden/workspace-oAW/POC_Prof/model/POC_1.profile.um l "), true);
Profile meinProfil= (org.eclipse.uml2.uml.Profile) EcoreUtil.getObjectByType(stdUML.getContents(), UMLPackage.Literals.PROFILE);
return meinProfil;
}

private static void muell(){
try {
resourceSet.getResource(URI
.createURI(UMLResource.STANDARD_PROFILE_URI), true);

resourceSet.getResource(URI
.createURI(UMLResource.ECORE_PROFILE_URI), true);
} catch (Exception e) {
// ignore
}
}

private static void printStereos(Classifier myClass) {
System.out.println("Anwendbare Stereotypen: ");
for (Stereotype stereotyp : myClass.getApplicableStereotypes()) {
System.out.println("Stereotyp: " + stereotyp);
}
System.out.println("Anwendbare Stereotypen ende");
}

private static void printStereosApplied(Classifier myClass) {
System.out.println("Angewendete Stereotypen: ");
for (Stereotype stereotyp : myClass.getAppliedStereotypes()) {
System.out.println("Angewendete: " + stereotyp);
}
System.out.println("Anwendbare Stereotypen ende");
}

public static void save(Resource resource){
// Print the contents of the resource to System.out.
try
{
resource.save(Collections.EMPTY_MAP);
}
catch (IOException e) {
System.out.println("Fehler "+e.toString());
}
}

public static URI fileURI(){
File file = new File("testModelle/testModell.uml");
System.out.println("Datein mit Pfad "+file.getAbsolutePath()+ " erzeugt.");
URI fileURI = URI.createFileURI(file.getAbsolutePath());
return fileURI;
}

public static void initResourceSet(){
resourceSet = new ResourceSetImpl();

resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI,URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createURI(" jar:file:/home/qn/Coden/eclipse-oAW/plugins/org.eclipse.uml2 .uml.resources_2.1.0.v200706251652.jar!/ ");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
}

public static Resource createResource(URI location) {
Resource resource = resourceSet.createResource(location);
return resource;
}

public static Profile stereotypeTest() {
URI uri2file = URI
.createURI(" /home/qn/Coden/workspace-oAW/StaticProfile/model/default.pro file.uml ").appendFragment("_uy27sHWxEdyjl9eZlwzeuA");
//_V_rHMHW3Edyjl9eZlwzeuA
//_uy27sHWxEdyjl9eZlwzeuA sollte ok sein
System.out.println("File exists? " + new File(uri2file.path()).exists());

Resource profilResource = resourceSet.getResource(uri2file, true); //System.out.println("contains? "+resourceSet.getResources().contains(profilResource));

Map<URI,URI> uriMap = resourceSet.getURIConverter().getURIMap();
UMLPlugin.getEPackageNsURIToProfileLocationMap().put("de.oio.POC ",uri2file);
URI uri = URI.createURI(" /home/qn/Coden/workspace-oAW/StaticProfile/model/default.pro file.uml ");
uriMap.put(URI.createURI("de.oio.POC"), uri2file);

// uri.appendSegment("libraries").appendSegment(""));

// resourceSet.getPackageRegistry().put("de.oio.POC",POCPackage.eINSTANCE);
// System.out.println("profilResource.getURI()= "+profilResource.getURI());

Profile myProfile = UMLUtil.getProfile(POCPackage.eINSTANCE);
System.out.println("Profile == null? "+Boolean.toString(myProfile==null));


Profile meinProfil = null;
//Weg I (klappt bei mir aber zeigt nix)
//(Profile)profilResource.getAllContents().next();

//Weg II
meinProfil = (org.eclipse.uml2.uml.Profile) EcoreUtil.getObjectByType(profilResource.getContents(), UMLPackage.Literals.PROFILE);

if(true)
return meinProfil;
return myProfile;
}

public static Model createModel(String name) {
Model model = UMLFactory.eINSTANCE.createModel();
model.setName(name);

System.out.println("Model " + model.getQualifiedName() + " created");

return model;
}

public static Package createPackage(Package parentPackage, String name) {
Package newPackage = parentPackage.createNestedPackage(name);
// System.out.println("Package " + newPackage.getQualifiedName()
// + " created in " + parentPackage.getQualifiedName());
return newPackage;
}

public static Class createClass(Package parentPackage, String name) {
Class clazz = parentPackage.createOwnedClass(name, false);
// System.out.println("Klasse " + clazz.getQualifiedName()+" erzeugt");
return clazz;
}
}

--------------030401020602020103040706
Content-Type: text/xml;
name="default.umlprofile_diagram"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="default.umlprofile_diagram"

<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.1/notation" xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML" xmi:id="_u88r0HWxEdyjl9eZlwzeuA" type="UMLProfile" name="default.umlprofile_diagram" measurementUnit="Pixel">
<children xmi:type="notation:Node" xmi:id="_wCzgoHWxEdyjl9eZlwzeuA" type="2007">
<children xmi:type="notation:Node" xmi:id="_wC0uwHWxEdyjl9eZlwzeuA" type="5009"/>
<children xmi:type="notation:Node" xmi:id="_wC4ZIHWxEdyjl9eZlwzeuA" type="7005">
<styles xmi:type="notation:DrawerStyle" xmi:id="_wC5AMHWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_wC5AMXWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_wC5AMnWxEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_wCzgoXWxEdyjl9eZlwzeuA" fontName="Verdana"/>
<element xmi:type="uml:Profile" href="default.profile.uml#_uy27sHWxEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_wCzgonWxEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_zD8WYHWxEdyjl9eZlwzeuA" type="2001">
<children xmi:type="notation:Node" xmi:id="_zD89cHWxEdyjl9eZlwzeuA" type="5001"/>
<children xmi:type="notation:Node" xmi:id="_zD9kgHWxEdyjl9eZlwzeuA" type="7001">
<children xmi:type="notation:Node" xmi:id="_M-l6gHWyEdyjl9eZlwzeuA" type="3001">
<element xmi:type="uml:Property" href="default.profile.uml#_M-XRAHWyEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_M-l6gXWyEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_NyKsgHWyEdyjl9eZlwzeuA" type="3001">
<element xmi:type="uml:Property" href="default.profile.uml#_Nx8DAHWyEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_NyKsgXWyEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:DrawerStyle" xmi:id="_zD9kgXWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_zD9kgnWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_zD9kg3WxEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_zD-LkHWxEdyjl9eZlwzeuA" type="7002">
<styles xmi:type="notation:DrawerStyle" xmi:id="_zD-LkXWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_zD-LknWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_zD-Lk3WxEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_zD8WYXWxEdyjl9eZlwzeuA" fontName="Verdana"/>
<element xmi:type="uml:Stereotype" href="default.profile.uml#_zDHP8HWxEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_zD8WYnWxEdyjl9eZlwzeuA" x="251" y="203"/>
</children>
<children xmi:type="notation:Node" xmi:id="_1K5b0HWxEdyjl9eZlwzeuA" type="2001">
<children xmi:type="notation:Node" xmi:id="_1K5b03WxEdyjl9eZlwzeuA" type="5001"/>
<children xmi:type="notation:Node" xmi:id="_1K6C4HWxEdyjl9eZlwzeuA" type="7001">
<styles xmi:type="notation:DrawerStyle" xmi:id="_1K6C4XWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_1K6C4nWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_1K6C43WxEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_1K6C5HWxEdyjl9eZlwzeuA" type="7002">
<styles xmi:type="notation:DrawerStyle" xmi:id="_1K6C5XWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_1K6C5nWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_1K6C53WxEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_1K5b0XWxEdyjl9eZlwzeuA" fontName="Verdana"/>
<element xmi:type="uml:Stereotype" href="default.profile.uml#_1K1KYHWxEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_1K5b0nWxEdyjl9eZlwzeuA" x="592" y="220"/>
</children>
<children xmi:type="notation:Node" xmi:id="_3fG6IHWxEdyjl9eZlwzeuA" type="2003">
<children xmi:type="notation:Node" xmi:id="_3fHhMHWxEdyjl9eZlwzeuA" type="5005"/>
<children xmi:type="notation:Node" xmi:id="_3fIIQHWxEdyjl9eZlwzeuA" type="7004">
<children xmi:type="notation:Node" xmi:id="_Hea2gHWyEdyjl9eZlwzeuA" type="3005">
<element xmi:type="uml:EnumerationLiteral" href="default.profile.uml#_HeMNAHWyEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_Hea2gXWyEdyjl9eZlwzeuA"/>
</children>
<children xmi:type="notation:Node" xmi:id="_LxaVsHWyEdyjl9eZlwzeuA" type="3005">
<element xmi:type="uml:EnumerationLiteral" href="default.profile.uml#_LxJ3AHWyEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Location" xmi:id="_LxaVsXWyEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:DrawerStyle" xmi:id="_3fIIQXWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_3fIIQnWxEdyjl9eZlwzeuA"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_3fIIQ3WxEdyjl9eZlwzeuA"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_3fG6IXWxEdyjl9eZlwzeuA" fontName="Verdana"/>
<element xmi:type="uml:Enumeration" href="default.profile.uml#_3e2bcHWxEdyjl9eZlwzeuA"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_3fG6InWxEdyjl9eZlwzeuA" x="352" y="48"/>
</children>
<children xmi:type="notation:Node" xmi:id="_7ujoYHX5EdyT4bcDFauwJQ" type="2001">
<children xmi:type="notation:Node" xmi:id="_7ukPcHX5EdyT4bcDFauwJQ" type="5001"/>
<children xmi:type="notation:Node" xmi:id="_7uk2gHX5EdyT4bcDFauwJQ" type="7001">
<styles xmi:type="notation:DrawerStyle" xmi:id="_7uk2gXX5EdyT4bcDFauwJQ"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_7uk2gnX5EdyT4bcDFauwJQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_7uk2g3X5EdyT4bcDFauwJQ"/>
</children>
<children xmi:type="notation:Node" xmi:id="_7uldkHX5EdyT4bcDFauwJQ" type="7002">
<styles xmi:type="notation:DrawerStyle" xmi:id="_7uldkXX5EdyT4bcDFauwJQ"/>
<styles xmi:type="notation:SortingStyle" xmi:id="_7uldknX5EdyT4bcDFauwJQ"/>
<styles xmi:type="notation:FilteringStyle" xmi:id="_7uldk3X5EdyT4bcDFauwJQ"/>
</children>
<styles xmi:type="notation:ShapeStyle" xmi:id="_7ujoYXX5EdyT4bcDFauwJQ" fontName="Verdana"/>
<element xmi:type="uml:Stereotype" href="default.profile.uml#_7tqQgHX5EdyT4bcDFauwJQ"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_7ujoYnX5EdyT4bcDFauwJQ" x="328" y="395"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_u88r0XWxEdyjl9eZlwzeuA"/>
<element xmi:type="uml:Profile" href="default.profile.uml#_uy27sHWxEdyjl9eZlwzeuA"/>
</notation:Diagram>

--------------030401020602020103040706--
Re: dynamic EMF profiles [message #625170 is a reply to message #476351] Wed, 10 October 2007 19:18 Go to previous message
Stefan Kuhn is currently offline Stefan KuhnFriend
Messages: 355
Registered: July 2009
Senior Member
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

any ideas?

- -stefan

SKuhn schrieb:
> hi james,
>
> I tried to follow your instructions but didn't succeed. I attached the
> sources, maybe you can take a look at it or provide a working example.
>
> -stefan
>
>
> James Bruck schrieb:
>> Unfortunately there is no detailed tutorial yet ... it is being worked on
>> and should be a more detailed step by step guide.
>> The name of the extension point is: generated_package.exsd in
>> org.eclipse.uml2.uml plugin. If you get the source code there is some
>> more documentation etc.
>> The extension point will be fixed in 2.2 M2 ( unfortunately 2.1.1 was just
>> released before I noticed the mistake ).
>
>> - James.
>
>
>
>> "SKuhn" <kuhn@oio.de> wrote in message
>> news:fdj912$a3j$1@build.eclipse.org...
>> awesome, that looks really good. Thanks a lot.
>> Could I've found these steps in any tutorial? What's the name of the
>> extension point and with which version will the problem be fixed?
>
>> -stefan
>
>
>> James Bruck schrieb:
>>>>> Hi Stefan,
>>>>>
>>>>> I hope I'm interpreting this question correctly - you are asking how to
>>> do
>>>>> static profile definition. I just wanted to point out that with a
>>>>> statically defined profiles there is no need to "define" ( create an
>>> ecore
>>>>> representation attached as an annotation ) your profile in the
>>> traditional
>>>>> way and therefore, dynamic EMF doesn't come into the picture ( hence the
>>>>> term "statically defined" ).
>>>>>
>>>>> There are several steps involved...
>>>>>
>>>>>
>>>>>
>>>>> ----------- Create your Profile -------------
>>>>> 1. Create your uml profile as you would normally ( For example, create a
>>>>> stereotype called MyExtendedClass that extends uml:Class ). (see the
>>> getting
>>>>> started article for details ). (Call it My.profile.uml for example)
>>>>> 2. ** don't do the "define" step ***
>>>>> 3. On your profile, apply the <<ePackage>> stereotype from the existing
>>>>> Ecore profile.
>>>>> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>>>>>
>>>>> ------- Generate code ---------
>>>>> 1. Create an EMF project as you would from any other .uml model to
>>> generate
>>>>> code from but specify your profile as the source ( My.profile.uml )
>>>>> 2. Select the "Process All" options when loading your My.profile.uml.
>>>>> 3. Generate code as you would normally from the resulting .genmodel.
>>>>>
>>>>> ------- Using your profile ------
>>>>> Up to this point, things were pretty easy. Here comes the tricky
>>> part...
>>>>> 1. Move your previously generated code for your profile to your
>>> development
>>>>> environment.
>>>>> 2. Create a new plugin in your development environment ( say a JUnit
>>> plugin
>>>>> to get started with ).
>>>>> 3. In your JUnit plugin test, add the line:
>>>>>
>>>>>
>>> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
>>>>> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX is
>>> the
>>>>> id of the profile in your model.
>>>>> 4. Create a resource set and load your My.profile.uml.
>>>>> 5. Next, Load your profile using..
>>>>> Profile myProfile = UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
>>>>> ... )
>>>>> from the already generated MyProfilePackage from the "Generate Code"
>>>>> step.
>>>>> 6. Next, obtain your stereotype with..
>>>>> Stereotype myStereotype =
>>>>> myProfile.getOwnedStereotype("MyExtendedClass");
>>>>> 7. This is the interesting part ... Apply your stereotype as follows:
>>>>> MyExtendedClass myExtendedClass =
>>>>> (MyExtendedClass)myClass.applyStereotype(myStereotype);
>>>>> Notice how you do not get a stereotype application but rather a type
>>> of
>>>>> "MyExtendedClass".
>>>>> 8. Now you have full access to setting variagbles to MyExtendedClass
>>> etc.
>>>>> --- how cool is that ;) ----
>>>>>
>>>>> Note: There is an extension point exposed to help with the registration
>>>>> that we are doing in step 3 but I noticed that there is a bug ( I don't
>>>>> think the schema was properly exported ... that will be fixed shortly ).
>>>>>
>>>>> Cheers,
>>>>>
>>>>> - James.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> "SKuhn" <kuhn@oio.de> wrote in message
>>>>> news:fdgs8p$c5d$1@build.eclipse.org...
>>>>> hi all,
>>>>>
>>>>> I would like to statically import a known profile to my uml-model -
>>>>> therefore I'd like to generate model code. I looked over the uml2 code
>>>>> but couldn't find where dynamic emf is used there and how I can avoid it
>>>>> for a specific profile.
>>>>>
>>>>> -stefan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHDSVxIYVWjMSpDwwRArn9AJ9nqf9nRjjDX8yt3H3jed3/h4uABQCe JMWs
/ZTEq/pDLyjDGUxFfIKtoQ4=
=HRVF
-----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #625171 is a reply to message #476358] Wed, 10 October 2007 22:20 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
I looks like you didn't attach default.profile.uml.
You did attach some diagram of the profile though (no nsURI set up with
<<ePackage>> stereotype).

I'll post a step-by-step guide as soon as I can.

Cheers,

- James.



"SKuhn" <kuhn@oio.de> wrote in message
news:fej8j0$961$2@build.eclipse.org...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> any ideas?
>
> - -stefan
>
> SKuhn schrieb:
>> hi james,
>>
>> I tried to follow your instructions but didn't succeed. I attached the
>> sources, maybe you can take a look at it or provide a working example.
>>
>> -stefan
>>
>>
>> James Bruck schrieb:
>>> Unfortunately there is no detailed tutorial yet ... it is being worked
>>> on
>>> and should be a more detailed step by step guide.
>>> The name of the extension point is: generated_package.exsd in
>>> org.eclipse.uml2.uml plugin. If you get the source code there is some
>>> more documentation etc.
>>> The extension point will be fixed in 2.2 M2 ( unfortunately 2.1.1 was
>>> just
>>> released before I noticed the mistake ).
>>
>>> - James.
>>
>>
>>
>>> "SKuhn" <kuhn@oio.de> wrote in message
>>> news:fdj912$a3j$1@build.eclipse.org...
>>> awesome, that looks really good. Thanks a lot.
>>> Could I've found these steps in any tutorial? What's the name of the
>>> extension point and with which version will the problem be fixed?
>>
>>> -stefan
>>
>>
>>> James Bruck schrieb:
>>>>>> Hi Stefan,
>>>>>>
>>>>>> I hope I'm interpreting this question correctly - you are asking how
>>>>>> to
>>>> do
>>>>>> static profile definition. I just wanted to point out that with a
>>>>>> statically defined profiles there is no need to "define" ( create an
>>>> ecore
>>>>>> representation attached as an annotation ) your profile in the
>>>> traditional
>>>>>> way and therefore, dynamic EMF doesn't come into the picture ( hence
>>>>>> the
>>>>>> term "statically defined" ).
>>>>>>
>>>>>> There are several steps involved...
>>>>>>
>>>>>>
>>>>>>
>>>>>> ----------- Create your Profile -------------
>>>>>> 1. Create your uml profile as you would normally ( For example,
>>>>>> create a
>>>>>> stereotype called MyExtendedClass that extends uml:Class ). (see the
>>>> getting
>>>>>> started article for details ). (Call it My.profile.uml for example)
>>>>>> 2. ** don't do the "define" step ***
>>>>>> 3. On your profile, apply the <<ePackage>> stereotype from the
>>>>>> existing
>>>>>> Ecore profile.
>>>>>> 4. Set the nsURI to something ... say http://www.myOrg/MyProfile
>>>>>>
>>>>>> ------- Generate code ---------
>>>>>> 1. Create an EMF project as you would from any other .uml model to
>>>> generate
>>>>>> code from but specify your profile as the source ( My.profile.uml )
>>>>>> 2. Select the "Process All" options when loading your My.profile.uml.
>>>>>> 3. Generate code as you would normally from the resulting .genmodel.
>>>>>>
>>>>>> ------- Using your profile ------
>>>>>> Up to this point, things were pretty easy. Here comes the tricky
>>>> part...
>>>>>> 1. Move your previously generated code for your profile to your
>>>> development
>>>>>> environment.
>>>>>> 2. Create a new plugin in your development environment ( say a JUnit
>>>> plugin
>>>>>> to get started with ).
>>>>>> 3. In your JUnit plugin test, add the line:
>>>>>>
>>>>>>
>>>> UMLPlugin.getEPackageNsURIToProfileLocationMap().put(http://www.myOrg.com/My
>>>>>> Profile, URI.createURI( ... path to My.profile.uml#_XXX")); where XXX
>>>>>> is
>>>> the
>>>>>> id of the profile in your model.
>>>>>> 4. Create a resource set and load your My.profile.uml.
>>>>>> 5. Next, Load your profile using..
>>>>>> Profile myProfile =
>>>>>> UMLUtil.getProfile(MyProfilePackage.eINSTANCE,
>>>>>> ... )
>>>>>> from the already generated MyProfilePackage from the "Generate
>>>>>> Code"
>>>>>> step.
>>>>>> 6. Next, obtain your stereotype with..
>>>>>> Stereotype myStereotype =
>>>>>> myProfile.getOwnedStereotype("MyExtendedClass");
>>>>>> 7. This is the interesting part ... Apply your stereotype as
>>>>>> follows:
>>>>>> MyExtendedClass myExtendedClass =
>>>>>> (MyExtendedClass)myClass.applyStereotype(myStereotype);
>>>>>> Notice how you do not get a stereotype application but rather a
>>>>>> type
>>>> of
>>>>>> "MyExtendedClass".
>>>>>> 8. Now you have full access to setting variagbles to MyExtendedClass
>>>> etc.
>>>>>> --- how cool is that ;) ----
>>>>>>
>>>>>> Note: There is an extension point exposed to help with the
>>>>>> registration
>>>>>> that we are doing in step 3 but I noticed that there is a bug ( I
>>>>>> don't
>>>>>> think the schema was properly exported ... that will be fixed
>>>>>> shortly ).
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> - James.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> "SKuhn" <kuhn@oio.de> wrote in message
>>>>>> news:fdgs8p$c5d$1@build.eclipse.org...
>>>>>> hi all,
>>>>>>
>>>>>> I would like to statically import a known profile to my uml-model -
>>>>>> therefore I'd like to generate model code. I looked over the uml2
>>>>>> code
>>>>>> but couldn't find where dynamic emf is used there and how I can avoid
>>>>>> it
>>>>>> for a specific profile.
>>>>>>
>>>>>> -stefan
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.7 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFHDSVxIYVWjMSpDwwRArn9AJ9nqf9nRjjDX8yt3H3jed3/h4uABQCe JMWs
> /ZTEq/pDLyjDGUxFfIKtoQ4=
> =HRVF
> -----END PGP SIGNATURE-----
Re: dynamic EMF profiles [message #625175 is a reply to message #476358] Thu, 11 October 2007 09:05 Go to previous message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Hello Stefan,

I succeeded with this, adapt it to your case first.

String s =
" D:\\workspace\\eclipse-europa\\TestProfile\\model\\MyProfile .profile.uml ";

ResourceSet set = new ResourceSetImpl();
set.getPackageRegistry().put(MyProfilePackage.eNS_URI,
MyProfilePackage.eINSTANCE);
set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
set.getResourceFactoryRegistry().getExtensionToFactoryMap(). put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Map uriMap = set.getURIConverter().getURIMap();
URI uri =
URI.createURI(" jar:file:/C:/Tools/eclipse-europa-modeling/eclipse/plugins/o rg.eclipse.uml2.uml.resources_2.1.0.v200706251652.jar!/ ");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
uri.appendSegment("profiles").appendSegment(""));

Resource res = set.getResource(URI.createFileURI(s), true);

Profile myProfile = (org.eclipse.uml2.uml.Profile)
EcoreUtil.getObjectByType(res.getContents(), UMLPackage.Literals.PROFILE);

Stereotype myStereotype = myProfile.getOwnedStereotype("MyStereotype");

org.eclipse.uml2.uml.Package myPackage =
UMLFactory.eINSTANCE.createPackage();
myPackage.applyProfile(myProfile);

org.eclipse.uml2.uml.Class myClass = UMLFactory.eINSTANCE.createClass();
myClass.setPackage(myPackage);
myClass.setName("Class");
MyStereotype myExtendedClass = (MyStereotype)
myClass.applyStereotype(myStereotype);
myExtendedClass.setAttribute(true);

System.out.println(myClass.getName()); // > Class
System.out.println(myExtendedClass.isAttribute()); // > true
Re: dynamic EMF profiles [message #625177 is a reply to message #476268] Thu, 11 October 2007 09:37 Go to previous message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Hello Stefan,

But what if a stereotype extend 2 metaclasses and each metaclass has
different attributes?

- With one decorator for both, you would have some attributes without
value.
- With two decorators, one for each metaclass, the handle of the types
would not be very appealing (to me, -particular opinion-)

I think I'd rather a get method in the stereotype class returning the
metaclass instance, because now we have to keep the reference to both: the
metaclass instance and the stereotype instance. It could return the common
supertype of the metaclasses (EObject or Object in the worst case).

Maybe also a method to query which metaclass is actually extending.

What do you think?
Previous Topic:Stereotype Application very slow
Next Topic:Loop Node and Conditional Node
Goto Forum:
  


Current Time: Thu Apr 25 10:17:40 GMT 2024

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

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

Back to the top