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