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