mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
copies the tags from a source history when a workflow is creating new histories to store results.
moves tag copying logic into the model for TagAssociation class adds copy_tags_from method to history and storedworkflow classes
This commit is contained in:
@@ -434,7 +434,10 @@ class History( object, UsesAnnotations ):
|
||||
|
||||
# Copy annotation.
|
||||
self.copy_item_annotation( db_session, self.user, self, target_user, new_history )
|
||||
|
||||
|
||||
#Copy Tags
|
||||
new_history.copy_tags_from(target_user=target_user, source_history=self)
|
||||
|
||||
# Copy HDAs.
|
||||
if activatable:
|
||||
hdas = self.activatable_datasets
|
||||
@@ -494,6 +497,12 @@ class History( object, UsesAnnotations ):
|
||||
if nice_size:
|
||||
rval = galaxy.datatypes.data.nice_size( rval )
|
||||
return rval
|
||||
|
||||
def copy_tags_from(self,target_user,source_history):
|
||||
for src_shta in source_history.tags:
|
||||
new_shta = src_shta.copy()
|
||||
new_shta.user = target_user
|
||||
self.tags.append(new_shta)
|
||||
|
||||
class HistoryUserShareAssociation( object ):
|
||||
def __init__( self ):
|
||||
@@ -1717,6 +1726,12 @@ class StoredWorkflow( object, APIItem):
|
||||
self.published = False
|
||||
self.latest_workflow_id = None
|
||||
self.workflows = []
|
||||
|
||||
def copy_tags_from(self,target_user,source_workflow):
|
||||
for src_swta in source_workflow.owner_tags:
|
||||
new_swta = src_swta.copy()
|
||||
new_swta.user = target_user
|
||||
self.tags.append(new_swta)
|
||||
|
||||
class Workflow( object ):
|
||||
def __init__( self ):
|
||||
@@ -2543,7 +2558,15 @@ class ItemTagAssociation ( object ):
|
||||
self.user_tname = user_tname
|
||||
self.value = None
|
||||
self.user_value = None
|
||||
|
||||
|
||||
def copy(self):
|
||||
new_ta = type(self)()
|
||||
new_ta.tag_id = self.tag_id
|
||||
new_ta.user_tname = self.user_tname
|
||||
new_ta.value = self.value
|
||||
new_ta.user_value = self.user_value
|
||||
return new_ta
|
||||
|
||||
class HistoryTagAssociation ( ItemTagAssociation ):
|
||||
pass
|
||||
|
||||
|
||||
@@ -508,7 +508,6 @@ class WorkflowController( BaseUIController, SharableMixin, UsesStoredWorkflowMix
|
||||
trans.response.set_content_type("image/svg+xml")
|
||||
return self._workflow_to_svg_canvas( trans, stored ).standalone_xml()
|
||||
|
||||
|
||||
@web.expose
|
||||
@web.require_login( "use Galaxy workflows" )
|
||||
def clone( self, trans, id ):
|
||||
@@ -531,15 +530,8 @@ class WorkflowController( BaseUIController, SharableMixin, UsesStoredWorkflowMix
|
||||
annotation_obj = self.get_item_annotation_obj( trans.sa_session, stored.user, stored )
|
||||
if annotation_obj:
|
||||
self.add_item_annotation( trans.sa_session, trans.get_user(), new_stored, annotation_obj.annotation )
|
||||
# Clone tags.
|
||||
for swta in stored.owner_tags:
|
||||
new_swta = model.StoredWorkflowTagAssociation()
|
||||
new_swta.tag = swta.tag
|
||||
new_swta.user = trans.user
|
||||
new_swta.user_tname = swta.user_tname
|
||||
new_swta.user_value = swta.user_value
|
||||
new_swta.value = swta.value
|
||||
new_stored.tags.append( new_swta )
|
||||
new_stored.copy_tags_from(trans.user,stored)
|
||||
|
||||
if not owner:
|
||||
new_stored.name += " shared by '%s'" % stored.user.email
|
||||
new_stored.user = user
|
||||
@@ -1408,6 +1400,7 @@ class WorkflowController( BaseUIController, SharableMixin, UsesStoredWorkflowMix
|
||||
mx_ds_name = trans.sa_session.query(trans.app.model.HistoryDatasetAssociation).get( single_input ).name
|
||||
nh_name = '%s on %s' % (nh_name, mx_ds_name)
|
||||
new_history = trans.app.model.History( user=trans.user, name=nh_name )
|
||||
new_history.copy_tags_from(trans.user, trans.get_history())
|
||||
trans.sa_session.add( new_history )
|
||||
target_history = new_history
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user