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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations