forked from mdeimel/grails-hibernate-filter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
HibernateFilterGrailsPlugin.groovy
45 lines (36 loc) · 1.54 KB
/
HibernateFilterGrailsPlugin.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import org.codehaus.groovy.grails.commons.GrailsDomainClass
import org.grails.plugin.hibernate.filter.HibernateFilterUtils
class HibernateFilterGrailsPlugin {
def version = '0.4.0'
def grailsVersion = '2.5 > *'
def loadAfter = ['controllers', 'hibernate']
def observe = ['*']
def pluginExcludes = ['grails-app/domain/**']
def author = 'Scott Burch'
def authorEmail = '[email protected]'
def title = 'Hibernate Filter plugin'
def description = 'Integrates Hibernate filtering into Grails'
def documentation = 'http://grails.org/plugin/hibernate-filter'
def license = 'APACHE'
def developers = [[name: 'Burt Beckwith', email: '[email protected]'],
[name: 'Dónal Murtagh'],
[name: 'Alex Shneyderman', email: '[email protected]']]
def issueManagement = [system: 'GitHub', url: 'https://github.com/burtbeckwith/grails-hibernate-filter/issues']
def scm = [url: 'https://github.com/burtbeckwith/grails-hibernate-filter']
def doWithDynamicMethods = { ctx ->
for (GrailsDomainClass dc in application.domainClasses) {
HibernateFilterUtils.addDomainClassMethods dc.clazz, ctx
}
for (Class artefactClass in application.allArtefacts) {
HibernateFilterUtils.addDomainProxies artefactClass
}
}
def onChange = { event ->
if (!(event.source instanceof Class)) return
if (!event.application.isArtefact(event.source)) return
HibernateFilterUtils.addDomainProxies event.source
if (event.application.isDomainClass(event.source)) {
HibernateFilterUtils.addDomainClassMethods event.source, event.ctx
}
}
}