Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Model-to-Model Transformation » Model-To-Model Sibling Child Problem
Model-To-Model Sibling Child Problem [message #1811210] Wed, 28 August 2019 16:46 Go to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Dear All,

I have two metamodels which are a PIM and PSM.



PIM -> index.php/fa/36184/0/


PSM-> index.php/fa/36185/0/

According to my metamodel Design -> IoTSystem , i can transform this easily
. Indirect-> NodeR , i can transform this but is transforms as sibling of IoTSystem not it's chield.
SensorDevice->Saul is also sibling of IoTSystem.

According to my metamodel IoTsystem has chield NodeR , NodeR has chield Saul.


index.php/fa/36186/0/


According to the above figure and my code below, the wrong hierarchy is made. I try to achieve the correct result.


Here is my transformation code;




rule DesignToIoTSystem {
from
pim : PIM!Design
to
iot : ContikiOS!IoTSystem (
Name<- 'DesignIoTSystem'
)
}


rule DirectToNode {
from
pim : PIM!Direct
to
psm : ContikiOS!NodeR(
Name<- 'NodeR'

)
}

rule SensorDeviceToSaul {
from
pim : PIM!SensorDevice
to
psm : ContikiOS!SAUL (
Name<- 'aSaulDevice',
Temperature<-pim.Temperature,
Humidity<-pim.Humidity

)
}


So my question is according to my metamodels how should i mofiy my ATL code to achieve it?

Thanks All.
  • Attachment: PIM.png
    (Size: 14.58KB, Downloaded 358 times)
  • Attachment: PSM.png
    (Size: 21.29KB, Downloaded 368 times)
  • Attachment: result.png
    (Size: 3.13KB, Downloaded 340 times)

[Updated on: Wed, 28 August 2019 17:02]

Report message to a moderator

Re: Model-To-Model Sibling Child Problem [message #1811213 is a reply to message #1811210] Wed, 28 August 2019 17:32 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
No Message Body
Re: Model-To-Model Sibling Child Problem [message #1811214 is a reply to message #1811213] Wed, 28 August 2019 17:35 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

Here is my transformation code;


Well perhaps 10% of it; no overall declarations, no launch, no metamodels, ....

So I can probably only guess at 10% of an answer. If you have a bad container it's probably because you specified a bad container, or more likely no container at all so the ATL default rescue is to use the root as the container.

Regards

Ed Willink
Re: Model-To-Model Sibling Child Problem [message #1811217 is a reply to message #1811214] Wed, 28 August 2019 21:06 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Hi Ed,

I am new to M2M in ATL, I have already done PSM (M2T) in Acceleo. Because of size constraints, I took an excerpt from both metamodels and my ATL code is all of it. There is no %10 etc. So, if I successfully achieve child/sibling problem for those 3 classes I can solve the rest of it. I thought that ATL handles relations and cardinalities according to the metamodel. I also stuck at how to map relations.

Thanks.

[Updated on: Wed, 28 August 2019 21:09]

Report message to a moderator

Re: Model-To-Model Sibling Child Problem [message #1811224 is a reply to message #1811217] Thu, 29 August 2019 05:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

There are many ATL examples, so you can probably just emulate one of those.

If you want me to spend my time looking at your code, you need to provide your code, as a repro project, so that I can see the actual problem which is frequently in the content that 'helpful' users trim as part of a 'simplified' description.

Regards

Ed Willink
Re: Model-To-Model Sibling Child Problem [message #1811225 is a reply to message #1811224] Thu, 29 August 2019 06:22 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Hi Ed,
So, how can i provide my code as repro project to you ?
Re: Model-To-Model Sibling Child Problem [message #1811230 is a reply to message #1811225] Thu, 29 August 2019 08:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

See e.g. https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink
Re: Model-To-Model Sibling Child Problem [message #1811262 is a reply to message #1811230] Thu, 29 August 2019 18:30 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Hi Ed,

-I am really sorry that I could not recognize what you asked at first about "repro" project. Moreover, I wish I had a mentor like you, and have just looked at your academic profile. I am a student who suffers the deadline of my defense thesis. Because this is my first and big MDE project.
-I exported my project and in the attachments, the file named "contikiOS" is my PSMM (metamodel). The file named "PIM" is my PIMM (metamodel). You can freely edit any PIMM (metamodel) relations, cardinalities, and Eclasses, However, PSMM (named contikiOS) shall not be modified.
- PIM.pim is my PIM model and you don't need Sirius files for the model part. I just create a simple model to achieve what i asked above. But if it is required I can send them to you.
- File named " Deneme" has ATL rules. The rules transform each Class as a parent However as I said they have children.

- I send you my project and Run configurations.
-I use OBEO 11.0 version.

The xml output of the wrong (always transforms as parent all Models) is shown below;

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:contikiOS="http://www.eclipse.org/sirius/contikiOS">
  <contikiOS:IoTSystem Name="DesignIoTSystem"/>
  <contikiOS:PlatformR Name="RiotPlatformR"/>
  <contikiOS:Platform Name="ContikiPlatform"/>
  <contikiOS:RaspberryPi Name="RaspberryPI"/>
  <contikiOS:LogMan URL="www.example.com"/>
  <contikiOS:NodeR Name="NodeR"/>
  <contikiOS:Node Name="Node"/>
  <contikiOS:SAUL Temperature="true" Humidity="true" Name="aSaulDevice"/>
</xmi:XMI>


To have correct output i added elements manually the output should be as follows;


<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:contikiOS="http://www.eclipse.org/sirius/contikiOS">
  <contikiOS:IoTSystem Name="DesignIoTSystem">
    <platform/>
    <logman/>
    <platformR>
      <saul Temperature="true" Humidity="true" Name="aSaul"/>
    </platformR>
  </contikiOS:IoTSystem>
</xmi:XMI>


Thanks for your help.

[Updated on: Thu, 29 August 2019 18:33]

Report message to a moderator

Re: Model-To-Model Sibling Child Problem [message #1811294 is a reply to message #1811262] Fri, 30 August 2019 07:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

Your model has, for instance, a IoTSystem::platformR feature that contains zero or more PlatformR elements. Your transformation has no assignment to this relationship so it is not surprising that it is unassigned and so your PlatformR object has no container and is rescued from oblivion by the ATL saver placing it at the model root.

In an imperative transformation language such as QVTo, it is common practice to transform parent-down with each parent rule assigning the containers of its one or more children. e.g

platformR += aPlatformR

In a declarative transformation language, such as ATL (or QVTr), it is often more appropriate to proceed child-up so that each child assigns its exactly one container as part of the child rule.

IoTSystem <- aPlatformR

where PlatformR::IoTSystem is the implicit opposite of IoTSystem::platformR. Unfortunately ATL does not appear to support OCL's implicit opposites so you must provide an explicit (e.g. PlatformR::iot) opposite (often a good idea anyway). You may then write

iot <- aPlatformR

so that aPlatformR has a container.

(My early attempts at using ATL failed completely because no tutorial seemed to point out the utility/necessity of child-up rather than parent-down rules.)

======

Your metamodel has very little inheritance, which is unusual. If nothing else everything usually benefits from inheriting from an 'Element' and probably 'NamedElement' and even 'TimerElement'. You may find that the standard leadingLowerCamelCase convention for feature names is helpful..

I suggest you work with a much smaller example while you are familiarizing with the technology so that you reduce the amount that you need to refactor as you gain experience.

Regards

Ed Willink

Re: Model-To-Model Sibling Child Problem [message #1811295 is a reply to message #1811294] Fri, 30 August 2019 08:04 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Hi Ed,

Thanks for your answer.

I don't have to transform all of PIM elements to PSM elements. So, as Result i should define relations to achieve parent chield relation?
Re: Model-To-Model Sibling Child Problem [message #1811296 is a reply to message #1811295] Fri, 30 August 2019 08:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

Sorry, your sentence has multiple errors making your meaning ambiguous.

I can only comment that you need to transform what you need to transform.

Regards

Ed Willink
Re: Model-To-Model Sibling Child Problem [message #1811298 is a reply to message #1811296] Fri, 30 August 2019 09:06 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Hi,

I try to summarize your comments.(BTW I use ATL for transformation.)
-as a first step, I should define relations,
-as a second step, Elements needs containers and a container refers to e.g IoTSystem is the container of PlatformR and PlatformR is the container of the NodeR,
-as a third step, If I define my relations and satisfy container for sub-elements.
then I can achieve parent/child hierarchy.
Am I correct?

[Updated on: Fri, 30 August 2019 09:07]

Report message to a moderator

Re: Model-To-Model Sibling Child Problem [message #1811302 is a reply to message #1811298] Fri, 30 August 2019 10:26 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
Hi

Sorry. I do not have time to supervise your every thought. Particularly when it is confusingly expressed. ATL has rules, so I am not sure what you mean by "relation". QVTr (and M2M generally) has relations, UML (and metamodelling generally) has relationships. Metamodels are usually a first step.

When you have made some progress and cannot proceed I may look at your repro at that point. Not before.

Regards

Ed Willink
Re: Model-To-Model Sibling Child Problem [message #1811308 is a reply to message #1811302] Fri, 30 August 2019 12:22 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Still need help.
Re: Model-To-Model Sibling Child Problem [message #1811315 is a reply to message #1811308] Fri, 30 August 2019 14:03 Go to previous message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Dear All, I have solved my problem. I just made a mistake when transforming relations. Thanks a lot.
Previous Topic:Own Model to XML
Next Topic:[ATL] Transform only a part of the rules ?
Goto Forum:
  


Current Time: Sun Jul 21 17:59:43 GMT 2024

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

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

Back to the top