Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Acceleo - Reference to another model(Using Acceleo on a model wich contains references to another model )
Acceleo - Reference to another model [message #1790221] Thu, 07 June 2018 08:52 Go to next message
Flora Ferreira is currently offline Flora FerreiraFriend
Messages: 2
Registered: June 2018
Junior Member
I am facing a problem and I am kind of desesperate :

I am trying to transform a constraint OCL into a C# program. To do so, I define my ocl constraints in a CompleteOCL document, and I save it as Abstract Syntax : POC.ocl.oclas. Then I use Acceleo with the Pivot Meta-model ('http://www.eclipse.org/ocl/2015/Pivot').

However, common OCL operations (such as 'size') are defined in another model : the Library. So when I try to recover operations used on my OCL model, nothing happened, I can only recover the operation I defined in my ocl document.

For example I wrote the following constraint :
inv pasPlusDe10Objets('Il y a plus de 10 objets dans ce diagramme'): self.DiagramObjects -> size() <= 10


I save it as Abstract Syntax under the name of POC.ocl.oclas, and when I opened POC.ocl.oclas and I go to the OperationCallExp of size, I obtain this :

> [OperationCallExp]
... > /eContainer
...... > name =
...
...... > referredOperatio
......... > [Operation] size
............ > name = size
...

So I could recover the referredOperation name inside the editor (MoDisco Model Browser)

I wrote in Acceleo :
[comment getCode() opération/]
[template public getCode(operationCallExp : pivot::OperationCallExp) post (trim())]
[operationCallExp.ownedSource.getCode()/] 
[operationCallExp.referredOperation.name/][operationCallExp.ownedArguments -> getArguments()/]
[/template]


In theory,
[operationCallExp.referredOperation.name/]
gives me the name of the operation, as we have it in MoDisco Model Browser. In reality, it gives me nothing, except when I defined the operation (and thus when the operation doesn't come from the OCL Library).

And it only generate one file : "POC.oclxx", not "Library.oclxx"

That lead us to this question : Is it possible in Acceleo to make a reference to another model (than the main one) ? And if it is, how to do that ?

I am using Eclipse Oxygen (Release (4.7.3a)) and the '3.7.2.201708211328' version of Acceleo. I also tried with Photon package but the problem remains.

Thank you in advance !

---------------------------------------------------------------------------------------
The zipped projet attached :

POC folder contains POC metamodel (POC.ecore), OCL constraint on this metamodel (POC.ocl) and the Pivot model associate (POC.ocl.oclas). Files generated by Acceleo are in the files folder.

POC_Acceleo forlder contains the Acceleo transformation (generate.mtl).
Re: Acceleo - Reference to another model [message #1790278 is a reply to message #1790221] Thu, 07 June 2018 19:06 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I am afraid that you have made the same mistake as numerous Acceleo newbies; totally ignored the comments at the end of Generate.java. (I have no idea why the Acceleo developers have not responded to this inevitable newbie hurdle. If nothing else Generate.java could have a compilation error demanding attention.)

If you add PivotStandaloneSetup.doSetup(), remove @generated, and (iteratively) fixup the classpath by adding com.google.inject and org.apache.log4j it works,.

(PivotStandaloneSetup.doSetup() is the standard Xtext idiom, which the most recent enhancement to fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=530953 has yet to support.

Regards

Ed Willink
Re: Acceleo - Reference to another model [message #1790279 is a reply to message #1790278] Thu, 07 June 2018 19:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If https://bugs.eclipse.org/bugs/show_bug.cgi?id=535665 is resolved, this kind of problem might be obvious to the user from the outset.

Regards

Ed Willink
Re: Acceleo - Reference to another model [message #1790355 is a reply to message #1790279] Fri, 08 June 2018 13:57 Go to previous message
Flora Ferreira is currently offline Flora FerreiraFriend
Messages: 2
Registered: June 2018
Junior Member
Hi,

Indeed, it works !!

Thank you,
Have a nice day,

Flora
Previous Topic:Does Acceleo support Break and Continue in for loops ?
Next Topic:Acceleo creating a UI launcher "Acceleo Model to text"not found
Goto Forum:
  


Current Time: Tue Mar 19 03:10:39 GMT 2024

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

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

Back to the top