Esempio n. 1
0
    def create_ops(self, id_scope=IdScope()):
        from vistrails.core.modules.basic_modules import identifier as basic_pkg
        from vistrails.core.vistrail.module import Module
        from vistrails.core.vistrail.module_function import ModuleFunction
        from vistrails.core.vistrail.module_param import ModuleParam
        from vistrails.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=basic_pkg)
        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)
        cparam = ModuleControlParam(id=id_scope.getNewId(
            ModuleControlParam.vtType),
                                    name='foo',
                                    value='bar')
        add_cparam = AddOp(id=id_scope.getNewId(AddOp.vtType),
                           what=ModuleControlParam.vtType,
                           objectId=m.id,
                           data=cparam)

        return [add_op, change_op, delete_op, add_annotation]
Esempio n. 2
0
    def create_module(self, id_scope=None):
        from vistrails.core.modules.basic_modules import identifier as basic_pkg
        from vistrails.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)
        ]
        control_parameters = [
            ModuleControlParam(id=id_scope.getNewId(ModuleControlParam.vtType),
                               name='combiner',
                               value='pairwise')
        ]
        module = Module(id=id_scope.getNewId(Module.vtType),
                        name='Float',
                        package=basic_pkg,
                        functions=functions,
                        controlParameters=control_parameters)
        return module
Esempio n. 3
0
    def __init__(self,
                 id,
                 name,
                 vtid=None,
                 version=None,
                 alias_list=None,
                 t='vistrail',
                 has_seq=None,
                 layout='',
                 geometry='',
                 id_scope=IdScope()):
        if has_seq is None:
            has_seq = 0

        DBMashup.__init__(self, id, name, version, alias_list, t, vtid, layout,
                          geometry, has_seq)
        self.id_scope = id_scope
        if has_seq is None:
            self.has_seq = False
            if isinstance(self.alias_list, list):
                for v in self.alias_list:
                    if v.component.seq == True:
                        self.has_seq = True
        else:
            self.has_seq = has_seq
Esempio n. 4
0
 def create_param(self, id_scope=IdScope()):
     param = PEParam(id=id_scope.getNewId(PEParam.vtType),
                         pos=1,
                         interpolator='normal-int',
                         value='[1, 2]',
                         dimension=1)
     return param
Esempio n. 5
0
    def create_action(self, id_scope=None):
        from vistrails.core.modules.basic_modules import identifier as basic_pkg
        from vistrails.core.vistrail.action import Action
        from vistrails.core.vistrail.module import Module
        from vistrails.core.vistrail.module_function import ModuleFunction
        from vistrails.core.vistrail.module_param import ModuleParam
        from vistrails.db.domain import IdScope

        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=basic_pkg,
                   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
Esempio n. 6
0
    def create_annotation(self, id_scope=IdScope()):

        annotation = \
            ActionAnnotation(id=id_scope.getNewId('mashup_actionAnnotation'),
                             key='akey', action_id=1L,
                             value='some value', user='******')
        return annotation
Esempio n. 7
0
 def create_component(self, id_scope=IdScope()):
     c = 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")
     return c
Esempio n. 8
0
    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
Esempio n. 9
0
 def create_port(self, id_scope=IdScope()):
     port = Port(id=id_scope.getNewId(Port.vtType),
                 type='source',
                 moduleId=12L,
                 moduleName='String',
                 name='value',
                 signature='(%s:String)' % get_vistrails_basic_pkg_id())
     return port
Esempio n. 10
0
    def create_annotation(self, id_scope=None):
        from vistrails.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
Esempio n. 11
0
 def test_copy(self):
     id_scope = IdScope()
     a1 = self.create_action(id_scope)
     a2 = copy.copy(a1)
     self.assertEquals(a1, a2)
     self.assertEquals(a1.id, a2.id)
     a3 = a1.do_copy(True, id_scope, {})
     self.assertEquals(a1, a3)
     self.assertNotEquals(a1.id, a3.id)
Esempio n. 12
0
 def create_port_spec(self, id_scope=IdScope()):
     # FIXME add a valid port spec
     port_spec = PortSpec(id=id_scope.getNewId(PortSpec.vtType),
                          name='SetValue',
                          type='input',
                          sigstring='(%s:String)' % \
                              get_vistrails_basic_pkg_id(),
                          )
     return port_spec
Esempio n. 13
0
 def test_copy(self):
     id_scope = IdScope()
     m1 = self.create_mashup(id_scope)
     m2 = copy.copy(m1)
     self.assertEqual(m1, m2)
     self.assertEqual(m1.id, m2.id)
     m3 = m2.do_copy(True, id_scope, {})
     self.assertEqual(m1, m3)
     self.assertNotEqual(m1.id, m3.id)
Esempio n. 14
0
 def test_copy(self):        
     id_scope = IdScope()
     f1 = self.create_function(id_scope)
     f2 = copy.copy(f1)
     self.assertEquals(f1, f2)
     self.assertEquals(f1.id, f2.id)
     f3 = f1.do_copy(True, id_scope, {})
     self.assertEquals(f1, f3)
     self.assertNotEquals(f1.real_id, f3.real_id)
Esempio n. 15
0
 def test_copy(self):
     id_scope = IdScope()
     c1 = self.create_component(id_scope)
     c2 = copy.copy(c1)
     self.assertEqual(c1, c2)
     self.assertEqual(c1.id, c2.id)
     c3 = c2.do_copy(True, id_scope, {})
     self.assertEqual(c1, c3)
     self.assertNotEqual(c1.id, c3.id)
Esempio n. 16
0
    def create_control_parameter(self, id_scope=None):
        from vistrails.db.domain import IdScope

        if id_scope is None:
            id_scope = IdScope()
        control_parameter = ModuleControlParam(id=id_scope.getNewId(ModuleControlParam.vtType),
                                name='name %s',
                                value='some value %s')
        return control_parameter
Esempio n. 17
0
 def test_copy(self):        
     id_scope = IdScope()
     p1 = self.create_param(id_scope)
     p2 = copy.copy(p1)
     self.assertEquals(p1, p2)
     self.assertEquals(p1.id, p2.id)
     p3 = p1.do_copy(True, id_scope, {})
     self.assertEquals(p1, p3)
     self.assertNotEquals(p1.real_id, p3.real_id)
Esempio n. 18
0
 def test_copy(self):        
     id_scope = IdScope()
     pe1 = self.create_pe(id_scope)
     pe2 = copy.copy(pe1)
     self.assertEquals(pe1, pe2)
     self.assertEquals(pe1.id, pe2.id)
     pe3 = pe1.do_copy(True, id_scope, {})
     self.assertEquals(pe1, pe3)
     self.assertNotEquals(pe1.id, pe3.id)
Esempio n. 19
0
    def test_copy(self):
        id_scope = IdScope()

        s1 = self.create_port_spec(id_scope)
        s2 = copy.copy(s1)
        self.assertEquals(s1, s2)
        self.assertEquals(s1.id, s2.id)
        s3 = s1.do_copy(True, id_scope, {})
        self.assertEquals(s1, s3)
        self.assertNotEquals(s1.id, s3.id)
Esempio n. 20
0
    def create_annotation(self, id_scope=None):
        from vistrails.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
Esempio n. 21
0
    def test_copy(self):
        id_scope = IdScope()

        loc1 = self.create_location(id_scope)
        loc2 = copy.copy(loc1)
        self.assertEquals(loc1, loc2)
        self.assertEquals(loc1.id, loc2.id)
        loc3 = loc1.do_copy(True, id_scope, {})
        self.assertEquals(loc1, loc3)
        self.assertNotEquals(loc1.id, loc3.id)
Esempio n. 22
0
 def create_function(self, id_scope=IdScope()):
     param = ModuleParam(id=id_scope.getNewId(ModuleParam.vtType),
                         pos=2,
                         type='Int',
                         val='1')
     function = ModuleFunction(id=id_scope.getNewId(ModuleFunction.vtType),
                               pos=0,
                               name='value',
                               parameters=[param])
     return function
Esempio n. 23
0
    def test_copy(self):
        id_scope = IdScope()

        t1 = self.create_tag(id_scope)
        t2 = copy.copy(t1)
        self.assertEquals(t1, t2)
        self.assertEquals(t1.id, t2.id)
        t3 = t1.do_copy(True, id_scope, {})
        self.assertEquals(t1, t3)
        self.assertNotEquals(t1.id, t3.id)
Esempio n. 24
0
 def create_mashup(self, id_scope=IdScope()):
     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])
     return m
    def test_copy(self):
        from vistrails.db.domain import IdScope
        id_scope = IdScope()

        a1 = self.create_control_parameter(id_scope)
        a2 = copy.copy(a1)
        self.assertEquals(a1, a2)
        self.assertEquals(a1.id, a2.id)
        a3 = a1.do_copy(True, id_scope, {})
        self.assertEquals(a1, a3)
        self.assertNotEquals(a1.id, a3.id)
Esempio n. 26
0
 def create_pe(self, id_scope=IdScope()):
     pe = ParameterExploration(
                         id=id_scope.getNewId(ParameterExploration.vtType),
                         action_id=6,
                         user='******',
                         date='2007-11-23 12:48',
                         dims='[1,2]',
                         layout='{1:"normal"}',
                         name='test-pe',
                         functions=[])
     return pe
Esempio n. 27
0
    def test_copy(self):
        """Check that copy works correctly"""

        id_scope = IdScope()
        m1 = self.create_group(id_scope)
        m2 = copy.copy(m1)
        self.assertEquals(m1, m2)
        self.assertEquals(m1.id, m2.id)
        m3 = m1.do_copy(True, id_scope, {})
        self.assertEquals(m1, m3)
        self.assertNotEquals(m1.id, m3.id)
Esempio n. 28
0
    def test_copy(self):
        """Check that copy works correctly"""
        from vistrails.db.domain import IdScope

        id_scope = IdScope()
        m1 = self.create_module(id_scope)
        m2 = copy.copy(m1)
        self.assertEquals(m1, m2)
        self.assertEquals(m1.id, m2.id)
        m3 = m1.do_copy(True, id_scope, {})
        self.assertEquals(m1, m3)
        self.assertNotEquals(m1.id, m3.id)
Esempio n. 29
0
    def test_port_spec_copy(self):
        id_scope = IdScope()
        psi = DBPortSpecItem(id=id_scope.getNewId(DBPortSpecItem.vtType),
                             pos=0,
                             module="File",
                             package="org.vistrails.vistrails.basic")

        ps1 = DBPortSpec(id=id_scope.getNewId(DBPortSpec.vtType),
                         portSpecItems=[psi,])
        ops = create_copy_op_chain(ps1, id_scope=id_scope)
        self.assertNotEqual(ps1.db_portSpecItems[0].db_id,
                            ops[0].db_data.db_portSpecItems[0].db_id)
Esempio n. 30
0
 def create_function(self, id_scope=IdScope()):
     param = PEParam(id=id_scope.getNewId(PEParam.vtType),
                     pos=2,
                     interpolator='Stepper',
                     dimension=4,
                     value='[1, 2]')
     function = PEFunction(id=id_scope.getNewId(PEFunction.vtType),
                           module_id=7,
                           port_name='value',
                           is_alias=0,
                           parameters=[param])
     return function