Plug-in Profile URI_Mapping [message #1752602] |
Wed, 25 January 2017 10:00  |
Eclipse User |
|
|
|
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 #1781610 is a reply to message #1781566] |
Fri, 09 February 2018 07:11   |
Eclipse User |
|
|
|
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 #1781768 is a reply to message #1781625] |
Tue, 13 February 2018 03:55  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.06406 seconds