use of org.pentaho.di.ui.core.database.dialog.SQLEditor in project pentaho-kettle by pentaho.
the class GPLoadDialog method create.
// Generate code for create table...
// Conversions done by Database
private void create() {
try {
GPLoadMeta info = new GPLoadMeta();
getInfo(info);
// new name might not yet be linked to other
String name = stepname;
// steps!
StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "GPLoadDialog.StepMeta.Title"), name, info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "GPLoadDialog.NoSQLNeeds.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "GPLoadDialog.NoSQLNeeds.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "GPLoadDialog.SQLError.DialogTitle"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "GPLoadDialog.CouldNotBuildSQL.DialogTitle"), BaseMessages.getString(PKG, "GPLoadDialog.CouldNotBuildSQL.DialogMessage"), ke);
}
}
use of org.pentaho.di.ui.core.database.dialog.SQLEditor in project pentaho-kettle by pentaho.
the class IngresVectorwiseLoaderDialog method sql.
private void sql() {
try {
IngresVectorwiseLoaderMeta info = new IngresVectorwiseLoaderMeta();
getInfo(info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
StepMeta stepMeta = transMeta.findStep(stepname);
// Only use the fields that were specified.
//
RowMetaInterface prevNew = new RowMeta();
for (int i = 0; i < info.getFieldDatabase().length; i++) {
ValueMetaInterface insValue = prev.searchValueMeta(info.getFieldStream()[i]);
if (insValue != null) {
ValueMetaInterface insertValue = insValue.clone();
insertValue.setName(info.getFieldDatabase()[i]);
prevNew.addValueMeta(insertValue);
} else {
throw new KettleStepException(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.FailedToFindField.Message", info.getFieldStream()[i]));
}
}
prev = prevNew;
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.NoSQL.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.NoSQL.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.BuildSQLError.DialogTitle"), BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.BuildSQLError.DialogMessage"), ke);
}
}
use of org.pentaho.di.ui.core.database.dialog.SQLEditor in project pentaho-kettle by pentaho.
the class MonetDBBulkLoaderDialog method create.
// Generate code for create table...
// Conversions done by Database
private void create() {
try {
MonetDBBulkLoaderMeta info = new MonetDBBulkLoaderMeta();
getInfo(info);
// new name might not yet be linked to other steps!
String name = stepname;
SQLStatement sql = info.getTableDdl(transMeta, name, false, null, false);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.NoSQLNeeds.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.NoSQLNeeds.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.SQLError.DialogTitle"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.CouldNotBuildSQL.DialogTitle"), BaseMessages.getString(PKG, "MonetDBBulkLoaderDialog.CouldNotBuildSQL.DialogMessage"), ke);
}
}
use of org.pentaho.di.ui.core.database.dialog.SQLEditor in project pentaho-kettle by pentaho.
the class OraBulkLoaderDialog method create.
// Generate code for create table...
// Conversions done by Database
private void create() {
try {
OraBulkLoaderMeta info = new OraBulkLoaderMeta();
getInfo(info);
// new name might not yet be linked to other steps!
String name = stepname;
StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "OraBulkLoaderDialog.StepMeta.Title"), name, info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "OraBulkLoaderDialog.NoSQLNeeds.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "OraBulkLoaderDialog.NoSQLNeeds.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "OraBulkLoaderDialog.SQLError.DialogTitle"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "OraBulkLoaderDialog.CouldNotBuildSQL.DialogTitle"), BaseMessages.getString(PKG, "OraBulkLoaderDialog.CouldNotBuildSQL.DialogMessage"), ke);
}
}
use of org.pentaho.di.ui.core.database.dialog.SQLEditor in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryDialog method create.
private void create() {
System.out.println("Loading repository info...");
KettleDatabaseRepositoryMeta repositoryMeta = new KettleDatabaseRepositoryMeta();
getInfo(repositoryMeta);
if (repositoryMeta.getConnection() != null) {
if (repositoryMeta.getConnection().getAccessType() == DatabaseMeta.TYPE_ACCESS_ODBC) {
// Show a warning: using ODBC is not always the best choice ;-)
System.out.println("Show ODBC warning...");
MessageBox qmb = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
qmb.setMessage(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.ODBCIsNotSafe.Message", Const.CR, Const.CR));
qmb.setText(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.ODBCIsNotSafe.Title"));
int answer = qmb.open();
if (answer != SWT.YES) {
// Don't continue
return;
}
}
try {
System.out.println("Allocating repository...");
KettleDatabaseRepository rep = (KettleDatabaseRepository) PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class);
rep.init(repositoryMeta);
if (!rep.getDatabaseMeta().getDatabaseInterface().supportsRepository()) {
// Show a warning box "This database type is not supported for the use as a database repository."
System.out.println("Show database type is not supported warning...");
MessageBox qmb = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
qmb.setMessage(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.DBTypeNotSupport.Message", Const.CR, Const.CR));
qmb.setText(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.DBTypeNotSupport.Title"));
int answer = qmb.open();
if (answer != SWT.YES) {
// Don't continue
return;
}
}
System.out.println("Connecting to database for repository creation...");
rep.connectionDelegate.connect(true, true);
boolean upgrade = false;
String cu = BaseMessages.getString(PKG, "RepositoryDialog.Dialog.CreateUpgrade.Create");
try {
String userTableName = rep.getDatabaseMeta().quoteField(KettleDatabaseRepository.TABLE_R_USER);
upgrade = rep.getDatabase().checkTableExists(userTableName);
if (upgrade) {
cu = BaseMessages.getString(PKG, "RepositoryDialog.Dialog.CreateUpgrade.Upgrade");
}
} catch (KettleDatabaseException dbe) {
// Roll back the connection: this is required for certain databases like PGSQL
// Otherwise we can't execute any other DDL statement.
//
rep.rollback();
// Don't show an error anymore, just go ahead and propose to create the repository!
}
MessageBox qmb = new MessageBox(shell, SWT.ICON_WARNING | SWT.YES | SWT.NO);
qmb.setMessage(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.CreateUpgrade.Message1") + cu + BaseMessages.getString(PKG, "RepositoryDialog.Dialog.CreateUpgrade.Message2"));
qmb.setText(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.CreateUpgrade.Title"));
int answer = qmb.open();
if (answer == SWT.YES) {
boolean goAhead = !upgrade;
if (!goAhead) {
EnterPasswordDialog etd = new EnterPasswordDialog(shell, BaseMessages.getString(PKG, "RepositoryDialog.Dialog.EnterPassword.Title"), BaseMessages.getString(PKG, "RepositoryDialog.Dialog.EnterPassword.Message"), "");
etd.setModal();
String pwd = etd.open();
if (pwd != null) {
try {
// authenticate as admin before upgrade
// disconnect before connecting, we connected above already
//
rep.disconnect();
rep.connect("admin", pwd, true);
goAhead = true;
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryDialog.Dialog.UnableToVerifyUser.Title"), BaseMessages.getString(PKG, "RepositoryDialog.Dialog.UnableToVerifyUser.Message"), e);
}
}
}
if (goAhead) {
System.out.println(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.TryingToUpgradeRepository.Message1") + cu + BaseMessages.getString(PKG, "RepositoryDialog.Dialog.TryingToUpgradeRepository.Message2"));
UpgradeRepositoryProgressDialog urpd = new UpgradeRepositoryProgressDialog(shell, rep, upgrade);
if (urpd.open()) {
if (urpd.isDryRun()) {
StringBuilder sql = new StringBuilder();
sql.append("-- Repository creation/upgrade DDL: ").append(Const.CR);
sql.append("--").append(Const.CR);
sql.append("-- Nothing was created nor modified in the target repository database.").append(Const.CR);
sql.append("-- Hit the OK button to execute the generated SQL or Close to reject the changes.").append(Const.CR);
sql.append("-- Please note that it is possible to change/edit the generated SQL before execution.").append(Const.CR);
sql.append("--").append(Const.CR);
for (String statement : urpd.getGeneratedStatements()) {
if (statement.endsWith(";")) {
sql.append(statement).append(Const.CR);
} else {
sql.append(statement).append(";").append(Const.CR).append(Const.CR);
}
}
SQLEditor editor = new SQLEditor(rep.getDatabaseMeta(), shell, SWT.NONE, rep.getDatabaseMeta(), DBCache.getInstance(), sql.toString());
editor.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.UpgradeFinished.Message1") + cu + BaseMessages.getString(PKG, "RepositoryDialog.Dialog.UpgradeFinished.Message2"));
mb.setText(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.UpgradeFinished.Title"));
mb.open();
}
}
}
}
rep.disconnect();
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "RepositoryDialog.Dialog.UnableToConnectToUpgrade.Title"), BaseMessages.getString(PKG, "RepositoryDialog.Dialog.UnableToConnectToUpgrade.Message") + Const.CR, ke);
}
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.FirstCreateAValidConnection.Message"));
mb.setText(BaseMessages.getString(PKG, "RepositoryDialog.Dialog.FirstCreateAValidConnection.Title"));
mb.open();
}
}
Aggregations