Module: TaliaCore::ActiveSourceParts::SqlHelper

Included in:
TaliaCore::ActiveSource
Defined in:
lib/talia_core/active_source_parts/sql_helper.rb

Overview

This contains sql joins and segments that can be used by the ActiveSource classes.

Instance Method Summary collapse

Instance Method Details

#default_inv_joinsObject

Returns the “default” join for reverse lookups



28
29
30
31
32
# File 'lib/talia_core/active_source_parts/sql_helper.rb', line 28

def default_inv_joins
  join = "LEFT JOIN semantic_relations ON semantic_relations.object_id = active_sources.id AND semantic_relations.object_type = 'TaliaCore::ActiveSource' "
  join << " LEFT JOIN active_sources AS sub_sources ON semantic_relations.subject_id = sub_sources.id"
  join
end

#default_joins(include_rels = true, include_props = true) ⇒ Object

Returns the “default” join (meaning that it joins all the “triple tables” together. The flags signal whether the relations and properties should be joined.



10
11
12
13
14
15
# File 'lib/talia_core/active_source_parts/sql_helper.rb', line 10

def default_joins(include_rels = true, include_props = true)
  join = "LEFT JOIN semantic_relations ON semantic_relations.subject_id = active_sources.id "
  join << sources_join if(include_rels)
  join << props_join  if(include_props)
  join
end

#props_joinObject

Joins properties on semantic relations



23
24
25
# File 'lib/talia_core/active_source_parts/sql_helper.rb', line 23

def props_join
  " LEFT JOIN semantic_properties AS obj_props ON semantic_relations.object_id = obj_props.id AND semantic_relations.object_type = 'TaliaCore::SemanticProperty'"
end

#sources_joinObject

Joins sources on semantic relations



18
19
20
# File 'lib/talia_core/active_source_parts/sql_helper.rb', line 18

def sources_join
  " LEFT JOIN active_sources AS obj_sources ON semantic_relations.object_id = obj_sources.id AND semantic_relations.object_type = 'TaliaCore::ActiveSource'"
end