Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Need help with thisModule.resolveTemp(...)(Adapting model to ECore)
Need help with thisModule.resolveTemp(...) [message #1831511] Fri, 21 August 2020 10:46 Go to next message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
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 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

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 Go to previous message
Neeraj Bhusare is currently offline Neeraj BhusareFriend
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
Previous Topic:Select the features to be transformed using if else statements in rules
Next Topic:[Solved] Using an extended set of primitive ECore types
Goto Forum:
  


Current Time: Sat Apr 20 06:02:19 GMT 2024

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

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

Back to the top