app/models/bplmodels/mods_desc_metadata.rb
def insert_geonames(geonames_id)
      puts 'Geonames ID is: ' + geonames_id

      #Duplicate Geonames value?
      if self.subject.valueURI.include?(geonames_id)
        return false
      end

      api_result = Geomash::Geonames.get_geonames_data(geonames_id)

      puts 'API Result is: ' + api_result.to_s


      subject_index = self.mods(0).subject.count

      self.mods(0).subject(subject_index).authority = "geonames"
      self.mods(0).subject(subject_index).valueURI = "http://sws.geonames.org/#{geonames_id}"
      self.mods(0).subject(subject_index).authorityURI = 'http://sws.geonames.org'


      self.mods(0).subject(subject_index).geographic = api_result[:hier_geo].values[-1]


      #Insert Coordinates
      if api_result[:coords] != nil
        self.mods(0).subject(subject_index).cartographics.coordinates = api_result[:coords][:latitude] + "," + api_result[:coords][:longitude]
      end
    end
#include Hydra::Datastream::CommonModsIndexMethods
# MODS XML constants.
include Hydra::Datastream::CommonModsIndexMethods
MODS XML constants.
include Hydra :: Datastream :: CommonModsIndexMethods MODS XML constants .
def insert_geonames(geonames_id)
      puts 'Geonames ID is: ' + geonames_id
      if self.subject.valueURI.include?(geonames_id)
        return false
      end
      api_result = Geomash::Geonames.get_geonames_data(geonames_id)
      puts 'API Result is: ' + api_result.to_s
      subject_index = self.mods(0).subject.count
      self.mods(0).subject(subject_index).authority = "geonames"
      self.mods(0).subject(subject_index).valueURI = "http://sws.geonames.org/#{geonames_id}"
      self.mods(0).subject(subject_index).authorityURI = 'http://sws.geonames.org'
      self.mods(0).subject(subject_index).geographic = api_result[:hier_geo].values[-1]
      if api_result[:coords] != nil
        self.mods(0).subject(subject_index).cartographics.coordinates = api_result[:coords][:latitude] + "," + api_result[:coords][:longitude]
      end
    end
def insert_geonames ( geonames_id ) puts 'Geonames ID is: ' + geonames_id if self . subject . valueURI . include? ( geonames_id ) return false end api_result = Geomash :: Geonames . get_geonames_data ( geonames_id ) puts 'API Result is: ' + api_result . to_s subject_index = self . mods ( 0 ) . subject . count self . mods ( 0 ) . subject ( subject_index ) . authority = "geonames" self . mods ( 0 ) . subject ( subject_index ) . valueURI = "http://sws.geonames.org/#{geonames_id}" self . mods ( 0 ) . subject ( subject_index ) . authorityURI = 'http://sws.geonames.org' self . mods ( 0 ) . subject ( subject_index ) . geographic = api_result [ :hier_geo ] . values [ - 1 ] if api_result [ :coords ] != nil self . mods ( 0 ) . subject ( subject_index ) . cartographics . coordinates = api_result [ :coords ] [ :latitude ] + "," + api_result [ :coords ] [ :longitude ] end end
include Hydra::Datastream::CommonModsIndexMethods
MODS XML constants.
include Hydra :: Datastream :: CommonModsIndexMethods MODS XML constants .
#Duplicate Geonames value? #Insert Coordinates
geonames_id