use of org.pentaho.di.core.logging.LogTableField in project pentaho-kettle by pentaho.
the class TransDialog method showChannelLogTableOptions.
private void showChannelLogTableOptions() {
previousLogTableIndex = LOG_INDEX_CHANNEL;
addDBSchemaTableLogOptions(channelLogTable);
// The log timeout in days
//
Label wlLogTimeout = new Label(wLogOptionsComposite, SWT.RIGHT);
wlLogTimeout.setText(BaseMessages.getString(PKG, "TransDialog.LogTimeout.Label"));
wlLogTimeout.setToolTipText(BaseMessages.getString(PKG, "TransDialog.LogTimeout.Tooltip"));
props.setLook(wlLogTimeout);
FormData fdlLogTimeout = new FormData();
fdlLogTimeout.left = new FormAttachment(0, 0);
fdlLogTimeout.right = new FormAttachment(middle, -margin);
fdlLogTimeout.top = new FormAttachment(wLogTable, margin);
wlLogTimeout.setLayoutData(fdlLogTimeout);
wLogTimeout = new TextVar(transMeta, wLogOptionsComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wLogTimeout.setToolTipText(BaseMessages.getString(PKG, "TransDialog.LogTimeout.Tooltip"));
props.setLook(wLogTimeout);
wLogTimeout.addModifyListener(lsMod);
FormData fdLogTimeout = new FormData();
fdLogTimeout.left = new FormAttachment(middle, 0);
fdLogTimeout.top = new FormAttachment(wLogTable, margin);
fdLogTimeout.right = new FormAttachment(100, 0);
wLogTimeout.setLayoutData(fdLogTimeout);
wLogTimeout.setText(Const.NVL(channelLogTable.getTimeoutInDays(), ""));
// Add the fields grid...
//
Label wlFields = new Label(wLogOptionsComposite, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "TransDialog.TransLogTable.Fields.Label"));
props.setLook(wlFields);
FormData fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wLogTimeout, margin * 2);
wlFields.setLayoutData(fdlFields);
final java.util.List<LogTableField> fields = channelLogTable.getFields();
final int nrRows = fields.size();
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "TransDialog.TransLogTable.Fields.FieldName"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "TransDialog.TransLogTable.Fields.Description"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
FieldDisabledListener disabledListener = new FieldDisabledListener() {
public boolean isFieldDisabled(int rowNr) {
if (rowNr >= 0 && rowNr < fields.size()) {
LogTableField field = fields.get(rowNr);
return field.isSubjectAllowed();
} else {
return true;
}
}
};
colinf[1].setDisabledListener(disabledListener);
wOptionFields = new TableView(transMeta, wLogOptionsComposite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.CHECK, colinf, nrRows, true, lsMod, props);
wOptionFields.setSortable(false);
for (int i = 0; i < fields.size(); i++) {
LogTableField field = fields.get(i);
TableItem item = wOptionFields.table.getItem(i);
item.setChecked(field.isEnabled());
item.setText(new String[] { "", Const.NVL(field.getFieldName(), ""), Const.NVL(field.getDescription(), "") });
}
wOptionFields.table.getColumn(0).setText(BaseMessages.getString(PKG, "TransDialog.TransLogTable.Fields.Enabled"));
FormData fdOptionFields = new FormData();
fdOptionFields.left = new FormAttachment(0, 0);
fdOptionFields.top = new FormAttachment(wlFields, margin);
fdOptionFields.right = new FormAttachment(100, 0);
fdOptionFields.bottom = new FormAttachment(100, 0);
wOptionFields.setLayoutData(fdOptionFields);
wOptionFields.optWidth(true);
wOptionFields.layout();
wLogOptionsComposite.layout(true, true);
wLogComp.layout(true, true);
}
use of org.pentaho.di.core.logging.LogTableField in project pentaho-kettle by pentaho.
the class TransDialog method getStepLogTableOptions.
private void getStepLogTableOptions() {
if (previousLogTableIndex == LOG_INDEX_STEP) {
// The connection...
//
stepLogTable.setConnectionName(wLogconnection.getText());
stepLogTable.setSchemaName(wLogSchema.getText());
stepLogTable.setTableName(wLogTable.getText());
stepLogTable.setTimeoutInDays(wLogTimeout.getText());
for (int i = 0; i < stepLogTable.getFields().size(); i++) {
TableItem item = wOptionFields.table.getItem(i);
LogTableField field = stepLogTable.getFields().get(i);
field.setEnabled(item.getChecked());
field.setFieldName(item.getText(1));
}
}
}
use of org.pentaho.di.core.logging.LogTableField in project pentaho-kettle by pentaho.
the class Mapping method prepareMappingExecution.
public void prepareMappingExecution() throws KettleException {
initTransFromMeta();
MappingData mappingData = getData();
//
try {
mappingData.getMappingTrans().prepareExecution(getTrans().getArguments());
} catch (KettleException e) {
throw new KettleException(BaseMessages.getString(PKG, "Mapping.Exception.UnableToPrepareExecutionOfMapping"), e);
}
//
switch(mappingData.mappingTransMeta.getTransformationType()) {
case Normal:
case SerialSingleThreaded:
break;
case SingleThreaded:
mappingData.singleThreadedTransExcecutor = new SingleThreadedTransExecutor(mappingData.getMappingTrans());
if (!mappingData.singleThreadedTransExcecutor.init()) {
throw new KettleException(BaseMessages.getString(PKG, "Mapping.Exception.UnableToInitSingleThreadedTransformation"));
}
break;
default:
break;
}
// If there is no read/write logging step set, we can insert the data from
// the first mapping input/output step...
//
MappingInput[] mappingInputs = mappingData.getMappingTrans().findMappingInput();
LogTableField readField = mappingData.mappingTransMeta.getTransLogTable().findField(TransLogTable.ID.LINES_READ);
if (readField.getSubject() == null && mappingInputs != null && mappingInputs.length >= 1) {
readField.setSubject(mappingInputs[0].getStepMeta());
}
MappingOutput[] mappingOutputs = mappingData.getMappingTrans().findMappingOutput();
LogTableField writeField = mappingData.mappingTransMeta.getTransLogTable().findField(TransLogTable.ID.LINES_WRITTEN);
if (writeField.getSubject() == null && mappingOutputs != null && mappingOutputs.length >= 1) {
writeField.setSubject(mappingOutputs[0].getStepMeta());
}
// Before we add rowsets and all, we should note that the mapping step did
// not receive ANY input and output rowsets.
// This is an exception to the general rule, built into
// Trans.prepareExecution()
//
// A Mapping Input step is supposed to read directly from the previous
// steps.
// A Mapping Output step is supposed to write directly to the next steps.
// OK, check the input mapping definitions and look up the steps to read
// from.
//
StepInterface[] sourceSteps;
for (MappingIODefinition inputDefinition : meta.getInputMappings()) {
//
if (!Utils.isEmpty(inputDefinition.getInputStepname())) {
StepInterface sourceStep = getTrans().findRunThread(inputDefinition.getInputStepname());
if (sourceStep == null) {
throw new KettleException(BaseMessages.getString(PKG, "MappingDialog.Exception.StepNameNotFound", inputDefinition.getInputStepname()));
}
sourceSteps = new StepInterface[] { sourceStep };
} else {
// We have no defined source step.
// That means that we're reading from all input steps that this mapping
// step has.
//
List<StepMeta> prevSteps = getTransMeta().findPreviousSteps(getStepMeta());
// TODO: Handle remote steps from: getStepMeta().getRemoteInputSteps()
//
// Let's read data from all the previous steps we find...
// The origin is the previous step
// The target is the Mapping Input step.
//
sourceSteps = new StepInterface[prevSteps.size()];
for (int s = 0; s < sourceSteps.length; s++) {
sourceSteps[s] = getTrans().findRunThread(prevSteps.get(s).getName());
}
}
// What step are we writing to?
MappingInput mappingInputTarget = null;
MappingInput[] mappingInputSteps = mappingData.getMappingTrans().findMappingInput();
if (Utils.isEmpty(inputDefinition.getOutputStepname())) {
if (mappingInputSteps.length == 0) {
throw new KettleException(BaseMessages.getString(PKG, "MappingDialog.Exception.OneMappingInputStepRequired"));
}
if (mappingInputSteps.length > 1) {
throw new KettleException(BaseMessages.getString(PKG, "MappingDialog.Exception.OnlyOneMappingInputStepAllowed", "" + mappingInputSteps.length));
}
mappingInputTarget = mappingInputSteps[0];
} else {
// A target step was specified. See if we can find it...
for (int s = 0; s < mappingInputSteps.length && mappingInputTarget == null; s++) {
if (mappingInputSteps[s].getStepname().equals(inputDefinition.getOutputStepname())) {
mappingInputTarget = mappingInputSteps[s];
}
}
// If we still didn't find it it's a drag.
if (mappingInputTarget == null) {
throw new KettleException(BaseMessages.getString(PKG, "MappingDialog.Exception.StepNameNotFound", inputDefinition.getOutputStepname()));
}
}
//
if (inputDefinition.isRenamingOnOutput()) {
addInputRenames(getData().inputRenameList, inputDefinition.getValueRenames());
}
mappingInputTarget.setConnectorSteps(sourceSteps, inputDefinition.getValueRenames(), getStepname());
}
//
for (MappingIODefinition outputDefinition : meta.getOutputMappings()) {
// OK, what is the source (input) step in the mapping: it's the mapping
// output step...
// What step are we reading from here?
//
MappingOutput mappingOutputSource = (MappingOutput) mappingData.getMappingTrans().findRunThread(outputDefinition.getInputStepname());
if (mappingOutputSource == null) {
// No source step was specified: we're reading from a single Mapping
// Output step.
// We should verify this if this is really the case...
//
MappingOutput[] mappingOutputSteps = mappingData.getMappingTrans().findMappingOutput();
if (mappingOutputSteps.length == 0) {
throw new KettleException(BaseMessages.getString(PKG, "MappingDialog.Exception.OneMappingOutputStepRequired"));
}
if (mappingOutputSteps.length > 1) {
throw new KettleException(BaseMessages.getString(PKG, "MappingDialog.Exception.OnlyOneMappingOutputStepAllowed", "" + mappingOutputSteps.length));
}
mappingOutputSource = mappingOutputSteps[0];
}
// To what steps in this transformation are we writing to?
//
StepInterface[] targetSteps = pickupTargetStepsFor(outputDefinition);
// Now tell the mapping output step where to look...
// Also explain the mapping output steps how to rename the values back...
//
mappingOutputSource.setConnectorSteps(targetSteps, getData().inputRenameList, outputDefinition.getValueRenames());
// Is this mapping copying or distributing?
// Make sure the mapping output step mimics this behavior:
//
mappingOutputSource.setDistributed(isDistributed());
}
// Finally, add the mapping transformation to the active sub-transformations
// map in the parent transformation
//
getTrans().addActiveSubTransformation(getStepname(), getData().getMappingTrans());
}
use of org.pentaho.di.core.logging.LogTableField in project pentaho-kettle by pentaho.
the class Database method cleanupLogRecords.
public void cleanupLogRecords(LogTableCoreInterface logTable) throws KettleDatabaseException {
double timeout = Const.toDouble(Const.trim(environmentSubstitute(logTable.getTimeoutInDays())), 0.0);
if (timeout < 0.000001) {
// bother
return;
}
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(environmentSubstitute(logTable.getActualSchemaName()), environmentSubstitute(logTable.getActualTableName()));
if (schemaTable.isEmpty()) {
// we can't process without table name
DatabaseLogExceptionFactory.getExceptionStrategy(logTable).registerException(log, PKG, "DatabaseMeta.Error.LogTableNameNotFound");
}
LogTableField logField = logTable.getLogDateField();
if (logField == null) {
// can't stand without logField
DatabaseLogExceptionFactory.getExceptionStrategy(logTable).registerException(log, PKG, "Database.Exception.LogTimeoutDefinedOnTableWithoutLogField");
}
String sql = "DELETE FROM " + schemaTable + " WHERE " + databaseMeta.quoteField(logField.getFieldName()) + " < ?";
long now = System.currentTimeMillis();
long limit = now - Math.round(timeout * 24 * 60 * 60 * 1000);
RowMetaAndData row = new RowMetaAndData();
row.addValue(logField.getFieldName(), ValueMetaInterface.TYPE_DATE, new Date(limit));
try {
// fire database
execStatement(sql, row.getRowMeta(), row.getData());
} catch (Exception e) {
DatabaseLogExceptionFactory.getExceptionStrategy(logTable).registerException(log, PKG, "Database.Exception.UnableToCleanUpOlderRecordsFromLogTable", environmentSubstitute(logTable.getActualTableName()));
}
}
use of org.pentaho.di.core.logging.LogTableField in project pentaho-kettle by pentaho.
the class JobDialog method showJobLogTableOptions.
private void showJobLogTableOptions(JobLogTable jobLogTable) {
addDBSchemaTableLogOptions(jobLogTable);
// Log interval...
//
Label wlLogInterval = new Label(wLogOptionsComposite, SWT.RIGHT);
wlLogInterval.setText(BaseMessages.getString(PKG, "JobDialog.LogInterval.Label"));
props.setLook(wlLogInterval);
FormData fdlLogInterval = new FormData();
fdlLogInterval.left = new FormAttachment(0, 0);
fdlLogInterval.right = new FormAttachment(middle, -margin);
fdlLogInterval.top = new FormAttachment(wLogTable, margin);
wlLogInterval.setLayoutData(fdlLogInterval);
wLogInterval = new TextVar(jobMeta, wLogOptionsComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wLogInterval);
wLogInterval.addModifyListener(lsMod);
FormData fdLogInterval = new FormData();
fdLogInterval.left = new FormAttachment(middle, 0);
fdLogInterval.top = new FormAttachment(wLogTable, margin);
fdLogInterval.right = new FormAttachment(100, 0);
wLogInterval.setLayoutData(fdLogInterval);
wLogInterval.setText(Const.NVL(jobLogTable.getLogInterval(), ""));
// The log timeout in days
//
Label wlLogTimeout = new Label(wLogOptionsComposite, SWT.RIGHT);
wlLogTimeout.setText(BaseMessages.getString(PKG, "JobDialog.LogTimeout.Label"));
wlLogTimeout.setToolTipText(BaseMessages.getString(PKG, "JobDialog.LogTimeout.Tooltip"));
props.setLook(wlLogTimeout);
FormData fdlLogTimeout = new FormData();
fdlLogTimeout.left = new FormAttachment(0, 0);
fdlLogTimeout.right = new FormAttachment(middle, -margin);
fdlLogTimeout.top = new FormAttachment(wLogInterval, margin);
wlLogTimeout.setLayoutData(fdlLogTimeout);
wLogTimeout = new TextVar(jobMeta, wLogOptionsComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wLogTimeout.setToolTipText(BaseMessages.getString(PKG, "JobDialog.LogTimeout.Tooltip"));
props.setLook(wLogTimeout);
wLogTimeout.addModifyListener(lsMod);
FormData fdLogTimeout = new FormData();
fdLogTimeout.left = new FormAttachment(middle, 0);
fdLogTimeout.top = new FormAttachment(wLogInterval, margin);
fdLogTimeout.right = new FormAttachment(100, 0);
wLogTimeout.setLayoutData(fdLogTimeout);
wLogTimeout.setText(Const.NVL(jobLogTable.getTimeoutInDays(), ""));
// The log size limit
//
Label wlLogSizeLimit = new Label(wLogOptionsComposite, SWT.RIGHT);
wlLogSizeLimit.setText(BaseMessages.getString(PKG, "JobDialog.LogSizeLimit.Label"));
wlLogSizeLimit.setToolTipText(BaseMessages.getString(PKG, "JobDialog.LogSizeLimit.Tooltip"));
props.setLook(wlLogSizeLimit);
FormData fdlLogSizeLimit = new FormData();
fdlLogSizeLimit.left = new FormAttachment(0, 0);
fdlLogSizeLimit.right = new FormAttachment(middle, -margin);
fdlLogSizeLimit.top = new FormAttachment(wLogTimeout, margin);
wlLogSizeLimit.setLayoutData(fdlLogSizeLimit);
wLogSizeLimit = new TextVar(jobMeta, wLogOptionsComposite, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wLogSizeLimit.setToolTipText(BaseMessages.getString(PKG, "JobDialog.LogSizeLimit.Tooltip"));
props.setLook(wLogSizeLimit);
wLogSizeLimit.addModifyListener(lsMod);
FormData fdLogSizeLimit = new FormData();
fdLogSizeLimit.left = new FormAttachment(middle, 0);
fdLogSizeLimit.top = new FormAttachment(wLogTimeout, margin);
fdLogSizeLimit.right = new FormAttachment(100, 0);
wLogSizeLimit.setLayoutData(fdLogSizeLimit);
wLogSizeLimit.setText(Const.NVL(jobLogTable.getLogSizeLimit(), ""));
// Add the fields grid...
//
Label wlFields = new Label(wLogOptionsComposite, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "JobDialog.TransLogTable.Fields.Label"));
props.setLook(wlFields);
FormData fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wLogSizeLimit, margin * 2);
wlFields.setLayoutData(fdlFields);
final java.util.List<LogTableField> fields = jobLogTable.getFields();
final int nrRows = fields.size();
ColumnInfo[] colinf = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "JobDialog.TransLogTable.Fields.FieldName"), ColumnInfo.COLUMN_TYPE_TEXT, false), new ColumnInfo(BaseMessages.getString(PKG, "JobDialog.TransLogTable.Fields.Description"), ColumnInfo.COLUMN_TYPE_TEXT, false, true) };
wOptionFields = new // add a
TableView(// add a
jobMeta, // add a
wLogOptionsComposite, // add a
SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.CHECK, // left...
colinf, nrRows, true, lsMod, props);
wOptionFields.setSortable(false);
for (int i = 0; i < fields.size(); i++) {
LogTableField field = fields.get(i);
TableItem item = wOptionFields.table.getItem(i);
item.setChecked(field.isEnabled());
item.setText(new String[] { "", Const.NVL(field.getFieldName(), ""), Const.NVL(field.getDescription(), "") });
}
wOptionFields.table.getColumn(0).setText(BaseMessages.getString(PKG, "JobDialog.TransLogTable.Fields.Enabled"));
FormData fdOptionFields = new FormData();
fdOptionFields.left = new FormAttachment(0, 0);
fdOptionFields.top = new FormAttachment(wlFields, margin);
fdOptionFields.right = new FormAttachment(100, 0);
fdOptionFields.bottom = new FormAttachment(100, 0);
wOptionFields.setLayoutData(fdOptionFields);
wOptionFields.optWidth(true);
wOptionFields.layout();
}
Aggregations