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