TRIMM Groovy/Grails

Trimm-GroovyGrails The TRIMM Groovy module supports generating Groovy code from UML 2.x Class models.

TRIMM Groovy supports the Generator Gap Pattern through the use of Mixins. See the TRIMM Grails extensions

By applying specialized TRIMM Grails Generator extensions you can also generate GORM domain models that even support GEnvers.

Below is an example Maven POM which configures the TrimmGroovyMavenPlugin together with a GroovyConfig.yml configuration file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>dk.tigerteam.mdd</groupId>
    <artifactId>TrimmGroovyExample</artifactId>
    <name>TrimmGroovyExample</name>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>dk.tigerteam</groupId>
                <artifactId>TrimmGroovyMavenPlugin</artifactId>
                <version>1.0.0-SNAPSHOT</version>
                <executions>
                    <execution>
                        <id>generate</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <yamlFile>model/GroovyConfig.yml</yamlFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
   <repositories>
        <repository>
            <id>tigerteam-maven2-repository</id>
            <name>tigerteam.dk Repository for Maven 2</name>
            <url>http://www.tigerteam.dk/maven2/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>tigerteam-maven2-repository</id>
            <name>tigerteam.dk Repository for Maven 2</name>
            <url>http://www.tigerteam.dk/maven2/</url>
        </pluginRepository>
    </pluginRepositories>
</project>

GroovyConfig.yml configuration file:

xmiModelPath: model/MDD Example.xml
umlTool: EA
basePackageName: dk
modelPreprocessingScript: model/model-preprocessing.groovy
rootSuperClass: dk.tigerteam.trimm.gormexample.AbstractEntity
useImports: true
#modelPreprocessingScript: model/model-preprocessing.groovy
sourceCodeFormatting:
#    implementation: dk.tigerteam.trimm.mdsd.groovy.generator.codewriter.EclipseFormattingCodeWriter
    # Formatting exclusions can be specified even though implementation hasn't been specified (and the default GroovyCodeWriter is used)
    excludeFormattingForPackages: 
        - dk.tigerteam.mddexample.meta
        - dk.tigerteam.mddexample.test
        
# Paths
generateBaseClassesToPath: target/generated-sources/domainmodel
generateExtensionClassesToPath: target/generated-sources/domainmodel-extensions
generateInterfacesToPath: target/generated-sources/domainmodel
generateTestClassesToPath: target/generated-sources/generated-tests
generateResourcesToPath: target/generated-sources/generated-resources

mapUmlPropertyTypes:
    - name: DateTime
      javaType: Date
    - name: LocalDate
      javaType: Date

# Gorm specific setup, mixinSuperClass is used with GroovyMixinEventListener if you want to mixin common Gorm field like uuid, dateCreated, lastUpdated
gormSetup:
     excludeGormMappedProperties: true
     mixinSuperClass: dk.tigerteam.trimm.gormexample.EntityMixIn

# Extensions (note these listeners can also be groovy scripts containing a single class implement the GeneratorEventListener interface (or which extend specializations thereof)
eventListeners:
    - listener: dk.tigerteam.trimm.mdsd.groovy.generator.gorm.GormGeneratorEventListener
    - listener: dk.tigerteam.trimm.mdsd.groovy.generator.extensions.GroovyMixinEventListener
    - listener: dk.tigerteam.trimm.mdsd.groovy.generator.gorm.EnversEventListener