-
Notifications
You must be signed in to change notification settings - Fork 11
/
GrailsflowGrailsPlugin.groovy
290 lines (249 loc) · 11 KB
/
GrailsflowGrailsPlugin.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
import com.jcatalog.grailsflow.model.process.FlowStatus
import com.jcatalog.grailsflow.grails.ListFactoryBean
import com.jcatalog.grailsflow.search.DefaultSearchParameter
import com.jcatalog.grailsflow.search.DateSearchParameter
import com.jcatalog.grailsflow.search.DefaultDisplayParameter
import com.jcatalog.grailsflow.status.NodeStatusEnum
import com.jcatalog.grailsflow.status.ProcessStatusEnum
import com.jcatalog.grailsflow.scheduling.triggers.ConfigurableSimpleTrigger
class GrailsflowGrailsPlugin {
def version = "1.10.1-SNAPSHOT"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "2.3 > *"
def dependsOn = [quartz: "1.0.1 > *"]
def pluginExcludes = [
"src/docs/**"
]
def author = "OpusCapita Software GmbH"
def authorEmail = "[email protected]"
def title = "Grailsflow"
def description = "GrailsFlow is an open source Workflow and Process Engine."
// URL to the plugin's documentation
def documentation = "https://github.com/OpusCapita/grailsflow-core-plugin"
def license = "APACHE"
def organization = [ name: "OpusCapita Software GmbH", url: "https://www.opuscapita.com/" ]
def developers = [
[ name: "July Antonicheva", email: "[email protected]" ]
]
def issueManagement = [ system: "JIRA", url: "http://jira.jcatalog.com/browse/GFW" ]
def scm = [ url: "https://github.com/OpusCapita/grailsflow-core-plugin" ]
def doWithSpring = {
ConfigurableSimpleTrigger.metaClass.'static'.getGrailsApplication = { -> application }
def clusterName = (application.config.grailsflow.clusterName instanceof Closure) ?
application.config.grailsflow.clusterName() : application.config.grailsflow.clusterName
if (!clusterName) {
application.config.grailsflow.clusterName = "gfw_${new Date().time}_${new Random().nextInt(1000000)}"
}
// format patterns
defaultLocale(java.lang.String, "en")
// default workarea configuration
workareaPathProvider(com.jcatalog.grailsflow.workarea.GrailsflowPathProvider) {
resourcesPath = "workarea"
resourcesUrl = "/workarea"
}
// default scripts configuration
scriptsProvider(com.jcatalog.grailsflow.workarea.GrailsflowWorkareaScriptsProvider) {
workareaPathProvider = ref('workareaPathProvider')
}
appExternalID(java.lang.String, "grailsflow")
processesPath(java.lang.String, "processes")
actionsPath(java.lang.String, "actions")
documentsPath(java.lang.String, "documents")
callbacksPath(java.lang.String, "callbacks")
// default UI configuration
maxResultSize(java.lang.Integer, "20")
// default configuration for threads quantity (threads that can be running concurrently)
maxThreadsQuantity(java.lang.Integer, "7")
// default configuration for quantity of restricted processes that used in SQL
// 'in' clause
maxRestrictedProcesses(java.lang.Integer, "2000")
// default configuration for quantity of loaded processes in removing service
maxLoadedProcesses(java.lang.Integer, "200")
// default security configuration
securityHelper(com.jcatalog.grailsflow.security.GrailsflowSecurityHelper)
usersProvider(com.jcatalog.grailsflow.security.GrailsflowUsersProvider)
rolesProvider(com.jcatalog.grailsflow.security.GrailsflowRolesProvider)
groupsProvider(com.jcatalog.grailsflow.security.GrailsflowGroupsProvider)
// default asynchronous configuration
clientExecutor(com.jcatalog.grailsflow.client.GrailsflowHTTPClientExecutor)
// Grailsflow engine configuration
actionFactory(com.jcatalog.grailsflow.actions.GrailsflowActionFactory) {
actionsPath = ref('actionsPath')
scriptsProvider = ref('scriptsProvider')
}
worklistProvider(com.jcatalog.grailsflow.worklist.WorklistProvider) {
appExternalID = ref('appExternalID')
}
processProvider(com.jcatalog.grailsflow.process.ProcessProvider) {
appExternalID = ref('appExternalID')
}
processScriptProvider(com.jcatalog.grailsflow.process.script.GrailsflowProcessScriptProvider) {
scriptsProvider = ref('scriptsProvider')
processesPath = ref('processesPath')
}
cacheManager(com.jcatalog.grailsflow.cache.SimpleCacheManager)
processFactory(com.jcatalog.grailsflow.engine.GrailsflowCachingProcessFactory) {
processScriptProvider = ref('processScriptProvider')
cacheManager = ref('cacheManager')
}
nodeExecutor(com.jcatalog.grailsflow.engine.execution.NodeExecutor) {
actionFactory = ref('actionFactory')
}
// validation
processDefValidator(com.jcatalog.grailsflow.validation.DefaultProcessDefValidator)
processClassValidator(com.jcatalog.grailsflow.validation.DefaultProcessClassValidator)
bean(org.springframework.web.multipart.commons.CommonsMultipartResolver) {
maxUploadSize(1000000)
}
// Allows worklist filtering
// NOTE: if set to TRUE - it can cause problems with performance
// in case of large amount of items.
isWorklistFilterAvailable(java.lang.Boolean, Boolean.TRUE)
// processListColumns UI
processTypeSearchProperty(DefaultSearchParameter) {
name = "type"
searchTemplate = "/processList/search/type"
}
processStatusSearchProperty(DefaultSearchParameter) {
name = "status"
searchTemplate = "/processList/search/status"
}
startedFromSearchProperty(DateSearchParameter) {
name = "startedFrom"
searchTemplate = "/processList/search/date"
}
userSearchProperty(DefaultSearchParameter) {
name = "startUser"
}
finishedFromSearchProperty(DateSearchParameter) {
name = "finishedFrom"
searchTemplate = "/processList/search/date"
}
processListSearchParameters(ListFactoryBean) {
items = [ ref('processTypeSearchProperty'),
ref('processStatusSearchProperty'),
ref('startedFromSearchProperty'), ref('userSearchProperty'),
ref('finishedFromSearchProperty')
]
}
processTypeDisplayProperty(DefaultDisplayParameter) {
name = "type"
displayTemplate = "/processList/display/type"
}
processStatusDisplayProperty(DefaultDisplayParameter) {
name = "status.statusID"
displayProperty = "status"
displayTemplate = "/processList/display/status"
}
createdOnDisplayProperty(DefaultDisplayParameter) {
name = "createdOn"
displayProperty = "createdOn"
displayTemplate = "/processList/display/dateTime"
}
createdByDisplayProperty(DefaultDisplayParameter) {
name = "createdBy"
displayProperty = "createdBy"
}
activeNodesDisplayProperty(DefaultDisplayParameter) {
name = "activeNodes"
sortable = false
displayTemplate = "/processList/display/activeNodes"
}
finishedOnDisplayProperty(DefaultDisplayParameter) {
name = "finishedOn"
displayProperty = "finishedOn"
displayTemplate = "/processList/display/dateTime"
}
processListDisplayParameters(ListFactoryBean) {
items = [ ref('processTypeDisplayProperty'),
ref('processStatusDisplayProperty'),
ref('createdOnDisplayProperty'), ref('createdByDisplayProperty'),
ref("activeNodesDisplayProperty"),
ref('finishedOnDisplayProperty')
]
}
nodeWorklistColumn(DefaultDisplayParameter) {
name = "nodeID"
displayTemplate = "/worklist/display/node"
}
externalURLWorklistColumn(DefaultDisplayParameter) {
name = "externalUrl"
sortable = false
displayTemplate = "/worklist/display/externalUrl"
}
processTypeWorklistColumn(DefaultDisplayParameter) {
name = "processType"
displayProperty = "process"
sortable = false
displayTemplate = "/worklist/display/processType"
}
callerWorklistColumn(DefaultDisplayParameter) {
name = "caller"
displayProperty = "caller"
}
startedOnWorklistColumn(DefaultDisplayParameter) {
name = "startedOn"
displayProperty = "startedOn"
displayTemplate = "/worklist/display/dateTime"
}
dueOnWorklistColumn(DefaultDisplayParameter) {
name = "dueOn"
displayProperty = "dueOn"
displayTemplate = "/worklist/display/dateTime"
}
worklistDisplayParameters(ListFactoryBean) {
items = [ ref('nodeWorklistColumn'),
ref('externalURLWorklistColumn'),
ref('processTypeWorklistColumn'),
ref('callerWorklistColumn'),
ref('startedOnWorklistColumn'),
ref('dueOnWorklistColumn')
]
}
// Extensions
eventEmailProcessor(com.jcatalog.grailsflow.extension.email.GrailsflowEventEmailProcessor) {
processManagerService = ref('processManagerService')
}
if(!application.config.grails.converters.json.circular.reference.behaviour) {
def jsonConverterConfig = new ConfigObject()
jsonConverterConfig.grails.converters.json.circular.reference.behaviour = "INSERT_NULL"
application.config.merge(jsonConverterConfig)
application.configChanged()
}
}
def doWithApplicationContext = { applicationContext ->
def sessionFactory = applicationContext.sessionFactory
FlowStatus.withTransaction {
// Insert process statuses into DB if they're missing
ProcessStatusEnum.values()?.each() {
def statusID = it.value()
if (!FlowStatus.findByStatusID(statusID)) {
def status = new FlowStatus(statusID: statusID, description: statusID, isFinal: it.isFinal())
status.save()
}
}
// Insert node statuses into DB if they're missing
NodeStatusEnum.values()?.each() {
def statusID = it.value()
if (!FlowStatus.findByStatusID(statusID)) {
def status = new FlowStatus(statusID: statusID, description: statusID, isFinal: it.isFinal())
status.save()
}
}
}
}
def doWithWebDescriptor = { xml ->
// TODO Implement additions to web.xml (optional)
}
def doWithDynamicMethods = { ctx ->
// TODO Implement registering dynamic methods to classes (optional)
}
def onChange = { event ->
// TODO Implement code that is executed when this class plugin class is changed
// the event contains: event.application and event.applicationContext objects
}
def onApplicationChange = { event ->
// TODO Implement code that is executed when any class in a GrailsApplication changes
// the event contain: event.source, event.application and event.applicationContext objects
}
}