Need help with thisModule.resolveTemp(...) [message #1831511] |
Fri, 21 August 2020 10:46 |
Neeraj Bhusare Messages: 177 Registered: July 2009 Location: Canada |
Senior Member |
|
|
Hi,
I am trying to adapt an entity-model (meta-meta-model) to ECore (meta-model) model. I plan to replace the existing model transformation (programmatic) with ATL. The content of the .atl file is provided below.
The problem I am facing is - 1) When I try to set the parent of an EClass, 2) When I try to set the data-type of an EAttribute. In the first case, entity.parent returns the parent Entity assuming it is defined. In the latter case, attribute.dataType returns the reference-type, which is an Entity.
I went through a bunch of forum threads (links below), and a few ATL transformation use-cases to confirm my use of resolveTemp. It looks correct to me, but I fail to understand why it doesn't work. Could someone please verify the use of resolveTemp and help me resolve the issue.
lazy rule Entity2EClass {
from
entity: Entity!Entity
to
eClass: ECore!EClass (
name <- entity.name,
abstract <- entity.abstract,
eSuperTypes <- if not entity.parent.oclIsUndefined() then
Sequence{thisModule.resolveTemp(entity.parent, 'eClass')}
else
Sequence {}
endif,
eAttributes <- entity.attributes -> collect(attribute | thisModule.
Attribute2EAttribute(attribute))
)
}
lazy rule Attribute2EAttribute {
from
attribute: Entity!Attribute
to
eAttribute: ECore!EAttribute (
name <- attribute.name,
eType <- if attribute.dataType.name = 'EString' then
ECore!EString
else
thisModule.resolveTemp(attribute.dataType, 'eClass')
endif
)
}
Forum threads
https://www.eclipse.org/forums/index.php/t/441471/
https://www.eclipse.org/forums/index.php/t/1099777/
https://www.eclipse.org/forums/index.php/t/171154/
Transformation use-cases
https://www.eclipse.org/atl/atlTransformations/
Tx in advance,
Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
|
|
|
Re: Need help with thisModule.resolveTemp(...) [message #1831526 is a reply to message #1831511] |
Fri, 21 August 2020 17:30 |
|
1) Tracing source elements to target elements does not work for lazy rules, as they are invoked manually, possibly more than once on the same input. Is there any reason why you can't use regular rules?
2) Whenever an element is transformed by a regular rule, you can just refer to the transformed source element somewhere in the "to" part, and it will implicitly be translated to the target element it was transformed into. In other words: you can just use the "entity.parent" expression without calling "thisModule.resolveTemp()" on it.
Cheers,
Dennis
|
|
|
Re: Need help with thisModule.resolveTemp(...) [message #1831948 is a reply to message #1831526] |
Thu, 03 September 2020 12:46 |
Neeraj Bhusare Messages: 177 Registered: July 2009 Location: Canada |
Senior Member |
|
|
Hi Dennis,
Sorry for the delayed feedback. Please find my comments below
> 1) Tracing source elements to target elements does not work for lazy rules, as they are invoked manually, possibly more than once on the same input. Is there any reason why you can't use regular rules?
This was my very first attempt at using ATL for model transformation. My understanding about the lazy rules was quite limited. I understand it better now, and I have replaced it with matched rule (PS link below)
> 2) Whenever an element is transformed by a regular rule, you can just refer to the transformed source element somewhere in the "to" part, and it will implicitly be translated to the target element it was transformed into. In other words: you can just use the "entity.parent" expression without calling "thisModule.resolveTemp()" on it.
You are right. I have removed the resolveTemp() from the grammar definition, and also fixed the Entity2EClass rule. Here is the link to the complete grammar definition - https://bit.ly/32Si6KN
Tx for your help.
Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
|
|
|
Powered by
FUDForum. Page generated in 0.01450 seconds