use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class MQTTProducerDialog method buildSetupTab.
private void buildSetupTab() {
CTabItem wSetupTab = new CTabItem(wTabFolder, SWT.NONE);
wSetupTab.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.SetupTab"));
Composite wSetupComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wSetupComp);
FormLayout setupLayout = new FormLayout();
setupLayout.marginHeight = 15;
setupLayout.marginWidth = 15;
wSetupComp.setLayout(setupLayout);
Label wlMqttServer = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlMqttServer);
wlMqttServer.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.Connection"));
FormData fdlBootstrapServers = new FormData();
fdlBootstrapServers.left = new FormAttachment(0, 0);
fdlBootstrapServers.top = new FormAttachment(0, 0);
fdlBootstrapServers.right = new FormAttachment(0, INPUT_WIDTH);
wlMqttServer.setLayoutData(fdlBootstrapServers);
wMqttServer = new TextVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMqttServer);
wMqttServer.addModifyListener(lsMod);
FormData fdBootstrapServers = new FormData();
fdBootstrapServers.left = new FormAttachment(0, 0);
fdBootstrapServers.top = new FormAttachment(wlMqttServer, 5);
fdBootstrapServers.right = new FormAttachment(0, INPUT_WIDTH);
wMqttServer.setLayoutData(fdBootstrapServers);
Label wlClientId = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlClientId);
wlClientId.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.ClientId"));
FormData fdlClientId = new FormData();
fdlClientId.left = new FormAttachment(0, 0);
fdlClientId.top = new FormAttachment(wMqttServer, 10);
fdlClientId.right = new FormAttachment(50, 0);
wlClientId.setLayoutData(fdlClientId);
wClientId = new TextVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wClientId);
wClientId.addModifyListener(lsMod);
FormData fdClientId = new FormData();
fdClientId.left = new FormAttachment(0, 0);
fdClientId.top = new FormAttachment(wlClientId, 5);
fdClientId.right = new FormAttachment(0, INPUT_WIDTH);
wClientId.setLayoutData(fdClientId);
Label wlTopic = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlTopic);
wlTopic.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.Topic"));
FormData fdlTopic = new FormData();
fdlTopic.left = new FormAttachment(0, 0);
fdlTopic.top = new FormAttachment(wClientId, 10);
fdlTopic.width = 200;
wlTopic.setLayoutData(fdlTopic);
wTopic = new TextVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wTopic);
wTopic.addModifyListener(lsMod);
FormData fdTopic = new FormData();
fdTopic.left = new FormAttachment(0, 0);
fdTopic.top = new FormAttachment(wlTopic, 5);
fdTopic.width = 200;
wTopic.setLayoutData(fdTopic);
Label wlQOS = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlQOS);
wlQOS.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.QOS"));
FormData fdlQOS = new FormData();
fdlQOS.left = new FormAttachment(wlTopic, 15);
fdlQOS.top = new FormAttachment(wClientId, 10);
fdlQOS.width = 120;
wlQOS.setLayoutData(fdlQOS);
wQOS = new ComboVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wQOS);
wQOS.addModifyListener(lsMod);
FormData fdQOS = new FormData();
fdQOS.left = new FormAttachment(wTopic, 15);
fdQOS.top = new FormAttachment(wlQOS, 5);
fdQOS.width = 135;
wQOS.setLayoutData(fdQOS);
wQOS.add("0");
wQOS.add("1");
wQOS.add("2");
Label wlMessageField = new Label(wSetupComp, SWT.LEFT);
props.setLook(wlMessageField);
wlMessageField.setText(BaseMessages.getString(PKG, "MQTTProducerDialog.MessageField"));
FormData fdlMessageField = new FormData();
fdlMessageField.left = new FormAttachment(0, 0);
fdlMessageField.top = new FormAttachment(wTopic, 10);
fdlMessageField.right = new FormAttachment(50, 0);
wlMessageField.setLayoutData(fdlMessageField);
wMessageField = new ComboVar(transMeta, wSetupComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wMessageField);
wMessageField.addModifyListener(lsMod);
FormData fdMessageField = new FormData();
fdMessageField.left = new FormAttachment(0, 0);
fdMessageField.top = new FormAttachment(wlMessageField, 5);
fdMessageField.right = new FormAttachment(0, INPUT_WIDTH);
wMessageField.setLayoutData(fdMessageField);
Listener lsMessageFocus = e -> {
String current = wMessageField.getText();
wMessageField.getCComboWidget().removeAll();
wMessageField.setText(current);
try {
RowMetaInterface rmi = transMeta.getPrevStepFields(meta.getParentStepMeta().getName());
List ls = rmi.getValueMetaList();
for (Object l : ls) {
ValueMetaBase vmb = (ValueMetaBase) l;
wMessageField.add(vmb.getName());
}
} catch (KettleStepException ex) {
// do nothing
}
};
wMessageField.getCComboWidget().addListener(SWT.FocusIn, lsMessageFocus);
FormData fdSetupComp = new FormData();
fdSetupComp.left = new FormAttachment(0, 0);
fdSetupComp.top = new FormAttachment(0, 0);
fdSetupComp.right = new FormAttachment(100, 0);
fdSetupComp.bottom = new FormAttachment(100, 0);
wSetupComp.setLayoutData(fdSetupComp);
wSetupComp.layout();
wSetupTab.setControl(wSetupComp);
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class XMLInputSaxMeta method getFields.
public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
for (int i = 0; i < inputFields.length; i++) {
XMLInputSaxField field = inputFields[i];
int type = field.getType();
if (type == ValueMeta.TYPE_NONE) {
type = ValueMeta.TYPE_STRING;
}
try {
ValueMetaInterface v = ValueMetaFactory.createValueMeta(field.getName(), type);
v.setLength(field.getLength());
v.setPrecision(field.getPrecision());
v.setConversionMask(field.getFormat());
v.setGroupingSymbol(field.getGroupSymbol());
v.setDecimalSymbol(field.getDecimalSymbol());
v.setCurrencySymbol(field.getCurrencySymbol());
v.setOrigin(name);
row.addValueMeta(v);
} catch (Exception e) {
throw new KettleStepException(e);
}
}
if (includeFilename) {
ValueMeta v = new ValueMeta(filenameField, ValueMeta.TYPE_STRING);
v.setLength(100, -1);
v.setOrigin(name);
row.addValueMeta(v);
}
if (includeRowNumber) {
ValueMeta v = new ValueMeta(rowNumberField, ValueMeta.TYPE_NUMBER);
v.setLength(7, 0);
v.setOrigin(name);
row.addValueMeta(v);
}
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class SapInputMeta method getFields.
public void getFields(RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
// TODO: add an option to also include the input data...
row.clear();
for (SapOutputField field : outputFields) {
try {
ValueMetaInterface valueMeta = ValueMetaFactory.createValueMeta(field.getNewName(), field.getTargetType());
valueMeta.setOrigin(origin);
row.addValueMeta(valueMeta);
} catch (Exception e) {
throw new KettleStepException(e);
}
}
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class ShapeFileReader method processRow.
public synchronized boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleStepException {
meta = (ShapeFileReaderMeta) smi;
data = (ShapeFileReaderData) sdi;
boolean retval = true;
if (data.shapeNr >= data.shapeFile.getNrShapes()) {
setOutputDone();
return false;
}
if (first) {
first = false;
data.outputRowMeta = new RowMeta();
meta.getFields(data.outputRowMeta, getStepname(), null, null, this);
}
// building new row
Object[] outputRow = RowDataUtil.allocateRowData(data.outputRowMeta.size());
int outputIndex;
// getting shape # data.shapeNr from shapefile
// Get the shape from the shapefile
//
ShapeInterface si = data.shapeFile.getShape(data.shapeNr);
switch(si.getType()) {
case Shape.SHAPE_TYPE_POLYLINE_M:
{
// PolyLimeM";
ShapePolyLineM eplm = (ShapePolyLineM) si;
int partnr = 0;
for (int j = 0; j < eplm.nrpoints; j++) {
// PolyLimeM, point #"+j;
for (int k = 0; k < eplm.nrparts; k++) {
if (j == eplm.part_starts[k])
partnr++;
}
outputIndex = 0;
// adding the basics";
// Add the basics...
// The filename...
outputRow[outputIndex++] = meta.getShapeFilename();
// The file type
outputRow[outputIndex++] = data.shapeFile.getFileHeader().getShapeTypeDesc();
// The shape nr
outputRow[outputIndex++] = new Long(data.shapeNr + 1);
// The part nr
outputRow[outputIndex++] = new Long(partnr);
// The nr of parts
outputRow[outputIndex++] = new Long(eplm.nrparts);
// The point nr
outputRow[outputIndex++] = new Long(j + 1);
// The nr of points
outputRow[outputIndex++] = new Long(eplm.nrpoints);
// The X coordinate
outputRow[outputIndex++] = new Double(eplm.point[j].x);
// The Y coordinate
outputRow[outputIndex++] = new Double(eplm.point[j].y);
// The measure
outputRow[outputIndex++] = new Double(eplm.measures[j]);
// The Values in the DBF file...
// PolyLimeM, point #"+j+", add dbf data";
Object[] dbfData = si.getDbfData();
RowMetaInterface dbfMeta = si.getDbfMeta();
for (int d = 0; d < dbfMeta.size(); d++) {
outputRow[outputIndex++] = dbfData[d];
}
linesInput++;
// Put it out to the rest of the world...
putRow(data.outputRowMeta, outputRow);
}
}
break;
case Shape.SHAPE_TYPE_POLYGON:
{
// ShapePolygon";
ShapePolygon epl = (ShapePolygon) si;
int partnr = 0;
for (int j = 0; j < epl.nrpoints; j++) {
// PolyLime, point #"+j;
for (int k = 0; k < epl.nrparts; k++) {
if (j == epl.part_starts[k])
partnr++;
}
outputIndex = 0;
// adding the basics";
// Add the basics...
// The filename...
outputRow[outputIndex++] = meta.getShapeFilename();
// The file type
outputRow[outputIndex++] = data.shapeFile.getFileHeader().getShapeTypeDesc();
// The shape nr
outputRow[outputIndex++] = new Long(data.shapeNr + 1);
// The part nr
outputRow[outputIndex++] = new Long(partnr);
// The nr of parts
outputRow[outputIndex++] = new Long(epl.nrparts);
// The point nr
outputRow[outputIndex++] = new Long(j + 1);
// The nr of points
outputRow[outputIndex++] = new Long(epl.nrpoints);
// The X coordinate
outputRow[outputIndex++] = new Double(epl.point[j].x);
// The Y coordinate
outputRow[outputIndex++] = new Double(epl.point[j].y);
// The measure
outputRow[outputIndex++] = new Double(0.0);
// The Values in the DBF file...
// PolyLime, point #"+j+", add dbf data";
//
Object[] dbfData = si.getDbfData();
RowMetaInterface dbfMeta = si.getDbfMeta();
for (int d = 0; d < dbfMeta.size(); d++) {
outputRow[outputIndex++] = dbfData[d];
}
linesInput++;
// Put it out to the rest of the world...
putRow(data.outputRowMeta, outputRow);
}
}
break;
case Shape.SHAPE_TYPE_POLYLINE:
{
// PolyLime";
ShapePolyLine epl = (ShapePolyLine) si;
int partnr = 0;
for (int j = 0; j < epl.nrpoints; j++) {
// PolyLime, point #"+j;
for (int k = 0; k < epl.nrparts; k++) {
if (j == epl.part_starts[k])
partnr++;
}
outputIndex = 0;
// adding the basics";
// Add the basics...
// The filename...
outputRow[outputIndex++] = meta.getShapeFilename();
// The file type
outputRow[outputIndex++] = data.shapeFile.getFileHeader().getShapeTypeDesc();
// The shape nr
outputRow[outputIndex++] = new Long(data.shapeNr + 1);
// The part nr
outputRow[outputIndex++] = new Long(partnr);
// The nr of parts
outputRow[outputIndex++] = new Long(epl.nrparts);
// The point nr
outputRow[outputIndex++] = new Long(j + 1);
// The nr of points
outputRow[outputIndex++] = new Long(epl.nrpoints);
// The X coordinate
outputRow[outputIndex++] = new Double(epl.point[j].x);
// The Y coordinate
outputRow[outputIndex++] = new Double(epl.point[j].y);
// The measure
outputRow[outputIndex++] = new Double(0.0);
// The Values in the DBF file...
// PolyLime, point #"+j+", add dbf data";
//
Object[] dbfData = si.getDbfData();
RowMetaInterface dbfMeta = si.getDbfMeta();
for (int d = 0; d < dbfMeta.size(); d++) {
outputRow[outputIndex++] = dbfData[d];
}
linesInput++;
// Put it out to the rest of the world...
putRow(data.outputRowMeta, outputRow);
}
}
break;
case Shape.SHAPE_TYPE_POINT:
{
// Point";
ShapePoint ep = (ShapePoint) si;
// Add the basics...
outputIndex = 0;
// The filename...
outputRow[outputIndex++] = meta.getShapeFilename();
// The file type
outputRow[outputIndex++] = data.shapeFile.getFileHeader().getShapeTypeDesc();
// The shape nr
outputRow[outputIndex++] = new Long(data.shapeNr);
// The part nr
outputRow[outputIndex++] = new Long(0L);
// The nr of parts
outputRow[outputIndex++] = new Long(0L);
// The point nr
outputRow[outputIndex++] = new Long(0L);
// The nr of points
outputRow[outputIndex++] = new Long(0L);
// The X coordinate
outputRow[outputIndex++] = new Double(ep.x);
// The Y coordinate
outputRow[outputIndex++] = new Double(ep.y);
// The measure
outputRow[outputIndex++] = new Double(0.0);
// The Values in the DBF file...
// PolyLimeM, point #"+data.shapeNr+", add dbf data";
//
Object[] dbfData = si.getDbfData();
RowMetaInterface dbfMeta = si.getDbfMeta();
for (int d = 0; d < dbfMeta.size(); d++) {
outputRow[outputIndex++] = dbfData[d];
}
linesInput++;
// Put it out to the rest of the world...
putRow(data.outputRowMeta, outputRow);
}
break;
default:
System.out.println("Unable to parse shape type [" + Shape.getEsriTypeDesc(si.getType()) + "] : not yet implemented.");
throw new KettleStepException("Unable to parse shape type [" + Shape.getEsriTypeDesc(si.getType()) + "] : not yet implemented.");
}
// Next shape please!
data.shapeNr++;
if ((linesInput % Const.ROWS_UPDATE) == 0)
logBasic("linenr " + linesInput);
return retval;
}
use of org.pentaho.di.core.exception.KettleStepException in project pentaho-kettle by pentaho.
the class ShapeFileReaderMeta method getFields.
public void getFields(RowMetaInterface row, String name, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space) throws KettleStepException {
// The filename...
ValueMetaInterface filename = new ValueMeta("filename", ValueMetaInterface.TYPE_STRING);
filename.setOrigin(name);
filename.setLength(255);
row.addValueMeta(filename);
// The file type
ValueMetaInterface ft = new ValueMeta("filetype", ValueMetaInterface.TYPE_STRING);
ft.setLength(50);
ft.setOrigin(name);
row.addValueMeta(ft);
// The shape nr
ValueMetaInterface shnr = new ValueMeta("shapenr", ValueMetaInterface.TYPE_INTEGER);
shnr.setOrigin(name);
row.addValueMeta(shnr);
// The part nr
ValueMetaInterface pnr = new ValueMeta("partnr", ValueMetaInterface.TYPE_INTEGER);
pnr.setOrigin(name);
row.addValueMeta(pnr);
// The part nr
ValueMetaInterface nrp = new ValueMeta("nrparts", ValueMetaInterface.TYPE_INTEGER);
nrp.setOrigin(name);
row.addValueMeta(nrp);
// The point nr
ValueMetaInterface ptnr = new ValueMeta("pointnr", ValueMetaInterface.TYPE_INTEGER);
ptnr.setOrigin(name);
row.addValueMeta(ptnr);
// The nr of points
ValueMetaInterface nrpt = new ValueMeta("nrpointS", ValueMetaInterface.TYPE_INTEGER);
nrpt.setOrigin(name);
row.addValueMeta(nrpt);
// The X coordinate
ValueMetaInterface x = new ValueMeta("x", ValueMetaInterface.TYPE_NUMBER);
x.setOrigin(name);
row.addValueMeta(x);
// The Y coordinate
ValueMetaInterface y = new ValueMeta("y", ValueMetaInterface.TYPE_NUMBER);
y.setOrigin(name);
row.addValueMeta(y);
// The measure
ValueMetaInterface m = new ValueMeta("measure", ValueMetaInterface.TYPE_NUMBER);
m.setOrigin(name);
row.addValueMeta(m);
if (getDbfFilename() != null) {
XBase xbase = new XBase(getLog(), getDbfFilename());
try {
xbase.setDbfFile(getDbfFilename());
xbase.open();
RowMetaInterface fields = xbase.getFields();
for (int i = 0; i < fields.size(); i++) {
fields.getValueMeta(i).setOrigin(name);
row.addValueMeta(fields.getValueMeta(i));
}
} catch (Throwable e) {
throw new KettleStepException("Unable to read from DBF file", e);
} finally {
xbase.close();
}
} else {
throw new KettleStepException("Unable to read from DBF file: no filename specfied");
}
}
Aggregations