sentences.rb revision 00e4f15826d75fbfc079bef3e559b7fa4c62e911
881N/Amodule Ontology::Sentences
881N/A extend ActiveSupport::Concern
881N/A
881N/A included do
881N/A has_many :sentences, :extend => Methods
881N/A end
881N/A
881N/A module Methods
881N/A def update_or_create_from_hash(hash, timestamp = Time.now)
881N/A e = find_or_initialize_by_name(hash['name'])
881N/A
881N/A e.text = hash['text'].to_s
881N/A e.range = hash['range']
881N/A e.updated_at = timestamp
881N/A
881N/A e.save!
881N/A
881N/A execute_sql "DELETE FROM sentences_entities WHERE sentence_id=#{e.id}"
881N/A execute_sql "INSERT INTO sentences_entities (sentence_id, entity_id, ontology_version_id)
881N/A SELECT #{e.id}, id, ontology_id FROM entities WHERE
881N/A ontology_id=#{@association.owner.id} AND text IN (?)",
881N/A hash['symbols']
881N/A
881N/A e
881N/A end
881N/A end
881N/Aend
881N/A