How to use the catalog/contextCatalog.getNamespaces function in catalog

To help you get started, we’ve selected a few catalog examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudera / hue / desktop / core / src / desktop / js / ko / components / contextPopover / ko.contextPopover.js View on Github external
let sourceType = params.data.sourceType && params.data.sourceType.toLowerCase();

    if (!sourceType || sourceType === 'hive') {
      huePubSub.publish('cluster.config.get.config', clusterConfig => {
        if (clusterConfig) {
          const defaultEditor = clusterConfig['default_sql_interpreter'];
          if (!sourceType || (sourceType === 'hive' && defaultEditor === 'impala')) {
            sourceType = defaultEditor;
          }
        }
      });
    }

    if (self.isCatalogEntry) {
      contextCatalog.getNamespaces({ sourceType: sourceType }).done(context => {
        // TODO: Namespace and compute selection for global search results?
        dataCatalog
          .getEntry({
            sourceType: sourceType,
            namespace: context.namespaces[0],
            compute: context.namespaces[0].computes[0],
            path: path,
            definition: { type: params.data.type.toLowerCase() }
          })
          .done(catalogEntry => {
            catalogEntry.navigatorMeta = params.data;
            catalogEntry.navigatorMetaPromise = $.Deferred().resolve(catalogEntry.navigatorMeta);
            catalogEntry.saveLater();
            self.contents(new DataCatalogContext({ popover: self, catalogEntry: catalogEntry }));
          });
      });
github cloudera / hue / desktop / core / src / desktop / js / ko / components / assist / assistDbSource.js View on Github external
loadNamespaces(refresh) {
    const self = this;
    self.loading(true);

    if (refresh) {
      contextCatalog.getComputes({ sourceType: self.sourceType, clearCache: true });
    }

    return contextCatalog
      .getNamespaces({ sourceType: self.sourceType, clearCache: refresh })
      .done(context => {
        const assistNamespaces = [];
        let activeNamespace;
        let activeCompute;
        context.namespaces.forEach(namespace => {
          const assistNamespace = new AssistDbNamespace({
            sourceType: self.sourceType,
            namespace: namespace,
            i18n: self.i18n,
            nonSqlType: self.nonSqlType,
            navigationSettings: self.navigationSettings
          });

          if (self.initialNamespace && namespace.id === self.initialNamespace.id) {
            activeNamespace = assistNamespace;
github cloudera / hue / desktop / core / src / desktop / js / jquery / plugins / jquery.hiveautocomplete.js View on Github external
function Plugin(element, options) {
  const self = this;
  self.element = element;
  self.options = $.extend({}, defaults, options);
  self._defaults = defaults;
  self._name = pluginName;

  self.namespaceDeferred = $.Deferred();
  self.computeDeferred = $.Deferred();

  if (self.options.namespace) {
    self.namespaceDeferred.resolve(self.options.namespace);
  } else {
    contextCatalog.getNamespaces({ sourceType: options.apiHelperType }).done(context => {
      if (context.namespaces && context.namespaces.length) {
        self.namespaceDeferred.resolve(context.namespaces[0]);
      } else {
        self.namespaceDeferred.reject();
      }
    });
  }
  self.namespaceDeferred.done(namespace => {
    if (
      !self.options.compute ||
      !namespace.computes.some(compute => {
        if (compute.id === self.options.compute.id) {
          self.computeDeferred.resolve(compute);
          return true;
        }
      })
github cloudera / hue / desktop / core / src / desktop / js / ko / components / assist / assistDbSource.js View on Github external
huePubSub.subscribe('context.catalog.namespaces.refreshed', sourceType => {
      if (self.sourceType !== sourceType) {
        return;
      }

      self.loading(true);
      contextCatalog
        .getNamespaces({ sourceType: self.sourceType })
        .done(context => {
          const newNamespaces = [];
          const existingNamespaceIndex = {};
          self.namespaces().forEach(assistNamespace => {
            existingNamespaceIndex[assistNamespace.namespace.id] = assistNamespace;
          });
          context.namespaces.forEach(newNamespace => {
            if (existingNamespaceIndex[newNamespace.id]) {
              existingNamespaceIndex[newNamespace.id].namespace = newNamespace;
              existingNamespaceIndex[newNamespace.id].name = newNamespace.name;
              existingNamespaceIndex[newNamespace.id].status(newNamespace.status);
              newNamespaces.push(existingNamespaceIndex[newNamespace.id]);
            } else {
              newNamespaces.push(
                new AssistDbNamespace({
github cloudera / hue / desktop / core / src / desktop / js / apps / table_browser / metastoreSource.js View on Github external
loadNamespaces() {
    this.loading(true);
    contextCatalog
      .getNamespaces({ sourceType: this.type })
      .done(context => {
        const namespacesWithComputes = context.namespaces.filter(
          namespace => namespace.computes.length
        );
        this.namespaces(
          namespacesWithComputes.map(
            namespace =>
              new MetastoreNamespace({
                metastoreViewModel: this.metastoreViewModel,
                sourceType: this.type,
                navigatorEnabled: this.metastoreViewModel.navigatorEnabled,
                optimizerEnabled: this.metastoreViewModel.optimizerEnabled,
                namespace: namespace
              })
          )