Search in sources :

Example 1 with ConnectionManager

use of org.pentaho.di.connections.ConnectionManager in project pentaho-kettle by pentaho.

the class ConnectionUtil method init.

/**
 * Initialize the connected meta store with embedded named connections
 *
 * @param meta The meta containing named connections
 */
public static void init(AbstractMeta meta) {
    ConnectionManager connectionManager = ConnectionManager.getInstance();
    IMetaStore metaStore = null;
    try {
        if (meta.getRepository() != null) {
            if (meta.getMetaStore() instanceof DelegatingMetaStore) {
                metaStore = ((DelegatingMetaStore) meta.getMetaStore()).getActiveMetaStore();
            } else {
                metaStore = meta.getRepository().getMetaStore();
            }
        } else {
            metaStore = MetaStoreConst.openLocalPentahoMetaStore();
        }
    } catch (MetaStoreException ignored) {
    // Allow connectedMetaStore to be null
    }
    if (metaStore != null) {
        final IMetaStore connectedMetaStore = metaStore;
        connectionManager.setMetastoreSupplier(() -> connectedMetaStore);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) ConnectionManager(org.pentaho.di.connections.ConnectionManager) DelegatingMetaStore(org.pentaho.metastore.stores.delegate.DelegatingMetaStore) IMetaStore(org.pentaho.metastore.api.IMetaStore)

Example 2 with ConnectionManager

use of org.pentaho.di.connections.ConnectionManager in project pentaho-kettle by pentaho.

the class ConnectionDelegate method delete.

public void delete(String label) {
    ConnectionDeleteDialog connectionDeleteDialog = new ConnectionDeleteDialog(spoonSupplier.get().getShell());
    if (connectionDeleteDialog.open(label) == SWT.YES) {
        ConnectionManager connectionManager = ConnectionManager.getInstance();
        connectionManager.delete(label);
        spoonSupplier.get().getShell().getDisplay().asyncExec(() -> spoonSupplier.get().refreshTree(ConnectionFolderProvider.STRING_VFS_CONNECTIONS));
        EngineMetaInterface engineMetaInterface = spoonSupplier.get().getActiveMeta();
        if (engineMetaInterface instanceof AbstractMeta) {
            ((AbstractMeta) engineMetaInterface).setChanged();
        }
    }
}
Also used : ConnectionManager(org.pentaho.di.connections.ConnectionManager) AbstractMeta(org.pentaho.di.base.AbstractMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface)

Aggregations

ConnectionManager (org.pentaho.di.connections.ConnectionManager)2 AbstractMeta (org.pentaho.di.base.AbstractMeta)1 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)1 IMetaStore (org.pentaho.metastore.api.IMetaStore)1 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)1 DelegatingMetaStore (org.pentaho.metastore.stores.delegate.DelegatingMetaStore)1