From 01547a959d636cafa979674619ab7dc5ebb55f96 Mon Sep 17 00:00:00 2001 From: Peter Ledbrook Date: Wed, 7 Oct 2009 16:29:35 +0100 Subject: [PATCH] Adding "as DTO" and toDTO() to collections and maps is currently unworkable because there is no way to specify the DTO type in the collection/map. So I have removed the methods. --- DtoGrailsPlugin.groovy | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/DtoGrailsPlugin.groovy b/DtoGrailsPlugin.groovy index f91eb8f..cd4b04d 100644 --- a/DtoGrailsPlugin.groovy +++ b/DtoGrailsPlugin.groovy @@ -2,6 +2,7 @@ import grails.plugins.dto.DTO import org.codehaus.groovy.grails.plugins.dto.DefaultGrailsDtoGenerator import org.dozer.spring.DozerBeanMapperFactoryBean +import org.springframework.context.ApplicationContext class DtoGrailsPlugin { // the plugin version @@ -39,12 +40,8 @@ map domain class instances to DTO instances. def doWithDynamicMethods = { final ctx -> // Add "as DTO" and toDTO() to domain classes. for (dc in application.domainClasses) { - addDtoMethods(dc.metaClass) + addDtoMethods(dc.metaClass, ctx) } - - // Also add them to Collection and Map. - addDtoMethods(Collection.metaClass) - addDtoMethods(Map.metaClass) } def doWithApplicationContext = { final ctx -> @@ -61,7 +58,7 @@ map domain class instances to DTO instances. // The event is the same as for 'onChange'. } - private addDtoMethods(MetaClass mc) { + private addDtoMethods(final MetaClass mc, final ApplicationContext ctx) { // First add the "as DTO". final originalAsType = mc.getMetaMethod("asType", [ Class ] as Object[]) mc.asType = { Class clazz ->