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