List of usage examples for org.dom4j Namespace getPrefix
public String getPrefix()
From source file:org.talend.camel.designer.ui.wizards.export.RouteJavaScriptOSGIForESBManager.java
License:Open Source License
private static void moveNamespaceInChildren(Element treeRoot, String oldNspURI, String newNspURI) { for (Iterator<?> i = treeRoot.elementIterator(); i.hasNext();) { Element e = (Element) i.next(); Namespace oldNsp = e.getNamespace(); if (oldNspURI.equals(oldNsp.getURI())) { Namespace newNsp = Namespace.get(oldNsp.getPrefix(), newNspURI); e.setQName(QName.get(e.getName(), newNsp)); e.remove(oldNsp);/*w ww .ja va2 s . c om*/ } moveNamespaceInChildren(e, oldNspURI, newNspURI); } }
From source file:org.xmlactions.mapping.bean_to_xml.Bean.java
License:Apache License
public Element processBean(BeanToXml map, Object obj) { Element element = DocumentHelper.createElement(BeanToXmlUtils.buildName(getPrefix(), getName())); for (Namespace namespace : map.getNamespaces()) { element.addNamespace(namespace.getPrefix(), namespace.getUri()); }// ww w. j a v a2s. c o m for (MapperAttribute attribute : getAttributes()) { attribute.buildXml(map, element, obj); } for (MapperElement node : getElements()) { node.buildXml(map, element, obj); } return element; }
From source file:org.zenonpagetemplates.onePhaseImpl.PageTemplateImpl.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) private void defaultContent(Element element, ContentHandler contentHandler, LexicalHandler lexicalHandler, EvaluationHelper evaluationHelper, Stack<Map<String, Slot>> slotStack) throws SAXException, PageTemplateException, IOException, EvaluationException { // Use default template content for (Iterator<Node> i = element.nodeIterator(); i.hasNext();) { Node node = i.next();//from w w w . ja v a 2s . co m switch (node.getNodeType()) { case Node.ELEMENT_NODE: processElement((Element) node, contentHandler, lexicalHandler, evaluationHelper, slotStack); break; case Node.TEXT_NODE: char[] text = node.getText().toCharArray(); contentHandler.characters(text, 0, text.length); break; case Node.COMMENT_NODE: char[] comment = node.getText().toCharArray(); lexicalHandler.comment(comment, 0, comment.length); break; case Node.CDATA_SECTION_NODE: lexicalHandler.startCDATA(); char[] cdata = node.getText().toCharArray(); contentHandler.characters(cdata, 0, cdata.length); lexicalHandler.endCDATA(); break; case Node.NAMESPACE_NODE: Namespace declared = (Namespace) node; //System.err.println( "Declared namespace: " + declared.getPrefix() + ":" + declared.getURI() ); this.namespaces.put(declared.getPrefix(), declared.getURI()); //if ( declared.getURI().equals( TAL_NAMESPACE_URI ) ) { // this.talNamespacePrefix = declared.getPrefix(); //} //else if (declared.getURI().equals( METAL_NAMESPACE_URI ) ) { // this.metalNamespacePrefix = declared.getPrefix(); //} break; case Node.ATTRIBUTE_NODE: // Already handled break; case Node.DOCUMENT_TYPE_NODE: case Node.ENTITY_REFERENCE_NODE: case Node.PROCESSING_INSTRUCTION_NODE: default: //System.err.println( "WARNING: Node type not supported: " + node.getNodeTypeName() ); } } }
From source file:org.zenonpagetemplates.onePhaseImpl.PageTemplateImpl.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" }) private void findMacros(Element element, Map<String, Macro> macros) { // Process any declared namespaces for (Iterator<Namespace> i = element.declaredNamespaces().iterator(); i.hasNext();) { Namespace namespace = i.next(); this.namespaces.put(namespace.getPrefix(), namespace.getURI()); }/* w w w . jav a 2s. c o m*/ // Look for our attribute String name = element.attributeValue(METAL_DEFINE_MACRO); if (name != null) { macros.put(name, new MacroImpl(element)); } // Recurse into child elements for (Iterator i = element.elementIterator(); i.hasNext();) { findMacros((Element) i.next(), macros); } }
From source file:org.zenonpagetemplates.twoPhasesImpl.model.ZPTDocument.java
License:Open Source License
public void addNamespace(Namespace namespace) { this.namespaces.put(namespace.getPrefix(), namespace.getURI()); }
From source file:org.zenonpagetemplates.twoPhasesImpl.model.ZPTElement.java
License:Open Source License
public void addNamespaceStaticAttribute(Namespace namespace) { this.addStaticAttribute(new StaticAttributeImpl(namespace.getPrefix(), XMLNS, namespace.getURI())); }
From source file:org.zenonpagetemplates.twoPhasesImpl.ZPTDocumentFactory.java
License:Open Source License
@SuppressWarnings("unchecked") static private void mapAttributes(Element element, ZPTElement zptElement, ZPTDocument zptDocument) throws PageTemplateException { String talOmitTag = null;// www . j a v a2 s . co m boolean isReplace = false; for (Iterator<Attribute> i = element.attributeIterator(); i.hasNext();) { Attribute attribute = i.next(); Namespace namespace = attribute.getNamespace(); String name = attribute.getName(); String namespacePrefix = namespace.getPrefix(); // Handle ZPT attributes if (TwoPhasesPageTemplate.TAL_NAMESPACE_URI.equals(namespace.getURI())) { // tal:define if (name.equals(TwoPhasesPageTemplate.TAL_DEFINE)) { zptElement.addDynamicAttribute(new TALDefine(namespacePrefix, attribute.getValue())); } // tal:condition else if (name.equals(TwoPhasesPageTemplate.TAL_CONDITION)) { zptElement.addDynamicAttribute(new TALCondition(namespacePrefix, attribute.getValue())); } // tal:repeat else if (name.equals(TwoPhasesPageTemplate.TAL_REPEAT)) { zptElement.addDynamicAttribute(new TALRepeat(namespacePrefix, attribute.getValue())); } // tal:content else if (name.equals(TwoPhasesPageTemplate.TAL_CONTENT)) { zptElement.addDynamicAttribute(new TALContent(namespacePrefix, attribute.getValue())); } // tal:replace else if (name.equals(TwoPhasesPageTemplate.TAL_REPLACE)) { isReplace = true; zptElement.addDynamicAttribute(new TALContent(namespacePrefix, attribute.getValue())); } // tal:attributes else if (name.equals(TwoPhasesPageTemplate.TAL_ATTRIBUTES)) { zptElement.addDynamicAttribute(new TALAttributes(namespacePrefix, attribute.getValue())); } // tal:omit-tag else if (name.equals(TwoPhasesPageTemplate.TAL_OMIT_TAG)) { talOmitTag = attribute.getValue(); } // tal:on-error else if (name.equals(TwoPhasesPageTemplate.TAL_ON_ERROR)) { zptElement.addDynamicAttribute(new TALOnError(namespacePrefix, attribute.getValue())); } // tal:tag else if (name.equals(TwoPhasesPageTemplate.TAL_TAG)) { zptElement.addDynamicAttribute(new TALTag(namespacePrefix, attribute.getValue())); } // error else { throw new PageTemplateException("Unknown TAL attribute: " + name + " in template"); } } else if (TwoPhasesPageTemplate.METAL_NAMESPACE_URI.equals(namespace.getURI())) { // metal:use-macro if (name.equals(TwoPhasesPageTemplate.METAL_USE_MACRO)) { zptElement.addDynamicAttribute(new METALUseMacro(namespacePrefix, attribute.getValue())); } // metal:define-slot else if (name.equals(TwoPhasesPageTemplate.METAL_DEFINE_SLOT)) { zptElement.addDynamicAttribute(new METALDefineSlot(namespacePrefix, attribute.getValue())); } // metal:define-macro else if (name.equals(TwoPhasesPageTemplate.METAL_DEFINE_MACRO)) { zptElement.addDynamicAttribute(new METALDefineMacro(namespacePrefix, attribute.getValue())); } // metal:fill-slot else if (name.equals(TwoPhasesPageTemplate.METAL_FILL_SLOT)) { zptElement.addDynamicAttribute(new METALFillSlot(namespacePrefix, attribute.getValue())); } // error else { throw new PageTemplateException("Unknown metal attribute: " + name + " in template"); } } else if (TwoPhasesPageTemplate.I18N_NAMESPACE_URI.equals(namespace.getURI())) { // i18n:domain if (name.equals(TwoPhasesPageTemplate.I18N_DOMAIN)) { zptElement.addDynamicAttribute(new I18NDomain(namespacePrefix, attribute.getValue())); } // i18n:define else if (name.equals(TwoPhasesPageTemplate.I18N_DEFINE)) { zptElement.addDynamicAttribute(new I18NDefine(namespacePrefix, attribute.getValue())); } // i18n:content else if (name.equals(TwoPhasesPageTemplate.I18N_CONTENT)) { zptElement.addDynamicAttribute(new I18NContent(namespacePrefix, attribute.getValue())); } // i18n:replace else if (name.equals(TwoPhasesPageTemplate.I18N_REPLACE)) { isReplace = true; zptElement.addDynamicAttribute(new I18NContent(namespacePrefix, attribute.getValue())); } // i18n:attributes else if (name.equals(TwoPhasesPageTemplate.I18N_ATTRIBUTES)) { zptElement.addDynamicAttribute(new I18NAttributes(namespacePrefix, attribute.getValue())); } // i18n:params else if (name.equals(TwoPhasesPageTemplate.I18N_PARAMS)) { zptElement.addDynamicAttribute(new I18NParams(namespacePrefix, attribute.getValue())); } // i18n:on-error else if (name.equals(TwoPhasesPageTemplate.I18N_ON_ERROR)) { zptElement.addDynamicAttribute(new I18NOnError(namespacePrefix, attribute.getValue())); } // error else { throw new PageTemplateException("Unknown i18n attribute: " + name + " in template"); } } // Pass on all other attributes else { zptElement.addStaticAttribute(new StaticAttributeImpl(namespacePrefix, name, attribute.getValue())); } } // Add omit-tag if (talOmitTag != null) { zptElement.addDynamicAttribute(new TALOmitTag(zptDocument.getTALPrefix(), talOmitTag)); } else if (isReplace) { zptElement.addDynamicAttribute(new TALOmitTag(zptDocument.getTALPrefix(), VOID_STRING)); } }
From source file:routines.system.NestXMLTool.java
License:Open Source License
public static void replaceDefaultNameSpace(org.dom4j.Element nestRoot, org.dom4j.Element declaredDefaultNamespaceElement) { if (nestRoot != null) { List<org.dom4j.Namespace> declaredNamespaces = nestRoot.declaredNamespaces(); for (org.dom4j.Namespace namespace : declaredNamespaces) { if ("".equals(namespace.getPrefix()) && !"".equals(namespace.getURI())) {// current element declare a // default namespace declaredDefaultNamespaceElement = nestRoot; break; }//from w w w . j a v a2 s . c o m } for (org.dom4j.Element tmp : (java.util.List<org.dom4j.Element>) nestRoot.elements()) { if (declaredDefaultNamespaceElement != null && (tmp.getQName().getNamespace() == org.dom4j.Namespace.NO_NAMESPACE)) { tmp.setQName(org.dom4j.DocumentHelper.createQName(tmp.getName(), declaredDefaultNamespaceElement.getQName().getNamespace())); } replaceDefaultNameSpace(tmp, declaredDefaultNamespaceElement); } } }
From source file:zuora.ots_login_0_1.OTS_Login.java
License:Apache License
public void tFileInputXML_2Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFileInputXML_2_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; String currentComponent = ""; java.util.Map<String, Object> resourceMap = new java.util.HashMap<String, Object>(); try {//from w w w. j a va 2 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; row2Struct row2 = new row2Struct(); stage_OKStruct stage_OK = new stage_OKStruct(); /** * [tMysqlOutput_3 begin ] start */ ok_Hash.put("tMysqlOutput_3", false); start_Hash.put("tMysqlOutput_3", System.currentTimeMillis()); currentComponent = "tMysqlOutput_3"; int tos_count_tMysqlOutput_3 = 0; int nb_line_tMysqlOutput_3 = 0; int nb_line_update_tMysqlOutput_3 = 0; int nb_line_inserted_tMysqlOutput_3 = 0; int nb_line_deleted_tMysqlOutput_3 = 0; int nb_line_rejected_tMysqlOutput_3 = 0; int deletedCount_tMysqlOutput_3 = 0; int updatedCount_tMysqlOutput_3 = 0; int insertedCount_tMysqlOutput_3 = 0; int rejectedCount_tMysqlOutput_3 = 0; String tableName_tMysqlOutput_3 = "ots_job_state"; boolean whetherReject_tMysqlOutput_3 = false; java.util.Calendar calendar_tMysqlOutput_3 = java.util.Calendar.getInstance(); calendar_tMysqlOutput_3.set(1, 0, 1, 0, 0, 0); long year1_tMysqlOutput_3 = calendar_tMysqlOutput_3.getTime().getTime(); calendar_tMysqlOutput_3.set(10000, 0, 1, 0, 0, 0); long year10000_tMysqlOutput_3 = calendar_tMysqlOutput_3.getTime().getTime(); long date_tMysqlOutput_3; java.sql.Connection conn_tMysqlOutput_3 = null; String dbProperties_tMysqlOutput_3 = "noDatetimeStringSync=true"; String url_tMysqlOutput_3 = null; if (dbProperties_tMysqlOutput_3 == null || dbProperties_tMysqlOutput_3.trim().length() == 0) { url_tMysqlOutput_3 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + "rewriteBatchedStatements=true"; } else { String properties_tMysqlOutput_3 = "noDatetimeStringSync=true"; if (!properties_tMysqlOutput_3.contains("rewriteBatchedStatements")) { properties_tMysqlOutput_3 += "&rewriteBatchedStatements=true"; } url_tMysqlOutput_3 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + properties_tMysqlOutput_3; } String driverClass_tMysqlOutput_3 = "org.gjt.mm.mysql.Driver"; String dbUser_tMysqlOutput_3 = "root"; final String decryptedPassword_tMysqlOutput_3 = routines.system.PasswordEncryptUtil .decryptPassword("7a440551249af37a"); String dbPwd_tMysqlOutput_3 = decryptedPassword_tMysqlOutput_3; java.lang.Class.forName(driverClass_tMysqlOutput_3); conn_tMysqlOutput_3 = java.sql.DriverManager.getConnection(url_tMysqlOutput_3, dbUser_tMysqlOutput_3, dbPwd_tMysqlOutput_3); resourceMap.put("conn_tMysqlOutput_3", conn_tMysqlOutput_3); conn_tMysqlOutput_3.setAutoCommit(false); int commitEvery_tMysqlOutput_3 = 10000; int commitCounter_tMysqlOutput_3 = 0; int count_tMysqlOutput_3 = 0; String insert_tMysqlOutput_3 = "INSERT INTO `" + "ots_job_state" + "` (`id`,`stage`,`result`,`error`,`server_url`,`session`,`timestamp`) VALUES (?,?,?,?,?,?,?)"; int batchSize_tMysqlOutput_3 = 100; int batchSizeCounter_tMysqlOutput_3 = 0; java.sql.PreparedStatement pstmt_tMysqlOutput_3 = conn_tMysqlOutput_3 .prepareStatement(insert_tMysqlOutput_3); /** * [tMysqlOutput_3 begin ] stop */ /** * [tMap_1 begin ] start */ ok_Hash.put("tMap_1", false); start_Hash.put("tMap_1", System.currentTimeMillis()); currentComponent = "tMap_1"; int tos_count_tMap_1 = 0; // ############################### // # Lookup's keys initialization // ############################### // ############################### // # Vars initialization class Var__tMap_1__Struct { } Var__tMap_1__Struct Var__tMap_1 = new Var__tMap_1__Struct(); // ############################### // ############################### // # Outputs initialization stage_OKStruct stage_OK_tmp = new stage_OKStruct(); // ############################### /** * [tMap_1 begin ] stop */ /** * [tFileInputXML_2 begin ] start */ ok_Hash.put("tFileInputXML_2", false); start_Hash.put("tFileInputXML_2", System.currentTimeMillis()); currentComponent = "tFileInputXML_2"; int tos_count_tFileInputXML_2 = 0; int nb_line_tFileInputXML_2 = 0; String os_tFileInputXML_2 = System.getProperty("os.name").toLowerCase(); boolean isWindows_tFileInputXML_2 = false; if (os_tFileInputXML_2.indexOf("windows") > -1 || os_tFileInputXML_2.indexOf("nt") > -1) { isWindows_tFileInputXML_2 = true; } class NameSpaceTool_tFileInputXML_2 { public java.util.HashMap<String, String> xmlNameSpaceMap = new java.util.HashMap<String, String>(); private java.util.List<String> defualtNSPath = new java.util.ArrayList<String>(); public void countNSMap(org.dom4j.Element el) { for (org.dom4j.Namespace ns : (java.util.List<org.dom4j.Namespace>) el .declaredNamespaces()) { if (ns.getPrefix().trim().length() == 0) { xmlNameSpaceMap.put("pre" + defualtNSPath.size(), ns.getURI()); String path = ""; org.dom4j.Element elTmp = el; while (elTmp != null) { if (elTmp.getNamespacePrefix() != null && elTmp.getNamespacePrefix().length() > 0) { path = "/" + elTmp.getNamespacePrefix() + ":" + elTmp.getName() + path; } else { path = "/" + elTmp.getName() + path; } elTmp = elTmp.getParent(); } defualtNSPath.add(path); } else { xmlNameSpaceMap.put(ns.getPrefix(), ns.getURI()); } } for (org.dom4j.Element e : (java.util.List<org.dom4j.Element>) el.elements()) { countNSMap(e); } } private final org.talend.xpath.XPathUtil util = new org.talend.xpath.XPathUtil(); { util.setDefaultNSPath(defualtNSPath); } public String addDefaultNSPrefix(String path) { return util.addDefaultNSPrefix(path); } public String addDefaultNSPrefix(String relativeXpression, String basePath) { return util.addDefaultNSPrefix(relativeXpression, basePath); } } class XML_API_tFileInputXML_2 { public boolean isDefNull(org.dom4j.Node node) throws javax.xml.transform.TransformerException { if (node != null && node instanceof org.dom4j.Element) { org.dom4j.Attribute attri = ((org.dom4j.Element) node).attribute("nil"); if (attri != null && ("true").equals(attri.getText())) { return true; } } return false; } public boolean isMissing(org.dom4j.Node node) throws javax.xml.transform.TransformerException { return node == null ? true : false; } public boolean isEmpty(org.dom4j.Node node) throws javax.xml.transform.TransformerException { if (node != null) { return node.getText().length() == 0; } return false; } } org.dom4j.io.SAXReader reader_tFileInputXML_2 = new org.dom4j.io.SAXReader(); Object filename_tFileInputXML_2 = null; try { filename_tFileInputXML_2 = "C:/ETL_FASTWEB/ZUORA/data/responses/ots/login.xml"; } catch (java.lang.Exception e) { System.err.println(e.getMessage()); } if (filename_tFileInputXML_2 != null && filename_tFileInputXML_2 instanceof String && filename_tFileInputXML_2.toString().startsWith("//")) { if (!isWindows_tFileInputXML_2) { filename_tFileInputXML_2 = filename_tFileInputXML_2.toString().replaceFirst("//", "/"); } } boolean isValidFile_tFileInputXML_2 = true; org.dom4j.Document doc_tFileInputXML_2 = null; java.io.Closeable toClose_tFileInputXML_2 = null; try { if (filename_tFileInputXML_2 instanceof java.io.InputStream) { java.io.InputStream inputStream_tFileInputXML_2 = (java.io.InputStream) filename_tFileInputXML_2; toClose_tFileInputXML_2 = inputStream_tFileInputXML_2; doc_tFileInputXML_2 = reader_tFileInputXML_2.read(inputStream_tFileInputXML_2); } else { java.io.Reader unicodeReader_tFileInputXML_2 = new UnicodeReader( new java.io.FileInputStream(String.valueOf(filename_tFileInputXML_2)), "ISO-8859-15"); toClose_tFileInputXML_2 = unicodeReader_tFileInputXML_2; org.xml.sax.InputSource in_tFileInputXML_2 = new org.xml.sax.InputSource( unicodeReader_tFileInputXML_2); doc_tFileInputXML_2 = reader_tFileInputXML_2.read(in_tFileInputXML_2); } } catch (java.lang.Exception e) { System.err.println(e.getMessage()); isValidFile_tFileInputXML_2 = false; } finally { if (toClose_tFileInputXML_2 != null) { toClose_tFileInputXML_2.close(); } } if (isValidFile_tFileInputXML_2) { NameSpaceTool_tFileInputXML_2 nsTool_tFileInputXML_2 = new NameSpaceTool_tFileInputXML_2(); nsTool_tFileInputXML_2.countNSMap(doc_tFileInputXML_2.getRootElement()); java.util.HashMap<String, String> xmlNameSpaceMap_tFileInputXML_2 = nsTool_tFileInputXML_2.xmlNameSpaceMap; org.dom4j.XPath x_tFileInputXML_2 = doc_tFileInputXML_2.createXPath(nsTool_tFileInputXML_2 .addDefaultNSPrefix("/soapenv:Envelope/soapenv:Body/ns1:loginResponse/ns1:result")); x_tFileInputXML_2.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_2); java.util.List<org.dom4j.tree.AbstractNode> nodeList_tFileInputXML_2 = (java.util.List<org.dom4j.tree.AbstractNode>) x_tFileInputXML_2 .selectNodes(doc_tFileInputXML_2); XML_API_tFileInputXML_2 xml_api_tFileInputXML_2 = new XML_API_tFileInputXML_2(); String str_tFileInputXML_2 = ""; org.dom4j.Node node_tFileInputXML_2 = null; // init all mapping xpaths for (org.dom4j.tree.AbstractNode temp_tFileInputXML_2 : nodeList_tFileInputXML_2) { nb_line_tFileInputXML_2++; row2 = null; boolean whetherReject_tFileInputXML_2 = false; row2 = new row2Struct(); try { org.dom4j.XPath xTmp0_tFileInputXML_2 = org.dom4j.DocumentHelper .createXPath(nsTool_tFileInputXML_2.addDefaultNSPrefix("ns1:Session", "/soapenv:Envelope/soapenv:Body/ns1:loginResponse/ns1:result")); xTmp0_tFileInputXML_2.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_2); Object obj0_tFileInputXML_2 = xTmp0_tFileInputXML_2.evaluate(temp_tFileInputXML_2); if (obj0_tFileInputXML_2 == null) { node_tFileInputXML_2 = null; str_tFileInputXML_2 = ""; } else if (obj0_tFileInputXML_2 instanceof org.dom4j.Node) { node_tFileInputXML_2 = (org.dom4j.Node) obj0_tFileInputXML_2; str_tFileInputXML_2 = org.jaxen.function.StringFunction.evaluate( node_tFileInputXML_2, org.jaxen.dom4j.DocumentNavigator.getInstance()); } else if (obj0_tFileInputXML_2 instanceof String || obj0_tFileInputXML_2 instanceof Number) { node_tFileInputXML_2 = temp_tFileInputXML_2; str_tFileInputXML_2 = String.valueOf(obj0_tFileInputXML_2); } else if (obj0_tFileInputXML_2 instanceof java.util.List) { java.util.List<org.dom4j.Node> nodes_tFileInputXML_2 = (java.util.List<org.dom4j.Node>) obj0_tFileInputXML_2; node_tFileInputXML_2 = nodes_tFileInputXML_2.size() > 0 ? nodes_tFileInputXML_2.get(0) : null; str_tFileInputXML_2 = node_tFileInputXML_2 == null ? "" : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_2, org.jaxen.dom4j.DocumentNavigator.getInstance()); } if (xml_api_tFileInputXML_2.isDefNull(node_tFileInputXML_2)) { row2.Session = null; } else if (xml_api_tFileInputXML_2.isEmpty(node_tFileInputXML_2)) { row2.Session = ""; } else if (xml_api_tFileInputXML_2.isMissing(node_tFileInputXML_2)) { row2.Session = null; } else { row2.Session = str_tFileInputXML_2; } org.dom4j.XPath xTmp1_tFileInputXML_2 = org.dom4j.DocumentHelper .createXPath(nsTool_tFileInputXML_2.addDefaultNSPrefix("ns1:ServerUrl", "/soapenv:Envelope/soapenv:Body/ns1:loginResponse/ns1:result")); xTmp1_tFileInputXML_2.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_2); Object obj1_tFileInputXML_2 = xTmp1_tFileInputXML_2.evaluate(temp_tFileInputXML_2); if (obj1_tFileInputXML_2 == null) { node_tFileInputXML_2 = null; str_tFileInputXML_2 = ""; } else if (obj1_tFileInputXML_2 instanceof org.dom4j.Node) { node_tFileInputXML_2 = (org.dom4j.Node) obj1_tFileInputXML_2; str_tFileInputXML_2 = org.jaxen.function.StringFunction.evaluate( node_tFileInputXML_2, org.jaxen.dom4j.DocumentNavigator.getInstance()); } else if (obj1_tFileInputXML_2 instanceof String || obj1_tFileInputXML_2 instanceof Number) { node_tFileInputXML_2 = temp_tFileInputXML_2; str_tFileInputXML_2 = String.valueOf(obj1_tFileInputXML_2); } else if (obj1_tFileInputXML_2 instanceof java.util.List) { java.util.List<org.dom4j.Node> nodes_tFileInputXML_2 = (java.util.List<org.dom4j.Node>) obj1_tFileInputXML_2; node_tFileInputXML_2 = nodes_tFileInputXML_2.size() > 0 ? nodes_tFileInputXML_2.get(0) : null; str_tFileInputXML_2 = node_tFileInputXML_2 == null ? "" : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_2, org.jaxen.dom4j.DocumentNavigator.getInstance()); } if (xml_api_tFileInputXML_2.isDefNull(node_tFileInputXML_2)) { row2.ServerUrl = null; } else if (xml_api_tFileInputXML_2.isEmpty(node_tFileInputXML_2)) { row2.ServerUrl = ""; } else if (xml_api_tFileInputXML_2.isMissing(node_tFileInputXML_2)) { row2.ServerUrl = null; } else { row2.ServerUrl = str_tFileInputXML_2; } } catch (java.lang.Exception e) { whetherReject_tFileInputXML_2 = true; System.err.println(e.getMessage()); row2 = null; } if (nb_line_tFileInputXML_2 > 50) { break; } /** * [tFileInputXML_2 begin ] stop */ /** * [tFileInputXML_2 main ] start */ currentComponent = "tFileInputXML_2"; tos_count_tFileInputXML_2++; /** * [tFileInputXML_2 main ] stop */ // Start of branch "row2" if (row2 != null) { /** * [tMap_1 main ] start */ currentComponent = "tMap_1"; boolean hasCasePrimitiveKeyWithNull_tMap_1 = false; // ############################### // # Input tables (lookups) boolean rejectedInnerJoin_tMap_1 = false; boolean mainRowRejected_tMap_1 = false; // ############################### { // start of Var scope // ############################### // # Vars tables Var__tMap_1__Struct Var = Var__tMap_1;// ############################### // ############################### // # Output tables stage_OK = null; // # Output table : 'stage_OK' stage_OK_tmp.id = 0; stage_OK_tmp.stage = (String) globalMap.get("stage"); stage_OK_tmp.result = "OK"; stage_OK_tmp.error = null; stage_OK_tmp.server_url = row2.ServerUrl; stage_OK_tmp.session = row2.Session; stage_OK_tmp.timestamp = TalendDate.getCurrentDate(); stage_OK = stage_OK_tmp; // ############################### } // end of Var scope rejectedInnerJoin_tMap_1 = false; tos_count_tMap_1++; /** * [tMap_1 main ] stop */ // Start of branch "stage_OK" if (stage_OK != null) { /** * [tMysqlOutput_3 main ] start */ currentComponent = "tMysqlOutput_3"; whetherReject_tMysqlOutput_3 = false; pstmt_tMysqlOutput_3.setLong(1, stage_OK.id); if (stage_OK.stage == null) { pstmt_tMysqlOutput_3.setNull(2, java.sql.Types.OTHER); } else { pstmt_tMysqlOutput_3.setObject(2, stage_OK.stage); } if (stage_OK.result == null) { pstmt_tMysqlOutput_3.setNull(3, java.sql.Types.OTHER); } else { pstmt_tMysqlOutput_3.setObject(3, stage_OK.result); } if (stage_OK.error == null) { pstmt_tMysqlOutput_3.setNull(4, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_3.setString(4, stage_OK.error); } if (stage_OK.server_url == null) { pstmt_tMysqlOutput_3.setNull(5, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_3.setString(5, stage_OK.server_url); } if (stage_OK.session == null) { pstmt_tMysqlOutput_3.setNull(6, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_3.setString(6, stage_OK.session); } if (stage_OK.timestamp != null) { date_tMysqlOutput_3 = stage_OK.timestamp.getTime(); if (date_tMysqlOutput_3 < year1_tMysqlOutput_3 || date_tMysqlOutput_3 >= year10000_tMysqlOutput_3) { pstmt_tMysqlOutput_3.setString(7, "0000-00-00 00:00:00"); } else { pstmt_tMysqlOutput_3.setTimestamp(7, new java.sql.Timestamp(date_tMysqlOutput_3)); } } else { pstmt_tMysqlOutput_3.setNull(7, java.sql.Types.DATE); } pstmt_tMysqlOutput_3.addBatch(); nb_line_tMysqlOutput_3++; batchSizeCounter_tMysqlOutput_3++; if (batchSize_tMysqlOutput_3 <= batchSizeCounter_tMysqlOutput_3) { try { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : pstmt_tMysqlOutput_3.executeBatch()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : e.getUpdateCounts()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : countEach_tMysqlOutput_3); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; System.err.println(e.getMessage()); } batchSizeCounter_tMysqlOutput_3 = 0; } commitCounter_tMysqlOutput_3++; if (commitEvery_tMysqlOutput_3 <= commitCounter_tMysqlOutput_3) { try { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : pstmt_tMysqlOutput_3.executeBatch()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : e.getUpdateCounts()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : countEach_tMysqlOutput_3); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; System.err.println(e.getMessage()); } conn_tMysqlOutput_3.commit(); commitCounter_tMysqlOutput_3 = 0; } tos_count_tMysqlOutput_3++; /** * [tMysqlOutput_3 main ] stop */ } // End of branch "stage_OK" } // End of branch "row2" /** * [tFileInputXML_2 end ] start */ currentComponent = "tFileInputXML_2"; } } globalMap.put("tFileInputXML_2_NB_LINE", nb_line_tFileInputXML_2); ok_Hash.put("tFileInputXML_2", true); end_Hash.put("tFileInputXML_2", System.currentTimeMillis()); /** * [tFileInputXML_2 end ] stop */ /** * [tMap_1 end ] start */ currentComponent = "tMap_1"; // ############################### // # Lookup hashes releasing // ############################### ok_Hash.put("tMap_1", true); end_Hash.put("tMap_1", System.currentTimeMillis()); /** * [tMap_1 end ] stop */ /** * [tMysqlOutput_3 end ] start */ currentComponent = "tMysqlOutput_3"; try { if (batchSizeCounter_tMysqlOutput_3 != 0) { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : pstmt_tMysqlOutput_3.executeBatch()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; } } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_3 = 0; for (int countEach_tMysqlOutput_3 : e.getUpdateCounts()) { countSum_tMysqlOutput_3 += (countEach_tMysqlOutput_3 < 0 ? 0 : countEach_tMysqlOutput_3); } insertedCount_tMysqlOutput_3 += countSum_tMysqlOutput_3; System.err.println(e.getMessage()); } batchSizeCounter_tMysqlOutput_3 = 0; if (pstmt_tMysqlOutput_3 != null) { pstmt_tMysqlOutput_3.close(); } if (commitCounter_tMysqlOutput_3 > 0) { conn_tMysqlOutput_3.commit(); } conn_tMysqlOutput_3.close(); resourceMap.put("finish_tMysqlOutput_3", true); nb_line_deleted_tMysqlOutput_3 = nb_line_deleted_tMysqlOutput_3 + deletedCount_tMysqlOutput_3; nb_line_update_tMysqlOutput_3 = nb_line_update_tMysqlOutput_3 + updatedCount_tMysqlOutput_3; nb_line_inserted_tMysqlOutput_3 = nb_line_inserted_tMysqlOutput_3 + insertedCount_tMysqlOutput_3; nb_line_rejected_tMysqlOutput_3 = nb_line_rejected_tMysqlOutput_3 + rejectedCount_tMysqlOutput_3; globalMap.put("tMysqlOutput_3_NB_LINE", nb_line_tMysqlOutput_3); globalMap.put("tMysqlOutput_3_NB_LINE_UPDATED", nb_line_update_tMysqlOutput_3); globalMap.put("tMysqlOutput_3_NB_LINE_INSERTED", nb_line_inserted_tMysqlOutput_3); globalMap.put("tMysqlOutput_3_NB_LINE_DELETED", nb_line_deleted_tMysqlOutput_3); globalMap.put("tMysqlOutput_3_NB_LINE_REJECTED", nb_line_rejected_tMysqlOutput_3); ok_Hash.put("tMysqlOutput_3", true); end_Hash.put("tMysqlOutput_3", System.currentTimeMillis()); /** * [tMysqlOutput_3 end ] stop */ } // end the resume } catch (java.lang.Exception e) { TalendException te = new TalendException(e, currentComponent, globalMap); throw te; } catch (java.lang.Error error) { throw error; } finally { try { /** * [tFileInputXML_2 finally ] start */ currentComponent = "tFileInputXML_2"; /** * [tFileInputXML_2 finally ] stop */ /** * [tMap_1 finally ] start */ currentComponent = "tMap_1"; /** * [tMap_1 finally ] stop */ /** * [tMysqlOutput_3 finally ] start */ currentComponent = "tMysqlOutput_3"; if (resourceMap.get("finish_tMysqlOutput_3") == null) { if (resourceMap.get("conn_tMysqlOutput_3") != null) { try { ((java.sql.Connection) resourceMap.get("conn_tMysqlOutput_3")).close(); } catch (java.sql.SQLException sqlEx_tMysqlOutput_3) { String errorMessage_tMysqlOutput_3 = "failed to close the connection in tMysqlOutput_3 :" + sqlEx_tMysqlOutput_3.getMessage(); System.err.println(errorMessage_tMysqlOutput_3); } } } /** * [tMysqlOutput_3 finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tFileInputXML_2_SUBPROCESS_STATE", 1); }
From source file:zuora.ots_login_0_1.OTS_Login.java
License:Apache License
public void tFileInputXML_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFileInputXML_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 {// ww w. ja v a 2 s . c om String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row5Struct row5 = new row5Struct(); /** * [tWriteJSONField_2_Out begin ] start */ ok_Hash.put("tWriteJSONField_2_Out", false); start_Hash.put("tWriteJSONField_2_Out", System.currentTimeMillis()); currentVirtualComponent = "tWriteJSONField_2"; currentComponent = "tWriteJSONField_2_Out"; int tos_count_tWriteJSONField_2_Out = 0; // tWriteXMLFieldOut_begin int nb_line_tWriteJSONField_2_Out = 0; boolean needRoot_tWriteJSONField_2_Out = true; String strCompCache_tWriteJSONField_2_Out = null; java.util.Queue<row3Struct> listGroupby_tWriteJSONField_2_Out = new java.util.concurrent.ConcurrentLinkedQueue<row3Struct>(); class ThreadXMLField_tWriteJSONField_2_Out extends Thread { java.util.Queue<row3Struct> queue; java.util.List<java.util.Map<String, String>> flows; java.lang.Exception lastException; String currentComponent; ThreadXMLField_tWriteJSONField_2_Out(java.util.Queue q) { this.queue = q; globalMap.put("queue_tWriteJSONField_2_In", queue); lastException = null; } ThreadXMLField_tWriteJSONField_2_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_2_In", queue); globalMap.put("flows_tWriteJSONField_2_In", flows); } public java.lang.Exception getLastException() { return this.lastException; } public String getCurrentComponent() { return this.currentComponent; } @Override public void run() { try { tWriteJSONField_2_InProcess(globalMap); } catch (TalendException te) { this.lastException = te.getException(); this.currentComponent = te.getCurrentComponent(); } } } ThreadXMLField_tWriteJSONField_2_Out txf_tWriteJSONField_2_Out = new ThreadXMLField_tWriteJSONField_2_Out( listGroupby_tWriteJSONField_2_Out); txf_tWriteJSONField_2_Out.start(); java.util.List<java.util.List<String>> groupbyList_tWriteJSONField_2_Out = new java.util.ArrayList<java.util.List<String>>(); java.util.Map<String, String> valueMap_tWriteJSONField_2_Out = new java.util.HashMap<String, String>(); class NestXMLTool_tWriteJSONField_2_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_2_Out nestXMLTool_tWriteJSONField_2_Out = new NestXMLTool_tWriteJSONField_2_Out(); row5Struct rowStructOutput_tWriteJSONField_2_Out = null; // sort group root element for judgement of group java.util.List<org.dom4j.Element> groupElementList_tWriteJSONField_2_Out = new java.util.ArrayList<org.dom4j.Element>(); org.dom4j.Element root4Group_tWriteJSONField_2_Out = null; org.dom4j.Document doc_tWriteJSONField_2_Out = org.dom4j.DocumentHelper.createDocument(); org.dom4j.io.OutputFormat format_tWriteJSONField_2_Out = org.dom4j.io.OutputFormat .createCompactFormat(); format_tWriteJSONField_2_Out.setNewLineAfterDeclaration(false); format_tWriteJSONField_2_Out.setTrimText(false); format_tWriteJSONField_2_Out.setEncoding("ISO-8859-15"); int[] orders_tWriteJSONField_2_Out = new int[1]; /** * [tWriteJSONField_2_Out begin ] stop */ /** * [tFileInputXML_1 begin ] start */ ok_Hash.put("tFileInputXML_1", false); start_Hash.put("tFileInputXML_1", System.currentTimeMillis()); currentComponent = "tFileInputXML_1"; int tos_count_tFileInputXML_1 = 0; int nb_line_tFileInputXML_1 = 0; String os_tFileInputXML_1 = System.getProperty("os.name").toLowerCase(); boolean isWindows_tFileInputXML_1 = false; if (os_tFileInputXML_1.indexOf("windows") > -1 || os_tFileInputXML_1.indexOf("nt") > -1) { isWindows_tFileInputXML_1 = true; } class NameSpaceTool_tFileInputXML_1 { public java.util.HashMap<String, String> xmlNameSpaceMap = new java.util.HashMap<String, String>(); private java.util.List<String> defualtNSPath = new java.util.ArrayList<String>(); public void countNSMap(org.dom4j.Element el) { for (org.dom4j.Namespace ns : (java.util.List<org.dom4j.Namespace>) el .declaredNamespaces()) { if (ns.getPrefix().trim().length() == 0) { xmlNameSpaceMap.put("pre" + defualtNSPath.size(), ns.getURI()); String path = ""; org.dom4j.Element elTmp = el; while (elTmp != null) { if (elTmp.getNamespacePrefix() != null && elTmp.getNamespacePrefix().length() > 0) { path = "/" + elTmp.getNamespacePrefix() + ":" + elTmp.getName() + path; } else { path = "/" + elTmp.getName() + path; } elTmp = elTmp.getParent(); } defualtNSPath.add(path); } else { xmlNameSpaceMap.put(ns.getPrefix(), ns.getURI()); } } for (org.dom4j.Element e : (java.util.List<org.dom4j.Element>) el.elements()) { countNSMap(e); } } private final org.talend.xpath.XPathUtil util = new org.talend.xpath.XPathUtil(); { util.setDefaultNSPath(defualtNSPath); } public String addDefaultNSPrefix(String path) { return util.addDefaultNSPrefix(path); } public String addDefaultNSPrefix(String relativeXpression, String basePath) { return util.addDefaultNSPrefix(relativeXpression, basePath); } } class XML_API_tFileInputXML_1 { public boolean isDefNull(org.dom4j.Node node) throws javax.xml.transform.TransformerException { if (node != null && node instanceof org.dom4j.Element) { org.dom4j.Attribute attri = ((org.dom4j.Element) node).attribute("nil"); if (attri != null && ("true").equals(attri.getText())) { return true; } } return false; } public boolean isMissing(org.dom4j.Node node) throws javax.xml.transform.TransformerException { return node == null ? true : false; } public boolean isEmpty(org.dom4j.Node node) throws javax.xml.transform.TransformerException { if (node != null) { return node.getText().length() == 0; } return false; } } org.dom4j.io.SAXReader reader_tFileInputXML_1 = new org.dom4j.io.SAXReader(); Object filename_tFileInputXML_1 = null; try { filename_tFileInputXML_1 = "C:/ETL_FASTWEB/ZUORA/data/responses/ots/login.xml"; } catch (java.lang.Exception e) { System.err.println(e.getMessage()); } if (filename_tFileInputXML_1 != null && filename_tFileInputXML_1 instanceof String && filename_tFileInputXML_1.toString().startsWith("//")) { if (!isWindows_tFileInputXML_1) { filename_tFileInputXML_1 = filename_tFileInputXML_1.toString().replaceFirst("//", "/"); } } boolean isValidFile_tFileInputXML_1 = true; org.dom4j.Document doc_tFileInputXML_1 = null; java.io.Closeable toClose_tFileInputXML_1 = null; try { if (filename_tFileInputXML_1 instanceof java.io.InputStream) { java.io.InputStream inputStream_tFileInputXML_1 = (java.io.InputStream) filename_tFileInputXML_1; toClose_tFileInputXML_1 = inputStream_tFileInputXML_1; doc_tFileInputXML_1 = reader_tFileInputXML_1.read(inputStream_tFileInputXML_1); } else { java.io.Reader unicodeReader_tFileInputXML_1 = new UnicodeReader( new java.io.FileInputStream(String.valueOf(filename_tFileInputXML_1)), "ISO-8859-15"); toClose_tFileInputXML_1 = unicodeReader_tFileInputXML_1; org.xml.sax.InputSource in_tFileInputXML_1 = new org.xml.sax.InputSource( unicodeReader_tFileInputXML_1); doc_tFileInputXML_1 = reader_tFileInputXML_1.read(in_tFileInputXML_1); } } catch (java.lang.Exception e) { System.err.println(e.getMessage()); isValidFile_tFileInputXML_1 = false; } finally { if (toClose_tFileInputXML_1 != null) { toClose_tFileInputXML_1.close(); } } if (isValidFile_tFileInputXML_1) { NameSpaceTool_tFileInputXML_1 nsTool_tFileInputXML_1 = new NameSpaceTool_tFileInputXML_1(); nsTool_tFileInputXML_1.countNSMap(doc_tFileInputXML_1.getRootElement()); java.util.HashMap<String, String> xmlNameSpaceMap_tFileInputXML_1 = nsTool_tFileInputXML_1.xmlNameSpaceMap; org.dom4j.XPath x_tFileInputXML_1 = doc_tFileInputXML_1.createXPath(nsTool_tFileInputXML_1 .addDefaultNSPrefix("/soapenv:Envelope/soapenv:Body/soapenv:Fault")); x_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1); java.util.List<org.dom4j.tree.AbstractNode> nodeList_tFileInputXML_1 = (java.util.List<org.dom4j.tree.AbstractNode>) x_tFileInputXML_1 .selectNodes(doc_tFileInputXML_1); XML_API_tFileInputXML_1 xml_api_tFileInputXML_1 = new XML_API_tFileInputXML_1(); String str_tFileInputXML_1 = ""; org.dom4j.Node node_tFileInputXML_1 = null; // init all mapping xpaths for (org.dom4j.tree.AbstractNode temp_tFileInputXML_1 : nodeList_tFileInputXML_1) { nb_line_tFileInputXML_1++; row5 = null; boolean whetherReject_tFileInputXML_1 = false; row5 = new row5Struct(); try { org.dom4j.XPath xTmp0_tFileInputXML_1 = org.dom4j.DocumentHelper .createXPath(nsTool_tFileInputXML_1.addDefaultNSPrefix("faultcode", "/soapenv:Envelope/soapenv:Body/soapenv:Fault")); xTmp0_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1); Object obj0_tFileInputXML_1 = xTmp0_tFileInputXML_1.evaluate(temp_tFileInputXML_1); if (obj0_tFileInputXML_1 == null) { node_tFileInputXML_1 = null; str_tFileInputXML_1 = ""; } else if (obj0_tFileInputXML_1 instanceof org.dom4j.Node) { node_tFileInputXML_1 = (org.dom4j.Node) obj0_tFileInputXML_1; str_tFileInputXML_1 = org.jaxen.function.StringFunction.evaluate( node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance()); } else if (obj0_tFileInputXML_1 instanceof String || obj0_tFileInputXML_1 instanceof Number) { node_tFileInputXML_1 = temp_tFileInputXML_1; str_tFileInputXML_1 = String.valueOf(obj0_tFileInputXML_1); } else if (obj0_tFileInputXML_1 instanceof java.util.List) { java.util.List<org.dom4j.Node> nodes_tFileInputXML_1 = (java.util.List<org.dom4j.Node>) obj0_tFileInputXML_1; node_tFileInputXML_1 = nodes_tFileInputXML_1.size() > 0 ? nodes_tFileInputXML_1.get(0) : null; str_tFileInputXML_1 = node_tFileInputXML_1 == null ? "" : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance()); } if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) { row5.faultcode = null; } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) { row5.faultcode = ""; } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) { row5.faultcode = null; } else { row5.faultcode = str_tFileInputXML_1; } org.dom4j.XPath xTmp1_tFileInputXML_1 = org.dom4j.DocumentHelper .createXPath(nsTool_tFileInputXML_1.addDefaultNSPrefix("faultstring", "/soapenv:Envelope/soapenv:Body/soapenv:Fault")); xTmp1_tFileInputXML_1.setNamespaceURIs(xmlNameSpaceMap_tFileInputXML_1); Object obj1_tFileInputXML_1 = xTmp1_tFileInputXML_1.evaluate(temp_tFileInputXML_1); if (obj1_tFileInputXML_1 == null) { node_tFileInputXML_1 = null; str_tFileInputXML_1 = ""; } else if (obj1_tFileInputXML_1 instanceof org.dom4j.Node) { node_tFileInputXML_1 = (org.dom4j.Node) obj1_tFileInputXML_1; str_tFileInputXML_1 = org.jaxen.function.StringFunction.evaluate( node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance()); } else if (obj1_tFileInputXML_1 instanceof String || obj1_tFileInputXML_1 instanceof Number) { node_tFileInputXML_1 = temp_tFileInputXML_1; str_tFileInputXML_1 = String.valueOf(obj1_tFileInputXML_1); } else if (obj1_tFileInputXML_1 instanceof java.util.List) { java.util.List<org.dom4j.Node> nodes_tFileInputXML_1 = (java.util.List<org.dom4j.Node>) obj1_tFileInputXML_1; node_tFileInputXML_1 = nodes_tFileInputXML_1.size() > 0 ? nodes_tFileInputXML_1.get(0) : null; str_tFileInputXML_1 = node_tFileInputXML_1 == null ? "" : org.jaxen.function.StringFunction.evaluate(node_tFileInputXML_1, org.jaxen.dom4j.DocumentNavigator.getInstance()); } if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) { row5.faultstring = null; } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) { row5.faultstring = ""; } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) { row5.faultstring = null; } else { row5.faultstring = str_tFileInputXML_1; } } catch (java.lang.Exception e) { whetherReject_tFileInputXML_1 = true; System.err.println(e.getMessage()); row5 = null; } if (nb_line_tFileInputXML_1 > 50) { break; } /** * [tFileInputXML_1 begin ] stop */ /** * [tFileInputXML_1 main ] start */ currentComponent = "tFileInputXML_1"; tos_count_tFileInputXML_1++; /** * [tFileInputXML_1 main ] stop */ // Start of branch "row5" if (row5 != null) { /** * [tWriteJSONField_2_Out main ] start */ currentVirtualComponent = "tWriteJSONField_2"; currentComponent = "tWriteJSONField_2_Out"; if (txf_tWriteJSONField_2_Out.getLastException() != null) { currentComponent = txf_tWriteJSONField_2_Out.getCurrentComponent(); throw txf_tWriteJSONField_2_Out.getLastException(); } nb_line_tWriteJSONField_2_Out++; valueMap_tWriteJSONField_2_Out.clear(); valueMap_tWriteJSONField_2_Out.put("faultcode", (row5.faultcode != null ? row5.faultcode.toString() : null)); valueMap_tWriteJSONField_2_Out.put("faultstring", (row5.faultstring != null ? row5.faultstring.toString() : null)); String strTemp_tWriteJSONField_2_Out = ""; strTemp_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out + valueMap_tWriteJSONField_2_Out.get("faultcode") + valueMap_tWriteJSONField_2_Out.get("faultcode").length(); strTemp_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out + valueMap_tWriteJSONField_2_Out.get("faultstring") + valueMap_tWriteJSONField_2_Out.get("faultstring").length(); if (strCompCache_tWriteJSONField_2_Out == null) { strCompCache_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out; rowStructOutput_tWriteJSONField_2_Out = row5; } else { // the data read is different from the data read // last time. if (strCompCache_tWriteJSONField_2_Out .equals(strTemp_tWriteJSONField_2_Out) == false) { nestXMLTool_tWriteJSONField_2_Out .replaceDefaultNameSpace(doc_tWriteJSONField_2_Out.getRootElement()); java.io.StringWriter strWriter_tWriteJSONField_2_Out = new java.io.StringWriter(); org.dom4j.io.XMLWriter output_tWriteJSONField_2_Out = new org.dom4j.io.XMLWriter( strWriter_tWriteJSONField_2_Out, format_tWriteJSONField_2_Out); output_tWriteJSONField_2_Out.write(doc_tWriteJSONField_2_Out); output_tWriteJSONField_2_Out.close(); row3Struct row_tWriteJSONField_2_Out = new row3Struct(); row_tWriteJSONField_2_Out.result = strWriter_tWriteJSONField_2_Out.toString(); listGroupby_tWriteJSONField_2_Out.add(row_tWriteJSONField_2_Out); doc_tWriteJSONField_2_Out.clearContent(); needRoot_tWriteJSONField_2_Out = true; for (int i_tWriteJSONField_2_Out = 0; i_tWriteJSONField_2_Out < orders_tWriteJSONField_2_Out.length; i_tWriteJSONField_2_Out++) { orders_tWriteJSONField_2_Out[i_tWriteJSONField_2_Out] = 0; } if (groupbyList_tWriteJSONField_2_Out != null && groupbyList_tWriteJSONField_2_Out.size() >= 0) { groupbyList_tWriteJSONField_2_Out.clear(); } strCompCache_tWriteJSONField_2_Out = strTemp_tWriteJSONField_2_Out; rowStructOutput_tWriteJSONField_2_Out = row5; } } org.dom4j.Element subTreeRootParent_tWriteJSONField_2_Out = null; // build root xml tree if (needRoot_tWriteJSONField_2_Out) { needRoot_tWriteJSONField_2_Out = false; org.dom4j.Element root_tWriteJSONField_2_Out = doc_tWriteJSONField_2_Out .addElement("result"); subTreeRootParent_tWriteJSONField_2_Out = root_tWriteJSONField_2_Out; org.dom4j.Element root_0_tWriteJSONField_2_Out = root_tWriteJSONField_2_Out .addElement("faultstring"); if (valueMap_tWriteJSONField_2_Out.get("faultstring") != null) { nestXMLTool_tWriteJSONField_2_Out.setText(root_0_tWriteJSONField_2_Out, valueMap_tWriteJSONField_2_Out.get("faultstring")); } root4Group_tWriteJSONField_2_Out = subTreeRootParent_tWriteJSONField_2_Out; } else { subTreeRootParent_tWriteJSONField_2_Out = root4Group_tWriteJSONField_2_Out; } // build group xml tree // build loop xml tree org.dom4j.Element loop_tWriteJSONField_2_Out = org.dom4j.DocumentHelper .createElement("faultcode"); if (orders_tWriteJSONField_2_Out[0] == 0) { orders_tWriteJSONField_2_Out[0] = 0; } if (1 < orders_tWriteJSONField_2_Out.length) { orders_tWriteJSONField_2_Out[1] = 0; } subTreeRootParent_tWriteJSONField_2_Out.elements() .add(orders_tWriteJSONField_2_Out[0]++, loop_tWriteJSONField_2_Out); if (valueMap_tWriteJSONField_2_Out.get("faultcode") != null) { nestXMLTool_tWriteJSONField_2_Out.setText(loop_tWriteJSONField_2_Out, valueMap_tWriteJSONField_2_Out.get("faultcode")); } tos_count_tWriteJSONField_2_Out++; /** * [tWriteJSONField_2_Out main ] stop */ } // End of branch "row5" /** * [tFileInputXML_1 end ] start */ currentComponent = "tFileInputXML_1"; } } globalMap.put("tFileInputXML_1_NB_LINE", nb_line_tFileInputXML_1); ok_Hash.put("tFileInputXML_1", true); end_Hash.put("tFileInputXML_1", System.currentTimeMillis()); /** * [tFileInputXML_1 end ] stop */ /** * [tWriteJSONField_2_Out end ] start */ currentVirtualComponent = "tWriteJSONField_2"; currentComponent = "tWriteJSONField_2_Out"; if (nb_line_tWriteJSONField_2_Out > 0) { nestXMLTool_tWriteJSONField_2_Out .replaceDefaultNameSpace(doc_tWriteJSONField_2_Out.getRootElement()); java.io.StringWriter strWriter_tWriteJSONField_2_Out = new java.io.StringWriter(); org.dom4j.io.XMLWriter output_tWriteJSONField_2_Out = new org.dom4j.io.XMLWriter( strWriter_tWriteJSONField_2_Out, format_tWriteJSONField_2_Out); output_tWriteJSONField_2_Out.write(doc_tWriteJSONField_2_Out); output_tWriteJSONField_2_Out.close(); row3Struct row_tWriteJSONField_2_Out = new row3Struct(); row_tWriteJSONField_2_Out.result = strWriter_tWriteJSONField_2_Out.toString(); listGroupby_tWriteJSONField_2_Out.add(row_tWriteJSONField_2_Out); } globalMap.put("tWriteJSONField_2_Out_NB_LINE", nb_line_tWriteJSONField_2_Out); globalMap.put("tWriteJSONField_2_In_FINISH" + (listGroupby_tWriteJSONField_2_Out == null ? "" : listGroupby_tWriteJSONField_2_Out.hashCode()), "true"); txf_tWriteJSONField_2_Out.join(); if (txf_tWriteJSONField_2_Out.getLastException() != null) { currentComponent = txf_tWriteJSONField_2_Out.getCurrentComponent(); throw txf_tWriteJSONField_2_Out.getLastException(); } resourceMap.put("finish_tWriteJSONField_2_Out", true); ok_Hash.put("tWriteJSONField_2_Out", true); end_Hash.put("tWriteJSONField_2_Out", System.currentTimeMillis()); /** * [tWriteJSONField_2_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 { /** * [tFileInputXML_1 finally ] start */ currentComponent = "tFileInputXML_1"; /** * [tFileInputXML_1 finally ] stop */ /** * [tWriteJSONField_2_Out finally ] start */ currentVirtualComponent = "tWriteJSONField_2"; currentComponent = "tWriteJSONField_2_Out"; java.util.Queue listGroupby_tWriteJSONField_2_Out = (java.util.Queue) globalMap .get("queue_tWriteJSONField_2_In"); if (resourceMap.get("finish_tWriteJSONField_2_Out") == null) { globalMap.put("tWriteJSONField_2_In_FINISH_WITH_EXCEPTION" + (listGroupby_tWriteJSONField_2_Out == null ? "" : listGroupby_tWriteJSONField_2_Out.hashCode()), "true"); } if (listGroupby_tWriteJSONField_2_Out != null) { globalMap.put("tWriteJSONField_2_In_FINISH" + (listGroupby_tWriteJSONField_2_Out == null ? "" : listGroupby_tWriteJSONField_2_Out.hashCode()), "true"); } /** * [tWriteJSONField_2_Out finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tFileInputXML_1_SUBPROCESS_STATE", 1); }