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