'Callback function used to look for duplicates during
the import process
@param item: the S3ImportItem to check'

@staticmethod
def supply_catalog_item_duplicate(item):

    data = item.data
    table = item.table
    query = (table.deleted != True)
    item_id = data.get('item_id')
    if item_id:
        query &= (table.item_id == item_id)
    catalog_id = data.get('catalog_id')
    if catalog_id:
        query &= (table.catalog_id == catalog_id)
    item_category_id = data.get('item_category_id')
    if item_category_id:
        query &= (table.item_category_id == item_category_id)
    duplicate = current.db(query).select(table.id, limitby=(0, 1)).first()
    if duplicate:
        item.id = duplicate.id
        item.method = item.METHOD.UPDATE
