def hash_to_item(hash)
      item = ResultItem.new

      bibjson = hash["bibjson"] || {}

      item.unique_id  = hash["id"]

      # Hard-code to Article, we don't get any format information
      item.format     = "Article"

      item.title      = bibjson["title"]


      item.start_page = bibjson["start_page"]
      item.end_page   = bibjson["end_page"]

      item.year       = bibjson["year"]
      if (year = bibjson["year"].to_i) && (month = bibjson["month"].to_i)
        if year != 0 && month != 0
          item.publication_date = Date.new(bibjson["year"].to_i, bibjson["month"].to_i)
        end
      end

      item.abstract   = sanitize(bibjson["abstract"]) if bibjson.has_key?("abstract")

      journal           = bibjson["journal"] || {}
      item.volume       = journal["volume"]
      item.issue        = journal["number"]
      item.source_title = journal["title"]
      item.publisher    = journal["publisher"]
      item.language_str = journal["language"].try(:first)

      (bibjson["identifier"] || []).each do |id_hash|
        case id_hash["type"]
        when "doi"
          item.doi = id_hash["id"]
        when "pissn"
          item.issn = id_hash["id"]
        end
      end

      (bibjson["author"] || []).each do |author_hash|
        if author_hash.has_key?("name")
          author = Author.new(:display => author_hash["name"])
          item.authors << author
        end
      end

      # I _think_ DOAJ articles results always only have one link,
      # and it may always be of type 'fulltext'
      link_hash             = (bibjson["link"] || []).first
      if link_hash && link_hash["url"]
        item.link             = link_hash["url"]
        item.link_is_fulltext = true if link_hash["type"] == "fulltext"
      end

      return item
    end
def hash_to_item(hash)
      item = ResultItem.new

      bibjson = hash["bibjson"] || {}

      item.unique_id  = hash["id"]

      # Hard-code to Article, we don't get any format information
      item.format     = "Article"

      item.title      = bibjson["title"]


      item.start_page = bibjson["start_page"]
      item.end_page   = bibjson["end_page"]

      item.year       = bibjson["year"]
      if (year = bibjson["year"].to_i) && (month = bibjson["month"].to_i)
        if year != 0 && month != 0
          item.publication_date = Date.new(bibjson["year"].to_i, bibjson["month"].to_i)
        end
      end

      item.abstract   = sanitize(bibjson["abstract"]) if bibjson.has_key?("abstract")

      journal           = bibjson["journal"] || {}
      item.volume       = journal["volume"]
      item.issue        = journal["number"]
      item.source_title = journal["title"]
      item.publisher    = journal["publisher"]
      item.language_str = journal["language"].try(:first)

      (bibjson["identifier"] || []).each do |id_hash|
        case id_hash["type"]
        when "doi"
          item.doi = id_hash["id"]
        when "pissn"
          item.issn = id_hash["id"]
        end
      end

      (bibjson["author"] || []).each do |author_hash|
        if author_hash.has_key?("name")
          author = Author.new(:display => author_hash["name"])
          item.authors << author
        end
      end

      # I _think_ DOAJ articles results always only have one link,
      # and it may always be of type 'fulltext'
      link_hash             = (bibjson["link"] || []).first
      if link_hash && link_hash["url"]
        item.link             = link_hash["url"]
        item.link_is_fulltext = true if link_hash["type"] == "fulltext"
      end

      return item
    end
Converts from item found in DOAJ results to BentoSearch::ResultItem