Search in sources :

Example 26 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class RepositoryImporter method loadSharedObjects.

/**
 * Load the shared objects up front, replace them in the xforms/jobs loaded from XML. We do this for performance
 * reasons.
 *
 * @throws KettleException
 */
protected void loadSharedObjects() throws KettleException {
    sharedObjects = new SharedObjects();
    for (ObjectId id : rep.getDatabaseIDs(false)) {
        DatabaseMeta databaseMeta = rep.loadDatabaseMeta(id, null);
        validateImportedElement(importRules, databaseMeta);
        sharedObjects.storeObject(databaseMeta);
    }
    ObjectId[] slaveIDs = rep.getSlaveIDs(false);
    List<SlaveServer> slaveServers = new ArrayList<SlaveServer>(slaveIDs.length);
    for (ObjectId id : slaveIDs) {
        SlaveServer slaveServer = rep.loadSlaveServer(id, null);
        validateImportedElement(importRules, slaveServer);
        sharedObjects.storeObject(slaveServer);
        slaveServers.add(slaveServer);
    }
    for (ObjectId id : rep.getClusterIDs(false)) {
        ClusterSchema clusterSchema = rep.loadClusterSchema(id, slaveServers, null);
        validateImportedElement(importRules, clusterSchema);
        sharedObjects.storeObject(clusterSchema);
    }
    for (ObjectId id : rep.getPartitionSchemaIDs(false)) {
        PartitionSchema partitionSchema = rep.loadPartitionSchema(id, null);
        validateImportedElement(importRules, partitionSchema);
        sharedObjects.storeObject(partitionSchema);
    }
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) ArrayList(java.util.ArrayList) SharedObjects(org.pentaho.di.shared.SharedObjects) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 27 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class RepositoriesMeta method clone.

public RepositoriesMeta clone() {
    RepositoriesMeta meta = new RepositoriesMeta();
    meta.clear();
    for (DatabaseMeta dbMeta : databases) {
        meta.addDatabase(dbMeta);
    }
    for (RepositoryMeta repMeta : repositories) {
        meta.addRepository(repMeta.clone());
    }
    return meta;
}
Also used : KettleDatabaseRepositoryMeta(org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 28 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class RepositoriesMeta method clear.

public void clear() {
    errorMessage = null;
    databases = new ArrayList<DatabaseMeta>();
    repositories = new ArrayList<RepositoryMeta>();
    LogLevel level = null;
    if (log != null) {
        level = log.getLogLevel();
    }
    setLog(newLogChannel());
    if (level != null) {
        log.setLogLevel(level);
    }
}
Also used : KettleDatabaseRepositoryMeta(org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) LogLevel(org.pentaho.di.core.logging.LogLevel)

Example 29 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class RepositoriesMeta method parseRepositoriesDoc.

protected void parseRepositoriesDoc(Document doc) throws Exception {
    // Get the <repositories> node:
    Node repsnode = XMLHandler.getSubNode(doc, "repositories");
    // Handle connections
    int nrconn = XMLHandler.countNodes(repsnode, "connection");
    if (log.isDebug()) {
        log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ConnectionNumber", nrconn));
    }
    for (int i = 0; i < nrconn; i++) {
        if (log.isDebug()) {
            log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.LookingConnection", i));
        }
        Node dbnode = XMLHandler.getSubNodeByNr(repsnode, "connection", i);
        DatabaseMeta dbcon = null;
        try {
            dbcon = new DatabaseMeta(dbnode);
            addDatabase(dbcon);
            if (log.isDebug()) {
                log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ReadConnection", dbcon.getName()));
            }
        } catch (Exception kpe) {
            log.logError(BaseMessages.getString(PKG, "RepositoryMeta.Error.CreatingDatabaseMeta", dbcon.getName()));
        }
    }
    // Handle repositories...
    int nrreps = XMLHandler.countNodes(repsnode, RepositoryMeta.XML_TAG);
    if (log.isDebug()) {
        log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.RepositoryNumber", nrreps));
    }
    StringBuilder unableToReadIds = new StringBuilder();
    KettleException kettleException = null;
    for (int i = 0; i < nrreps; i++) {
        Node repnode = XMLHandler.getSubNodeByNr(repsnode, RepositoryMeta.XML_TAG, i);
        if (log.isDebug()) {
            log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.LookingRepository", i));
        }
        String id = XMLHandler.getTagValue(repnode, "id");
        if (Utils.isEmpty(id)) {
            // Backward compatibility : if the id is not defined, it's the database repository!
            // 
            id = KettleDatabaseRepositoryMeta.REPOSITORY_TYPE_ID;
        }
        try {
            RepositoryMeta repositoryMeta = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, id, RepositoryMeta.class);
            if (repositoryMeta != null) {
                repositoryMeta.loadXML(repnode, databases);
                // repositories dialog
                if (repositoryMeta.getDescription() == null || repositoryMeta.getDescription().equals("")) {
                    repositoryMeta.setDescription(repositoryMeta.getName());
                }
                addRepository(repositoryMeta);
                if (log.isDebug()) {
                    log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Log.ReadRepository", repositoryMeta.getName()));
                }
            } else {
                unableToReadIds.append(id);
                unableToReadIds.append(",");
                if (log.isDebug()) {
                    log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Error.ReadRepositoryId", id));
                }
            }
        } catch (KettleException ex) {
            // Get to the root cause
            Throwable cause = ex;
            kettleException = ex;
            while (cause.getCause() != null) {
                cause = cause.getCause();
            }
            if (cause instanceof KettleRepositoryNotSupportedException) {
                // If the root cause is a KettleRepositoryNotSupportedException, do not fail
                if (log.isDebug()) {
                    log.logDebug(BaseMessages.getString(PKG, "RepositoryMeta.Error.UnrecognizedRepositoryType", id));
                }
            }
        }
    }
    if (unableToReadIds != null && unableToReadIds.length() > 0) {
        errorMessage = BaseMessages.getString(PKG, "RepositoryMeta.Error.ReadRepositoryIdNotAvailable", unableToReadIds.substring(0, unableToReadIds.lastIndexOf(",")));
    }
    if (kettleException != null) {
        throw kettleException;
    }
}
Also used : KettleDatabaseRepositoryMeta(org.pentaho.di.repository.kdr.KettleDatabaseRepositoryMeta) KettleException(org.pentaho.di.core.exception.KettleException) Node(org.w3c.dom.Node) KettleRepositoryNotSupportedException(org.pentaho.di.core.exception.KettleRepositoryNotSupportedException) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) KettleException(org.pentaho.di.core.exception.KettleException) FileNotFoundException(java.io.FileNotFoundException) KettleRepositoryNotSupportedException(org.pentaho.di.core.exception.KettleRepositoryNotSupportedException)

Example 30 with DatabaseMeta

use of org.pentaho.di.core.database.DatabaseMeta in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryMeta method populate.

@Override
public void populate(Map<String, Object> properties, RepositoriesMeta repositoriesMeta) {
    super.populate(properties, repositoriesMeta);
    String databaseConnection = (String) properties.get(DATABASE_CONNECTION);
    DatabaseMeta databaseMeta = repositoriesMeta.searchDatabase(databaseConnection);
    if (databaseMeta != null) {
        setConnection(databaseMeta);
    }
}
Also used : DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Aggregations

DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)522 Test (org.junit.Test)133 KettleException (org.pentaho.di.core.exception.KettleException)131 Database (org.pentaho.di.core.database.Database)88 MessageBox (org.eclipse.swt.widgets.MessageBox)66 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)63 TransMeta (org.pentaho.di.trans.TransMeta)57 StepMeta (org.pentaho.di.trans.step.StepMeta)54 ArrayList (java.util.ArrayList)53 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)48 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)44 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)42 SlaveServer (org.pentaho.di.cluster.SlaveServer)33 IMetaStore (org.pentaho.metastore.api.IMetaStore)30 ObjectId (org.pentaho.di.repository.ObjectId)29 DatabaseExplorerDialog (org.pentaho.di.ui.core.database.dialog.DatabaseExplorerDialog)29 JobMeta (org.pentaho.di.job.JobMeta)26 TransHopMeta (org.pentaho.di.trans.TransHopMeta)26 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)24 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)24