Exemple #1
0
            else:
                same_annotations.append(
                    DBAnnotation.update_version(annotation, translate_dict))
        return same_annotations

    def update_workflow(old_obj, translate_dict):
        return DBWorkflow.update_version(old_obj.db_workflow, translate_dict)

    translate_dict = {'DBGroup': {'workflow': update_workflow},
                      'DBVistrail': {'tags': update_tags,
                                     'actions': update_actions},
                      'DBAction': {'annotations': update_annotations},
                      'DBParameter': {'type': update_type},
                      }
    _vistrail.update_id_scope()
    vistrail = DBVistrail.update_version(_vistrail, translate_dict)

    id_scope = vistrail.idScope
    id_scope.setBeginId('annotation', _vistrail.idScope.getNewId('annotation'))
    key_lists = {'__tag__': tag_annotations,
                 '__notes__': notes_annotations,
                 '__thumb__': thumb_annotations,
                 '__upgrade__': upgrade_annotations,
                 '__prune__': prune_annotations}
    for key, annotations in key_lists.iteritems():
        for action_id, value, new_id in annotations:
            if new_id is None:
                new_id = id_scope.getNewId(DBActionAnnotation.vtType)
            annotation = DBActionAnnotation(id=new_id,
                                            action_id=action_id,
                                            key=key,
Exemple #2
0
        'DBGroup': {
            'workflow': update_workflow
        },
        'DBVistrail': {
            'tags': update_tags,
            'actions': update_actions
        },
        'DBAction': {
            'annotations': update_annotations
        },
        'DBParameter': {
            'type': update_type
        },
    }
    _vistrail.update_id_scope()
    vistrail = DBVistrail.update_version(_vistrail, translate_dict)

    id_scope = vistrail.idScope
    id_scope.setBeginId('annotation', _vistrail.idScope.getNewId('annotation'))
    key_lists = {
        '__tag__': tag_annotations,
        '__notes__': notes_annotations,
        '__thumb__': thumb_annotations,
        '__upgrade__': upgrade_annotations,
        '__prune__': prune_annotations
    }
    for key, annotations in key_lists.iteritems():
        for action_id, value, new_id in annotations:
            if new_id is None:
                new_id = id_scope.getNewId(DBActionAnnotation.vtType)
            annotation = DBActionAnnotation(id=new_id,
Exemple #3
0
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':
                if obj.db_what == 'portSpec':
                    trans_dict['DBAdd'] = {'data': update_portSpec_op}
                    new_op = DBAdd.update_version(obj, trans_dict)
                    new_ops.append(new_op)
                    del trans_dict['DBAdd']
                else:
                    new_op = DBAdd.update_version(obj, trans_dict)
                    new_ops.append(new_op)
            elif obj.vtType == 'change':
                if obj.db_what == 'portSpec':
                    trans_dict['DBChange'] = {'data': update_portSpec_op}
                    new_op = DBChange.update_version(obj, trans_dict)
                    new_ops.append(new_op)
                    del trans_dict['DBChange']
                else:
                    new_op = DBChange.update_version(obj, trans_dict)
                    new_ops.append(new_op)
        return new_ops

    vistrail = DBVistrail()
    id_scope = vistrail.idScope

    def update_annotations(old_obj, trans_dict):
        new_annotations = []
        for a in old_obj.db_annotations:
            new_annotations.append(DBAnnotation.update_version(a, 
                                                               translate_dict))
            id_scope.updateBeginId(DBAnnotation.vtType, a.db_id)
        vars = {}
        for var in old_obj.db_vistrailVariables:
            descriptor = (var.db_package, var.db_module, var.db_namespace)
            vars[var.db_name] = (var.db_uuid, descriptor, var.db_value)
        if vars:
            new_id = id_scope.getNewId(DBAnnotation.vtType)
            annotation = DBAnnotation(id=new_id, key='__vistrail_vars__', 
                                      value=str(vars))
            new_annotations.append(annotation)

        return new_annotations

    translate_dict = {'DBModule': {'portSpecs': update_portSpecs},
                      'DBModuleDescriptor': {'portSpecs': update_portSpecs},
                      'DBAction': {'operations': update_operations},
                      'DBGroup': {'workflow': update_workflow},
                      'DBVistrail': {'annotations': update_annotations},
                      }

    vistrail = DBVistrail.update_version(_vistrail, translate_dict, vistrail)

    if _vistrail.db_parameter_explorations:
        debug.warning(("Vistrail contains %s parameter explorations that "
                      "cannot be converted") % len(_vistrail.db_parameter_explorations))

    vistrail.db_version = '1.0.2'
    return vistrail