use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.
the class DataGridDialog method preview.
/**
* Preview the data generated by this transform. This generates a pipeline using this transform &
* a dummy and previews it.
*/
private void preview() {
// Create the table input reader transform...
DataGridMeta oneMeta = new DataGridMeta();
getInfo(oneMeta);
PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(pipelineMeta.getMetadataProvider(), oneMeta, wTransformName.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "DataGridDialog.EnterPreviewSize.Title"), BaseMessages.getString(PKG, "DataGridDialog.EnterPreviewSize.Message"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, previewMeta, new String[] { wTransformName.getText() }, new int[] { previewSize });
progressDialog.open();
Pipeline pipeline = progressDialog.getPipeline();
String loggingText = progressDialog.getLoggingText();
if (!progressDialog.isCancelled() && pipeline.getResult() != null && pipeline.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, wTransformName.getText(), progressDialog.getPreviewRowsMeta(wTransformName.getText()), progressDialog.getPreviewRows(wTransformName.getText()), loggingText);
prd.open();
}
}
use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.
the class MetadataInputDialog method preview.
// Preview the data
private void preview() {
try {
// Create the Access input transform
MetadataInputMeta oneMeta = new MetadataInputMeta();
getInfo(oneMeta);
PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(metadataProvider, oneMeta, wTransformName.getText());
// Preview the first 1000 rows...
//
PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, previewMeta, new String[] { wTransformName.getText() }, new int[] { 1000 });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Pipeline pipeline = progressDialog.getPipeline();
String loggingText = progressDialog.getLoggingText();
if (pipeline.getResult() != null && pipeline.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, wTransformName.getText(), progressDialog.getPreviewRowsMeta(wTransformName.getText()), progressDialog.getPreviewRows(wTransformName.getText()), loggingText);
prd.open();
}
} catch (HopException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "MetadataInputDialog.ErrorPreviewingData.DialogTitle"), BaseMessages.getString(PKG, "MetadataInputDialog.ErrorPreviewingData.DialogMessage"), e);
}
}
use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.
the class TableInputDialog method preview.
/**
* Preview the data generated by this transform. This generates a pipeline using this transform &
* a dummy and previews it.
*/
private void preview() {
// Create the table input reader transform...
TableInputMeta oneMeta = new TableInputMeta();
getInfo(oneMeta, true);
PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(pipelineMeta.getMetadataProvider(), oneMeta, wTransformName.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "TableInputDialog.EnterPreviewSize"), BaseMessages.getString(PKG, "TableInputDialog.NumberOfRowsToPreview"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, previewMeta, new String[] { wTransformName.getText() }, new int[] { previewSize });
progressDialog.open();
Pipeline pipeline = progressDialog.getPipeline();
String loggingText = progressDialog.getLoggingText();
if (!progressDialog.isCancelled()) {
if (pipeline.getResult() != null && pipeline.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"), BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
etd.setReadOnly();
etd.open();
} else {
PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, wTransformName.getText(), progressDialog.getPreviewRowsMeta(wTransformName.getText()), progressDialog.getPreviewRows(wTransformName.getText()), loggingText);
prd.open();
}
}
}
}
use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.
the class SqlEditor method exec.
private void exec() {
DatabaseMeta databaseMeta = connection;
if (databaseMeta == null) {
return;
}
StringBuilder message = new StringBuilder();
Database db = new Database(loggingObject, variables, databaseMeta);
try {
db.connect();
String sqlScript = Utils.isEmpty(wScript.getSelectionText()) ? wScript.getText() : wScript.getSelectionText();
// Multiple statements in the script need to be split into individual
// executable statements
List<SqlScriptStatement> statements = databaseMeta.getIDatabase().getSqlScriptStatements(sqlScript + Const.CR);
int nrstats = 0;
for (SqlScriptStatement sql : statements) {
if (sql.isQuery()) {
// A Query
log.logDetailed("launch SELECT statement: " + Const.CR + sql);
nrstats++;
try {
List<Object[]> rows = db.getRows(sql.getStatement(), 1000);
IRowMeta rowMeta = db.getReturnRowMeta();
if (rows.size() > 0) {
PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, BaseMessages.getString(PKG, "SQLEditor.ResultRows.Title", Integer.toString(nrstats)), rowMeta, rows);
prd.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.ICON_INFORMATION | SWT.OK);
mb.setMessage(BaseMessages.getString(PKG, "SQLEditor.NoRows.Message", sql));
mb.setText(BaseMessages.getString(PKG, "SQLEditor.NoRows.Title"));
mb.open();
}
} catch (HopDatabaseException dbe) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "SQLEditor.ErrorExecSQL.Title"), BaseMessages.getString(PKG, "SQLEditor.ErrorExecSQL.Message", sql), dbe);
}
} else {
log.logDetailed("launch DDL statement: " + Const.CR + sql);
// A DDL statement
nrstats++;
int startLogLine = HopLogStore.getLastBufferLineNr();
try {
log.logDetailed("Executing SQL: " + Const.CR + sql);
db.execStatement(sql.getStatement());
message.append(BaseMessages.getString(PKG, "SQLEditor.Log.SQLExecuted", sql));
message.append(Const.CR);
// Clear the database cache, in case we're using one...
if (dbcache != null) {
dbcache.clear(databaseMeta.getName());
}
// mark the statement in green in the dialog...
//
sql.setOk(true);
} catch (Exception dbe) {
sql.setOk(false);
String error = BaseMessages.getString(PKG, "SQLEditor.Log.SQLExecError", sql, dbe.toString());
message.append(error).append(Const.CR);
ErrorDialog dialog = new ErrorDialog(shell, BaseMessages.getString(PKG, "SQLEditor.ErrorExecSQL.Title"), error, dbe, true);
if (dialog.isCancelled()) {
break;
}
} finally {
int endLogLine = HopLogStore.getLastBufferLineNr();
sql.setLoggingText(HopLogStore.getAppender().getLogBufferFromTo(db.getLogChannelId(), true, startLogLine, endLogLine).toString());
sql.setComplete(true);
refreshExecutionResults();
}
}
}
message.append(BaseMessages.getString(PKG, "SQLEditor.Log.StatsExecuted", Integer.toString(nrstats)));
message.append(Const.CR);
} catch (HopDatabaseException dbe) {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
String error = BaseMessages.getString(PKG, "SQLEditor.Error.CouldNotConnect.Message", (connection == null ? "" : connection.getName()), dbe.getMessage());
message.append(error).append(Const.CR);
mb.setMessage(error);
mb.setText(BaseMessages.getString(PKG, "SQLEditor.Error.CouldNotConnect.Title"));
mb.open();
} finally {
db.disconnect();
refreshExecutionResults();
}
EnterTextDialog dialog = new EnterTextDialog(shell, BaseMessages.getString(PKG, "SQLEditor.Result.Title"), BaseMessages.getString(PKG, "SQLEditor.Result.Message"), message.toString(), true);
dialog.open();
}
use of org.apache.hop.ui.core.dialog.PreviewRowsDialog in project hop by apache.
the class GetSubFoldersDialog method preview.
// Preview the data
private void preview() {
// Create the XML input transform
GetSubFoldersMeta oneMeta = new GetSubFoldersMeta();
getInfo(oneMeta);
PipelineMeta previewMeta = PipelinePreviewFactory.generatePreviewPipeline(pipelineMeta.getMetadataProvider(), oneMeta, wTransformName.getText());
EnterNumberDialog numberDialog = new EnterNumberDialog(shell, props.getDefaultPreviewSize(), BaseMessages.getString(PKG, "GetSubFoldersDialog.PreviewSize.DialogTitle"), BaseMessages.getString(PKG, "GetSubFoldersDialog.PreviewSize.DialogMessage"));
int previewSize = numberDialog.open();
if (previewSize > 0) {
PipelinePreviewProgressDialog progressDialog = new PipelinePreviewProgressDialog(shell, variables, previewMeta, new String[] { wTransformName.getText() }, new int[] { previewSize });
progressDialog.open();
if (!progressDialog.isCancelled()) {
Pipeline pipeline = progressDialog.getPipeline();
String loggingText = progressDialog.getLoggingText();
if (pipeline.getResult() != null && pipeline.getResult().getNrErrors() > 0) {
EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "GetSubFoldersDialog.ErrorInPreview.DialogMessage"), loggingText, true);
etd.setReadOnly();
etd.open();
}
PreviewRowsDialog prd = new PreviewRowsDialog(shell, variables, SWT.NONE, wTransformName.getText(), progressDialog.getPreviewRowsMeta(wTransformName.getText()), progressDialog.getPreviewRows(wTransformName.getText()), loggingText);
prd.open();
}
}
}
Aggregations