Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Problem calling AcceleoService programatically
icon4.gif  [Acceleo] Problem calling AcceleoService programatically [message #1020941] Tue, 19 March 2013 08:26 Go to next message
Marc Schlegel is currently offline Marc Schlegel
Messages: 42
Registered: July 2009
Member
Hello everyone,

I am going to hold a little informal presentation for my company about M2T-Generators. Since I only used xText with xPand, I thought it would be a good idea to show some alternatives as well so I dove into Acceleo yesterday.

I think I got everything setup, but there must be still a little mistake. I created a project with the mtl-files and a Workflow-class (AbstractAcceleoGenerator) which is exported. The project is included in my ECore-Editor-project and the Command is calling the workflow.

I attached my template-modules, and this is how I call the Generator
Workflow wf = new Workflow(
	URI.createFileURI(editorInput.getFullPath().toString()), 
	folder.getFullPath().toFile(), 
	Collections.emptyList());
wf.doGenerate(new BasicMonitor());


But nothing happens...so I debugged into it. Withing the AcceleoService#doGenerate there is a loop which traverses over my ECore-Model

while (targetElements.hasNext()) {
	final EObject potentialTarget = targetElements.next();
	if (argumentType.isInstance(potentialTarget)) {
		final List<Object> actualArguments = new ArrayList<Object>();
		actualArguments.add(potentialTarget);
		actualArguments.addAll(arguments);
		previewResult.putAll(doGenerateTemplate(template, actualArguments, generationRoot,
				monitor));
		generationHasOccurred = true;
	}
}


This is the problem
if (argumentType.isInstance(potentialTarget))
because it is never true.

argumentType is always EClassifier whereas potentialTarget is a Class from my ECore (which seems correct to me). So I guess I have to tell Acceleo that the starting-point is a of a certain type from my model (in this case DTOs).

Can someone help me out please and show me what I am missing?
Thanks
Re: [Acceleo] Problem calling AcceleoService programatically [message #1021080 is a reply to message #1020941] Tue, 19 March 2013 13:53 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 413
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

If you launch the generation do you have any kind of error message (package not registered, resource factory missing)?
Do the value argument type or the value potentialTarget are proxy (eIsProxy())?
Are you launching the generator in Eclipse (as an Eclipse plug-in deployed in an Eclipse instance) or as a stand alone Java application (EMFPlugin.IS_ECLIPSE_RUNNING)?

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: +stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com | Eclipse Java Development Tools Tips and Tricks



Re: [Acceleo] Problem calling AcceleoService programatically [message #1021162 is a reply to message #1021080] Tue, 19 March 2013 15:33 Go to previous messageGo to next message
Marc Schlegel is currently offline Marc Schlegel
Messages: 42
Registered: July 2009
Member
Hi

No, I do not get any error messages, thats why I assumed that the template-configuration is correct.

There are also no eIsProxy-attributes.

But I just saw a slight mistake in my first post: argumentType is an EClassImpl with the attribute name set to DTOs. So I guess this is the argument from my template.
The first portentialTarget is an instance of BeanImpl which is confusing...

My ECore-Tree looks like this.
DTOs (has a containment of beans)
	BeanA (has a containment of properties)
		Property1
		Property2
	BeanB


So I am wondering why the doGenerate starts traversing with the Beans instead with DTOs
Re: [Acceleo] Problem calling AcceleoService programatically [message #1021661 is a reply to message #1021162] Wed, 20 March 2013 13:26 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 413
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

ArgumentType should be the type of the parameter of your main template, the potential target is an element of your model. We first try with the root of your model and then we all its content:

// The input model itself is a potential argument
if (argumentType.isInstance(model)) {
	final List<Object> actualArguments = new ArrayList<Object>();
	actualArguments.add(model);
	actualArguments.addAll(arguments);
	previewResult.putAll(doGenerateTemplate(template, actualArguments, generationRoot, monitor));
	generationHasOccurred = true;
}
final TreeIterator<EObject> targetElements = model.eAllContents();
while (targetElements.hasNext()) {
	final EObject potentialTarget = targetElements.next();
	if (argumentType.isInstance(potentialTarget)) {
		final List<Object> actualArguments = new ArrayList<Object>();
		actualArguments.add(potentialTarget);
		actualArguments.addAll(arguments);
		previewResult.putAll(doGenerateTemplate(template, actualArguments, generationRoot, monitor));
		generationHasOccurred = true;
	}
}


With the ecore tree that you have described, for some reasons this "argumentType.isInstance(model)" returns false. What version of Acceleo are you using and where is your meta-model located (in another project in the workspace, in a plug-in)?

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: +stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com | Eclipse Java Development Tools Tips and Tricks



Re: [Acceleo] Problem calling AcceleoService programatically [message #1021749 is a reply to message #1021661] Wed, 20 March 2013 16:05 Go to previous message
Marc Schlegel is currently offline Marc Schlegel
Messages: 42
Registered: July 2009
Member
Stephane Begaudeau wrote on Wed, 20 March 2013 09:26
What version of Acceleo are you using and where is your meta-model located (in another project in the workspace, in a plug-in)?


Hi, I am using the Juno-ReleaseTrain-Version: 3.3.2

But your point about the plugin-structure might be the right hint. This is how it looks

  • simplegenerator (here is the ecore and the generated Java-model-classes)
  • simplegenerator.edit
  • simplegenerator.editor (from here I call Acceleo -> dependecy on simplegenerator.acceleo)
  • simplegenerator.acceleo


Still, when I add a dependency to simplgenerator for simplegenerator.acceleo I still have the same problem.

I attached my little testproject. I hold the presentation today so it is not important any more, but still I´d like to solve the issue to dive deeper into the framework.
Previous Topic:Xpand Workflow file
Next Topic:[Acceleo] Simple, step by step, working tutorial, from UML to code?
Goto Forum:
  


Current Time: Thu Oct 23 22:06:22 GMT 2014

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

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