Search in sources :

Example 26 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class TextFileInputDialog method first.

// Get the first x lines
private void first(boolean skipHeaders) {
    TextFileInputMeta info = new TextFileInputMeta();
    getInfo(info);
    try {
        if (info.getTextFileList(transMeta).nrOfFiles() > 0) {
            String shellText = BaseMessages.getString(PKG, "TextFileInputDialog.LinesToView.DialogTitle");
            String lineText = BaseMessages.getString(PKG, "TextFileInputDialog.LinesToView.DialogMessage");
            EnterNumberDialog end = new EnterNumberDialog(shell, 100, shellText, lineText);
            int nrLines = end.open();
            if (nrLines >= 0) {
                List<String> linesList = getFirst(nrLines, skipHeaders);
                if (linesList != null && linesList.size() > 0) {
                    String firstlines = "";
                    for (String aLinesList : linesList) {
                        firstlines += aLinesList + Const.CR;
                    }
                    EnterTextDialog etd = new EnterTextDialog(shell, BaseMessages.getString(PKG, "TextFileInputDialog.ContentOfFirstFile.DialogTitle"), (nrLines == 0 ? BaseMessages.getString(PKG, "TextFileInputDialog.ContentOfFirstFile.AllLines.DialogMessage") : BaseMessages.getString(PKG, "TextFileInputDialog.ContentOfFirstFile.NLines.DialogMessage", "" + nrLines)), firstlines, true);
                    etd.setReadOnly();
                    etd.open();
                } else {
                    MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                    mb.setMessage(BaseMessages.getString(PKG, "TextFileInputDialog.UnableToReadLines.DialogMessage"));
                    mb.setText(BaseMessages.getString(PKG, "TextFileInputDialog.UnableToReadLines.DialogTitle"));
                    mb.open();
                }
            }
        } else {
            MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
            mb.setMessage(BaseMessages.getString(PKG, "TextFileInputDialog.NoValidFile.DialogMessage"));
            mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
            mb.open();
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "TextFileInputDialog.ErrorGettingData.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TextFileInputMeta(org.pentaho.di.trans.steps.textfileinput.TextFileInputMeta) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) EnterNumberDialog(org.pentaho.di.ui.core.dialog.EnterNumberDialog) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 27 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class TextFileOutputDialog method getFields.

private void getFields() {
    if (!gotPreviousFields) {
        try {
            String field = wFileNameField.getText();
            RowMetaInterface r = transMeta.getPrevStepFields(stepname);
            if (r != null) {
                wFileNameField.setItems(r.getFieldNames());
            }
            if (field != null) {
                wFileNameField.setText(field);
            }
        } catch (KettleException ke) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "TextFileOutputDialog.FailedToGetFields.DialogTitle"), BaseMessages.getString(PKG, "TextFileOutputDialog.FailedToGetFields.DialogMessage"), ke);
        }
        gotPreviousFields = true;
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 28 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class TextFileOutputDialog method get.

private void get() {
    try {
        RowMetaInterface r = transMeta.getPrevStepFields(stepname);
        if (r != null) {
            TableItemInsertListener listener = new TableItemInsertListener() {

                public boolean tableItemInserted(TableItem tableItem, ValueMetaInterface v) {
                    if (v.isNumeric()) {
                        // currency symbol
                        tableItem.setText(6, Const.NVL(v.getCurrencySymbol(), ""));
                        // decimal and grouping
                        tableItem.setText(7, Const.NVL(v.getDecimalSymbol(), ""));
                        tableItem.setText(8, Const.NVL(v.getGroupingSymbol(), ""));
                    }
                    // trim type
                    tableItem.setText(9, Const.NVL(ValueMetaString.getTrimTypeDesc(v.getTrimType()), ""));
                    // conversion mask
                    if (!Utils.isEmpty(v.getConversionMask())) {
                        tableItem.setText(3, v.getConversionMask());
                    } else {
                        if (v.isNumber()) {
                            if (v.getLength() > 0) {
                                int le = v.getLength();
                                int pr = v.getPrecision();
                                if (v.getPrecision() <= 0) {
                                    pr = 0;
                                }
                                String mask = "";
                                for (int m = 0; m < le - pr; m++) {
                                    mask += "0";
                                }
                                if (pr > 0) {
                                    mask += ".";
                                }
                                for (int m = 0; m < pr; m++) {
                                    mask += "0";
                                }
                                tableItem.setText(3, mask);
                            }
                        }
                    }
                    return true;
                }
            };
            BaseStepDialog.getFieldsFromPrevious(r, wFields, 1, new int[] { 1 }, new int[] { 2 }, 4, 5, listener);
        }
    } catch (KettleException ke) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Title"), BaseMessages.getString(PKG, "System.Dialog.GetFieldsFailed.Message"), ke);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TableItemInsertListener(org.pentaho.di.ui.trans.step.TableItemInsertListener) TableItem(org.eclipse.swt.widgets.TableItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Point(org.eclipse.swt.graphics.Point) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 29 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class TransExecutorDialog method selectFileTrans.

private void selectFileTrans() {
    String curFile = transMeta.environmentSubstitute(wPath.getText());
    FileObject root = null;
    String parentFolder = null;
    try {
        parentFolder = KettleVFS.getFileObject(transMeta.environmentSubstitute(transMeta.getFilename())).getParent().toString();
    } catch (Exception e) {
    // Take no action
    }
    try {
        root = KettleVFS.getFileObject(curFile != null ? curFile : Const.getUserHomeDirectory());
        VfsFileChooserDialog vfsFileChooser = Spoon.getInstance().getVfsFileChooserDialog(root.getParent(), root);
        FileObject file = vfsFileChooser.open(shell, null, Const.STRING_TRANS_FILTER_EXT, Const.getTransformationFilterNames(), VfsFileChooserDialog.VFS_DIALOG_OPEN_FILE);
        if (file == null) {
            return;
        }
        String fileName = file.getName().toString();
        if (fileName != null) {
            loadFileTrans(fileName);
            if (parentFolder != null && fileName.startsWith(parentFolder)) {
                fileName = fileName.replace(parentFolder, "${" + Const.INTERNAL_VARIABLE_ENTRY_CURRENT_DIRECTORY + "}");
            }
            wPath.setText(fileName);
            specificationMethod = ObjectLocationSpecificationMethod.FILENAME;
        }
    } catch (IOException | KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "TransExecutorDialog.ErrorLoadingTransformation.DialogTitle"), BaseMessages.getString(PKG, "TransExecutorDialog.ErrorLoadingTransformation.DialogMessage"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) VfsFileChooserDialog(org.pentaho.vfs.ui.VfsFileChooserDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) FileObject(org.apache.commons.vfs2.FileObject) IOException(java.io.IOException) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException)

Example 30 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class TransExecutorDialog method getByReferenceData.

private void getByReferenceData(ObjectId transObjectId) {
    try {
        RepositoryObject transInf = repository.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
        String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), transInf.getRepositoryDirectory().getPath());
        String fullPath = Const.NVL(path, "") + "/" + Const.NVL(transInf.getName(), "");
        wPath.setText(fullPath);
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)1977 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)449 KettleStepException (org.pentaho.di.core.exception.KettleStepException)438 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)317 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)316 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)233 IOException (java.io.IOException)208 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)195 FileObject (org.apache.commons.vfs2.FileObject)150 StepMeta (org.pentaho.di.trans.step.StepMeta)150 ArrayList (java.util.ArrayList)149 KettleFileException (org.pentaho.di.core.exception.KettleFileException)124 TransMeta (org.pentaho.di.trans.TransMeta)119 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)113 Test (org.junit.Test)111 KettleValueException (org.pentaho.di.core.exception.KettleValueException)100 Database (org.pentaho.di.core.database.Database)97 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)95 ObjectId (org.pentaho.di.repository.ObjectId)91 Shell (org.eclipse.swt.widgets.Shell)90