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