use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class ElasticSearchBulk method processRow.
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
Object[] rowData = getRow();
if (rowData == null) {
if (currentRequest != null && currentRequest.numberOfActions() > 0) {
// didn't fill a whole batch
processBatch(false);
}
setOutputDone();
return false;
}
if (first) {
first = false;
setupData();
currentRequest = client.prepareBulk();
requestsBuffer = new ArrayList<IndexRequestBuilder>(this.batchSize);
initFieldIndexes();
}
try {
data.inputRowBuffer[data.nextBufferRowIdx++] = rowData;
return indexRow(data.inputRowMeta, rowData) || !stopOnError;
} catch (KettleStepException e) {
throw e;
} catch (Exception e) {
rejectAllRows(e.getLocalizedMessage());
String msg = BaseMessages.getString(PKG, "ElasticSearchBulk.Log.Exception", e.getLocalizedMessage());
logError(msg);
throw new KettleStepException(msg, e);
}
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class AnalyticQueryMeta method getFields.
public void getFields(RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
// re-assemble a new row of metadata
//
RowMetaInterface fields = new RowMeta();
// Add existing values
fields.addRowMeta(r);
// add analytic values
for (int i = 0; i < number_of_fields; i++) {
int index_of_subject = -1;
index_of_subject = r.indexOfValue(subjectField[i]);
// if we found the subjectField in the RowMetaInterface, and we should....
if (index_of_subject > -1) {
ValueMetaInterface vmi = r.getValueMeta(index_of_subject).clone();
vmi.setOrigin(origin);
vmi.setName(aggregateField[i]);
fields.addValueMeta(r.size() + i, vmi);
} else {
// we have a condition where the subjectField can't be found from the rowMetaInterface
StringBuilder sbfieldNames = new StringBuilder();
String[] fieldNames = r.getFieldNames();
for (int j = 0; j < fieldNames.length; j++) {
sbfieldNames.append("[" + fieldNames[j] + "]" + (j < fieldNames.length - 1 ? ", " : ""));
}
throw new KettleStepException(BaseMessages.getString(PKG, "AnalyticQueryMeta.Exception.SubjectFieldNotFound", getParentStepMeta().getName(), subjectField[i], sbfieldNames.toString()));
}
}
r.clear();
// Add back to Row Meta
r.addRowMeta(fields);
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class CombinationLookup method processRow.
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
// Get row from input rowset & set row busy!
Object[] r = getRow();
// if no more input to be expected set done
if (r == null) {
setOutputDone();
return false;
}
if (first) {
first = false;
data.outputRowMeta = getInputRowMeta().clone();
meta.getFields(data.outputRowMeta, getStepname(), null, null, this, repository, metaStore);
data.schemaTable = meta.getDatabaseMeta().getQuotedSchemaTableCombination(data.realSchemaName, data.realTableName);
determineTechKeyCreation();
// The indexes of the key values...
//
data.keynrs = new int[meta.getKeyField().length];
for (int i = 0; i < meta.getKeyField().length; i++) {
data.keynrs[i] = getInputRowMeta().indexOfValue(meta.getKeyField()[i]);
if (data.keynrs[i] < 0) {
// couldn't find field!
throw new KettleStepException(BaseMessages.getString(PKG, "CombinationLookup.Exception.FieldNotFound", meta.getKeyField()[i]));
}
}
// Determine for each input field if we want it removed or not.
//
data.removeField = new boolean[getInputRowMeta().size()];
//
for (int i = 0; i < getInputRowMeta().size(); i++) {
ValueMetaInterface valueMeta = getInputRowMeta().getValueMeta(i);
// Is this one of the keys?
int idx = Const.indexOfString(valueMeta.getName(), meta.getKeyField());
data.removeField[i] = idx >= 0;
}
// Determine the metadata row to calculate hashcodes.
//
data.hashRowMeta = new RowMeta();
for (int i = 0; i < meta.getKeyField().length; i++) {
// KEYi = ?
data.hashRowMeta.addValueMeta(getInputRowMeta().getValueMeta(data.keynrs[i]));
}
setCombiLookup(getInputRowMeta());
preloadCache(data.hashRowMeta);
}
try {
// add new values to the row in rowset[0].
Object[] outputRow = lookupValues(getInputRowMeta(), r);
// copy row to output rowset(s);
putRow(data.outputRowMeta, outputRow);
if (checkFeedback(getLinesRead())) {
if (log.isBasic()) {
logBasic(BaseMessages.getString(PKG, "CombinationLookup.Log.LineNumber") + getLinesRead());
}
}
} catch (KettleException e) {
if (getStepMeta().isDoingErrorHandling()) {
putError(getInputRowMeta(), r, 1L, Const.getStackTracker(e), null, "CBL001");
} else {
logError(BaseMessages.getString(PKG, "CombinationLookup.Log.ErrorInStepRunning") + e.getMessage());
setErrors(1);
stopAll();
// signal end to receiver(s)
setOutputDone();
return false;
}
}
return true;
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class AutoDocDialog method open.
public String open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MIN | SWT.MAX);
props.setLook(shell);
setShellImage(shell, inputMeta);
ModifyListener lsMod = new ModifyListener() {
public void modifyText(ModifyEvent e) {
inputMeta.setChanged();
}
};
changed = inputMeta.hasChanged();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = Const.FORM_MARGIN;
formLayout.marginHeight = Const.FORM_MARGIN;
shell.setLayout(formLayout);
shell.setText(BaseMessages.getString(PKG, "AutoDoc.Step.Name"));
int middle = props.getMiddlePct();
int margin = Const.MARGIN;
// Step name line
//
wlStepname = new Label(shell, SWT.RIGHT);
wlStepname.setText(BaseMessages.getString(PKG, "AutoDocDialog.Stepname.Label"));
props.setLook(wlStepname);
fdlStepname = new FormData();
fdlStepname.left = new FormAttachment(0, 0);
fdlStepname.right = new FormAttachment(middle, -margin);
fdlStepname.top = new FormAttachment(0, margin);
wlStepname.setLayoutData(fdlStepname);
wStepname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wStepname);
wStepname.addModifyListener(lsMod);
fdStepname = new FormData();
fdStepname.left = new FormAttachment(middle, 0);
fdStepname.top = new FormAttachment(0, margin);
fdStepname.right = new FormAttachment(100, 0);
wStepname.setLayoutData(fdStepname);
Control lastControl = wStepname;
RowMetaInterface previousFields;
try {
previousFields = transMeta.getPrevStepFields(stepMeta);
} catch (KettleStepException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "AutoDocDialog.ErrorDialog.UnableToGetInputFields.Title"), BaseMessages.getString(PKG, "AutoDocDialog.ErrorDialog.UnableToGetInputFields.Message"), e);
previousFields = new RowMeta();
}
// The filename field ...
//
wFilenameField = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.FilenameField.Label"), BaseMessages.getString(PKG, "AutoDocDialog.FilenameField.Tooltip"));
wFilenameField.setItems(previousFields.getFieldNames());
props.setLook(wFilenameField);
wFilenameField.addModifyListener(lsMod);
FormData fdFilenameField = new FormData();
fdFilenameField.top = new FormAttachment(lastControl, margin);
fdFilenameField.left = new FormAttachment(0, 0);
fdFilenameField.right = new FormAttachment(100, 0);
wFilenameField.setLayoutData(fdFilenameField);
lastControl = wFilenameField;
// The FileType field ...
//
wFileTypeField = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.FileTypeField.Label"), BaseMessages.getString(PKG, "AutoDocDialog.FileTypeField.Tooltip"));
wFileTypeField.setItems(previousFields.getFieldNames());
props.setLook(wFileTypeField);
wFileTypeField.addModifyListener(lsMod);
FormData fdFileTypeField = new FormData();
fdFileTypeField.top = new FormAttachment(lastControl, margin);
fdFileTypeField.left = new FormAttachment(0, 0);
fdFileTypeField.right = new FormAttachment(100, 0);
wFileTypeField.setLayoutData(fdFileTypeField);
lastControl = wFileTypeField;
// The target filename ...
//
wTargetFilename = new LabelTextVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.TargetFilename.Label"), BaseMessages.getString(PKG, "AutoDocDialog.TargetFilename.Tooltip"));
props.setLook(wTargetFilename);
wTargetFilename.addModifyListener(lsMod);
FormData fdTargetFilename = new FormData();
fdTargetFilename.top = new FormAttachment(lastControl, margin);
fdTargetFilename.left = new FormAttachment(0, 0);
fdTargetFilename.right = new FormAttachment(100, 0);
wTargetFilename.setLayoutData(fdTargetFilename);
lastControl = wTargetFilename;
// The output type ...
//
wOutputType = new LabelComboVar(transMeta, shell, BaseMessages.getString(PKG, "AutoDocDialog.OutputType.Label"), BaseMessages.getString(PKG, "AutoDocDialog.OutputType.Tooltip"));
OutputType[] outputTypes = KettleReportBuilder.OutputType.values();
String[] items = new String[outputTypes.length];
for (int i = 0; i < outputTypes.length; i++) {
items[i] = outputTypes[i].name();
}
wOutputType.setItems(items);
props.setLook(wOutputType);
wOutputType.addModifyListener(lsMod);
wOutputType.getComboWidget().setEditable(false);
FormData fdOutputType = new FormData();
fdOutputType.top = new FormAttachment(lastControl, margin);
fdOutputType.left = new FormAttachment(0, 0);
fdOutputType.right = new FormAttachment(100, 0);
wOutputType.setLayoutData(fdOutputType);
wOutputType.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
setFlags();
}
});
lastControl = wOutputType;
// Include name check-box
//
Label wlInclName = new Label(shell, SWT.RIGHT);
wlInclName.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclName.Label"));
props.setLook(wlInclName);
FormData fdlInclName = new FormData();
fdlInclName.left = new FormAttachment(0, 0);
fdlInclName.right = new FormAttachment(middle, -margin);
fdlInclName.top = new FormAttachment(lastControl, margin);
wlInclName.setLayoutData(fdlInclName);
wInclName = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclName);
FormData fdInclName = new FormData();
fdInclName.left = new FormAttachment(middle, 0);
fdInclName.right = new FormAttachment(100, 0);
fdInclName.top = new FormAttachment(lastControl, margin);
wInclName.setLayoutData(fdInclName);
lastControl = wInclName;
// Include description check-box
//
Label wlInclDesc = new Label(shell, SWT.RIGHT);
wlInclDesc.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclDesc.Label"));
props.setLook(wlInclDesc);
FormData fdlInclDesc = new FormData();
fdlInclDesc.left = new FormAttachment(0, 0);
fdlInclDesc.right = new FormAttachment(middle, -margin);
fdlInclDesc.top = new FormAttachment(lastControl, margin);
wlInclDesc.setLayoutData(fdlInclDesc);
wInclDesc = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclDesc);
FormData fdInclDesc = new FormData();
fdInclDesc.left = new FormAttachment(middle, 0);
fdInclDesc.right = new FormAttachment(100, 0);
fdInclDesc.top = new FormAttachment(lastControl, margin);
wInclDesc.setLayoutData(fdInclDesc);
lastControl = wInclDesc;
// Include extended description check-box
//
Label wlInclExtDesc = new Label(shell, SWT.RIGHT);
wlInclExtDesc.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclExtDesc.Label"));
props.setLook(wlInclExtDesc);
FormData fdlInclExtDesc = new FormData();
fdlInclExtDesc.left = new FormAttachment(0, 0);
fdlInclExtDesc.right = new FormAttachment(middle, -margin);
fdlInclExtDesc.top = new FormAttachment(lastControl, margin);
wlInclExtDesc.setLayoutData(fdlInclExtDesc);
wInclExtDesc = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclExtDesc);
FormData fdInclExtDesc = new FormData();
fdInclExtDesc.left = new FormAttachment(middle, 0);
fdInclExtDesc.right = new FormAttachment(100, 0);
fdInclExtDesc.top = new FormAttachment(lastControl, margin);
wInclExtDesc.setLayoutData(fdInclExtDesc);
lastControl = wInclExtDesc;
// Include creation information (user/date) check-box
//
Label wlInclCreated = new Label(shell, SWT.RIGHT);
wlInclCreated.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclCreated.Label"));
props.setLook(wlInclCreated);
FormData fdlInclCreated = new FormData();
fdlInclCreated.left = new FormAttachment(0, 0);
fdlInclCreated.right = new FormAttachment(middle, -margin);
fdlInclCreated.top = new FormAttachment(lastControl, margin);
wlInclCreated.setLayoutData(fdlInclCreated);
wInclCreated = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclCreated);
FormData fdInclCreated = new FormData();
fdInclCreated.left = new FormAttachment(middle, 0);
fdInclCreated.right = new FormAttachment(100, 0);
fdInclCreated.top = new FormAttachment(lastControl, margin);
wInclCreated.setLayoutData(fdInclCreated);
lastControl = wInclCreated;
// Include modified information (user/date) check-box
//
Label wlInclModified = new Label(shell, SWT.RIGHT);
wlInclModified.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclModified.Label"));
props.setLook(wlInclModified);
FormData fdlInclModified = new FormData();
fdlInclModified.left = new FormAttachment(0, 0);
fdlInclModified.right = new FormAttachment(middle, -margin);
fdlInclModified.top = new FormAttachment(lastControl, margin);
wlInclModified.setLayoutData(fdlInclModified);
wInclModified = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclModified);
FormData fdInclModified = new FormData();
fdInclModified.left = new FormAttachment(middle, 0);
fdInclModified.right = new FormAttachment(100, 0);
fdInclModified.top = new FormAttachment(lastControl, margin);
wInclModified.setLayoutData(fdInclModified);
lastControl = wInclModified;
// Include image check-box
//
Label wlInclImage = new Label(shell, SWT.RIGHT);
wlInclImage.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclImage.Label"));
props.setLook(wlInclImage);
FormData fdlInclImage = new FormData();
fdlInclImage.left = new FormAttachment(0, 0);
fdlInclImage.right = new FormAttachment(middle, -margin);
fdlInclImage.top = new FormAttachment(lastControl, margin);
wlInclImage.setLayoutData(fdlInclImage);
wInclImage = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclImage);
FormData fdInclImage = new FormData();
fdInclImage.left = new FormAttachment(middle, 0);
fdInclImage.right = new FormAttachment(100, 0);
fdInclImage.top = new FormAttachment(lastControl, margin);
wInclImage.setLayoutData(fdInclImage);
lastControl = wInclImage;
// Include logging check-box
//
Label wlInclLogging = new Label(shell, SWT.RIGHT);
wlInclLogging.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclLogging.Label"));
props.setLook(wlInclLogging);
FormData fdlInclLogging = new FormData();
fdlInclLogging.left = new FormAttachment(0, 0);
fdlInclLogging.right = new FormAttachment(middle, -margin);
fdlInclLogging.top = new FormAttachment(lastControl, margin);
wlInclLogging.setLayoutData(fdlInclLogging);
wInclLogging = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclLogging);
FormData fdInclLogging = new FormData();
fdInclLogging.left = new FormAttachment(middle, 0);
fdInclLogging.right = new FormAttachment(100, 0);
fdInclLogging.top = new FormAttachment(lastControl, margin);
wInclLogging.setLayoutData(fdInclLogging);
lastControl = wInclLogging;
// Include last execution date check-box
//
Label wlInclLastExecResult = new Label(shell, SWT.RIGHT);
wlInclLastExecResult.setText(BaseMessages.getString(PKG, "AutoDocDialog.InclLastExecResult.Label"));
props.setLook(wlInclLastExecResult);
FormData fdlInclLastExecResult = new FormData();
fdlInclLastExecResult.left = new FormAttachment(0, 0);
fdlInclLastExecResult.right = new FormAttachment(middle, -margin);
fdlInclLastExecResult.top = new FormAttachment(lastControl, margin);
wlInclLastExecResult.setLayoutData(fdlInclLastExecResult);
wInclLastExecResult = new Button(shell, SWT.CHECK | SWT.LEFT);
props.setLook(wInclLastExecResult);
FormData fdInclLastExecResult = new FormData();
fdInclLastExecResult.left = new FormAttachment(middle, 0);
fdInclLastExecResult.right = new FormAttachment(100, 0);
fdInclLastExecResult.top = new FormAttachment(lastControl, margin);
wInclLastExecResult.setLayoutData(fdInclLastExecResult);
lastControl = wInclLastExecResult;
// Some buttons first, so that the dialog scales nicely...
//
wOK = new Button(shell, SWT.PUSH);
wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
wCancel = new Button(shell, SWT.PUSH);
wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
setButtonPositions(new Button[] { wOK, wCancel }, margin, lastControl);
// Add listeners
lsCancel = new Listener() {
public void handleEvent(Event e) {
cancel();
}
};
lsOK = new Listener() {
public void handleEvent(Event e) {
ok();
}
};
wCancel.addListener(SWT.Selection, lsCancel);
wOK.addListener(SWT.Selection, lsOK);
lsDef = new SelectionAdapter() {
public void widgetDefaultSelected(SelectionEvent e) {
ok();
}
};
wStepname.addSelectionListener(lsDef);
wFilenameField.addSelectionListener(lsDef);
// Detect X or ALT-F4 or something that kills this window...
shell.addShellListener(new ShellAdapter() {
public void shellClosed(ShellEvent e) {
cancel();
}
});
// Set the shell size, based upon previous time...
setSize();
getData();
inputMeta.setChanged(changed);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
return stepname;
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class OlapInputMeta method getFields.
@Override
public void getFields(RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
RowMetaInterface add = null;
try {
initData(space);
add = data.outputRowMeta;
} catch (Exception dbe) {
throw new KettleStepException("Unable to get query result for MDX query: " + Const.CR + mdx, dbe);
}
//
for (int i = 0; i < add.size(); i++) {
ValueMetaInterface v = add.getValueMeta(i);
v.setOrigin(origin);
}
row.addRowMeta(add);
}
Aggregations