Book a Demo

Author Topic: Groovy on EA  (Read 4809 times)

jeanphiv

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Groovy on EA
« on: May 02, 2007, 07:37:24 am »
Hi

I'm starting to use Grails and i would like to know how to add a new language generation module to enterprise architect.
I succeded to add a new language (product), to modify template but i don't know how generating a .groovy file instead of a .java for each class of my model.
Do you know how to issue such a task?

Thanks very much
Jean-Philippe

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Groovy on EA
« Reply #1 on: May 02, 2007, 01:46:42 pm »
You'll need to make an MDG technology.  Have a look at http://www.sparxsystems.com.au/EAUserGuide/addingcodemodulesinmdgtec.htm for the specifics about how to do what you want with an mdg technology.

jeanphiv

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Groovy on EA
« Reply #2 on: May 02, 2007, 11:35:44 pm »
Thanks for your reply

I succeeded to create a new MDG technology and defined a code options file.
I've loaded this profile from resouces.
The problem is that classes tagged with the groovy language continue to generate .java file.
I tried to create a uml profile and set a stereotype to the class i would like to use to generate my code but the result is the same.
How can'i make the link between used classes and my new MDG technology?

Thank for your help.

Here is the code options files


<?xml version="1.0" encoding="UTF-8"?>
<CodeOptions>
<CodeOption name="DefaultExtension">.groovy</CodeOption>
<CodeOption name="ImplementationExtension"></CodeOption>
<CodeOption name="ImplementationPath"></CodeOption>
<CodeOption name="PackagePathSeparator">.</CodeOption>
<CodeOption name="DefaultSourceDirectory">p:/grails/test2</CodeOption>
<CodeOption name="Editor"></CodeOption>
</CodeOptions>

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Groovy on EA
« Reply #3 on: May 03, 2007, 01:04:31 pm »
So, you've created your MDG technology using the wizard (Tools | Create MDG Technology), having included the datatypes, code templates and code options for groovy.  You've then imported that into your model by opening the Resources view (View | Resources), right clicking on the MDG Technologies item and selecting Import Technology?  And it's still not working?

What version (and build number) are you using?  It won't work before build 801.

jeanphiv

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Groovy on EA
« Reply #4 on: May 03, 2007, 11:22:34 pm »
I'm using the 805 version.


Hereafter is the simplest MDG i can do, i've loaded it from the resource panel, created a very simple class, marked it and its package with 'Groovy' language and finally asked for code generation.
If i ask to auto generate files, the root directory set in the codeoption mark isn't used (the root directory is requested for each generation) and the used extention is .java and not .groovy as requested.



Here is the Groovy3MDG.xml file generated by the MDG tool:

<MDG.Technology version="1.0">
<Documentation id="Groovy3" name="Groovy3" version="00.0"
notes="Groovy3" />
<CodeModules>
<CodeModule language="Groovy1" notes="">
<CodeTypes>
<RefData version="1.0" exporter="EA.25">
<DataSet name="Model Data Types - Code and DDL"
table="t_datatypes"
filter="Type='#Type#' and ProductName='#ProductName#' and DataType='#DataType#'"
stoplist=";DatatypeID;">
<DataRow>
<Column name="Type" value="DDL" />
<Column name="ProductName" value="Oracle" />
<Column name="DataType" value="VARCHAR" />
<Column name="Size" value="1" />
<Column name="MaxLen" value="4000" />
<Column name="MaxPrec" value="0" />
<Column name="MaxScale" value="0" />
<Column name="DefaultLen" value="50" />
<Column name="DefaultPrec" value="0" />
<Column name="DefaultScale" value="0" />
<Column name="User" value="0" />
<Column name="GenericType" value="varchar" />
<Column name="DatatypeID" value="3" />
</DataRow>
<DataRow>
<Column name="Type" value="Code" />
<Column name="ProductName" value="Groovy1" />
<Column name="DataType" value="String" />
<Column name="Size" value="0" />
<Column name="MaxScale" value="0" />
<Column name="User" value="1" />
<Column name="GenericType" value="String" />
<Column name="DatatypeID" value="241" />
</DataRow>
</DataSet>
</RefData>
</CodeTypes>
<CodeTemplates>
<RefData version="1.0" exporter="EA.25">
<DataSet name="Groovy1_Code_Template"
table="t_template"
filter="TemplateType='#TemplateType#' and TemplateName='#TemplateName#' and Style='#Style#'">
<DataRow>
<Column name="TemplateID"
value="{669B0E64-585E-47d9-A068-91F66CF2B730}" />
<Column name="TemplateType"
value="Groovy1_Code_Template" />
<Column name="TemplateName" value="File" />
<Column name="Template"
value="class %class% {&#xA;}" />
</DataRow>
</DataSet>
</RefData>
</CodeTemplates>
<CodeOptions>
<CodeOption name="DefaultExtension">.groovy</CodeOption>
<CodeOption name="PackagePathSeparator">.</CodeOption>
<CodeOption name="DefaultSourceDirectory">
p:/grails/test2
</CodeOption>
</CodeOptions>
</CodeModule>
</CodeModules>
</MDG.Technology>