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