Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » EMF - not possible to create a profile model
EMF - not possible to create a profile model [message #1334476] Mon, 05 May 2014 15:55 Go to next message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 128
Registered: April 2013
Senior Member
Hello,

I have an issue with creating an EMF profile file. In the ZIP file I attached, a minimal example is provided (targeting Epsilon developments, however I reduced it to the EMF part to solve the current issue). There, it is possible to create the model file "LeftModel.uml", as the output to the console shows.

However, when I try to create the profile file, this does not work. In the subsequent step, I try to create the EMF model for "LeftModel.uml", trying to use my profile file. However, this results in exceptions.

Any support is very much appreciated, thanks.

Kind regards, Alex
Re: EMF - not possible to create a profile model [message #1334691 is a reply to message #1334476] Mon, 05 May 2014 18:06 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1006
Registered: July 2009
Senior Member
Hi, Alex,

The example you provided doesn't seem to be reduced to just EMF: it
has Epsilon dependencies. Moreover, half of the code seems to be
commented out. And I don't know what any of it is actually trying to
do. Is there supposed to be anything in these model files? Are you
creating new files or loading existing files? It's all quite opaque to
me (I know nothing of Epsilon).

I can't run the example code without quite a bit of work. Can you just
share what the exceptions are that you are seeing? It appears, at
least, that you are running this code "stand-alone" (not in the context
of a running Eclipse instance). In that case, in order to for work
with UML Profiles, you have a few EMF and UML2 registries to populate,
first. Have a look at the UMLResourcesUtil::init(ResourceSet) API and
how it is used by the UML2 JUnit tests for an example (especially the
tests in the org.eclipse.uml2.uml.bug.tests package).

Cheers,

Christian


On 2014-05-05 15:55:43 +0000, Alexander Fülleborn said:

> Hello,
>
> I have an issue with creating an EMF profile file. In the ZIP file I
> attached, a minimal example is provided (targeting Epsilon
> developments, however I reduced it to the EMF part to solve the current
> issue). There, it is possible to create the model file "LeftModel.uml",
> as the output to the console shows.
>
> However, when I try to create the profile file, this does not work. In
> the subsequent step, I try to create the EMF model for "LeftModel.uml",
> trying to use my profile file. However, this results in exceptions.
>
> Any support is very much appreciated, thanks.
>
> Kind regards, Alex
> <image>
Re: EMF - not possible to create a profile model [message #1337353 is a reply to message #1334691] Tue, 06 May 2014 20:54 Go to previous messageGo to next message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 128
Registered: April 2013
Senior Member
Hi Christian,

thanks a lot for your quick and constructive answer. I am so sorry that my example is too opaque for you, please excuse. Well, I have the following comments/answers (but also further questions ;-(() on it:


"The example you provided doesn't seem to be reduced to just EMF: it
has Epsilon dependencies."

==> You're right. I should remove it completely.

"Moreover, half of the code seems to be
commented out. And I don't know what any of it is actually trying to
do. Is there supposed to be anything in these model files? Are you
creating new files or loading existing files? It's all quite opaque to
me (I know nothing of Epsilon)."

==> I want to create models from *uml files that are then used by Epsilon to compare or transform them. The first part is my concern most important at the moment that I addressed to you.

"I can't run the example code without quite a bit of work. Can you just
share what the exceptions are that you are seeing?"

==> I propose that I first reduce the example really to EMF - as you propose. I found out that the exceptions have also an "Epsilon flavour".

"It appears, at
least, that you are running this code "stand-alone" (not in the context
of a running Eclipse instance). In that case, in order to for work
with UML Profiles, you have a few EMF and UML2 registries to populate,
first. Have a look at the UMLResourcesUtil::init(ResourceSet) API and
how it is used by the UML2 JUnit tests for an example (especially the
tests in the org.eclipse.uml2.uml.bug.tests package)."

==> That is true - it is a standalone scenario. I had a look to the sources you provided. However, I have quite a bit of problems to translate them to my case. E.g., in my current code, I create a list of "IModel" which is Epsilon specific. Unfortunately, I do not find an EMF type that I can use instead to replace this. Would it be possible that you give me any further hints?

What my program needs to do is:

1.) The "foundation" - to be solved first: Create model from file with a specific dsl profile
- be started in a separate Eclipse instance
- create a UML2 model from a .uml file, using a profile that is also provided as a .uml file

2.) Wrap the created UML2 models to Epsilon models in order to compare or transform them - to be supported by Epsilon expertise.

Thanks a lot for your appreciated support for 1.),

KR, Alex
Re: EMF - not possible to create a profile model [message #1340314 is a reply to message #1337353] Thu, 08 May 2014 02:21 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1006
Registered: July 2009
Senior Member
Hi, Alex,

If I understand correctly, by "create models" you actually mean to
"load models" from serialized resources (XML files) into memory.
Creating models suggests creating something that doesn't exist, yet;
you want to load something that already exists.

So, this is done much as with any EMF-based application (remember I
know nothing of Epsilon): in a ResourceSet, create a Resource on the
URI of the document (*.uml file) you want to load, then as the resource
to load itself. The *.uml file containing your model will have within
it properly encoded references to the profile that cause it to be
loaded automatically in the same resource set; you don't have to load
the profile explicitly.

The EMF tutorials [1], UML "Getting Started" [2] and "Introduction to
UML2 Profiles" [3] tutorials should help with all of this.

For stand-alone applications working with UML, there is (as previously
mentioned), some extra registration that needs to be done using the
UMLResourcesUtil: UMLResourcesUtil.init(ResourceSet). The UML
tutorials actually cover this. Moreover, those tutorials are shipped
with the latest milestone (Luna M7 [4]) of the UML2 SDK as installable
example projects, providing code that runs. Find them in the "File ->
New -> Example..." wizard.

HTH,

Christian

[1] http://www.eclipse.org/modeling/emf/docs/
[2] https://wiki.eclipse.org/MDT/UML2/Getting_Started_with_UML2
[3] https://wiki.eclipse.org/MDT/UML2/Introduction_to_UML2_Profiles
[4]
http://www.eclipse.org/modeling/mdt/downloads/?showAll=1&hlbuild=S201405050725&project=uml2


On 2014-05-06 20:54:02 +0000, Alexander Fülleborn said:

> Hi Christian,
>
> thanks a lot for your quick and constructive answer. I am so sorry that
> my example is too opaque for you, please excuse. Well, I have the
> following comments/answers (but also further questions ;-(() on it:
>
>
> "The example you provided doesn't seem to be reduced to just EMF: it
> has Epsilon dependencies."
>
> ==> You're right. I should remove it completely.
>
> "Moreover, half of the code seems to be
> commented out. And I don't know what any of it is actually trying to
> do. Is there supposed to be anything in these model files? Are you
> creating new files or loading existing files? It's all quite opaque to
> me (I know nothing of Epsilon)."
>
> ==> I want to create models from *uml files that are then used by
> Epsilon to compare or transform them. The first part is my concern most
> important at the moment that I addressed to you.
>
> "I can't run the example code without quite a bit of work. Can you just
> share what the exceptions are that you are seeing?"
>
> ==> I propose that I first reduce the example really to EMF - as you
> propose. I found out that the exceptions have also an "Epsilon flavour".
>
> "It appears, at
> least, that you are running this code "stand-alone" (not in the context
> of a running Eclipse instance). In that case, in order to for work
> with UML Profiles, you have a few EMF and UML2 registries to populate,
> first. Have a look at the UMLResourcesUtil::init(ResourceSet) API and
> how it is used by the UML2 JUnit tests for an example (especially the
> tests in the org.eclipse.uml2.uml.bug.tests package)."
>
> ==> That is true - it is a standalone scenario. I had a look to the
> sources you provided. However, I have quite a bit of problems to
> translate them to my case. E.g., in my current code, I create a list of
> "IModel" which is Epsilon specific. Unfortunately, I do not find an EMF
> type that I can use instead to replace this. Would it be possible that
> you give me any further hints?
>
> What my program needs to do is:
>
> 1.) The "foundation" - to be solved first: Create model from file with
> a specific dsl profile
> - be started in a separate Eclipse instance
> - create a UML2 model from a .uml file, using a profile that is also
> provided as a .uml file
>
> 2.) Wrap the created UML2 models to Epsilon models in order to compare
> or transform them - to be supported by Epsilon expertise.
>
> Thanks a lot for your appreciated support for 1.),
>
> KR, Alex
Re: EMF - not possible to create a profile model [message #1350565 is a reply to message #1340314] Mon, 12 May 2014 18:25 Go to previous messageGo to next message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 128
Registered: April 2013
Senior Member
Hi Christian,

thanks for your answer and the very helpful hints that it contains. In the meantime I reworked my example. I hope that I improved it according to your recommendations. Now, I get an exception that I attached together with the new version of my example to this reply and that looks like the following:


Hello. This is the minimal example to fix my problems with loading UML models from files.
file:/C:/Dokumente%20und%20Einstellungen/Sandra/Eigene%20Dateien/Forschung%20Alex/ProPMan%20-%20Problem-oriented%20Pattern%20Management/Minimal%20troubleshoot%20java%20example%20to%20fix%20UML2%20problems/bin/res/LeftModel.uml
LeftModel.uml
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.io.FileNotFoundException: C:\Dokumente%20und%20Einstellungen\Sandra\Eigene%20Dateien\Forschung%20Alex\ProPMan%20-%20Problem-oriented%20Pattern%20Management\Minimal%20troubleshoot%20java%20example%20to%20fix%20UML2%20problems\bin\res\LeftModel.uml (Das System kann den angegebenen Pfad nicht finden)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:377)
	at ProPManMinimalExample.getModel(ProPManMinimalExample.java:55)
	at ProPManMinimalExample.main(ProPManMinimalExample.java:45)
Caused by: java.io.FileNotFoundException: C:\Dokumente%20und%20Einstellungen\Sandra\Eigene%20Dateien\Forschung%20Alex\ProPMan%20-%20Problem-oriented%20Pattern%20Management\Minimal%20troubleshoot%20java%20example%20to%20fix%20UML2%20problems\bin\res\LeftModel.uml (Das System kann den angegebenen Pfad nicht finden)
	at java.io.FileInputStream.open(Native Method)
	at java.io.FileInputStream.<init>(Unknown Source)
	at org.eclipse.emf.ecore.resource.impl.FileURIHandlerImpl.createInputStream(FileURIHandlerImpl.java:99)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:354)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1256)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 3 more



I really tried to find out myself the reason, but unfortunately, I was not able to ;-(. Do you have an idea?

In addition I have another question: I know that my models are created for Eclipse UML < 4.0.0 (I think they are 3.0.0). How can I enable my plug-in to use them in spite of this difference? Do I need to select the 3.0.0 in the registration anywhere?

Thanks and kind regards, Alex

[Updated on: Mon, 12 May 2014 18:31]

Report message to a moderator

Re: EMF - not possible to create a profile model [message #1350873 is a reply to message #1350565] Mon, 12 May 2014 21:27 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1006
Registered: July 2009
Senior Member
Hi, Alex,

The problem was that your code started down the right path to getting a
URI for the UML resource to load (by looking up the classpath resource
URL), but then didn't do anything with that. Instead, it tried to load
a file resource from the absolute filesystem path "/res/LeftModel.uml"
which, of course, doesn't exist.

Find attached an update of your code sample that fixes this problem and
succeeds in loading the model and dumping its contents to standard
output. A launch configuration file is included.

Note a few changes in the project (you might want to do a directory
diff to see what's changed):

* it is converted to a plug-in project in order to simplify management of
the classpath (the included launch config doesn't launch an Eclipse
instance, though, but just a pure Java app). The classpath configured
in your project had hard-coded paths to particular versions of Eclipse
plug-in JARs that I don't have and in locations in your computer's
filesystem that meant nothing to my computer :-)

* the ProPManMinimalExample::main method, as I said, started to
compute the correct URI for the LeftModel.uml resource but then
abandoned it

* the ProPManMinimalExample::getModel method used the EcoreUtil
getEObjectsByType method, which returns a list, instead of just
getEObjectByType, which returns the first matching element. Simple
typo that you would have found if loading the resource had succeeded

Cheers,

Christian
Re: EMF - not possible to create a profile model [message #1351946 is a reply to message #1350873] Tue, 13 May 2014 08:20 Go to previous messageGo to next message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 128
Registered: April 2013
Senior Member
Hi Christian,

thanks a lot for your support and the provided solution! I just would like to test it. As I still get errors due to the fact that some classes are not found, I would like to get back to the following part of your answer:

"[...]
* it is converted to a plug-in project in order to simplify management of
the classpath (the included launch config doesn't launch an Eclipse
instance, though, but just a pure Java app). The classpath configured
in your project had hard-coded paths to particular versions of Eclipse
plug-in JARs that I don't have and in locations in your computer's
filesystem that meant nothing to my computer Smile
[...]"

What do I need to simplify the management of the classpath in my environment? I have not that much experience with Eclipse to exactly understand what you have done to make it work.

In addition I have another question: I know that my models are created for Eclipse UML < 4.0.0 (I think they are 3.0.0). How can I enable my plug-in to use them in spite of this difference? Do I need to select the 3.0.0 in the registration anywhere?

Thanks a lot and kind regards, Alex

[Updated on: Tue, 13 May 2014 13:20]

Report message to a moderator

Re: EMF - not possible to create a profile model [message #1353310 is a reply to message #1351946] Tue, 13 May 2014 21:37 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1006
Registered: July 2009
Senior Member
Hi, Alex,

You don't need to do anything that my updated sample doesn't do.

The point is that the PDE can use an OSGi bundle manifest's description
of its dependencies to generate a classpath automatically, based on the
symbolic names of the bundles it requires, instead of hard-coding a
classpath comprising specific JARs in specific locations on a
particular filesystem.

If some classes aren't found, you'll need to add to the MANIFEST.MF
dependencies on the bundles (or packages) that provide those classes.

If you don't know what the OSGi manifest is and how it works, you need
to read up on OSGi and how Eclipse uses it to implement its plug-in
architecture.

Cheers,

Christian


On 2014-05-13 08:20:33 +0000, Alexander Fülleborn said:

> Hi Christian,
>
> thanks a lot for your support and the provided solution! I just would
> like to test it. As I still get errors due to the fact that some
> classes are not found, I would like to get back to the following part
> of your answer:
>
> "[...]
> * it is converted to a plug-in project in order to simplify management of
> the classpath (the included launch config doesn't launch an Eclipse
> instance, though, but just a pure Java app). The classpath configured
> in your project had hard-coded paths to particular versions of Eclipse
> plug-in JARs that I don't have and in locations in your computer's
> filesystem that meant nothing to my computer :)
> [...]"
>
> What do I need to simplify the management of the classpath in my
> environment? I have not that much experience with Eclipse to exactly
> understand what you have done to make it work.
>
> Thanks a lot and kind regards, Alex
Re: EMF - not possible to create a profile model [message #1372400 is a reply to message #1353310] Wed, 21 May 2014 20:31 Go to previous message
Alexander Fülleborn is currently offline Alexander FüllebornFriend
Messages: 128
Registered: April 2013
Senior Member
Hi Christian,

thanks a lot for these helpful explanations! In the meantime, I have been able to get your rework of my example running - and I have made significant progress since then.

Have a good time and thanks again.

Cheers, Alex
Previous Topic:UML-specific Diagnostician?
Next Topic:IntroductionToUMLProfiles Question
Goto Forum:
  


Current Time: Wed Sep 02 15:05:56 GMT 2015

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

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