1 | /** |
---|
2 | * Provides a data service to create base and demo data. |
---|
3 | * Beware that most, if not all, base data is referenced by "Id" throughout the program. |
---|
4 | * This allows changing the text of the 'name' property to something of the same meaning. |
---|
5 | * But be sure to maintain the correct Id during creation, indicated by #1, #2 etc. |
---|
6 | */ |
---|
7 | class CreateDataService { |
---|
8 | |
---|
9 | boolean transactional = false |
---|
10 | |
---|
11 | def personService |
---|
12 | def taskService |
---|
13 | def dateUtilService |
---|
14 | def appConfigService |
---|
15 | def assignedGroupService |
---|
16 | def assignedPersonService |
---|
17 | |
---|
18 | /******************************************* |
---|
19 | Start of Group methods. |
---|
20 | Generally use these methods to create data. |
---|
21 | *******************************************/ |
---|
22 | |
---|
23 | /** |
---|
24 | * Always call this at startup to ensure that we have admin access |
---|
25 | * and that the system pseudo person is available. |
---|
26 | */ |
---|
27 | def ensureSystemAndAdminAccess() { |
---|
28 | if(!Authority.findByAuthority("ROLE_AppAdmin") ) { |
---|
29 | log.warn "ROLE_AppAdmin not found, calling createAdminAuthority()." |
---|
30 | createAdminAuthority() |
---|
31 | } |
---|
32 | if(!Person.findByloginName("system") ) { |
---|
33 | log.warn "LoginName 'system' not found, calling createSystemPerson()." |
---|
34 | createSystemPerson() |
---|
35 | } |
---|
36 | if(!Person.findByloginName("admin") ) { |
---|
37 | log.warn "LoginName 'admin' not found, calling createAdminPerson()." |
---|
38 | createAdminPerson() |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * Create the base data required for the application to function. |
---|
44 | */ |
---|
45 | def createBaseData() { |
---|
46 | |
---|
47 | if(appConfigService.exists("baseDataCreated")) { |
---|
48 | log.error "Base data has already been created, will NOT recreate." |
---|
49 | return false |
---|
50 | } |
---|
51 | |
---|
52 | log.info "Creating base data..." |
---|
53 | |
---|
54 | // Person and Utils |
---|
55 | createBaseAuthorities() |
---|
56 | createBasePersonGroups() |
---|
57 | createBaseDefinitions() |
---|
58 | createBaseUnitsOfMeasure() |
---|
59 | createBasePeriods() |
---|
60 | createBaseSupplierType() |
---|
61 | createBaseManufacturerType() |
---|
62 | |
---|
63 | // Tasks |
---|
64 | createBaseTaskGroups() |
---|
65 | createBaseTaskStatus() |
---|
66 | createBaseTaskPriorities() |
---|
67 | createBaseTaskBudgetStatus() |
---|
68 | createBaseTaskTypes() |
---|
69 | createBaseTaskModificationTypes() |
---|
70 | createBaseEntryTypes() |
---|
71 | |
---|
72 | // Inventory |
---|
73 | createBaseInventoryTypes() |
---|
74 | createBaseInventoryMovementTypes() |
---|
75 | |
---|
76 | // Assets |
---|
77 | createBaseExtenededAttributeTypes() |
---|
78 | createBaseMaintenancePolicies() |
---|
79 | |
---|
80 | // Record that data has been created. |
---|
81 | appConfigService.set("baseDataCreated") |
---|
82 | } |
---|
83 | |
---|
84 | /** |
---|
85 | * Create demo data for some example sites. |
---|
86 | */ |
---|
87 | def createDemoData() { |
---|
88 | |
---|
89 | if(!appConfigService.exists("baseDataCreated")) { |
---|
90 | log.error "Demo data cannot be created until base data has been created." |
---|
91 | return false |
---|
92 | } |
---|
93 | |
---|
94 | if(appConfigService.exists("demoDataCreated")) { |
---|
95 | log.error "Demo data has already been created, will NOT recreate." |
---|
96 | return false |
---|
97 | } |
---|
98 | |
---|
99 | if(appConfigService.exists("demoDataCreationDisabled")) { |
---|
100 | log.error "Demo data creation has been disabled, will NOT create." |
---|
101 | return false |
---|
102 | } |
---|
103 | |
---|
104 | log.info "Creating demo data..." |
---|
105 | |
---|
106 | // Person and Utils |
---|
107 | createDemoPersons() |
---|
108 | createDemoSites() |
---|
109 | createDemoDepartments() |
---|
110 | createDemoSuppliers() |
---|
111 | createDemoManufacturers() |
---|
112 | |
---|
113 | // Tasks |
---|
114 | createDemoTasks() |
---|
115 | createDemoEntries() |
---|
116 | createDemoAssignedGroups() |
---|
117 | createDemoAssignedPersons() |
---|
118 | createDemoTaskRecurringSchedules() |
---|
119 | |
---|
120 | // Inventory |
---|
121 | createDemoInventoryStores() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
122 | createDemoInventoryLocations() |
---|
123 | createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
124 | createDemoInventoryItems() |
---|
125 | |
---|
126 | // Assets |
---|
127 | createDemoLifePlan() |
---|
128 | createDemoTaskProcedure() |
---|
129 | createDemoMaintenanceActions() |
---|
130 | createDemoSections() |
---|
131 | createDemoAssetTree() |
---|
132 | createDemoAssetExtenedAttributes() |
---|
133 | |
---|
134 | // Record that data has been created. |
---|
135 | appConfigService.set("demoDataCreated") |
---|
136 | } |
---|
137 | |
---|
138 | /****************** |
---|
139 | Start of Person |
---|
140 | *******************/ |
---|
141 | |
---|
142 | def createAdminAuthority() { |
---|
143 | def authInstance |
---|
144 | |
---|
145 | authInstance = new Authority(description:"Application Admin, not required for daily use! Grants full admin access to the application.", |
---|
146 | authority:"ROLE_AppAdmin") |
---|
147 | saveAndTest(authInstance) |
---|
148 | } |
---|
149 | |
---|
150 | def createBaseAuthorities() { |
---|
151 | |
---|
152 | def authInstance |
---|
153 | |
---|
154 | authInstance = new Authority(description:"Business manager, grants full management access.", |
---|
155 | authority:"ROLE_Manager") |
---|
156 | saveAndTest(authInstance) |
---|
157 | |
---|
158 | authInstance = new Authority(description:"Application User, all application users need this base role to allow login.", |
---|
159 | authority:"ROLE_AppUser") |
---|
160 | saveAndTest(authInstance) |
---|
161 | } |
---|
162 | |
---|
163 | void createBasePersonGroups() { |
---|
164 | //TypeOfPersonGroup |
---|
165 | def personGroupTypeInstance |
---|
166 | personGroupTypeInstance = new PersonGroupType(name:"Team") |
---|
167 | saveAndTest(personGroupTypeInstance) |
---|
168 | personGroupTypeInstance = new PersonGroupType(name:"Contractor") |
---|
169 | saveAndTest(personGroupTypeInstance) |
---|
170 | personGroupTypeInstance = new PersonGroupType(name:"ProjectTeam") |
---|
171 | saveAndTest(personGroupTypeInstance) |
---|
172 | |
---|
173 | //PersonGroup |
---|
174 | def personGroupInstance |
---|
175 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
176 | name:"Electrical") |
---|
177 | saveAndTest(personGroupInstance) |
---|
178 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
179 | name:"Mechanical") |
---|
180 | saveAndTest(personGroupInstance) |
---|
181 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
182 | name:"Production") |
---|
183 | saveAndTest(personGroupInstance) |
---|
184 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(2), |
---|
185 | name:"Kewl AirCon Guys") |
---|
186 | saveAndTest(personGroupInstance) |
---|
187 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(3), |
---|
188 | name:"gnuMims") |
---|
189 | saveAndTest(personGroupInstance) |
---|
190 | } |
---|
191 | |
---|
192 | def createSystemPerson() { |
---|
193 | //Person |
---|
194 | def passClearText = "pass" |
---|
195 | def passwordEncoded = personService.encodePassword(passClearText) |
---|
196 | def personInstance |
---|
197 | |
---|
198 | //Person #1 |
---|
199 | personInstance = new Person(loginName:"system", |
---|
200 | firstName:"gnuMims", |
---|
201 | lastName:"System", |
---|
202 | description:'''This is a pseudo person that the application uses to insert data. DO NOT |
---|
203 | assign login authorities or change the details of this person.''', |
---|
204 | pass:passClearText, |
---|
205 | password:passwordEncoded, |
---|
206 | email:"system@example.com") |
---|
207 | saveAndTest(personInstance) |
---|
208 | } |
---|
209 | |
---|
210 | def createAdminPerson() { |
---|
211 | //Person |
---|
212 | def passClearText = "pass" |
---|
213 | def passwordEncoded = personService.encodePassword(passClearText) |
---|
214 | def personInstance |
---|
215 | |
---|
216 | //Person #2 |
---|
217 | personInstance = new Person(loginName:"admin", |
---|
218 | firstName:"Admin", |
---|
219 | lastName:"Powers", |
---|
220 | description:'''Every time the application starts it ensures that the 'admin' login name is available. |
---|
221 | DO update the password and other details but keep the login name as 'admin'. ''', |
---|
222 | pass:passClearText, |
---|
223 | password:passwordEncoded, |
---|
224 | email:"admin@example.com") |
---|
225 | saveAndTest(personInstance) |
---|
226 | personInstance.addToAuthorities(Authority.get(1)) |
---|
227 | } |
---|
228 | |
---|
229 | def createBasePersons() { |
---|
230 | } |
---|
231 | |
---|
232 | def createDemoPersons() { |
---|
233 | //Person |
---|
234 | def passClearText = "pass" |
---|
235 | def passwordEncoded = personService.encodePassword(passClearText) |
---|
236 | def personInstance |
---|
237 | |
---|
238 | //Person #1 is system. |
---|
239 | //Person #2 is admin. |
---|
240 | |
---|
241 | //Person #3 |
---|
242 | personInstance = new Person(loginName:"manager", |
---|
243 | firstName:"Demo", |
---|
244 | lastName:"Manager", |
---|
245 | pass:passClearText, |
---|
246 | password:passwordEncoded, |
---|
247 | email:"manager@example.com") |
---|
248 | saveAndTest(personInstance) |
---|
249 | personInstance.addToAuthorities(Authority.get(2)) |
---|
250 | personInstance.addToAuthorities(Authority.get(3)) |
---|
251 | personInstance.addToPersonGroups(PersonGroup.get(5)) |
---|
252 | |
---|
253 | //Person #4 |
---|
254 | personInstance = new Person(loginName:"user", |
---|
255 | firstName:"Demo", |
---|
256 | lastName:"User", |
---|
257 | pass:passClearText, |
---|
258 | password:passwordEncoded, |
---|
259 | email:"user@example.com") |
---|
260 | saveAndTest(personInstance) |
---|
261 | personInstance.addToAuthorities(Authority.get(3)) |
---|
262 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
263 | |
---|
264 | //Person #5 |
---|
265 | personInstance = new Person(loginName:"craig", |
---|
266 | firstName:"Craig", |
---|
267 | lastName:"SuperSparky", |
---|
268 | pass:passClearText, |
---|
269 | password:passwordEncoded, |
---|
270 | email:"user@example.com") |
---|
271 | saveAndTest(personInstance) |
---|
272 | personInstance.addToAuthorities(Authority.get(3)) |
---|
273 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
274 | |
---|
275 | //Person #6 |
---|
276 | personInstance = new Person(loginName:"john", |
---|
277 | firstName:"John", |
---|
278 | lastName:"SuperFitter", |
---|
279 | pass:passClearText, |
---|
280 | password:passwordEncoded, |
---|
281 | email:"user@example.com") |
---|
282 | saveAndTest(personInstance) |
---|
283 | personInstance.addToAuthorities(Authority.get(3)) |
---|
284 | personInstance.addToPersonGroups(PersonGroup.get(2)) |
---|
285 | |
---|
286 | //Person #7 |
---|
287 | personInstance = new Person(loginName:"mann", |
---|
288 | firstName:"Production", |
---|
289 | lastName:"Mann", |
---|
290 | pass:passClearText, |
---|
291 | password:passwordEncoded, |
---|
292 | email:"user@example.com") |
---|
293 | saveAndTest(personInstance) |
---|
294 | personInstance.addToAuthorities(Authority.get(3)) |
---|
295 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
296 | } |
---|
297 | |
---|
298 | /*********************** |
---|
299 | START OF UTILITIES |
---|
300 | ***********************/ |
---|
301 | |
---|
302 | //These can redefined by the site at deployment time. |
---|
303 | /// @todo: build an admin view so that only the value (definition) can be changed. |
---|
304 | def createBaseDefinitions() { |
---|
305 | appConfigService.set("Department Definition", "A department as recongised by accounting.") |
---|
306 | appConfigService.set("Site Definition", "The site, plant or area.") |
---|
307 | appConfigService.set("Section Definition", "A logical grouping of assets as determined by design.") |
---|
308 | appConfigService.set("Asset Definition", "Asset definition") |
---|
309 | appConfigService.set("Asset Sub Item 1 Name", "Asset Sub Item name") |
---|
310 | appConfigService.set("Asset Sub Item 1 Definition", "Asset Sub Item definition") |
---|
311 | appConfigService.set("Asset Sub Item 2 Name", "Asset Sub Item name") |
---|
312 | appConfigService.set("Asset Sub Item 2 Definition", "Asset Sub Item definition") |
---|
313 | appConfigService.set("Asset Sub Item 3 Name", "Asset Sub Item name") |
---|
314 | appConfigService.set("Asset Sub Item 3 Definition", "Asset Sub Item definition") |
---|
315 | appConfigService.set("Asset Sub Item 4 Name", "Asset Sub Item name") |
---|
316 | appConfigService.set("Asset Sub Item 4 Definition", "Asset Sub Item definition") |
---|
317 | } |
---|
318 | |
---|
319 | def createDemoSites() { |
---|
320 | //Site |
---|
321 | def siteInstance |
---|
322 | |
---|
323 | siteInstance = new Site(name: "Creek Mill") |
---|
324 | saveAndTest(siteInstance) |
---|
325 | |
---|
326 | siteInstance = new Site(name: "Jasper Street Depot") |
---|
327 | saveAndTest(siteInstance) |
---|
328 | |
---|
329 | siteInstance = new Site(name: "River Press") |
---|
330 | saveAndTest(siteInstance) |
---|
331 | } |
---|
332 | |
---|
333 | def createDemoDepartments() { |
---|
334 | |
---|
335 | //Department |
---|
336 | def departmentInstance |
---|
337 | |
---|
338 | //Department #1 |
---|
339 | departmentInstance = new Department(name: "Print Centre", |
---|
340 | site: Site.get(1)) |
---|
341 | saveAndTest(departmentInstance) |
---|
342 | |
---|
343 | //Department #2 |
---|
344 | departmentInstance = new Department(name: "Pulp Mill 2", |
---|
345 | site: Site.get(2)) |
---|
346 | saveAndTest(departmentInstance) |
---|
347 | } |
---|
348 | |
---|
349 | def createBaseUnitsOfMeasure() { |
---|
350 | |
---|
351 | //UnitOfMeasure |
---|
352 | def unitOfMeasureInstance |
---|
353 | |
---|
354 | //UnitOfMeasure #1 |
---|
355 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
356 | saveAndTest(unitOfMeasureInstance) |
---|
357 | |
---|
358 | //UnitOfMeasure #2 |
---|
359 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
360 | saveAndTest(unitOfMeasureInstance) |
---|
361 | |
---|
362 | //UnitOfMeasure #3 |
---|
363 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
364 | saveAndTest(unitOfMeasureInstance) |
---|
365 | |
---|
366 | //UnitOfMeasure #4 |
---|
367 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
368 | saveAndTest(unitOfMeasureInstance) |
---|
369 | |
---|
370 | //UnitOfMeasure #5 |
---|
371 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
372 | saveAndTest(unitOfMeasureInstance) |
---|
373 | } |
---|
374 | |
---|
375 | def createBasePeriods() { |
---|
376 | |
---|
377 | //Period |
---|
378 | def periodInstance |
---|
379 | |
---|
380 | //Period #1 |
---|
381 | periodInstance = new Period(period: "Day(s)") |
---|
382 | saveAndTest(periodInstance) |
---|
383 | |
---|
384 | //Period #2 |
---|
385 | periodInstance = new Period(period: "Week(s)") |
---|
386 | saveAndTest(periodInstance) |
---|
387 | |
---|
388 | //Period #3 |
---|
389 | periodInstance = new Period(period: "Month(s)") |
---|
390 | saveAndTest(periodInstance) |
---|
391 | |
---|
392 | //Period #4 |
---|
393 | periodInstance = new Period(period: "Year(s)") |
---|
394 | saveAndTest(periodInstance) |
---|
395 | } |
---|
396 | |
---|
397 | def createBaseSupplierType() { |
---|
398 | |
---|
399 | // SupplierType |
---|
400 | def supplierTypeInstance |
---|
401 | |
---|
402 | // SupplierType #1 |
---|
403 | supplierTypeInstance = new SupplierType(name: "OEM", |
---|
404 | description: "Original equipment supplier") |
---|
405 | saveAndTest(supplierTypeInstance) |
---|
406 | |
---|
407 | // SupplierType #2 |
---|
408 | supplierTypeInstance = new SupplierType(name: "Local", |
---|
409 | description: "Local supplier") |
---|
410 | saveAndTest(supplierTypeInstance) |
---|
411 | } |
---|
412 | |
---|
413 | def createBaseManufacturerType() { |
---|
414 | |
---|
415 | // ManufacturerType |
---|
416 | def manufacturerTypeInstance |
---|
417 | |
---|
418 | // ManufacturerType #1 |
---|
419 | manufacturerTypeInstance = new ManufacturerType(name: "OEM", |
---|
420 | description: "Original equipment manufacturer") |
---|
421 | saveAndTest(manufacturerTypeInstance) |
---|
422 | |
---|
423 | // ManufacturerType #2 |
---|
424 | manufacturerTypeInstance = new ManufacturerType(name: "Alternate", |
---|
425 | description: "Not original equipment manufacturer") |
---|
426 | saveAndTest(manufacturerTypeInstance) |
---|
427 | |
---|
428 | } |
---|
429 | |
---|
430 | def createDemoSuppliers() { |
---|
431 | |
---|
432 | // Supplier |
---|
433 | def supplierInstance |
---|
434 | |
---|
435 | // Supplier #1 |
---|
436 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
437 | supplierType: SupplierType.get(1)) |
---|
438 | saveAndTest(supplierInstance) |
---|
439 | |
---|
440 | // Supplier #2 |
---|
441 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
442 | supplierType: SupplierType.get(2)) |
---|
443 | saveAndTest(supplierInstance) |
---|
444 | } |
---|
445 | |
---|
446 | def createDemoManufacturers() { |
---|
447 | |
---|
448 | // Manufacturer |
---|
449 | def manufacturerInstance |
---|
450 | |
---|
451 | // Manufacturer #1 |
---|
452 | manufacturerInstance = new Manufacturer(name: "OEM Manufacturer", |
---|
453 | manufacturerType: ManufacturerType.get(1)) |
---|
454 | saveAndTest(manufacturerInstance) |
---|
455 | |
---|
456 | // Manufacturer #2 |
---|
457 | manufacturerInstance = new Manufacturer(name: "Laser Cutting Services Pty", |
---|
458 | manufacturerType: ManufacturerType.get(2)) |
---|
459 | saveAndTest(manufacturerInstance) |
---|
460 | } |
---|
461 | |
---|
462 | /********************* |
---|
463 | START OF TASK |
---|
464 | *********************/ |
---|
465 | |
---|
466 | def createBaseTaskGroups() { |
---|
467 | //TaskGroup |
---|
468 | def taskGroupInstance |
---|
469 | |
---|
470 | //TaskGroup #1 |
---|
471 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
472 | description:"Engineering daily activities") |
---|
473 | saveAndTest(taskGroupInstance) |
---|
474 | |
---|
475 | //TaskGroup #2 |
---|
476 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
477 | description:"Production daily activities") |
---|
478 | saveAndTest(taskGroupInstance) |
---|
479 | |
---|
480 | //TaskGroup #3 |
---|
481 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
482 | description:" ") |
---|
483 | saveAndTest(taskGroupInstance) |
---|
484 | } |
---|
485 | |
---|
486 | def createBaseTaskStatus() { |
---|
487 | |
---|
488 | //TaskStatus |
---|
489 | def taskStatusInstance |
---|
490 | |
---|
491 | taskStatusInstance = new TaskStatus(name:"Not Started") // #1 |
---|
492 | saveAndTest(taskStatusInstance) |
---|
493 | |
---|
494 | taskStatusInstance = new TaskStatus(name:"In Progress") // #2 |
---|
495 | saveAndTest(taskStatusInstance) |
---|
496 | |
---|
497 | taskStatusInstance = new TaskStatus(name:"Complete") // #3 |
---|
498 | saveAndTest(taskStatusInstance) |
---|
499 | } |
---|
500 | |
---|
501 | def createBaseTaskPriorities() { |
---|
502 | |
---|
503 | //TaskPriority |
---|
504 | def taskPriorityInstance |
---|
505 | |
---|
506 | taskPriorityInstance = new TaskPriority(name:"Normal") // #1 |
---|
507 | saveAndTest(taskPriorityInstance) |
---|
508 | |
---|
509 | taskPriorityInstance = new TaskPriority(name:"Low") // #2 |
---|
510 | saveAndTest(taskPriorityInstance) |
---|
511 | |
---|
512 | taskPriorityInstance = new TaskPriority(name:"High") // #3 |
---|
513 | saveAndTest(taskPriorityInstance) |
---|
514 | |
---|
515 | taskPriorityInstance = new TaskPriority(name:"Immediate") // #4 |
---|
516 | saveAndTest(taskPriorityInstance) |
---|
517 | } |
---|
518 | |
---|
519 | def createBaseTaskBudgetStatus() { |
---|
520 | |
---|
521 | //TaskBudgetStatus |
---|
522 | def taskBudgetStatusInstance |
---|
523 | |
---|
524 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Unplanned") // #1 |
---|
525 | saveAndTest(taskBudgetStatusInstance) |
---|
526 | |
---|
527 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Planned") // #2 |
---|
528 | saveAndTest(taskBudgetStatusInstance) |
---|
529 | } |
---|
530 | |
---|
531 | def createBaseTaskTypes() { |
---|
532 | |
---|
533 | //TaskType |
---|
534 | def taskTypeInstance |
---|
535 | |
---|
536 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #1 |
---|
537 | saveAndTest(taskTypeInstance) |
---|
538 | |
---|
539 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #2 |
---|
540 | saveAndTest(taskTypeInstance) |
---|
541 | |
---|
542 | taskTypeInstance = new TaskType(name:"Project") // #3 |
---|
543 | saveAndTest(taskTypeInstance) |
---|
544 | |
---|
545 | taskTypeInstance = new TaskType(name:"Turnaround") // #4 |
---|
546 | saveAndTest(taskTypeInstance) |
---|
547 | |
---|
548 | taskTypeInstance = new TaskType(name:"Production Run") // #5 |
---|
549 | saveAndTest(taskTypeInstance) |
---|
550 | } |
---|
551 | |
---|
552 | def createBaseTaskModificationTypes() { |
---|
553 | |
---|
554 | //ModificationType |
---|
555 | def taskModificationTypeInstance |
---|
556 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 |
---|
557 | taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 |
---|
558 | taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 |
---|
559 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 |
---|
560 | taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 |
---|
561 | taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 |
---|
562 | taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 |
---|
563 | taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 |
---|
564 | taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 |
---|
565 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Groups)").save() // #10 |
---|
566 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Persons)").save() // #11 |
---|
567 | } |
---|
568 | |
---|
569 | def createDemoTasks() { |
---|
570 | |
---|
571 | def taskResult |
---|
572 | def p = [:] |
---|
573 | |
---|
574 | //Task #1 |
---|
575 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
576 | taskPriority:TaskPriority.get(2), |
---|
577 | taskType:TaskType.get(1), |
---|
578 | leadPerson:Person.get(2), |
---|
579 | description:"Check specific level sensor", |
---|
580 | comment:"Has been noted as problematic, try recalibrating.", |
---|
581 | targetStartDate: dateUtilService.today] |
---|
582 | |
---|
583 | taskResult = taskService.create(p) |
---|
584 | |
---|
585 | //Task #2 |
---|
586 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
587 | taskPriority:TaskPriority.get(2), |
---|
588 | taskType:TaskType.get(1), |
---|
589 | leadPerson:Person.get(5), |
---|
590 | description:"Some follow-up work", |
---|
591 | comment:"Some help required", |
---|
592 | targetStartDate: dateUtilService.tomorrow, |
---|
593 | parentTask: Task.get(1)] |
---|
594 | |
---|
595 | taskResult = taskService.create(p) |
---|
596 | |
---|
597 | //Task #3 |
---|
598 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
599 | taskPriority:TaskPriority.get(2), |
---|
600 | taskType:TaskType.get(1), |
---|
601 | leadPerson:Person.get(5), |
---|
602 | description:"A Sub Task can be created by setting the Parent Task value", |
---|
603 | comment:"Some help required", |
---|
604 | targetStartDate: dateUtilService.yesterday, |
---|
605 | parentTask: Task.get(1)] |
---|
606 | |
---|
607 | taskResult = taskService.create(p) |
---|
608 | |
---|
609 | //Task #4 |
---|
610 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
611 | taskPriority:TaskPriority.get(2), |
---|
612 | taskType:TaskType.get(1), |
---|
613 | leadPerson:Person.get(4), |
---|
614 | description:"Replace sensor at next opportunity.", |
---|
615 | comment:"Nothing else has worked.", |
---|
616 | targetStartDate: dateUtilService.oneWeekFromNow, |
---|
617 | parentTask: Task.get(1)] |
---|
618 | |
---|
619 | taskResult = taskService.create(p) |
---|
620 | |
---|
621 | //Task #5 |
---|
622 | p = [taskGroup:TaskGroup.findByName("Production Activites"), |
---|
623 | taskPriority:TaskPriority.get(2), |
---|
624 | taskType:TaskType.get(5), |
---|
625 | leadPerson:Person.get(6), |
---|
626 | description:"Production Report", |
---|
627 | comment:"Production report for specific production run or shift", |
---|
628 | targetStartDate: dateUtilService.today - 6] |
---|
629 | |
---|
630 | taskResult = taskService.create(p) |
---|
631 | |
---|
632 | //Task #6 |
---|
633 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
634 | taskPriority:TaskPriority.get(1), |
---|
635 | taskType:TaskType.get(2), |
---|
636 | leadPerson:Person.get(4), |
---|
637 | description:"This is a recurring task", |
---|
638 | comment:"If there is a parent task specified then this is a generated sub task, if there is a recurring schedule specified then this is a parent task.", |
---|
639 | targetStartDate: dateUtilService.today] |
---|
640 | |
---|
641 | taskResult = taskService.create(p) |
---|
642 | } |
---|
643 | |
---|
644 | def createBaseEntryTypes() { |
---|
645 | |
---|
646 | //EntryType |
---|
647 | def entryTypeInstance |
---|
648 | |
---|
649 | entryTypeInstance = new EntryType(name:"Fault") // #1 |
---|
650 | saveAndTest(entryTypeInstance) |
---|
651 | |
---|
652 | entryTypeInstance = new EntryType(name:"Work Done") // #2 |
---|
653 | saveAndTest(entryTypeInstance) |
---|
654 | |
---|
655 | entryTypeInstance = new EntryType(name:"Production Note") // #3 |
---|
656 | saveAndTest(entryTypeInstance) |
---|
657 | |
---|
658 | entryTypeInstance = new EntryType(name:"Work Request") // #4 |
---|
659 | saveAndTest(entryTypeInstance) |
---|
660 | } |
---|
661 | |
---|
662 | def createDemoEntries() { |
---|
663 | |
---|
664 | def entryResult |
---|
665 | def p = [:] |
---|
666 | |
---|
667 | //Entry #1 |
---|
668 | p = [task: Task.get(1), |
---|
669 | entryType: EntryType.get(1), |
---|
670 | comment: "This level sensor is causing us trouble.", |
---|
671 | durationMinute: 20] |
---|
672 | |
---|
673 | entryResult = taskService.createEntry(p) |
---|
674 | |
---|
675 | //Entry #2 |
---|
676 | p = [task: Task.get(1), |
---|
677 | entryType: EntryType.get(2), |
---|
678 | comment: "Cleaned sensor, see how it goes.", |
---|
679 | durationMinute: 30] |
---|
680 | |
---|
681 | entryResult = taskService.createEntry(p) |
---|
682 | |
---|
683 | //Entry #3 |
---|
684 | p = [task: Task.get(1), |
---|
685 | entryType: EntryType.get(2), |
---|
686 | comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", |
---|
687 | durationMinute: 20] |
---|
688 | |
---|
689 | entryResult = taskService.createEntry(p) |
---|
690 | } |
---|
691 | |
---|
692 | def createDemoAssignedGroups() { |
---|
693 | |
---|
694 | def result |
---|
695 | def p = [:] |
---|
696 | |
---|
697 | //AssignedGroup #1 |
---|
698 | p = [personGroup: PersonGroup.get(1), |
---|
699 | task: Task.get(1), |
---|
700 | estimatedHour: 2, |
---|
701 | estimatedMinute: 30] |
---|
702 | result = assignedGroupService.save(p) |
---|
703 | |
---|
704 | //AssignedGroup #2 |
---|
705 | p = [personGroup: PersonGroup.get(2), |
---|
706 | task: Task.get(1), |
---|
707 | estimatedHour: 1, |
---|
708 | estimatedMinute: 0] |
---|
709 | result = assignedGroupService.save(p) |
---|
710 | } |
---|
711 | |
---|
712 | def createDemoAssignedPersons() { |
---|
713 | |
---|
714 | def result |
---|
715 | def p = [:] |
---|
716 | |
---|
717 | //AssignedPerson #1 |
---|
718 | p = [person: Person.get(4), |
---|
719 | task: Task.get(1), |
---|
720 | estimatedHour: 1, |
---|
721 | estimatedMinute: 20] |
---|
722 | result = assignedPersonService.save(p) |
---|
723 | |
---|
724 | //AssignedPerson #2 |
---|
725 | p = [person: Person.get(5), |
---|
726 | task: Task.get(1), |
---|
727 | estimatedHour: 3, |
---|
728 | estimatedMinute: 30] |
---|
729 | result = assignedPersonService.save(p) |
---|
730 | } |
---|
731 | |
---|
732 | def createDemoTaskRecurringSchedules() { |
---|
733 | |
---|
734 | //TaskRecurringSchedule |
---|
735 | def taskRecurringScheduleInstance |
---|
736 | |
---|
737 | //TaskRecurringSchedule #1 |
---|
738 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), |
---|
739 | recurEvery: 1, |
---|
740 | recurPeriod: Period.get(2), |
---|
741 | nextTargetStartDate: dateUtilService.today, |
---|
742 | generateAhead: 1, |
---|
743 | taskDuration: 2, |
---|
744 | taskDurationPeriod: Period.get(1), |
---|
745 | enabled: false) |
---|
746 | saveAndTest(taskRecurringScheduleInstance) |
---|
747 | |
---|
748 | //TaskRecurringSchedule #2 |
---|
749 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6), |
---|
750 | recurEvery: 1, |
---|
751 | recurPeriod: Period.get(1), |
---|
752 | nextTargetStartDate: dateUtilService.today, |
---|
753 | generateAhead: 1, |
---|
754 | taskDuration: 1, |
---|
755 | taskDurationPeriod: Period.get(1), |
---|
756 | enabled: true) |
---|
757 | saveAndTest(taskRecurringScheduleInstance) |
---|
758 | } |
---|
759 | |
---|
760 | /************************* |
---|
761 | START OF INVENTORY |
---|
762 | **************************/ |
---|
763 | |
---|
764 | def createDemoInventoryStores() { |
---|
765 | |
---|
766 | //InventoryStore |
---|
767 | def inventoryStoreInstance |
---|
768 | |
---|
769 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
770 | saveAndTest(inventoryStoreInstance) |
---|
771 | |
---|
772 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
773 | saveAndTest(inventoryStoreInstance) |
---|
774 | } |
---|
775 | |
---|
776 | def createDemoInventoryLocations() { |
---|
777 | |
---|
778 | // InventoryLocation |
---|
779 | def inventoryLocation |
---|
780 | |
---|
781 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
782 | saveAndTest(inventoryLocation) |
---|
783 | |
---|
784 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "C55") |
---|
785 | saveAndTest(inventoryLocation) |
---|
786 | } |
---|
787 | |
---|
788 | def createDemoInventoryGroups() { |
---|
789 | |
---|
790 | //InventoryGroup |
---|
791 | def inventoryGroupInstance |
---|
792 | |
---|
793 | //InventoryGroup #1 |
---|
794 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
795 | saveAndTest(inventoryGroupInstance) |
---|
796 | |
---|
797 | //InventoryGroup #2 |
---|
798 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
799 | saveAndTest(inventoryGroupInstance) |
---|
800 | |
---|
801 | //InventoryGroup #3 |
---|
802 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
803 | saveAndTest(inventoryGroupInstance) |
---|
804 | |
---|
805 | //InventoryGroup #4 |
---|
806 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
807 | saveAndTest(inventoryGroupInstance) |
---|
808 | } |
---|
809 | |
---|
810 | def createBaseInventoryTypes() { |
---|
811 | |
---|
812 | //InventoryType |
---|
813 | def inventoryTypeInstance |
---|
814 | |
---|
815 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
816 | saveAndTest(inventoryTypeInstance) |
---|
817 | |
---|
818 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
819 | saveAndTest(inventoryTypeInstance) |
---|
820 | } |
---|
821 | |
---|
822 | def createBaseInventoryMovementTypes() { |
---|
823 | |
---|
824 | // InventoryMovementType |
---|
825 | def inventoryMovementTypeInstance |
---|
826 | |
---|
827 | // InventoryMovementType #1 |
---|
828 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
829 | incrementsInventory: false) |
---|
830 | saveAndTest(inventoryMovementTypeInstance) |
---|
831 | |
---|
832 | // InventoryMovementType #2 |
---|
833 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
834 | incrementsInventory: true) |
---|
835 | saveAndTest(inventoryMovementTypeInstance) |
---|
836 | |
---|
837 | // InventoryMovementType #3 |
---|
838 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
839 | incrementsInventory: true) |
---|
840 | saveAndTest(inventoryMovementTypeInstance) |
---|
841 | |
---|
842 | // InventoryMovementType #4 |
---|
843 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
844 | incrementsInventory: true) |
---|
845 | saveAndTest(inventoryMovementTypeInstance) |
---|
846 | |
---|
847 | // InventoryMovementType #5 |
---|
848 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
849 | incrementsInventory: false) |
---|
850 | saveAndTest(inventoryMovementTypeInstance) |
---|
851 | } |
---|
852 | |
---|
853 | def createDemoInventoryItems() { |
---|
854 | |
---|
855 | //InventoryItem |
---|
856 | def inventoryItemInstance |
---|
857 | |
---|
858 | //InventoryItem #1 |
---|
859 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
860 | inventoryType: InventoryType.get(1), |
---|
861 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
862 | inventoryLocation: InventoryLocation.get(1), |
---|
863 | name: "Hemp rope", |
---|
864 | description: "Natural hemp rope.", |
---|
865 | unitsInStock: 2, |
---|
866 | reorderPoint: 0) |
---|
867 | saveAndTest(inventoryItemInstance) |
---|
868 | |
---|
869 | //InventoryItem #2 |
---|
870 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
871 | inventoryType: InventoryType.get(1), |
---|
872 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
873 | inventoryLocation: InventoryLocation.get(1), |
---|
874 | name: "Cotton Rope 12mm", |
---|
875 | description: "A soft natural rope made from cotton.", |
---|
876 | alternateItems: InventoryItem.get(1), |
---|
877 | unitsInStock: 2, |
---|
878 | reorderPoint: 0) |
---|
879 | saveAndTest(inventoryItemInstance) |
---|
880 | |
---|
881 | //InventoryItem #3 |
---|
882 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
883 | inventoryType: InventoryType.get(1), |
---|
884 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
885 | inventoryLocation: InventoryLocation.get(2), |
---|
886 | name: "2305-2RS", |
---|
887 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
888 | unitsInStock: 3, |
---|
889 | reorderPoint: 2) |
---|
890 | saveAndTest(inventoryItemInstance) |
---|
891 | |
---|
892 | //InventoryItem #4 |
---|
893 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
894 | inventoryType: InventoryType.get(1), |
---|
895 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
896 | inventoryLocation: InventoryLocation.get(2), |
---|
897 | name: "L1592-K10", |
---|
898 | description: "10kW contactor", |
---|
899 | unitsInStock: 4, |
---|
900 | reorderPoint: 0) |
---|
901 | saveAndTest(inventoryItemInstance) |
---|
902 | |
---|
903 | //InventoryItem #5 |
---|
904 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
905 | inventoryType: InventoryType.get(1), |
---|
906 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
907 | inventoryLocation: InventoryLocation.get(2), |
---|
908 | name: "6205-ZZ", |
---|
909 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
910 | unitsInStock: 5, |
---|
911 | reorderPoint: 2) |
---|
912 | saveAndTest(inventoryItemInstance) |
---|
913 | } |
---|
914 | |
---|
915 | /******************* |
---|
916 | START OF ASSET |
---|
917 | *******************/ |
---|
918 | |
---|
919 | def createDemoLifePlan() { |
---|
920 | |
---|
921 | //LifePlan |
---|
922 | def lifeplanInstance |
---|
923 | |
---|
924 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
925 | saveAndTest(lifeplanInstance) |
---|
926 | } |
---|
927 | |
---|
928 | def createBaseExtenededAttributeTypes() { |
---|
929 | |
---|
930 | //ExtendedAttributeType |
---|
931 | def extendedAttributeTypeInstance |
---|
932 | |
---|
933 | //ExtendedAttributeType #1 |
---|
934 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Model Number") |
---|
935 | saveAndTest(extendedAttributeTypeInstance) |
---|
936 | |
---|
937 | //ExtendedAttributeType #2 |
---|
938 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Purchase Cost") |
---|
939 | saveAndTest(extendedAttributeTypeInstance) |
---|
940 | |
---|
941 | //ExtendedAttributeType #3 |
---|
942 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Serial Number") |
---|
943 | saveAndTest(extendedAttributeTypeInstance) |
---|
944 | |
---|
945 | //ExtendedAttributeType #4 |
---|
946 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufactured Date") |
---|
947 | saveAndTest(extendedAttributeTypeInstance) |
---|
948 | |
---|
949 | //ExtendedAttributeType #5 |
---|
950 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Location Description") |
---|
951 | saveAndTest(extendedAttributeTypeInstance) |
---|
952 | |
---|
953 | //ExtendedAttributeType #6 |
---|
954 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Centre") |
---|
955 | saveAndTest(extendedAttributeTypeInstance) |
---|
956 | |
---|
957 | //ExtendedAttributeType #7 |
---|
958 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Code") |
---|
959 | saveAndTest(extendedAttributeTypeInstance) |
---|
960 | |
---|
961 | //ExtendedAttributeType #8 |
---|
962 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufacturer's Number") |
---|
963 | saveAndTest(extendedAttributeTypeInstance) |
---|
964 | |
---|
965 | //ExtendedAttributeType #9 |
---|
966 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Inventory Number") |
---|
967 | saveAndTest(extendedAttributeTypeInstance) |
---|
968 | } |
---|
969 | |
---|
970 | def createBaseMaintenancePolicies() { |
---|
971 | |
---|
972 | //MaintenancePolicy |
---|
973 | def maintenancePolicyInstance |
---|
974 | |
---|
975 | //MaintenancePolicy #1 |
---|
976 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
977 | saveAndTest(maintenancePolicyInstance) |
---|
978 | |
---|
979 | //MaintenancePolicy #2 |
---|
980 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
981 | saveAndTest(maintenancePolicyInstance) |
---|
982 | |
---|
983 | //MaintenancePolicy #3 |
---|
984 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
985 | saveAndTest(maintenancePolicyInstance) |
---|
986 | |
---|
987 | //MaintenancePolicy #4 |
---|
988 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
989 | saveAndTest(maintenancePolicyInstance) |
---|
990 | |
---|
991 | //MaintenancePolicy #5 |
---|
992 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
993 | saveAndTest(maintenancePolicyInstance) |
---|
994 | |
---|
995 | //MaintenancePolicy #6 |
---|
996 | maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement") |
---|
997 | saveAndTest(maintenancePolicyInstance) |
---|
998 | |
---|
999 | //MaintenancePolicy #7 |
---|
1000 | maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test") |
---|
1001 | saveAndTest(maintenancePolicyInstance) |
---|
1002 | } |
---|
1003 | |
---|
1004 | def createDemoTaskProcedure() { |
---|
1005 | |
---|
1006 | //TaskProcedure |
---|
1007 | def taskProcedureInstance |
---|
1008 | |
---|
1009 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
1010 | saveAndTest(taskProcedureInstance) |
---|
1011 | taskProcedureInstance.addToTasks(Task.get(1)) |
---|
1012 | } |
---|
1013 | |
---|
1014 | def createDemoMaintenanceActions() { |
---|
1015 | |
---|
1016 | //MaintenanceAction |
---|
1017 | def maintenanceActionInstance |
---|
1018 | |
---|
1019 | //MaintenanceAction #1 |
---|
1020 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
1021 | procedureStepNumber: 1, |
---|
1022 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
1023 | taskProcedure: TaskProcedure.get(1)) |
---|
1024 | saveAndTest(maintenanceActionInstance) |
---|
1025 | |
---|
1026 | //MaintenanceAction #2 |
---|
1027 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
1028 | procedureStepNumber: 2, |
---|
1029 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
1030 | taskProcedure: TaskProcedure.get(1)) |
---|
1031 | saveAndTest(maintenanceActionInstance) |
---|
1032 | |
---|
1033 | //MaintenanceAction #3 |
---|
1034 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
1035 | procedureStepNumber: 3, |
---|
1036 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
1037 | taskProcedure: TaskProcedure.get(1)) |
---|
1038 | saveAndTest(maintenanceActionInstance) |
---|
1039 | } |
---|
1040 | |
---|
1041 | def createDemoSections() { |
---|
1042 | |
---|
1043 | //Section |
---|
1044 | def sectionInstance |
---|
1045 | |
---|
1046 | //Section #1 |
---|
1047 | sectionInstance = new Section(name: "Press Section", |
---|
1048 | site: Site.get(3), |
---|
1049 | department: Department.get(1)) |
---|
1050 | saveAndTest(sectionInstance) |
---|
1051 | |
---|
1052 | //Section #2 |
---|
1053 | sectionInstance = new Section(name: "RO System", |
---|
1054 | site: Site.get(1), |
---|
1055 | department: Department.get(2)) |
---|
1056 | saveAndTest(sectionInstance) |
---|
1057 | |
---|
1058 | //Section #3 |
---|
1059 | sectionInstance = new Section(name: "Auxiliary Section", |
---|
1060 | site: Site.get(1), |
---|
1061 | department: Department.get(1)) |
---|
1062 | saveAndTest(sectionInstance) |
---|
1063 | } |
---|
1064 | |
---|
1065 | def createDemoAssetTree() { |
---|
1066 | |
---|
1067 | //Asset |
---|
1068 | def assetInstance |
---|
1069 | |
---|
1070 | //Asset #1 |
---|
1071 | def assetInstance1 = new Asset(name: "Print Tower 22", |
---|
1072 | section: Section.get(1)) |
---|
1073 | saveAndTest(assetInstance1) |
---|
1074 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
1075 | |
---|
1076 | //Asset #2 |
---|
1077 | def assetInstance2 = new Asset(name: "Print Tower 21", |
---|
1078 | section: Section.get(1)) |
---|
1079 | saveAndTest(assetInstance2) |
---|
1080 | |
---|
1081 | //Asset #3 |
---|
1082 | def assetInstance3 = new Asset(name: "Print Tower 23", |
---|
1083 | section: Section.get(1)) |
---|
1084 | saveAndTest(assetInstance3) |
---|
1085 | |
---|
1086 | //Asset #4 |
---|
1087 | def assetInstance4 = new Asset(name: "RO 1", |
---|
1088 | section: Section.get(2)) |
---|
1089 | saveAndTest(assetInstance4) |
---|
1090 | |
---|
1091 | //AssetSubItem |
---|
1092 | def assetSubItemInstance |
---|
1093 | |
---|
1094 | //AssetSubItem #1 Level1 |
---|
1095 | def assetSubItemInstance1 = new AssetSubItem(name: "Print Tower") |
---|
1096 | saveAndTest(assetSubItemInstance1) |
---|
1097 | |
---|
1098 | // Add assetSubItemInstance1 to some assets. |
---|
1099 | assetInstance1.addToAssetSubItems(assetSubItemInstance1) |
---|
1100 | assetInstance2.addToAssetSubItems(assetSubItemInstance1) |
---|
1101 | assetInstance3.addToAssetSubItems(assetSubItemInstance1) |
---|
1102 | |
---|
1103 | //AssetSubItem #2 Level1 |
---|
1104 | def assetSubItemInstance2 = new AssetSubItem(name: "Reactor Tower") |
---|
1105 | saveAndTest(assetSubItemInstance2) |
---|
1106 | |
---|
1107 | // Add assetSubItemInstance2 to some assets. |
---|
1108 | assetInstance4.addToAssetSubItems(assetSubItemInstance2) |
---|
1109 | |
---|
1110 | //AssetSubItem #3 Level1 |
---|
1111 | def assetSubItemInstance3 = new AssetSubItem(name: "Blower Tower") |
---|
1112 | saveAndTest(assetSubItemInstance3) |
---|
1113 | |
---|
1114 | // Add assetSubItemInstance3 to some assets. |
---|
1115 | assetInstance4.addToAssetSubItems(assetSubItemInstance3) |
---|
1116 | |
---|
1117 | //AssetSubItem #4 Level2 |
---|
1118 | assetSubItemInstance = new AssetSubItem(name: "Print Unit Upper", |
---|
1119 | parentItem: AssetSubItem.get(1)) |
---|
1120 | saveAndTest(assetSubItemInstance) |
---|
1121 | |
---|
1122 | //AssetSubItem #5 Level3 |
---|
1123 | assetSubItemInstance = new AssetSubItem(name: "Agitator", |
---|
1124 | parentItem: AssetSubItem.get(2)) |
---|
1125 | saveAndTest(assetSubItemInstance) |
---|
1126 | |
---|
1127 | //AssetSubItem #6 Level2 |
---|
1128 | assetSubItemInstance = new AssetSubItem(name: "Scraper", |
---|
1129 | parentItem: AssetSubItem.get(3)) |
---|
1130 | saveAndTest(assetSubItemInstance) |
---|
1131 | |
---|
1132 | //AssetSubItem #7 Level3 |
---|
1133 | assetSubItemInstance = new AssetSubItem(name: "Motor", |
---|
1134 | parentItem: AssetSubItem.get(5)) |
---|
1135 | saveAndTest(assetSubItemInstance) |
---|
1136 | |
---|
1137 | //AssetSubItem #8 Level3 |
---|
1138 | assetSubItemInstance = new AssetSubItem(name: "Gearbox", |
---|
1139 | parentItem: AssetSubItem.get(5)) |
---|
1140 | saveAndTest(assetSubItemInstance) |
---|
1141 | |
---|
1142 | //AssetSubItem #9 Level4 |
---|
1143 | assetSubItemInstance = new AssetSubItem(name: "DS Bearing", |
---|
1144 | parentItem: AssetSubItem.get(7)) |
---|
1145 | saveAndTest(assetSubItemInstance) |
---|
1146 | |
---|
1147 | //AssetSubItem #10 Level4 |
---|
1148 | assetSubItemInstance = new AssetSubItem(name: "NDS Bearing", |
---|
1149 | parentItem: AssetSubItem.get(7)) |
---|
1150 | saveAndTest(assetSubItemInstance) |
---|
1151 | } // createDemoAssetTree() |
---|
1152 | |
---|
1153 | def createDemoAssetExtenedAttributes() { |
---|
1154 | |
---|
1155 | //AssetExtendedAttribute |
---|
1156 | def assetExtendedAttributeInstance |
---|
1157 | |
---|
1158 | //AssetExtendedAttribute #1 |
---|
1159 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
1160 | asset: Asset.get(1), |
---|
1161 | extendedAttributeType: ExtendedAttributeType.get(1)) |
---|
1162 | saveAndTest(assetExtendedAttributeInstance) |
---|
1163 | |
---|
1164 | //AssetExtendedAttribute #2 |
---|
1165 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
1166 | asset: Asset.get(1), |
---|
1167 | extendedAttributeType: ExtendedAttributeType.get(5)) |
---|
1168 | saveAndTest(assetExtendedAttributeInstance) |
---|
1169 | } |
---|
1170 | |
---|
1171 | |
---|
1172 | /**************************************** |
---|
1173 | Call this function instead of .save() |
---|
1174 | *****************************************/ |
---|
1175 | private boolean saveAndTest(object) { |
---|
1176 | if(!object.save()) { |
---|
1177 | // DemoDataSuccessful = false |
---|
1178 | log.error "'${object}' failed to save!" |
---|
1179 | log.error object.errors |
---|
1180 | return false |
---|
1181 | } |
---|
1182 | return true |
---|
1183 | } |
---|
1184 | } |
---|