Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 def create_action(self, id_scope=IdScope()):
     from core.mashup.component import Component
     from core.mashup.alias import Alias
     c1 = Component(id=id_scope.getNewId('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('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('action'),
                     parent_id=0L,
                     date=datetime(2007,11,18),
                     mashup=m)
     return action
Exemplo n.º 3
0
 def fromXml(node):
     if node.tag != 'action':
         debug.debug("node.tag != 'action'")
         return None
     #read attributes
     data = node.get('id', None)
     id = Action.convert_from_str(data, 'long')
     data = node.get('parent_id', None)
     parent_id = Action.convert_from_str(data, 'long')
     data = node.get('user', None)
     user = Action.convert_from_str(data, 'str')
     data = node.get('date', None)
     date = Action.convert_from_str(data, 'datetime')
     child = node.getchildren()[0]
     if child.tag == 'mashup':
         mashup = Mashup.fromXml(child)
     return Action(id=id, parent_id=parent_id, mashup=mashup, user=user,
                   date=date)
Exemplo n.º 4
0
    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.doCopy()
                        mashup.id_scope = id_scope
                        mashup.version = version
                        mashup.validateForPipeline(pipeline)
                        currVersion = mashuptrail.addVersion(
                            parent_id=mashuptrail.getLatestVersion(),
                            mashup=mashup,
                            user=core.system.current_user(),
                            date=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=core.system.current_user(),
                date=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.doCopy()
                        mashup.id_scope = id_scope
                        mashup.version = version
                        mashup.validateForPipeline(pipeline)
                        currVersion = mashuptrail.addVersion(
                            parent_id=mashuptrail.getLatestVersion(),
                            mashup=mashup,
                            user=core.system.current_user(),
                            date=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=core.system.current_user(),
                date=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