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