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: "Creek Mill") |
---|
381 | saveAndTest(siteInstance) |
---|
382 | |
---|
383 | siteInstance = new Site(name: "Jasper Street Depot") |
---|
384 | saveAndTest(siteInstance) |
---|
385 | |
---|
386 | siteInstance = new Site(name: "River Press") |
---|
387 | saveAndTest(siteInstance) |
---|
388 | } |
---|
389 | |
---|
390 | def createDemoDepartments() { |
---|
391 | |
---|
392 | //Department |
---|
393 | def departmentInstance |
---|
394 | |
---|
395 | //Department #1 |
---|
396 | departmentInstance = new Department(name: "Print Centre", |
---|
397 | site: Site.get(1)) |
---|
398 | saveAndTest(departmentInstance) |
---|
399 | |
---|
400 | //Department #2 |
---|
401 | departmentInstance = new Department(name: "Pulp Mill 2", |
---|
402 | site: Site.get(2)) |
---|
403 | saveAndTest(departmentInstance) |
---|
404 | } |
---|
405 | |
---|
406 | def createBaseUnitsOfMeasure() { |
---|
407 | |
---|
408 | //UnitOfMeasure |
---|
409 | def unitOfMeasureInstance |
---|
410 | |
---|
411 | //UnitOfMeasure #1 |
---|
412 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
413 | saveAndTest(unitOfMeasureInstance) |
---|
414 | |
---|
415 | //UnitOfMeasure #2 |
---|
416 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
417 | saveAndTest(unitOfMeasureInstance) |
---|
418 | |
---|
419 | //UnitOfMeasure #3 |
---|
420 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
421 | saveAndTest(unitOfMeasureInstance) |
---|
422 | |
---|
423 | //UnitOfMeasure #4 |
---|
424 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
425 | saveAndTest(unitOfMeasureInstance) |
---|
426 | |
---|
427 | //UnitOfMeasure #5 |
---|
428 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
429 | saveAndTest(unitOfMeasureInstance) |
---|
430 | } |
---|
431 | |
---|
432 | def createBasePeriods() { |
---|
433 | |
---|
434 | //Period |
---|
435 | def periodInstance |
---|
436 | |
---|
437 | //Period #1 |
---|
438 | periodInstance = new Period(period: "Day(s)") |
---|
439 | saveAndTest(periodInstance) |
---|
440 | |
---|
441 | //Period #2 |
---|
442 | periodInstance = new Period(period: "Week(s)") |
---|
443 | saveAndTest(periodInstance) |
---|
444 | |
---|
445 | //Period #3 |
---|
446 | periodInstance = new Period(period: "Month(s)") |
---|
447 | saveAndTest(periodInstance) |
---|
448 | |
---|
449 | //Period #4 |
---|
450 | periodInstance = new Period(period: "Year(s)") |
---|
451 | saveAndTest(periodInstance) |
---|
452 | } |
---|
453 | |
---|
454 | def createBaseSupplierType() { |
---|
455 | |
---|
456 | // SupplierType |
---|
457 | def supplierTypeInstance |
---|
458 | |
---|
459 | // SupplierType #1 |
---|
460 | supplierTypeInstance = new SupplierType(name: "OEM", |
---|
461 | description: "Original equipment supplier") |
---|
462 | saveAndTest(supplierTypeInstance) |
---|
463 | |
---|
464 | // SupplierType #2 |
---|
465 | supplierTypeInstance = new SupplierType(name: "Local", |
---|
466 | description: "Local supplier") |
---|
467 | saveAndTest(supplierTypeInstance) |
---|
468 | } |
---|
469 | |
---|
470 | def createBaseManufacturerType() { |
---|
471 | |
---|
472 | // ManufacturerType |
---|
473 | def manufacturerTypeInstance |
---|
474 | |
---|
475 | // ManufacturerType #1 |
---|
476 | manufacturerTypeInstance = new ManufacturerType(name: "OEM", |
---|
477 | description: "Original equipment manufacturer") |
---|
478 | saveAndTest(manufacturerTypeInstance) |
---|
479 | |
---|
480 | // ManufacturerType #2 |
---|
481 | manufacturerTypeInstance = new ManufacturerType(name: "Alternate", |
---|
482 | description: "Not original equipment manufacturer") |
---|
483 | saveAndTest(manufacturerTypeInstance) |
---|
484 | |
---|
485 | } |
---|
486 | |
---|
487 | def createDemoSuppliers() { |
---|
488 | |
---|
489 | // Supplier |
---|
490 | def supplierInstance |
---|
491 | |
---|
492 | // Supplier #1 |
---|
493 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
494 | supplierType: SupplierType.get(1)) |
---|
495 | saveAndTest(supplierInstance) |
---|
496 | |
---|
497 | // Supplier #2 |
---|
498 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
499 | supplierType: SupplierType.get(2)) |
---|
500 | saveAndTest(supplierInstance) |
---|
501 | } |
---|
502 | |
---|
503 | def createDemoManufacturers() { |
---|
504 | |
---|
505 | // Manufacturer |
---|
506 | def manufacturerInstance |
---|
507 | |
---|
508 | // Manufacturer #1 |
---|
509 | manufacturerInstance = new Manufacturer(name: "OEM Manufacturer", |
---|
510 | manufacturerType: ManufacturerType.get(1)) |
---|
511 | saveAndTest(manufacturerInstance) |
---|
512 | |
---|
513 | // Manufacturer #2 |
---|
514 | manufacturerInstance = new Manufacturer(name: "Laser Cutting Services Pty", |
---|
515 | manufacturerType: ManufacturerType.get(2)) |
---|
516 | saveAndTest(manufacturerInstance) |
---|
517 | } |
---|
518 | |
---|
519 | /********************* |
---|
520 | START OF TASK |
---|
521 | *********************/ |
---|
522 | |
---|
523 | def createBaseTaskGroups() { |
---|
524 | //TaskGroup |
---|
525 | def taskGroupInstance |
---|
526 | |
---|
527 | //TaskGroup #1 |
---|
528 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
529 | description:"Engineering daily activities") |
---|
530 | saveAndTest(taskGroupInstance) |
---|
531 | |
---|
532 | //TaskGroup #2 |
---|
533 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
534 | description:"Production daily activities") |
---|
535 | saveAndTest(taskGroupInstance) |
---|
536 | |
---|
537 | //TaskGroup #3 |
---|
538 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
539 | description:" ") |
---|
540 | saveAndTest(taskGroupInstance) |
---|
541 | } |
---|
542 | |
---|
543 | def createBaseTaskStatus() { |
---|
544 | |
---|
545 | //TaskStatus |
---|
546 | def taskStatusInstance |
---|
547 | |
---|
548 | taskStatusInstance = new TaskStatus(name:"Not Started") // #1 |
---|
549 | saveAndTest(taskStatusInstance) |
---|
550 | |
---|
551 | taskStatusInstance = new TaskStatus(name:"In Progress") // #2 |
---|
552 | saveAndTest(taskStatusInstance) |
---|
553 | |
---|
554 | taskStatusInstance = new TaskStatus(name:"Complete") // #3 |
---|
555 | saveAndTest(taskStatusInstance) |
---|
556 | } |
---|
557 | |
---|
558 | def createBaseTaskPriorities() { |
---|
559 | |
---|
560 | //TaskPriority |
---|
561 | def taskPriorityInstance |
---|
562 | |
---|
563 | taskPriorityInstance = new TaskPriority(name:"Normal") // #1 |
---|
564 | saveAndTest(taskPriorityInstance) |
---|
565 | |
---|
566 | taskPriorityInstance = new TaskPriority(name:"Low") // #2 |
---|
567 | saveAndTest(taskPriorityInstance) |
---|
568 | |
---|
569 | taskPriorityInstance = new TaskPriority(name:"High") // #3 |
---|
570 | saveAndTest(taskPriorityInstance) |
---|
571 | |
---|
572 | taskPriorityInstance = new TaskPriority(name:"Immediate") // #4 |
---|
573 | saveAndTest(taskPriorityInstance) |
---|
574 | } |
---|
575 | |
---|
576 | def createBaseTaskBudgetStatus() { |
---|
577 | |
---|
578 | //TaskBudgetStatus |
---|
579 | def taskBudgetStatusInstance |
---|
580 | |
---|
581 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Unplanned") // #1 |
---|
582 | saveAndTest(taskBudgetStatusInstance) |
---|
583 | |
---|
584 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Planned") // #2 |
---|
585 | saveAndTest(taskBudgetStatusInstance) |
---|
586 | } |
---|
587 | |
---|
588 | def createBaseTaskTypes() { |
---|
589 | |
---|
590 | //TaskType |
---|
591 | def taskTypeInstance |
---|
592 | |
---|
593 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #1 |
---|
594 | saveAndTest(taskTypeInstance) |
---|
595 | |
---|
596 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #2 |
---|
597 | saveAndTest(taskTypeInstance) |
---|
598 | |
---|
599 | taskTypeInstance = new TaskType(name:"Project") // #3 |
---|
600 | saveAndTest(taskTypeInstance) |
---|
601 | |
---|
602 | taskTypeInstance = new TaskType(name:"Turnaround") // #4 |
---|
603 | saveAndTest(taskTypeInstance) |
---|
604 | |
---|
605 | taskTypeInstance = new TaskType(name:"Production Run") // #5 |
---|
606 | saveAndTest(taskTypeInstance) |
---|
607 | } |
---|
608 | |
---|
609 | def createBaseTaskModificationTypes() { |
---|
610 | |
---|
611 | //ModificationType |
---|
612 | def taskModificationTypeInstance |
---|
613 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 |
---|
614 | taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 |
---|
615 | taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 |
---|
616 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 |
---|
617 | taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 |
---|
618 | taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 |
---|
619 | taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 |
---|
620 | taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 |
---|
621 | taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 |
---|
622 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Groups)").save() // #10 |
---|
623 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Persons)").save() // #11 |
---|
624 | } |
---|
625 | |
---|
626 | def createDemoTasks() { |
---|
627 | |
---|
628 | def taskResult |
---|
629 | def p = [:] |
---|
630 | |
---|
631 | //Task #1 |
---|
632 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
633 | taskPriority:TaskPriority.get(2), |
---|
634 | taskType:TaskType.get(1), |
---|
635 | leadPerson:Person.get(2), |
---|
636 | description:"Check specific level sensor", |
---|
637 | comment:"Has been noted as problematic, try recalibrating.", |
---|
638 | targetStartDate: dateUtilService.today] |
---|
639 | |
---|
640 | taskResult = taskService.create(p) |
---|
641 | |
---|
642 | //Task #2 |
---|
643 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
644 | taskPriority:TaskPriority.get(2), |
---|
645 | taskType:TaskType.get(1), |
---|
646 | leadPerson:Person.get(5), |
---|
647 | description:"Some follow-up work", |
---|
648 | comment:"Some help required", |
---|
649 | targetStartDate: dateUtilService.tomorrow, |
---|
650 | parentTask: Task.get(1)] |
---|
651 | |
---|
652 | taskResult = taskService.create(p) |
---|
653 | |
---|
654 | //Task #3 |
---|
655 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
656 | taskPriority:TaskPriority.get(2), |
---|
657 | taskType:TaskType.get(1), |
---|
658 | leadPerson:Person.get(5), |
---|
659 | description:"A Sub Task can be created by setting the Parent Task value", |
---|
660 | comment:"Some help required", |
---|
661 | targetStartDate: dateUtilService.yesterday, |
---|
662 | parentTask: Task.get(1)] |
---|
663 | |
---|
664 | taskResult = taskService.create(p) |
---|
665 | |
---|
666 | //Task #4 |
---|
667 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
668 | taskPriority:TaskPriority.get(2), |
---|
669 | taskType:TaskType.get(1), |
---|
670 | leadPerson:Person.get(4), |
---|
671 | description:"Replace sensor at next opportunity.", |
---|
672 | comment:"Nothing else has worked.", |
---|
673 | targetStartDate: dateUtilService.oneWeekFromNow, |
---|
674 | parentTask: Task.get(1)] |
---|
675 | |
---|
676 | taskResult = taskService.create(p) |
---|
677 | |
---|
678 | //Task #5 |
---|
679 | p = [taskGroup:TaskGroup.findByName("Production Activites"), |
---|
680 | taskPriority:TaskPriority.get(2), |
---|
681 | taskType:TaskType.get(5), |
---|
682 | leadPerson:Person.get(6), |
---|
683 | description:"Production Report", |
---|
684 | comment:"Production report for specific production run or shift", |
---|
685 | targetStartDate: dateUtilService.today - 6] |
---|
686 | |
---|
687 | taskResult = taskService.create(p) |
---|
688 | |
---|
689 | //Task #6 |
---|
690 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
691 | taskPriority:TaskPriority.get(1), |
---|
692 | taskType:TaskType.get(2), |
---|
693 | leadPerson:Person.get(4), |
---|
694 | description:"This is a recurring task", |
---|
695 | 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.", |
---|
696 | targetStartDate: dateUtilService.today] |
---|
697 | |
---|
698 | taskResult = taskService.create(p) |
---|
699 | } |
---|
700 | |
---|
701 | def createBaseEntryTypes() { |
---|
702 | |
---|
703 | //EntryType |
---|
704 | def entryTypeInstance |
---|
705 | |
---|
706 | entryTypeInstance = new EntryType(name:"Fault") // #1 |
---|
707 | saveAndTest(entryTypeInstance) |
---|
708 | |
---|
709 | entryTypeInstance = new EntryType(name:"Work Done") // #2 |
---|
710 | saveAndTest(entryTypeInstance) |
---|
711 | |
---|
712 | entryTypeInstance = new EntryType(name:"Production Note") // #3 |
---|
713 | saveAndTest(entryTypeInstance) |
---|
714 | |
---|
715 | entryTypeInstance = new EntryType(name:"Work Request") // #4 |
---|
716 | saveAndTest(entryTypeInstance) |
---|
717 | } |
---|
718 | |
---|
719 | def createDemoEntries() { |
---|
720 | |
---|
721 | def entryResult |
---|
722 | def p = [:] |
---|
723 | |
---|
724 | //Entry #1 |
---|
725 | p = [task: Task.get(1), |
---|
726 | entryType: EntryType.get(1), |
---|
727 | comment: "This level sensor is causing us trouble.", |
---|
728 | durationMinute: 20] |
---|
729 | |
---|
730 | entryResult = taskService.createEntry(p) |
---|
731 | |
---|
732 | //Entry #2 |
---|
733 | p = [task: Task.get(1), |
---|
734 | entryType: EntryType.get(2), |
---|
735 | comment: "Cleaned sensor, see how it goes.", |
---|
736 | durationMinute: 30] |
---|
737 | |
---|
738 | entryResult = taskService.createEntry(p) |
---|
739 | |
---|
740 | //Entry #3 |
---|
741 | p = [task: Task.get(1), |
---|
742 | entryType: EntryType.get(2), |
---|
743 | comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", |
---|
744 | durationMinute: 20] |
---|
745 | |
---|
746 | entryResult = taskService.createEntry(p) |
---|
747 | } |
---|
748 | |
---|
749 | def createDemoAssignedGroups() { |
---|
750 | |
---|
751 | def result |
---|
752 | def p = [:] |
---|
753 | |
---|
754 | //AssignedGroup #1 |
---|
755 | p = [personGroup: PersonGroup.get(1), |
---|
756 | task: Task.get(1), |
---|
757 | estimatedHour: 2, |
---|
758 | estimatedMinute: 30] |
---|
759 | result = assignedGroupService.save(p) |
---|
760 | |
---|
761 | //AssignedGroup #2 |
---|
762 | p = [personGroup: PersonGroup.get(2), |
---|
763 | task: Task.get(1), |
---|
764 | estimatedHour: 1, |
---|
765 | estimatedMinute: 0] |
---|
766 | result = assignedGroupService.save(p) |
---|
767 | } |
---|
768 | |
---|
769 | def createDemoAssignedPersons() { |
---|
770 | |
---|
771 | def result |
---|
772 | def p = [:] |
---|
773 | |
---|
774 | //AssignedPerson #1 |
---|
775 | p = [person: Person.get(4), |
---|
776 | task: Task.get(1), |
---|
777 | estimatedHour: 1, |
---|
778 | estimatedMinute: 20] |
---|
779 | result = assignedPersonService.save(p) |
---|
780 | |
---|
781 | //AssignedPerson #2 |
---|
782 | p = [person: Person.get(5), |
---|
783 | task: Task.get(1), |
---|
784 | estimatedHour: 3, |
---|
785 | estimatedMinute: 30] |
---|
786 | result = assignedPersonService.save(p) |
---|
787 | } |
---|
788 | |
---|
789 | def createDemoTaskRecurringSchedules() { |
---|
790 | |
---|
791 | //TaskRecurringSchedule |
---|
792 | def taskRecurringScheduleInstance |
---|
793 | |
---|
794 | //TaskRecurringSchedule #1 |
---|
795 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), |
---|
796 | recurEvery: 1, |
---|
797 | recurPeriod: Period.get(2), |
---|
798 | nextTargetStartDate: dateUtilService.today, |
---|
799 | generateAhead: 1, |
---|
800 | taskDuration: 2, |
---|
801 | taskDurationPeriod: Period.get(1), |
---|
802 | enabled: false) |
---|
803 | saveAndTest(taskRecurringScheduleInstance) |
---|
804 | |
---|
805 | //TaskRecurringSchedule #2 |
---|
806 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6), |
---|
807 | recurEvery: 1, |
---|
808 | recurPeriod: Period.get(1), |
---|
809 | nextTargetStartDate: dateUtilService.today, |
---|
810 | generateAhead: 1, |
---|
811 | taskDuration: 1, |
---|
812 | taskDurationPeriod: Period.get(1), |
---|
813 | enabled: true) |
---|
814 | saveAndTest(taskRecurringScheduleInstance) |
---|
815 | } |
---|
816 | |
---|
817 | /************************* |
---|
818 | START OF INVENTORY |
---|
819 | **************************/ |
---|
820 | |
---|
821 | def createDemoInventoryStores() { |
---|
822 | |
---|
823 | //InventoryStore |
---|
824 | def inventoryStoreInstance |
---|
825 | |
---|
826 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
827 | saveAndTest(inventoryStoreInstance) |
---|
828 | |
---|
829 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
830 | saveAndTest(inventoryStoreInstance) |
---|
831 | } |
---|
832 | |
---|
833 | def createDemoInventoryLocations() { |
---|
834 | |
---|
835 | // InventoryLocation |
---|
836 | def inventoryLocation |
---|
837 | |
---|
838 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
839 | saveAndTest(inventoryLocation) |
---|
840 | |
---|
841 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "C55") |
---|
842 | saveAndTest(inventoryLocation) |
---|
843 | } |
---|
844 | |
---|
845 | def createDemoInventoryGroups() { |
---|
846 | |
---|
847 | //InventoryGroup |
---|
848 | def inventoryGroupInstance |
---|
849 | |
---|
850 | //InventoryGroup #1 |
---|
851 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
852 | saveAndTest(inventoryGroupInstance) |
---|
853 | |
---|
854 | //InventoryGroup #2 |
---|
855 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
856 | saveAndTest(inventoryGroupInstance) |
---|
857 | |
---|
858 | //InventoryGroup #3 |
---|
859 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
860 | saveAndTest(inventoryGroupInstance) |
---|
861 | |
---|
862 | //InventoryGroup #4 |
---|
863 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
864 | saveAndTest(inventoryGroupInstance) |
---|
865 | } |
---|
866 | |
---|
867 | def createBaseInventoryTypes() { |
---|
868 | |
---|
869 | //InventoryType |
---|
870 | def inventoryTypeInstance |
---|
871 | |
---|
872 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
873 | saveAndTest(inventoryTypeInstance) |
---|
874 | |
---|
875 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
876 | saveAndTest(inventoryTypeInstance) |
---|
877 | } |
---|
878 | |
---|
879 | def createBaseInventoryMovementTypes() { |
---|
880 | |
---|
881 | // InventoryMovementType |
---|
882 | def inventoryMovementTypeInstance |
---|
883 | |
---|
884 | // InventoryMovementType #1 |
---|
885 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
886 | incrementsInventory: false) |
---|
887 | saveAndTest(inventoryMovementTypeInstance) |
---|
888 | |
---|
889 | // InventoryMovementType #2 |
---|
890 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
891 | incrementsInventory: true) |
---|
892 | saveAndTest(inventoryMovementTypeInstance) |
---|
893 | |
---|
894 | // InventoryMovementType #3 |
---|
895 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
896 | incrementsInventory: true) |
---|
897 | saveAndTest(inventoryMovementTypeInstance) |
---|
898 | |
---|
899 | // InventoryMovementType #4 |
---|
900 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
901 | incrementsInventory: true) |
---|
902 | saveAndTest(inventoryMovementTypeInstance) |
---|
903 | |
---|
904 | // InventoryMovementType #5 |
---|
905 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
906 | incrementsInventory: false) |
---|
907 | saveAndTest(inventoryMovementTypeInstance) |
---|
908 | } |
---|
909 | |
---|
910 | def createDemoInventoryItems() { |
---|
911 | |
---|
912 | //InventoryItem |
---|
913 | def inventoryItemInstance |
---|
914 | |
---|
915 | //InventoryItem #1 |
---|
916 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
917 | inventoryType: InventoryType.get(1), |
---|
918 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
919 | inventoryLocation: InventoryLocation.get(1), |
---|
920 | name: "Hemp rope", |
---|
921 | description: "Natural hemp rope.", |
---|
922 | unitsInStock: 2, |
---|
923 | reorderPoint: 0) |
---|
924 | saveAndTest(inventoryItemInstance) |
---|
925 | |
---|
926 | //InventoryItem #2 |
---|
927 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
928 | inventoryType: InventoryType.get(1), |
---|
929 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
930 | inventoryLocation: InventoryLocation.get(1), |
---|
931 | name: "Cotton Rope 12mm", |
---|
932 | description: "A soft natural rope made from cotton.", |
---|
933 | alternateItems: InventoryItem.get(1), |
---|
934 | unitsInStock: 2, |
---|
935 | reorderPoint: 0) |
---|
936 | saveAndTest(inventoryItemInstance) |
---|
937 | |
---|
938 | //InventoryItem #3 |
---|
939 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
940 | inventoryType: InventoryType.get(1), |
---|
941 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
942 | inventoryLocation: InventoryLocation.get(2), |
---|
943 | name: "2305-2RS", |
---|
944 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
945 | unitsInStock: 3, |
---|
946 | reorderPoint: 2) |
---|
947 | saveAndTest(inventoryItemInstance) |
---|
948 | |
---|
949 | //InventoryItem #4 |
---|
950 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
951 | inventoryType: InventoryType.get(1), |
---|
952 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
953 | inventoryLocation: InventoryLocation.get(2), |
---|
954 | name: "L1592-K10", |
---|
955 | description: "10kW contactor", |
---|
956 | unitsInStock: 4, |
---|
957 | reorderPoint: 0) |
---|
958 | saveAndTest(inventoryItemInstance) |
---|
959 | |
---|
960 | //InventoryItem #5 |
---|
961 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
962 | inventoryType: InventoryType.get(1), |
---|
963 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
964 | inventoryLocation: InventoryLocation.get(2), |
---|
965 | name: "6205-ZZ", |
---|
966 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
967 | unitsInStock: 5, |
---|
968 | reorderPoint: 2) |
---|
969 | saveAndTest(inventoryItemInstance) |
---|
970 | } |
---|
971 | |
---|
972 | /******************* |
---|
973 | START OF ASSET |
---|
974 | *******************/ |
---|
975 | |
---|
976 | def createDemoLifePlan() { |
---|
977 | |
---|
978 | //LifePlan |
---|
979 | def lifeplanInstance |
---|
980 | |
---|
981 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
982 | saveAndTest(lifeplanInstance) |
---|
983 | } |
---|
984 | |
---|
985 | def createBaseExtenededAttributeTypes() { |
---|
986 | |
---|
987 | //ExtendedAttributeType |
---|
988 | def extendedAttributeTypeInstance |
---|
989 | |
---|
990 | //ExtendedAttributeType #1 |
---|
991 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Model Number") |
---|
992 | saveAndTest(extendedAttributeTypeInstance) |
---|
993 | |
---|
994 | //ExtendedAttributeType #2 |
---|
995 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Purchase Cost") |
---|
996 | saveAndTest(extendedAttributeTypeInstance) |
---|
997 | |
---|
998 | //ExtendedAttributeType #3 |
---|
999 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Serial Number") |
---|
1000 | saveAndTest(extendedAttributeTypeInstance) |
---|
1001 | |
---|
1002 | //ExtendedAttributeType #4 |
---|
1003 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufactured Date") |
---|
1004 | saveAndTest(extendedAttributeTypeInstance) |
---|
1005 | |
---|
1006 | //ExtendedAttributeType #5 |
---|
1007 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Location Description") |
---|
1008 | saveAndTest(extendedAttributeTypeInstance) |
---|
1009 | |
---|
1010 | //ExtendedAttributeType #6 |
---|
1011 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Centre") |
---|
1012 | saveAndTest(extendedAttributeTypeInstance) |
---|
1013 | |
---|
1014 | //ExtendedAttributeType #7 |
---|
1015 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Code") |
---|
1016 | saveAndTest(extendedAttributeTypeInstance) |
---|
1017 | |
---|
1018 | //ExtendedAttributeType #8 |
---|
1019 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufacturer's Number") |
---|
1020 | saveAndTest(extendedAttributeTypeInstance) |
---|
1021 | |
---|
1022 | //ExtendedAttributeType #9 |
---|
1023 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Inventory Number") |
---|
1024 | saveAndTest(extendedAttributeTypeInstance) |
---|
1025 | } |
---|
1026 | |
---|
1027 | def createBaseMaintenancePolicies() { |
---|
1028 | |
---|
1029 | //MaintenancePolicy |
---|
1030 | def maintenancePolicyInstance |
---|
1031 | |
---|
1032 | //MaintenancePolicy #1 |
---|
1033 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
1034 | saveAndTest(maintenancePolicyInstance) |
---|
1035 | |
---|
1036 | //MaintenancePolicy #2 |
---|
1037 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
1038 | saveAndTest(maintenancePolicyInstance) |
---|
1039 | |
---|
1040 | //MaintenancePolicy #3 |
---|
1041 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
1042 | saveAndTest(maintenancePolicyInstance) |
---|
1043 | |
---|
1044 | //MaintenancePolicy #4 |
---|
1045 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
1046 | saveAndTest(maintenancePolicyInstance) |
---|
1047 | |
---|
1048 | //MaintenancePolicy #5 |
---|
1049 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
1050 | saveAndTest(maintenancePolicyInstance) |
---|
1051 | |
---|
1052 | //MaintenancePolicy #6 |
---|
1053 | maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement") |
---|
1054 | saveAndTest(maintenancePolicyInstance) |
---|
1055 | |
---|
1056 | //MaintenancePolicy #7 |
---|
1057 | maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test") |
---|
1058 | saveAndTest(maintenancePolicyInstance) |
---|
1059 | } |
---|
1060 | |
---|
1061 | def createDemoTaskProcedure() { |
---|
1062 | |
---|
1063 | //TaskProcedure |
---|
1064 | def taskProcedureInstance |
---|
1065 | |
---|
1066 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
1067 | saveAndTest(taskProcedureInstance) |
---|
1068 | taskProcedureInstance.addToTasks(Task.get(1)) |
---|
1069 | } |
---|
1070 | |
---|
1071 | def createDemoMaintenanceActions() { |
---|
1072 | |
---|
1073 | //MaintenanceAction |
---|
1074 | def maintenanceActionInstance |
---|
1075 | |
---|
1076 | //MaintenanceAction #1 |
---|
1077 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
1078 | procedureStepNumber: 1, |
---|
1079 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
1080 | taskProcedure: TaskProcedure.get(1)) |
---|
1081 | saveAndTest(maintenanceActionInstance) |
---|
1082 | |
---|
1083 | //MaintenanceAction #2 |
---|
1084 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
1085 | procedureStepNumber: 2, |
---|
1086 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
1087 | taskProcedure: TaskProcedure.get(1)) |
---|
1088 | saveAndTest(maintenanceActionInstance) |
---|
1089 | |
---|
1090 | //MaintenanceAction #3 |
---|
1091 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
1092 | procedureStepNumber: 3, |
---|
1093 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
1094 | taskProcedure: TaskProcedure.get(1)) |
---|
1095 | saveAndTest(maintenanceActionInstance) |
---|
1096 | } |
---|
1097 | |
---|
1098 | def createDemoSections() { |
---|
1099 | |
---|
1100 | //Section |
---|
1101 | def sectionInstance |
---|
1102 | |
---|
1103 | //Section #1 |
---|
1104 | sectionInstance = new Section(name: "Press Section", |
---|
1105 | site: Site.get(3), |
---|
1106 | department: Department.get(1)) |
---|
1107 | saveAndTest(sectionInstance) |
---|
1108 | |
---|
1109 | //Section #2 |
---|
1110 | sectionInstance = new Section(name: "RO System", |
---|
1111 | site: Site.get(1), |
---|
1112 | department: Department.get(2)) |
---|
1113 | saveAndTest(sectionInstance) |
---|
1114 | |
---|
1115 | //Section #3 |
---|
1116 | sectionInstance = new Section(name: "Auxiliary Section", |
---|
1117 | site: Site.get(1), |
---|
1118 | department: Department.get(1)) |
---|
1119 | saveAndTest(sectionInstance) |
---|
1120 | } |
---|
1121 | |
---|
1122 | def createDemoAssetTree() { |
---|
1123 | |
---|
1124 | //Asset |
---|
1125 | def assetInstance |
---|
1126 | |
---|
1127 | //Asset #1 |
---|
1128 | def assetInstance1 = new Asset(name: "Print Tower 22", |
---|
1129 | section: Section.get(1)) |
---|
1130 | saveAndTest(assetInstance1) |
---|
1131 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
1132 | |
---|
1133 | //Asset #2 |
---|
1134 | def assetInstance2 = new Asset(name: "Print Tower 21", |
---|
1135 | section: Section.get(1)) |
---|
1136 | saveAndTest(assetInstance2) |
---|
1137 | |
---|
1138 | //Asset #3 |
---|
1139 | def assetInstance3 = new Asset(name: "Print Tower 23", |
---|
1140 | section: Section.get(1)) |
---|
1141 | saveAndTest(assetInstance3) |
---|
1142 | |
---|
1143 | //Asset #4 |
---|
1144 | def assetInstance4 = new Asset(name: "RO 1", |
---|
1145 | section: Section.get(2)) |
---|
1146 | saveAndTest(assetInstance4) |
---|
1147 | |
---|
1148 | //AssetSubItem |
---|
1149 | def assetSubItemInstance |
---|
1150 | |
---|
1151 | //AssetSubItem #1 Level1 |
---|
1152 | def assetSubItemInstance1 = new AssetSubItem(name: "Print Tower") |
---|
1153 | saveAndTest(assetSubItemInstance1) |
---|
1154 | |
---|
1155 | // Add assetSubItemInstance1 to some assets. |
---|
1156 | assetInstance1.addToAssetSubItems(assetSubItemInstance1) |
---|
1157 | assetInstance2.addToAssetSubItems(assetSubItemInstance1) |
---|
1158 | assetInstance3.addToAssetSubItems(assetSubItemInstance1) |
---|
1159 | |
---|
1160 | //AssetSubItem #2 Level1 |
---|
1161 | def assetSubItemInstance2 = new AssetSubItem(name: "Reactor Tower") |
---|
1162 | saveAndTest(assetSubItemInstance2) |
---|
1163 | |
---|
1164 | // Add assetSubItemInstance2 to some assets. |
---|
1165 | assetInstance4.addToAssetSubItems(assetSubItemInstance2) |
---|
1166 | |
---|
1167 | //AssetSubItem #3 Level1 |
---|
1168 | def assetSubItemInstance3 = new AssetSubItem(name: "Blower Tower") |
---|
1169 | saveAndTest(assetSubItemInstance3) |
---|
1170 | |
---|
1171 | // Add assetSubItemInstance3 to some assets. |
---|
1172 | assetInstance4.addToAssetSubItems(assetSubItemInstance3) |
---|
1173 | |
---|
1174 | //AssetSubItem #4 Level2 |
---|
1175 | assetSubItemInstance = new AssetSubItem(name: "Print Unit Upper", |
---|
1176 | parentItem: AssetSubItem.get(1)) |
---|
1177 | saveAndTest(assetSubItemInstance) |
---|
1178 | |
---|
1179 | //AssetSubItem #5 Level3 |
---|
1180 | assetSubItemInstance = new AssetSubItem(name: "Agitator", |
---|
1181 | parentItem: AssetSubItem.get(2)) |
---|
1182 | saveAndTest(assetSubItemInstance) |
---|
1183 | |
---|
1184 | //AssetSubItem #6 Level2 |
---|
1185 | assetSubItemInstance = new AssetSubItem(name: "Scraper", |
---|
1186 | parentItem: AssetSubItem.get(3)) |
---|
1187 | saveAndTest(assetSubItemInstance) |
---|
1188 | |
---|
1189 | //AssetSubItem #7 Level3 |
---|
1190 | assetSubItemInstance = new AssetSubItem(name: "Motor", |
---|
1191 | parentItem: AssetSubItem.get(5)) |
---|
1192 | saveAndTest(assetSubItemInstance) |
---|
1193 | |
---|
1194 | //AssetSubItem #8 Level3 |
---|
1195 | assetSubItemInstance = new AssetSubItem(name: "Gearbox", |
---|
1196 | parentItem: AssetSubItem.get(5)) |
---|
1197 | saveAndTest(assetSubItemInstance) |
---|
1198 | |
---|
1199 | //AssetSubItem #9 Level4 |
---|
1200 | assetSubItemInstance = new AssetSubItem(name: "DS Bearing", |
---|
1201 | parentItem: AssetSubItem.get(7)) |
---|
1202 | saveAndTest(assetSubItemInstance) |
---|
1203 | |
---|
1204 | //AssetSubItem #10 Level4 |
---|
1205 | assetSubItemInstance = new AssetSubItem(name: "NDS Bearing", |
---|
1206 | parentItem: AssetSubItem.get(7)) |
---|
1207 | saveAndTest(assetSubItemInstance) |
---|
1208 | } // createDemoAssetTree() |
---|
1209 | |
---|
1210 | def createDemoAssetExtenedAttributes() { |
---|
1211 | |
---|
1212 | //AssetExtendedAttribute |
---|
1213 | def assetExtendedAttributeInstance |
---|
1214 | |
---|
1215 | //AssetExtendedAttribute #1 |
---|
1216 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
1217 | asset: Asset.get(1), |
---|
1218 | extendedAttributeType: ExtendedAttributeType.get(1)) |
---|
1219 | saveAndTest(assetExtendedAttributeInstance) |
---|
1220 | |
---|
1221 | //AssetExtendedAttribute #2 |
---|
1222 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
1223 | asset: Asset.get(1), |
---|
1224 | extendedAttributeType: ExtendedAttributeType.get(5)) |
---|
1225 | saveAndTest(assetExtendedAttributeInstance) |
---|
1226 | } |
---|
1227 | |
---|
1228 | |
---|
1229 | /**************************************** |
---|
1230 | Call this function instead of .save() |
---|
1231 | *****************************************/ |
---|
1232 | private boolean saveAndTest(object) { |
---|
1233 | if(!object.save()) { |
---|
1234 | // DemoDataSuccessful = false |
---|
1235 | log.error "'${object}' failed to save!" |
---|
1236 | log.error object.errors |
---|
1237 | return false |
---|
1238 | } |
---|
1239 | return true |
---|
1240 | } |
---|
1241 | } |
---|