Search in sources :

Example 66 with KettleXMLException

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

the class ExcelOutputMeta method readData.

private void readData(Node stepnode) throws KettleXMLException {
    try {
        headerEnabled = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "header"));
        footerEnabled = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "footer"));
        encoding = XMLHandler.getTagValue(stepnode, "encoding");
        append = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "append"));
        String addToResult = XMLHandler.getTagValue(stepnode, "add_to_result_filenames");
        if (Utils.isEmpty(addToResult)) {
            addToResultFilenames = true;
        } else {
            addToResultFilenames = "Y".equalsIgnoreCase(addToResult);
        }
        fileName = XMLHandler.getTagValue(stepnode, "file", "name");
        extension = XMLHandler.getTagValue(stepnode, "file", "extention");
        doNotOpenNewFileInit = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "do_not_open_newfile_init"));
        createparentfolder = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "create_parent_folder"));
        stepNrInFilename = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "split"));
        dateInFilename = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "add_date"));
        timeInFilename = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "add_time"));
        SpecifyFormat = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "SpecifyFormat"));
        date_time_format = XMLHandler.getTagValue(stepnode, "file", "date_time_format");
        usetempfiles = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "usetempfiles"));
        tempdirectory = XMLHandler.getTagValue(stepnode, "file", "tempdirectory");
        autoSizeColumns = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "autosizecolums"));
        nullIsBlank = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "nullisblank"));
        protectsheet = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "file", "protect_sheet"));
        password = Encr.decryptPasswordOptionallyEncrypted(XMLHandler.getTagValue(stepnode, "file", "password"));
        splitEvery = Const.toInt(XMLHandler.getTagValue(stepnode, "file", "splitevery"), 0);
        templateEnabled = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "template", "enabled"));
        templateAppend = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "template", "append"));
        templateFileName = XMLHandler.getTagValue(stepnode, "template", "filename");
        sheetname = XMLHandler.getTagValue(stepnode, "file", "sheetname");
        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);
            outputFields[i] = new ExcelField();
            outputFields[i].setName(XMLHandler.getTagValue(fnode, "name"));
            outputFields[i].setType(XMLHandler.getTagValue(fnode, "type"));
            outputFields[i].setFormat(XMLHandler.getTagValue(fnode, "format"));
        }
        Node customnode = XMLHandler.getSubNode(stepnode, "custom");
        header_font_name = getFontNameByCode(Const.NVL(XMLHandler.getTagValue(customnode, "header_font_name"), ""));
        header_font_size = Const.NVL(XMLHandler.getTagValue(customnode, "header_font_size"), "" + DEFAULT_FONT_SIZE);
        header_font_bold = "Y".equalsIgnoreCase(XMLHandler.getTagValue(customnode, "header_font_bold"));
        header_font_italic = "Y".equalsIgnoreCase(XMLHandler.getTagValue(customnode, "header_font_italic"));
        header_font_underline = getFontUnderlineByCode(Const.NVL(XMLHandler.getTagValue(customnode, "header_font_underline"), ""));
        header_font_orientation = getFontOrientationByCode(Const.NVL(XMLHandler.getTagValue(customnode, "header_font_orientation"), ""));
        header_font_color = getFontColorByCode(Const.NVL(XMLHandler.getTagValue(customnode, "header_font_color"), "" + FONT_COLOR_BLACK));
        header_background_color = getFontColorByCode(Const.NVL(XMLHandler.getTagValue(customnode, "header_background_color"), "" + FONT_COLOR_NONE));
        header_row_height = XMLHandler.getTagValue(customnode, "header_row_height");
        header_alignment = getFontAlignmentByCode(Const.NVL(XMLHandler.getTagValue(customnode, "header_alignment"), ""));
        header_image = XMLHandler.getTagValue(customnode, "header_image");
        // Row font
        row_font_name = getFontNameByCode(Const.NVL(XMLHandler.getTagValue(customnode, "row_font_name"), ""));
        row_font_size = Const.NVL(XMLHandler.getTagValue(customnode, "row_font_size"), "" + DEFAULT_FONT_SIZE);
        row_font_color = getFontColorByCode(Const.NVL(XMLHandler.getTagValue(customnode, "row_font_color"), "" + FONT_COLOR_BLACK));
        row_background_color = getFontColorByCode(Const.NVL(XMLHandler.getTagValue(customnode, "row_background_color"), "" + FONT_COLOR_NONE));
    } catch (Exception e) {
        throw new KettleXMLException("Unable to load step info from XML", 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)

Example 67 with KettleXMLException

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

the class HTTPMeta method readData.

private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    try {
        int nrargs;
        url = XMLHandler.getTagValue(stepnode, "url");
        urlInField = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "urlInField"));
        urlField = XMLHandler.getTagValue(stepnode, "urlField");
        encoding = XMLHandler.getTagValue(stepnode, "encoding");
        httpLogin = XMLHandler.getTagValue(stepnode, "httpLogin");
        httpPassword = Encr.decryptPasswordOptionallyEncrypted(XMLHandler.getTagValue(stepnode, "httpPassword"));
        proxyHost = XMLHandler.getTagValue(stepnode, "proxyHost");
        proxyPort = XMLHandler.getTagValue(stepnode, "proxyPort");
        socketTimeout = XMLHandler.getTagValue(stepnode, "socketTimeout");
        connectionTimeout = XMLHandler.getTagValue(stepnode, "connectionTimeout");
        closeIdleConnectionsTime = XMLHandler.getTagValue(stepnode, "closeIdleConnectionsTime");
        Node lookup = XMLHandler.getSubNode(stepnode, "lookup");
        nrargs = XMLHandler.countNodes(lookup, "arg");
        int nrheaders = XMLHandler.countNodes(lookup, "header");
        allocate(nrargs, nrheaders);
        for (int i = 0; i < nrargs; i++) {
            Node anode = XMLHandler.getSubNodeByNr(lookup, "arg", i);
            argumentField[i] = XMLHandler.getTagValue(anode, "name");
            argumentParameter[i] = XMLHandler.getTagValue(anode, "parameter");
        }
        for (int i = 0; i < nrheaders; i++) {
            Node anode = XMLHandler.getSubNodeByNr(lookup, "header", i);
            headerField[i] = XMLHandler.getTagValue(anode, "name");
            headerParameter[i] = XMLHandler.getTagValue(anode, "parameter");
        }
        fieldName = XMLHandler.getTagValue(stepnode, "result", "name");
        resultCodeFieldName = XMLHandler.getTagValue(stepnode, "result", "code");
        responseTimeFieldName = XMLHandler.getTagValue(stepnode, "result", "response_time");
        responseHeaderFieldName = XMLHandler.getTagValue(stepnode, "result", "response_header");
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "HTTPMeta.Exception.UnableToReadStepInfo"), 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 68 with KettleXMLException

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

the class IfNullMeta method readData.

private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    try {
        selectFields = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "selectFields"));
        selectValuesType = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "selectValuesType"));
        replaceAllByValue = XMLHandler.getTagValue(stepnode, "replaceAllByValue");
        replaceAllMask = XMLHandler.getTagValue(stepnode, "replaceAllMask");
        String setEmptyStringAllString = XMLHandler.getTagValue(stepnode, "setEmptyStringAll");
        setEmptyStringAll = !Utils.isEmpty(setEmptyStringAllString) && "Y".equalsIgnoreCase(setEmptyStringAllString);
        Node types = XMLHandler.getSubNode(stepnode, "valuetypes");
        int nrtypes = XMLHandler.countNodes(types, "valuetype");
        Node fieldNodes = XMLHandler.getSubNode(stepnode, "fields");
        int nrfields = XMLHandler.countNodes(fieldNodes, "field");
        allocate(nrtypes, nrfields);
        for (int i = 0; i < nrtypes; i++) {
            Node tnode = XMLHandler.getSubNodeByNr(types, "valuetype", i);
            valueTypes[i].setTypeName(XMLHandler.getTagValue(tnode, "name"));
            valueTypes[i].setTypereplaceValue(XMLHandler.getTagValue(tnode, "value"));
            valueTypes[i].setTypereplaceMask(XMLHandler.getTagValue(tnode, "mask"));
            String typeemptyString = XMLHandler.getTagValue(tnode, "set_type_empty_string");
            valueTypes[i].setTypeEmptyString(!Utils.isEmpty(typeemptyString) && "Y".equalsIgnoreCase(typeemptyString));
        }
        for (int i = 0; i < nrfields; i++) {
            Node fnode = XMLHandler.getSubNodeByNr(fieldNodes, "field", i);
            fields[i].setFieldName(XMLHandler.getTagValue(fnode, "name"));
            fields[i].setReplaceValue(XMLHandler.getTagValue(fnode, "value"));
            fields[i].setReplaceMask(XMLHandler.getTagValue(fnode, "mask"));
            String emptyString = XMLHandler.getTagValue(fnode, "set_empty_string");
            fields[i].setEmptyString(!Utils.isEmpty(emptyString) && "Y".equalsIgnoreCase(emptyString));
        }
    } catch (Exception e) {
        throw new KettleXMLException("It was not possibke to load the IfNull metadata from XML", 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)

Example 69 with KettleXMLException

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

the class InsertUpdateMeta method readData.

private void readData(Node stepnode, List<? extends SharedObjectInterface> databases) throws KettleXMLException {
    this.databases = databases;
    try {
        String csize;
        int nrkeys, nrvalues;
        String con = XMLHandler.getTagValue(stepnode, "connection");
        databaseMeta = DatabaseMeta.findDatabase(databases, con);
        csize = XMLHandler.getTagValue(stepnode, "commit");
        commitSize = (csize != null) ? csize : "0";
        schemaName = XMLHandler.getTagValue(stepnode, "lookup", "schema");
        tableName = XMLHandler.getTagValue(stepnode, "lookup", "table");
        updateBypassed = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "update_bypassed"));
        Node lookup = XMLHandler.getSubNode(stepnode, "lookup");
        nrkeys = XMLHandler.countNodes(lookup, "key");
        nrvalues = XMLHandler.countNodes(lookup, "value");
        allocate(nrkeys, nrvalues);
        for (int i = 0; i < nrkeys; i++) {
            Node knode = XMLHandler.getSubNodeByNr(lookup, "key", i);
            keyStream[i] = XMLHandler.getTagValue(knode, "name");
            keyLookup[i] = XMLHandler.getTagValue(knode, "field");
            keyCondition[i] = XMLHandler.getTagValue(knode, "condition");
            if (keyCondition[i] == null) {
                keyCondition[i] = "=";
            }
            keyStream2[i] = XMLHandler.getTagValue(knode, "name2");
        }
        for (int i = 0; i < nrvalues; i++) {
            Node vnode = XMLHandler.getSubNodeByNr(lookup, "value", i);
            updateLookup[i] = XMLHandler.getTagValue(vnode, "name");
            updateStream[i] = XMLHandler.getTagValue(vnode, "rename");
            if (updateStream[i] == null) {
                // default: the same name!
                updateStream[i] = updateLookup[i];
            }
            String updateValue = XMLHandler.getTagValue(vnode, "update");
            if (updateValue == null) {
                // default TRUE
                update[i] = Boolean.TRUE;
            } else {
                if (updateValue.equalsIgnoreCase("Y")) {
                    update[i] = Boolean.TRUE;
                } else {
                    update[i] = Boolean.FALSE;
                }
            }
        }
    } catch (Exception e) {
        throw new KettleXMLException(BaseMessages.getString(PKG, "InsertUpdateMeta.Exception.UnableToReadStepInfoFromXML"), 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 70 with KettleXMLException

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

the class IngresVectorwiseLoaderMeta method loadXML.

@Override
public void loadXML(Node stepnode, List<DatabaseMeta> databases, IMetaStore metaStore) throws KettleXMLException {
    try {
        String con = XMLHandler.getTagValue(stepnode, "connection");
        databaseMeta = DatabaseMeta.findDatabase(databases, con);
        tablename = XMLHandler.getTagValue(stepnode, "table");
        fifoFileName = XMLHandler.getTagValue(stepnode, "fifo_file_name");
        sqlPath = XMLHandler.getTagValue(stepnode, "sql_path");
        encoding = XMLHandler.getTagValue(stepnode, "encoding");
        delimiter = XMLHandler.getTagValue(stepnode, "delimiter");
        continueOnError = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "continue_on_error"));
        errorFileName = XMLHandler.getTagValue(stepnode, "error_file_name");
        useStandardConversion = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_standard_conversion"));
        useAuthentication = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_authentication"));
        useDynamicVNode = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_dynamic_vnode"));
        useSSV = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_SSV_delimiter"));
        String escape = XMLHandler.getTagValue(stepnode, "escape_special_characters");
        escapingSpecialCharacters = Utils.isEmpty(escape) ? true : "Y".equalsIgnoreCase(escape);
        usingVwload = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "use_vwload"));
        maxNrErrors = XMLHandler.getTagValue(stepnode, "max_errors");
        truncatingTable = "Y".equalsIgnoreCase(XMLHandler.getTagValue(stepnode, "truncate_table"));
        bufferSize = XMLHandler.getTagValue(stepnode, "buffer_size");
        Node fields = XMLHandler.getSubNode(stepnode, "fields");
        int nrRows = XMLHandler.countNodes(fields, "field");
        allocate(nrRows);
        for (int i = 0; i < nrRows; i++) {
            Node knode = XMLHandler.getSubNodeByNr(fields, "field", i);
            fieldDatabase[i] = XMLHandler.getTagValue(knode, "column_name");
            fieldStream[i] = XMLHandler.getTagValue(knode, "stream_name");
        }
    } catch (Exception e) {
        throw new KettleXMLException("Unable to load step info from XML", e);
    }
}
Also used : Node(org.w3c.dom.Node) 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)

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