libraries/HighThroughputHelper.rb
def transfer_part_associations(from_collection:, to_collection:)
    copy_sample_matrix(from_collection: from_collection, to_collection: to_collection)
    from_collection_associations = AssociationMap.new(from_collection)
    to_collection_associations   = AssociationMap.new(to_collection)
    from_associations_map = from_collection_associations.instance_variable_get(:@map)
    # Remove previous source data from each part, retain only value where the key is part_data
    from_associations_map.select! {|key| key == 'part_data' } # Retain only the part_data, so that global associations do not get copied over
    from_associations_map.fetch('part_data').map! {|row| row.map! {|part| part.key?("source") ? part.reject! {|k| k == "source" } : part } }
    from_associations_map.fetch('part_data').map! {|row| row.map! {|part| part.key?("destination") ? part.reject! {|k| k == "destination" } : part } }
    # Set edited map to the destination collection_associations
    to_collection_associations.instance_variable_set(:@map, from_associations_map) # setting it to the associations @map will push the part_data onto each part item automatically
    to_collection_associations.save()
    return from_associations_map
  end
# Only transfer part associations to avoid copying over global associations (things directly associated to the collection)
Only transfer part associations to avoid copying over global associations (things directly associated to the collection)
Only transfer part associations to avoid copying over global associations ( things directly associated to the collection )
def transfer_part_associations(from_collection:, to_collection:)
    copy_sample_matrix(from_collection: from_collection, to_collection: to_collection)
    from_collection_associations = AssociationMap.new(from_collection)
    to_collection_associations   = AssociationMap.new(to_collection)
    from_associations_map = from_collection_associations.instance_variable_get(:@map)
    from_associations_map.select! {|key| key == 'part_data' } 
    from_associations_map.fetch('part_data').map! {|row| row.map! {|part| part.key?("source") ? part.reject! {|k| k == "source" } : part } }
    from_associations_map.fetch('part_data').map! {|row| row.map! {|part| part.key?("destination") ? part.reject! {|k| k == "destination" } : part } }
    to_collection_associations.instance_variable_set(:@map, from_associations_map) 
    to_collection_associations.save()
    return from_associations_map
  end
def transfer_part_associations ( from_collection : , to_collection : ) copy_sample_matrix ( from_collection : from_collection , to_collection : to_collection ) from_collection_associations = AssociationMap . new ( from_collection ) to_collection_associations = AssociationMap . new ( to_collection ) from_associations_map = from_collection_associations . instance_variable_get ( :@map ) from_associations_map . select! { | key | key == 'part_data' } from_associations_map . fetch ( 'part_data' ) . map! { | row | row . map! { | part | part . key? ( "source" ) ? part . reject! { | k | k == "source" } : part } } from_associations_map . fetch ( 'part_data' ) . map! { | row | row . map! { | part | part . key? ( "destination" ) ? part . reject! { | k | k == "destination" } : part } } to_collection_associations . instance_variable_set ( :@map , from_associations_map ) to_collection_associations . save ( ) return from_associations_map end
Only transfer part associations to avoid copying over global associations (things directly associated to the collection)
Only transfer part associations to avoid copying over global associations ( things directly associated to the collection )
# Remove previous source data from each part, retain only value where the key is part_data # Retain only the part_data, so that global associations do not get copied over # Set edited map to the destination collection_associations # setting it to the associations @map will push the part_data onto each part item automatically
from_collection
to_collection