Home » Archived » M2M (model-to-model transformation) » [ATL]How to do the MT whose source models are Java object instances in memory?
[ATL]How to do the MT whose source models are Java object instances in memory? [message #46361] |
Thu, 14 June 2007 02:57 |
stephen Yu Messages: 35 Registered: July 2009 |
Member |
|
|
Hi,
I read some examples about ATL for MT, they are all file based. Take the
Families2Person sample as an example, the source model is xxx.ecore file
and the out put (target source) is also a file named xxx.ecore.
In my case, my program get some java objects in memory, for an instance, I
get an arrayList of Family objects, then how to transform them to Person
objects both in memory and in files?
One solution I'm thinking about is to transform the java objects in memory
to a ecore file then do the transformation. But, I want to try to avoid
those O/I operationa to improve the performance, so any other better
solution?
Thanks a lot
Stephen Yu
|
|
| |
Re: [ATL]How to do the MT whose source models are Java object instances in memor [message #46453 is a reply to message #46423] |
Thu, 14 June 2007 11:55 |
Dennis Wagelaar Messages: 147 Registered: July 2009 |
Senior Member |
|
|
William Piers schreef:
> Hello,
>
> Currently, ATL doesn't support that kind of transformation, and is only
> based on files. Indeed, you have to persist mermory objects into a file
> to allow any ATL transformation.
>
> Regards,
>
> William Piers
>
>
True, there is no "official" support for that kind of thing. There is
public API available however. Since Stephen probably wants to run ATL
from a Java program, you may try loading your EMF model directly through
the ASMEMFModel class. ASMEMFModel provides the following method:
public static ASMEMFModel loadASMEMFModel(String name, ASMEMFModel
metamodel, Resource extent, ModelLoader ml)
When invoking this method, the ModelLoader argument may be null, since
no loading from file is required. Unfortunately, this approach is
EMF-specific.
Another note: you can't just pass a bunch of EMF objects to ATL. It has
to be a valid EMF model, residing inside an EMF Resource.
Regards,
Dennis
|
|
| |
Re: [ATL]How to do the MT whose source models are Java object instances in memor [message #46641 is a reply to message #46619] |
Fri, 15 June 2007 07:41 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hello,
ATL already has several drivers (i.e., for EMF, for MDR) to handle
models. This means that ATL can transform models stored in EMF or MDR,
for instance.
If you want to directly transform your Java objects that do not use EMF
or MDR, then you can write a driver for them.
See the following page for more information:
http://wiki.eclipse.org/index.php/ATL_Model_Handlers
Regards,
Frédéric Jouault
Stephen Yu wrote:
> Hi,
>
> Since ATL APIs do not support in-memory transformation for now, I need
> to transform the in-memory java objects to a file first, that is to say,
> persist the java objects in files.
> As I know, JAXB can be used to persist java objects which is called
> marshall. However, the output of JAXB is a XML file which is different
> from the xxx.ecore file for ATL input, although the xxx.xml and
> xxx.ecore represent the same objects.
> That is to say, I need to transform the xxx.xml to xxx.ecore by writing
> another ATL file. It seams so complicated :(.
>
> Any other good idea?
>
> Thanks a lot.
>
> Stephen
>
>
>
>
>
|
|
|
Re: [ATL]How to do the MT whose source models are Java object instances in memor [message #46723 is a reply to message #46641] |
Fri, 15 June 2007 09:27 |
stephen Yu Messages: 35 Registered: July 2009 |
Member |
|
|
Hi,
I see your point, but to write a customized Model handler/driver is to
difficult for me now. I maybe will implement customized Model
handler/driver in the future:). In the very begining, I just need a simple
solution to transform in-memory java objects to the target model which I
need.
Just as I mentioned before, in order to do the MT, I need to transform
in-memory java object to xxx.ecore first.
For now, I finished transforming java ojbect to XML file through JAXB, the
next step is transform xxx.XML to xxx.ecore.
Has anybody implemented MT for XML-->EMF(ecore) ? I saw lots of samples in
[http://www.eclipse.org/m2m/atl/atlTransformations/], but except this one.
Thanks a lots.
Stephen
Frédéric Jouault wrote:
> Hello,
> ATL already has several drivers (i.e., for EMF, for MDR) to handle
> models. This means that ATL can transform models stored in EMF or MDR,
> for instance.
> If you want to directly transform your Java objects that do not use EMF
> or MDR, then you can write a driver for them.
> See the following page for more information:
> http://wiki.eclipse.org/index.php/ATL_Model_Handlers
> Regards,
> Frédéric Jouault
> Stephen Yu wrote:
>> Hi,
>>
>> Since ATL APIs do not support in-memory transformation for now, I need
>> to transform the in-memory java objects to a file first, that is to say,
>> persist the java objects in files.
>> As I know, JAXB can be used to persist java objects which is called
>> marshall. However, the output of JAXB is a XML file which is different
>> from the xxx.ecore file for ATL input, although the xxx.xml and
>> xxx.ecore represent the same objects.
>> That is to say, I need to transform the xxx.xml to xxx.ecore by writing
>> another ATL file. It seams so complicated :(.
>>
>> Any other good idea?
>>
>> Thanks a lot.
>>
>> Stephen
>>
>>
>>
>>
>>
|
|
|
Re: [ATL]How to do the MT whose source models are Java object instances in memor [message #46747 is a reply to message #46723] |
Fri, 15 June 2007 09:36 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hello,
There are many XML2<some metamodel> examples in the transformation library.
Regards,
Frédéric Jouault
Stephen Yu wrote:
> Hi,
>
> I see your point, but to write a customized Model handler/driver is to
> difficult for me now. I maybe will implement customized Model
> handler/driver in the future:). In the very begining, I just need a
> simple solution to transform in-memory java objects to the target model
> which I need.
>
> Just as I mentioned before, in order to do the MT, I need to transform
> in-memory java object to xxx.ecore first.
> For now, I finished transforming java ojbect to XML file through JAXB,
> the next step is transform xxx.XML to xxx.ecore.
>
> Has anybody implemented MT for XML-->EMF(ecore) ? I saw lots of samples
> in [http://www.eclipse.org/m2m/atl/atlTransformations/], but except this
> one.
>
> Thanks a lots.
>
> Stephen
>
>
> Frédéric Jouault wrote:
>
>> Hello,
>
>> ATL already has several drivers (i.e., for EMF, for MDR) to handle
>> models. This means that ATL can transform models stored in EMF or MDR,
>> for instance.
>
>> If you want to directly transform your Java objects that do not use
>> EMF or MDR, then you can write a driver for them.
>
>> See the following page for more information:
>> http://wiki.eclipse.org/index.php/ATL_Model_Handlers
>
>
>> Regards,
>
>> Frédéric Jouault
>
>
>> Stephen Yu wrote:
>>> Hi,
>>>
>>> Since ATL APIs do not support in-memory transformation for now, I
>>> need to transform the in-memory java objects to a file first, that is
>>> to say, persist the java objects in files.
>>> As I know, JAXB can be used to persist java objects which is called
>>> marshall. However, the output of JAXB is a XML file which is
>>> different from the xxx.ecore file for ATL input, although the xxx.xml
>>> and xxx.ecore represent the same objects.
>>> That is to say, I need to transform the xxx.xml to xxx.ecore by
>>> writing another ATL file. It seams so complicated :(.
>>>
>>> Any other good idea?
>>>
>>> Thanks a lot.
>>>
>>> Stephen
>>>
>>>
>>>
>>>
>>>
>
>
|
|
|
Re: [ATL]How to do the MT whose source models are Java object instances in memor [message #46774 is a reply to message #46747] |
Fri, 15 June 2007 10:18 |
stephen Yu Messages: 35 Registered: July 2009 |
Member |
|
|
Hi,
Yes, there are many XML2<some metamodel> examples, but just can not find
XML2EMF(ecore). :(
Trying to write it by myself.......
Stephen.
Frédéric Jouault wrote:
> Hello,
> There are many XML2<some metamodel> examples in the transformation library.
> Regards,
> Frédéric Jouault
> Stephen Yu wrote:
>> Hi,
>>
>> I see your point, but to write a customized Model handler/driver is to
>> difficult for me now. I maybe will implement customized Model
>> handler/driver in the future:). In the very begining, I just need a
>> simple solution to transform in-memory java objects to the target model
>> which I need.
>>
>> Just as I mentioned before, in order to do the MT, I need to transform
>> in-memory java object to xxx.ecore first.
>> For now, I finished transforming java ojbect to XML file through JAXB,
>> the next step is transform xxx.XML to xxx.ecore.
>>
>> Has anybody implemented MT for XML-->EMF(ecore) ? I saw lots of samples
>> in [http://www.eclipse.org/m2m/atl/atlTransformations/], but except this
>> one.
>>
>> Thanks a lots.
>>
>> Stephen
>>
>>
>> Frédéric Jouault wrote:
>>
>>> Hello,
>>
>>> ATL already has several drivers (i.e., for EMF, for MDR) to handle
>>> models. This means that ATL can transform models stored in EMF or MDR,
>>> for instance.
>>
>>> If you want to directly transform your Java objects that do not use
>>> EMF or MDR, then you can write a driver for them.
>>
>>> See the following page for more information:
>>> http://wiki.eclipse.org/index.php/ATL_Model_Handlers
>>
>>
>>> Regards,
>>
>>> Frédéric Jouault
>>
>>
>>> Stephen Yu wrote:
>>>> Hi,
>>>>
>>>> Since ATL APIs do not support in-memory transformation for now, I
>>>> need to transform the in-memory java objects to a file first, that is
>>>> to say, persist the java objects in files.
>>>> As I know, JAXB can be used to persist java objects which is called
>>>> marshall. However, the output of JAXB is a XML file which is
>>>> different from the xxx.ecore file for ATL input, although the xxx.xml
>>>> and xxx.ecore represent the same objects.
>>>> That is to say, I need to transform the xxx.xml to xxx.ecore by
>>>> writing another ATL file. It seams so complicated :(.
>>>>
>>>> Any other good idea?
>>>>
>>>> Thanks a lot.
>>>>
>>>> Stephen
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
|
|
| |
Re: [ATL]How to do the MT whose source models are Java object instances in memor [message #47102 is a reply to message #46804] |
Mon, 18 June 2007 02:00 |
stephen Yu Messages: 35 Registered: July 2009 |
Member |
|
|
Hi Frédéric,
Sorry, I did not explain what I need clearly.
Thanks for your patience in helping me. :)
My task is to transform Java object in memory to ModelA which conforms to
MetaModelA.
Since ATL MT operation is file based, so I firstly transform Java objects
in Momery to XML file (we call it persistence, I finished it through
JAXB).[step 1]
I also finished the ATL file for transformation from xxx.ecore to
ModelA.[step 3] The input file xxx.ecore represents a list of Java objects
which confirms to the metamodel I created for the java class, just as the
familis2persons sample has done.
Now the problem is how to transform the XML file (output for the first
step) to the xxx.ecore file for the input of third step?
In the transfromation, the input is a XML file which represents a list of
Java objects. The metamodel is XML.ecore.
The output of this transformation is a xxx.ecore file which also
represents a list of Java objects. The metamodel is EMF.
To make it more clear, here is my case:
source model is: ovouMonitors.xml ,metamodel is xml.ecore
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ovouMonitor xmlns:ns2="http://xxx.com/0.1/models/w-models">
<nodeInfo>
<hostName>www.xxx.com</hostName>
<ipAddress>10.42.33.131</ipAddress>
<machineType>unix</machineType>
<networkType>HTTP</networkType>
<loginName>sfyu</loginName>
<password>123</password>
</nodeInfo>
<serviceAttributeName>AAAAA</serviceAttributeName>
<groupName>ALi88</groupName>
</ovouMonitor>
Target model is:ovouMonitor.ecore, metamodel is EMF
<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns="MonitorModel">
<OVOUMonitor serviceAttributeName="AAAAA" groupName="ALi88">
<nodeInfo hostName="www.xxx.com" ipAddress="10.42.33.131"
machineType="unix" networkType="HTTP" loginName="sfyu" password="123"/>
</OVOUMonitor>
</xmi:XMI>
Frédéric Jouault wrote:
> Hi,
> > Yes, there are many XML2<some metamodel> examples, but just can not find
> > XML2EMF(ecore). :(
> I am confused here. What does "XML2EMF(ecore)" mean? What is your target
> metamodel?
> Regards,
> Frédéric Jouault
|
|
|
Re: [ATL]How to do the MT whose source models are Java object instances in memor [message #47132 is a reply to message #47102] |
Mon, 18 June 2007 06:37 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hello,
I am still confused ;-).
You first state that the target metamodel is MetaModelA, then you state
that the metamodel is EMF (I know EMF the model handler, but I do not
know any metamodel by that name), then your example shows that the
target metamodel is MonitorModel.
If the later is the actual metamodel, then you would have to write a
transformation XML2MonitorModel, and there are many examples of such
transformations in the ATL transformation library.
Note that most of these transformations can be executed using EMF or
MDR. If you use EMF, the transformation will use the EMF XMI 2.0 format
(for which we often use the .ecore extension, even though it may
correspond to a terminal model conforming to a metamodel != Ecore).
Regards,
Frédéric Jouault
Stephen Yu wrote:
> Hi Frédéric,
>
> Sorry, I did not explain what I need clearly.
> Thanks for your patience in helping me. :)
>
> My task is to transform Java object in memory to ModelA which conforms
> to MetaModelA.
> Since ATL MT operation is file based, so I firstly transform Java
> objects in Momery to XML file (we call it persistence, I finished it
> through JAXB).[step 1]
>
> I also finished the ATL file for transformation from xxx.ecore to
> ModelA.[step 3] The input file xxx.ecore represents a list of Java
> objects which confirms to the metamodel I created for the java class,
> just as the familis2persons sample has done.
> Now the problem is how to transform the XML file (output for the first
> step) to the xxx.ecore file for the input of third step?
> In the transfromation, the input is a XML file which represents a list
> of Java objects. The metamodel is XML.ecore.
> The output of this transformation is a xxx.ecore file which also
> represents a list of Java objects. The metamodel is EMF.
>
> To make it more clear, here is my case:
> source model is: ovouMonitors.xml ,metamodel is xml.ecore
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <ovouMonitor xmlns:ns2="http://xxx.com/0.1/models/w-models">
> <nodeInfo>
> <hostName>www.xxx.com</hostName>
> <ipAddress>10.42.33.131</ipAddress>
> <machineType>unix</machineType>
> <networkType>HTTP</networkType>
> <loginName>sfyu</loginName>
> <password>123</password>
> </nodeInfo>
> <serviceAttributeName>AAAAA</serviceAttributeName>
> <groupName>ALi88</groupName>
> </ovouMonitor>
>
>
> Target model is:ovouMonitor.ecore, metamodel is EMF
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns="MonitorModel">
> <OVOUMonitor serviceAttributeName="AAAAA" groupName="ALi88">
> <nodeInfo hostName="www.xxx.com" ipAddress="10.42.33.131"
> machineType="unix" networkType="HTTP" loginName="sfyu" password="123"/>
> </OVOUMonitor>
> </xmi:XMI>
>
>
>
>
> Frédéric Jouault wrote:
>
>> Hi,
>
>> > Yes, there are many XML2<some metamodel> examples, but just can not
>> find
>> > XML2EMF(ecore). :(
>
>> I am confused here. What does "XML2EMF(ecore)" mean? What is your
>> target metamodel?
>
>
>> Regards,
>
>> Frédéric Jouault
>
>
|
|
|
Goto Forum:
Current Time: Thu Dec 26 23:58:18 GMT 2024
Powered by FUDForum. Page generated in 0.03727 seconds
|