Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Containment references cannot span across models(Several output models need to be merged in one file)
Containment references cannot span across models [message #975246] Wed, 07 November 2012 13:27 Go to next message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
Hi forum members,

I've been using ATL happily for months now to create a transformation from a vendor-specific model to an open model called OTX. Its purpose is to describe diagnostic procedures.
The ATL file has grown to more than 4kLOC, and seems that I've just run into a serious problem.
The target Ecore model, OTX, has a submodel, DiagCom, which is an Ecore model, too (I received them as XML schema definitions, which I imported with the Ecore tools). Both of them are output models to the ATL transformation:
create OUT: otx, diag: otxDiagCom from IN: transformate;

In the run configuration, there is a file for each model, but all the output shall be put into the OTX output model/file, whereas the DiagCom output file shall remain empty.
That works fine when a DiagCom target element is put into an OTX element within the rule that creates it, but - and that's my problem - it does not work for a set of rules where a DiagCom target element is not put into an OTX element immediately, but by another rule:
lazy rule Asam3dResponse2ResponseParameters {
    from
    	source: transformate!Asam3dResponse
    to
        -- This target element from DiagCom is not put anywhere in the current rule,
        -- which makes it reside in the DiagCom output file eventually.
        -- There is nothing I can do about that, although I need it in the OTX file
        -- and it should be put there by the next rule 'Asam3dCallServiceTactic2Action'.
    	otxResponseParameters: otxDiagCom!ResponseParameters(
    		name <- otxStringTerm
    	),
    	otxStringTerm: otx!StringLiteral(
    		value <- source.name
    	)
}

lazy rule Asam3dCallServiceTactic2Action {
    from
    	source: transformate!Asam3dCallServiceTactic,
    to
    	otxAction: otx!Action(
    		id <- thisModule -> getId(),
    		realisation <- otxExecuteDiagService
        ),
        -- This output element eventually resides in the OTX output file,
        -- although it is from the DiagCom model. This is how I need it!
        -- I guess it works because it is put into an OTX element right above,
        -- i.e. in the very rule where it is created.
	otxExecuteDiagService: otxDiagCom!ExecuteDiagService(
		diagService <- otxDiagServiceValue,
        -- The DiagCom target element 'otxResponseParameters' from the above rule
        -- 'Asam3dResponse2ResponseParameters' should be put in the current
        -- output element 'otxExecuteDiagService' here, but, as written above,
        -- goes to the DiagCom output file.
		responseParameters <- source.service.responses
			-> collect(response | thisModule -> 
                           Asam3dResponse2ResponseParameters(response))
	),
	otxDiagServiceValue: otxDiagCom!DiagServiceValue(
	        valueOf <- source.service.name
	)
}


I would more than glad if you could help me with that - it would be a total disaster if I had to rework the whole project without ATL, because I'm running short on time (and it's more fun that way).
Thank you for reading!
Re: Containment references cannot span across models [message #975840 is a reply to message #975246] Thu, 08 November 2012 00:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25919
Registered: July 2009
Senior Member
Gunnar,

I don't follow the details but note that EMF does support cross resource
containment, i.e., a contained object can be in the root of a different
resource. You need to enable that by setting the GenModel property
"Containment Proxies" to true, and then any containment EReference is
resolveProxies true (the default) will support cross resource containment.


On 07/11/2012 7:27 PM, Gunnar Arndt wrote:
> Hi forum members,
>
> I've been using ATL happily for months now to create a transformation
> from a vendor-specific model to an open model called OTX. Its purpose
> is to describe diagnostic procedures.
> The ATL file has grown to more than 4kLOC, and seems that I've just
> run into a serious problem.
> The target Ecore model, OTX, has a submodel, DiagCom, which is an
> Ecore model, too (I received them as XML schema definitions, which I
> imported with the Ecore tools). Both of them are output models to the
> ATL transformation:
>
> create OUT: otx, diag: otxDiagCom from IN: transformate;
>
> In the run configuration, there is a file for each model, but all the
> output shall be put into the OTX output model/file, whereas the
> DiagCom output file shall remain empty. That works fine when a DiagCom
> target element is put into an OTX element within the rule that creates
> it, but - and that's my problem - it does not work for a set of rules
> where a DiagCom target element is not put into an OTX element
> immediately, but by another rule:
>
> lazy rule Asam3dResponse2ResponseParameters {
> from
> source: transformate!Asam3dResponse
> to
> -- This target element from DiagCom is not put anywhere in the
> current rule,
> -- which makes it reside in the DiagCom output file eventually.
> -- There is nothing I can do about that, although I need it in
> the OTX file
> -- and it should be put there by the next rule
> 'Asam3dCallServiceTactic2Action'.
> otxResponseParameters: otxDiagCom!ResponseParameters(
> name <- otxStringTerm
> ),
> otxStringTerm: otx!StringLiteral(
> value <- source.name
> )
> }
>
> lazy rule Asam3dCallServiceTactic2Action {
> from
> source: transformate!Asam3dCallServiceTactic,
> to
> otxAction: otx!Action(
> id <- thisModule -> getId(),
> realisation <- otxExecuteDiagService
> ),
> -- This output element eventually resides in the OTX output file,
> -- although it is from the DiagCom model. This is how I need it!
> -- I guess it works because it is put into an OTX element right
> above,
> -- i.e. in the very rule where it is created.
> otxExecuteDiagService: otxDiagCom!ExecuteDiagService(
> diagService <- otxDiagServiceValue,
> -- The DiagCom target element 'otxResponseParameters' from the
> above rule
> -- 'Asam3dResponse2ResponseParameters' should be put in the
> current
> -- output element 'otxExecuteDiagService' here, but, as written
> above,
> -- goes to the DiagCom output file.
> responseParameters <- source.service.responses
> -> collect(response | thisModule ->
> Asam3dResponse2ResponseParameters(response))
> ),
> otxDiagServiceValue: otxDiagCom!DiagServiceValue(
> valueOf <- source.service.name
> )
> }
>
>
> I would more than glad if you could help me with that - it would be a
> total disaster if I had to rework the whole project without ATL,
> because I'm running short on time (and it's more fun that way).
> Thank you for reading!
Re: Containment references cannot span across models [message #977430 is a reply to message #975840] Fri, 09 November 2012 04:25 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 600
Registered: July 2009
Senior Member
Hello,

If OTX.ecore is directly linked to DiagCom.ecore (i.e. refers to/uses some of its elements), then you just need to load OTX.ecore and ATL will also automatically load DiagCom.ecore.
Thus, you would have only one output to your transformation and so one single target model to fill.

Best regards,

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Containment references cannot span across models [message #982631 is a reply to message #975246] Tue, 13 November 2012 04:36 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
Guys, thank you for your replies.

Ed: Containment proxies were indeed deactivated, which I have changed and regenerated.
It does not help, the message "Containment references cannot span across models" shows up again, so I guess it is an ATL problem, not an Ecore one.

Hugo: OTX.ecore and DiagCom.ecore were both created from OTX.xsd, which imports DiagCom.xsd. Seperate sub-models were created automatically, and I only imported them to ATL explicitely because I do not know another way to create sub-model elements there.
When an element of org.iso.otx.DiagCom.DiagService is required, I have tried to use both
to otx!"org::iso::otx::DiagCom::DiagService"()
-- Cannot find class org::iso::otx::DiagCom::DiagService in reference model otx

as described here, and
to otx!DiagService()
-- Cannot find class DiagService in reference model otx

instead of
to otxDiagCom!DiagService()
-- Containment references cannot span across models

but that doesn't work out.
Hugo, your solution is just what I'm looking for, but I don't know how to it that way. Maybe you can post a little example?
Re: Containment references cannot span across models [message #983056 is a reply to message #982631] Tue, 13 November 2012 11:36 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 600
Registered: July 2009
Senior Member
I'm not sure your problem comes from this but, in the advanced options of the ATL launch configuration, you also have to "Allow inter-model dependencies".

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Containment references cannot span across models [message #985375 is a reply to message #975246] Thu, 15 November 2012 05:53 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
Hugo, thank you for the replay again.
I have had cross-model references activated since I have been using a sub-model, as it is required for this case where all elements go to the OTX (main model) file:
from
 transformate!something
to
 action: otx!Action(
  realisation <- callService
 ),
 callService: otxDiagCom!CallService()


As you may have guessed already, it does not solve my problem of the main binding from a sub-model.
Can you provide more precise information on how to generate sub-model (DiagCom) elements without loading the DiagCom metamodel explicitely?
I can currently work around the issue, but you'd make me feel much better if there was a permanent solution.
Re: Containment references cannot span across models [message #985915 is a reply to message #985375] Fri, 16 November 2012 11:44 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 600
Registered: July 2009
Senior Member
Hello,

If you have now a header looking like this
create OUT: otx from IN: transformate;

where "otxDiagCom" is automatically loaded via "otx", then you should be able to create "otxDiagCom" element as if they were from "otx":
from
 transformate!something
to
 action: otx!Action(
  realisation <- callService
 ),
 callService: otx!CallService()

"otx" is in this case just the name given by the ATL transformation to the output metamodel, even if actually corresponding to several Ecore files.

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Containment references cannot span across models [message #986700 is a reply to message #975246] Wed, 21 November 2012 06:32 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
Hugo, thank you again for your code, but I've tested it that way already (see above).
It yields the error message
Cannot find class CallService in reference model otx
.
I'm beginning to wonder if the problem is with Ecore, not with ATL, similar to Ed's containment proxies I had not activated (no effect either, though).
Is there anything I can do during the Ecore model generation from OTX.xsd (importing DiagCom.xsd, among others) in order to create only one model, or to have the sub-models loaded automatically, as you expect them to be?
Re: Containment references cannot span across models [message #986712 is a reply to message #986700] Wed, 21 November 2012 07:24 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 600
Registered: July 2009
Senior Member
Concerning the Ecore model generation from the XSD, there is probably an option when selecting the different Ecore packages to be produced out of the single XSD file.
I guess you should post this question directly onto the EMF forum to get more hints.

Hugo


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: Containment references cannot span across models [message #986740 is a reply to message #975246] Wed, 21 November 2012 09:01 Go to previous message
Gunnar Arndt is currently offline Gunnar Arndt
Messages: 57
Registered: June 2012
Member
Will do, thanks.

[Updated on: Wed, 21 November 2012 09:02]

Report message to a moderator

Previous Topic:Launch transformation by java returns different output compared to atl run
Next Topic:custom data types
Goto Forum:
  


Current Time: Fri Jul 25 12:09:34 EDT 2014

Powered by FUDForum. Page generated in 0.02808 seconds