Class: DBMapping::RelationsMapper
- Defined in:
- lib/data/sqlite/relations_mapper.rb
Overview
class to apply ER-mapping for person to tasks relations in a sqlite database
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#generate_person_and_task_relations(relations) ⇒ Object
public method to map available tasks the its corresponding persons.
-
#initialize(database) ⇒ RelationsMapper
constructor
initialization.
-
#map_entity_relations ⇒ Hash
method to retrieve the task assignments to the persons identified by its corresponding ids.
-
#retrieve_tasks_for_person(p_id) ⇒ Array
method to retrieve the task ids assigned to a person represented by its id.
Methods inherited from Base
Constructor Details
#initialize(database) ⇒ RelationsMapper
initialization
10 11 12 |
# File 'lib/data/sqlite/relations_mapper.rb', line 10 def initialize(database) super(database) end |
Instance Method Details
#generate_person_and_task_relations(relations) ⇒ Object
public method to map available tasks the its corresponding persons
16 17 18 19 20 21 22 |
# File 'lib/data/sqlite/relations_mapper.rb', line 16 def generate_person_and_task_relations(relations) relations.each_pair { |person_id, values| values.each { |task_id| @db_base.map_task_to_person(person_id, task_id) } } end |
#map_entity_relations ⇒ Hash
method to retrieve the task assignments to the persons identified by its corresponding ids
27 28 29 30 31 32 33 34 |
# File 'lib/data/sqlite/relations_mapper.rb', line 27 def map_entity_relations assignments = @db_base.query_assignments results = Hash.new() assignments.each { |result| results[result["P_Id"]] = result["T_Id"] } return results end |
#retrieve_tasks_for_person(p_id) ⇒ Array
method to retrieve the task ids assigned to a person represented by its id
39 40 41 42 43 44 45 46 |
# File 'lib/data/sqlite/relations_mapper.rb', line 39 def retrieve_tasks_for_person(p_id) assignments = @db_base.query_assignments_for_person(p_id) results = Array.new() assignments.each { |result| results << result["T_Id"] } return results end |