The page also has links to example templates. Some of them are quite complex because of support for featuremaps and
such, in general more specific templates are much simpler.

gr. Martin

On 11/05/2012 02:36 PM, Pradeep Badiger wrote:

> Hi,
>
> I am new to Texo and want to generate JPA code with custom annotations on conditions for which i need to read metadata
> information in ecore model.
>
> what is the correct way to access ecore model annotations in a template file?
>
> thanks,
> Pradeep V.B.
>
>

For examples the addition.xpt (see below). Within the define you have access to the ModelGenAnnotation instance (for
EClass, EPackage etc). From the ModelGenAnnotation instance you can find the underlying modelelement as a property, for
example eClass, ePackage etc.

«REM»Template file which can be overridden to generate additional files or code«ENDREM»
«IMPORT org::eclipse::emf::texo::modelgenerator::modelannotations»
«IMPORT org::eclipse::emf::texo::generator»

«REM»Called for EPackages, even if you don't want to generate code for EPackages, still keep this empty DEFINE«ENDREM»
«DEFINE root(ModelController modelController) FOR EPackageModelGenAnnotation-»
«ENDDEFINE»

«REM»Called for EClasses, even if you don't want to generate code for EClasses, still keep this empty DEFINE«ENDREM»
«DEFINE root(ModelController modelController) FOR EClassModelGenAnnotation-»
«ENDDEFINE»

«REM»Called for EEnums, even if you don't want to generate code for EEnums, still keep this empty DEFINE«ENDREM»
«DEFINE root(ModelController modelController) FOR EEnumModelGenAnnotation-»
«ENDDEFINE»

gr. Martin

On 11/07/2012 07:08 AM, Pradeep Badiger wrote:
> Hi Martin,
>
> Yes the metadata required are added as EAnnotations in the model. I need to use this metadata as conditional fields in
> the overridden template to generate additional code in the generated code.
> I was using JET templates earlier which had access to metadata defined on the models which allowed me to control the
> code generation. I was hoping the same when using the Xpand language and Texo.
>
> thanks,
> Pradeep V.B.
>
>

Hi Martin, I am trying to override addtions.xpt and generate a file for every EClass in emf file. I need a different package and class name for the new file. How do i override that. I am not able to generate it in a different package. A new file is getting generated in with the same name as that of EClass.

(as an example), so you can determine the filename yourselve.
In the above example the filename is created using this utility:
String classFileName( EClassifierModelGenAnnotation this ): qualifiedClassName.replaceAll("\\.","/") + ".java";

Let me know if you have additional questions.

gr. Martin

On 12/17/2012 09:39 AM, Pradeep Badiger wrote:
> Hi Martin, I am trying to override addtions.xpt and generate a file for every EClass in emf file. I need a different
> package and class name for the new file. How do i override that. I am not able to generate it in a different package. A
> new file is getting generated in with the same name as that of EClass.
>
> Thanks,
> Pradeep V.B.