Home » Modeling » EMF » How to retrieve EPackage from a file extension
How to retrieve EPackage from a file extension [message #527394] |
Thu, 15 April 2010 07:05 |
Tristan Faure Messages: 460 Registered: July 2009 |
Senior Member |
|
|
Hi,
currently we take epackage from an eclass for example :
myEobject.eClass().getEPackage()
we have a meta model including UML meta model. Some relations in the
meta model reference UML Element.
In a generic way with CustomPackage we can access to UML metamodel using
the ConverterUtil.
In a generic way if we do myEobject.eClass().getEPackage() on an UML
element we will have UML Epackage (normal :) )
What we want it's to access to all the Package from a file extension for
example
getAllPackage("custom") : returns {CustomPackage,UMLPackage}
getAllPackage("uml") : returns {UMLPackage}
Is it possible to do this ?
Tristan
|
|
| |
Re: How to retrieve EPackage from a file extension [message #527854 is a reply to message #527457] |
Fri, 16 April 2010 16:31 |
Tristan Faure Messages: 460 Registered: July 2009 |
Senior Member |
|
|
Thank you for your answer. My comment bellow
Le 15/04/2010 12:47, Ed Merks a écrit :
> Tristan,
>
> Comments below.
>
>
> Tristan FAURE wrote:
>> Hi,
>> currently we take epackage from an eclass for example :
>> myEobject.eClass().getEPackage()
>>
>> we have a meta model including UML meta model. Some relations in the
>> meta model reference UML Element.
>>
>> In a generic way with CustomPackage we can access to UML metamodel
>> using the ConverterUtil.
>> In a generic way if we do myEobject.eClass().getEPackage() on an UML
>> element we will have UML Epackage (normal :) )
>>
>> What we want it's to access to all the Package from a file extension
>> for example
>> getAllPackage("custom") : returns {CustomPackage,UMLPackage}
>> getAllPackage("uml") : returns {UMLPackage}
>>
>> Is it possible to do this ?
> It's impossible to know in advance what types of objects may occur in
> a resource. Moreover, with support for content types, even just given
> the extension, there may well not be an extension based resource
> factory registered. Instead there might be many content types
> registered for the same extension. My suspicion is that your question
> might be more about how you should be using content types. They're
> generally supported by scanning the resource, usually just the root
> element, to determine its namespace and hence which EPackage's
> instances it contains.
Okay but in my case my root element could be a UML model and i can't
access to my CustomPackage isn't it ?
>>
>> Tristan
I will look for an other solution to my problem
Tristan
|
|
|
Re: How to retrieve EPackage from a file extension [message #527857 is a reply to message #527854] |
Fri, 16 April 2010 16:50 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Tristan,
Comments below.
Tristan FAURE wrote:
> Thank you for your answer. My comment bellow
>
> Le 15/04/2010 12:47, Ed Merks a écrit :
>> Tristan,
>>
>> Comments below.
>>
>>
>> Tristan FAURE wrote:
>>> Hi,
>>> currently we take epackage from an eclass for example :
>>> myEobject.eClass().getEPackage()
>>>
>>> we have a meta model including UML meta model. Some relations in the
>>> meta model reference UML Element.
>>>
>>> In a generic way with CustomPackage we can access to UML metamodel
>>> using the ConverterUtil.
>>> In a generic way if we do myEobject.eClass().getEPackage() on an UML
>>> element we will have UML Epackage (normal :) )
>>>
>>> What we want it's to access to all the Package from a file extension
>>> for example
>>> getAllPackage("custom") : returns {CustomPackage,UMLPackage}
>>> getAllPackage("uml") : returns {UMLPackage}
>>>
>>> Is it possible to do this ?
>> It's impossible to know in advance what types of objects may occur in
>> a resource. Moreover, with support for content types, even just
>> given the extension, there may well not be an extension based
>> resource factory registered. Instead there might be many content
>> types registered for the same extension. My suspicion is that your
>> question might be more about how you should be using content types.
>> They're generally supported by scanning the resource, usually just
>> the root element, to determine its namespace and hence which
>> EPackage's instances it contains.
> Okay but in my case my root element could be a UML model and i can't
> access to my CustomPackage isn't it ?
Sorry, I can't follow what you're asking.
>>>
>>> Tristan
> I will look for an other solution to my problem
I wonder what the problem is? Why do you need to know which model's
instance is in a given file?
>
> Tristan
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to retrieve EPackage from a file extension [message #528053 is a reply to message #527857] |
Mon, 19 April 2010 06:41 |
Tristan Faure Messages: 460 Registered: July 2009 |
Senior Member |
|
|
Okay i think i will explain a little bit more my problem :)
we are developing an application generating acceleo code (for
documentation generation), my acceleo problem is explained here :
http://www.eclipse.org/forums/index.php?t=msg&th=166504& amp;start=0&
We don't want to force user to list the metamodels he uses. The user
fills an input model and we want to use the extension to deduce at least
the metamodels linked to the "metamodel of the extension".
(if custom extension, we want to fill custom and uml metamodels).
If it is not possible we will explain to users that they have to fill
the metamodel URIs.
Regards
Tristan FAURE
Le 16/04/2010 18:50, Ed Merks a écrit :
> Tristan,
>
> Comments below.
>
> Tristan FAURE wrote:
>> Thank you for your answer. My comment bellow
>>
>> Le 15/04/2010 12:47, Ed Merks a écrit :
>>> Tristan,
>>>
>>> Comments below.
>>>
>>>
>>> Tristan FAURE wrote:
>>>> Hi,
>>>> currently we take epackage from an eclass for example :
>>>> myEobject.eClass().getEPackage()
>>>>
>>>> we have a meta model including UML meta model. Some relations in
>>>> the meta model reference UML Element.
>>>>
>>>> In a generic way with CustomPackage we can access to UML metamodel
>>>> using the ConverterUtil.
>>>> In a generic way if we do myEobject.eClass().getEPackage() on an
>>>> UML element we will have UML Epackage (normal :) )
>>>>
>>>> What we want it's to access to all the Package from a file
>>>> extension for example
>>>> getAllPackage("custom") : returns {CustomPackage,UMLPackage}
>>>> getAllPackage("uml") : returns {UMLPackage}
>>>>
>>>> Is it possible to do this ?
>>> It's impossible to know in advance what types of objects may occur
>>> in a resource. Moreover, with support for content types, even just
>>> given the extension, there may well not be an extension based
>>> resource factory registered. Instead there might be many content
>>> types registered for the same extension. My suspicion is that your
>>> question might be more about how you should be using content types.
>>> They're generally supported by scanning the resource, usually just
>>> the root element, to determine its namespace and hence which
>>> EPackage's instances it contains.
>> Okay but in my case my root element could be a UML model and i can't
>> access to my CustomPackage isn't it ?
> Sorry, I can't follow what you're asking.
>>>>
>>>> Tristan
>> I will look for an other solution to my problem
> I wonder what the problem is? Why do you need to know which model's
> instance is in a given file?
>>
>> Tristan
|
|
|
Re: How to retrieve EPackage from a file extension [message #528094 is a reply to message #528053] |
Mon, 19 April 2010 10:44 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Tristan,
Comments below.
Tristan FAURE wrote:
> Okay i think i will explain a little bit more my problem :)
> we are developing an application generating acceleo code (for
> documentation generation), my acceleo problem is explained here :
> http://www.eclipse.org/forums/index.php?t=msg&th=166504& amp;start=0&
>
> We don't want to force user to list the metamodels he uses. The user
> fills an input model and we want to use the extension to deduce at
> least the metamodels linked to the "metamodel of the extension".
> (if custom extension, we want to fill custom and uml metamodels).
It seems to me each instance could refer to a different set of models.
For example, EModelElement or Ecore, which UML extends, so this applies
to UML as well, has containment and cross references of type EObject.
This means any particular *.ecore resource could refer to or contain any
other arbitrary model. So the answer to "what models are in any
particular *.ecore" is "instances of EcorePackage's EClass along with
instances from any model you might imagine".
>
> If it is not possible we will explain to users that they have to fill
> the metamodel URIs.
If you scan the actual instance, you'd be able to determine all the
models. I.e., Resource.getAllContents() and ask for the eClass of each
EObject tells you all the contained models. You'd also have to visit
the eCrossReferences of each EObject if you want to know the model's
instances that are references, and you'd have to walk the whole closure
if you want to know what types of instances are all reachable.
>
> Regards
> Tristan FAURE
>
>
> Le 16/04/2010 18:50, Ed Merks a écrit :
>> Tristan,
>>
>> Comments below.
>>
>> Tristan FAURE wrote:
>>> Thank you for your answer. My comment bellow
>>>
>>> Le 15/04/2010 12:47, Ed Merks a écrit :
>>>> Tristan,
>>>>
>>>> Comments below.
>>>>
>>>>
>>>> Tristan FAURE wrote:
>>>>> Hi,
>>>>> currently we take epackage from an eclass for example :
>>>>> myEobject.eClass().getEPackage()
>>>>>
>>>>> we have a meta model including UML meta model. Some relations in
>>>>> the meta model reference UML Element.
>>>>>
>>>>> In a generic way with CustomPackage we can access to UML metamodel
>>>>> using the ConverterUtil.
>>>>> In a generic way if we do myEobject.eClass().getEPackage() on an
>>>>> UML element we will have UML Epackage (normal :) )
>>>>>
>>>>> What we want it's to access to all the Package from a file
>>>>> extension for example
>>>>> getAllPackage("custom") : returns {CustomPackage,UMLPackage}
>>>>> getAllPackage("uml") : returns {UMLPackage}
>>>>>
>>>>> Is it possible to do this ?
>>>> It's impossible to know in advance what types of objects may occur
>>>> in a resource. Moreover, with support for content types, even just
>>>> given the extension, there may well not be an extension based
>>>> resource factory registered. Instead there might be many content
>>>> types registered for the same extension. My suspicion is that your
>>>> question might be more about how you should be using content
>>>> types. They're generally supported by scanning the resource,
>>>> usually just the root element, to determine its namespace and hence
>>>> which EPackage's instances it contains.
>>> Okay but in my case my root element could be a UML model and i can't
>>> access to my CustomPackage isn't it ?
>> Sorry, I can't follow what you're asking.
>>>>>
>>>>> Tristan
>>> I will look for an other solution to my problem
>> I wonder what the problem is? Why do you need to know which model's
>> instance is in a given file?
>>>
>>> Tristan
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to retrieve EPackage from a file extension [message #528124 is a reply to message #528094] |
Mon, 19 April 2010 12:44 |
Tristan Faure Messages: 460 Registered: July 2009 |
Senior Member |
|
|
Thank you for your answers, some comments bellow.
Tristan
Le 19/04/2010 12:44, Ed Merks a écrit :
> Tristan,
>
> Comments below.
>
> Tristan FAURE wrote:
>> Okay i think i will explain a little bit more my problem :)
>> we are developing an application generating acceleo code (for
>> documentation generation), my acceleo problem is explained here :
>> http://www.eclipse.org/forums/index.php?t=msg&th=166504& amp;start=0&
>>
>> We don't want to force user to list the metamodels he uses. The user
>> fills an input model and we want to use the extension to deduce at
>> least the metamodels linked to the "metamodel of the extension".
>> (if custom extension, we want to fill custom and uml metamodels).
> It seems to me each instance could refer to a different set of
> models. For example, EModelElement or Ecore, which UML extends, so
> this applies to UML as well, has containment and cross references of
> type EObject. This means any particular *.ecore resource could refer
> to or contain any other arbitrary model. So the answer to "what
> models are in any particular *.ecore" is "instances of EcorePackage's
> EClass along with instances from any model you might imagine".
yes of course, but what i imagined is the same view of genmodel import
tree.
When we import an ecore file, EMF provides a list of all the imported
packages. But i think we will browse all the crossreferences and fill
dynamically the list of EPackages. It is simpler.
>>
>> If it is not possible we will explain to users that they have to fill
>> the metamodel URIs.
> If you scan the actual instance, you'd be able to determine all the
> models. I.e., Resource.getAllContents() and ask for the eClass of
> each EObject tells you all the contained models. You'd also have to
> visit the eCrossReferences of each EObject if you want to know the
> model's instances that are references, and you'd have to walk the
> whole closure if you want to know what types of instances are all
> reachable.
>>
>> Regards
>> Tristan FAURE
>>
>>
>> Le 16/04/2010 18:50, Ed Merks a écrit :
>>> Tristan,
>>>
>>> Comments below.
>>>
>>> Tristan FAURE wrote:
>>>> Thank you for your answer. My comment bellow
>>>>
>>>> Le 15/04/2010 12:47, Ed Merks a écrit :
>>>>> Tristan,
>>>>>
>>>>> Comments below.
>>>>>
>>>>>
>>>>> Tristan FAURE wrote:
>>>>>> Hi,
>>>>>> currently we take epackage from an eclass for example :
>>>>>> myEobject.eClass().getEPackage()
>>>>>>
>>>>>> we have a meta model including UML meta model. Some relations in
>>>>>> the meta model reference UML Element.
>>>>>>
>>>>>> In a generic way with CustomPackage we can access to UML
>>>>>> metamodel using the ConverterUtil.
>>>>>> In a generic way if we do myEobject.eClass().getEPackage() on an
>>>>>> UML element we will have UML Epackage (normal :) )
>>>>>>
>>>>>> What we want it's to access to all the Package from a file
>>>>>> extension for example
>>>>>> getAllPackage("custom") : returns {CustomPackage,UMLPackage}
>>>>>> getAllPackage("uml") : returns {UMLPackage}
>>>>>>
>>>>>> Is it possible to do this ?
>>>>> It's impossible to know in advance what types of objects may occur
>>>>> in a resource. Moreover, with support for content types, even
>>>>> just given the extension, there may well not be an extension based
>>>>> resource factory registered. Instead there might be many content
>>>>> types registered for the same extension. My suspicion is that
>>>>> your question might be more about how you should be using content
>>>>> types. They're generally supported by scanning the resource,
>>>>> usually just the root element, to determine its namespace and
>>>>> hence which EPackage's instances it contains.
>>>> Okay but in my case my root element could be a UML model and i
>>>> can't access to my CustomPackage isn't it ?
>>> Sorry, I can't follow what you're asking.
>>>>>>
>>>>>> Tristan
>>>> I will look for an other solution to my problem
>>> I wonder what the problem is? Why do you need to know which model's
>>> instance is in a given file?
>>>>
>>>> Tristan
|
|
|
Goto Forum:
Current Time: Fri Apr 26 23:56:20 GMT 2024
Powered by FUDForum. Page generated in 0.03637 seconds
|