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