Search in sources :

Example 56 with KettleDatabaseException

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

the class KettleDatabaseRepositoryTransDelegate method loadTransHopMeta.

public TransHopMeta loadTransHopMeta(ObjectId id_trans_hop, List<StepMeta> steps) throws KettleException {
    TransHopMeta hopTransMeta = new TransHopMeta();
    try {
        hopTransMeta.setObjectId(id_trans_hop);
        RowMetaAndData r = getTransHop(id_trans_hop);
        hopTransMeta.setEnabled(r.getBoolean("ENABLED", false));
        long id_step_from = r.getInteger("ID_STEP_FROM", 0);
        long id_step_to = r.getInteger("ID_STEP_TO", 0);
        StepMeta fromStep = StepMeta.findStep(steps, new LongObjectId(id_step_from));
        // 
        if (fromStep == null && id_step_from > 0) {
            // Simply load this, we only want the name, we don't care about the
            // rest...
            // 
            StepMeta stepMeta = repository.stepDelegate.loadStepMeta(new LongObjectId(id_step_from), new ArrayList<DatabaseMeta>(), new ArrayList<PartitionSchema>());
            fromStep = StepMeta.findStep(steps, stepMeta.getName());
        }
        if (fromStep == null) {
            log.logError("Unable to determine source step of transformation hop with ID: " + id_trans_hop);
            // Invalid hop, simply ignore. See: PDI-2446
            return null;
        }
        hopTransMeta.setFromStep(fromStep);
        hopTransMeta.getFromStep().setDraw(true);
        hopTransMeta.setToStep(StepMeta.findStep(steps, new LongObjectId(id_step_to)));
        // 
        if (hopTransMeta.getToStep() == null && id_step_to > 0) {
            // Simply load this, we only want the name, we don't care about
            // the rest...
            StepMeta stepMeta = repository.stepDelegate.loadStepMeta(new LongObjectId(id_step_to), new ArrayList<DatabaseMeta>(), new ArrayList<PartitionSchema>());
            hopTransMeta.setToStep(StepMeta.findStep(steps, stepMeta.getName()));
        }
        if (hopTransMeta.getFromStep() == null || hopTransMeta.getFromStep() == null) {
            // 
            return null;
        }
        hopTransMeta.getToStep().setDraw(true);
        return hopTransMeta;
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "TransHopMeta.Exception.LoadTransformationHopInfo") + id_trans_hop, dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) PartitionSchema(org.pentaho.di.partition.PartitionSchema) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) TransHopMeta(org.pentaho.di.trans.TransHopMeta) LongObjectId(org.pentaho.di.repository.LongObjectId) StepMeta(org.pentaho.di.trans.step.StepMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Example 57 with KettleDatabaseException

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

the class KettleDatabaseRepositoryUserDelegate method loadUserInfo.

// Load user with login from repository, don't verify password...
public IUser loadUserInfo(IUser userInfo, String login) throws KettleException {
    try {
        userInfo.setObjectId(getUserID(login));
        if (userInfo.getObjectId() != null) {
            RowMetaAndData r = getUser(userInfo.getObjectId());
            if (r != null) {
                userInfo.setLogin(r.getString("LOGIN", null));
                userInfo.setPassword(Encr.decryptPassword(r.getString("PASSWORD", null)));
                userInfo.setUsername(r.getString("NAME", null));
                userInfo.setDescription(r.getString("DESCRIPTION", null));
                userInfo.setEnabled(r.getBoolean("ENABLED", false));
                return userInfo;
            } else {
                throw new KettleDatabaseException(BaseMessages.getString(PKG, "UserInfo.Error.UserNotFound", login));
            }
        } else {
            throw new KettleDatabaseException(BaseMessages.getString(PKG, "UserInfo.Error.UserNotFound", login));
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "UserInfo.Error.UserNotLoaded", login, ""), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Example 58 with KettleDatabaseException

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

the class KettleDatabaseRepositoryUserDelegate method saveUserInfo.

public void saveUserInfo(IUser userInfo) throws KettleException {
    try {
        // Do we have a user id already?
        if (userInfo.getObjectId() == null) {
            // Get userid in the repository
            userInfo.setObjectId(getUserID(userInfo.getLogin()));
        }
        if (userInfo.getObjectId() == null) {
            // This means the login doesn't exist in the database
            // and we have no id, so we don't know the old one...
            // Just grab the next user ID and do an insert:
            userInfo.setObjectId(repository.connectionDelegate.getNextUserID());
            repository.connectionDelegate.insertTableRow("R_USER", fillTableRow(userInfo));
        } else {
            repository.connectionDelegate.updateTableRow("R_USER", "ID_USER", fillTableRow(userInfo));
        }
        // Put a commit behind it!
        repository.commit();
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "UserInfo.Error.SavingUser", userInfo.getLogin()), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException)

Example 59 with KettleDatabaseException

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

the class KettleDatabaseRepositoryJobDelegate method loadJobHopMeta.

public JobHopMeta loadJobHopMeta(ObjectId id_job_hop, List<JobEntryCopy> jobcopies) throws KettleException {
    JobHopMeta jobHopMeta = new JobHopMeta();
    try {
        RowMetaAndData r = getJobHop(id_job_hop);
        if (r != null) {
            long id_jobentry_copy_from = r.getInteger("ID_JOBENTRY_COPY_FROM", -1L);
            long id_jobentry_copy_to = r.getInteger("ID_JOBENTRY_COPY_TO", -1L);
            jobHopMeta.setEnabled(r.getBoolean("ENABLED", true));
            jobHopMeta.setEvaluation(r.getBoolean("EVALUATION", true));
            jobHopMeta.setConditional();
            if (r.getBoolean("UNCONDITIONAL", !jobHopMeta.getEvaluation())) {
                jobHopMeta.setUnconditional();
            }
            jobHopMeta.setFromEntry(JobMeta.findJobEntryCopy(jobcopies, new LongObjectId(id_jobentry_copy_from)));
            jobHopMeta.setToEntry(JobMeta.findJobEntryCopy(jobcopies, new LongObjectId(id_jobentry_copy_to)));
            return jobHopMeta;
        } else {
            throw new KettleException("Unable to find job hop with ID : " + id_job_hop);
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "JobHopMeta.Exception.UnableToLoadHopInfoRep", "" + id_job_hop), dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobHopMeta(org.pentaho.di.job.JobHopMeta) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 60 with KettleDatabaseException

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

the class KettleDatabaseRepositoryJobDelegate method readDatabases.

/**
 * Read the database connections in the repository and add them to this job if they are not yet present.
 *
 * @param jobMeta
 *          the job to put the database connections in
 * @param overWriteShared
 *          set to true if you want to overwrite shared connections while loading.
 * @throws KettleException
 */
public void readDatabases(JobMeta jobMeta, boolean overWriteShared) throws KettleException {
    try {
        ObjectId[] dbids = repository.getDatabaseIDs(false);
        for (int i = 0; i < dbids.length; i++) {
            // reads last version
            DatabaseMeta databaseMeta = repository.loadDatabaseMeta(dbids[i], null);
            databaseMeta.shareVariablesWith(jobMeta);
            // See if there already is one in the transformation
            // 
            DatabaseMeta check = jobMeta.findDatabase(databaseMeta.getName());
            // 
            if (check == null || overWriteShared) {
                if (databaseMeta.getName() != null) {
                    jobMeta.addOrReplaceDatabase(databaseMeta);
                    if (!overWriteShared) {
                        databaseMeta.setChanged(false);
                    }
                }
            }
        }
        jobMeta.setChanged(false);
    } catch (KettleDatabaseException dbe) {
        throw new KettleException(BaseMessages.getString(PKG, "JobMeta.Log.UnableToReadDatabaseIDSFromRepository"), dbe);
    } catch (KettleException ke) {
        throw new KettleException(BaseMessages.getString(PKG, "JobMeta.Log.UnableToReadDatabasesFromRepository"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta)

Aggregations

KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)279 KettleException (org.pentaho.di.core.exception.KettleException)176 SQLException (java.sql.SQLException)69 Database (org.pentaho.di.core.database.Database)46 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)41 KettleValueException (org.pentaho.di.core.exception.KettleValueException)39 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)37 KettleDatabaseBatchException (org.pentaho.di.core.exception.KettleDatabaseBatchException)33 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)31 BatchUpdateException (java.sql.BatchUpdateException)27 ResultSet (java.sql.ResultSet)27 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)26 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)25 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)24 RowMeta (org.pentaho.di.core.row.RowMeta)22 FileObject (org.apache.commons.vfs2.FileObject)18 LongObjectId (org.pentaho.di.repository.LongObjectId)17 Savepoint (java.sql.Savepoint)16 ArrayList (java.util.ArrayList)16 Test (org.junit.Test)14