0

Hi all i'm very new to acceleo

In my project, i have a java driver class which calls different acceleo templates. Some of the templates have parameters without any EObject type. I am calling calling initialize() and doGenerate() functions of generated java module for a template. the problems are facing are :

  1. initialize() expects the first argument to be Ecore object and rest of parameters are as List. However as I mentioned some of the templates do not have any EObject parameters. How do I call such templates from a java application?

  2. To work around the above problem, i adjusted my driver and templates to have dummy EObject as first parameter. Then it calls templates successfully but it won't generate any output. The templates generate output if I call them from another driver template though. However I do not want to write my driver program in MTL as it requires complex analysis of data model.

Please advice me on how can I progress in my case.

Thanks&Regards
Dhanunjaya M.

Sam DeHaan
  • 10,246
  • 2
  • 40
  • 48
dmusham
  • 1
  • 1

1 Answers1

1

The API we expose by default through the Java class we generate alongside the "main" templates' modules and the Acceleo "facade" classes always assume that there is an EObject as first parameter of the templates that are to be called. This has been made in order to facilitate the use for most use cases (we expect this use case to be 90% of the total).

For other use cases, you will have to make use of the APIs that are behind those facades. Namely, you can create another "initialize" method that does not take an EObject as parameter for these cases when you simply don't have one. You will then need to also override the "generate(Monitor)" method so that it does not use AcceleoService.doGenerate... or any other method of AcceleoService for that matter : this is the "facade" class that I was talking about.

What you will need is to call a method that mimics what AcceleoService.doGenerate does without relying on an EObject to find the template that needs to be called. If you do not have Acceleo's SDK or sources at hand, you can take a peek at the code through github : AcceleoService#doGenerate.

Kellindil
  • 4,523
  • 21
  • 20