def translateVistrail(_vistrail): def update_key(old_obj, translate_dict): return '__notes__' def update_annotation(old_obj, translate_dict): new_dict = {'DBAnnotation': {'key': update_key}} new_list = [] for annotation in old_obj.db_annotations: if annotation.db_key == 'notes': new_list.append(DBAnnotation.update_version(annotation, new_dict)) else: new_list.append(DBAnnotation.update_version(annotation, {})) return new_list def update_session(old_obj, translate_dict): if not old_obj.db_session: session = None else: session = long(old_obj.db_session) return session def update_workflow(old_obj, translate_dict): return DBWorkflow.update_version(old_obj.db_workflow, translate_dict) translate_dict = {'DBAction': {'annotations': update_annotation, 'session': update_session}, 'DBGroup': {'workflow': update_workflow}} # pass DBVistrail because domain contains enriched version of the auto_gen vistrail = DBVistrail.update_version(_vistrail, translate_dict) vistrail.db_version = '0.9.3' return vistrail
def translateVistrail(_vistrail): def update_key(old_obj, translate_dict): return "__notes__" def update_annotation(old_obj, translate_dict): new_dict = {"DBAnnotation": {"key": update_key}} new_list = [] for annotation in old_obj.db_annotations: if annotation.db_key == "notes": new_list.append(DBAnnotation.update_version(annotation, new_dict)) else: new_list.append(DBAnnotation.update_version(annotation, {})) return new_list def update_session(old_obj, translate_dict): if not old_obj.db_session: session = None else: session = long(old_obj.db_session) return session def update_workflow(old_obj, translate_dict): return DBWorkflow.update_version(old_obj.db_workflow, translate_dict) translate_dict = { "DBAction": {"annotations": update_annotation, "session": update_session}, "DBGroup": {"workflow": update_workflow}, } # pass DBVistrail because domain contains enriched version of the auto_gen vistrail = DBVistrail.update_version(_vistrail, translate_dict) vistrail.db_version = "0.9.3" return vistrail
def translateVistrail(_vistrail): vistrail = DBVistrail() for _action in _vistrail.db_actions: ops = [] for op in _action.db_operations: if op.vtType == 'add': data = convert_data(op.db_data) ops.append( DBAdd(id=op.db_id, what=op.db_what, objectId=op.db_objectId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType, data=data)) elif op.vtType == 'change': data = convert_data(op.db_data) ops.append( DBChange(id=op.db_id, what=op.db_what, oldObjId=op.db_oldObjId, newObjId=op.db_newObjId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType, data=data)) elif op.vtType == 'delete': ops.append( DBDelete(id=op.db_id, what=op.db_what, objectId=op.db_objectId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType)) annotations = [] for annotation in _action.db_annotations: annotations.append( DBAnnotation(id=annotation.db_id, key=annotation.db_key, value=annotation.db_value)) session = _action.db_session if not session: session = None else: session = long(_action.db_session) action = DBAction(id=_action.db_id, prevId=_action.db_prevId, date=_action.db_date, user=_action.db_user, prune=_action.db_prune, session=session, operations=ops, annotations=annotations) vistrail.db_add_action(action) for _tag in _vistrail.db_tags: tag = DBTag(id=_tag.db_id, name=_tag.db_name) vistrail.db_add_tag(tag) vistrail.db_version = '0.9.3' return vistrail
def translateVistrail(_vistrail): def update_operations(old_obj, trans_dict): def update_abstraction(old_obj, trans_dict): def get_version(old_obj, trans_dict): return long(old_obj.db_internal_version) new_dict = {'DBAbstractionRef': {'version': get_version}} new_dict.update(trans_dict) return DBAbstractionRef.update_version(old_obj.db_data, new_dict) new_ops = [] for obj in old_obj.db_operations: if obj.vtType == 'add': if obj.db_what == 'abstraction': trans_dict['DBAdd'] = {'data': update_abstraction} new_op = DBAdd.update_version(obj, trans_dict) new_op.db_what = 'abstractionRef' new_ops.append(new_op) del trans_dict['DBAdd'] else: new_op = DBAdd.update_version(obj, trans_dict) if obj.db_parentObjType == 'abstraction': new_op.db_parentObjType = 'abstractionRef' new_ops.append(new_op) elif obj.vtType == 'delete': new_ops.append(DBDelete.update_version(obj, trans_dict)) elif obj.vtType == 'change': if obj.db_what == 'abstraction': trans_dict['DBChange'] = {'data': update_abstraction} new_op = DBChange.update_version(obj, trans_dict) new_op.db_what = 'abstractionRef' new_ops.append(new_op) del trans_dict['DBChange'] else: new_op = DBChange.update_version(obj, trans_dict) if obj.db_parentObjType == 'abstraction': new_op.db_parentObjType = 'abstractionRef' new_ops.append(new_op) return new_ops translate_dict = { 'DBGroup': { 'workflow': update_workflow }, 'DBAction': { 'operations': update_operations }, 'DBWorkflow': { 'modules': update_modules } } # pass DBVistrail because domain contains enriched version of the auto_gen vistrail = DBVistrail.update_version(_vistrail, translate_dict) vistrail.db_version = '0.9.3' return vistrail
def translateVistrail(_vistrail): vistrail = DBVistrail() for _action in _vistrail.db_actions: ops = [] for op in _action.db_operations: if op.vtType == 'add': data = convert_data(op.db_data) ops.append(DBAdd(id=op.db_id, what=op.db_what, objectId=op.db_objectId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType, data=data)) elif op.vtType == 'change': data = convert_data(op.db_data) ops.append(DBChange(id=op.db_id, what=op.db_what, oldObjId=op.db_oldObjId, newObjId=op.db_newObjId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType, data=data)) elif op.vtType == 'delete': ops.append(DBDelete(id=op.db_id, what=op.db_what, objectId=op.db_objectId, parentObjId=op.db_parentObjId, parentObjType=op.db_parentObjType)) annotations = [] for annotation in _action.db_annotations: annotations.append(DBAnnotation(id=annotation.db_id, key=annotation.db_key, value=annotation.db_value)) session = _action.db_session if not session: session = None else: session = long(_action.db_session) action = DBAction(id=_action.db_id, prevId=_action.db_prevId, date=_action.db_date, user=_action.db_user, prune=_action.db_prune, session=session, operations=ops, annotations=annotations) vistrail.db_add_action(action) for _tag in _vistrail.db_tags: tag = DBTag(id=_tag.db_id, name=_tag.db_name) vistrail.db_add_tag(tag) vistrail.db_version = '0.9.3' return vistrail
def translateVistrail(_vistrail): def update_operations(old_obj, trans_dict): def update_abstraction(old_obj, trans_dict): def get_version(old_obj, trans_dict): return long(old_obj.db_internal_version) new_dict = {"DBAbstractionRef": {"version": get_version}} new_dict.update(trans_dict) return DBAbstractionRef.update_version(old_obj.db_data, new_dict) new_ops = [] for obj in old_obj.db_operations: if obj.vtType == "add": if obj.db_what == "abstraction": trans_dict["DBAdd"] = {"data": update_abstraction} new_op = DBAdd.update_version(obj, trans_dict) new_op.db_what = "abstractionRef" new_ops.append(new_op) del trans_dict["DBAdd"] else: new_op = DBAdd.update_version(obj, trans_dict) if obj.db_parentObjType == "abstraction": new_op.db_parentObjType = "abstractionRef" new_ops.append(new_op) elif obj.vtType == "delete": new_ops.append(DBDelete.update_version(obj, trans_dict)) elif obj.vtType == "change": if obj.db_what == "abstraction": trans_dict["DBChange"] = {"data": update_abstraction} new_op = DBChange.update_version(obj, trans_dict) new_op.db_what = "abstractionRef" new_ops.append(new_op) del trans_dict["DBChange"] else: new_op = DBChange.update_version(obj, trans_dict) if obj.db_parentObjType == "abstraction": new_op.db_parentObjType = "abstractionRef" new_ops.append(new_op) return new_ops translate_dict = { "DBGroup": {"workflow": update_workflow}, "DBAction": {"operations": update_operations}, "DBWorkflow": {"modules": update_modules}, } # pass DBVistrail because domain contains enriched version of the auto_gen vistrail = DBVistrail.update_version(_vistrail, translate_dict) vistrail.db_version = "0.9.3" return vistrail
def translateVistrail(_vistrail): def update_operations(old_obj, trans_dict): def update_abstraction(old_obj, trans_dict): def get_version(old_obj, trans_dict): return long(old_obj.db_internal_version) new_dict = {'DBAbstractionRef': {'version': get_version}} new_dict.update(trans_dict) return DBAbstractionRef.update_version(old_obj.db_data, new_dict) new_ops = [] for obj in old_obj.db_operations: if obj.vtType == 'add': if obj.db_what == 'abstraction': trans_dict['DBAdd'] = {'data': update_abstraction} new_op = DBAdd.update_version(obj, trans_dict) new_op.db_what = 'abstractionRef' new_ops.append(new_op) del trans_dict['DBAdd'] else: new_op = DBAdd.update_version(obj, trans_dict) if obj.db_parentObjType == 'abstraction': new_op.db_parentObjType = 'abstractionRef' new_ops.append(new_op) elif obj.vtType == 'delete': new_ops.append(DBDelete.update_version(obj, trans_dict)) elif obj.vtType == 'change': if obj.db_what == 'abstraction': trans_dict['DBChange'] = {'data': update_abstraction} new_op = DBChange.update_version(obj, trans_dict) new_op.db_what = 'abstractionRef' new_ops.append(new_op) del trans_dict['DBChange'] else: new_op = DBChange.update_version(obj, trans_dict) if obj.db_parentObjType == 'abstraction': new_op.db_parentObjType = 'abstractionRef' new_ops.append(new_op) return new_ops translate_dict = {'DBGroup': {'workflow': update_workflow}, 'DBAction': {'operations': update_operations}, 'DBWorkflow': {'modules': update_modules}} # pass DBVistrail because domain contains enriched version of the auto_gen vistrail = DBVistrail.update_version(_vistrail, translate_dict) vistrail.db_version = '0.9.3' return vistrail