Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » read uml model program
read uml model program [message #1744742] Thu, 29 September 2016 19:34 Go to next message
W. Shen is currently offline W. ShenFriend
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
index.php/fa/27257/0/
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 266 times)
Re: read uml model program [message #1744830 is a reply to message #1744742] Fri, 30 September 2016 15:27 Go to previous messageGo to next message
W. Shen is currently offline W. ShenFriend
Messages: 3
Registered: September 2016
Junior Member
I am attaching the project which does not go into the while loop. But after moving the following statements:
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,"

from the MANIFEST.MF file. The project can read the packages, entering the while loop.
Look forward to knowing whether the difference of EMF/UML2 causes the difference. How should I change the project to read a UML model in the Require-Bundle?
Millions of Thanks.
Re: read uml model program [message #1744831 is a reply to message #1744742] Fri, 30 September 2016 15:28 Go to previous messageGo to next message
W. Shen is currently offline W. ShenFriend
Messages: 3
Registered: September 2016
Junior Member
I am attaching the project which does not go into the while loop. But after moving the following statements:
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,"

from the MANIFEST.MF file. The project can read the packages, entering the while loop.
Look forward to knowing whether the difference of EMF/UML2 causes the difference. How should I change the project to read a UML model in the Require-Bundle?
Millions of Thanks.
Re: read uml model program [message #1744840 is a reply to message #1744831] Fri, 30 September 2016 17:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5843
Registered: July 2009
Senior Member
Hi

2011 is a long time ago. You are using UML 2.3 tooling and complaining that UMl 2.5 tooling fails to read it. I suggest you get a proper version of RSA.

Regards

Ed Willink
Re: read uml model program [message #1744967 is a reply to message #1744742] Mon, 03 October 2016 14:28 Go to previous message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1167
Registered: July 2009
Location: Canada
Senior Member

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
Previous Topic:Dangling references when creating profile
Next Topic:Read sequence diagram by its Xmi
Goto Forum:
  


Current Time: Thu Apr 26 08:00:38 GMT 2018

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

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