Ejemplo n.º 1
0
    def create_action(self, id_scope=None):
        from core.vistrail.action import Action
        from core.vistrail.module import Module
        from core.vistrail.module_function import ModuleFunction
        from core.vistrail.module_param import ModuleParam
        from core.vistrail.operation import AddOp
        from db.domain import IdScope
        from datetime import datetime
        
        if id_scope is None:
            id_scope = IdScope()
        param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                            type='Integer',
                            val='1')
        function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                                  name='value',
                                  parameters=[param])
        m = Module(id=id_scope.getNewId(Module.vtType),
                   name='Float',
                   package='edu.utah.sci.vistrails.basic',
                   functions=[function])

        add_op = AddOp(id=id_scope.getNewId('operation'),
                       what='module',
                       objectId=m.id,
                       data=m)
        action = Action(id=id_scope.getNewId(Action.vtType),
                        prevId=0,
                        date=datetime(2007,11,18),
                        operations=[add_op])
        return action
Ejemplo n.º 2
0
    def create_action(self, id_scope=None):
        from core.vistrail.action import Action
        from core.vistrail.module import Module
        from core.vistrail.module_function import ModuleFunction
        from core.vistrail.module_param import ModuleParam
        from core.vistrail.operation import AddOp
        from db.domain import IdScope
        from datetime import datetime

        if id_scope is None:
            id_scope = IdScope()
        param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                            type='Integer',
                            val='1')
        function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                                  name='value',
                                  parameters=[param])
        m = Module(id=id_scope.getNewId(Module.vtType),
                   name='Float',
                   package='edu.utah.sci.vistrails.basic',
                   functions=[function])

        add_op = AddOp(id=id_scope.getNewId('operation'),
                       what='module',
                       objectId=m.id,
                       data=m)
        action = Action(id=id_scope.getNewId(Action.vtType),
                        prevId=0,
                        date=datetime(2007, 11, 18),
                        operations=[add_op])
        return action
Ejemplo n.º 3
0
 def create_module(self, id_scope=None):
     from db.domain import IdScope
     if id_scope is None:
         id_scope = IdScope()
     
     params = [ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                               type='Int',
                               val='1')]
     functions = [ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                                 name='value',
                                 parameters=params)]
     module = Module(id=id_scope.getNewId(Module.vtType),
                     name='Float',
                     package='edu.utah.sci.vistrails.basic',
                     functions=functions)
     return module
Ejemplo n.º 4
0
    def create_annotation(self, id_scope=None):
        from db.domain import IdScope

        if id_scope is None:
            id_scope = IdScope()
        annotation = Annotation(id=id_scope.getNewId(Annotation.vtType),
                                key='akey %s',
                                value='some value %s')
        return annotation
    def create_annotation(self, id_scope=None):
        from db.domain import IdScope

        if id_scope is None:
            id_scope = IdScope()
        annotation = Annotation(id=id_scope.getNewId(Annotation.vtType),
                                key='akey %s',
                                value='some value %s')
        return annotation
    def create_annotation(self, id_scope=None):
        from db.domain import IdScope

        if id_scope is None:
            id_scope = IdScope()
        annotation = \
            ActionAnnotation(id=id_scope.getNewId(ActionAnnotation.vtType),
                             key='akey', action_id=1L,
                             value='some value', user='******')
        return annotation
Ejemplo n.º 7
0
    def create_annotation(self, id_scope=None):
        from db.domain import IdScope

        if id_scope is None:
            id_scope = IdScope()
        annotation = \
            ActionAnnotation(id=id_scope.getNewId(ActionAnnotation.vtType),
                             key='akey', action_id=1L,
                             value='some value', user='******')
        return annotation
Ejemplo n.º 8
0
    def create_module(self, id_scope=None):
        from db.domain import IdScope
        if id_scope is None:
            id_scope = IdScope()

        params = [
            ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                        type='Int',
                        val='1')
        ]
        functions = [
            ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                           name='value',
                           parameters=params)
        ]
        module = Module(id=id_scope.getNewId(Module.vtType),
                        name='Float',
                        package='edu.utah.sci.vistrails.basic',
                        functions=functions)
        return module
Ejemplo n.º 9
0
    def create_ops(self, id_scope=IdScope()):
        from core.vistrail.module import Module
        from core.vistrail.module_function import ModuleFunction
        from core.vistrail.module_param import ModuleParam
        from core.vistrail.annotation import Annotation

        if id_scope is None:
            id_scope = IdScope(
                remap={
                    AddOp.vtType: 'operation',
                    ChangeOp.vtType: 'operation',
                    DeleteOp.vtType: 'operation'
                })

        m = Module(id=id_scope.getNewId(Module.vtType),
                   name='Float',
                   package='edu.utah.sci.vistrails.basic')
        add_op = AddOp(id=id_scope.getNewId(AddOp.vtType),
                       what=Module.vtType,
                       objectId=m.id,
                       data=m)
        function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                                  name='value')
        change_op = ChangeOp(id=id_scope.getNewId(ChangeOp.vtType),
                             what=ModuleFunction.vtType,
                             oldObjId=2,
                             newObjId=function.real_id,
                             parentObjId=m.id,
                             parentObjType=Module.vtType,
                             data=function)
        param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                            type='Float',
                            val='1.0')

        delete_op = DeleteOp(id=id_scope.getNewId(DeleteOp.vtType),
                             what=ModuleParam.vtType,
                             objectId=param.real_id,
                             parentObjId=function.real_id,
                             parentObjType=ModuleFunction.vtType)

        annotation = Annotation(id=id_scope.getNewId(Annotation.vtType),
                                key='foo',
                                value='bar')
        add_annotation = AddOp(id=id_scope.getNewId(AddOp.vtType),
                               what=Annotation.vtType,
                               objectId=m.id,
                               data=annotation)

        return [add_op, change_op, delete_op, add_annotation]
    def create_ops(self, id_scope=IdScope()):
        from core.vistrail.module import Module
        from core.vistrail.module_function import ModuleFunction
        from core.vistrail.module_param import ModuleParam
        from core.vistrail.annotation import Annotation
        
        if id_scope is None:
            id_scope = IdScope(remap={AddOp.vtType: 'operation',
                                      ChangeOp.vtType: 'operation',
                                      DeleteOp.vtType: 'operation'})

        m = Module(id=id_scope.getNewId(Module.vtType),
                   name='Float',
                   package='edu.utah.sci.vistrails.basic')
        add_op = AddOp(id=id_scope.getNewId(AddOp.vtType),
                       what=Module.vtType,
                       objectId=m.id,
                       data=m)
        function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                                  name='value')
        change_op = ChangeOp(id=id_scope.getNewId(ChangeOp.vtType),
                             what=ModuleFunction.vtType,
                             oldObjId=2,
                             newObjId=function.real_id,
                             parentObjId=m.id,
                             parentObjType=Module.vtType,
                             data=function)
        param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                            type='Float',
                            val='1.0')
        
        delete_op = DeleteOp(id=id_scope.getNewId(DeleteOp.vtType),
                             what=ModuleParam.vtType,
                             objectId=param.real_id,
                             parentObjId=function.real_id,
                             parentObjType=ModuleFunction.vtType)

        annotation = Annotation(id=id_scope.getNewId(Annotation.vtType),
                                key='foo',
                                value='bar')
        add_annotation = AddOp(id=id_scope.getNewId(AddOp.vtType),
                               what=Annotation.vtType,
                               objectId=m.id,
                               data=annotation)
        
        return [add_op, change_op, delete_op, add_annotation]
Ejemplo n.º 11
0
    def create_abstraction(self, id_scope=None):
        from core.vistrail.action import Action
        from core.vistrail.module import Module
        from core.vistrail.module_function import ModuleFunction
        from core.vistrail.module_param import ModuleParam
        from core.vistrail.operation import AddOp
        from core.vistrail.tag import Tag
        from db.domain import IdScope
        from datetime import datetime
        
        if id_scope is None:
            id_scope = IdScope()
        function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                                  name='value')
        m = Module(id=id_scope.getNewId(Module.vtType),
                   name='Float',
                   package='edu.utah.sci.vistrails.basic',
                   functions=[function])

        add_op = AddOp(id=id_scope.getNewId('operation'),
                       what='module',
                       objectId=m.id,
                       data=m)
        add_op2 = AddOp(id=id_scope.getNewId('operation'),
                       what='function',
                       objectId=function.id,
                       data=function)
        action = Action(id=id_scope.getNewId(Action.vtType),
                        prevId=0,
                        date=datetime(2007,11, 18),
                        operations=[add_op, add_op2])
        tag = Tag(id=id_scope.getNewId(Tag.vtType),
                  name='a tag')
        abstraction = Abstraction(id=id_scope.getNewId(Abstraction.vtType),
                                  name='blah',
                                  actions=[action],
                                  tags=[tag])
        return abstraction
    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