read uml model program [message #1744742] |
Thu, 29 September 2016 19:34 |
W. Shen Messages: 3 Registered: September 2016 |
Junior Member |
|
|
I try to read a simple UML model in .uml file saved from RSA. I have the following code:
public void loadModel() {
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
.put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
URI uri = URI.createURI("models" + System.getProperty("file.separator")
+ this.file_name);
Resource resource = resourceSet.getResource(uri, true);
Collection<?> packages = EcoreUtil.getObjectsByType(
resource.getContents(), UMLPackage.Literals.PACKAGE);
Iterator<?> it = packages.iterator();
System.out.println("Checking packages?");
while (it.hasNext()) {
System.out.println("Enter a package");
....
}
}
but it seems that the code can read the model info when I have the following jar files included
but when I use required plugins via dependencies (via MANIFEST.MF which is shown as follows:
...
Require-Bundle: org.eclipse.emf.common;bundle-version="2.11.1",
org.eclipse.emf.ecore;bundle-version="2.11.2",
org.eclipse.emf.ecore.xmi;bundle-version="2.11.1",
org.eclipse.uml2.common;bundle-version="2.1.0",
org.eclipse.uml2.uml;bundle-version="5.1.2"
I notice the difference between the versions. How can I revise the code to make the MANIFEST.MF file work? Should I change sth in the .uml file?
Thanks.
-
Attachment: jarfiles.jpg
(Size: 45.87KB, Downloaded 822 times)
|
|
|
|
|
|
Re: read uml model program [message #1744967 is a reply to message #1744742] |
Mon, 03 October 2016 14:28 |
|
Hi,
RSA uses an older release of UML2 than is current (it implements, I think, the OMG UML 2.2 version of the language, which is quite different in some important ways).
These UML models from RSA cannot be loaded by the default UML resource implementation in UML2. There are transformations that need to be performed, as described by various ecore2ecore and ecore2xml files packaged with the UML plug-in.
So, you need to adjust your code to use the proper resource implementation for the files that you are loading. This can be handled automatically in the Eclipse run-time by letting the resource set's resource registry figure it out according to the content-type detected in the model file, or you can set up registrations in your resource-set explicitly. That may be necessary if you are not running in the Eclipse run-time.
Have a look at Bug437977Test class in the UML2 test suite to see an example of loading models from an older version of UML.
HTH,
Christian
|
|
|
Powered by
FUDForum. Page generated in 0.02578 seconds