def create_action(self, id_scope=IdScope()): from vistrails.core.mashup.component import Component from vistrails.core.mashup.alias import Alias from vistrails.core.mashup.mashup import Mashup c1 = Component(id=id_scope.getNewId('mashup_component'), vttype='parameter', param_id=15L, parent_vttype='function', parent_id=3L, mid=4L, type='String', value='test', p_pos=0, pos=1, strvaluelist='test1,test2', widget="text") a1 = Alias(id=id_scope.getNewId('mashup_alias'), name='alias1', component=c1) m = Mashup(id=id_scope.getNewId('mashup'), name='mashup1', vtid='empty.vt', version=15L, alias_list=[a1]) action = Action(id=id_scope.getNewId('mashup_action'), prevId=0L, date=datetime(2007, 11, 18), mashup=m) return action
def createMashupVersion(self, alias_list, quiet=False): id = self.id_scope.getNewId('mashup') mashup = Mashup(id=id, name="mashup%s" % id, vtid=self.currentMashup.vtid, version=self.currentMashup.version, alias_list=alias_list) currVersion = self.mshptrail.addVersion(parent_id=self.currentVersion, mashup=mashup, user=current_user(), date=current_time()) self.mshptrail.currentVersion = currVersion self.currentMashup = mashup #print "created new mashup ", currVersion self.setCurrentVersion(currVersion, quiet) self.setChanged(True) return currVersion
def createMashupController(self, vt_controller, version, view=DummyView()): #print "Manager creating mashup controller ", vt_controller, version newvt_controller = MashupsManager.copyVistrailController(vt_controller, view) mashuptrail = \ MashupsManager.getMashuptrailforVersionInVistrailController(vt_controller, version) if mashuptrail is None: (p_mashuptrail, p_version) = \ MashupsManager.findClosestParentMashuptrail(vt_controller, version) id_scope = IdScope(1L) if p_mashuptrail is not None: version_name = vt_controller.get_pipeline_name(p_version) (res, mshpv) = MashupsManager.showFoundMashupsDialog(p_mashuptrail, version_name) if res in ['Copy', 'Move']: pipeline = newvt_controller.vistrail.getPipeline(version) if res == 'Copy': # we will copy the mashup from the parent trail and # validate it to the current pipeline before adding # to the current mashup trail mashuptrail = Mashuptrail(self.getNewMashuptrailId(), version, id_scope) p_mashup = p_mashuptrail.getMashup(mshpv) mashup = p_mashup.do_copy() mashup.id_scope = id_scope mashup.version = version mashup.validateForPipeline(pipeline) currVersion = mashuptrail.addVersion( parent_id=mashuptrail.getLatestVersion(), mashup=mashup, user=vistrails.core.system.current_user(), date=vistrails.core.system.current_time()) mashuptrail.currentVersion = currVersion mashuptrail.updateIdScope() p_tag = p_mashuptrail.getTagForActionId(mshpv) if p_tag == '': tag = "<latest>" tag = "Copy from %s"%p_tag MashupsManager.addMashuptrailtoVistrailController(vt_controller, mashuptrail) elif res == 'Move': # we will move the parent trail and validate all mashups # for the current pipeline to make sure they will be # executable for the current version mashuptrail = p_mashuptrail currVersion = mashuptrail.getLatestVersion() mashuptrail.currentVersion = currVersion mashuptrail.validateMashupsForPipeline(version, pipeline) tag = None mashuptrail.vtVersion = version mshpController = MashupController(vt_controller, newvt_controller, version, mashuptrail) mshpController.setCurrentVersion(mashuptrail.currentVersion) # this is to make sure the pipeline displayed in the mashup # view is consistent with the list of aliases in the central # panel mshpController.updatePipelineAliasesFromCurrentMashup() if tag is not None: mshpController.updateCurrentTag(tag) return mshpController mashuptrail = Mashuptrail(self.getNewMashuptrailId(), version, id_scope) pipeline = newvt_controller.vistrail.getPipeline(version) id = id_scope.getNewId('mashup') mashup = Mashup(id=id, name="mashup%s"%id, vtid=vt_controller.locator, version=version) mashup.loadAliasesFromPipeline(pipeline, id_scope) currVersion = mashuptrail.addVersion(parent_id=mashuptrail.getLatestVersion(), mashup=mashup, user=vistrails.core.system.current_user(), date=vistrails.core.system.current_time()) mashuptrail.currentVersion = currVersion MashupsManager.addMashuptrailtoVistrailController(vt_controller, mashuptrail) mshpController = MashupController(vt_controller, newvt_controller, version, mashuptrail) mshpController.setCurrentVersion(mashuptrail.currentVersion) if mshpController.currentVersion == 1L: mshpController.updateCurrentTag("ROOT") else: #print "----> found mashuptrail ", mashuptrail.currentVersion mshpController = MashupController(vt_controller, newvt_controller, version, mashuptrail) mshpController.setCurrentVersion(mashuptrail.currentVersion) mshpController.updatePipelineAliasesFromCurrentMashup() return mshpController
def createMashupController(self, vt_controller, version, view=DummyView()): #print "Manager creating mashup controller ", vt_controller, version newvt_controller = MashupsManager.copyVistrailController( vt_controller, view) mashuptrail = \ MashupsManager.getMashuptrailforVersionInVistrailController(vt_controller, version) if mashuptrail is None: (p_mashuptrail, p_version) = \ MashupsManager.findClosestParentMashuptrail(vt_controller, version) id_scope = IdScope(1L) if p_mashuptrail is not None: version_name = vt_controller.get_pipeline_name(p_version) (res, mshpv) = MashupsManager.showFoundMashupsDialog( p_mashuptrail, version_name) if res in ['Copy', 'Move']: pipeline = newvt_controller.vistrail.getPipeline(version) if res == 'Copy': # we will copy the mashup from the parent trail and # validate it to the current pipeline before adding # to the current mashup trail mashuptrail = Mashuptrail(self.getNewMashuptrailId(), version, id_scope) p_mashup = p_mashuptrail.getMashup(mshpv) mashup = p_mashup.do_copy() mashup.id_scope = id_scope mashup.version = version mashup.validateForPipeline(pipeline) currVersion = mashuptrail.addVersion( parent_id=mashuptrail.getLatestVersion(), mashup=mashup, user=vistrails.core.system.current_user(), date=vistrails.core.system.current_time()) mashuptrail.currentVersion = currVersion mashuptrail.updateIdScope() p_tag = p_mashuptrail.getTagForActionId(mshpv) if p_tag == '': tag = "<latest>" tag = "Copy from %s" % p_tag MashupsManager.addMashuptrailtoVistrailController( vt_controller, mashuptrail) else: # res == 'Move' # we will move the parent trail and validate all mashups # for the current pipeline to make sure they will be # executable for the current version mashuptrail = p_mashuptrail currVersion = mashuptrail.getLatestVersion() mashuptrail.currentVersion = currVersion mashuptrail.validateMashupsForPipeline( version, pipeline) tag = None mashuptrail.vtVersion = version mshpController = MashupController(vt_controller, newvt_controller, version, mashuptrail) mshpController.setCurrentVersion( mashuptrail.currentVersion) # this is to make sure the pipeline displayed in the mashup # view is consistent with the list of aliases in the central # panel mshpController.updatePipelineAliasesFromCurrentMashup() if tag is not None: mshpController.updateCurrentTag(tag) return mshpController mashuptrail = Mashuptrail(self.getNewMashuptrailId(), version, id_scope) pipeline = newvt_controller.vistrail.getPipeline(version) id = id_scope.getNewId('mashup') mashup = Mashup(id=id, name="mashup%s" % id, vtid=vt_controller.locator, version=version) mashup.loadAliasesFromPipeline(pipeline, id_scope) currVersion = mashuptrail.addVersion( parent_id=mashuptrail.getLatestVersion(), mashup=mashup, user=vistrails.core.system.current_user(), date=vistrails.core.system.current_time()) mashuptrail.currentVersion = currVersion MashupsManager.addMashuptrailtoVistrailController( vt_controller, mashuptrail) mshpController = MashupController(vt_controller, newvt_controller, version, mashuptrail) mshpController.setCurrentVersion(mashuptrail.currentVersion) if mshpController.currentVersion == 1L: mshpController.updateCurrentTag("ROOT") else: #print "----> found mashuptrail ", mashuptrail.currentVersion mshpController = MashupController(vt_controller, newvt_controller, version, mashuptrail) mshpController.setCurrentVersion(mashuptrail.currentVersion) mshpController.updatePipelineAliasesFromCurrentMashup() return mshpController
def do_copy(self, new_ids=False, id_scope=None, id_remap=None): cp = DBMashupAction.do_copy(self, new_ids, id_scope, id_remap) cp.__class__ = Action Mashup.convert(cp.mashup) return cp
def convert(_action): if _action.__class__ == Action: return _action.__class__ = Action Mashup.convert(_action.mashup)