Home » Modeling » UML2 » Unable to read profile or model file programatically
| |
Re: Unable to read profile or model file programatically [message #471345 is a reply to message #471184] |
Fri, 02 March 2007 14:21 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Paul,
No, this code isn't correct; what you need to do, assuming you're running
stand-alone, is ensure the package, extension, and pathmaps are registered.
This source for the profiles article
( http://download.eclipse.org/modeling/mdt/uml2/downloads/arti cles/uml2.articles_200607181325.zip)
shows how to do this; alternatively, you could follow the advice in the FAQ
at
http://wiki.eclipse.org/index.php/MDT-UML2-FAQ#What.27s_requ ired_to_load_a_UML_.28.uml.29_resource_from_a_standalone_app lication.3F.
Kenn
"Paul Gribben" <paul.gribben@gmail.com> wrote in message
news:eea9d951de0b1834b2f35a0fe56db4ea$1@www.eclipse.org...
> Having looked through the source code for the UML2 plugin, I've managed to
> solve this problem as follows (although I'm not convinced it's the correct
> approach). The resourceSet object must be initialised in the following
> manner:
>
> EPackage.Registry ePackageRegistry = new
> EPackageRegistryImpl(EPackage.Registry.INSTANCE);
> ePackageRegistry.put(UML22UMLResource.UML2_METAMODEL_NS_URI,
> UMLPackage.eINSTANCE);
> ePackageRegistry.put("platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore ",
> UMLPackage.eINSTANCE);
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.setPackageRegistry(ePackageRegistry);
>
>
>
|
|
| | |
Re: Unable to read profile or model file programatically [message #476704 is a reply to message #471345] |
Wed, 05 December 2007 14:41 |
Bert Vanhooff Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Hi,
When I use the technique described in the wiki (see code below) the
profile is always null.
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,UMLResource.Factory.I NSTANCE);
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri =
URI.createURI(" jar:file://Users/bertvh/Temp/eclipse/plugins/org.eclipse.uml 2.uml.resources_2.0.3.v200707131442.jar!/");
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(""));
Resource resource = resourceSet.getResource(URI.createFileURI(fileName),
true);
profile = (Profile) EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.Literals.PROFILE);
When I inspect the loaded resource (and toString() it) I see the
following (AnyTypeImpl !?);
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@5a02ef (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@76b9ea (name: Profile)
(instanceClassName: null) etc...
The profile I try to load had been validated and applies to a model
succesfully. The first lines of the file are:
<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
xmi:id="_PXi8QJK5EdybSc66Lg43Vg" name="SimpleDistribution"
metaclassReference="_8PuhYJK5EdybSc66Lg43Vg">
<eAnnotations xmi:id="_EKkUMJK-EdyRQJafRUw19Q"
source="http://www.eclipse.org/uml2/2.0.0/UML">
etc..
Any ideas on what I'm doing wrong?
Many thanks,
Bert.
Kenn Hussey wrote:
> Paul,
>
> No, this code isn't correct; what you need to do, assuming you're running
> stand-alone, is ensure the package, extension, and pathmaps are registered.
> This source for the profiles article
> ( http://download.eclipse.org/modeling/mdt/uml2/downloads/arti cles/uml2.articles_200607181325.zip)
> shows how to do this; alternatively, you could follow the advice in the FAQ
> at
> http://wiki.eclipse.org/index.php/MDT-UML2-FAQ#What.27s_requ ired_to_load_a_UML_.28.uml.29_resource_from_a_standalone_app lication.3F.
>
> Kenn
>
> "Paul Gribben" <paul.gribben@gmail.com> wrote in message
> news:eea9d951de0b1834b2f35a0fe56db4ea$1@www.eclipse.org...
>> Having looked through the source code for the UML2 plugin, I've managed to
>> solve this problem as follows (although I'm not convinced it's the correct
>> approach). The resourceSet object must be initialised in the following
>> manner:
>>
>> EPackage.Registry ePackageRegistry = new
>> EPackageRegistryImpl(EPackage.Registry.INSTANCE);
>> ePackageRegistry.put(UML22UMLResource.UML2_METAMODEL_NS_URI,
>> UMLPackage.eINSTANCE);
>> ePackageRegistry.put("platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore ",
>> UMLPackage.eINSTANCE);
>>
>> ResourceSet resourceSet = new ResourceSetImpl();
>> resourceSet.setPackageRegistry(ePackageRegistry);
>>
>>
>>
>
>
|
|
|
Re: Unable to read profile or model file programatically [message #476727 is a reply to message #476704] |
Mon, 10 December 2007 16:32 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Bert,
Have a look at the code in the
following..http://www.eclipse.org/modeling/mdt/uml2/docs/gui des/UML2_2.0_Migration_Guide/guide.html
in the section entitled: 'Programmatic Migration'. That should provide all
the details.
If that still doesn't work, please ask again.
Cheers,
- James.
"Bert Vanhooff" <bert.vanhooff@cs.kuleuven.be> wrote in message
news:4756B88A.40208@cs.kuleuven.be...
> Hi,
>
> When I use the technique described in the wiki (see code below) the
> profile is always null.
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,UMLResource.Factory.I NSTANCE);
> Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
> URI uri =
> URI.createURI(" jar:file://Users/bertvh/Temp/eclipse/plugins/org.eclipse.uml 2.uml.resources_2.0.3.v200707131442.jar!/");
> 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(""));
> Resource resource = resourceSet.getResource(URI.createFileURI(fileName),
> true);
> profile = (Profile) EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.PROFILE);
>
> When I inspect the loaded resource (and toString() it) I see the following
> (AnyTypeImpl !?);
>
> org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@5a02ef (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@76b9ea (name: Profile)
> (instanceClassName: null) etc...
>
> The profile I try to load had been validated and applies to a model
> succesfully. The first lines of the file are:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Profile xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xmi:id="_PXi8QJK5EdybSc66Lg43Vg" name="SimpleDistribution"
> metaclassReference="_8PuhYJK5EdybSc66Lg43Vg">
> <eAnnotations xmi:id="_EKkUMJK-EdyRQJafRUw19Q"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> etc..
>
>
> Any ideas on what I'm doing wrong?
>
>
> Many thanks,
> Bert.
>
>
> Kenn Hussey wrote:
>> Paul,
>>
>> No, this code isn't correct; what you need to do, assuming you're running
>> stand-alone, is ensure the package, extension, and pathmaps are
>> registered. This source for the profiles article
>> ( http://download.eclipse.org/modeling/mdt/uml2/downloads/arti cles/uml2.articles_200607181325.zip)
>> shows how to do this; alternatively, you could follow the advice in the
>> FAQ at
>> http://wiki.eclipse.org/index.php/MDT-UML2-FAQ#What.27s_requ ired_to_load_a_UML_.28.uml.29_resource_from_a_standalone_app lication.3F.
>>
>> Kenn
>>
>> "Paul Gribben" <paul.gribben@gmail.com> wrote in message
>> news:eea9d951de0b1834b2f35a0fe56db4ea$1@www.eclipse.org...
>>> Having looked through the source code for the UML2 plugin, I've managed
>>> to solve this problem as follows (although I'm not convinced it's the
>>> correct approach). The resourceSet object must be initialised in the
>>> following manner:
>>>
>>> EPackage.Registry ePackageRegistry = new
>>> EPackageRegistryImpl(EPackage.Registry.INSTANCE);
>>> ePackageRegistry.put(UML22UMLResource.UML2_METAMODEL_NS_URI,
>>> UMLPackage.eINSTANCE);
>>> ePackageRegistry.put("platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore ",
>>> UMLPackage.eINSTANCE);
>>>
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>> resourceSet.setPackageRegistry(ePackageRegistry);
>>>
>>>
>>>
>>
|
|
| |
Re: Unable to read profile or model file programatically [message #594105 is a reply to message #471184] |
Fri, 02 March 2007 14:21 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Paul,
No, this code isn't correct; what you need to do, assuming you're running
stand-alone, is ensure the package, extension, and pathmaps are registered.
This source for the profiles article
( http://download.eclipse.org/modeling/mdt/uml2/downloads/arti cles/uml2.articles_200607181325.zip)
shows how to do this; alternatively, you could follow the advice in the FAQ
at
http://wiki.eclipse.org/index.php/MDT-UML2-FAQ#What.27s_requ ired_to_load_a_UML_.28.uml.29_resource_from_a_standalone_app lication.3F
Kenn
"Paul Gribben" <paul.gribben@gmail.com> wrote in message
news:eea9d951de0b1834b2f35a0fe56db4ea$1@www.eclipse.org...
> Having looked through the source code for the UML2 plugin, I've managed to
> solve this problem as follows (although I'm not convinced it's the correct
> approach). The resourceSet object must be initialised in the following
> manner:
>
> EPackage.Registry ePackageRegistry = new
> EPackageRegistryImpl(EPackage.Registry.INSTANCE);
> ePackageRegistry.put(UML22UMLResource.UML2_METAMODEL_NS_URI,
> UMLPackage.eINSTANCE);
> ePackageRegistry.put("platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore ",
> UMLPackage.eINSTANCE);
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.setPackageRegistry(ePackageRegistry);
>
>
>
|
|
| | |
Re: Unable to read profile or model file programatically [message #625676 is a reply to message #471345] |
Wed, 05 December 2007 14:41 |
Bert Vanhooff Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Hi,
When I use the technique described in the wiki (see code below) the
profile is always null.
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,UMLResource.Factory.I NSTANCE);
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
URI uri =
URI.createURI(" jar:file://Users/bertvh/Temp/eclipse/plugins/org.eclipse.uml 2.uml.resources_2.0.3.v200707131442.jar!/");
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(""));
Resource resource = resourceSet.getResource(URI.createFileURI(fileName),
true);
profile = (Profile) EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.Literals.PROFILE);
When I inspect the loaded resource (and toString() it) I see the
following (AnyTypeImpl !?);
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@5a02ef (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@76b9ea (name: Profile)
(instanceClassName: null) etc...
The profile I try to load had been validated and applies to a model
succesfully. The first lines of the file are:
<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
xmi:id="_PXi8QJK5EdybSc66Lg43Vg" name="SimpleDistribution"
metaclassReference="_8PuhYJK5EdybSc66Lg43Vg">
<eAnnotations xmi:id="_EKkUMJK-EdyRQJafRUw19Q"
source="http://www.eclipse.org/uml2/2.0.0/UML">
etc..
Any ideas on what I'm doing wrong?
Many thanks,
Bert.
Kenn Hussey wrote:
> Paul,
>
> No, this code isn't correct; what you need to do, assuming you're running
> stand-alone, is ensure the package, extension, and pathmaps are registered.
> This source for the profiles article
> ( http://download.eclipse.org/modeling/mdt/uml2/downloads/arti cles/uml2.articles_200607181325.zip)
> shows how to do this; alternatively, you could follow the advice in the FAQ
> at
> http://wiki.eclipse.org/index.php/MDT-UML2-FAQ#What.27s_requ ired_to_load_a_UML_.28.uml.29_resource_from_a_standalone_app lication.3F
>
> Kenn
>
> "Paul Gribben" <paul.gribben@gmail.com> wrote in message
> news:eea9d951de0b1834b2f35a0fe56db4ea$1@www.eclipse.org...
>> Having looked through the source code for the UML2 plugin, I've managed to
>> solve this problem as follows (although I'm not convinced it's the correct
>> approach). The resourceSet object must be initialised in the following
>> manner:
>>
>> EPackage.Registry ePackageRegistry = new
>> EPackageRegistryImpl(EPackage.Registry.INSTANCE);
>> ePackageRegistry.put(UML22UMLResource.UML2_METAMODEL_NS_URI,
>> UMLPackage.eINSTANCE);
>> ePackageRegistry.put("platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore ",
>> UMLPackage.eINSTANCE);
>>
>> ResourceSet resourceSet = new ResourceSetImpl();
>> resourceSet.setPackageRegistry(ePackageRegistry);
>>
>>
>>
>
>
|
|
|
Re: Unable to read profile or model file programatically [message #625700 is a reply to message #476704] |
Mon, 10 December 2007 16:32 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Bert,
Have a look at the code in the
following..http://www.eclipse.org/modeling/mdt/uml2/docs/gui des/UML2_2.0_Migration_Guide/guide.html
in the section entitled: 'Programmatic Migration'. That should provide all
the details.
If that still doesn't work, please ask again.
Cheers,
- James.
"Bert Vanhooff" <bert.vanhooff@cs.kuleuven.be> wrote in message
news:4756B88A.40208@cs.kuleuven.be...
> Hi,
>
> When I use the technique described in the wiki (see code below) the
> profile is always null.
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(UMLResource.FILE_EXTENSION,UMLResource.Factory.I NSTANCE);
> Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
> URI uri =
> URI.createURI(" jar:file://Users/bertvh/Temp/eclipse/plugins/org.eclipse.uml 2.uml.resources_2.0.3.v200707131442.jar!/");
> 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(""));
> Resource resource = resourceSet.getResource(URI.createFileURI(fileName),
> true);
> profile = (Profile) EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.PROFILE);
>
> When I inspect the loaded resource (and toString() it) I see the following
> (AnyTypeImpl !?);
>
> org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@5a02ef (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@76b9ea (name: Profile)
> (instanceClassName: null) etc...
>
> The profile I try to load had been validated and applies to a model
> succesfully. The first lines of the file are:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Profile xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xmi:id="_PXi8QJK5EdybSc66Lg43Vg" name="SimpleDistribution"
> metaclassReference="_8PuhYJK5EdybSc66Lg43Vg">
> <eAnnotations xmi:id="_EKkUMJK-EdyRQJafRUw19Q"
> source="http://www.eclipse.org/uml2/2.0.0/UML">
> etc..
>
>
> Any ideas on what I'm doing wrong?
>
>
> Many thanks,
> Bert.
>
>
> Kenn Hussey wrote:
>> Paul,
>>
>> No, this code isn't correct; what you need to do, assuming you're running
>> stand-alone, is ensure the package, extension, and pathmaps are
>> registered. This source for the profiles article
>> ( http://download.eclipse.org/modeling/mdt/uml2/downloads/arti cles/uml2.articles_200607181325.zip)
>> shows how to do this; alternatively, you could follow the advice in the
>> FAQ at
>> http://wiki.eclipse.org/index.php/MDT-UML2-FAQ#What.27s_requ ired_to_load_a_UML_.28.uml.29_resource_from_a_standalone_app lication.3F
>>
>> Kenn
>>
>> "Paul Gribben" <paul.gribben@gmail.com> wrote in message
>> news:eea9d951de0b1834b2f35a0fe56db4ea$1@www.eclipse.org...
>>> Having looked through the source code for the UML2 plugin, I've managed
>>> to solve this problem as follows (although I'm not convinced it's the
>>> correct approach). The resourceSet object must be initialised in the
>>> following manner:
>>>
>>> EPackage.Registry ePackageRegistry = new
>>> EPackageRegistryImpl(EPackage.Registry.INSTANCE);
>>> ePackageRegistry.put(UML22UMLResource.UML2_METAMODEL_NS_URI,
>>> UMLPackage.eINSTANCE);
>>> ePackageRegistry.put("platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore ",
>>> UMLPackage.eINSTANCE);
>>>
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>> resourceSet.setPackageRegistry(ePackageRegistry);
>>>
>>>
>>>
>>
|
|
|
Goto Forum:
Current Time: Thu Apr 25 16:46:59 GMT 2024
Powered by FUDForum. Page generated in 0.03644 seconds
|