Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » [solved] How to modify a profile that is already in use?(It's about the correct usage of define() and how UML2 profiles are managed)
[solved] How to modify a profile that is already in use? [message #638933] Sat, 13 November 2010 13:57 Go to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
EDIT: In the meantime, the results on this topic are documented here:
http://argouml.tigris.org/wiki/UML2%2C_Profiles_and_XMI
Happy reading!

---------------------------topic-begins-here---------------- -----------

Dear experts,

I've read the article about using profiles ( http://www.eclipse.org/modeling/mdt/uml2/docs/articles/Intro duction_to_UML2_Profiles/article.html) and managed to create and (un)apply profiles programmatically for quite a long time. But I always run into a problem when an already used profile needs to be modified (extended/changed).

Here is the problem:

After making a change to the profile, I have to define it again to also update the Ecore representation. But then, I've got both the old and the new Ecore package in my profile. So I wonder what happens to my models that apply that profile *before* and *after* my modification and redefinition of the profile.

Questions:

Is it feasible to modify profiles, or are they ment to be read-only after defining and/or applying them?
Is it correct to let the profile evolve the way I described? It grows with each modification cicle!
Do different models refer to different "generations" of the Ecore package in the profile, and is this done intentionally?

Thanks for any clarification! (I'm struggling here for several months now)

Regards,
Thomas Neustupny

[Updated on: Tue, 14 December 2010 12:59]

Report message to a moderator

Re: How to modify a profile that is already in use? [message #639379 is a reply to message #638933] Tue, 16 November 2010 10:22 Go to previous messageGo to next message
Vlad Varnica is currently offline Vlad VarnicaFriend
Messages: 546
Registered: July 2009
Location: Milton Keynes - UK
Senior Member
A profile is static and can not be modified if not directly manipulated once created.
I mean that when you upload your model into memory, not only the model is uploaded but also all the created profiles. It means that model and profile are loaded at the same time.
You can not therefore change the profile if still at model stage creation.

The trick I use is to create a profile diagram with UML, then to save it into the model and update my model once the profile has been updated.
More information on the UML profile update is available at: http://www.forum-omondo.com/documentation_eclipseuml_2008/di agrams/Profile_diagram/index.html

I have written a documentation on this subject in 2005 but this is still the only real UML profile oppose to EMF profile documentation which exist on the web for eclipse : http://www.tutorial-omondo.com/profileIntro/index.html

This profile mechanism has been developed by Thomas Guiu many years ago and nothing better has been done since. This is the only code of EclipseUML which has not been changed in the last three years, it means it was really good Smile

[Updated on: Tue, 16 November 2010 10:26]

Report message to a moderator

Re: How to modify a profile that is already in use? [message #639455 is a reply to message #639379] Tue, 16 November 2010 16:15 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
Thank you for the links, Vlad. So, your answer basically is: "never change a profile that is once applied"? Does this mean that, e.g., if the Hibernate profile (in your first link) is missing a stereotype, then there is no way to add it later? As a consequence, it should not be possible to successfully call define() on a once defined profile, but it works (with the described effect of a growing XMI file).

I was hoping to find an answer on how a profile can be updated, but I didn't find it following your links, or I just overlooked it. I thought profiles cannot be updated?

So should I avoid to call define() more than once on a profile?
But if I do, which problems with my applying models can occur?
Re: How to modify a profile that is already in use? [message #639637 is a reply to message #639455] Wed, 17 November 2010 10:14 Go to previous messageGo to next message
Vlad Varnica is currently offline Vlad VarnicaFriend
Messages: 546
Registered: July 2009
Location: Milton Keynes - UK
Senior Member
What I do when I need to add/change stereotype to hibernate, ejb3 profiles etc.. is to change my profile manually using the profile diagram and then take it from the model. Save everything and again put it back, upload and save it again.
It works Confused

I don't use the profile at code level because it is really nightmare. I never also manually change my xmi because if you just made a mistake the entire model is corrupted and could not be open; UML model management is very fragile and the best is to use a tool or a framework on the top of it.
Re: How to modify a profile that is already in use? [message #639865 is a reply to message #638933] Thu, 18 November 2010 08:25 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
The point is that I AM implementing that kind of framework! Wink It's the UML2 model subsystem of ArgoUML (which is a standalone tool, so not another competitor in the area of eclipse uml tools). That's why I'm interested in the details when you talk about "use a profile diagram", "update model", "load/save everything".

So, at the moment it looks like I need to do my own analysis/tests on what happens or what could happen to my profiles/models. I will try some save/load/modification cycles with sample models and profiles. For now I tend to believe in the "generations of Ecore packages" theory I talked about in my first post (see above).

I'd be very grateful if someone could point me to some docs. What I have now is the mentioned profile article, the javadocs and the articles from Vlad (thanks again).
Re: How to modify a profile that is already in use? [message #644842 is a reply to message #638933] Tue, 14 December 2010 12:48 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
Progress!!! Smile

During implementation convenient profile support in ArgoUML using UML2, it turned out that:

1. changing a profile requires another define() call
2. a new Ecore package is then created in the profile, so that models applying the profile are not affected
3. it's the profile application in the model that refers to one of the Ecore packages
4. at the time when a profile is applied: it's always the most recent Ecore package that is applied

For a detailed explanation, I've created this documentation (work-in-progress):
http://argouml.tigris.org/wiki/UML2%2C_Profiles_and_XMI

I hope it's helpful. At the moment my question is: is it feasible for a model to have more than one profile application of the same profile (referring different Ecore packages)?

Regards,
Thomas
Re: [solved] How to modify a profile that is already in use? [message #645229 is a reply to message #638933] Thu, 16 December 2010 06:41 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
I finished my work on the linked wiki page, here is my conclusion:

When loading a model after a used profile got redefined, something really strange happens (at least in ArgoUML): the references to the old Ecore package are automatically changed, so the model suddenly references the new Ecore package after loading the XMI. So, the model gets its profile references refreshed in every load/save cycle.

So: modifying (and redefining) a profile is no problem, as long as no objects (with an xmi:id attribute) are removed. But: never delete profile elements when models exist
that use the profile!

Maintaining a profile means to add or change elements, this is well supported by the profile mechanism of UML2/EMF. Keep in mind that the profile grows by introducing a new Ecore package with all profile elements in it, so avoid to define the profile too often.

Are these statement correct? Please give feedback!

[Updated on: Thu, 16 December 2010 06:43]

Report message to a moderator

Re: [solved] How to modify a profile that is already in use? [message #645343 is a reply to message #645229] Thu, 16 December 2010 17:04 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Can you illustrate what you are describing with two versions of the profile markup, in the 1st serialization, and the 2nd serialization?

Are you sure it isn't just a result of random id generation? In the TextUML Toolkit, where models (and profiles) are rebuilt from scratch every time the user saves a TextUML file, we use stable id generation to allow cross references to remain valid:

if (resource instanceof XMIResource) {
	for (TreeIterator ti = resource.getAllContents(); ti.hasNext();) {
		EObject current = (EObject) ti.next();
		String identifier = UML2Util.getXMIIdentifier((InternalEObject) current);
		((XMIResource) resource).setID(current, identifier);
	}
}


Rafael
http://alphasimple.com

[Updated on: Thu, 16 December 2010 17:04]

Report message to a moderator

Re: [solved] How to modify a profile that is already in use? [message #645360 is a reply to message #645343] Thu, 16 December 2010 18:19 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
Hi Rafael,

the two different ids perfectly make sense, which I tried to explain in the linked article. I'll try to demonstrate it. A model that applies a profile references it that way (when saved as XMI):
<references xmi:type="ecore:EPackage" href="http://argouml.org/user-profiles/myProfile.xmi#_vOqHcPOuEd-ZR_t966HNrQ"/>

This is a reference to the following node in the profile's XMI:
<contents xmi:type="ecore:EPackage" xmi:id="_vOqHcPOuEd-ZR_t966HNrQ" name="myProfile" nsURI="http:///schemas/myProfile/_vONbgPOuEd-ZR_t966HNrQ/0"
          nsPrefix="myProfile">

After calling define() again on the profile, another node is created with another id:
<contents xmi:type="ecore:EPackage" xmi:id="_2q7_IAavEeCTnu3LMa6_rg" name="myProfile" nsURI="http:///schemas/myProfile/_2qyOIAavEeCTnu3LMa6_rg/1"
          nsPrefix="myProfile">

Both nodes (I called them Ecore packages in the article) are in the profile, they are loaded when the profile is used. So the above reference in the model's XMI serializations remains valid. New models using the profile will use the new Ecore package with the id "_2q7_IAavEeCTnu3LMa6_rg":
references xmi:type="ecore:EPackage" href="http://argouml.org/user-profiles/myProfile.xmi#_2q7_IAavEeCTnu3LMa6_rg"/>

What I found is that even my old model with the old reference (to id "_vOqHcPOuEd-ZR_t966HNrQ") not only loads fine (because the profile has both Ecore packages), but even more, the UML2 xmi parser CHANGES that reference to the new one (to id "_2q7_IAavEeCTnu3LMa6_rg")!

So, there is no need to programmatically do a stable id generation, as far as I see. Is there a reason for the code you posted?

(I hope I got your question right.)
Re: [solved] How to modify a profile that is already in use? [message #645385 is a reply to message #645360] Thu, 16 December 2010 22:32 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
I understand better now, thanks.

It sounds weird to me that you will keep all these stale definitions around (growing indefinitely).

I would look into removing an existing definition before defining the profile again. This old thread ended with a similar conclusion:

http://dev.eclipse.org/newslists/news.eclipse.tools.uml2/msg 04176.html

I am not sure if the magic you are seeing (old stereotype applications being automatically updated to reflect the latest definition) would continue to work though.

Re: my example - feel free to ignore it, it doesn't help in this case - it was intended to show how you can recreate entire models and have their ids to be predictable (because they are based on the qualified name of the element) and thus preserve any cross references.

Re: [solved] How to modify a profile that is already in use? [message #645442 is a reply to message #638933] Fri, 17 December 2010 09:31 Go to previous message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
Hi Rafael,

I explained in my article why all the different definitions are needed. Of course the profile keeps growing, but this is a tribute to a well working concept of managing profile dependencies (the profile itself cannot know which model depends on it).

It's like a stable interface distribution without a deprecation mechanism: any artefact (profile element in our case, function/method signature in the case of programming languages) that is once published, must be kept forever.

In the thread you mentioned, the problem was not multiple project definition, but the way it was used: when you define a profile in memory and then apply it to a model, then of course the saved model will contain profile references that don't exist, because the underlying profile is not saved after the second define.

About the "magic", and if it will continue to work: though I think it makes perfectly sense, I'd really appreciate if some expert would confirm that this is indeed intended (I found no docs on this)!
Previous Topic:looking for source for old version of UML2
Next Topic:Re: ANSI-C-model and dealing with redundant references
Goto Forum:
  


Current Time: Fri Dec 19 10:56:24 GMT 2014

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

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