lib/cultural_network/import/feature_importation.rb
# The optional column "feature_types.id" can be used to specify the feature object type name.
# If there is a category title, then optional columns are "categories.info_source.id" and
# "categories.time_units.date".  
The optional column "feature_types.id" can be used to specify the feature object type name.
The optional column " feature_types . id " can be used to specify the feature object type name .
def process_feature_types(n)
      feature_ids_with_object_types_added = Array.new
      delete_types = self.fields.delete('feature_types.delete')
      feature_object_types = self.feature.feature_object_types    
      feature_object_types.clear if !delete_types.blank? && delete_types.downcase == 'yes'
      0.upto(n) do |i|
        prefix = i>0 ? "#{i}.feature_types" : 'feature_types'
        feature_type_id = self.fields.delete("#{prefix}.id")
        next if feature_type_id.blank?
        category = Category.find(feature_type_id)
        if category.nil?
          puts "Feature type #{feature_type_id} not found."
          next
        end
        feature_object_type = feature_object_types.where(:category_id => category.id).first
        if feature_object_type.nil?
          feature_object_type = feature_object_types.create(:category => category, :skip_update => true)
          feature_ids_with_object_types_added << self.feature.id if !feature_ids_with_object_types_added.include? self.feature.id
        end
        if feature_object_type.nil?
          puts "Couldn't associate feature type #{feature_type_id} to feature #{self.feature.pid}"
          next
        end
        self.add_date(prefix, feature_object_type)
        self.add_info_source(prefix, feature_object_type)
        self.add_note(prefix, feature_object_type)
        1.upto(8) do |j|
          field_prefix = "#{prefix}.#{j}"
          self.add_info_source(field_prefix, feature_object_type)
          self.add_date(field_prefix, feature_object_type)
          self.add_note(field_prefix, feature_object_type)
        end
      end
      return feature_ids_with_object_types_added
    end
def process_feature_types ( n ) feature_ids_with_object_types_added = Array . new delete_types = self . fields . delete ( 'feature_types.delete' ) feature_object_types = self . feature . feature_object_types feature_object_types . clear if ! delete_types . blank? && delete_types . downcase == 'yes' 0 . upto ( n ) do | i | prefix = i > 0 ? "#{i}.feature_types" : 'feature_types' feature_type_id = self . fields . delete ( "#{prefix}.id" ) next if feature_type_id . blank? category = Category . find ( feature_type_id ) if category . nil? puts "Feature type #{feature_type_id} not found." next end feature_object_type = feature_object_types . where ( :category_id => category . id ) . first if feature_object_type . nil? feature_object_type = feature_object_types . create ( :category => category , :skip_update => true ) feature_ids_with_object_types_added << self . feature . id if ! feature_ids_with_object_types_added . include? self . feature . id end if feature_object_type . nil? puts "Couldn't associate feature type #{feature_type_id} to feature #{self.feature.pid}" next end self . add_date ( prefix , feature_object_type ) self . add_info_source ( prefix , feature_object_type ) self . add_note ( prefix , feature_object_type ) 1 . upto ( 8 ) do | j | field_prefix = "#{prefix}.#{j}" self . add_info_source ( field_prefix , feature_object_type ) self . add_date ( field_prefix , feature_object_type ) self . add_note ( field_prefix , feature_object_type ) end end return feature_ids_with_object_types_added end
The optional column "feature_types.id" can be used to specify the feature object type name.
The optional column " feature_types . id " can be used to specify the feature object type name .
n
<not_specific>