Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL-EMF] Problem with references
[ATL-EMF] Problem with references [message #629698] Wed, 29 September 2010 10:01 Go to next message
Dave  is currently offline Dave Friend
Messages: 37
Registered: September 2010
Member
Hi all,

as you can deduct from the topic title, I'm having some problems with references in the XML model resulting from my ATL trasformation.
The XML model is conform to an ecore metamodel.
What is important to know for you is that, in the ecore metamodel, a matrix is defined: its type is named "OverheadMatrixType" and it's composed of 1 or more oMElement, which type is named OMElementType. This last type is composed of just one instance of the following elements:
- serverId, of type ServerType (it's not just the Id, but the just element itself);
- sWResourceId, of type SoftwareResourceType (it's not just the Id, but the just element itself);
- amountOfService, of type Double.

In an imperative section, I've written the following lines:

for(sw in swResources) {				
	...
				
	oMatrixEntries <- if(not actualAllocation.oclIsUndefined())
						then
				  			if(not (actualAllocation.oclIsUndefined() or actualAllocation.name.oclIsUndefined() or thisModule.removeBlankSpaces(actualAllocation.name) = ''))
								then
									if(actualAllocation.name.toReal() >= 0.0)
										then				oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw, actualAllocation.name.toReal()))
										else
											oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw, thisModule.defaultAmountOfService))->debug('The <<Allocate>> relation between ' + hwRes.name + ' and ' + sw.eCrossReferences()->first().name + ' has a wrong value. It must have a non-negative real value. It will be setted to the default value (0.0).')
									endif
								else
									oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw, thisModule.defaultAmountOfService))->debug('The <<Allocate>> relation between ' + hwRes.name + ' and ' + sw.eCrossReferences()->first().name + ' is undefined. It must have a non-negative real value. It will be setted to the default value (0.0).')
							endif
						else
							oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw, thisModule.defaultAmountOfService))->debug('The <<Allocate>> relation between ' + hwRes.name + ' and ' + sw.eCrossReferences()->first().name + ' is undefined. It must have a non-negative real value. It will be setted to the default value (0.0).')
					endif;
				
	actualAllocation <- OclUndefined;
}


where:
- swResources is a Sequence of elements composed of only two attributes (sWResourceId and sWResourceName);
- oMatrixEntries is a Sequence of OMElementType (that will form the OverheadMatrixType element);
- NewOMElement is the following simple called rule:

rule NewOMElement (server : spmif!ServerType, swRes : spmif!SoftwareResourceType, amount : Real) {
	to
		el : spmif!OMElementType (
			serverId <- server,
			sWResourceId <- swRes,
			amountOfService <- amount
		)
	do {
		el;
	}
}


- actualAllocation is an <<Allocate>> relation, which name, converted to a Real, defines the amountOfService parameter required from the NewOMElement rule.

Now, let's focus our attention to the line:

oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw, actualAllocation.name.toReal()))


that is executed if and only if all the values needed by the NewOMElement rule are defined.
The problem is that when the XML resulting file is written, the corresponding tag contains the reference to "sw". So, the reference is not resolved. In fact, the following is the resulting part of the XML file, corresponding to the matrix entry (CPU, Instr) = 10.0, where CPU was the actualServer, Instr was the "sw" parameter and 10.0 was the amountOfService.

<oMElement amountOfService="10.0" serverId="CPU">
          <sWResourceId href="platform:/resource/SDs2EGs/models/uml/eHealthSystem_techReport.uml#_mXLWkZQNEd--N67QQ2J2AA"/>
</oMElement>


As you can see, the sWResourceId tag contains a not resolved reference, when I would like to obtain something like:

<oMElement amountOfService="10.0" serverId="CPU" sWResourceId="Instr"/>


Anyone can help me, please? How could I resolve that reference? I've tried the resolveTemp function, but I don't know on what parameters I must call it.

Many thanks,
Dave.
Re: [ATL-EMF] Problem with references [message #629727 is a reply to message #629698] Wed, 29 September 2010 11:07 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Le 29/09/2010 12:01, Dave a écrit :
> Hi all,
>
> as you can deduct from the topic title, I'm having some problems with
> references in the XML model resulting from my ATL trasformation.
> The XML model is conform to an ecore metamodel.
> What is important to know for you is that, in the ecore metamodel, a
> matrix is defined: its type is named "OverheadMatrixType" and it's
> composed of 1 or more oMElement, which type is named OMElementType. This
> last type is composed of just one instance of the following elements:
> - serverId, of type ServerType (it's not just the Id, but the just
> element itself);
> - sWResourceId, of type SoftwareResourceType (it's not just the Id, but
> the just element itself);
> - amountOfService, of type Double.
>
> In an imperative section, I've written the following lines:
>
> for(sw in swResources) {
> ...
>
> oMatrixEntries <- if(not actualAllocation.oclIsUndefined())
> then
> if(not (actualAllocation.oclIsUndefined() or
> actualAllocation.name.oclIsUndefined() or
> thisModule.removeBlankSpaces(actualAllocation.name) = ''))
> then
> if(actualAllocation.name.toReal() >= 0.0)
> then oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw,
> actualAllocation.name.toReal()))
> else
> oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw,
> thisModule.defaultAmountOfService))->debug('The <<Allocate>> relation
> between ' + hwRes.name + ' and ' + sw.eCrossReferences()->first().name +
> ' has a wrong value. It must have a non-negative real value. It will be
> setted to the default value (0.0).')
> endif
> else
> oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw,
> thisModule.defaultAmountOfService))->debug('The <<Allocate>> relation
> between ' + hwRes.name + ' and ' + sw.eCrossReferences()->first().name +
> ' is undefined. It must have a non-negative real value. It will be
> setted to the default value (0.0).')
> endif
> else
> oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw,
> thisModule.defaultAmountOfService))->debug('The <<Allocate>> relation
> between ' + hwRes.name + ' and ' + sw.eCrossReferences()->first().name +
> ' is undefined. It must have a non-negative real value. It will be
> setted to the default value (0.0).')
> endif;
>
> actualAllocation <- OclUndefined;
> }
>
> where:
> - swResources is a Sequence of elements composed of only two attributes
> (sWResourceId and sWResourceName);
> - oMatrixEntries is a Sequence of OMElementType (that will form the
> OverheadMatrixType element);
> - NewOMElement is the following simple called rule:
>
> rule NewOMElement (server : spmif!ServerType, swRes :
> spmif!SoftwareResourceType, amount : Real) {
> to
> el : spmif!OMElementType (
> serverId <- server,
> sWResourceId <- swRes,
> amountOfService <- amount
> )
> do {
> el;
> }
> }
>
> - actualAllocation is an <<Allocate>> relation, which name, converted to
> a Real, defines the amountOfService parameter required from the
> NewOMElement rule.
>
> Now, let's focus our attention to the line:
>
> oMatrixEntries.append(thisModule.NewOMElement(actualServer, sw,
> actualAllocation.name.toReal()))
>
> that is executed if and only if all the values needed by the
> NewOMElement rule are defined.
> The problem is that when the XML resulting file is written, the
> corresponding tag contains the reference to "sw". So, the reference is
> not resolved. In fact, the following is the resulting part of the XML
> file, corresponding to the matrix entry (CPU, Instr) = 10.0, where CPU
> was the actualServer, Instr was the "sw" parameter and 10.0 was the
> amountOfService.
>
> <oMElement amountOfService="10.0" serverId="CPU">
> <sWResourceId
> href=" platform:/resource/SDs2EGs/models/uml/eHealthSystem_techRepo rt.uml#_mXLWkZQNEd--N67QQ2J2AA "/>
>
> </oMElement>
>
> As you can see, the sWResourceId tag contains a not resolved reference,
> when I would like to obtain something like:
>
> <oMElement amountOfService="10.0" serverId="CPU" sWResourceId="Instr"/>
>
> Anyone can help me, please? How could I resolve that reference? I've

You should try to avoid imperative code because it can produce
side-effects as getting a reference on input model in place of the
corresponding value in output model (like the one you seem to get).

> tried the resolveTemp function, but I don't know on what parameters I
> must call it.

thisModule.resolveTemp(<the input model element>, <the variable name of
corresponding output element in the matching rule>)

>
> Many thanks,
> Dave.

--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: [ATL-EMF] Problem with references [message #630065 is a reply to message #629727] Thu, 30 September 2010 14:36 Go to previous messageGo to next message
Dave  is currently offline Dave Friend
Messages: 37
Registered: September 2010
Member
Thanks for your reply, Vincent.

I solved my problem.
I moved the code in the imperative block of another rule, that had a direct visibility of all the software resources. For my purposes, apart from being conceptually better than the previous, this solution also works! Cool

However, I'll have a lot of other questions to submit and I'll be sure to submit them here! Smile

Thanks for your time and consideration,
Dave.
Re: [ATL-EMF] Problem with references [message #630071 is a reply to message #629727] Thu, 30 September 2010 14:46 Go to previous messageGo to next message
Dave  is currently offline Dave Friend
Messages: 37
Registered: September 2010
Member
Thanks for your reply, Vincent.

I solved my problem.
I moved the code in the imperative block of another rule, that had a direct visibility of all the software resources. For my purposes, apart from being conceptually better than the previous, this solution also works! Cool

However, I'll have a lot of other questions to submit and I'll be sure to submit them here! Smile

Thanks for your time and consideration,
Dave.
Re: [ATL-EMF] Problem with references [message #630073 is a reply to message #629727] Thu, 30 September 2010 14:48 Go to previous message
Dave  is currently offline Dave Friend
Messages: 37
Registered: September 2010
Member
Sorry for the repetition. I didn't realize it.

[Updated on: Thu, 30 September 2010 14:51]

Report message to a moderator

Previous Topic:[ATL] refining more than one model
Next Topic:[QVTO] Bug 254417 fix broke black box import in org.eclipse.m2m.qvt.oml_1.0.1?
Goto Forum:
  


Current Time: Fri Apr 19 17:10:31 GMT 2024

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

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

Back to the top