commit/galaxy-central: jmchilton: When copying individual collections via the GUI - copy HDAs by default also.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/4d62fbb0458b/ Changeset: 4d62fbb0458b User: jmchilton Date: 2015-02-09 18:29:45+00:00 Summary: 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. Affected #: 2 files diff -r d9325c4bf7d670b6024b33c9723bb83e1856db6e -r 4d62fbb0458b49add6a009d86f17719dece7452f lib/galaxy/model/__init__.py --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -2711,12 +2711,16 @@ 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 @@ 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 @@ 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, diff -r d9325c4bf7d670b6024b33c9723bb83e1856db6e -r 4d62fbb0458b49add6a009d86f17719dece7452f lib/galaxy/webapps/galaxy/controllers/dataset.py --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -1074,7 +1074,11 @@ 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() Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org