Ignore:
Timestamp:
Nov 25, 2010, 8:47:00 AM (9 years ago)
Author:
gav
Message:

Domain change: as per ticket #96 - Remove unused fields from InventoryItem?.
Removed InventoryItem?.preferredManufacturer and manufacturersPartNumber.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/InventoryCsvService.groovy

    r718 r719  
    5252            def line = []
    5353            def lineNumber = 0
    54             def maxNumberOfColumns = 23
     54            def maxNumberOfColumns = 20
    5555            def inventoryParams = [:]
    5656            def inventoryProperties = ["name", "description", "comment", "unitsInStock", "reorderPoint", "reorderQuantity",
     
    5959                                                        "inventoryGroup", "inventoryType",
    6060                                                        "suppliersPartNumber", "preferredSupplier", "alternateSuppliers",
    61                                                         "manufacturersPartNumber", "preferredManufacturer", "alternateManufacturers",
    6261                                                        "alternateItems", "spareFor"]
    6362
     
    6968            def spareForInstance
    7069            def alternateItemInstance
    71             def preferredManufacturerInstance
    72             def alternateManufacturerInstance
    73             def manufacturerTypeInstance
    74             def manufacturerTypeUnknown = ManufacturerType.get(1)
    7570            def inventoryTypeInstance
    7671            def unitOfMeasureInstance
     
    8883            def tempSupplierType = ''
    8984            def tempSupplierItemAndType = []
    90 
    91             def tempPreferredManufacturerItemAndType = ''
    92             def tempPreferredManufacturerItem = ''
    93             def tempPreferredManufacturerType = ''
    94 
    95             def tempAlternateManufacturers = []
    96             def tempManufacturerItem = ''
    97             def tempManufacturerType = ''
    98             def tempManufacturerItemAndType = []
    9985
    10086            def tempSpareFor = []
     
    238224                        return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])
    239225                    }
    240                 }
    241 
    242                 // Preferred Manufacturer
    243                 if(inventoryParams.preferredManufacturer) {
    244                     tempPreferredManufacturerItemAndType = parseItemAndType(inventoryParams.preferredManufacturer)
    245                     tempPreferredManufacturerItem = WordUtils.capitalize(tempPreferredManufacturerItemAndType[0])
    246 
    247                     preferredManufacturerInstance = Manufacturer.findByName(tempPreferredManufacturerItem)
    248                     if(!preferredManufacturerInstance) {
    249 
    250                         // Manufacturer Type.
    251                         if(tempPreferredManufacturerItemAndType.size == 2) {
    252                             tempPreferredManufacturerType = WordUtils.capitalize(tempPreferredManufacturerItemAndType[1])
    253                             manufacturerTypeInstance = ManufacturerType.findByName(tempPreferredManufacturerType)
    254                         }
    255                         else
    256                             manufacturerTypeInstance = manufacturerTypeUnknown
    257                         if(!manufacturerTypeInstance) {
    258                             log.error "Failed to find preferred manufacturer type on line: " + lineNumber
    259                             return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])
    260                         }
    261 
    262                         preferredManufacturerInstance = new Manufacturer(name: tempPreferredManufacturerItem,
    263                                                                                                             manufacturerType: manufacturerTypeInstance)
    264                         if(!preferredManufacturerInstance.save()) {
    265                             log.error "Failed to create preferred manufacturer on line: " + lineNumber
    266                             return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])
    267                         }
    268                     }
    269                 }
    270                 else
    271                     preferredManufacturerInstance = null
    272 
    273                 // Alternate Manufacturers.
    274                 tempAlternateManufacturers = parseInputList(inventoryParams.alternateManufacturers)
    275                 inventoryParams.alternateManufacturers = []
    276 
    277                 for(tempManufacturer in tempAlternateManufacturers) {
    278                     tempManufacturerItemAndType = parseItemAndType(tempManufacturer)
    279                     tempManufacturerItem = WordUtils.capitalizeFully(tempManufacturerItemAndType[0])
    280 
    281                     alternateManufacturerInstance = Manufacturer.findByName(tempManufacturerItem)
    282                     if(!alternateManufacturerInstance) {
    283 
    284                         // ManufacturerType.
    285                         if(tempManufacturerItemAndType.size == 2) {
    286                             tempManufacturerType = WordUtils.capitalize(tempManufacturerItemAndType[1])
    287                             manufacturerTypeInstance = ManufacturerType.findByName(tempManufacturerType)
    288                         }
    289                         else
    290                             manufacturerTypeInstance = manufacturerTypeUnknown
    291                         if(!manufacturerTypeInstance) {
    292                             log.error "Failed to find manufacturer type on line: " + lineNumber
    293                             return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])
    294                         }
    295 
    296                         alternateManufacturerInstance = new Manufacturer(name: tempManufacturerItem,
    297                                                                                                 manufacturerType: manufacturerTypeInstance)
    298                         if(!alternateManufacturerInstance.save()) {
    299                             log.error "Failed to create manufacturers on line: " + lineNumber
    300                             return fail(code: "inventory.import.failure", args: [lineNumber, logFileLink])
    301                         }
    302                     }
    303 
    304                     inventoryParams.alternateManufacturers.add(alternateManufacturerInstance)
    305226                }
    306227
     
    417338                inventoryParams.unitOfMeasure = unitOfMeasureInstance
    418339                inventoryParams.preferredSupplier = preferredSupplierInstance
    419                 inventoryParams.preferredManufacturer = preferredManufacturerInstance
    420340
    421341                // Name.
     
    485405        writer.writeNext("Comment: Required columns are marked with a (*) in the header line.")
    486406        writer.writeNext("Comment: Lists of items in a column must be separated by a semicolon (;), not a comma.")
    487         writer.writeNext("Comment: The at symbol (@) is reserved for indicating supplier and manufacturer types.")
     407        writer.writeNext("Comment: The at symbol (@) is reserved for indicating supplier types.")
    488408        writer.writeNext("Comment: Identical and existing names will be considered as the same item.")
    489409        writer.writeNext("Comment: Lines containing 'comment' will be ignored.")
     
    515435                                        "123", "Multi Supplier@Local",
    516436                                        "Multi Distributors1@OEM; Multi Distributors2@Local",
    517                                         "321", "Master Manufacturer@OEM",
    518                                         "Mega Manufacturer1@OEM;Mega Manufacturer2@Alternate",
    519437                                        "2204E-2RS", ""
    520438                                        ] as String[])
     
    530448                                        "456KL", "Multi Supplier",
    531449                                        "Multi Distributors1; Multi Distributors2",
    532                                         "654OP", "Master Manufacturer",
    533                                         "Mega Manufacturer1;Mega Manufacturer2",
    534450                                        "", ""
    535451                                        ] as String[])
     
    582498            }.collect { it.name + "@" + it.supplierType }.join(';') )
    583499
    584             row.add(inventoryItem.manufacturersPartNumber)
    585 
    586             if(inventoryItem.preferredManufacturer)
    587                 row.add( inventoryItem.preferredManufacturer.name + "@" + inventoryItem.preferredManufacturer.manufacturerType )
    588             else
    589                 row.add('')
    590 
    591             row.add(inventoryItem.alternateManufacturers.sort { p1, p2 ->
    592                 p1.name.compareToIgnoreCase(p2.name)
    593             }.collect { it.name + "@" + it.manufacturerType }.join(';'))
    594 
    595             row.add(inventoryItem.alternateItems.sort { p1, p2 ->
    596                 p1.name.compareToIgnoreCase(p2.name)
    597             }.collect { it.name }.join(';') )
    598 
    599500            row.add(inventoryItem.spareFor.sort { p1, p2 ->
    600501                p1.name.compareToIgnoreCase(p2.name)
     
    813714            "Estimated Unit Price", "Currency", "Enable Reorder", "Location*", "Store*", "Site*", "Group*", "Type*",
    814715            "Supplier's Part Number", "Preferred Supplier", "Alternate Suppliers",
    815             "Manufacturer's Part Number", "Preferred Manufacturer", "Alternate Manufacturers", "Alternate Item", "Spare For"]
     716            "Alternate Item", "Spare For"]
    816717    }
    817718
Note: See TracChangeset for help on using the changeset viewer.