Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Problems about loading UML file
Problems about loading UML file [message #476837] Wed, 09 January 2008 08:30 Go to next message
Eclipse UserFriend
Originally posted by: heiyuchuanxia.163.com

Hi, everyone, I'm a newbie here. Now I encounter a problem about loading
a uml file. I can load the resource and get the content but I just can't
get the package in this uml file.

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(
UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);

URI fileURI =URI.createFileURI(new
File("model/bpel.uml").getAbsolutePath());
org.eclipse.uml2.uml.Package umlpackage=load(fileURI);

the code of load method:
protected static org.eclipse.uml2.uml.Package load(URI uri) {
org.eclipse.uml2.uml.Package package_ = null;

try {
Resource resource = RESOURCE_SET.getResource(uri, true);

package_ = (org.eclipse.uml2.uml.Package) EcoreUtil
.getObjectByType(resource.getContents(),
UMLPackage.Literals.PACKAGE);
} catch (WrappedException we) {
err(we.getMessage());
System.exit(1);
}

return package_;
}

after these code, the umlpackage is null and the return Package of the
load method is null.

I debuged these code, and it's really call the UMLResourceFactory.

It seems there is some wrong in the getObjectByType method, since the
content object is
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@16877f8 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@19c7c21 (name: Package)
(instanceClassName: null) (abstract: false, interface: false)) but the
type is org.eclipse.emf.ecore.impl.EClassImpl@170ec24 (name: Package)
(instanceClassName: null) (abstract: false, interface: false) , so the
type.isInstance(object) is false.

How can I get the package of the uml model.

Thanks very much for caring about my question.
Stefanie
Re: Problems about loading UML file [message #476838 is a reply to message #476837] Wed, 09 January 2008 08:38 Go to previous message
Eclipse UserFriend
Originally posted by: heiyuchuanxia.163.com

Ha, I think I just solved the problem reference a same problem discuss
in the newsgroup.

I miss the registerPackage method.

RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);

Now, it works fine.

Stefanie

stefanie zhao 写道:
> Hi, everyone, I'm a newbie here. Now I encounter a problem about loading
> a uml file. I can load the resource and get the content but I just can't
> get the package in this uml file.
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(
> UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
>
> URI fileURI =URI.createFileURI(new
> File("model/bpel.uml").getAbsolutePath());
> org.eclipse.uml2.uml.Package umlpackage=load(fileURI);
>
> the code of load method:
> protected static org.eclipse.uml2.uml.Package load(URI uri) {
> org.eclipse.uml2.uml.Package package_ = null;
>
> try {
> Resource resource = RESOURCE_SET.getResource(uri, true);
>
> package_ = (org.eclipse.uml2.uml.Package) EcoreUtil
> .getObjectByType(resource.getContents(),
> UMLPackage.Literals.PACKAGE);
> } catch (WrappedException we) {
> err(we.getMessage());
> System.exit(1);
> }
>
> return package_;
> }
>
> after these code, the umlpackage is null and the return Package of the
> load method is null.
>
> I debuged these code, and it's really call the UMLResourceFactory.
>
> It seems there is some wrong in the getObjectByType method, since the
> content object is
> org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@16877f8 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@19c7c21 (name: Package)
> (instanceClassName: null) (abstract: false, interface: false)) but the
> type is org.eclipse.emf.ecore.impl.EClassImpl@170ec24 (name: Package)
> (instanceClassName: null) (abstract: false, interface: false) , so the
> type.isInstance(object) is false.
>
> How can I get the package of the uml model.
>
> Thanks very much for caring about my question.
> Stefanie
Re: Problems about loading UML file [message #625862 is a reply to message #476837] Wed, 09 January 2008 08:38 Go to previous message
Eclipse UserFriend
Originally posted by: heiyuchuanxia.163.com

Ha, I think I just solved the problem reference a same problem discuss
in the newsgroup.

I miss the registerPackage method.

RESOURCE_SET.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);

Now, it works fine.

Stefanie

stefanie zhao 写道:
> Hi, everyone, I'm a newbie here. Now I encounter a problem about loading
> a uml file. I can load the resource and get the content but I just can't
> get the package in this uml file.
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(
> UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
>
> URI fileURI =URI.createFileURI(new
> File("model/bpel.uml").getAbsolutePath());
> org.eclipse.uml2.uml.Package umlpackage=load(fileURI);
>
> the code of load method:
> protected static org.eclipse.uml2.uml.Package load(URI uri) {
> org.eclipse.uml2.uml.Package package_ = null;
>
> try {
> Resource resource = RESOURCE_SET.getResource(uri, true);
>
> package_ = (org.eclipse.uml2.uml.Package) EcoreUtil
> .getObjectByType(resource.getContents(),
> UMLPackage.Literals.PACKAGE);
> } catch (WrappedException we) {
> err(we.getMessage());
> System.exit(1);
> }
>
> return package_;
> }
>
> after these code, the umlpackage is null and the return Package of the
> load method is null.
>
> I debuged these code, and it's really call the UMLResourceFactory.
>
> It seems there is some wrong in the getObjectByType method, since the
> content object is
> org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@16877f8 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@19c7c21 (name: Package)
> (instanceClassName: null) (abstract: false, interface: false)) but the
> type is org.eclipse.emf.ecore.impl.EClassImpl@170ec24 (name: Package)
> (instanceClassName: null) (abstract: false, interface: false) , so the
> type.isInstance(object) is false.
>
> How can I get the package of the uml model.
>
> Thanks very much for caring about my question.
> Stefanie
Previous Topic:Problems about loading UML file
Next Topic:[Announce] MDT UML2 2.2.0 I200801091300 is available
Goto Forum:
  


Current Time: Tue Aug 09 11:50:27 GMT 2022

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

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

Back to the top