Search in sources :

Example 21 with KettleStepException

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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) MQTT_VERSION(org.pentaho.di.trans.step.mqtt.MQTTConstants.MQTT_VERSION) Image(org.eclipse.swt.graphics.Image) StepDialogInterface(org.pentaho.di.trans.step.StepDialogInterface) GUIResource(org.pentaho.di.ui.core.gui.GUIResource) TextVar(org.pentaho.di.ui.core.widget.TextVar) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) KEEP_ALIVE_INTERVAL(org.pentaho.di.trans.step.mqtt.MQTTConstants.KEEP_ALIVE_INTERVAL) TransMeta(org.pentaho.di.trans.TransMeta) SERVER_URIS(org.pentaho.di.trans.step.mqtt.MQTTConstants.SERVER_URIS) Composite(org.eclipse.swt.widgets.Composite) Listener(org.eclipse.swt.widgets.Listener) CONNECTION_TIMEOUT(org.pentaho.di.trans.step.mqtt.MQTTConstants.CONNECTION_TIMEOUT) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) AUTOMATIC_RECONNECT(org.pentaho.di.trans.step.mqtt.MQTTConstants.AUTOMATIC_RECONNECT) ConstUI(org.pentaho.di.ui.core.ConstUI) BaseStepDialog(org.pentaho.di.ui.trans.step.BaseStepDialog) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) CLEAN_SESSION(org.pentaho.di.trans.step.mqtt.MQTTConstants.CLEAN_SESSION) PluginDialog(org.pentaho.di.core.annotations.PluginDialog) BaseMessages(org.pentaho.di.i18n.BaseMessages) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Props(org.pentaho.di.core.Props) Text(org.eclipse.swt.widgets.Text) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) CTabFolder(org.eclipse.swt.custom.CTabFolder) FormLayout(org.eclipse.swt.layout.FormLayout) ShellEvent(org.eclipse.swt.events.ShellEvent) FormData(org.eclipse.swt.layout.FormData) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display) ShellAdapter(org.eclipse.swt.events.ShellAdapter) STORAGE_LEVEL(org.pentaho.di.trans.step.mqtt.MQTTConstants.STORAGE_LEVEL) CTabItem(org.eclipse.swt.custom.CTabItem) List(java.util.List) ModifyListener(org.eclipse.swt.events.ModifyListener) SWT(org.eclipse.swt.SWT) KettleStepException(org.pentaho.di.core.exception.KettleStepException) MAX_INFLIGHT(org.pentaho.di.trans.step.mqtt.MQTTConstants.MAX_INFLIGHT) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) KettleStepException(org.pentaho.di.core.exception.KettleStepException) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) CTabItem(org.eclipse.swt.custom.CTabItem) TextVar(org.pentaho.di.ui.core.widget.TextVar) List(java.util.List) FormAttachment(org.eclipse.swt.layout.FormAttachment) ValueMetaBase(org.pentaho.di.core.row.value.ValueMetaBase)

Example 22 with KettleStepException

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);
    }
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) ValueMeta(org.pentaho.di.core.row.ValueMeta) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 23 with KettleStepException

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);
        }
    }
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 24 with KettleStepException

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;
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ShapePoint(org.pentaho.gis.shapefiles.ShapePoint) ShapePoint(org.pentaho.gis.shapefiles.ShapePoint) ShapePolyLineM(org.pentaho.gis.shapefiles.ShapePolyLineM) ShapePolyLine(org.pentaho.gis.shapefiles.ShapePolyLine) ShapeInterface(org.pentaho.gis.shapefiles.ShapeInterface) ShapePolygon(org.pentaho.gis.shapefiles.ShapePolygon)

Example 25 with KettleStepException

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");
    }
}
Also used : KettleStepException(org.pentaho.di.core.exception.KettleStepException) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMeta(org.pentaho.di.core.row.ValueMeta) XBase(org.pentaho.di.trans.steps.xbaseinput.XBase) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

KettleStepException (org.pentaho.di.core.exception.KettleStepException)235 KettleException (org.pentaho.di.core.exception.KettleException)139 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)103 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)97 RowMeta (org.pentaho.di.core.row.RowMeta)51 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)44 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)27 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)27 KettleValueException (org.pentaho.di.core.exception.KettleValueException)26 IOException (java.io.IOException)23 RowAdapter (org.pentaho.di.trans.step.RowAdapter)21 ArrayList (java.util.ArrayList)20 StepMeta (org.pentaho.di.trans.step.StepMeta)19 RowSet (org.pentaho.di.core.RowSet)18 Database (org.pentaho.di.core.database.Database)15 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)13 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)13 FormAttachment (org.eclipse.swt.layout.FormAttachment)12 FormData (org.eclipse.swt.layout.FormData)12 Button (org.eclipse.swt.widgets.Button)12