'Copy the visualization with the given id and associate the copy
with the given user (defaults to trans.user).
Raises `ItemAccessibilityException` if `user` is not passed and
the current user is anonymous, and if the visualization is not `importable`.
Raises `ItemDeletionException` if the visualization has been deleted.'

def import_visualization(self, trans, id, user=None):

    if (not user):
        if (not trans.user):
            raise exceptions.ItemAccessibilityException('You    must    be    logged    in    to    import    Galaxy    visualizations')
        user = trans.user
    visualization = self.get_visualization(trans, id, check_ownership=False)
    if (not visualization.importable):
        raise exceptions.ItemAccessibilityException('The    owner    of    this    visualization    has    disabled    imports    via    this    link.')
    if visualization.deleted:
        raise exceptions.ItemDeletionException("You    can't    import    this    visualization    because    it    has    been    deleted.")
    imported_visualization = visualization.copy(user=user, title=('imported:    ' + visualization.title))
    trans.sa_session.add(imported_visualization)
    trans.sa_session.flush()
    return imported_visualization
