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