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