Changeset 688 for trunk/grails-app
- Timestamp:
- Oct 6, 2010, 4:23:46 AM (14 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AppCoreController.groovy
r687 r688 9 9 10 10 def authService 11 def assetService 11 12 def appConfigService 12 13 def createDataService 13 14 def searchableService 15 def assetSubItemService 14 16 def createBulkDataService 15 17 … … 269 271 } 270 272 273 /** 274 * Allow admin to create recommended extended attributes for assets. 275 */ 276 @Secured(['ROLE_AppAdmin']) 277 def createRecommendedAssetExtendedAttributes = { 278 def result = assetService.createRecommendedExtendedAttributes() 279 if(!result.error) { 280 flash.message = g.message(code:"default.create.success", args:["Extended attributes created", '']) 281 redirect(action: appAdmin) 282 return 283 } 284 285 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 286 redirect(action: appAdmin) 287 } 288 289 /** 290 * Allow admin to create recommended extended attributes for level 1 assetSubItems. 291 */ 292 @Secured(['ROLE_AppAdmin']) 293 def createRecommendedAssetSubItemExtendedAttributes = { 294 def result = assetSubItemService.createRecommendedExtendedAttributes() 295 if(!result.error) { 296 flash.message = g.message(code:"default.create.success", args:["Extended attributes created", '']) 297 redirect(action: appAdmin) 298 return 299 } 300 301 flash.errorMessage = g.message(code: result.error.code, args: result.error.args) 302 redirect(action: appAdmin) 303 } 304 271 305 } // end of class. -
trunk/grails-app/services/AssetService.groovy
r429 r688 5 5 6 6 boolean transactional = false 7 8 def sessionFactory 7 9 8 10 def assetSubItemService … … 235 237 } // end saveCopySrvce 236 238 239 /** 240 * Create recommended extended attributes for all assets. 241 */ 242 def createRecommendedExtendedAttributes() { 243 def result = [:] 244 245 def hibernateSession = sessionFactory.currentSession 246 247 def assets = Asset.list() 248 def locationDescription = ExtendedAttributeType.get(5) 249 def ecr = ExtendedAttributeType.get(9) 250 def assetNumber = ExtendedAttributeType.get(17) 251 def assetCondition = ExtendedAttributeType.get(16) 252 def maintenancePercentComplete = ExtendedAttributeType.get(13) 253 def registrationRequired = ExtendedAttributeType.get(14) 254 def registrationExpiryDate = ExtendedAttributeType.get(15) 255 def regulatoryRequirement = ExtendedAttributeType.get(12) 256 def riskLevel = ExtendedAttributeType.get(10) 257 def safeWorkProcedure = ExtendedAttributeType.get(11) 258 259 for(asset in assets) { 260 261 def attributeTypes = asset.assetExtendedAttributes.collect {it.extendedAttributeType} 262 263 //AssetExtendedAttribute 264 def assetExtendedAttributeInstance 265 266 if(!attributeTypes.contains(locationDescription)) { 267 //AssetExtendedAttribute #1 268 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 269 asset: asset, 270 extendedAttributeType: locationDescription) 271 assetExtendedAttributeInstance.save() 272 } 273 274 if(!attributeTypes.contains(ecr)) { 275 //AssetExtendedAttribute #2 276 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 277 asset: asset, 278 extendedAttributeType: ecr) 279 assetExtendedAttributeInstance.save() 280 } 281 282 if(!attributeTypes.contains(assetNumber)) { 283 //AssetExtendedAttribute #3 284 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 285 asset: asset, 286 extendedAttributeType: assetNumber) 287 assetExtendedAttributeInstance.save() 288 } 289 290 if(!attributeTypes.contains(assetCondition)) { 291 //AssetExtendedAttribute #4 292 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 293 asset: asset, 294 extendedAttributeType: assetCondition) 295 assetExtendedAttributeInstance.save() 296 } 297 298 if(!attributeTypes.contains(maintenancePercentComplete)) { 299 //AssetExtendedAttribute #5 300 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "TBA", 301 asset: asset, 302 extendedAttributeType: maintenancePercentComplete) 303 assetExtendedAttributeInstance.save() 304 } 305 306 if(!attributeTypes.contains(registrationRequired)) { 307 //AssetExtendedAttribute #6 308 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 309 asset: asset, 310 extendedAttributeType: registrationRequired) 311 assetExtendedAttributeInstance.save() 312 } 313 314 if(!attributeTypes.contains(registrationExpiryDate)) { 315 //AssetExtendedAttribute #7 316 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 317 asset: asset, 318 extendedAttributeType:registrationExpiryDate) 319 assetExtendedAttributeInstance.save() 320 } 321 322 if(!attributeTypes.contains(regulatoryRequirement)) { 323 //AssetExtendedAttribute #8 324 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 325 asset: asset, 326 extendedAttributeType: regulatoryRequirement) 327 assetExtendedAttributeInstance.save() 328 } 329 330 if(!attributeTypes.contains(riskLevel)) { 331 //AssetExtendedAttribute #9 332 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 333 asset: asset, 334 extendedAttributeType: riskLevel) 335 assetExtendedAttributeInstance.save() 336 } 337 338 if(!attributeTypes.contains(safeWorkProcedure)) { 339 //AssetExtendedAttribute #10 340 assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Not Specified", 341 asset: asset, 342 extendedAttributeType: safeWorkProcedure) 343 assetExtendedAttributeInstance.save() 344 } 345 346 hibernateSession.flush() 347 348 } // for 349 350 // Success. 351 return result 352 353 } // createRecommendedExtendedAttributes() 354 237 355 } // end class -
trunk/grails-app/services/AssetSubItemService.groovy
r387 r688 1 1 2 import net.kromhouts.HqlBuilder 2 3 import org.apache.commons.lang.WordUtils 3 4 … … 5 6 6 7 boolean transactional = false 8 9 def sessionFactory 7 10 8 11 /** … … 120 123 } // save() 121 124 125 /** 126 * Get a list of level 1 assetSubItems. 127 * @returns By default all level 1 assetSubItems are returned. 128 */ 129 def getLevel1AssetSubItems(params) { 130 131 // A result is returned for every level 1 assetSubItem. 132 def q = new HqlBuilder().query { 133 select 'assetSubItem' 134 from 'AssetSubItem assetSubItem', 135 'inner join assetSubItem.assets as asset' 136 where 'asset != null' // ensure that only level 1 assetSubItems are returned. 137 } 138 def assetSubItems = AssetSubItem.executeQuery(q.query, q.namedParams) 139 140 } 141 142 /** 143 * Create recommended extended attributes for all level 1 subItems. 144 */ 145 def createRecommendedExtendedAttributes() { 146 def result = [:] 147 148 def hibernateSession = sessionFactory.currentSession 149 150 def assetSubItems = getLevel1AssetSubItems() 151 152 def manufacturer = ExtendedAttributeType.get(8) 153 def modelNumber = ExtendedAttributeType.get(1) 154 def serialNumber = ExtendedAttributeType.get(3) 155 def manufacturedDate = ExtendedAttributeType.get(4) 156 157 for(assetSubItem in assetSubItems) { 158 159 def attributeTypes = assetSubItem.assetSubItemExtendedAttributes.collect {it.extendedAttributeType} 160 161 //AssetSubItemExtendedAttribute 162 def assetSubItemExtendedAttributeInstance 163 164 if(!attributeTypes.contains(manufacturer)) { 165 //AssetSubItemExtendedAttribute #1 166 assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(value: "Not Specified", 167 assetSubItem: assetSubItem, 168 extendedAttributeType: manufacturer) 169 assetSubItemExtendedAttributeInstance.save() 170 } 171 172 if(!attributeTypes.contains(modelNumber)) { 173 //AssetSubItemExtendedAttribute #2 174 assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(value: "Not Specified", 175 assetSubItem: assetSubItem, 176 extendedAttributeType: modelNumber) 177 assetSubItemExtendedAttributeInstance.save() 178 } 179 180 if(!attributeTypes.contains(serialNumber)) { 181 //AssetSubItemExtendedAttribute #3 182 assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(value: "Not Specified", 183 assetSubItem: assetSubItem, 184 extendedAttributeType: serialNumber) 185 assetSubItemExtendedAttributeInstance.save() 186 } 187 188 if(!attributeTypes.contains(manufacturedDate)) { 189 //AssetSubItemExtendedAttribute #4 190 assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(value: "Not Specified", 191 assetSubItem: assetSubItem, 192 extendedAttributeType: manufacturedDate) 193 assetSubItemExtendedAttributeInstance.save() 194 } 195 196 hibernateSession.flush() 197 198 } // for 199 200 // Success. 201 return result 202 203 } // createRecommendedExtendedAttributes() 204 122 205 } // end class -
trunk/grails-app/services/CreateDataService.groovy
r685 r688 1425 1425 1426 1426 //Section #1 1427 sectionInstance = new Section(name: " Press",1427 sectionInstance = new Section(name: "A-Press", 1428 1428 description: "Press Section", 1429 1429 site: Site.get(3), -
trunk/grails-app/views/appCore/appAdmin.gsp
r624 r688 49 49 </g:else> 50 50 51 <br /> 52 <br /> 53 54 <g:link action="createRecommendedAssetExtendedAttributes">Asset Extended Attributes</g:link> - Create recommended extended attributes for assets. 55 <br /> 56 <g:link action="createRecommendedAssetSubItemExtendedAttributes">Sub Asset Extended Attributes</g:link> - Create recommended extended attributes for level 1 sub assets. 57 51 58 </td> 52 59 </tr>
Note: See TracChangeset
for help on using the changeset viewer.