app/models/trait_bank/json_ld.rb
# NOTE: We look for an ITIS entry first, because it is the most robust,
# detailed, and stable option. WHEN YOU CHANGE THIS (i.e.: when we get the
# so-called "Dynamic EOL Hierarchy"), please let Google know that you've done
# so: they will need to reindex things.
We look for an ITIS entry first, because it is the most robust,
detailed, and stable option. WHEN YOU CHANGE THIS , please let Google know that you've done
so: they will need to reindex things.
We look for an ITIS entry first because it is the most robust detailed and stable option . WHEN YOU CHANGE THIS please let Google know that you ' ve done so : they will need to reindex things .
def for_concept(concept, traits = nil)
      stable_entry = concept.entry(Hierarchy.itis)
      feed = {
        "@id" => concept.id,
        "@type" => "dwc:Taxon",
        "scientificName" => stable_entry.name.string,
        "dwc:taxonRank" => (stable_entry.rank) ? stable_entry.rank.label : nil }
      if parent = stable_entry.parent
        feed["dwc:parentNameUsageID"] =
          KnownUri.taxon_uri(parent.taxon_concept_id)
      end
      page_url = "http://eol.org/pages/#{concept.id}"
      feed["potentialAction"] =
        target("EntryPoint", "Related", page_url)
      feed["sameAs"] = concept.published_hierarchy_entries.map(&:outlink_url).compact
      feed["vernacularNames"] =
        concept.common_names.map { |tcn| tcn.to_json_hash }
      page = PageTraits.new(concept.id)
      page.populate
      traits ||= page.traits
      feed["traits"] = traits ?
        traits.map { |trait| for_trait(trait, page_url) } :
        []
      feed
    end
def for_concept ( concept , traits = nil ) stable_entry = concept . entry ( Hierarchy . itis ) feed = { "@id" => concept . id , "@type" => "dwc:Taxon" , "scientificName" => stable_entry . name . string , "dwc:taxonRank" => ( stable_entry . rank ) ? stable_entry . rank . label : nil } if parent = stable_entry . parent feed [ "dwc:parentNameUsageID" ] = KnownUri . taxon_uri ( parent . taxon_concept_id ) end page_url = "http://eol.org/pages/#{concept.id}" feed [ "potentialAction" ] = target ( "EntryPoint" , "Related" , page_url ) feed [ "sameAs" ] = concept . published_hierarchy_entries . map ( & :outlink_url ) . compact feed [ "vernacularNames" ] = concept . common_names . map { | tcn | tcn . to_json_hash } page = PageTraits . new ( concept . id ) page . populate traits ||= page . traits feed [ "traits" ] = traits ? traits . map { | trait | for_trait ( trait , page_url ) } : [ ] feed end
NOTE: We look for an ITIS entry first, because it is the most robust,
detailed, and stable option.
NOTE : We look for an ITIS entry first because it is the most robust detailed and stable option .
concept
<not_specific>
traits
<not_specific>