Sha256: 3b5e485047fa78762ac978eeb396f5acfc11de847dddc8cb36c77611f17a5f44

Contents?: true

Size: 1.48 KB

Versions: 28

Compression:

Stored size: 1.48 KB

Contents

module TaliaCore
  module ActiveSourceParts
    
    # This contains sql joins and segments that can be used by the ActiveSource classes.
    module SqlHelper
      
      # Returns the "default" join (meaning that it joins all the "triple tables"
      # together. The flags signal whether the relations and properties should 
      # be joined.
      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

      # Joins sources on semantic relations
      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

      # Joins properties on semantic relations
      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

      # Returns the "default" join for reverse lookups
      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
      
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
talia_core-0.7.0 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.5.4 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.5.3 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.5.2 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.5.1 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.5.0 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.22 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.20 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.19 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.18 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.17 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.16 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.15 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.14 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.13 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.12 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.11 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.10 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.9 lib/talia_core/active_source_parts/sql_helper.rb
talia_core-0.4.8 lib/talia_core/active_source_parts/sql_helper.rb