source: trunk/grails-app/services/CreateDataService.groovy @ 399

Last change on this file since 399 was 399, checked in by gav, 14 years ago

Remove email and emailShow from Person in preparation for ContactDetails.

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