def convert_operation_list(ops): for op in ops: if op.vtType == 'add': AddOp.convert(op) elif op.vtType == 'change': ChangeOp.convert(op) elif op.vtType == 'delete': DeleteOp.convert(op) else: raise TypeError("Unknown operation type '%s'" % op.vtType)
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
def convert(_action): if _action.__class__ == Action: return _action.__class__ = Action for _annotation in _action.annotations: Annotation.convert(_annotation) for _operation in _action.operations: if _operation.vtType == 'add': AddOp.convert(_operation) elif _operation.vtType == 'change': ChangeOp.convert(_operation) elif _operation.vtType == 'delete': DeleteOp.convert(_operation) else: raise TypeError("Unknown operation type '%s'" % _operation.vtType)
def test_plugin_data(self): import vistrails.core.db.io v1 = self.create_vistrail() plugin_data_str = "testing plugin_data" p = PluginData(id=v1.idScope.getNewId(PluginData.vtType), data=plugin_data_str) add_op = AddOp(id=v1.idScope.getNewId(AddOp.vtType), what=PluginData.vtType, objectId=p.id, data=p) action = Action(id=v1.idScope.getNewId(Action.vtType), operations=[add_op]) v1.add_action(action, 0) workflow = v1.getPipeline(action.id) p2 = workflow.plugin_datas[0] assert plugin_data_str == p2.data
def create_vistrail(self): vistrail = Vistrail() m = Module(id=vistrail.idScope.getNewId(Module.vtType), name='Float', package=get_vistrails_basic_pkg_id()) add_op = AddOp(id=vistrail.idScope.getNewId(AddOp.vtType), what=Module.vtType, objectId=m.id, data=m) function_id = vistrail.idScope.getNewId(ModuleFunction.vtType) function = ModuleFunction(id=function_id, name='value') change_op = ChangeOp(id=vistrail.idScope.getNewId(ChangeOp.vtType), what=ModuleFunction.vtType, oldObjId=2, newObjId=function.real_id, parentObjId=m.id, parentObjType=Module.vtType, data=function) param = ModuleParam(id=vistrail.idScope.getNewId(ModuleParam.vtType), type='Integer', val='1') delete_op = DeleteOp(id=vistrail.idScope.getNewId(DeleteOp.vtType), what=ModuleParam.vtType, objectId=param.real_id, parentObjId=function.real_id, parentObjType=ModuleFunction.vtType) action1 = Action(id=vistrail.idScope.getNewId(Action.vtType), operations=[add_op]) action2 = Action(id=vistrail.idScope.getNewId(Action.vtType), operations=[change_op, delete_op]) vistrail.add_action(action1, 0) vistrail.add_action(action2, action1.id) vistrail.addTag('first action', action1.id) vistrail.addTag('second action', action2.id) return vistrail