Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Re: Problem load model
Re: Problem load model [message #491057] Tue, 13 October 2009 04:03 Go to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26223
Registered: July 2009
Senior Member
Ouakib,

It's best to use the UML newsgroup to ask UML questions. I've added it
to the "to" list of the reply. More comments below.

ouakib wrote:
> Hi ,
> I work on an eclipse application , which the aim is to get from an UML
> model all the classes having the stereotype "entity".
> I have two files : "profile.uml" which contains stereotypes and
> "mymodel.uml" which contains classes and it references "profile.uml"
> . Here is my source code :
> URI uri =
> URI.createFileURI("/projectName/model/mymodel.uml");
This doesn't look like a good file URI to me. Shouldn't you be using
URI.createPlatfromResourceURI?
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource resource = resourceSet.getResource(uri, true);
> EObject value= resource.getContents().get(0);
> String proposal ="";
> for (TreeIterator<EObject> iteratorTree =
> EcoreUtil.getAllContents(value.eContents());
> iteratorTree.hasNext();) {
> EObject content = iteratorTree.next();
> if (content instanceof Class
> )
> { Class ve = (Class) content;
> if(ve.hasStereotype("Entity")) {
> proposal =ve.getName() ;
> ICompletionProposal completionProposal
> =createCompletionProposal(proposal, context);
> acceptor.accept(completionProposal); the file "mymodel.uml"
> was loaded but "profile.uml" wasn't. so the test :
> ve.hasStereotype("Entity") is always false .
> Can you see the problem?
The URI looks questionable.
Re: Problem load model [message #491147 is a reply to message #491057] Tue, 13 October 2009 13:18 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
The profile is saved in the model directly as <<entity>> and have a dynamic Id which is added before the name of your class and at the botton of your xmi file.

I mean that for example I am creating two Entities stereotype in my diagram. This stereotype has an Id which is similar to both Classes and at the end of the xmi you have a kind of dynamic annotation such as for example: _5SBN4K9pEd62HvqAnAI8RQ
You need to identify what is the dynamic Id of your stereotype and then query directly the xml file of your model.

The dynamic Id concept is really cool because you can refactor your model, update it etc...and all model information will immediately be updated. This approach is a lot more powerful than the Id related to the name of an element which could be refactored and then lost. I mean that you can not refactor an Id therefore it is not a risk for your model Smile
I know that if you want to query the model then it is really painful but the problem is somewhere else. Don't forget that the model should be in memory therefore this query should immediate give a result. If you parse the model on disk it would be too long. I think the best is either to use EMF with GMF or directly the metamodel and parse the in memory model.

The problem is that GMF model is different from the metamodel stereotypes because of transformation stage therefore it seems that only directly working at metamodel level would solve this dilema !!
I mean to parse the .uml model but this woud be a long process to query it each time. I mean 30 seconds or even more for a real and not a test model.


My recommendation would be to select a tools directly working at metamodel level and not using transformation layers.
Re: Problem load model [message #491192 is a reply to message #491147] Tue, 13 October 2009 15:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26223
Registered: July 2009
Senior Member
Vlad,

Comments below.

Vlad Varnica wrote:
> The profile is saved in the model directly as <<entity>> and have a
> dynamic Id which is added before the name of your class and at the
> botton of your xmi file.
That's a serialization detail one would hope not to have to know about
when working with the UML2 API.
>
>
> I mean that for example I am creating two Entities stereotype in my
> diagram. This stereotype has an Id which is similar to both Classes
> and at the end of the xmi you have a kind of dynamic annotation such
> as for example: _5SBN4K9pEd62HvqAnAI8RQ
It looks like a UUID...
>
> You need to identify what is the dynamic Id of your stereotype and
> then query directly the xml file of your model.
You're suggesting one work directly with XML?
>
> The dynamic Id concept is really cool because you can refactor your
> model, update it etc...and all model information will immediately be
> updated. This approach is a lot more powerful than the Id related to
> the name of an element which could be refactored and then lost. I mean
> that you can not refactor an Id therefore it is not a risk for your
> model :)
> I know that if you want to query the model then it is really painful
> but the problem is somewhere else.
What problem?
> Don't forget that the model should be in memory therefore this query
> should immediate give a result. If you parse the model on disk it
> would be too long.
The code in the original question is loading the resource into memory.
Are you suggesting that's too long?
> I think the best is either to use EMF with GMF or directly the
> metamodel and parse the in memory model.
That's exactly what they are doing...
>
>
> The problem is that GMF model is different from the metamodel
> stereotypes because of transformation stage therefore it seems that
> only directly working at metamodel level would solve this dilema !!
Not sure there was a dilemma. There was no mention of GMF in the post...
> I mean to parse the .uml model but this woud be a long process to
> query it each time. I mean 30 seconds or even more for a real and not
> a test model.
I don't understand what alternative you're suggesting. Not to parse the
UML model?
> My recommendation would be to select a tools directly working at
> metamodel level and not using transformation layers.
Surely this doesn't address any question in the original post? What
tool are suggesting be selected? Isn't UML the meta model level?
Re: Problem load model [message #627985 is a reply to message #491057] Tue, 13 October 2009 13:18 Go to previous message
Vlad Varnica is currently offline Vlad VarnicaFriend
Messages: 546
Registered: July 2009
Location: Milton Keynes - UK
Senior Member
The profile is saved in the model directly as <<entity>> and have a dynamic Id which is added before the name of your class and at the botton of your xmi file.

I mean that for example I am creating two Entities stereotype in my diagram. This stereotype has an Id which is similar to both Classes and at the end of the xmi you have a kind of dynamic annotation such as for example: _5SBN4K9pEd62HvqAnAI8RQ
You need to identify what is the dynamic Id of your stereotype and then query directly the xml file of your model.

The dynamic Id concept is really cool because you can refactor your model, update it etc...and all model information will immediately be updated. This approach is a lot more powerful than the Id related to the name of an element which could be refactored and then lost. I mean that you can not refactor an Id therefore it is not a risk for your model :)
I know that if you want to query the model then it is really painful but the problem is somewhere else. Don't forget that the model should be in memory therefore this query should immediate give a result. If you parse the model on disk it would be too long. I think the best is either to use EMF with GMF or directly the metamodel and parse the in memory model.

The problem is that GMF model is different from the metamodel stereotypes because of transformation stage therefore it seems that only directly working at metamodel level would solve this dilema !!
I mean to parse the .uml model but this woud be a long process to query it each time. I mean 30 seconds or even more for a real and not a test model.

My recommendation would be to select a tools directly working at metamodel level and not using transformation layers.
Re: Problem load model [message #627987 is a reply to message #491147] Tue, 13 October 2009 15:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26223
Registered: July 2009
Senior Member
Vlad,

Comments below.

Vlad Varnica wrote:
> The profile is saved in the model directly as <<entity>> and have a
> dynamic Id which is added before the name of your class and at the
> botton of your xmi file.
That's a serialization detail one would hope not to have to know about
when working with the UML2 API.
>
>
> I mean that for example I am creating two Entities stereotype in my
> diagram. This stereotype has an Id which is similar to both Classes
> and at the end of the xmi you have a kind of dynamic annotation such
> as for example: _5SBN4K9pEd62HvqAnAI8RQ
It looks like a UUID...
>
> You need to identify what is the dynamic Id of your stereotype and
> then query directly the xml file of your model.
You're suggesting one work directly with XML?
>
> The dynamic Id concept is really cool because you can refactor your
> model, update it etc...and all model information will immediately be
> updated. This approach is a lot more powerful than the Id related to
> the name of an element which could be refactored and then lost. I mean
> that you can not refactor an Id therefore it is not a risk for your
> model :)
> I know that if you want to query the model then it is really painful
> but the problem is somewhere else.
What problem?
> Don't forget that the model should be in memory therefore this query
> should immediate give a result. If you parse the model on disk it
> would be too long.
The code in the original question is loading the resource into memory.
Are you suggesting that's too long?
> I think the best is either to use EMF with GMF or directly the
> metamodel and parse the in memory model.
That's exactly what they are doing...
>
>
> The problem is that GMF model is different from the metamodel
> stereotypes because of transformation stage therefore it seems that
> only directly working at metamodel level would solve this dilema !!
Not sure there was a dilemma. There was no mention of GMF in the post...
> I mean to parse the .uml model but this woud be a long process to
> query it each time. I mean 30 seconds or even more for a real and not
> a test model.
I don't understand what alternative you're suggesting. Not to parse the
UML model?
> My recommendation would be to select a tools directly working at
> metamodel level and not using transformation layers.
Surely this doesn't address any question in the original post? What
tool are suggesting be selected? Isn't UML the meta model level?
Previous Topic:UML validation from org.eclipse.emf.validation.examples.general
Next Topic:UML2 Javadoc
Goto Forum:
  


Current Time: Wed Nov 26 06:30:17 GMT 2014

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

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