Skip to content

Commit

Permalink
Adding "as DTO" and toDTO() to collections and maps is currently unwo…
Browse files Browse the repository at this point in the history
…rkable

because there is no way to specify the DTO type in the collection/map. So
I have removed the methods.
  • Loading branch information
pledbrook committed Oct 7, 2009
1 parent 66defac commit 01547a9
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions DtoGrailsPlugin.groovy
Expand Up @@ -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
Expand Down Expand Up @@ -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 ->
Expand All @@ -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 ->
Expand Down

0 comments on commit 01547a9

Please sign in to comment.