Home » Modeling » UML2 » UML2 Versions
| |
Re: UML2 Versions [message #873904 is a reply to message #873890] |
Sat, 19 May 2012 12:24 |
Eclipse User |
|
|
|
i'm using emf and uml2 in a standalone app
then, how about
Registry packageRegistry = resourceSet.getPackageRegistry();
packageRegistry.put("http://www.eclipse.org/uml2/3.0.0/UML",
UMLPackage.eINSTANCE);
packageRegistry.put("http://www.eclipse.org/uml2/2.0.0/UML",
UMLPackage.eINSTANCE);
i.e. do i still have to register those namespaces in package registry?
On 19.05.2012 13:26, Ed Willink wrote:
>
> If you use plugins rather than Java projects you can just use
> org.eclipse.uml2.uml.resources and forget about the suffixes.
>
|
|
| |
Re: UML2 Versions [message #873919 is a reply to message #873914] |
Sat, 19 May 2012 13:26 |
Eclipse User |
|
|
|
Hi,
yes, i've already use that in my app, and it seems that i'm able to
handle xmi files with uml models inside, but i'm not sure whether code
i've used is generic enough to handle most used xmi formats/uml models.
And i also not really understand that code fully. Below is the method
which creates and configures resource set. I have a feeling that this
code is a bit silly and some statements seem superfluous to me
(especially adding all those elements to package registry). It would
greatly help me, if i would get a some feedback on that code.
Thanks in advance.
> private static ResourceSet getResourceSet() throws XMIHandlerException {
>
> if (resourceSet == null) {
> resourceSet = new ResourceSetImpl();
>
> String path = "lib/xmihandlerjars/org.eclipse.uml2.uml.resources_3.0.0.v200906011111.jar";
>
> Map<String, Object> extensionToFactoryMap = resourceSet
> .getResourceFactoryRegistry().getExtensionToFactoryMap();
> Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
>
> try {
> FileInputStream in = new FileInputStream(path);
> in.close();
> } catch (IOException e) {
> throw (new XMIHandlerException(e));
> }
>
> path = path.replace('\\', '/');
>
> URI uri = URI.createURI("jar:file:" + path + "!/");
> debug("resource URI --> " + uri);
>
> Registry packageRegistry = resourceSet.getPackageRegistry();
> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
> // for other xmi files with further namespaces:
> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_1_NS_URI,
> UMLPackage.eINSTANCE);
> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_1_URI,
> UMLPackage.eINSTANCE);
> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_NS_URI,
> UMLPackage.eINSTANCE);
> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_URI,
> UMLPackage.eINSTANCE);
> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_2_NS_URI,
> UMLPackage.eINSTANCE);
> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_NS_URI,
> UMLPackage.eINSTANCE);
> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_URI,
> UMLPackage.eINSTANCE);
> // eclipse namespaces:
> packageRegistry.put(UML212UMLResource.UML_METAMODEL_NS_URI,
> UMLPackage.eINSTANCE);
> packageRegistry.put("http://www.eclipse.org/uml2/3.0.0/UML",
> UMLPackage.eINSTANCE);
> packageRegistry.put("http://www.eclipse.org/uml2/2.0.0/UML",
> UMLPackage.eINSTANCE);
>
> // For the .uml files in the eclipse jar files, we need this:
> extensionToFactoryMap.put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri
> .appendSegment("libraries").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri
> .appendSegment("metamodels").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri
> .appendSegment("profiles").appendSegment(""));
>
> extensionToFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
> UML22UMLResource.Factory.INSTANCE);
> extensionToFactoryMap.put(XMI2UMLResource.FILE_EXTENSION,
> XMI2UMLResource.Factory.INSTANCE);
>
> uriMap.putAll(UML22UMLExtendedMetaData.getURIMap());
> uriMap.putAll(XMI2UMLExtendedMetaData.getURIMap());
> }
>
> return resourceSet;
>
> }
On 19.05.2012 15:06, Ed Willink wrote:
>
> Have you looked at
> http://wiki.eclipse.org/index.php/MDT-UML2-FAQ#What.27s_required_to_load_a_UML_.28.uml.29_resource_from_a_standalone_application.3F
>
|
|
|
Re: UML2 Versions [message #873926 is a reply to message #873919] |
Sat, 19 May 2012 13:51 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
You're getting there but you have no content type declarations so
inadequate handling of old and future namespaces.
For complete coverage use Juno's UMLResourcesUtil.init() and trim all
the 2.4 declarations.
Regards
Ed Willink
On 19/05/2012 14:26, Emil Huseynli wrote:
> Hi,
>
> yes, i've already use that in my app, and it seems that i'm able to
> handle xmi files with uml models inside, but i'm not sure whether code
> i've used is generic enough to handle most used xmi formats/uml
> models. And i also not really understand that code fully. Below is the
> method which creates and configures resource set. I have a feeling
> that this code is a bit silly and some statements seem superfluous to
> me (especially adding all those elements to package registry). It
> would greatly help me, if i would get a some feedback on that code.
>
> Thanks in advance.
>
>> private static ResourceSet getResourceSet() throws
>> XMIHandlerException {
>>
>> if (resourceSet == null) {
>> resourceSet = new ResourceSetImpl();
>>
>> String path =
>> "lib/xmihandlerjars/org.eclipse.uml2.uml.resources_3.0.0.v200906011111.jar";
>>
>> Map<String, Object> extensionToFactoryMap = resourceSet
>> .getResourceFactoryRegistry().getExtensionToFactoryMap();
>> Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
>>
>> try {
>> FileInputStream in = new FileInputStream(path);
>> in.close();
>> } catch (IOException e) {
>> throw (new XMIHandlerException(e));
>> }
>>
>> path = path.replace('\\', '/');
>>
>> URI uri = URI.createURI("jar:file:" + path + "!/");
>> debug("resource URI --> " + uri);
>>
>> Registry packageRegistry = resourceSet.getPackageRegistry();
>> packageRegistry.put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
>> packageRegistry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
>> // for other xmi files with further namespaces:
>> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_1_NS_URI,
>> UMLPackage.eINSTANCE);
>> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_1_URI,
>> UMLPackage.eINSTANCE);
>> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_NS_URI,
>> UMLPackage.eINSTANCE);
>> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_1_URI,
>> UMLPackage.eINSTANCE);
>> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_2_2_NS_URI,
>> UMLPackage.eINSTANCE);
>> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_NS_URI,
>> UMLPackage.eINSTANCE);
>> packageRegistry.put(XMI212UMLResource.UML_METAMODEL_URI,
>> UMLPackage.eINSTANCE);
>> // eclipse namespaces:
>> packageRegistry.put(UML212UMLResource.UML_METAMODEL_NS_URI,
>> UMLPackage.eINSTANCE);
>> packageRegistry.put("http://www.eclipse.org/uml2/3.0.0/UML",
>> UMLPackage.eINSTANCE);
>> packageRegistry.put("http://www.eclipse.org/uml2/2.0.0/UML",
>> UMLPackage.eINSTANCE);
>>
>> // For the .uml files in the eclipse jar files, we need this:
>> extensionToFactoryMap.put(UMLResource.FILE_EXTENSION,
>> UMLResource.Factory.INSTANCE);
>> uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri
>> .appendSegment("libraries").appendSegment(""));
>> uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri
>> .appendSegment("metamodels").appendSegment(""));
>> uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri
>> .appendSegment("profiles").appendSegment(""));
>>
>> extensionToFactoryMap.put(UML22UMLResource.FILE_EXTENSION,
>> UML22UMLResource.Factory.INSTANCE);
>> extensionToFactoryMap.put(XMI2UMLResource.FILE_EXTENSION,
>> XMI2UMLResource.Factory.INSTANCE);
>>
>> uriMap.putAll(UML22UMLExtendedMetaData.getURIMap());
>> uriMap.putAll(XMI2UMLExtendedMetaData.getURIMap());
>> }
>>
>> return resourceSet;
>>
>> }
>
>
>
> On 19.05.2012 15:06, Ed Willink wrote:
>>
>> Have you looked at
>> http://wiki.eclipse.org/index.php/MDT-UML2-FAQ#What.27s_required_to_load_a_UML_.28.uml.29_resource_from_a_standalone_application.3F
>>
>>
|
|
|
Re: UML2 Versions [message #873933 is a reply to message #873926] |
Sat, 19 May 2012 14:06 |
Eclipse User |
|
|
|
ok, thanks a lot for quick responses!
On 19.05.2012 15:51, Ed Willink wrote:
>
> For complete coverage use Juno's UMLResourcesUtil.init() and trim all
> the 2.4 declarations.
>
|
|
| |
Re: UML2 Versions [message #874028 is a reply to message #873926] |
Sat, 19 May 2012 19:27 |
Eclipse User |
|
|
|
Hi,
i've switched to latest stable builds of both emf (2.8.0M7) and UML2
(4.0.0M7) and passing my resourceSet to UMLResourceUtil.init(). Do i
still need to do following?
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri
.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri
.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri
.appendSegment("profiles").appendSegment(""));
On 19.05.2012 15:51, Ed Willink wrote:
> Hi
>
> You're getting there but you have no content type declarations so
> inadequate handling of old and future namespaces.
>
> For complete coverage use Juno's UMLResourcesUtil.init() and trim all
> the 2.4 declarations.
>
|
|
|
Re: UML2 Versions [message #874195 is a reply to message #874028] |
Sun, 20 May 2012 05:41 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi<br>
<br>
The appended message from uml2-dev may answer all your questions.
Please criticize as appropriate. (The OCL usage is in M7.)<br>
---------------<br>
The Juno release of MDT/UML2 adds UML 2.4 and 2.4.1 support and
consequently many more namespaces whose content handlers need to be
correctly registered.
<br>
<br>
When running within Eclipse, the magic of extension points should
ensure that this happens automatically.
<br>
<br>
When running standalone, these registrations have been a consumer
responsibility. Most modeling tools have emerged in the last few
years while UML2 has been stable with support for UML 2.2 and so the
complexities of multi-version support is easily overlooked in some
handcrafted UML initialisation code.
<br>
<br>
In the latest MDT/UML2 I-build, there is a UML standalone
initialization routine (<a class="moz-txt-link-freetext"
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=364419">https://bugs.eclipse.org/bugs/show_bug.cgi?id=364419</a>).
Just invoke UMLResourcesUtil.init(null). This does all the hard
work, and should hide the next generation of changes for UML 2.5.
Only the physical location URI mappings are missing; i.e. from the
resolution of "platform:<i class="moz-txt-slash"><span
class="moz-txt-tag">/</span>resource/org.eclipse.uml2.uml.resources/profiles<span
class="moz-txt-tag">/</span></i>" to
URI.createURI(UMLResource.PROFILES_PATHMAP); similarly for
'metamodels' and 'libraries'. If you have automated plugin location,
using classpath analysis as performed by MWE2's StandaloneSetup
scanPath, or
org.eclipse.ocl.examples.domain.utilities.StandaloneProjectMap, this
missing step may be done automatically as well.
<br>
<br>
A patch to upgrade org.eclipse.ocl.uml.OCL.initialize(resourceSet)
to call UMLResourcesUtil.init(resourceSet) is in the pipeline, so
consumers of OCL.initialize need take no action other than taking
the opportunity to remove their duplicate initializations.
<br>
<br>
Other tools are encouraged to start using
UMLResourcesUtil.init(null) as soon as possible so that any residual
bugs are fixed for Juno, ensuring that UML 2.5 can be introduced
without a further downstream initialization ripple.
<br>
<br>
Regards
<br>
<br>
Ed Willink
<br>
<br>
<br>
<br>
On 19/05/2012 20:27, Emil Huseynli wrote:
<blockquote cite="mid:jp8s5m$341$1@xxxxxxxxe.org" type="cite">Hi,
<br>
<br>
i've switched to latest stable builds of both emf (2.8.0M7) and
UML2 (4.0.0M7) and passing my resourceSet to
UMLResourceUtil.init(). Do i still need to do following?
<br>
<br>
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri
<br>
.appendSegment("libraries").appendSegment(""));
<br>
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
uri
<br>
.appendSegment("metamodels").appendSegment(""));
<br>
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri
<br>
.appendSegment("profiles").appendSegment(""));
<br>
<br>
<br>
On 19.05.2012 15:51, Ed Willink wrote:
<br>
<blockquote type="cite">Hi
<br>
<br>
You're getting there but you have no content type declarations
so
<br>
inadequate handling of old and future namespaces.
<br>
<br>
For complete coverage use Juno's UMLResourcesUtil.init() and
trim all
<br>
the 2.4 declarations.
<br>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>
|
|
|
Re: UML2 Versions [message #874283 is a reply to message #874195] |
Sun, 20 May 2012 11:49 |
Eclipse User |
|
|
|
so, it does happen automatically for me, no need to populate uriMap
On 20.05.2012 07:41, Ed Willink wrote:
> Hi
>
> The appended message from uml2-dev may answer all your questions. Please
> criticize as appropriate. (The OCL usage is in M7.)
|
|
|
Goto Forum:
Current Time: Wed Apr 24 16:43:59 GMT 2024
Powered by FUDForum. Page generated in 1.03547 seconds
|