use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class JobDialog method showLogTypeOptions.
private void showLogTypeOptions(int index) {
if (index != previousLogTableIndex) {
getLogInfo(previousLogTableIndex);
//
for (Control control : wLogOptionsComposite.getChildren()) {
control.dispose();
}
previousLogTableIndex = index;
LogTableInterface logTable = logTables.get(index);
LogTableUserInterface logTableUserInterface = logTableUserInterfaces.get(index);
if (logTableUserInterface != null) {
logTableUserInterface.showLogTableOptions(wLogOptionsComposite, logTable);
} else {
if (logTable instanceof JobLogTable) {
showJobLogTableOptions((JobLogTable) logTable);
} else if (logTable instanceof ChannelLogTable) {
showChannelLogTableOptions((ChannelLogTable) logTable);
}
if (logTable instanceof JobEntryLogTable) {
showJobEntryLogTableOptions((JobEntryLogTable) logTable);
}
}
wLogOptionsComposite.layout(true, true);
wLogComp.layout(true, true);
}
}
use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class JobDialog method sql.
/**
* Generates code for create table... Conversions done by Database
*/
private void sql() {
if (previousLogTableIndex >= 0) {
getLogInfo(previousLogTableIndex);
}
try {
for (LogTableInterface logTable : logTables) {
if (logTable.getDatabaseMeta() != null && !Utils.isEmpty(logTable.getTableName())) {
// OK, we have something to work with!
//
Database db = null;
try {
db = new Database(jobMeta, logTable.getDatabaseMeta());
db.shareVariablesWith(jobMeta);
db.connect();
StringBuilder ddl = new StringBuilder();
RowMetaInterface fields = logTable.getLogRecord(LogStatus.START, null, null).getRowMeta();
String tableName = db.environmentSubstitute(logTable.getTableName());
String schemaTable = logTable.getDatabaseMeta().getQuotedSchemaTableCombination(db.environmentSubstitute(logTable.getSchemaName()), db.environmentSubstitute(logTable.getTableName()));
String createTable = db.getDDL(schemaTable, fields);
if (!Utils.isEmpty(createTable)) {
ddl.append("-- ").append(logTable.getLogTableType()).append(Const.CR);
ddl.append("--").append(Const.CR).append(Const.CR);
ddl.append(createTable).append(Const.CR);
}
java.util.List<RowMetaInterface> indexes = logTable.getRecommendedIndexes();
for (int i = 0; i < indexes.size(); i++) {
RowMetaInterface index = indexes.get(i);
if (!index.isEmpty()) {
String createIndex = db.getCreateIndexStatement(schemaTable, "IDX_" + tableName + "_" + (i + 1), index.getFieldNames(), false, false, false, true);
if (!Utils.isEmpty(createIndex)) {
ddl.append(createIndex);
}
}
}
if (ddl.length() > 0) {
SQLEditor sqledit = new SQLEditor(jobMeta, shell, SWT.NONE, logTable.getDatabaseMeta(), DBCache.getInstance(), ddl.toString());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setText(BaseMessages.getString(PKG, "JobDialog.NoSqlNedds.DialogTitle"));
mb.setMessage(logTable.getLogTableType() + Const.CR + Const.CR + BaseMessages.getString(PKG, "JobDialog.NoSqlNedds.DialogMessage"));
mb.open();
}
} finally {
if (db != null) {
db.disconnect();
}
}
}
}
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JobDialog.Dialog.ErrorCreatingSQL.Title"), BaseMessages.getString(PKG, "JobDialog.Dialog.ErrorCreatingSQL.Message"), e);
}
}
use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class JobDialog method addLogTab.
private void addLogTab() {
// ////////////////////////
// START OF LOG TAB///
// /
wLogTab = new CTabItem(wTabFolder, SWT.NONE);
wLogTab.setText(BaseMessages.getString(PKG, "JobDialog.LogTab.Label"));
FormLayout LogLayout = new FormLayout();
LogLayout.marginWidth = Const.MARGIN;
LogLayout.marginHeight = Const.MARGIN;
wLogComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wLogComp);
wLogComp.setLayout(LogLayout);
// Add a log type List on the left hand side...
//
wLogTypeList = new List(wLogComp, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
props.setLook(wLogTypeList);
for (LogTableInterface logTable : logTables) {
wLogTypeList.add(logTable.getLogTableType());
}
FormData fdLogTypeList = new FormData();
fdLogTypeList.left = new FormAttachment(0, 0);
fdLogTypeList.top = new FormAttachment(0, 0);
fdLogTypeList.right = new FormAttachment(middle / 2, 0);
fdLogTypeList.bottom = new FormAttachment(100, 0);
wLogTypeList.setLayoutData(fdLogTypeList);
wLogTypeList.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
showLogTypeOptions(wLogTypeList.getSelectionIndex());
}
});
// On the right side we see a dynamic area : a composite...
//
wLogOptionsComposite = new Composite(wLogComp, SWT.BORDER);
FormLayout logOptionsLayout = new FormLayout();
logOptionsLayout.marginWidth = Const.MARGIN;
logOptionsLayout.marginHeight = Const.MARGIN;
wLogOptionsComposite.setLayout(logOptionsLayout);
props.setLook(wLogOptionsComposite);
FormData fdLogOptionsComposite = new FormData();
fdLogOptionsComposite.left = new FormAttachment(wLogTypeList, margin);
fdLogOptionsComposite.top = new FormAttachment(0, 0);
fdLogOptionsComposite.right = new FormAttachment(100, 0);
fdLogOptionsComposite.bottom = new FormAttachment(100, 0);
wLogOptionsComposite.setLayoutData(fdLogOptionsComposite);
FormData fdLogComp = new FormData();
fdLogComp.left = new FormAttachment(0, 0);
fdLogComp.top = new FormAttachment(0, 0);
fdLogComp.right = new FormAttachment(100, 0);
fdLogComp.bottom = new FormAttachment(100, 0);
wLogComp.setLayoutData(fdLogComp);
wLogComp.layout();
wLogTab.setControl(wLogComp);
// ///////////////////////////////////////////////////////////
// / END OF LOG TAB
// ///////////////////////////////////////////////////////////
}
use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class JobDialog method open.
public JobMeta open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN | SWT.APPLICATION_MODAL);
props.setLook(shell);
shell.setImage(GUIResource.getInstance().getImageJobGraph());
lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
changed = true;
}
};
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "JobDialog.JobProperties.ShellText"));
middle = props.getMiddlePct();
margin = Const.MARGIN;
wTabFolder = new CTabFolder(shell, SWT.BORDER);
props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
//
for (LogTableInterface logTable : logTables) {
// can be null
logTableUserInterfaces.add(getLogTableUserInterface(logTable, jobMeta, lsMod));
}
addJobTab();
addParamTab();
addSettingsTab();
addLogTab();
// See if there are any other tabs to be added...
extraTabs = new ArrayList<JobDialogPluginInterface>();
java.util.List<PluginInterface> jobDialogPlugins = PluginRegistry.getInstance().getPlugins(JobDialogPluginType.class);
for (PluginInterface jobDialogPlugin : jobDialogPlugins) {
try {
JobDialogPluginInterface extraTab = (JobDialogPluginInterface) PluginRegistry.getInstance().loadClass(jobDialogPlugin);
extraTab.addTab(jobMeta, parent, wTabFolder);
extraTabs.add(extraTab);
} catch (Exception e) {
KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
if (krle != null) {
throw krle;
}
new ErrorDialog(shell, "Error", "Error loading job dialog plugin with id " + jobDialogPlugin.getIds()[0], e);
}
}
fdTabFolder = new FormData();
fdTabFolder.left = new FormAttachment(0, 0);
fdTabFolder.top = new FormAttachment(0, 0);
fdTabFolder.right = new FormAttachment(100, 0);
fdTabFolder.bottom = new FormAttachment(100, -50);
wTabFolder.setLayoutData(fdTabFolder);
// THE BUTTONS
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wSQL = new Button(shell, SWT.PUSH);
wSQL.setText(BaseMessages.getString(PKG, "System.Button.SQL"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
// BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, margin, wSharedObjectsFile);
BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, Const.MARGIN, null);
// Add listeners
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
lsSQL = new Listener() {
public void handleEvent(Event e) {
sql();
}
};
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
wOK.addListener(SWT.Selection, lsOK);
wSQL.addListener(SWT.Selection, lsSQL);
wCancel.addListener(SWT.Selection, lsCancel);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wJobname.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
wTabFolder.setSelection(0);
getData();
BaseStepDialog.setSize(shell);
changed = false;
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return jobMeta;
}
use of org.pentaho.di.core.logging.LogTableInterface in project pentaho-kettle by pentaho.
the class TransMeta method getSQLStatements.
/**
* Builds a list of all the SQL statements that this transformation needs in order to work properly.
*
* @param monitor
* a progress monitor listener to be updated as the SQL statements are generated
* @return An ArrayList of SQLStatement objects.
* @throws KettleStepException
* if any errors occur during SQL statement generation
*/
public List<SQLStatement> getSQLStatements(ProgressMonitorListener monitor) throws KettleStepException {
if (monitor != null) {
monitor.beginTask(BaseMessages.getString(PKG, "TransMeta.Monitor.GettingTheSQLForTransformationTask.Title"), nrSteps() + 1);
}
List<SQLStatement> stats = new ArrayList<>();
for (int i = 0; i < nrSteps(); i++) {
StepMeta stepMeta = getStep(i);
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.GettingTheSQLForStepTask.Title", "" + stepMeta));
}
RowMetaInterface prev = getPrevStepFields(stepMeta);
SQLStatement sqlCompat = compatibleStepMetaGetSQLStatements(stepMeta.getStepMetaInterface(), stepMeta, prev);
if (sqlCompat.getSQL() != null || sqlCompat.hasError()) {
stats.add(sqlCompat);
}
SQLStatement sql = stepMeta.getStepMetaInterface().getSQLStatements(this, stepMeta, prev, repository, metaStore);
if (sql.getSQL() != null || sql.hasError()) {
stats.add(sql);
}
if (monitor != null) {
monitor.worked(1);
}
}
//
if (monitor != null) {
monitor.subTask(BaseMessages.getString(PKG, "TransMeta.Monitor.GettingTheSQLForTransformationTask.Title2"));
}
if (transLogTable.getDatabaseMeta() != null && (!Utils.isEmpty(transLogTable.getTableName()) || !Utils.isEmpty(performanceLogTable.getTableName()))) {
try {
for (LogTableInterface logTable : new LogTableInterface[] { transLogTable, performanceLogTable, channelLogTable, stepLogTable }) {
if (logTable.getDatabaseMeta() != null && !Utils.isEmpty(logTable.getTableName())) {
Database db = null;
try {
db = new Database(this, transLogTable.getDatabaseMeta());
db.shareVariablesWith(this);
db.connect();
RowMetaInterface fields = logTable.getLogRecord(LogStatus.START, null, null).getRowMeta();
String schemaTable = logTable.getDatabaseMeta().getQuotedSchemaTableCombination(logTable.getSchemaName(), logTable.getTableName());
String sql = db.getDDL(schemaTable, fields);
if (!Utils.isEmpty(sql)) {
SQLStatement stat = new SQLStatement("<this transformation>", transLogTable.getDatabaseMeta(), sql);
stats.add(stat);
}
} catch (Exception e) {
throw new KettleDatabaseException("Unable to connect to logging database [" + logTable.getDatabaseMeta() + "]", e);
} finally {
if (db != null) {
db.disconnect();
}
}
}
}
} catch (KettleDatabaseException dbe) {
SQLStatement stat = new SQLStatement("<this transformation>", transLogTable.getDatabaseMeta(), null);
stat.setError(BaseMessages.getString(PKG, "TransMeta.SQLStatement.ErrorDesc.ErrorObtainingTransformationLogTableInfo") + dbe.getMessage());
stats.add(stat);
}
}
if (monitor != null) {
monitor.worked(1);
}
if (monitor != null) {
monitor.done();
}
return stats;
}
Aggregations