Changeset 549 for trunk/grails-app
- Timestamp:
- May 27, 2010, 9:24:43 PM (15 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/i18n/messages.properties
r548 r549 156 156 inventory.item.already.has.picture=Inventory item already has a picture, please delete the old picture first. 157 157 inventory.item.picture.file.unrecognised=Image file [{0}]: type not recognised. 158 inventory.item.picture.source.not.supported=Image source type not supported. 158 159 159 160 inventoryMovement.quantity.insufficientItemsInStock=Could not complete operation, insufficient items in stock. -
trunk/grails-app/services/CreateDataService.groovy
r534 r549 13 13 def dateUtilService 14 14 def appConfigService 15 def inventoryItemService 15 16 def assignedGroupService 16 17 def assignedPersonService 18 19 def grailsApplication 17 20 18 21 /******************************************* … … 1203 1206 def inventoryItemInstance 1204 1207 1208 def pictureResource = grailsApplication.mainContext.getResource('images/logo.png') 1209 1205 1210 //InventoryItem #1 1206 1211 inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), … … 1213 1218 reorderPoint: 0) 1214 1219 saveAndTest(inventoryItemInstance) 1220 inventoryItemService.savePicture(inventoryItemInstance, pictureResource) 1215 1221 1216 1222 //InventoryItem #2 … … 1225 1231 reorderPoint: 0) 1226 1232 saveAndTest(inventoryItemInstance) 1233 inventoryItemService.savePicture(inventoryItemInstance, pictureResource) 1227 1234 1228 1235 //InventoryItem #3 … … 1236 1243 reorderPoint: 2) 1237 1244 saveAndTest(inventoryItemInstance) 1245 inventoryItemService.savePicture(inventoryItemInstance, pictureResource) 1238 1246 1239 1247 //InventoryItem #4 … … 1247 1255 reorderPoint: 0) 1248 1256 saveAndTest(inventoryItemInstance) 1257 inventoryItemService.savePicture(inventoryItemInstance, pictureResource) 1249 1258 1250 1259 //InventoryItem #5 … … 1258 1267 reorderPoint: 2) 1259 1268 saveAndTest(inventoryItemInstance) 1269 inventoryItemService.savePicture(inventoryItemInstance, pictureResource) 1260 1270 } 1261 1271 -
trunk/grails-app/services/InventoryItemService.groovy
r548 r549 261 261 return fail(field:"picture", code:"inventory.item.already.has.picture") 262 262 263 // Declare some more variables, since we appear to have most of what we need. 263 264 def picture = new Picture(inventoryItem: result.inventoryItemInstance) 264 265 def imaging = new Imaging() … … 268 269 def pictureInputStream 269 270 271 // Check the supplied pictureSource and get the inputStream. 270 272 if(pictureSource instanceof javax.servlet.http.HttpServletRequest) { 271 273 def multiPartFile = pictureSource.getFile('file') … … 293 295 } 294 296 else { 295 return fail(code:"default.file.not.supplied") 296 } 297 297 return fail(code:"inventory.item.picture.source.not.supported") 298 } 299 300 // Create the Images. 298 301 try { 299 302 images = imaging.createAll(result.inventoryItemInstance, picture, pictureInputStream) 303 // Ensure the stream is closed. 304 pictureInputStream.close() 300 305 } 301 306 catch(Exception ex) { 302 307 log.error("picture save", ex) 308 // Ensure the stream is closed. 309 pictureInputStream.close() 303 310 return fail(code:"inventory.item.picture.file.unrecognised", args: [pictureFileName]) 304 311 } 305 312 313 // Add images to picture. 306 314 images.each { image -> 307 315 picture.addToImages(image) 308 316 } 309 317 318 // Save picture. 310 319 if(picture.hasErrors() || !picture.save()) 311 320 return fail(code:"default.create.failure", args: ["Picture"]) … … 313 322 result.inventoryItemInstance.picture = picture 314 323 324 // Save inventoryItem. 315 325 if(result.inventoryItemInstance.hasErrors() || !result.inventoryItemInstance.save()) 316 326 return fail(code:"default.create.failure")
Note: See TracChangeset
for help on using the changeset viewer.