sentences.rb revision 43998a7504eb0ead17751c3232763b56bbc1c7f5
4b8c0f56a6a49c41dd0e9fdd28a27c4f35e2a208Julian Kornbergermodule Ontology::Sentences
4b8c0f56a6a49c41dd0e9fdd28a27c4f35e2a208Julian Kornberger extend ActiveSupport::Concern
82f1abf37f3f32db5927f385dda0d07b5013a4eaTim Reddehase
4b8c0f56a6a49c41dd0e9fdd28a27c4f35e2a208Julian Kornberger included do
has_many :sentences, :extend => Methods
end
module Methods
def update_or_create_from_hash(hash, timestamp = Time.now)
e = find_or_initialize_by_name(hash['name'])
e.text = hash['text'].to_s
e.range = hash['range']
e.updated_at = timestamp
e.save!
execute_sql "DELETE FROM entities_sentences WHERE sentence_id=#{e.id}"
execute_sql "INSERT INTO entities_sentences (sentence_id, entity_id, ontology_id)
SELECT #{e.id}, id, ontology_id FROM entities WHERE
ontology_id=#{@association.owner.id} AND text IN (?)",
hash['symbols']
e.set_display_text!
e
end
end
end