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