Class: Es::HIDField

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_recordid?, #is_snapshot?, #is_timestamp?, #is_velocity?, parse, #to_config_generator, #to_load_config, #to_load_fragment

Constructor Details

#initialize(name, type, options) ⇒ HIDField

Returns a new instance of HIDField.



757
758
759
760
761
762
763
# File 'lib/es.rb', line 757

def initialize(name, type, options)
  name = "#{name}-#{options[:entity]}"
  super(name, type)
  @entity = options[:entity] || fail("Entity has to be scpecified for a HID Field")
  @fieldsInner = options[:fields] || fail("Fields has to be scpecified for a HID Field")
  @through = options[:through]
end

Instance Attribute Details

#entityObject

Returns the value of attribute entity.



751
752
753
# File 'lib/es.rb', line 751

def entity
  @entity
end

#fieldsInnerObject

Returns the value of attribute fieldsInner.



751
752
753
# File 'lib/es.rb', line 751

def fieldsInner
  @fieldsInner
end

#nameObject

Returns the value of attribute name.



751
752
753
# File 'lib/es.rb', line 751

def name
  @name
end

#throughObject

Returns the value of attribute through.



751
752
753
# File 'lib/es.rb', line 751

def through
  @through
end

#typeObject

Returns the value of attribute type.



751
752
753
# File 'lib/es.rb', line 751

def type
  @type
end

Instance Method Details

#is_hid?Boolean

Returns:

  • (Boolean)


753
754
755
# File 'lib/es.rb', line 753

def is_hid?
  true
end

#to_config_generator_extractObject



789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
# File 'lib/es.rb', line 789

def to_config_generator_extract
  if through.empty? then
    {
      :hid => 
          {
                :from_entity => entity,
                :from_fields => fields.map{|f| f}
          }
    }
  else
    {
      :hid => 
          {
                :from_entity => entity,
                :from_fields => fields.map{|f| f},
                :connected_through => through
          }
    
  }
  end
end

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



765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
# File 'lib/es.rb', line 765

def to_extract_fragment(pid, fields, options = {})
  {
    :name => name,
    :preferred => name,
    :definition => {
      :ops  => [
        through.nil? ? {:type => RECORDID_TYPE} : {:type => "stream", :data => through},
        {
          :type => "entity",
          :data => entity,
          :ops  => fieldsInner.map do |f|
            {
              :type => "stream",
              :data => f
            }
          end
        }
      ],
      :type => "historicid"
    }
  }
end