Class: Es::RecordIdField

Inherits:
Field
  • Object
show all
Defined in:
lib/es.rb

Constant Summary

Constants inherited from Field

Field::ATTRIBUTE_TYPE, Field::AUTOINCREMENT_TYPE, Field::DATE_TYPE, Field::DURATION_TYPE, Field::FACT_TYPE, Field::FIELD_TYPES, Field::HID_TYPE, Field::HISTORIC_TYPE, Field::IS_DELETED_TYPE, Field::RECORDID_TYPE, Field::SNAPSHOT_TYPE, Field::TIMEATTRIBUTE_TYPE, Field::TIMESTAMP_TYPE, Field::TIME_TYPE, Field::VELOCITY_TYPE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Field

#==, #is_attribute?, #is_autoincrement?, #is_date?, #is_duration?, #is_fact?, #is_hid?, #is_snapshot?, #is_timestamp?, #is_velocity?, parse, #to_config_generator, #to_config_generator_extract, #to_load_config, #to_load_fragment

Constructor Details

#initialize(name, type, partial) ⇒ RecordIdField

Returns a new instance of RecordIdField.



679
680
681
682
683
684
685
686
# File 'lib/es.rb', line 679

def initialize(name, type, partial)
  fail Es::IncorrectSpecificationError.new("The field name \"#{name.bright}\" does not have type specified. Type should be one of [#{FIELD_TYPES.join(', ')}]") if type.nil?
  fail Es::IncorrectSpecificationError.new("The type of field name \"#{name.bright}\" should be a string.") unless type.is_a?(String)
  fail Es::IncorrectSpecificationError.new("The field name \"#{name.bright}\" does have wrong type specified. Specified \"#{type.bright}\" should be one of [#{FIELD_TYPES.join(', ')}]") unless FIELD_TYPES.include?(type) || type == "none"
  @name = name
  @type = type
  @partial = partial
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



677
678
679
# File 'lib/es.rb', line 677

def name
  @name
end

#partialObject

Returns the value of attribute partial.



677
678
679
# File 'lib/es.rb', line 677

def partial
  @partial
end

#typeObject

Returns the value of attribute type.



677
678
679
# File 'lib/es.rb', line 677

def type
  @type
end

Instance Method Details

#is_recordid?Boolean

Returns:

  • (Boolean)


688
689
690
# File 'lib/es.rb', line 688

def is_recordid?
  true
end

#to_extract_fragment(pid, fields, options = {}) ⇒ Object



692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/es.rb', line 692

def to_extract_fragment(pid, fields, options = {})
if (partial == "true") then
   {
    :name => name,
    :preferred => name,
    :definition => {
      :ops => [{
        :type => Es::Helpers.type_to_type(type),
        :data => name,
        :ops => fields.select{|x| Es::Helpers.type_to_type(x.type) == "stream"}.map do |f|
                  {
                    :type => "stream",
                    :data => f.name
                  }
          end
      }],
      :type => Es::Helpers.type_to_operation(type)
    }
  } 
  else 
  {
    :name => name,
    :preferred => name,
    :definition => {
      :ops => [{
        :type => Es::Helpers.type_to_type(type),
        :data => name
      }],
      :type => Es::Helpers.type_to_operation(type)
    }
  }
  end
end