'Install queries. Raise InstallException on failure.'

def install(self, django_user):

    LOG.info(('Installing    sample    query:    %s' % (self.name,)))
    try:
        query = SavedQuery.objects.get(owner=django_user, name=self.name, type=self.type)
    except SavedQuery.DoesNotExist:
        query = SavedQuery(owner=django_user, name=self.name, type=self.type, desc=self.desc)
        query.data = json.dumps(self.data)
        query.save()
        LOG.info(('Successfully    installed    sample    design:    %s' % (self.name,)))
    if USE_NEW_EDITOR.get():
        home_dir = Directory.objects.get_home_directory(django_user)
        (examples_dir, created) = Directory.objects.get_or_create(parent_directory=home_dir, owner=django_user, name=Document2.EXAMPLES_DIR)
        try:
            doc2 = Document2.objects.get(owner=django_user, name=self.name, type=self._document_type(self.type), is_history=False)
            if (doc2.parent_directory != examples_dir):
                doc2.parent_directory = examples_dir
                doc2.save()
        except Document2.DoesNotExist:
            notebook = import_saved_beeswax_query(query)
            data = notebook.get_data()
            data['isSaved'] = True
            uuid = data.get('uuid')
            data = json.dumps(data)
            doc2 = Document2.objects.create(uuid=uuid, owner=django_user, parent_directory=examples_dir, name=self.name, type=self._document_type(self.type), description=self.desc, data=data)
        examples_dir.share(django_user, Document2Permission.READ_PERM, groups=[get_default_user_group()])
        LOG.info(('Successfully    installed    sample    query:    %s' % (self.name,)))
