Esempio n. 1
0
    def get_datasources_tables_data(self):
        try:
            datasources = congress.datasources_list(self.request)
        except Exception as e:
            msg = _('Unable to get services list: %s') % str(e)
            messages.error(self.request, msg)
            return []

        ds_temp = []
        for ds in datasources:
            ds_id = ds['id']
            try:
                ds_tables = congress.datasource_tables_list(self.request,
                                                            ds_id)
            except Exception as e:
                msg_args = {'ds_id': ds_id, 'error': str(e)}
                msg = _('Unable to get tables list for service "%(ds_id)s": '
                        '%(error)s') % msg_args
                messages.error(self.request, msg)
                return []

            for table in ds_tables:
                table.set_value('datasource_id', ds_id)
                table.set_value('datasource_name', ds['name'])
                table.set_value('datasource_driver', ds['driver'])
                table.set_id_as_name_if_empty()
                # Object ids within a Horizon table must be unique. Otherwise,
                # Horizon will cache the column values for the object by id and
                # use the same column values for all rows with the same id.
                table.set_value('table_id', table['id'])
                table.set_value('id', '%s-%s' % (ds_id, table['table_id']))
                ds_temp.append(table)

        logger.debug("ds_temp %s" % ds_temp)
        return ds_temp
Esempio n. 2
0
def _get_service_tables(request):
    # Return all service tables.
    all_tables = []
    try:
        # Get all the services.
        services = congress.datasources_list(request)
    except Exception as e:
        LOG.error('Unable to get list of data sources: %s', str(e))
    else:
        try:
            for service in services:
                # Get all the tables in this service.
                service_id = service['id']
                service_tables = congress.datasource_tables_list(
                    request, service_id)
                # Get the names of the tables.
                datasource_tables = []
                for table in service_tables:
                    table.set_id_as_name_if_empty()
                    datasource_tables.append(table['name'])

                all_tables.append({
                    'datasource': service['name'],
                    'tables': datasource_tables
                })
        except Exception as e:
            LOG.error('Unable to get tables for data source "%s": %s',
                      service_id, str(e))
    return all_tables
Esempio n. 3
0
    def get_datasources_tables_data(self):
        try:
            datasources = congress.datasources_list(self.request)
        except Exception as e:
            msg = _('Unable to get services list: %s') % str(e)
            messages.error(self.request, msg)
            return []

        ds_temp = []
        for ds in datasources:
            ds_id = ds['id']
            try:
                ds_tables = congress.datasource_tables_list(
                    self.request, ds_id)
            except Exception as e:
                msg_args = {'ds_id': ds_id, 'error': str(e)}
                msg = _('Unable to get tables list for service "%(ds_id)s": '
                        '%(error)s') % msg_args
                messages.error(self.request, msg)
                return []

            for table in ds_tables:
                table.set_value('datasource_id', ds_id)
                table.set_value('datasource_name', ds['name'])
                table.set_value('datasource_driver', ds['driver'])
                table.set_id_as_name_if_empty()
                # Object ids within a Horizon table must be unique. Otherwise,
                # Horizon will cache the column values for the object by id and
                # use the same column values for all rows with the same id.
                table.set_value('table_id', table['id'])
                table.set_value('id', '%s-%s' % (ds_id, table['table_id']))
                ds_temp.append(table)

        logger.debug("ds_temp %s" % ds_temp)
        return ds_temp
Esempio n. 4
0
def _get_service_tables(request):
    # Return all service tables.
    all_tables = []
    try:
        # Get all the services.
        services = congress.datasources_list(request)
    except Exception as e:
        LOG.error('Unable to get list of data sources: %s', str(e))
    else:
        try:
            for service in services:
                # Get all the tables in this service.
                service_id = service['id']
                service_tables = congress.datasource_tables_list(request,
                                                                 service_id)
                # Get the names of the tables.
                datasource_tables = []
                for table in service_tables:
                    table.set_id_as_name_if_empty()
                    datasource_tables.append(table['name'])

                all_tables.append({'datasource': service['name'],
                                   'tables': datasource_tables})
        except Exception as e:
            LOG.error('Unable to get tables for data source "%s": %s',
                      service_id, str(e))
    return all_tables