def migratable__migrate_owner(row, migrated, target, proc_hash=nil)
      # the owner attributes=> migrated reference hash
      ovh = self.class.owner_attributes.to_compact_hash do |mattr|
        pa = self.class.property(mattr)
        migratable__target_value(pa, row, migrated, proc_hash)
      end
      # If there is more than one owner candidate, then select the owner
      # attribute which references the target. If there is more than one
      # such attribute, then select the preferred owner.
      if ovh.size > 1 then
        tvh = ovh.filter_on_value { |ov| target === ov }.to_hash
        if tvh.size == 1 then
          ovh = tvh
        else
          ownrs = ovh.values.uniq
          if ownrs.size == 1 then
            ovh = {ovh.keys.first => ownrs.first}
          else
            logger.debug { "The migrated dependent #{qp} has ambiguous migrated owner references #{ovh.qp}." }
            preferred = migratable__preferred_owner(ownrs)
            if preferred then
              logger.debug { "The preferred dependent #{qp} migrated owner reference is #{preferred.qp}." }
              ovh = {ovh.keys.detect { |k| ovh[k] == preferred } => preferred}
            end
          end
        end
      end
      if ovh.size == 1 then
        oattr, oref = ovh.first
        set_property_value(oattr, oref)
        logger.debug { "Set the #{qp} #{oattr} owner to the migrated #{oref.qp}." }
      end
      oref
    end
def migratable__migrate_owner(row, migrated, target, proc_hash=nil)
      # the owner attributes=> migrated reference hash
      ovh = self.class.owner_attributes.to_compact_hash do |mattr|
        pa = self.class.property(mattr)
        migratable__target_value(pa, row, migrated, proc_hash)
      end
      # If there is more than one owner candidate, then select the owner
      # attribute which references the target. If there is more than one
      # such attribute, then select the preferred owner.
      if ovh.size > 1 then
        tvh = ovh.filter_on_value { |ov| target === ov }.to_hash
        if tvh.size == 1 then
          ovh = tvh
        else
          ownrs = ovh.values.uniq
          if ownrs.size == 1 then
            ovh = {ovh.keys.first => ownrs.first}
          else
            logger.debug { "The migrated dependent #{qp} has ambiguous migrated owner references #{ovh.qp}." }
            preferred = migratable__preferred_owner(ownrs)
            if preferred then
              logger.debug { "The preferred dependent #{qp} migrated owner reference is #{preferred.qp}." }
              ovh = {ovh.keys.detect { |k| ovh[k] == preferred } => preferred}
            end
          end
        end
      end
      if ovh.size == 1 then
        oattr, oref = ovh.first
        set_property_value(oattr, oref)
        logger.debug { "Set the #{qp} #{oattr} owner to the migrated #{oref.qp}." }
      end
      oref
    end
Migrates the owner as follows:
 * If there is exactly one migrated owner, then the owner reference is
   set to that owner.
 * Otherwise, if there is more than one owner but only one owner instance
   of the given target class, then that target instance is that owner.
 * Otherwise, no reference is set.

 @param row (see #migrate_references)
 @param migrated (see #migrate_references)
 @param target (see #migrate_references)
 @param proc_hash (see #migrate_references)
 @return [Resource, nil] the migrated owner, if any