Search in sources :

Example 1 with KettleDependencyException

use of org.pentaho.di.core.exception.KettleDependencyException in project pentaho-kettle by pentaho.

the class KettleDatabaseRepository method deleteSlave.

public synchronized void deleteSlave(ObjectId id_slave) throws KettleException {
    securityProvider.validateAction(RepositoryOperation.DELETE_SLAVE_SERVER);
    // First, see if the slave is still used by other objects...
    // If so, generate an error!!
    // We look in table R_TRANS_SLAVE to see if there are any transformations
    // using this slave.
    // We obviously also look in table R_CLUSTER_SLAVE to see if there are any
    // clusters that use this slave.
    // 
    String[] transList = getTransformationsUsingSlave(id_slave);
    String[] clustList = getClustersUsingSlave(id_slave);
    if (transList.length == 0 && clustList.length == 0) {
        connectionDelegate.performDelete("DELETE FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_SLAVE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_SLAVE_ID_SLAVE) + " = ? ", id_slave);
        connectionDelegate.performDelete("DELETE FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_TRANS_SLAVE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_TRANS_SLAVE_ID_SLAVE) + " = ? ", id_slave);
        commit();
    } else {
        StringBuilder message = new StringBuilder(100);
        if (transList.length > 0) {
            message.append("Slave used by the following transformations:").append(Const.CR);
            for (int i = 0; i < transList.length; i++) {
                message.append("  ").append(transList[i]).append(Const.CR);
            }
            message.append(Const.CR);
        }
        if (clustList.length > 0) {
            message.append("Slave used by the following cluster schemas:").append(Const.CR);
            for (int i = 0; i < clustList.length; i++) {
                message.append("  ").append(clustList[i]).append(Const.CR);
            }
        }
        KettleDependencyException e = new KettleDependencyException(message.toString());
        throw new KettleDependencyException("This slave server is still in use by one or more transformations (" + transList.length + ") or cluster schemas (" + clustList.length + ") :", e);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) KettleDependencyException(org.pentaho.di.core.exception.KettleDependencyException)

Example 2 with KettleDependencyException

use of org.pentaho.di.core.exception.KettleDependencyException in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryPartitionSchemaDelegate method delPartitionSchema.

public synchronized void delPartitionSchema(ObjectId id_partition_schema) throws KettleException {
    // First, see if the schema is still used by other objects...
    // If so, generate an error!!
    // 
    // We look in table R_TRANS_PARTITION_SCHEMA to see if there are any transformations using this schema.
    String[] transList = repository.getTransformationsUsingPartitionSchema(id_partition_schema);
    if (transList.length == 0) {
        repository.connectionDelegate.performDelete("DELETE FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_PARTITION) + " WHERE " + quote(KettleDatabaseRepository.FIELD_PARTITION_ID_PARTITION_SCHEMA) + " = ? ", id_partition_schema);
        repository.connectionDelegate.performDelete("DELETE FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_PARTITION_SCHEMA) + " WHERE " + quote(KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_ID_PARTITION_SCHEMA) + " = ? ", id_partition_schema);
    } else {
        StringBuilder message = new StringBuilder(100);
        message.append("The partition schema is used by the following transformations:").append(Const.CR);
        for (int i = 0; i < transList.length; i++) {
            message.append("  ").append(transList[i]).append(Const.CR);
        }
        message.append(Const.CR);
        KettleDependencyException e = new KettleDependencyException(message.toString());
        throw new KettleDependencyException("This partition schema is still in use by one or more transformations (" + transList.length + ") :", e);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleDependencyException(org.pentaho.di.core.exception.KettleDependencyException)

Example 3 with KettleDependencyException

use of org.pentaho.di.core.exception.KettleDependencyException in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryDatabaseDelegate method delDatabase.

public synchronized void delDatabase(ObjectId id_database) throws KettleException {
    repository.getSecurityProvider().validateAction(RepositoryOperation.DELETE_DATABASE);
    // First, see if the database connection is still used by other connections...
    // If so, generate an error!!
    // We look in table R_STEP_DATABASE to see if there are any steps using this database.
    // 
    String[] transList = repository.getTransformationsUsingDatabase(id_database);
    String[] jobList = repository.getJobsUsingDatabase(id_database);
    if (jobList.length == 0 && transList.length == 0) {
        repository.connectionDelegate.performDelete("DELETE FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_DATABASE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE) + " = ? ", id_database);
    } else {
        String message = " Database used by the following " + Const.CR;
        if (jobList.length > 0) {
            message = "jobs :" + Const.CR;
            for (String job : jobList) {
                message += "\t " + job + Const.CR;
            }
        }
        message += "transformations:" + Const.CR;
        for (String trans : transList) {
            message += "\t " + trans + Const.CR;
        }
        KettleDependencyException e = new KettleDependencyException(message);
        throw new KettleDependencyException("This database is still in use by " + jobList.length + " jobs and " + transList.length + " transformations references", e);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleDependencyException(org.pentaho.di.core.exception.KettleDependencyException)

Example 4 with KettleDependencyException

use of org.pentaho.di.core.exception.KettleDependencyException in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryClusterSchemaDelegate method delClusterSchema.

public synchronized void delClusterSchema(ObjectId id_cluster) throws KettleException {
    // First, see if the schema is still used by other objects...
    // If so, generate an error!!
    // 
    // We look in table R_TRANS_CLUSTER to see if there are any transformations using this schema.
    String[] transList = repository.getTransformationsUsingCluster(id_cluster);
    if (transList.length == 0) {
        repository.connectionDelegate.performDelete("DELETE FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_CLUSTER) + " WHERE " + quote(KettleDatabaseRepository.FIELD_CLUSTER_ID_CLUSTER) + " = ? ", id_cluster);
    } else {
        StringBuilder message = new StringBuilder();
        message.append("The cluster schema is used by the following transformations:").append(Const.CR);
        for (int i = 0; i < transList.length; i++) {
            message.append("  ").append(transList[i]).append(Const.CR);
        }
        message.append(Const.CR);
        KettleDependencyException e = new KettleDependencyException(message.toString());
        throw new KettleDependencyException("This cluster schema is still in use by one or more transformations (" + transList.length + ") :", e);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleDependencyException(org.pentaho.di.core.exception.KettleDependencyException)

Aggregations

KettleDependencyException (org.pentaho.di.core.exception.KettleDependencyException)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)1