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