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