use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.
the class DatabaseJoinMeta method getTableFields.
@Override
public RowMetaInterface getTableFields() {
// Build a dummy parameter row...
//
RowMetaInterface param = new RowMeta();
for (int i = 0; i < parameterField.length; i++) {
ValueMetaInterface v;
try {
v = ValueMetaFactory.createValueMeta(parameterField[i], parameterType[i]);
} catch (KettlePluginException e) {
v = new ValueMetaNone(parameterField[i]);
}
param.addValueMeta(v);
}
RowMetaInterface fields = null;
if (databaseMeta != null) {
Database db = new Database(loggingObject, databaseMeta);
// Keep track of this one for cancelQuery
databases = new Database[] { db };
try {
db.connect();
fields = db.getQueryFields(databaseMeta.environmentSubstitute(sql), true, param, new Object[param.size()]);
} catch (KettleDatabaseException dbe) {
logError(BaseMessages.getString(PKG, "DatabaseJoinMeta.Log.DatabaseErrorOccurred") + dbe.getMessage());
} finally {
db.disconnect();
}
}
return fields;
}
use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.
the class RepositoryDirectoryUI method loadRepositoryObjects.
protected static List<RepositoryElementMetaInterface> loadRepositoryObjects(RepositoryDirectoryInterface dir, boolean getTransformations, boolean getJobs, Repository rep) throws KettleDatabaseException {
// Then show the transformations & jobs in that directory...
List<RepositoryElementMetaInterface> repositoryObjects = new ArrayList<RepositoryElementMetaInterface>();
if (dir.getRepositoryObjects() == null) {
try {
dir.setRepositoryObjects(rep.getJobAndTransformationObjects(dir.getObjectId(), false));
} catch (KettleException e) {
throw new KettleDatabaseException(e);
}
}
List<RepositoryObjectType> allowedTypes = new ArrayList<>(2);
if (getTransformations) {
allowedTypes.add(RepositoryObjectType.TRANSFORMATION);
}
if (getJobs) {
allowedTypes.add(RepositoryObjectType.JOB);
}
for (RepositoryElementMetaInterface repoObject : dir.getRepositoryObjects()) {
if (allowedTypes.contains(repoObject.getObjectType())) {
repositoryObjects.add(repoObject);
}
}
return repositoryObjects;
}
use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.
the class JobEntryMysqlBulkFileDialog method getListColumns.
/**
* Get a list of columns, comma separated, allow the user to select from it.
*/
private void getListColumns() {
if (!Utils.isEmpty(wTablename.getText())) {
DatabaseMeta databaseMeta = jobMeta.findDatabase(wConnection.getText());
if (databaseMeta != null) {
Database database = new Database(loggingObject, databaseMeta);
database.shareVariablesWith(jobMeta);
try {
database.connect();
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(wSchemaname.getText(), wTablename.getText());
RowMetaInterface row = database.getTableFields(schemaTable);
String[] available = row.getFieldNames();
String[] source = wListColumn.getText().split(",");
for (int i = 0; i < source.length; i++) {
source[i] = Const.trim(source[i]);
}
int[] idxSource = Const.indexsOfStrings(source, available);
EnterSelectionDialog dialog = new EnterSelectionDialog(shell, available, BaseMessages.getString(PKG, "JobMysqlBulkFile.SelectColumns.Title"), BaseMessages.getString(PKG, "JobMysqlBulkFile.SelectColumns.Message"));
dialog.setMulti(true);
dialog.setAvoidQuickSearch();
dialog.setSelectedNrs(idxSource);
if (dialog.open() != null) {
String columns = "";
int[] idx = dialog.getSelectionIndeces();
for (int i = 0; i < idx.length; i++) {
if (i > 0) {
columns += ", ";
}
columns += available[idx[i]];
}
wListColumn.setText(columns);
}
} catch (KettleDatabaseException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobMysqlBulkFile.ConnectionError2.DialogMessage"), e);
} finally {
database.disconnect();
}
}
}
}
use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.
the class PaloCubeCreate method saveRep.
public void saveRep(Repository rep, IMetaStore metaStore, ObjectId id_job) throws KettleException {
try {
rep.saveDatabaseMetaJobEntryAttribute(id_job, getObjectId(), "connection", "id_database", databaseMeta);
rep.saveJobEntryAttribute(id_job, getObjectId(), "cubeName", this.getCubeName());
for (int i = 0; i < this.dimensionNames.size(); i++) {
rep.saveJobEntryAttribute(id_job, getObjectId(), i, "dimensionname", this.dimensionNames.get(i));
}
} catch (KettleDatabaseException dbe) {
throw new KettleException("unable to save jobentry of type 'file exists' to the repository for id_job=" + id_job, dbe);
}
}
use of org.pentaho.di.core.exception.KettleDatabaseException in project pentaho-kettle by pentaho.
the class PaloCubeDelete method saveRep.
public void saveRep(Repository rep, IMetaStore metaStore, ObjectId id_job) throws KettleException {
try {
rep.saveDatabaseMetaJobEntryAttribute(id_job, getObjectId(), "connection", "id_database", databaseMeta);
rep.saveStepAttribute(id_job, getObjectId(), "cubeName", this.getCubeName());
} catch (KettleDatabaseException dbe) {
throw new KettleException("unable to save jobentry of type 'file exists' to the repository for id_job=" + id_job, dbe);
}
}
Aggregations