Changeset 426
- Timestamp:
- Mar 3, 2010, 6:20:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/InventoryCsvService.groovy
r423 r426 27 27 28 28 def kByteMultiplier = 1000 29 def fileMaxSize = 500 * kByteMultiplier29 def fileMaxSize = 800 * kByteMultiplier 30 30 def logFileLink = g.link(controller: "appCore", action: "appLog") {"log"} 31 31 … … 82 82 83 83 def tempSuppliers = [] 84 def tempSupplierItem = '' 85 def tempSupplierType = '' 84 86 def tempSupplierItemAndType = [] 85 87 def tempManufacturers = [] 88 def tempManufacturerItem = '' 89 def tempManufacturerType = '' 86 90 def tempManufacturerItemAndType = [] 87 91 … … 113 117 114 118 def parseInputList = { 115 if( it.trim() == '') return []119 if( (it == null) || (it.trim() == '') ) return [] 116 120 return it.split(";").collect{it.trim()} 117 121 } … … 160 164 161 165 // Parse the line into the params map. 162 /** TODO: capitalize and capitalizeFully.*/163 166 inventoryParams = [:] 164 167 line.eachWithIndex { it, j -> … … 180 183 181 184 // Site 185 inventoryParams.site = WordUtils.capitalize(inventoryParams.site) 182 186 siteInstance = Site.findByName(inventoryParams.site) 183 187 if(!siteInstance) { … … 190 194 191 195 // InventoryStore 196 inventoryParams.inventoryStore = WordUtils.capitalizeFully(inventoryParams.inventoryStore) 192 197 inventoryStoreInstance = InventoryStore.findByName(inventoryParams.inventoryStore) 193 198 if(!inventoryStoreInstance) { … … 201 206 202 207 // InventoryLocation 208 inventoryParams.inventoryLocation = WordUtils.capitalize(inventoryParams.inventoryLocation) 203 209 inventoryLocationInstance = InventoryLocation.findByName(inventoryParams.inventoryLocation) 204 210 if(!inventoryLocationInstance) { … … 212 218 213 219 // InventoryGroup 220 inventoryParams.inventoryLocation = WordUtils.capitalizeFully(inventoryParams.inventoryLocation) 214 221 inventoryGroupInstance = InventoryGroup.findByName(inventoryParams.inventoryGroup) 215 222 if(!inventoryGroupInstance) { … … 222 229 223 230 // InventoryType 231 inventoryParams.inventoryType = WordUtils.capitalizeFully(inventoryParams.inventoryType) 224 232 inventoryTypeInstance = InventoryType.findByName(inventoryParams.inventoryType) 225 233 if(!inventoryTypeInstance) { … … 256 264 for(tempManufacturer in tempManufacturers) { 257 265 tempManufacturerItemAndType = parseItemAndType(tempManufacturer) 258 259 manufacturerInstance = Manufacturer.findByName(tempManufacturerItemAndType[0]) 266 tempManufacturerItem = WordUtils.capitalizeFully(tempManufacturerItemAndType[0]) 267 268 manufacturerInstance = Manufacturer.findByName(tempManufacturerItem) 260 269 if(!manufacturerInstance) { 261 270 262 271 // ManufacturerType. 263 if(tempManufacturerItemAndType.size == 2) 264 manufacturerTypeInstance = ManufacturerType.findByName(tempManufacturerItemAndType[1]) 272 if(tempManufacturerItemAndType.size == 2) { 273 tempManufacturerType = WordUtils.capitalizeFully(tempManufacturerItemAndType[1]) 274 manufacturerTypeInstance = ManufacturerType.findByName(tempManufacturerType) 275 } 265 276 else 266 277 manufacturerTypeInstance = manufacturerTypeUnknown … … 270 281 } 271 282 272 manufacturerInstance = new Manufacturer(name: tempManufacturerItem AndType[0],283 manufacturerInstance = new Manufacturer(name: tempManufacturerItem, 273 284 manufacturerType: manufacturerTypeInstance) 274 285 if(!manufacturerInstance.save()) { … … 287 298 for(tempSupplier in tempSuppliers) { 288 299 tempSupplierItemAndType = parseItemAndType(tempSupplier) 289 290 supplierInstance = Supplier.findByName(tempSupplierItemAndType[0]) 300 tempSupplierItem = WordUtils.capitalizeFully(tempSupplierItemAndType[0]) 301 302 supplierInstance = Supplier.findByName(tempSupplierItem) 291 303 if(!supplierInstance) { 292 304 293 305 // SupplierType. 294 if(tempSupplierItemAndType.size == 2) 295 supplierTypeInstance = SupplierType.findByName(tempSupplierItemAndType[1]) 306 if(tempSupplierItemAndType.size == 2) { 307 tempSupplierType = WordUtils.capitalizeFully(tempSupplierItemAndType[1]) 308 supplierTypeInstance = SupplierType.findByName(tempSupplierType) 309 } 296 310 else 297 311 supplierTypeInstance = supplierTypeUnknown … … 301 315 } 302 316 303 supplierInstance = new Supplier(name: tempSupplierItem AndType[0],317 supplierInstance = new Supplier(name: tempSupplierItem, 304 318 supplierType: supplierTypeInstance) 305 319 if(!supplierInstance.save()) { … … 317 331 318 332 for(tempAlternateItem in tempAlternateItems) { 319 333 tempAlternateItem = WordUtils.capitalize(tempAlternateItem) 320 334 alternateItemInstance = InventoryItem.findByName(tempAlternateItem) 321 335 if(!alternateItemInstance) { … … 342 356 for(asset in tempSpareFor) { 343 357 344 println '' 345 println 'asset: '+asset 346 println '' 358 asset = WordUtils.capitalize(asset) 347 359 348 360 spareForInstance = Asset.findByName(asset) … … 361 373 inventoryParams.unitOfMeasure = unitOfMeasureInstance 362 374 inventoryParams.averageDeliveryPeriod = averageDeliveryPeriodInstance 375 376 // Format remaining properties. 377 inventoryParams.name = WordUtils.capitalize(inventoryParams.name) 378 inventoryParams.description = inventoryParams.description[0].toUpperCase() + inventoryParams.description[1..-1] 363 379 364 380 // Debug
Note: See TracChangeset
for help on using the changeset viewer.