Search in sources :

Example 61 with KettleXMLException

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

the class FieldSplitterMeta method readData.

private void readData(Node stepnode) throws KettleXMLException {
    try {
        splitField = XMLHandler.getTagValue(stepnode, "splitfield");
        delimiter = XMLHandler.getTagValue(stepnode, "delimiter");
        enclosure = XMLHandler.getTagValue(stepnode, "enclosure");
        final Node fields = XMLHandler.getSubNode(stepnode, "fields");
        final int nrfields = XMLHandler.countNodes(fields, "field");
        allocate(nrfields);
        for (int i = 0; i < nrfields; i++) {
            final Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);
            fieldName[i] = XMLHandler.getTagValue(fnode, "name");
            fieldID[i] = XMLHandler.getTagValue(fnode, "id");
            final String sidrem = XMLHandler.getTagValue(fnode, "idrem");
            final String stype = XMLHandler.getTagValue(fnode, "type");
            fieldFormat[i] = XMLHandler.getTagValue(fnode, "format");
            fieldGroup[i] = XMLHandler.getTagValue(fnode, "group");
            fieldDecimal[i] = XMLHandler.getTagValue(fnode, "decimal");
            fieldCurrency[i] = XMLHandler.getTagValue(fnode, "currency");
            final String slen = XMLHandler.getTagValue(fnode, "length");
            final String sprc = XMLHandler.getTagValue(fnode, "precision");
            fieldNullIf[i] = XMLHandler.getTagValue(fnode, "nullif");
            fieldIfNull[i] = XMLHandler.getTagValue(fnode, "ifnull");
            final String trim = XMLHandler.getTagValue(fnode, "trimtype");
            fieldRemoveID[i] = "Y".equalsIgnoreCase(sidrem);
            fieldType[i] = ValueMetaFactory.getIdForValueMeta(stype);
            fieldLength[i] = Const.toInt(slen, -1);
            fieldPrecision[i] = Const.toInt(sprc, -1);
            fieldTrimType[i] = ValueMetaString.getTrimTypeByCode(trim);
        }
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "FieldSplitterMeta.Exception.UnableToLoadStepInfoFromXML"), e);
    }
}
Also used : Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 62 with KettleXMLException

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

the class FilterRowsMeta method readData.

private void readData(Node stepnode) throws KettleXMLException {
    try {
        setTrueStepname(XMLHandler.getTagValue(stepnode, "send_true_to"));
        setFalseStepname(XMLHandler.getTagValue(stepnode, "send_false_to"));
        Node compare = XMLHandler.getSubNode(stepnode, "compare");
        Node condnode = XMLHandler.getSubNode(compare, "condition");
        // The new situation...
        if (condnode != null) {
            condition = new Condition(condnode);
        } else {
            // Old style condition: Line1 OR Line2 OR Line3: @deprecated!
            condition = new Condition();
            int nrkeys = XMLHandler.countNodes(compare, "key");
            if (nrkeys == 1) {
                Node knode = XMLHandler.getSubNodeByNr(compare, "key", 0);
                String key = XMLHandler.getTagValue(knode, "name");
                String value = XMLHandler.getTagValue(knode, "value");
                String field = XMLHandler.getTagValue(knode, "field");
                String comparator = XMLHandler.getTagValue(knode, "condition");
                condition.setOperator(Condition.OPERATOR_NONE);
                condition.setLeftValuename(key);
                condition.setFunction(Condition.getFunction(comparator));
                condition.setRightValuename(field);
                condition.setRightExact(new ValueMetaAndData("value", value));
            } else {
                for (int i = 0; i < nrkeys; i++) {
                    Node knode = XMLHandler.getSubNodeByNr(compare, "key", i);
                    String key = XMLHandler.getTagValue(knode, "name");
                    String value = XMLHandler.getTagValue(knode, "value");
                    String field = XMLHandler.getTagValue(knode, "field");
                    String comparator = XMLHandler.getTagValue(knode, "condition");
                    Condition subc = new Condition();
                    if (i > 0) {
                        subc.setOperator(Condition.OPERATOR_OR);
                    } else {
                        subc.setOperator(Condition.OPERATOR_NONE);
                    }
                    subc.setLeftValuename(key);
                    subc.setFunction(Condition.getFunction(comparator));
                    subc.setRightValuename(field);
                    subc.setRightExact(new ValueMetaAndData("value", value));
                    condition.addCondition(subc);
                }
            }
        }
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "FilterRowsMeta.Exception..UnableToLoadStepInfoFromXML"), e);
    }
}
Also used : Condition(org.pentaho.di.core.Condition) Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) ValueMetaAndData(org.pentaho.di.core.row.ValueMetaAndData) 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)

Example 63 with KettleXMLException

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

the class FlattenerMeta method readData.

private void readData(Node stepnode) throws KettleXMLException {
    try {
        fieldName = XMLHandler.getTagValue(stepnode, "field_name");
        Node fields = XMLHandler.getSubNode(stepnode, "fields");
        int nrfields = XMLHandler.countNodes(fields, "field");
        allocate(nrfields);
        for (int i = 0; i < nrfields; i++) {
            Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);
            targetField[i] = XMLHandler.getTagValue(fnode, "name");
        }
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "FlattenerMeta.Exception.UnableToLoadStepInfoFromXML"), e);
    }
}
Also used : Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 64 with KettleXMLException

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

the class DynamicSQLRowMeta method readData.

private void readData(Node stepnode, List<DatabaseMeta> databases) throws KettleXMLException {
    try {
        String con = XMLHandler.getTagValue(stepnode, "connection");
        databaseMeta = DatabaseMeta.findDatabase(databases, con);
        sql = XMLHandler.getTagValue(stepnode, "sql");
        outerJoin = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "outer_join"));
        replacevars = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "replace_vars"));
        queryonlyonchange = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "query_only_on_change"));
        rowLimit = Const.toInt(XMLHandler.getTagValue(stepnode, "rowlimit"), 0);
        sqlfieldname = XMLHandler.getTagValue(stepnode, "sql_fieldname");
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "DynamicSQLRowMeta.Exception.UnableToLoadStepInfo"), e);
    }
}
Also used : KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Example 65 with KettleXMLException

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

the class ExcelInputMeta method readData.

private void readData(Node stepnode) throws KettleXMLException {
    try {
        startsWithHeader = YES.equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "header"));
        String nempty = XMLHandler.getTagValue(stepnode, "noempty");
        ignoreEmptyRows = YES.equalsIgnoreCase(nempty) || nempty == null;
        String soempty = XMLHandler.getTagValue(stepnode, "stoponempty");
        stopOnEmpty = YES.equalsIgnoreCase(soempty) || nempty == null;
        sheetRowNumberField = XMLHandler.getTagValue(stepnode, "sheetrownumfield");
        rowNumberField = XMLHandler.getTagValue(stepnode, "rownum_field");
        rowNumberField = XMLHandler.getTagValue(stepnode, "rownumfield");
        rowLimit = Const.toLong(XMLHandler.getTagValue(stepnode, "limit"), 0);
        encoding = XMLHandler.getTagValue(stepnode, "encoding");
        String addToResult = XMLHandler.getTagValue(stepnode, "add_to_result_filenames");
        if (Utils.isEmpty(addToResult)) {
            isaddresult = true;
        } else {
            isaddresult = "Y".equalsIgnoreCase(addToResult);
        }
        sheetField = XMLHandler.getTagValue(stepnode, "sheetfield");
        fileField = XMLHandler.getTagValue(stepnode, "filefield");
        acceptingFilenames = YES.equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "accept_filenames"));
        acceptingField = XMLHandler.getTagValue(stepnode, "accept_field");
        acceptingStepName = XMLHandler.getTagValue(stepnode, "accept_stepname");
        Node filenode = XMLHandler.getSubNode(stepnode, "file");
        Node sheetsnode = XMLHandler.getSubNode(stepnode, "sheets");
        Node fields = XMLHandler.getSubNode(stepnode, "fields");
        int nrfiles = XMLHandler.countNodes(filenode, "name");
        int nrsheets = XMLHandler.countNodes(sheetsnode, "sheet");
        int nrfields = XMLHandler.countNodes(fields, "field");
        allocate(nrfiles, nrsheets, nrfields);
        for (int i = 0; i < nrfiles; i++) {
            Node filenamenode = XMLHandler.getSubNodeByNr(filenode, "name", i);
            Node filemasknode = XMLHandler.getSubNodeByNr(filenode, "filemask", i);
            Node excludefilemasknode = XMLHandler.getSubNodeByNr(filenode, "exclude_filemask", i);
            Node fileRequirednode = XMLHandler.getSubNodeByNr(filenode, "file_required", i);
            Node includeSubFoldersnode = XMLHandler.getSubNodeByNr(filenode, "include_subfolders", i);
            fileName[i] = XMLHandler.getNodeValue(filenamenode);
            fileMask[i] = XMLHandler.getNodeValue(filemasknode);
            excludeFileMask[i] = XMLHandler.getNodeValue(excludefilemasknode);
            fileRequired[i] = XMLHandler.getNodeValue(fileRequirednode);
            includeSubFolders[i] = XMLHandler.getNodeValue(includeSubFoldersnode);
        }
        for (int i = 0; i < nrfields; i++) {
            Node fnode = XMLHandler.getSubNodeByNr(fields, "field", i);
            field[i] = new ExcelInputField();
            field[i].setName(XMLHandler.getTagValue(fnode, "name"));
            field[i].setType(ValueMetaFactory.getIdForValueMeta(XMLHandler.getTagValue(fnode, "type")));
            field[i].setLength(Const.toInt(XMLHandler.getTagValue(fnode, "length"), -1));
            field[i].setPrecision(Const.toInt(XMLHandler.getTagValue(fnode, "precision"), -1));
            String srepeat = XMLHandler.getTagValue(fnode, "repeat");
            field[i].setTrimType(getTrimTypeByCode(XMLHandler.getTagValue(fnode, "trim_type")));
            if (srepeat != null) {
                field[i].setRepeated(YES.equalsIgnoreCase(srepeat));
            } else {
                field[i].setRepeated(false);
            }
            field[i].setFormat(XMLHandler.getTagValue(fnode, "format"));
            field[i].setCurrencySymbol(XMLHandler.getTagValue(fnode, "currency"));
            field[i].setDecimalSymbol(XMLHandler.getTagValue(fnode, "decimal"));
            field[i].setGroupSymbol(XMLHandler.getTagValue(fnode, "group"));
        }
        for (int i = 0; i < nrsheets; i++) {
            Node snode = XMLHandler.getSubNodeByNr(sheetsnode, "sheet", i);
            sheetName[i] = XMLHandler.getTagValue(snode, "name");
            startRow[i] = Const.toInt(XMLHandler.getTagValue(snode, "startrow"), 0);
            startColumn[i] = Const.toInt(XMLHandler.getTagValue(snode, "startcol"), 0);
        }
        strictTypes = YES.equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "strict_types"));
        errorIgnored = YES.equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "error_ignored"));
        errorLineSkipped = YES.equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "error_line_skipped"));
        warningFilesDestinationDirectory = XMLHandler.getTagValue(stepnode, "bad_line_files_destination_directory");
        warningFilesExtension = XMLHandler.getTagValue(stepnode, "bad_line_files_extension");
        errorFilesDestinationDirectory = XMLHandler.getTagValue(stepnode, "error_line_files_destination_directory");
        errorFilesExtension = XMLHandler.getTagValue(stepnode, "error_line_files_extension");
        lineNumberFilesDestinationDirectory = XMLHandler.getTagValue(stepnode, "line_number_files_destination_directory");
        lineNumberFilesExtension = XMLHandler.getTagValue(stepnode, "line_number_files_extension");
        shortFileFieldName = XMLHandler.getTagValue(stepnode, "shortFileFieldName");
        pathFieldName = XMLHandler.getTagValue(stepnode, "pathFieldName");
        hiddenFieldName = XMLHandler.getTagValue(stepnode, "hiddenFieldName");
        lastModificationTimeFieldName = XMLHandler.getTagValue(stepnode, "lastModificationTimeFieldName");
        uriNameFieldName = XMLHandler.getTagValue(stepnode, "uriNameFieldName");
        rootUriNameFieldName = XMLHandler.getTagValue(stepnode, "rootUriNameFieldName");
        extensionFieldName = XMLHandler.getTagValue(stepnode, "extensionFieldName");
        sizeFieldName = XMLHandler.getTagValue(stepnode, "sizeFieldName");
        try {
            spreadSheetType = SpreadSheetType.valueOf(XMLHandler.getTagValue(stepnode, "spreadsheet_type"));
        } catch (Exception e) {
            spreadSheetType = SpreadSheetType.JXL;
        }
    } catch (Exception e) {
        throw new KettleXMLException("Unable to read step information from XML", e);
    }
}
Also used : Node(org.w3c.dom.Node) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettlePluginException(org.pentaho.di.core.exception.KettlePluginException) KettleStepException(org.pentaho.di.core.exception.KettleStepException)

Aggregations

KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)286 KettleException (org.pentaho.di.core.exception.KettleException)209 Node (org.w3c.dom.Node)164 KettleStepException (org.pentaho.di.core.exception.KettleStepException)150 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)25 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)23 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)20 Document (org.w3c.dom.Document)13 IOException (java.io.IOException)10 KettleValueException (org.pentaho.di.core.exception.KettleValueException)10 StringObjectId (org.pentaho.di.repository.StringObjectId)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)7 FileNotFoundException (java.io.FileNotFoundException)5 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 StreamInterface (org.pentaho.di.trans.step.errorhandling.StreamInterface)5 InputStream (java.io.InputStream)4 MalformedURLException (java.net.MalformedURLException)4 ParseException (java.text.ParseException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)4