Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Profile reapplication
Profile reapplication [message #469885] Fri, 02 February 2007 16:55 Go to next message
Chokri Mraidha is currently offline Chokri MraidhaFriend
Messages: 28
Registered: July 2009
Junior Member
Hello,


The specification of Package#applyProfile() is:

Applies the current definition of the specified profile to this package
and automatically applies required stereotypes in the profile to elements
within this package's namespace hieararchy. If a different definition is
already applied, automatically migrates any associated stereotype values
on a "best effort" basis (matching classifiers and structural features by
name).


According to this specification when I reapply a profile to a model M the
stereotypeApplications of M are migrated to the new profile application
(new definition).

But when I call applyProfile with a profile already applied this migration
is not performed and I have two stereotypes available (one for the old
profile and one for the new one).

The result is something like this in the uml file:

<Test:Stereotype_0 xmi:id="_WATyMLLcEduZAKbcGyKgJg"
base_Element="_QAoHsLLcEduZAKbcGyKgJg">
<Property_0>hello world</Property_0>
</Test:Stereotype_0>
<Test_1:Stereotype_0 xmi:id="_sz--ULLcEduZAKbcGyKgJg"
base_Element="_QOLbgLLcEduZAKbcGyKgJg">
<Property_0>new hello world</Property_0>


I am using uml2 2.0.3. Do I have to do something else than calling
Package#applyProfile() to make the migration occur?



Cheers,

Chokri
Re: Profile reapplication [message #470069 is a reply to message #469885] Mon, 05 February 2007 20:58 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Chokri,

Package::applyProfile() should be all that you need to call. You can have a
look at PackageOperations::applyProfile() to see what's going on.
It makes use of the StereotypeApplicationCopier() to achieve its task.

From the snippet you have provided below it seems like two stereotypes were
applied to the same element ... not good :(

Can you provide step by step details of how you arrived at this point.
Also, did you remember to "define" your profile after making changes to
update it? ( I suspect that you did).

If you can supply your profile and model I can have a look at it.

Regards,
- James.


"Chokri Mraidha" <Chokri.Mraidha@cea.fr> wrote in message
news:172a58a701afc5fc7ea06ef0f5dfd7bd$1@www.eclipse.org...
> Hello,
>
>
> The specification of Package#applyProfile() is:
>
> Applies the current definition of the specified profile to this package
> and automatically applies required stereotypes in the profile to elements
> within this package's namespace hieararchy. If a different definition is
> already applied, automatically migrates any associated stereotype values
> on a "best effort" basis (matching classifiers and structural features by
> name).
>
>
> According to this specification when I reapply a profile to a model M the
> stereotypeApplications of M are migrated to the new profile application
> (new definition).
>
> But when I call applyProfile with a profile already applied this migration
> is not performed and I have two stereotypes available (one for the old
> profile and one for the new one).
>
> The result is something like this in the uml file:
>
> <Test:Stereotype_0 xmi:id="_WATyMLLcEduZAKbcGyKgJg"
> base_Element="_QAoHsLLcEduZAKbcGyKgJg">
> <Property_0>hello world</Property_0>
> </Test:Stereotype_0>
> <Test_1:Stereotype_0 xmi:id="_sz--ULLcEduZAKbcGyKgJg"
> base_Element="_QOLbgLLcEduZAKbcGyKgJg">
> <Property_0>new hello world</Property_0>
>
>
> I am using uml2 2.0.3. Do I have to do something else than calling
> Package#applyProfile() to make the migration occur?
>
>
>
> Cheers,
>
> Chokri
>
Re: Profile reapplication [message #471740 is a reply to message #470069] Tue, 20 March 2007 16:25 Go to previous messageGo to next message
Chokri Mraidha is currently offline Chokri MraidhaFriend
Messages: 28
Registered: July 2009
Junior Member
James,

I think I have a problem of resource loading before the profile
application.
Could you give me an example (code) of what should be done before
Package#applyProfile() call?

For instance is the resourceSet is the one of the package on which I want
to apply profile on? Do I need to call UMLUtil.load() to load the profile
resource, etc...


Thanks,

Chokri
Re: Profile reapplication [message #471748 is a reply to message #471740] Wed, 21 March 2007 15:49 Go to previous messageGo to next message
Chokri Mraidha is currently offline Chokri MraidhaFriend
Messages: 28
Registered: July 2009
Junior Member
Hello,

Here is my code to apply a profile "profileToApply" to the package
"package_".
If an older version of the profile is applied I loose the stereotypes
already applied in package_.


URI profileUri =
URI.createURI("platform:/resource"+selectedFile.getFullPath().toString());

Package package_ = getSelected();
ResourceSet resourceSet = package_.eResource().getResourceSet();

Profile profileToApply = (Profile)UMLUtil.load(resourceSet, profileUri,
UMLPackage.Literals.PROFILE);

if(profileToApply.isDefined()){

ProfileApplication profileApplication =
package_.getProfileApplication(profileToApply);
if(profileApplication == null ||
profileApplication.getAppliedDefinition() !=
profileToApply.getDefinition()){
package_.applyProfile(profileToApply);
}
}


Can anyone help me on this?


Thank you in advance.


Regards,

Chokri
Re: Profile reapplication [message #471751 is a reply to message #471748] Thu, 22 March 2007 03:09 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Chokri,

It looks like you are applying the profile correctly.
Can you post your profile and a sample model.
Could it be that the stereotypes in the new version are no longer
applicable?

Regards,

- James.

"Chokri Mraidha" <Chokri.Mraidha@cea.fr> wrote in message
news:49fe17264eae4169e1d9b2e57944d241$1@www.eclipse.org...
> Hello,
>
> Here is my code to apply a profile "profileToApply" to the package
> "package_".
> If an older version of the profile is applied I loose the stereotypes
> already applied in package_.
>
>
> URI profileUri =
> URI.createURI("platform:/resource"+selectedFile.getFullPath().toString());
>
> Package package_ = getSelected();
> ResourceSet resourceSet = package_.eResource().getResourceSet();
>
> Profile profileToApply = (Profile)UMLUtil.load(resourceSet, profileUri,
> UMLPackage.Literals.PROFILE);
>
> if(profileToApply.isDefined()){
>
> ProfileApplication profileApplication =
> package_.getProfileApplication(profileToApply);
> if(profileApplication == null || profileApplication.getAppliedDefinition()
> != profileToApply.getDefinition()){
> package_.applyProfile(profileToApply);
> }
> }
>
>
> Can anyone help me on this?
>
>
> Thank you in advance.
>
>
> Regards,
>
> Chokri
>
>
>
>
>
Re: Profile reapplication [message #471755 is a reply to message #471748] Thu, 22 March 2007 13:02 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Chokri,

Have removed any of the previous definitions of the profile? Note that you
must keep the "legacy" Ecore representations around if you want to support
migration of data based on previous versions of the profile.

Kenn

"Chokri Mraidha" <Chokri.Mraidha@cea.fr> wrote in message
news:49fe17264eae4169e1d9b2e57944d241$1@www.eclipse.org...
> Hello,
>
> Here is my code to apply a profile "profileToApply" to the package
> "package_".
> If an older version of the profile is applied I loose the stereotypes
> already applied in package_.
>
>
> URI profileUri =
> URI.createURI("platform:/resource"+selectedFile.getFullPath().toString());
>
> Package package_ = getSelected();
> ResourceSet resourceSet = package_.eResource().getResourceSet();
>
> Profile profileToApply = (Profile)UMLUtil.load(resourceSet, profileUri,
> UMLPackage.Literals.PROFILE);
>
> if(profileToApply.isDefined()){
>
> ProfileApplication profileApplication =
> package_.getProfileApplication(profileToApply);
> if(profileApplication == null || profileApplication.getAppliedDefinition()
> != profileToApply.getDefinition()){
> package_.applyProfile(profileToApply);
> }
> }
>
>
> Can anyone help me on this?
>
>
> Thank you in advance.
>
>
> Regards,
>
> Chokri
>
>
>
>
>
Re: Profile reapplication [message #471803 is a reply to message #471755] Fri, 23 March 2007 10:13 Go to previous message
Chokri Mraidha is currently offline Chokri MraidhaFriend
Messages: 28
Registered: July 2009
Junior Member
Kenn,

That was the problem. I have removed previous definitions of my profile.
It works now.


Thanks.


Regards,

Chokri
Re: Profile reapplication [message #582118 is a reply to message #469885] Mon, 05 February 2007 20:58 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Chokri,

Package::applyProfile() should be all that you need to call. You can have a
look at PackageOperations::applyProfile() to see what's going on.
It makes use of the StereotypeApplicationCopier() to achieve its task.

From the snippet you have provided below it seems like two stereotypes were
applied to the same element ... not good :(

Can you provide step by step details of how you arrived at this point.
Also, did you remember to "define" your profile after making changes to
update it? ( I suspect that you did).

If you can supply your profile and model I can have a look at it.

Regards,
- James.


"Chokri Mraidha" <Chokri.Mraidha@cea.fr> wrote in message
news:172a58a701afc5fc7ea06ef0f5dfd7bd$1@www.eclipse.org...
> Hello,
>
>
> The specification of Package#applyProfile() is:
>
> Applies the current definition of the specified profile to this package
> and automatically applies required stereotypes in the profile to elements
> within this package's namespace hieararchy. If a different definition is
> already applied, automatically migrates any associated stereotype values
> on a "best effort" basis (matching classifiers and structural features by
> name).
>
>
> According to this specification when I reapply a profile to a model M the
> stereotypeApplications of M are migrated to the new profile application
> (new definition).
>
> But when I call applyProfile with a profile already applied this migration
> is not performed and I have two stereotypes available (one for the old
> profile and one for the new one).
>
> The result is something like this in the uml file:
>
> <Test:Stereotype_0 xmi:id="_WATyMLLcEduZAKbcGyKgJg"
> base_Element="_QAoHsLLcEduZAKbcGyKgJg">
> <Property_0>hello world</Property_0>
> </Test:Stereotype_0>
> <Test_1:Stereotype_0 xmi:id="_sz--ULLcEduZAKbcGyKgJg"
> base_Element="_QOLbgLLcEduZAKbcGyKgJg">
> <Property_0>new hello world</Property_0>
>
>
> I am using uml2 2.0.3. Do I have to do something else than calling
> Package#applyProfile() to make the migration occur?
>
>
>
> Cheers,
>
> Chokri
>
Re: Profile reapplication [message #601891 is a reply to message #470069] Tue, 20 March 2007 16:25 Go to previous message
Chokri Mraidha is currently offline Chokri MraidhaFriend
Messages: 28
Registered: July 2009
Junior Member
James,

I think I have a problem of resource loading before the profile
application.
Could you give me an example (code) of what should be done before
Package#applyProfile() call?

For instance is the resourceSet is the one of the package on which I want
to apply profile on? Do I need to call UMLUtil.load() to load the profile
resource, etc...


Thanks,

Chokri
Re: Profile reapplication [message #603086 is a reply to message #471740] Wed, 21 March 2007 15:49 Go to previous message
Chokri Mraidha is currently offline Chokri MraidhaFriend
Messages: 28
Registered: July 2009
Junior Member
Hello,

Here is my code to apply a profile "profileToApply" to the package
"package_".
If an older version of the profile is applied I loose the stereotypes
already applied in package_.


URI profileUri =
URI.createURI("platform:/resource"+selectedFile.getFullPath().toString());

Package package_ = getSelected();
ResourceSet resourceSet = package_.eResource().getResourceSet();

Profile profileToApply = (Profile)UMLUtil.load(resourceSet, profileUri,
UMLPackage.Literals.PROFILE);

if(profileToApply.isDefined()){

ProfileApplication profileApplication =
package_.getProfileApplication(profileToApply);
if(profileApplication == null ||
profileApplication.getAppliedDefinition() !=
profileToApply.getDefinition()){
package_.applyProfile(profileToApply);
}
}


Can anyone help me on this?


Thank you in advance.


Regards,

Chokri
Re: Profile reapplication [message #603102 is a reply to message #471748] Thu, 22 March 2007 03:09 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Chokri,

It looks like you are applying the profile correctly.
Can you post your profile and a sample model.
Could it be that the stereotypes in the new version are no longer
applicable?

Regards,

- James.

"Chokri Mraidha" <Chokri.Mraidha@cea.fr> wrote in message
news:49fe17264eae4169e1d9b2e57944d241$1@www.eclipse.org...
> Hello,
>
> Here is my code to apply a profile "profileToApply" to the package
> "package_".
> If an older version of the profile is applied I loose the stereotypes
> already applied in package_.
>
>
> URI profileUri =
> URI.createURI("platform:/resource"+selectedFile.getFullPath().toString());
>
> Package package_ = getSelected();
> ResourceSet resourceSet = package_.eResource().getResourceSet();
>
> Profile profileToApply = (Profile)UMLUtil.load(resourceSet, profileUri,
> UMLPackage.Literals.PROFILE);
>
> if(profileToApply.isDefined()){
>
> ProfileApplication profileApplication =
> package_.getProfileApplication(profileToApply);
> if(profileApplication == null || profileApplication.getAppliedDefinition()
> != profileToApply.getDefinition()){
> package_.applyProfile(profileToApply);
> }
> }
>
>
> Can anyone help me on this?
>
>
> Thank you in advance.
>
>
> Regards,
>
> Chokri
>
>
>
>
>
Re: Profile reapplication [message #603123 is a reply to message #471748] Thu, 22 March 2007 13:02 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Chokri,

Have removed any of the previous definitions of the profile? Note that you
must keep the "legacy" Ecore representations around if you want to support
migration of data based on previous versions of the profile.

Kenn

"Chokri Mraidha" <Chokri.Mraidha@cea.fr> wrote in message
news:49fe17264eae4169e1d9b2e57944d241$1@www.eclipse.org...
> Hello,
>
> Here is my code to apply a profile "profileToApply" to the package
> "package_".
> If an older version of the profile is applied I loose the stereotypes
> already applied in package_.
>
>
> URI profileUri =
> URI.createURI("platform:/resource"+selectedFile.getFullPath().toString());
>
> Package package_ = getSelected();
> ResourceSet resourceSet = package_.eResource().getResourceSet();
>
> Profile profileToApply = (Profile)UMLUtil.load(resourceSet, profileUri,
> UMLPackage.Literals.PROFILE);
>
> if(profileToApply.isDefined()){
>
> ProfileApplication profileApplication =
> package_.getProfileApplication(profileToApply);
> if(profileApplication == null || profileApplication.getAppliedDefinition()
> != profileToApply.getDefinition()){
> package_.applyProfile(profileToApply);
> }
> }
>
>
> Can anyone help me on this?
>
>
> Thank you in advance.
>
>
> Regards,
>
> Chokri
>
>
>
>
>
Re: Profile reapplication [message #603146 is a reply to message #471755] Fri, 23 March 2007 10:13 Go to previous message
Chokri Mraidha is currently offline Chokri MraidhaFriend
Messages: 28
Registered: July 2009
Junior Member
Kenn,

That was the problem. I have removed previous definitions of my profile.
It works now.


Thanks.


Regards,

Chokri
Previous Topic:Jar2UML reverse engineering tool available
Next Topic:Load samples using UML2 2.1.0 API
Goto Forum:
  


Current Time: Mon Apr 06 10:08:10 GMT 2020

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

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

Back to the top