mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
When copying individual collections via the GUI - copy HDAs by default also.
We may want to be able to turn this off someday in certain scenarios - but usually this will result in less confusion for the user. Doing this for whole histories also needs to be done - but it is a bit trickier (don't want the HDA copied twice). Might be better on the other side of eliminating the nessecity that these things have HIDs.
This commit is contained in:
@@ -2711,12 +2711,16 @@ class DatasetCollection( object, Dictifiable, UsesAnnotations ):
|
||||
error_message = "Dataset collection has no %s with key %s." % ( get_by_attribute, key )
|
||||
raise KeyError( error_message )
|
||||
|
||||
def copy( self ):
|
||||
def copy( self, destination=None, element_destination=None ):
|
||||
new_collection = DatasetCollection(
|
||||
collection_type=self.collection_type,
|
||||
)
|
||||
for element in self.elements:
|
||||
element.copy_to_collection( new_collection )
|
||||
element.copy_to_collection(
|
||||
new_collection,
|
||||
destination=destination,
|
||||
element_destination=element_destination,
|
||||
)
|
||||
object_session( self ).add( new_collection )
|
||||
object_session( self ).flush()
|
||||
return new_collection
|
||||
@@ -2835,20 +2839,24 @@ class HistoryDatasetCollectionAssociation( DatasetCollectionInstance, Dictifiabl
|
||||
break
|
||||
return matching_collection
|
||||
|
||||
def copy( self ):
|
||||
def copy( self, element_destination=None ):
|
||||
"""
|
||||
Create a copy of this history dataset collection association. Copy
|
||||
underlying collection.
|
||||
"""
|
||||
hdca = HistoryDatasetCollectionAssociation(
|
||||
hid=self.hid,
|
||||
collection=self.collection.copy(),
|
||||
collection=None,
|
||||
visible=self.visible,
|
||||
deleted=self.deleted,
|
||||
name=self.name,
|
||||
copied_from_history_dataset_collection_association=self,
|
||||
)
|
||||
|
||||
collection_copy = self.collection.copy(
|
||||
destination=hdca,
|
||||
element_destination=element_destination,
|
||||
)
|
||||
hdca.collection = collection_copy
|
||||
object_session( self ).add( hdca )
|
||||
object_session( self ).flush()
|
||||
return hdca
|
||||
@@ -2957,9 +2965,26 @@ class DatasetCollectionElement( object, Dictifiable ):
|
||||
else:
|
||||
return element_object
|
||||
|
||||
def copy_to_collection( self, collection ):
|
||||
def copy_to_collection( self, collection, destination=None, element_destination=None ):
|
||||
element_object = self.element_object
|
||||
if element_destination:
|
||||
if self.is_collection:
|
||||
element_object = element_object.copy(
|
||||
destination=destination,
|
||||
element_destination=element_destination
|
||||
)
|
||||
else:
|
||||
new_element_object = element_object.copy( copy_children=True )
|
||||
if destination is not None and element_object.hidden_beneath_collection_instance:
|
||||
new_element_object.hidden_beneath_collection_instance = destination
|
||||
# Ideally we would not need to give the following
|
||||
# element an HID and it would exist in the history only
|
||||
# as an element of the containing collection.
|
||||
element_destination.add_dataset( new_element_object )
|
||||
element_object = new_element_object
|
||||
|
||||
new_element = DatasetCollectionElement(
|
||||
element=self.element_object,
|
||||
element=element_object,
|
||||
collection=collection,
|
||||
element_index=self.element_index,
|
||||
element_identifier=self.element_identifier,
|
||||
|
||||
@@ -1074,7 +1074,11 @@ class DatasetInterface( BaseUIController, UsesAnnotations, UsesItemRatings, Uses
|
||||
if content.history_content_type == "dataset":
|
||||
hist.add_dataset( content.copy( copy_children=True ) )
|
||||
else:
|
||||
hist.add_dataset_collection( content.copy( ) )
|
||||
copy_collected_datasets = True
|
||||
copy_kwds = {}
|
||||
if copy_collected_datasets:
|
||||
copy_kwds["element_destination"] = hist
|
||||
hist.add_dataset_collection( content.copy( **copy_kwds ) )
|
||||
if current_history in target_histories:
|
||||
refresh_frames = ['history']
|
||||
trans.sa_session.flush()
|
||||
|
||||
Reference in New Issue
Block a user