Example usage for org.dom4j Element declaredNamespaces

List of usage examples for org.dom4j Element declaredNamespaces

Introduction

In this page you can find the example usage for org.dom4j Element declaredNamespaces.

Prototype

List<Namespace> declaredNamespaces();

Source Link

Document

Returns all the namespaces declared by this element.

Usage

From source file:zuora.ots_subscription_0_1.OTS_Subscription.java

License:Apache License

public void tLogCatcher_1Process(final java.util.Map<String, Object> globalMap) throws TalendException {
    globalMap.put("tLogCatcher_1_SUBPROCESS_STATE", 0);

    final boolean execStat = this.execStat;
    String currentVirtualComponent = null;

    String iterateId = "";

    String currentComponent = "";
    java.util.Map<String, Object> resourceMap = new java.util.HashMap<String, Object>();

    try {/*w w  w.  ja  va2 s.  c  o  m*/

        String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName();
        boolean resumeIt = currentMethodName.equals(resumeEntryMethodName);
        if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start
            // the
            // resume
            globalResumeTicket = true;

            row3Struct row3 = new row3Struct();

            /**
             * [tWriteJSONField_1_Out begin ] start
             */

            ok_Hash.put("tWriteJSONField_1_Out", false);
            start_Hash.put("tWriteJSONField_1_Out", System.currentTimeMillis());

            currentVirtualComponent = "tWriteJSONField_1";

            currentComponent = "tWriteJSONField_1_Out";

            int tos_count_tWriteJSONField_1_Out = 0;

            // tWriteXMLFieldOut_begin
            int nb_line_tWriteJSONField_1_Out = 0;
            boolean needRoot_tWriteJSONField_1_Out = true;

            String strCompCache_tWriteJSONField_1_Out = null;

            java.util.Queue<row6Struct> listGroupby_tWriteJSONField_1_Out = new java.util.concurrent.ConcurrentLinkedQueue<row6Struct>();

            class ThreadXMLField_tWriteJSONField_1_Out extends Thread {

                java.util.Queue<row6Struct> queue;

                java.util.List<java.util.Map<String, String>> flows;
                java.lang.Exception lastException;
                String currentComponent;

                ThreadXMLField_tWriteJSONField_1_Out(java.util.Queue q) {
                    this.queue = q;
                    globalMap.put("queue_tWriteJSONField_1_In", queue);
                    lastException = null;
                }

                ThreadXMLField_tWriteJSONField_1_Out(java.util.Queue q,
                        java.util.List<java.util.Map<String, String>> l) {
                    this.queue = q;
                    this.flows = l;
                    lastException = null;
                    globalMap.put("queue_tWriteJSONField_1_In", queue);
                    globalMap.put("flows_tWriteJSONField_1_In", flows);
                }

                public java.lang.Exception getLastException() {
                    return this.lastException;
                }

                public String getCurrentComponent() {
                    return this.currentComponent;
                }

                @Override
                public void run() {
                    try {
                        tWriteJSONField_1_InProcess(globalMap);
                    } catch (TalendException te) {
                        this.lastException = te.getException();
                        this.currentComponent = te.getCurrentComponent();
                    }
                }
            }

            ThreadXMLField_tWriteJSONField_1_Out txf_tWriteJSONField_1_Out = new ThreadXMLField_tWriteJSONField_1_Out(
                    listGroupby_tWriteJSONField_1_Out);

            txf_tWriteJSONField_1_Out.start();

            java.util.List<java.util.List<String>> groupbyList_tWriteJSONField_1_Out = new java.util.ArrayList<java.util.List<String>>();
            java.util.Map<String, String> valueMap_tWriteJSONField_1_Out = new java.util.HashMap<String, String>();

            class NestXMLTool_tWriteJSONField_1_Out {
                public void parseAndAdd(org.dom4j.Element nestRoot, String value) {
                    try {
                        org.dom4j.Document doc4Str = org.dom4j.DocumentHelper
                                .parseText("<root>" + value + "</root>");
                        nestRoot.setContent(doc4Str.getRootElement().content());
                    } catch (java.lang.Exception e) {
                        e.printStackTrace();
                        nestRoot.setText(value);
                    }
                }

                public void setText(org.dom4j.Element element, String value) {
                    if (value.startsWith("<![CDATA[") && value.endsWith("]]>")) {
                        String text = value.substring(9, value.length() - 3);
                        element.addCDATA(text);
                    } else {
                        element.setText(value);
                    }
                }

                public void replaceDefaultNameSpace(org.dom4j.Element nestRoot) {
                    if (nestRoot != null) {
                        for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) nestRoot.elements()) {
                            if (("").equals(tmp.getQName().getNamespace().getURI())
                                    && ("").equals(tmp.getQName().getNamespace().getPrefix())) {
                                tmp.setQName(org.dom4j.DocumentHelper.createQName(tmp.getName(),
                                        nestRoot.getQName().getNamespace()));
                            }
                            replaceDefaultNameSpace(tmp);
                        }
                    }
                }

                public void removeEmptyElement(org.dom4j.Element root) {
                    if (root != null) {
                        for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) root.elements()) {
                            removeEmptyElement(tmp);
                        }
                        if (root.content().size() == 0 && root.attributes().size() == 0
                                && root.declaredNamespaces().size() == 0) {
                            if (root.getParent() != null) {
                                root.getParent().remove(root);
                            }
                        }
                    }
                }
            }
            NestXMLTool_tWriteJSONField_1_Out nestXMLTool_tWriteJSONField_1_Out = new NestXMLTool_tWriteJSONField_1_Out();

            row3Struct rowStructOutput_tWriteJSONField_1_Out = null;
            // sort group root element for judgement of group
            java.util.List<org.dom4j.Element> groupElementList_tWriteJSONField_1_Out = new java.util.ArrayList<org.dom4j.Element>();
            org.dom4j.Element root4Group_tWriteJSONField_1_Out = null;
            org.dom4j.Document doc_tWriteJSONField_1_Out = org.dom4j.DocumentHelper.createDocument();
            org.dom4j.io.OutputFormat format_tWriteJSONField_1_Out = org.dom4j.io.OutputFormat
                    .createCompactFormat();
            format_tWriteJSONField_1_Out.setNewLineAfterDeclaration(false);
            format_tWriteJSONField_1_Out.setTrimText(false);
            format_tWriteJSONField_1_Out.setEncoding("ISO-8859-15");
            int[] orders_tWriteJSONField_1_Out = new int[1];

            /**
             * [tWriteJSONField_1_Out begin ] stop
             */

            /**
             * [tLogCatcher_1 begin ] start
             */

            ok_Hash.put("tLogCatcher_1", false);
            start_Hash.put("tLogCatcher_1", System.currentTimeMillis());

            currentComponent = "tLogCatcher_1";

            int tos_count_tLogCatcher_1 = 0;

            for (LogCatcherUtils.LogCatcherMessage lcm : tLogCatcher_1.getMessages()) {
                row3.type = lcm.getType();
                row3.origin = (lcm.getOrigin() == null || lcm.getOrigin().length() < 1 ? null
                        : lcm.getOrigin());
                row3.priority = lcm.getPriority();
                row3.message = lcm.getMessage();
                row3.code = lcm.getCode();

                row3.moment = java.util.Calendar.getInstance().getTime();

                row3.pid = pid;
                row3.root_pid = rootPid;
                row3.father_pid = fatherPid;

                row3.project = projectName;
                row3.job = jobName;
                row3.context = contextStr;

                /**
                 * [tLogCatcher_1 begin ] stop
                 */

                /**
                 * [tLogCatcher_1 main ] start
                 */

                currentComponent = "tLogCatcher_1";

                tos_count_tLogCatcher_1++;

                /**
                 * [tLogCatcher_1 main ] stop
                 */

                /**
                 * [tWriteJSONField_1_Out main ] start
                 */

                currentVirtualComponent = "tWriteJSONField_1";

                currentComponent = "tWriteJSONField_1_Out";

                if (txf_tWriteJSONField_1_Out.getLastException() != null) {
                    currentComponent = txf_tWriteJSONField_1_Out.getCurrentComponent();
                    throw txf_tWriteJSONField_1_Out.getLastException();
                }
                nb_line_tWriteJSONField_1_Out++;
                valueMap_tWriteJSONField_1_Out.clear();
                valueMap_tWriteJSONField_1_Out.put("moment",
                        (row3.moment != null ? FormatterUtils.format_Date(row3.moment, "yyyy-MM-dd HH:mm:ss")
                                : null));
                valueMap_tWriteJSONField_1_Out.put("pid", (row3.pid != null ? row3.pid.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("root_pid",
                        (row3.root_pid != null ? row3.root_pid.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("father_pid",
                        (row3.father_pid != null ? row3.father_pid.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("project",
                        (row3.project != null ? row3.project.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("job", (row3.job != null ? row3.job.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("context",
                        (row3.context != null ? row3.context.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("priority",
                        (row3.priority != null ? row3.priority.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("type", (row3.type != null ? row3.type.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("origin",
                        (row3.origin != null ? row3.origin.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("message",
                        (row3.message != null ? row3.message.toString() : null));
                valueMap_tWriteJSONField_1_Out.put("code", (row3.code != null ? row3.code.toString() : null));
                String strTemp_tWriteJSONField_1_Out = "";
                strTemp_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out
                        + valueMap_tWriteJSONField_1_Out.get("moment")
                        + valueMap_tWriteJSONField_1_Out.get("moment").length();
                strTemp_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out
                        + valueMap_tWriteJSONField_1_Out.get("project")
                        + valueMap_tWriteJSONField_1_Out.get("project").length();
                strTemp_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out
                        + valueMap_tWriteJSONField_1_Out.get("job")
                        + valueMap_tWriteJSONField_1_Out.get("job").length();
                strTemp_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out
                        + valueMap_tWriteJSONField_1_Out.get("type")
                        + valueMap_tWriteJSONField_1_Out.get("type").length();
                strTemp_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out
                        + valueMap_tWriteJSONField_1_Out.get("origin")
                        + valueMap_tWriteJSONField_1_Out.get("origin").length();
                strTemp_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out
                        + valueMap_tWriteJSONField_1_Out.get("message")
                        + valueMap_tWriteJSONField_1_Out.get("message").length();
                strTemp_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out
                        + valueMap_tWriteJSONField_1_Out.get("code")
                        + valueMap_tWriteJSONField_1_Out.get("code").length();
                if (strCompCache_tWriteJSONField_1_Out == null) {
                    strCompCache_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out;

                    rowStructOutput_tWriteJSONField_1_Out = row3;

                } else {
                    // the data read is different from the data read last
                    // time.
                    if (strCompCache_tWriteJSONField_1_Out.equals(strTemp_tWriteJSONField_1_Out) == false) {
                        nestXMLTool_tWriteJSONField_1_Out
                                .replaceDefaultNameSpace(doc_tWriteJSONField_1_Out.getRootElement());
                        java.io.StringWriter strWriter_tWriteJSONField_1_Out = new java.io.StringWriter();
                        org.dom4j.io.XMLWriter output_tWriteJSONField_1_Out = new org.dom4j.io.XMLWriter(
                                strWriter_tWriteJSONField_1_Out, format_tWriteJSONField_1_Out);
                        output_tWriteJSONField_1_Out.write(doc_tWriteJSONField_1_Out);
                        output_tWriteJSONField_1_Out.close();

                        row6Struct row_tWriteJSONField_1_Out = new row6Struct();

                        row_tWriteJSONField_1_Out.result = strWriter_tWriteJSONField_1_Out.toString();
                        listGroupby_tWriteJSONField_1_Out.add(row_tWriteJSONField_1_Out);

                        doc_tWriteJSONField_1_Out.clearContent();
                        needRoot_tWriteJSONField_1_Out = true;
                        for (int i_tWriteJSONField_1_Out = 0; i_tWriteJSONField_1_Out < orders_tWriteJSONField_1_Out.length; i_tWriteJSONField_1_Out++) {
                            orders_tWriteJSONField_1_Out[i_tWriteJSONField_1_Out] = 0;
                        }

                        if (groupbyList_tWriteJSONField_1_Out != null
                                && groupbyList_tWriteJSONField_1_Out.size() >= 0) {
                            groupbyList_tWriteJSONField_1_Out.clear();
                        }
                        strCompCache_tWriteJSONField_1_Out = strTemp_tWriteJSONField_1_Out;
                        rowStructOutput_tWriteJSONField_1_Out = row3;

                    }
                }

                org.dom4j.Element subTreeRootParent_tWriteJSONField_1_Out = null;

                // build root xml tree
                if (needRoot_tWriteJSONField_1_Out) {
                    needRoot_tWriteJSONField_1_Out = false;
                    org.dom4j.Element root_tWriteJSONField_1_Out = doc_tWriteJSONField_1_Out
                            .addElement("result");
                    subTreeRootParent_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out;
                    org.dom4j.Element root_0_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out
                            .addElement("project");
                    if (valueMap_tWriteJSONField_1_Out.get("project") != null) {
                        nestXMLTool_tWriteJSONField_1_Out.setText(root_0_tWriteJSONField_1_Out,
                                valueMap_tWriteJSONField_1_Out.get("project"));
                    }
                    org.dom4j.Element root_1_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out
                            .addElement("job");
                    if (valueMap_tWriteJSONField_1_Out.get("job") != null) {
                        nestXMLTool_tWriteJSONField_1_Out.setText(root_1_tWriteJSONField_1_Out,
                                valueMap_tWriteJSONField_1_Out.get("job"));
                    }
                    org.dom4j.Element root_2_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out
                            .addElement("type");
                    if (valueMap_tWriteJSONField_1_Out.get("type") != null) {
                        nestXMLTool_tWriteJSONField_1_Out.setText(root_2_tWriteJSONField_1_Out,
                                valueMap_tWriteJSONField_1_Out.get("type"));
                    }
                    org.dom4j.Element root_3_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out
                            .addElement("origin");
                    if (valueMap_tWriteJSONField_1_Out.get("origin") != null) {
                        nestXMLTool_tWriteJSONField_1_Out.setText(root_3_tWriteJSONField_1_Out,
                                valueMap_tWriteJSONField_1_Out.get("origin"));
                    }
                    org.dom4j.Element root_4_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out
                            .addElement("message");
                    if (valueMap_tWriteJSONField_1_Out.get("message") != null) {
                        nestXMLTool_tWriteJSONField_1_Out.setText(root_4_tWriteJSONField_1_Out,
                                valueMap_tWriteJSONField_1_Out.get("message"));
                    }
                    org.dom4j.Element root_5_tWriteJSONField_1_Out = root_tWriteJSONField_1_Out
                            .addElement("code");
                    if (valueMap_tWriteJSONField_1_Out.get("code") != null) {
                        nestXMLTool_tWriteJSONField_1_Out.setText(root_5_tWriteJSONField_1_Out,
                                valueMap_tWriteJSONField_1_Out.get("code"));
                    }
                    root4Group_tWriteJSONField_1_Out = subTreeRootParent_tWriteJSONField_1_Out;
                } else {
                    subTreeRootParent_tWriteJSONField_1_Out = root4Group_tWriteJSONField_1_Out;
                }
                // build group xml tree
                // build loop xml tree
                org.dom4j.Element loop_tWriteJSONField_1_Out = org.dom4j.DocumentHelper.createElement("moment");
                if (orders_tWriteJSONField_1_Out[0] == 0) {
                    orders_tWriteJSONField_1_Out[0] = 0;
                }
                if (1 < orders_tWriteJSONField_1_Out.length) {
                    orders_tWriteJSONField_1_Out[1] = 0;
                }
                subTreeRootParent_tWriteJSONField_1_Out.elements().add(orders_tWriteJSONField_1_Out[0]++,
                        loop_tWriteJSONField_1_Out);
                if (valueMap_tWriteJSONField_1_Out.get("moment") != null) {
                    nestXMLTool_tWriteJSONField_1_Out.setText(loop_tWriteJSONField_1_Out,
                            valueMap_tWriteJSONField_1_Out.get("moment"));
                }

                tos_count_tWriteJSONField_1_Out++;

                /**
                 * [tWriteJSONField_1_Out main ] stop
                 */

                /**
                 * [tLogCatcher_1 end ] start
                 */

                currentComponent = "tLogCatcher_1";

            }

            ok_Hash.put("tLogCatcher_1", true);
            end_Hash.put("tLogCatcher_1", System.currentTimeMillis());

            /**
             * [tLogCatcher_1 end ] stop
             */

            /**
             * [tWriteJSONField_1_Out end ] start
             */

            currentVirtualComponent = "tWriteJSONField_1";

            currentComponent = "tWriteJSONField_1_Out";

            if (nb_line_tWriteJSONField_1_Out > 0) {
                nestXMLTool_tWriteJSONField_1_Out
                        .replaceDefaultNameSpace(doc_tWriteJSONField_1_Out.getRootElement());
                java.io.StringWriter strWriter_tWriteJSONField_1_Out = new java.io.StringWriter();
                org.dom4j.io.XMLWriter output_tWriteJSONField_1_Out = new org.dom4j.io.XMLWriter(
                        strWriter_tWriteJSONField_1_Out, format_tWriteJSONField_1_Out);
                output_tWriteJSONField_1_Out.write(doc_tWriteJSONField_1_Out);
                output_tWriteJSONField_1_Out.close();
                row6Struct row_tWriteJSONField_1_Out = new row6Struct();

                row_tWriteJSONField_1_Out.result = strWriter_tWriteJSONField_1_Out.toString();
                listGroupby_tWriteJSONField_1_Out.add(row_tWriteJSONField_1_Out);

            }
            globalMap.put("tWriteJSONField_1_Out_NB_LINE", nb_line_tWriteJSONField_1_Out);
            globalMap.put("tWriteJSONField_1_In_FINISH" + (listGroupby_tWriteJSONField_1_Out == null ? ""
                    : listGroupby_tWriteJSONField_1_Out.hashCode()), "true");

            txf_tWriteJSONField_1_Out.join();
            if (txf_tWriteJSONField_1_Out.getLastException() != null) {
                currentComponent = txf_tWriteJSONField_1_Out.getCurrentComponent();
                throw txf_tWriteJSONField_1_Out.getLastException();
            }

            resourceMap.put("finish_tWriteJSONField_1_Out", true);

            ok_Hash.put("tWriteJSONField_1_Out", true);
            end_Hash.put("tWriteJSONField_1_Out", System.currentTimeMillis());

            /**
             * [tWriteJSONField_1_Out end ] stop
             */

        } // end the resume

    } catch (java.lang.Exception e) {

        TalendException te = new TalendException(e, currentComponent, globalMap);

        te.setVirtualComponentName(currentVirtualComponent);

        throw te;
    } catch (java.lang.Error error) {

        throw error;
    } finally {

        try {

            /**
             * [tLogCatcher_1 finally ] start
             */

            currentComponent = "tLogCatcher_1";

            /**
             * [tLogCatcher_1 finally ] stop
             */

            /**
             * [tWriteJSONField_1_Out finally ] start
             */

            currentVirtualComponent = "tWriteJSONField_1";

            currentComponent = "tWriteJSONField_1_Out";

            java.util.Queue listGroupby_tWriteJSONField_1_Out = (java.util.Queue) globalMap
                    .get("queue_tWriteJSONField_1_In");
            if (resourceMap.get("finish_tWriteJSONField_1_Out") == null) {
                globalMap.put("tWriteJSONField_1_In_FINISH_WITH_EXCEPTION"
                        + (listGroupby_tWriteJSONField_1_Out == null ? ""
                                : listGroupby_tWriteJSONField_1_Out.hashCode()),
                        "true");
            }

            if (listGroupby_tWriteJSONField_1_Out != null) {
                globalMap.put("tWriteJSONField_1_In_FINISH" + (listGroupby_tWriteJSONField_1_Out == null ? ""
                        : listGroupby_tWriteJSONField_1_Out.hashCode()), "true");
            }

            /**
             * [tWriteJSONField_1_Out finally ] stop
             */

        } catch (java.lang.Exception e) {
            // ignore
        } catch (java.lang.Error error) {
            // ignore
        }
        resourceMap = null;
    }

    globalMap.put("tLogCatcher_1_SUBPROCESS_STATE", 1);
}