Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Plug-in Profile URI_Mapping
Plug-in Profile URI_Mapping [message #1752602] Wed, 25 January 2017 15:00 Go to next message
Daniel Clarke is currently offline Daniel ClarkeFriend
Messages: 24
Registered: March 2016
Junior Member
Hi,

I've created a UML Profile in Papyrus. I then conveted this to an Eclipse Plugin Project. I've created a number of extensions below as specified in another thread: https://www.eclipse.org/forums/index.php/t/604098/

   <extension
         point="org.eclipse.emf.ecore.generated_package">
      <package
            class="test.profile.EPackage1"
            uri="test.profile.package1">
      </package>
   </extension>
   <extension
         point="org.eclipse.uml2.uml.generated_package">
      <profile
            location="platform:/plugin/test.profile/test_profile.profile.uml"
            uri="test.profile">
      </profile>
   </extension>
   <extension
         point="org.eclipse.papyrus.uml.extensionpoints.UMLProfile">
      <profile
            description="A test UML profile"
            name="test.profile"
            path="platform:/plugin/test.profile/test_profile.profile.uml">
      </profile>
   </extension>
   <extension
         point="org.eclipse.emf.ecore.uri_mapping">
      <mapping
            source="pathmap://test.profile/"
            target="platform:/plugin/test.profile/">
      </mapping>
   </extension>


However, I am unsure what these values should be set to... Anyway, if I export this profile using "Deployable plug-ins and fragments" and install on the host Eclipse, when it restarts I can select the profile to apply to a model and all is good...

However, I have another project in which I am trying to interogate the UML model (which references the profile) in order to generate code. When I attempt to run this, I get the following error:

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http:///schemas/Test_Profile/_I0W14KAUEeaf1fcNl03atw/51' not found. (file:/D:/Test_Model, 261, 104)

So it appears it cannot load the profile for some reason. I presume it is because the URI mapping is not correct? I have tried many different things, but do not really understand how everything is tied together.

Any help is appreciated.

Regards,
Dan
Re: Plug-in Profile URI_Mapping [message #1752621 is a reply to message #1752602] Wed, 25 January 2017 15:45 Go to previous messageGo to next message
Daniel Clarke is currently offline Daniel ClarkeFriend
Messages: 24
Registered: March 2016
Junior Member
Ok, so I didn't define a URI within the profile... I've done that now (set it to test.profile) and I get a slightly different error message...

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'test.profile' not found. (file:/D:/Test_Model, 261, 104).

This makes slightly more sense as I couldn't understand where it was picking up the "http:///schemas/Test_Profile...." However, still no closer to getting it working...
Re: Plug-in Profile URI_Mapping [message #1781293 is a reply to message #1752621] Mon, 05 February 2018 16:58 Go to previous messageGo to next message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
Hi Daniel,

I struggle with the same problem. I have created a small UML Profile with 2 stereotypes applied to a testmodel. If I run acceleo in the workspace environment (the profile is applied from the workspace) the
stereotype names are reported correctly (via aClass.getAppliedStereotypes().Name). Then if I export the profile as plugin and apply the registered plugin on my testmodel. After that I get the same errormessage like you.
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http:///schemas/DanaArchitecture/_EZ4nQAp8Eei7hods3tKEvg/0' not found. (file:/C:/Projects/DataAnalytics/UML/Tool/eclipse-modeling-neon-3-win32-x86_64/dana_ws/dana.architecture.model/DanaArchitectureModel.uml, 26, 96)
It seems that Acceleo can not resolve pathmap://DANA_PROFILE/... in my testmodel .uml file.
Can you confirm this behaviour in your application?
Best regards
Michael

Re: Plug-in Profile URI_Mapping [message #1781334 is a reply to message #1781293] Tue, 06 February 2018 07:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

IIRC the autogenerate main for Acceleo has comments on how to register UML correctly.

Regards

Ed Willink
Re: Plug-in Profile URI_Mapping [message #1781562 is a reply to message #1781334] Thu, 08 February 2018 16:12 Go to previous messageGo to next message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
Hi Ed,

the reason for the exception was the incorrect registration of the UML Profile plugin. (your remark) After generation of a static UML Profile
(from Help Contents -> Papyrus Guide -> Tasks -> Using UML Profile -> Generating Static Profiles) the package was correctly registered.
(new package registration was added:
if (!isInWorkspace(DanaArch.DanaArchPackage.class)) {
resourceSet.getPackageRegistry().put(DanaArch.DanaArchPackage.eINSTANCE.getNsURI(), DanaArch.DanaArchPackage.eINSTANCE);
} )
But I still have the Problem, that the call [aClass.getAppliedStereotypes().name/] (the stereotype is taken from my profile) is empty.
I have tried this again by using a stereotype of org.eclipse.uml2.uml.profile.standard. After add of the line
UMLResourcesUtil.init(resourceSet); the stereotype name was reported.
But neighter for used stereotypes of my profile nor from the MARTE profile the stereotype names were reported.
Any idea what is missing here.

Regards
Michael
Re: Plug-in Profile URI_Mapping [message #1781566 is a reply to message #1781562] Thu, 08 February 2018 17:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I'm sorry; I see ample opportunities for error, but I am afraid that if you cannot take the time to share a repro of your problem, I certainly do not have time to elaborate upon every possible guess that I might make as to what your problem is. See https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink
Re: Plug-in Profile URI_Mapping [message #1781610 is a reply to message #1781566] Fri, 09 February 2018 12:11 Go to previous messageGo to next message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
Hi Ed,

ok. To describe my problem I have created a static UML plugin, containing 2 stereotypes MyStereotype1 and MyStereotype2 extending the <<Metaclass>> class.
Name: com.mycompany.myproject.static.profile
This plugin is exported as a deployable plugin and copied to the eclipse plugins Directory.
Name: com.mycompany.myproject.static.profile_1.0.0.201802091212.jar
The UML model MyProject.uml (in com.mycompany.myproject.model) uses this UML plugin via Apply Registered Profile. It contains
two classes Class1 and Class2, which are applying the both stereotype MyStereotype1 and MyStereotype2 from the profile.
With the Acceleo plugin com.mycompany.myproject.acceleo I want to generate to two files Class1 and Class2 with the class name and
the applied stereotypes.
Content of generate.mtl:
[comment encoding = UTF-8 /]
[module generate('http://www.mycompany.com/MyProject/1', 'http://www.eclipse.org/uml2/5.0.0/UML')]
[template public generateElement(aClass : Class)]
[comment @main/]
[file (aClass.name, false, 'UTF-8')]
class: [aClass.name/], applied stereotypes: [aClass.getAppliedStereotypes().name/]
[/file]
[/template]
My problem is, that the used stereotypes names are not reported.
I just get the class names.
Enclosed:
the deployable UML profile plugin
com.mycompany.myproject.static.profile_1.0.0.201802091212.jar
in com.mycompany.myproject.zip
-Papyrus profile project: com.mycompany.myproject.static.profile
-Papyrus model project: com.mycompany.myproject.model
-Acceleo project: com.mycompany.myproject.acceleo
I hope, it is possible the reproduce the problem.

Best regards
Michael


Re: Plug-in Profile URI_Mapping [message #1781611 is a reply to message #1781610] Fri, 09 February 2018 12:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I'm not able to access your ZIP; it appears to be corrupt. Please try again and check that you can unzip it. If that fails, please post a DropBox or equivalent link. Or email me direct ed_at_willink.me.uk.

Can you provide the output file that you actually get, and separately what you would like to have got.

Regards

Ed Willink
Re: Plug-in Profile URI_Mapping [message #1781617 is a reply to message #1781611] Fri, 09 February 2018 13:44 Go to previous messageGo to next message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
Hi Ed,

thanks for your rapid reply. Enclosed the project and the expected output files.

Best regards
Michael

Re: Plug-in Profile URI_Mapping [message #1781625 is a reply to message #1781617] Fri, 09 February 2018 16:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Problem 1: You have not called UMLResourcesUtiI.init. You have not even uncommented the *.uml registration lines. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=530953 raised) Consequently your input is read as an XMIResourceImpl rather than a UMLResourceImpl.

Add UMLResourcesUtil.init(null); as the first line of main().

Problem 2: You have used a pathmap: without registering it

If you add the following to your Generate.java (https://bugs.eclipse.org/bugs/show_bug.cgi?id=530955 raised)

@Override
public EObject getModel() {
EObject model2 = super.getModel();
Resource eResource = model2.eResource();
EcoreUtil.resolveAll(eResource);
for (Resource resource : eResource.getResourceSet().getResources()) {
List<Diagnostic> errors = resource.getErrors();
for (Diagnostic error : errors) {
System.err.println(error);
}
}
return model2;
}

you will get the console output

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.net.MalformedURLException: unknown protocol: pathmap

The unresolved proxies have no name which is what you saw.

See UMLResourcesUtil.mapURIs for examples of configuring pathmap in the URI map.

One nice feature of Acceleo is that you can launch directly in the debugger without using a nested Eclipse. Java level debugging is easy once you install Acceleo with sources from its update site (https://bugs.eclipse.org/bugs/show_bug.cgi?id=530945 raised).

Regards

Ed Willink
Re: Plug-in Profile URI_Mapping [message #1781768 is a reply to message #1781625] Tue, 13 February 2018 08:55 Go to previous message
Michael Nestler is currently offline Michael NestlerFriend
Messages: 30
Registered: September 2014
Member
Hi Ed,

finally I fixed the Problem 2: You have used a pathmap: without registering it
by appending this lines (taken from UMLResourcesUtil) in registerPackages(ResourceSet resourceSet):
//register pathmap for applied profile pathmap://MYPROJECT_PROFILE/MyProject.profile.uml
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
URL profileURL = UMLUtil.class.getClassLoader().getResource(String.format("model/%s", "MyProject.ecore"));
URI profileURI = null;

if (profileURL != null) {
profileURI = URI.createURI(profileURL.toExternalForm(), true).trimSegments(2);
String uri = "pathmap://MYPROJECT_PROFILE/";
URI prefix = URI.createURI(uri);

URI location = profileURI.appendSegment("model");

// ensure trailing separator (make it a "URI prefix")
if (!prefix.hasTrailingPathSeparator()) {
prefix = prefix.appendSegment("");
}

// same with the location
if (!location.hasTrailingPathSeparator()) {
location = location.appendSegment("");
}
uriMap.put(prefix, location);
}

Thanks for your help.

Regards
Michael
Previous Topic:Active object execution and stimulation with signals
Next Topic:Moving a class diagram between packages
Goto Forum:
  


Current Time: Thu Mar 28 12:00:05 GMT 2024

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

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

Back to the top