def translateVistrail(_vistrail): """ Translate old annotation based vistrail variables to new DBVistrailVariable class """ global id_scope def update_workflow(old_obj, trans_dict): return DBWorkflow.update_version(old_obj.db_workflow, trans_dict, DBWorkflow()) def update_vistrail_variable(old_obj, trans_dict): return DBVistrailVariable.update_version(old_obj.db_vistrailVariables, trans_dict, DBVistrailVariable()) def update_operations(old_obj, trans_dict): new_ops = [] for obj in old_obj.db_operations: if obj.vtType == 'delete': new_ops.append(DBDelete.update_version(obj, trans_dict)) elif obj.vtType == 'add': new_op = DBAdd.update_version(obj, trans_dict) new_ops.append(new_op) elif obj.vtType == 'change': new_op = DBChange.update_version(obj, trans_dict) new_ops.append(new_op) return new_ops def update_annotations(old_obj, trans_dict): new_annotations = [] for a in old_obj.db_annotations: new_a = DBAnnotation.update_version(a, trans_dict) new_annotations.append(new_a) return new_annotations def update_actionAnnotations(old_obj, trans_dict): new_actionAnnotations = [] for aa in old_obj.db_actionAnnotations: new_aa = DBActionAnnotation.update_version(aa, trans_dict) new_actionAnnotations.append(new_aa) return new_actionAnnotations translate_dict = {'DBWorkflow': {'operations': update_workflow}, 'DBAction': {'operations': update_operations}, 'DBGroup': {'workflow': update_workflow}, 'DBVistrail': {'annotations': update_annotations, 'actionAnnotations': \ update_actionAnnotations, 'DBVistrailVariable': \ update_vistrail_variable } } vistrail = DBVistrail() id_scope = vistrail.idScope vistrail = DBVistrail.update_version(_vistrail, translate_dict, vistrail) vistrail.db_version = '1.0.4' return vistrail
def translateVistrail(_vistrail): """ Translate old annotation based vistrail variables to new DBVistrailVariable class """ global id_scope def update_workflow(old_obj, trans_dict): return DBWorkflow.update_version(old_obj.db_workflow, trans_dict, DBWorkflow()) translate_dict = {'DBGroup': {'workflow': update_workflow}} vistrail = DBVistrail() id_scope = vistrail.idScope vistrail = DBVistrail.update_version(_vistrail, translate_dict, vistrail) vistrail.db_version = '1.0.4' return vistrail
def translateVistrail(_vistrail): """ Translate new DBVistrailVariable based vistrail variables to old annotation based type """ global id_scope def update_workflow(old_obj, trans_dict): return DBWorkflow.update_version(old_obj.db_workflow, trans_dict, DBWorkflow()) def update_operations(old_obj, trans_dict): new_ops = [] for obj in old_obj.db_operations: if obj.vtType == 'delete': new_ops.append(DBDelete.update_version(obj, trans_dict)) elif obj.vtType == 'add': new_op = DBAdd.update_version(obj, trans_dict) new_ops.append(new_op) elif obj.vtType == 'change': new_op = DBChange.update_version(obj, trans_dict) new_ops.append(new_op) return new_ops vistrail = DBVistrail() id_scope = vistrail.idScope translate_dict = { 'DBAction': { 'operations': update_operations }, 'DBGroup': { 'workflow': update_workflow } } if _vistrail.db_controlParameters: debug.warning( ("Vistrail contains %s control parameters that " "cannot be converted") % len(_vistrail.db_controlParameters)) vistrail = DBVistrail.update_version(_vistrail, translate_dict, vistrail) vistrail.db_version = '1.0.4' return vistrail
def translateVistrail(_vistrail): """ Translate new DBVistrailVariable based vistrail variables to old annotation based type """ global id_scope def update_workflow(old_obj, trans_dict): return DBWorkflow.update_version(old_obj.db_workflow, trans_dict, DBWorkflow()) def update_operations(old_obj, trans_dict): new_ops = [] for obj in old_obj.db_operations: if obj.vtType == 'delete': new_ops.append(DBDelete.update_version(obj, trans_dict)) elif obj.vtType == 'add': new_op = DBAdd.update_version(obj, trans_dict) new_ops.append(new_op) elif obj.vtType == 'change': new_op = DBChange.update_version(obj, trans_dict) new_ops.append(new_op) return new_ops vistrail = DBVistrail() id_scope = vistrail.idScope translate_dict = {'DBAction': {'operations': update_operations}, 'DBGroup': {'workflow': update_workflow} } if _vistrail.db_controlParameters: debug.warning(("Vistrail contains %s control parameters that " "cannot be converted") % len(_vistrail.db_controlParameters)) vistrail = DBVistrail.update_version(_vistrail, translate_dict, vistrail) vistrail.db_version = '1.0.4' return vistrail