helpers/mappings_helper.rb
##
# Take an array of mappings and replace 'empty' classes with populated ones
# Does a lookup in a provided hash that uses ontology uri + class id as a key
Take an array of mappings and replace 'empty' classes with populated ones
Does a lookup in a provided hash that uses ontology uri + class id as a key
Take an array of mappings and replace ' empty ' classes with populated ones Does a lookup in a provided hash that uses ontology uri + class id as a key
def replace_empty_classes(mappings, populated_hash)
        mappings.each do |map|
          map.classes.each_with_index do |cls, i|
            if cls.respond_to?(:submission)
              found = populated_hash[cls.submission.ontology.id.to_s + cls.id.to_s]
            elsif cls.respond_to?(:getPrefLabel)
              cls.getPrefLabel
              found = cls
            end
            map.classes[i] = found if found
          end
        end
      end
def replace_empty_classes ( mappings , populated_hash ) mappings . each do | map | map . classes . each_with_index do | cls , i | if cls . respond_to? ( :submission ) found = populated_hash [ cls . submission . ontology . id . to_s + cls . id . to_s ] elsif cls . respond_to? ( :getPrefLabel ) cls . getPrefLabel found = cls end map . classes [ i ] = found if found end end end
Take an array of mappings and replace 'empty' classes with populated ones
Does a lookup in a provided hash that uses ontology uri + class id as a key
Take an array of mappings and replace ' empty ' classes with populated ones Does a lookup in a provided hash that uses ontology uri + class id as a key
# if it is an interportal or external mapping, generate the prefLabel
mappings
<not_specific>
populated_hash
<not_specific>