Java tutorial
// ============================================================================ // // Copyright (c) 2006-2015, Talend Inc. // // This source code has been automatically generated by_Talend Open Studio for ESB // / Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package zuora.ots_subscription_0_1; import routines.Numeric; import routines.DataOperation; import routines.TalendDataGenerator; import routines.TalendString; import routines.StringHandling; import routines.Relational; import routines.TalendDate; import routines.Mathematical; import routines.system.*; import routines.system.api.*; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.math.BigDecimal; import java.io.ByteArrayOutputStream; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.io.IOException; import java.util.Comparator; //the import part of tJavaFlex_1 //import java.util.List; @SuppressWarnings("unused") /** * Job: OTS_Subscription Purpose: <br> * Description: <br> * @author user@talend.com * @version 6.1.1.20151214_1327 * @status */ public class OTS_Subscription implements TalendJob { public final Object obj = new Object(); // for transmiting parameters purpose private Object valueObject = null; public Object getValueObject() { return this.valueObject; } public void setValueObject(Object valueObject) { this.valueObject = valueObject; } private final static String defaultCharset = java.nio.charset.Charset.defaultCharset().name(); private final static String utf8Charset = "UTF-8"; // create and load default properties private java.util.Properties defaultProps = new java.util.Properties(); // create application properties with default public class ContextProperties extends java.util.Properties { private static final long serialVersionUID = 1L; public ContextProperties(java.util.Properties properties) { super(properties); } public ContextProperties() { super(); } public void synchronizeContext() { } } private ContextProperties context = new ContextProperties(); public ContextProperties getContext() { return this.context; } private final String jobVersion = "0.1"; private final String jobName = "OTS_Subscription"; private final String projectName = "ZUORA"; public Integer errorCode = null; private String currentComponent = ""; private final java.util.Map<String, Object> globalMap = java.util.Collections .synchronizedMap(new java.util.HashMap<String, Object>()); private final java.util.Map<String, Long> start_Hash = new java.util.HashMap<String, Long>(); private final java.util.Map<String, Long> end_Hash = new java.util.HashMap<String, Long>(); private final java.util.Map<String, Boolean> ok_Hash = new java.util.HashMap<String, Boolean>(); public final java.util.List<String[]> globalBuffer = new java.util.ArrayList<String[]>(); // OSGi DataSource private final static String KEY_DB_DATASOURCES = "KEY_DB_DATASOURCES"; public void setDataSources(java.util.Map<String, javax.sql.DataSource> dataSources) { java.util.Map<String, routines.system.TalendDataSource> talendDataSources = new java.util.HashMap<String, routines.system.TalendDataSource>(); for (java.util.Map.Entry<String, javax.sql.DataSource> dataSourceEntry : dataSources.entrySet()) { talendDataSources.put(dataSourceEntry.getKey(), new routines.system.TalendDataSource(dataSourceEntry.getValue())); } globalMap.put(KEY_DB_DATASOURCES, talendDataSources); } LogCatcherUtils tLogCatcher_1 = new LogCatcherUtils(); private final java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(); private final java.io.PrintStream errorMessagePS = new java.io.PrintStream( new java.io.BufferedOutputStream(baos)); public String getExceptionStackTrace() { if ("failure".equals(this.getStatus())) { errorMessagePS.flush(); return baos.toString(); } return null; } private Exception exception; public Exception getException() { if ("failure".equals(this.getStatus())) { return this.exception; } return null; } private class TalendException extends Exception { private static final long serialVersionUID = 1L; private java.util.Map<String, Object> globalMap = null; private Exception e = null; private String currentComponent = null; private String virtualComponentName = null; public void setVirtualComponentName(String virtualComponentName) { this.virtualComponentName = virtualComponentName; } private TalendException(Exception e, String errorComponent, final java.util.Map<String, Object> globalMap) { this.currentComponent = errorComponent; this.globalMap = globalMap; this.e = e; } public Exception getException() { return this.e; } public String getCurrentComponent() { return this.currentComponent; } public String getExceptionCauseMessage(Exception e) { Throwable cause = e; String message = null; int i = 10; while (null != cause && 0 < i--) { message = cause.getMessage(); if (null == message) { cause = cause.getCause(); } else { break; } } if (null == message) { message = e.getClass().getName(); } return message; } @Override public void printStackTrace() { if (!(e instanceof TalendException || e instanceof TDieException)) { if (virtualComponentName != null && currentComponent.indexOf(virtualComponentName + "_") == 0) { globalMap.put(virtualComponentName + "_ERROR_MESSAGE", getExceptionCauseMessage(e)); } globalMap.put(currentComponent + "_ERROR_MESSAGE", getExceptionCauseMessage(e)); System.err.println("Exception in component " + currentComponent); } if (!(e instanceof TDieException)) { if (e instanceof TalendException) { e.printStackTrace(); } else { e.printStackTrace(); e.printStackTrace(errorMessagePS); OTS_Subscription.this.exception = e; } } if (!(e instanceof TalendException)) { try { for (java.lang.reflect.Method m : this.getClass().getEnclosingClass().getMethods()) { if (m.getName().compareTo(currentComponent + "_error") == 0) { m.invoke(OTS_Subscription.this, new Object[] { e, currentComponent, globalMap }); break; } } if (!(e instanceof TDieException)) { tLogCatcher_1.addMessage("Java Exception", currentComponent, 6, e.getClass().getName() + ":" + e.getMessage(), 1); tLogCatcher_1Process(globalMap); } } catch (TalendException e) { // do nothing } catch (Exception e) { this.e.printStackTrace(); } } } } public void tLogCatcher_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tLogCatcher_1_onSubJobError(exception, errorComponent, globalMap); } public void tMap_2_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tLogCatcher_1_onSubJobError(exception, errorComponent, globalMap); } public void tMysqlOutput_2_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tLogCatcher_1_onSubJobError(exception, errorComponent, globalMap); } public void tMysqlInput_4_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tMysqlInput_4_onSubJobError(exception, errorComponent, globalMap); } public void tSetGlobalVar_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tMysqlInput_4_onSubJobError(exception, errorComponent, globalMap); } public void tMysqlInput_2_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tMysqlInput_2_onSubJobError(exception, errorComponent, globalMap); } public void tFlowToIterate_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tMysqlInput_2_onSubJobError(exception, errorComponent, globalMap); } public void tLoop_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tMysqlInput_2_onSubJobError(exception, errorComponent, globalMap); } public void tMysqlInput_3_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tMysqlInput_2_onSubJobError(exception, errorComponent, globalMap); } public void tJavaFlex_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tMysqlInput_2_onSubJobError(exception, errorComponent, globalMap); } public void tSOAP_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tSOAP_1_onSubJobError(exception, errorComponent, globalMap); } public void tFileOutputXML_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tSOAP_1_onSubJobError(exception, errorComponent, globalMap); } public void tFixedFlowInput_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tFixedFlowInput_1_onSubJobError(exception, errorComponent, globalMap); } public void tMap_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tFixedFlowInput_1_onSubJobError(exception, errorComponent, globalMap); } public void tMysqlOutput_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tFixedFlowInput_1_onSubJobError(exception, errorComponent, globalMap); } public void tWriteJSONField_1_Out_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { tWriteJSONField_1_In_error(exception, errorComponent, globalMap); } public void tWriteJSONField_1_In_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put(errorComponent, System.currentTimeMillis()); status = "failure"; tLogCatcher_1_onSubJobError(exception, errorComponent, globalMap); } public void tLogCatcher_1_onSubJobError(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { resumeUtil.addLog("SYSTEM_LOG", "NODE:" + errorComponent, "", Thread.currentThread().getId() + "", "FATAL", "", exception.getMessage(), ResumeUtil.getExceptionStackTrace(exception), ""); } public void tMysqlInput_4_onSubJobError(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { resumeUtil.addLog("SYSTEM_LOG", "NODE:" + errorComponent, "", Thread.currentThread().getId() + "", "FATAL", "", exception.getMessage(), ResumeUtil.getExceptionStackTrace(exception), ""); } public void tMysqlInput_2_onSubJobError(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { resumeUtil.addLog("SYSTEM_LOG", "NODE:" + errorComponent, "", Thread.currentThread().getId() + "", "FATAL", "", exception.getMessage(), ResumeUtil.getExceptionStackTrace(exception), ""); } public void tSOAP_1_onSubJobError(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { resumeUtil.addLog("SYSTEM_LOG", "NODE:" + errorComponent, "", Thread.currentThread().getId() + "", "FATAL", "", exception.getMessage(), ResumeUtil.getExceptionStackTrace(exception), ""); } public void tFixedFlowInput_1_onSubJobError(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { resumeUtil.addLog("SYSTEM_LOG", "NODE:" + errorComponent, "", Thread.currentThread().getId() + "", "FATAL", "", exception.getMessage(), ResumeUtil.getExceptionStackTrace(exception), ""); } public void tWriteJSONField_1_In_onSubJobError(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { resumeUtil.addLog("SYSTEM_LOG", "NODE:" + errorComponent, "", Thread.currentThread().getId() + "", "FATAL", "", exception.getMessage(), ResumeUtil.getExceptionStackTrace(exception), ""); } public static class row3Struct implements routines.system.IPersistableRow<row3Struct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; public java.util.Date moment; public java.util.Date getMoment() { return this.moment; } public String pid; public String getPid() { return this.pid; } public String root_pid; public String getRoot_pid() { return this.root_pid; } public String father_pid; public String getFather_pid() { return this.father_pid; } public String project; public String getProject() { return this.project; } public String job; public String getJob() { return this.job; } public String context; public String getContext() { return this.context; } public Integer priority; public Integer getPriority() { return this.priority; } public String type; public String getType() { return this.type; } public String origin; public String getOrigin() { return this.origin; } public String message; public String getMessage() { return this.message; } public Integer code; public Integer getCode() { return this.code; } private java.util.Date readDate(ObjectInputStream dis) throws IOException { java.util.Date dateReturn = null; int length = 0; length = dis.readByte(); if (length == -1) { dateReturn = null; } else { dateReturn = new Date(dis.readLong()); } return dateReturn; } private void writeDate(java.util.Date date1, ObjectOutputStream dos) throws IOException { if (date1 == null) { dos.writeByte(-1); } else { dos.writeByte(0); dos.writeLong(date1.getTime()); } } private String readString(ObjectInputStream dis) throws IOException { String strReturn = null; int length = 0; length = dis.readInt(); if (length == -1) { strReturn = null; } else { if (length > commonByteArray_ZUORA_OTS_Subscription.length) { if (length < 1024 && commonByteArray_ZUORA_OTS_Subscription.length == 0) { commonByteArray_ZUORA_OTS_Subscription = new byte[1024]; } else { commonByteArray_ZUORA_OTS_Subscription = new byte[2 * length]; } } dis.readFully(commonByteArray_ZUORA_OTS_Subscription, 0, length); strReturn = new String(commonByteArray_ZUORA_OTS_Subscription, 0, length, utf8Charset); } return strReturn; } private void writeString(String str, ObjectOutputStream dos) throws IOException { if (str == null) { dos.writeInt(-1); } else { byte[] byteArray = str.getBytes(utf8Charset); dos.writeInt(byteArray.length); dos.write(byteArray); } } private Integer readInteger(ObjectInputStream dis) throws IOException { Integer intReturn; int length = 0; length = dis.readByte(); if (length == -1) { intReturn = null; } else { intReturn = dis.readInt(); } return intReturn; } private void writeInteger(Integer intNum, ObjectOutputStream dos) throws IOException { if (intNum == null) { dos.writeByte(-1); } else { dos.writeByte(0); dos.writeInt(intNum); } } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.moment = readDate(dis); this.pid = readString(dis); this.root_pid = readString(dis); this.father_pid = readString(dis); this.project = readString(dis); this.job = readString(dis); this.context = readString(dis); this.priority = readInteger(dis); this.type = readString(dis); this.origin = readString(dis); this.message = readString(dis); this.code = readInteger(dis); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // java.util.Date writeDate(this.moment, dos); // String writeString(this.pid, dos); // String writeString(this.root_pid, dos); // String writeString(this.father_pid, dos); // String writeString(this.project, dos); // String writeString(this.job, dos); // String writeString(this.context, dos); // Integer writeInteger(this.priority, dos); // String writeString(this.type, dos); // String writeString(this.origin, dos); // String writeString(this.message, dos); // Integer writeInteger(this.code, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("moment=" + String.valueOf(moment)); sb.append(",pid=" + pid); sb.append(",root_pid=" + root_pid); sb.append(",father_pid=" + father_pid); sb.append(",project=" + project); sb.append(",job=" + job); sb.append(",context=" + context); sb.append(",priority=" + String.valueOf(priority)); sb.append(",type=" + type); sb.append(",origin=" + origin); sb.append(",message=" + message); sb.append(",code=" + String.valueOf(code)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(row3Struct other) { int returnValue = -1; return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } 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 { 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); } public static class row5Struct implements routines.system.IPersistableRow<row5Struct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; protected static final int DEFAULT_HASHCODE = 1; protected static final int PRIME = 31; protected int hashCode = DEFAULT_HASHCODE; public boolean hashCodeDirty = true; public String loopKey; public long id; public long getId() { return this.id; } public Object stage; public Object getStage() { return this.stage; } public Object result; public Object getResult() { return this.result; } public String error; public String getError() { return this.error; } public String server_url; public String getServer_url() { return this.server_url; } public String session; public String getSession() { return this.session; } public java.util.Date timestamp; public java.util.Date getTimestamp() { return this.timestamp; } @Override public int hashCode() { if (this.hashCodeDirty) { final int prime = PRIME; int result = DEFAULT_HASHCODE; result = prime * result + (int) this.id; this.hashCode = result; this.hashCodeDirty = false; } return this.hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final row5Struct other = (row5Struct) obj; if (this.id != other.id) return false; return true; } public void copyDataTo(row5Struct other) { other.id = this.id; other.stage = this.stage; other.result = this.result; other.error = this.error; other.server_url = this.server_url; other.session = this.session; other.timestamp = this.timestamp; } public void copyKeysDataTo(row5Struct other) { other.id = this.id; } private String readString(ObjectInputStream dis) throws IOException { String strReturn = null; int length = 0; length = dis.readInt(); if (length == -1) { strReturn = null; } else { if (length > commonByteArray_ZUORA_OTS_Subscription.length) { if (length < 1024 && commonByteArray_ZUORA_OTS_Subscription.length == 0) { commonByteArray_ZUORA_OTS_Subscription = new byte[1024]; } else { commonByteArray_ZUORA_OTS_Subscription = new byte[2 * length]; } } dis.readFully(commonByteArray_ZUORA_OTS_Subscription, 0, length); strReturn = new String(commonByteArray_ZUORA_OTS_Subscription, 0, length, utf8Charset); } return strReturn; } private void writeString(String str, ObjectOutputStream dos) throws IOException { if (str == null) { dos.writeInt(-1); } else { byte[] byteArray = str.getBytes(utf8Charset); dos.writeInt(byteArray.length); dos.write(byteArray); } } private java.util.Date readDate(ObjectInputStream dis) throws IOException { java.util.Date dateReturn = null; int length = 0; length = dis.readByte(); if (length == -1) { dateReturn = null; } else { dateReturn = new Date(dis.readLong()); } return dateReturn; } private void writeDate(java.util.Date date1, ObjectOutputStream dos) throws IOException { if (date1 == null) { dos.writeByte(-1); } else { dos.writeByte(0); dos.writeLong(date1.getTime()); } } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.id = dis.readLong(); this.stage = (Object) dis.readObject(); this.result = (Object) dis.readObject(); this.error = readString(dis); this.server_url = readString(dis); this.session = readString(dis); this.timestamp = readDate(dis); } catch (IOException e) { throw new RuntimeException(e); } catch (ClassNotFoundException eCNFE) { throw new RuntimeException(eCNFE); } } } public void writeData(ObjectOutputStream dos) { try { // long dos.writeLong(this.id); // Object dos.writeObject(this.stage); // Object dos.writeObject(this.result); // String writeString(this.error, dos); // String writeString(this.server_url, dos); // String writeString(this.session, dos); // java.util.Date writeDate(this.timestamp, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("id=" + String.valueOf(id)); sb.append(",stage=" + String.valueOf(stage)); sb.append(",result=" + String.valueOf(result)); sb.append(",error=" + error); sb.append(",server_url=" + server_url); sb.append(",session=" + session); sb.append(",timestamp=" + String.valueOf(timestamp)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(row5Struct other) { int returnValue = -1; returnValue = checkNullsAndCompare(this.id, other.id); if (returnValue != 0) { return returnValue; } return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } public void tMysqlInput_4Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tMysqlInput_4_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 { 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(); /** * [tSetGlobalVar_1 begin ] start */ ok_Hash.put("tSetGlobalVar_1", false); start_Hash.put("tSetGlobalVar_1", System.currentTimeMillis()); currentComponent = "tSetGlobalVar_1"; int tos_count_tSetGlobalVar_1 = 0; /** * [tSetGlobalVar_1 begin ] stop */ /** * [tMysqlInput_4 begin ] start */ ok_Hash.put("tMysqlInput_4", false); start_Hash.put("tMysqlInput_4", System.currentTimeMillis()); currentComponent = "tMysqlInput_4"; int tos_count_tMysqlInput_4 = 0; java.util.Calendar calendar_tMysqlInput_4 = java.util.Calendar.getInstance(); calendar_tMysqlInput_4.set(0, 0, 0, 0, 0, 0); java.util.Date year0_tMysqlInput_4 = calendar_tMysqlInput_4.getTime(); int nb_line_tMysqlInput_4 = 0; java.sql.Connection conn_tMysqlInput_4 = null; String driverClass_tMysqlInput_4 = "org.gjt.mm.mysql.Driver"; java.lang.Class.forName(driverClass_tMysqlInput_4); String dbUser_tMysqlInput_4 = "root"; final String decryptedPassword_tMysqlInput_4 = routines.system.PasswordEncryptUtil .decryptPassword("7a440551249af37a"); String dbPwd_tMysqlInput_4 = decryptedPassword_tMysqlInput_4; String url_tMysqlInput_4 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + "noDatetimeStringSync=true"; conn_tMysqlInput_4 = java.sql.DriverManager.getConnection(url_tMysqlInput_4, dbUser_tMysqlInput_4, dbPwd_tMysqlInput_4); java.sql.Statement stmt_tMysqlInput_4 = conn_tMysqlInput_4.createStatement(); String dbquery_tMysqlInput_4 = "SELECT \n `ots_job_state`.`id`, \n `ots_job_state`.`stage`, \n `ots_job_state`.`result`, \n `ots_job_state`.`error`, \n `ots_job_state`.`server_url`, \n `ots_job_state`.`session`, \n `ots_job_state`.`timestamp`\nFROM `ots_job_state`\nWHERE `ots_job_state`.`result` = 'OK'\nAND `ots_job_state`.`stage` = 'LOGIN' "; globalMap.put("tMysqlInput_4_QUERY", dbquery_tMysqlInput_4); java.sql.ResultSet rs_tMysqlInput_4 = null; try { rs_tMysqlInput_4 = stmt_tMysqlInput_4.executeQuery(dbquery_tMysqlInput_4); java.sql.ResultSetMetaData rsmd_tMysqlInput_4 = rs_tMysqlInput_4.getMetaData(); int colQtyInRs_tMysqlInput_4 = rsmd_tMysqlInput_4.getColumnCount(); String tmpContent_tMysqlInput_4 = null; while (rs_tMysqlInput_4.next()) { nb_line_tMysqlInput_4++; if (colQtyInRs_tMysqlInput_4 < 1) { row5.id = 0; } else { if (rs_tMysqlInput_4.getObject(1) != null) { row5.id = rs_tMysqlInput_4.getLong(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_4 < 2) { row5.stage = null; } else { if (rs_tMysqlInput_4.getObject(2) != null) { row5.stage = rs_tMysqlInput_4.getObject(2); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_4 < 3) { row5.result = null; } else { if (rs_tMysqlInput_4.getObject(3) != null) { row5.result = rs_tMysqlInput_4.getObject(3); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_4 < 4) { row5.error = null; } else { row5.error = routines.system.JDBCUtil.getString(rs_tMysqlInput_4, 4, false); } if (colQtyInRs_tMysqlInput_4 < 5) { row5.server_url = null; } else { row5.server_url = routines.system.JDBCUtil.getString(rs_tMysqlInput_4, 5, false); } if (colQtyInRs_tMysqlInput_4 < 6) { row5.session = null; } else { row5.session = routines.system.JDBCUtil.getString(rs_tMysqlInput_4, 6, false); } if (colQtyInRs_tMysqlInput_4 < 7) { row5.timestamp = null; } else { if (rs_tMysqlInput_4.getString(7) != null) { String dateString_tMysqlInput_4 = rs_tMysqlInput_4.getString(7); if (!("0000-00-00").equals(dateString_tMysqlInput_4) && !("0000-00-00 00:00:00").equals(dateString_tMysqlInput_4)) { row5.timestamp = rs_tMysqlInput_4.getTimestamp(7); } else { row5.timestamp = (java.util.Date) year0_tMysqlInput_4.clone(); } } else { row5.timestamp = null; } } /** * [tMysqlInput_4 begin ] stop */ /** * [tMysqlInput_4 main ] start */ currentComponent = "tMysqlInput_4"; tos_count_tMysqlInput_4++; /** * [tMysqlInput_4 main ] stop */ /** * [tSetGlobalVar_1 main ] start */ currentComponent = "tSetGlobalVar_1"; globalMap.put("stage", "CREATE_SUBSCRIPTION"); globalMap.put("accounts_at_time", 50); globalMap.put("product_rate_plan_22", "2c92c0f8544bdfff01544de7f5b82f9c"); globalMap.put("product_rate_plan_0", "2c92c0f8544be00101544decfb362393"); globalMap.put("payment_method_other", "2c92c0f95432e69401543f83f39c2e34"); globalMap.put("session_key", row5.session); globalMap.put("server_url", row5.server_url); tos_count_tSetGlobalVar_1++; /** * [tSetGlobalVar_1 main ] stop */ /** * [tMysqlInput_4 end ] start */ currentComponent = "tMysqlInput_4"; } } finally { if (rs_tMysqlInput_4 != null) { rs_tMysqlInput_4.close(); } stmt_tMysqlInput_4.close(); if (conn_tMysqlInput_4 != null && !conn_tMysqlInput_4.isClosed()) { conn_tMysqlInput_4.close(); } } globalMap.put("tMysqlInput_4_NB_LINE", nb_line_tMysqlInput_4); ok_Hash.put("tMysqlInput_4", true); end_Hash.put("tMysqlInput_4", System.currentTimeMillis()); if (((String) globalMap.get("session_key")).length() > 0) { tMysqlInput_2Process(globalMap); } /** * [tMysqlInput_4 end ] stop */ /** * [tSetGlobalVar_1 end ] start */ currentComponent = "tSetGlobalVar_1"; ok_Hash.put("tSetGlobalVar_1", true); end_Hash.put("tSetGlobalVar_1", System.currentTimeMillis()); /** * [tSetGlobalVar_1 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 { /** * [tMysqlInput_4 finally ] start */ currentComponent = "tMysqlInput_4"; /** * [tMysqlInput_4 finally ] stop */ /** * [tSetGlobalVar_1 finally ] start */ currentComponent = "tSetGlobalVar_1"; /** * [tSetGlobalVar_1 finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tMysqlInput_4_SUBPROCESS_STATE", 1); } public static class dataStruct implements routines.system.IPersistableRow<dataStruct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; protected static final int DEFAULT_HASHCODE = 1; protected static final int PRIME = 31; protected int hashCode = DEFAULT_HASHCODE; public boolean hashCodeDirty = true; public String loopKey; public long id; public long getId() { return this.id; } public String promoID; public String getPromoID() { return this.promoID; } public String subscriber_surname; public String getSubscriber_surname() { return this.subscriber_surname; } public String subscriber_name; public String getSubscriber_name() { return this.subscriber_name; } public String subscriber_type; public String getSubscriber_type() { return this.subscriber_type; } public String orderer_surname; public String getOrderer_surname() { return this.orderer_surname; } public String orderer_name; public String getOrderer_name() { return this.orderer_name; } public String orderer_taxCode; public String getOrderer_taxCode() { return this.orderer_taxCode; } public String orderer_VATRegistrationNumber; public String getOrderer_VATRegistrationNumber() { return this.orderer_VATRegistrationNumber; } public String residenceAddress_street; public String getResidenceAddress_street() { return this.residenceAddress_street; } public String residenceAddress_zipCode; public String getResidenceAddress_zipCode() { return this.residenceAddress_zipCode; } public String residenceAddress_city; public String getResidenceAddress_city() { return this.residenceAddress_city; } public String residenceAddress_province; public String getResidenceAddress_province() { return this.residenceAddress_province; } public String residenceAddress_state; public String getResidenceAddress_state() { return this.residenceAddress_state; } public String shippingAddress_surname; public String getShippingAddress_surname() { return this.shippingAddress_surname; } public String shippingAddress_name; public String getShippingAddress_name() { return this.shippingAddress_name; } public String shippingAddress_careOf; public String getShippingAddress_careOf() { return this.shippingAddress_careOf; } public String shippingAddress_street; public String getShippingAddress_street() { return this.shippingAddress_street; } public String shippingAddress_zipCode; public String getShippingAddress_zipCode() { return this.shippingAddress_zipCode; } public String shippingAddress_city; public String getShippingAddress_city() { return this.shippingAddress_city; } public String shippingAddress_province; public String getShippingAddress_province() { return this.shippingAddress_province; } public String shippingAddress_state; public String getShippingAddress_state() { return this.shippingAddress_state; } public String orderer_email; public String getOrderer_email() { return this.orderer_email; } public String orderer_mobilePhone; public String getOrderer_mobilePhone() { return this.orderer_mobilePhone; } public String product_code; public String getProduct_code() { return this.product_code; } public String product_description; public String getProduct_description() { return this.product_description; } public String product_itemsNumber; public String getProduct_itemsNumber() { return this.product_itemsNumber; } public String product_price; public String getProduct_price() { return this.product_price; } public String VATRate; public String getVATRate() { return this.VATRate; } public String registrationDate; public String getRegistrationDate() { return this.registrationDate; } public String paymentMethod; public String getPaymentMethod() { return this.paymentMethod; } public String paymentDate; public String getPaymentDate() { return this.paymentDate; } public String creditTransferIBAN; public String getCreditTransferIBAN() { return this.creditTransferIBAN; } public String transactionReference; public String getTransactionReference() { return this.transactionReference; } public String branch_phone; public String getBranch_phone() { return this.branch_phone; } public String branch_email; public String getBranch_email() { return this.branch_email; } public String shippingMobilePhone; public String getShippingMobilePhone() { return this.shippingMobilePhone; } public int totalItems; public int getTotalItems() { return this.totalItems; } @Override public int hashCode() { if (this.hashCodeDirty) { final int prime = PRIME; int result = DEFAULT_HASHCODE; result = prime * result + (int) this.id; this.hashCode = result; this.hashCodeDirty = false; } return this.hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final dataStruct other = (dataStruct) obj; if (this.id != other.id) return false; return true; } public void copyDataTo(dataStruct other) { other.id = this.id; other.promoID = this.promoID; other.subscriber_surname = this.subscriber_surname; other.subscriber_name = this.subscriber_name; other.subscriber_type = this.subscriber_type; other.orderer_surname = this.orderer_surname; other.orderer_name = this.orderer_name; other.orderer_taxCode = this.orderer_taxCode; other.orderer_VATRegistrationNumber = this.orderer_VATRegistrationNumber; other.residenceAddress_street = this.residenceAddress_street; other.residenceAddress_zipCode = this.residenceAddress_zipCode; other.residenceAddress_city = this.residenceAddress_city; other.residenceAddress_province = this.residenceAddress_province; other.residenceAddress_state = this.residenceAddress_state; other.shippingAddress_surname = this.shippingAddress_surname; other.shippingAddress_name = this.shippingAddress_name; other.shippingAddress_careOf = this.shippingAddress_careOf; other.shippingAddress_street = this.shippingAddress_street; other.shippingAddress_zipCode = this.shippingAddress_zipCode; other.shippingAddress_city = this.shippingAddress_city; other.shippingAddress_province = this.shippingAddress_province; other.shippingAddress_state = this.shippingAddress_state; other.orderer_email = this.orderer_email; other.orderer_mobilePhone = this.orderer_mobilePhone; other.product_code = this.product_code; other.product_description = this.product_description; other.product_itemsNumber = this.product_itemsNumber; other.product_price = this.product_price; other.VATRate = this.VATRate; other.registrationDate = this.registrationDate; other.paymentMethod = this.paymentMethod; other.paymentDate = this.paymentDate; other.creditTransferIBAN = this.creditTransferIBAN; other.transactionReference = this.transactionReference; other.branch_phone = this.branch_phone; other.branch_email = this.branch_email; other.shippingMobilePhone = this.shippingMobilePhone; other.totalItems = this.totalItems; } public void copyKeysDataTo(dataStruct other) { other.id = this.id; } private String readString(ObjectInputStream dis) throws IOException { String strReturn = null; int length = 0; length = dis.readInt(); if (length == -1) { strReturn = null; } else { if (length > commonByteArray_ZUORA_OTS_Subscription.length) { if (length < 1024 && commonByteArray_ZUORA_OTS_Subscription.length == 0) { commonByteArray_ZUORA_OTS_Subscription = new byte[1024]; } else { commonByteArray_ZUORA_OTS_Subscription = new byte[2 * length]; } } dis.readFully(commonByteArray_ZUORA_OTS_Subscription, 0, length); strReturn = new String(commonByteArray_ZUORA_OTS_Subscription, 0, length, utf8Charset); } return strReturn; } private void writeString(String str, ObjectOutputStream dos) throws IOException { if (str == null) { dos.writeInt(-1); } else { byte[] byteArray = str.getBytes(utf8Charset); dos.writeInt(byteArray.length); dos.write(byteArray); } } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.id = dis.readLong(); this.promoID = readString(dis); this.subscriber_surname = readString(dis); this.subscriber_name = readString(dis); this.subscriber_type = readString(dis); this.orderer_surname = readString(dis); this.orderer_name = readString(dis); this.orderer_taxCode = readString(dis); this.orderer_VATRegistrationNumber = readString(dis); this.residenceAddress_street = readString(dis); this.residenceAddress_zipCode = readString(dis); this.residenceAddress_city = readString(dis); this.residenceAddress_province = readString(dis); this.residenceAddress_state = readString(dis); this.shippingAddress_surname = readString(dis); this.shippingAddress_name = readString(dis); this.shippingAddress_careOf = readString(dis); this.shippingAddress_street = readString(dis); this.shippingAddress_zipCode = readString(dis); this.shippingAddress_city = readString(dis); this.shippingAddress_province = readString(dis); this.shippingAddress_state = readString(dis); this.orderer_email = readString(dis); this.orderer_mobilePhone = readString(dis); this.product_code = readString(dis); this.product_description = readString(dis); this.product_itemsNumber = readString(dis); this.product_price = readString(dis); this.VATRate = readString(dis); this.registrationDate = readString(dis); this.paymentMethod = readString(dis); this.paymentDate = readString(dis); this.creditTransferIBAN = readString(dis); this.transactionReference = readString(dis); this.branch_phone = readString(dis); this.branch_email = readString(dis); this.shippingMobilePhone = readString(dis); this.totalItems = dis.readInt(); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // long dos.writeLong(this.id); // String writeString(this.promoID, dos); // String writeString(this.subscriber_surname, dos); // String writeString(this.subscriber_name, dos); // String writeString(this.subscriber_type, dos); // String writeString(this.orderer_surname, dos); // String writeString(this.orderer_name, dos); // String writeString(this.orderer_taxCode, dos); // String writeString(this.orderer_VATRegistrationNumber, dos); // String writeString(this.residenceAddress_street, dos); // String writeString(this.residenceAddress_zipCode, dos); // String writeString(this.residenceAddress_city, dos); // String writeString(this.residenceAddress_province, dos); // String writeString(this.residenceAddress_state, dos); // String writeString(this.shippingAddress_surname, dos); // String writeString(this.shippingAddress_name, dos); // String writeString(this.shippingAddress_careOf, dos); // String writeString(this.shippingAddress_street, dos); // String writeString(this.shippingAddress_zipCode, dos); // String writeString(this.shippingAddress_city, dos); // String writeString(this.shippingAddress_province, dos); // String writeString(this.shippingAddress_state, dos); // String writeString(this.orderer_email, dos); // String writeString(this.orderer_mobilePhone, dos); // String writeString(this.product_code, dos); // String writeString(this.product_description, dos); // String writeString(this.product_itemsNumber, dos); // String writeString(this.product_price, dos); // String writeString(this.VATRate, dos); // String writeString(this.registrationDate, dos); // String writeString(this.paymentMethod, dos); // String writeString(this.paymentDate, dos); // String writeString(this.creditTransferIBAN, dos); // String writeString(this.transactionReference, dos); // String writeString(this.branch_phone, dos); // String writeString(this.branch_email, dos); // String writeString(this.shippingMobilePhone, dos); // int dos.writeInt(this.totalItems); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("id=" + String.valueOf(id)); sb.append(",promoID=" + promoID); sb.append(",subscriber_surname=" + subscriber_surname); sb.append(",subscriber_name=" + subscriber_name); sb.append(",subscriber_type=" + subscriber_type); sb.append(",orderer_surname=" + orderer_surname); sb.append(",orderer_name=" + orderer_name); sb.append(",orderer_taxCode=" + orderer_taxCode); sb.append(",orderer_VATRegistrationNumber=" + orderer_VATRegistrationNumber); sb.append(",residenceAddress_street=" + residenceAddress_street); sb.append(",residenceAddress_zipCode=" + residenceAddress_zipCode); sb.append(",residenceAddress_city=" + residenceAddress_city); sb.append(",residenceAddress_province=" + residenceAddress_province); sb.append(",residenceAddress_state=" + residenceAddress_state); sb.append(",shippingAddress_surname=" + shippingAddress_surname); sb.append(",shippingAddress_name=" + shippingAddress_name); sb.append(",shippingAddress_careOf=" + shippingAddress_careOf); sb.append(",shippingAddress_street=" + shippingAddress_street); sb.append(",shippingAddress_zipCode=" + shippingAddress_zipCode); sb.append(",shippingAddress_city=" + shippingAddress_city); sb.append(",shippingAddress_province=" + shippingAddress_province); sb.append(",shippingAddress_state=" + shippingAddress_state); sb.append(",orderer_email=" + orderer_email); sb.append(",orderer_mobilePhone=" + orderer_mobilePhone); sb.append(",product_code=" + product_code); sb.append(",product_description=" + product_description); sb.append(",product_itemsNumber=" + product_itemsNumber); sb.append(",product_price=" + product_price); sb.append(",VATRate=" + VATRate); sb.append(",registrationDate=" + registrationDate); sb.append(",paymentMethod=" + paymentMethod); sb.append(",paymentDate=" + paymentDate); sb.append(",creditTransferIBAN=" + creditTransferIBAN); sb.append(",transactionReference=" + transactionReference); sb.append(",branch_phone=" + branch_phone); sb.append(",branch_email=" + branch_email); sb.append(",shippingMobilePhone=" + shippingMobilePhone); sb.append(",totalItems=" + String.valueOf(totalItems)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(dataStruct other) { int returnValue = -1; returnValue = checkNullsAndCompare(this.id, other.id); if (returnValue != 0) { return returnValue; } return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } public static class row2Struct implements routines.system.IPersistableRow<row2Struct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; public long count; public long getCount() { return this.count; } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.count = dis.readLong(); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // long dos.writeLong(this.count); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("count=" + String.valueOf(count)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(row2Struct other) { int returnValue = -1; return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } public void tMysqlInput_2Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tMysqlInput_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 { 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(); dataStruct data = new dataStruct(); /** * [tFlowToIterate_1 begin ] start */ int NB_ITERATE_tLoop_1 = 0; // for statistics ok_Hash.put("tFlowToIterate_1", false); start_Hash.put("tFlowToIterate_1", System.currentTimeMillis()); currentComponent = "tFlowToIterate_1"; int tos_count_tFlowToIterate_1 = 0; int nb_line_tFlowToIterate_1 = 0; int counter_tFlowToIterate_1 = 0; /** * [tFlowToIterate_1 begin ] stop */ /** * [tMysqlInput_2 begin ] start */ ok_Hash.put("tMysqlInput_2", false); start_Hash.put("tMysqlInput_2", System.currentTimeMillis()); currentComponent = "tMysqlInput_2"; int tos_count_tMysqlInput_2 = 0; java.util.Calendar calendar_tMysqlInput_2 = java.util.Calendar.getInstance(); calendar_tMysqlInput_2.set(0, 0, 0, 0, 0, 0); java.util.Date year0_tMysqlInput_2 = calendar_tMysqlInput_2.getTime(); int nb_line_tMysqlInput_2 = 0; java.sql.Connection conn_tMysqlInput_2 = null; String driverClass_tMysqlInput_2 = "org.gjt.mm.mysql.Driver"; java.lang.Class.forName(driverClass_tMysqlInput_2); String dbUser_tMysqlInput_2 = "root"; final String decryptedPassword_tMysqlInput_2 = routines.system.PasswordEncryptUtil .decryptPassword("7a440551249af37a"); String dbPwd_tMysqlInput_2 = decryptedPassword_tMysqlInput_2; String url_tMysqlInput_2 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + "noDatetimeStringSync=true"; conn_tMysqlInput_2 = java.sql.DriverManager.getConnection(url_tMysqlInput_2, dbUser_tMysqlInput_2, dbPwd_tMysqlInput_2); java.sql.Statement stmt_tMysqlInput_2 = conn_tMysqlInput_2.createStatement(); String dbquery_tMysqlInput_2 = "SELECT COUNT(*) as count\nFROM `ots_order`"; globalMap.put("tMysqlInput_2_QUERY", dbquery_tMysqlInput_2); java.sql.ResultSet rs_tMysqlInput_2 = null; try { rs_tMysqlInput_2 = stmt_tMysqlInput_2.executeQuery(dbquery_tMysqlInput_2); java.sql.ResultSetMetaData rsmd_tMysqlInput_2 = rs_tMysqlInput_2.getMetaData(); int colQtyInRs_tMysqlInput_2 = rsmd_tMysqlInput_2.getColumnCount(); String tmpContent_tMysqlInput_2 = null; while (rs_tMysqlInput_2.next()) { nb_line_tMysqlInput_2++; if (colQtyInRs_tMysqlInput_2 < 1) { row2.count = 0; } else { if (rs_tMysqlInput_2.getObject(1) != null) { row2.count = rs_tMysqlInput_2.getLong(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } /** * [tMysqlInput_2 begin ] stop */ /** * [tMysqlInput_2 main ] start */ currentComponent = "tMysqlInput_2"; tos_count_tMysqlInput_2++; /** * [tMysqlInput_2 main ] stop */ /** * [tFlowToIterate_1 main ] start */ currentComponent = "tFlowToIterate_1"; globalMap.put("accounts_total", row2.count); nb_line_tFlowToIterate_1++; counter_tFlowToIterate_1++; globalMap.put("tFlowToIterate_1_CURRENT_ITERATION", counter_tFlowToIterate_1); tos_count_tFlowToIterate_1++; /** * [tFlowToIterate_1 main ] stop */ NB_ITERATE_tLoop_1++; /** * [tLoop_1 begin ] start */ int NB_ITERATE_tMysqlInput_3 = 0; // for statistics ok_Hash.put("tLoop_1", false); start_Hash.put("tLoop_1", System.currentTimeMillis()); currentComponent = "tLoop_1"; int tos_count_tLoop_1 = 0; int current_iteration_tLoop_1 = 0; for (int looptLoop_1 = 0; looptLoop_1 <= ((long) globalMap.get("accounts_total")) - 1; looptLoop_1 = looptLoop_1 + ((int) globalMap.get("accounts_at_time"))) { current_iteration_tLoop_1++; globalMap.put("tLoop_1_CURRENT_VALUE", looptLoop_1); globalMap.put("tLoop_1_CURRENT_ITERATION", current_iteration_tLoop_1); /** * [tLoop_1 begin ] stop */ /** * [tLoop_1 main ] start */ currentComponent = "tLoop_1"; tos_count_tLoop_1++; /** * [tLoop_1 main ] stop */ NB_ITERATE_tMysqlInput_3++; /** * [tJavaFlex_1 begin ] start */ ok_Hash.put("tJavaFlex_1", false); start_Hash.put("tJavaFlex_1", System.currentTimeMillis()); currentComponent = "tJavaFlex_1"; int tos_count_tJavaFlex_1 = 0; String request = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns2=\"http://object.api.zuora.com/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ns1=\"http://api.zuora.com/\">" + "<SOAP-ENV:Header>" + "<ns1:SessionHeader>" + "<ns1:session>" + ((String) globalMap.get("session_key")) + "</ns1:session>" + "</ns1:SessionHeader>" + "</SOAP-ENV:Header>" + "<SOAP-ENV:Body>" + "<ns1:subscribe>"; String endRequest = "</ns1:subscribe></SOAP-ENV:Body></SOAP-ENV:Envelope>"; /** * [tJavaFlex_1 begin ] stop */ /** * [tMysqlInput_3 begin ] start */ ok_Hash.put("tMysqlInput_3", false); start_Hash.put("tMysqlInput_3", System.currentTimeMillis()); currentComponent = "tMysqlInput_3"; int tos_count_tMysqlInput_3 = 0; java.util.Calendar calendar_tMysqlInput_3 = java.util.Calendar.getInstance(); calendar_tMysqlInput_3.set(0, 0, 0, 0, 0, 0); java.util.Date year0_tMysqlInput_3 = calendar_tMysqlInput_3.getTime(); int nb_line_tMysqlInput_3 = 0; java.sql.Connection conn_tMysqlInput_3 = null; String driverClass_tMysqlInput_3 = "org.gjt.mm.mysql.Driver"; java.lang.Class.forName(driverClass_tMysqlInput_3); String dbUser_tMysqlInput_3 = "root"; final String decryptedPassword_tMysqlInput_3 = routines.system.PasswordEncryptUtil .decryptPassword("7a440551249af37a"); String dbPwd_tMysqlInput_3 = decryptedPassword_tMysqlInput_3; String url_tMysqlInput_3 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + "noDatetimeStringSync=true"; conn_tMysqlInput_3 = java.sql.DriverManager.getConnection(url_tMysqlInput_3, dbUser_tMysqlInput_3, dbPwd_tMysqlInput_3); java.sql.Statement stmt_tMysqlInput_3 = conn_tMysqlInput_3.createStatement(); String dbquery_tMysqlInput_3 = "SELECT \n `ots_order`.`id`, \n `ots_order`.`promoID`, \n `ots_order`.`subscriber_surname`, \n `ots_order`.`subscriber_name`, \n `ots_order`.`subscriber_type`, \n `ots_order`.`orderer_surname`, \n `ots_order`.`orderer_name`, \n `ots_order`.`orderer_taxCode`, \n `ots_order`.`orderer_VATRegistrationNumber`, \n `ots_order`.`residenceAddress_street`, \n `ots_order`.`residenceAddress_zipCode`, \n `ots_order`.`residenceAddress_city`, \n `ots_order`.`residenceAddress_province`, \n `ots_order`.`residenceAddress_state`, \n `ots_order`.`shippingAddress_surname`, \n `ots_order`.`shippingAddress_name`, \n `ots_order`.`shippingAddress_careOf`, \n `ots_order`.`shippingAddress_street`, \n `ots_order`.`shippingAddress_zipCode`, \n `ots_order`.`shippingAddress_city`, \n `ots_order`.`shippingAddress_province`, \n `ots_order`.`shippingAddress_state`, \n `ots_order`.`orderer_email`, \n `ots_order`.`orderer_mobilePhone`, \n `ots_order`.`product_code`, \n `ots_order`.`product_description`, \n `ots_order`.`product_itemsNumber`, \n `ots_order`.`product_price`, \n `ots_order`.`VATRate`, \n `ots_order`.`registrationDate`, \n `ots_order`.`paymentMethod`, \n `ots_order`.`paymentDate`, \n `ots_order`.`creditTransferIBAN`, \n `ots_order`.`transactionReference`, \n `ots_order`.`branch_phone`, \n `ots_order`.`branch_email`, \n `ots_order`.`shippingMobilePhone`, \n `ots_order`.`totalItems`\nFROM `ots_order`\nLIMIT " + globalMap.get("tLoop_1_CURRENT_VALUE") + "," + globalMap.get("accounts_at_time"); globalMap.put("tMysqlInput_3_QUERY", dbquery_tMysqlInput_3); java.sql.ResultSet rs_tMysqlInput_3 = null; try { rs_tMysqlInput_3 = stmt_tMysqlInput_3.executeQuery(dbquery_tMysqlInput_3); java.sql.ResultSetMetaData rsmd_tMysqlInput_3 = rs_tMysqlInput_3.getMetaData(); int colQtyInRs_tMysqlInput_3 = rsmd_tMysqlInput_3.getColumnCount(); String tmpContent_tMysqlInput_3 = null; while (rs_tMysqlInput_3.next()) { nb_line_tMysqlInput_3++; if (colQtyInRs_tMysqlInput_3 < 1) { data.id = 0; } else { if (rs_tMysqlInput_3.getObject(1) != null) { data.id = rs_tMysqlInput_3.getLong(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_3 < 2) { data.promoID = null; } else { data.promoID = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 2, false); } if (colQtyInRs_tMysqlInput_3 < 3) { data.subscriber_surname = null; } else { data.subscriber_surname = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 3, false); } if (colQtyInRs_tMysqlInput_3 < 4) { data.subscriber_name = null; } else { data.subscriber_name = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 4, false); } if (colQtyInRs_tMysqlInput_3 < 5) { data.subscriber_type = null; } else { data.subscriber_type = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 5, false); } if (colQtyInRs_tMysqlInput_3 < 6) { data.orderer_surname = null; } else { data.orderer_surname = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 6, false); } if (colQtyInRs_tMysqlInput_3 < 7) { data.orderer_name = null; } else { data.orderer_name = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 7, false); } if (colQtyInRs_tMysqlInput_3 < 8) { data.orderer_taxCode = null; } else { data.orderer_taxCode = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 8, false); } if (colQtyInRs_tMysqlInput_3 < 9) { data.orderer_VATRegistrationNumber = null; } else { data.orderer_VATRegistrationNumber = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 9, false); } if (colQtyInRs_tMysqlInput_3 < 10) { data.residenceAddress_street = null; } else { data.residenceAddress_street = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 10, false); } if (colQtyInRs_tMysqlInput_3 < 11) { data.residenceAddress_zipCode = null; } else { data.residenceAddress_zipCode = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 11, false); } if (colQtyInRs_tMysqlInput_3 < 12) { data.residenceAddress_city = null; } else { data.residenceAddress_city = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 12, false); } if (colQtyInRs_tMysqlInput_3 < 13) { data.residenceAddress_province = null; } else { data.residenceAddress_province = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 13, false); } if (colQtyInRs_tMysqlInput_3 < 14) { data.residenceAddress_state = null; } else { data.residenceAddress_state = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 14, false); } if (colQtyInRs_tMysqlInput_3 < 15) { data.shippingAddress_surname = null; } else { data.shippingAddress_surname = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 15, false); } if (colQtyInRs_tMysqlInput_3 < 16) { data.shippingAddress_name = null; } else { data.shippingAddress_name = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 16, false); } if (colQtyInRs_tMysqlInput_3 < 17) { data.shippingAddress_careOf = null; } else { data.shippingAddress_careOf = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 17, false); } if (colQtyInRs_tMysqlInput_3 < 18) { data.shippingAddress_street = null; } else { data.shippingAddress_street = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 18, false); } if (colQtyInRs_tMysqlInput_3 < 19) { data.shippingAddress_zipCode = null; } else { data.shippingAddress_zipCode = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 19, false); } if (colQtyInRs_tMysqlInput_3 < 20) { data.shippingAddress_city = null; } else { data.shippingAddress_city = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 20, false); } if (colQtyInRs_tMysqlInput_3 < 21) { data.shippingAddress_province = null; } else { data.shippingAddress_province = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 21, false); } if (colQtyInRs_tMysqlInput_3 < 22) { data.shippingAddress_state = null; } else { data.shippingAddress_state = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 22, false); } if (colQtyInRs_tMysqlInput_3 < 23) { data.orderer_email = null; } else { data.orderer_email = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 23, false); } if (colQtyInRs_tMysqlInput_3 < 24) { data.orderer_mobilePhone = null; } else { data.orderer_mobilePhone = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 24, false); } if (colQtyInRs_tMysqlInput_3 < 25) { data.product_code = null; } else { data.product_code = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 25, false); } if (colQtyInRs_tMysqlInput_3 < 26) { data.product_description = null; } else { data.product_description = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 26, false); } if (colQtyInRs_tMysqlInput_3 < 27) { data.product_itemsNumber = null; } else { data.product_itemsNumber = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 27, false); } if (colQtyInRs_tMysqlInput_3 < 28) { data.product_price = null; } else { data.product_price = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 28, false); } if (colQtyInRs_tMysqlInput_3 < 29) { data.VATRate = null; } else { data.VATRate = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 29, false); } if (colQtyInRs_tMysqlInput_3 < 30) { data.registrationDate = null; } else { data.registrationDate = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 30, false); } if (colQtyInRs_tMysqlInput_3 < 31) { data.paymentMethod = null; } else { data.paymentMethod = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 31, false); } if (colQtyInRs_tMysqlInput_3 < 32) { data.paymentDate = null; } else { data.paymentDate = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 32, false); } if (colQtyInRs_tMysqlInput_3 < 33) { data.creditTransferIBAN = null; } else { data.creditTransferIBAN = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 33, false); } if (colQtyInRs_tMysqlInput_3 < 34) { data.transactionReference = null; } else { data.transactionReference = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 34, false); } if (colQtyInRs_tMysqlInput_3 < 35) { data.branch_phone = null; } else { data.branch_phone = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 35, false); } if (colQtyInRs_tMysqlInput_3 < 36) { data.branch_email = null; } else { data.branch_email = routines.system.JDBCUtil.getString(rs_tMysqlInput_3, 36, false); } if (colQtyInRs_tMysqlInput_3 < 37) { data.shippingMobilePhone = null; } else { data.shippingMobilePhone = routines.system.JDBCUtil .getString(rs_tMysqlInput_3, 37, false); } if (colQtyInRs_tMysqlInput_3 < 38) { data.totalItems = 0; } else { if (rs_tMysqlInput_3.getObject(38) != null) { data.totalItems = rs_tMysqlInput_3.getInt(38); } else { throw new RuntimeException("Null value in non-Nullable column"); } } /** * [tMysqlInput_3 begin ] stop */ /** * [tMysqlInput_3 main ] start */ currentComponent = "tMysqlInput_3"; tos_count_tMysqlInput_3++; /** * [tMysqlInput_3 main ] stop */ /** * [tJavaFlex_1 main ] start */ currentComponent = "tJavaFlex_1"; request += "<ns1:subscribes>" + "<ns1:Account>" + "<ns2:Name>" + TalendString.replaceSpecialCharForXML(data.orderer_surname) + "</ns2:Name>" + "<ns2:VATId>" + data.orderer_VATRegistrationNumber + "</ns2:VATId>" + "<ns2:VATIDSEARCH__c>" + data.orderer_VATRegistrationNumber + "</ns2:VATIDSEARCH__c>" + "<ns2:Tax__c>" + data.orderer_taxCode + "</ns2:Tax__c>" + "<ns2:Currency>EUR</ns2:Currency>" + "<ns2:AutoPay>false</ns2:AutoPay>" + "<ns2:BillCycleDay>0</ns2:BillCycleDay>" + "<ns2:BcdSettingOption>AutoSet</ns2:BcdSettingOption>" + "<ns2:PaymentTerm>Net 30</ns2:PaymentTerm>" + "<ns2:Status>Active</ns2:Status>" + "<ns2:Batch>Batch1</ns2:Batch>" + "</ns1:Account>" + "<ns1:PaymentMethod xsi:type=\"ns2:PaymentMethod\">" + "<ns2:Id>" + ((String) globalMap.get("payment_method_other")) + "</ns2:Id>" + "</ns1:PaymentMethod>" + "<ns1:BillToContact>" + "<ns2:FirstName>" + (data.orderer_name.equals("") ? "-" : TalendString.replaceSpecialCharForXML(data.orderer_name)) + "</ns2:FirstName>" + "<ns2:LastName>" + TalendString.replaceSpecialCharForXML(data.orderer_surname) + "</ns2:LastName>" + "<ns2:Address1>" + data.residenceAddress_street + "</ns2:Address1>" + "<ns2:PostalCode>" + data.residenceAddress_zipCode + "</ns2:PostalCode>" + "<ns2:City>" + data.residenceAddress_city + "</ns2:City>" + "<ns2:State>" + data.residenceAddress_province + "</ns2:State>" + "<ns2:Country>" + data.residenceAddress_state + "</ns2:Country>" + "<ns2:WorkEmail>" + data.orderer_email + "</ns2:WorkEmail>" + "<ns2:MobilePhone>" + data.orderer_mobilePhone + "</ns2:MobilePhone>" + "</ns1:BillToContact>" + "<ns1:SoldToContact>" + "<ns2:FirstName>" + (data.shippingAddress_name.equals("") ? "-" : TalendString .replaceSpecialCharForXML(data.shippingAddress_name)) + "</ns2:FirstName>" + "<ns2:LastName>" + TalendString.replaceSpecialCharForXML(data.shippingAddress_surname) + "</ns2:LastName>" + "<ns2:Address1>" + data.shippingAddress_street + "</ns2:Address1>" + "<ns2:PostalCode>" + data.shippingAddress_zipCode + "</ns2:PostalCode>" + "<ns2:City>" + data.shippingAddress_city + "</ns2:City>" + "<ns2:State>" + data.shippingAddress_province + "</ns2:State>" + "<ns2:Country>" + data.shippingAddress_state + "</ns2:Country>" + "<ns2:MobilePhone>" + data.shippingMobilePhone + "</ns2:MobilePhone>" + "<ns2:CareOF__c>" + TalendString.replaceSpecialCharForXML(data.shippingAddress_careOf) + "</ns2:CareOF__c>" + "</ns1:SoldToContact>" + "<ns1:SubscribeOptions>" + "<ns1:ApplyCreditBalance>false</ns1:ApplyCreditBalance>" + "<ns1:GenerateInvoice>false</ns1:GenerateInvoice>" + "<ns1:ProcessPayments>false</ns1:ProcessPayments>" + "</ns1:SubscribeOptions>" + "<ns1:SubscriptionData>" + "<ns1:Subscription>" + "<ns2:Name>" + data.promoID + "</ns2:Name>" + "<ns2:ContractEffectiveDate>" + data.registrationDate + "</ns2:ContractEffectiveDate>" + "<ns2:ServiceActivationDate>" + data.registrationDate + "</ns2:ServiceActivationDate>" + "<ns2:ContractAcceptanceDate>" + data.registrationDate + "</ns2:ContractAcceptanceDate>" + "<ns2:RenewalTerm>0</ns2:RenewalTerm>" + "<ns2:TermType>TERMED</ns2:TermType>" + "<ns2:AutoRenew>false</ns2:AutoRenew>" + "<ns2:InitialTerm>24</ns2:InitialTerm>" + "<ns2:RenewalSetting>RENEW_TO_EVERGREEN</ns2:RenewalSetting>" + "<ns2:IsInvoiceSeparate>FALSE</ns2:IsInvoiceSeparate>" + "<ns2:SubscriberSurname__c>" + TalendString.replaceSpecialCharForXML(data.subscriber_surname) + "</ns2:SubscriberSurname__c>" + "<ns2:SubscriberName__c>" + TalendString.replaceSpecialCharForXML(data.subscriber_name) + "</ns2:SubscriberName__c>" + "<ns2:SubscriberType__c>" + data.subscriber_type + "</ns2:SubscriberType__c>" + "<ns2:paymentMethod__c>" + data.paymentMethod + "</ns2:paymentMethod__c>" + "<ns2:creditTransferIBAN__c>" + data.creditTransferIBAN + "</ns2:creditTransferIBAN__c>" + "<ns2:transactionReference__c>" + TalendString.replaceSpecialCharForXML(data.transactionReference) + "</ns2:transactionReference__c>" + "<ns2:branch_phone__c>" + TalendString.replaceSpecialCharForXML(data.branch_phone) + "</ns2:branch_phone__c>" + "<ns2:branch_email__c>" + TalendString.replaceSpecialCharForXML(data.branch_email) + "</ns2:branch_email__c>" + "<ns2:OrderStatus__c>Ricevuto</ns2:OrderStatus__c>" + "</ns1:Subscription>" + "<ns1:RatePlanData>" + "<ns1:RatePlan>" + "<ns2:ProductRatePlanId>" + (Relational.ISNULL(data.VATRate) || data.VATRate.equals("") ? ((String) globalMap.get("product_rate_plan_22")) : ((String) globalMap.get("product_rate_plan_0"))) + "</ns2:ProductRatePlanId>" + "</ns1:RatePlan>" + "</ns1:RatePlanData>" + "</ns1:SubscriptionData>" + "</ns1:subscribes>"; tos_count_tJavaFlex_1++; /** * [tJavaFlex_1 main ] stop */ /** * [tMysqlInput_3 end ] start */ currentComponent = "tMysqlInput_3"; } } finally { if (rs_tMysqlInput_3 != null) { rs_tMysqlInput_3.close(); } stmt_tMysqlInput_3.close(); if (conn_tMysqlInput_3 != null && !conn_tMysqlInput_3.isClosed()) { conn_tMysqlInput_3.close(); } } globalMap.put("tMysqlInput_3_NB_LINE", nb_line_tMysqlInput_3); ok_Hash.put("tMysqlInput_3", true); end_Hash.put("tMysqlInput_3", System.currentTimeMillis()); /** * [tMysqlInput_3 end ] stop */ /** * [tJavaFlex_1 end ] start */ currentComponent = "tJavaFlex_1"; globalMap.put("request", request + endRequest); System.out.println("request: " + globalMap.get("request")); ok_Hash.put("tJavaFlex_1", true); end_Hash.put("tJavaFlex_1", System.currentTimeMillis()); tSOAP_1Process(globalMap); /** * [tJavaFlex_1 end ] stop */ /** * [tLoop_1 end ] start */ currentComponent = "tLoop_1"; } ok_Hash.put("tLoop_1", true); end_Hash.put("tLoop_1", System.currentTimeMillis()); /** * [tLoop_1 end ] stop */ /** * [tMysqlInput_2 end ] start */ currentComponent = "tMysqlInput_2"; } } finally { if (rs_tMysqlInput_2 != null) { rs_tMysqlInput_2.close(); } stmt_tMysqlInput_2.close(); if (conn_tMysqlInput_2 != null && !conn_tMysqlInput_2.isClosed()) { conn_tMysqlInput_2.close(); } } globalMap.put("tMysqlInput_2_NB_LINE", nb_line_tMysqlInput_2); ok_Hash.put("tMysqlInput_2", true); end_Hash.put("tMysqlInput_2", System.currentTimeMillis()); /** * [tMysqlInput_2 end ] stop */ /** * [tFlowToIterate_1 end ] start */ currentComponent = "tFlowToIterate_1"; globalMap.put("tFlowToIterate_1_NB_LINE", nb_line_tFlowToIterate_1); ok_Hash.put("tFlowToIterate_1", true); end_Hash.put("tFlowToIterate_1", System.currentTimeMillis()); /** * [tFlowToIterate_1 end ] stop */ } // end the resume if (resumeEntryMethodName == null || globalResumeTicket) { resumeUtil.addLog("CHECKPOINT", "CONNECTION:SUBJOB_OK:tMysqlInput_2:OnSubjobOk", "", Thread.currentThread().getId() + "", "", "", "", "", ""); } tFixedFlowInput_1Process(globalMap); } catch (java.lang.Exception e) { TalendException te = new TalendException(e, currentComponent, globalMap); throw te; } catch (java.lang.Error error) { throw error; } finally { try { /** * [tMysqlInput_2 finally ] start */ currentComponent = "tMysqlInput_2"; /** * [tMysqlInput_2 finally ] stop */ /** * [tFlowToIterate_1 finally ] start */ currentComponent = "tFlowToIterate_1"; /** * [tFlowToIterate_1 finally ] stop */ /** * [tLoop_1 finally ] start */ currentComponent = "tLoop_1"; /** * [tLoop_1 finally ] stop */ /** * [tMysqlInput_3 finally ] start */ currentComponent = "tMysqlInput_3"; /** * [tMysqlInput_3 finally ] stop */ /** * [tJavaFlex_1 finally ] start */ currentComponent = "tJavaFlex_1"; /** * [tJavaFlex_1 finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tMysqlInput_2_SUBPROCESS_STATE", 1); } public static class row4Struct implements routines.system.IPersistableRow<row4Struct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; public routines.system.Document Soap; public routines.system.Document getSoap() { return this.Soap; } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.Soap = (routines.system.Document) dis.readObject(); } catch (IOException e) { throw new RuntimeException(e); } catch (ClassNotFoundException eCNFE) { throw new RuntimeException(eCNFE); } } } public void writeData(ObjectOutputStream dos) { try { // Document dos.writeObject(this.Soap); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("Soap=" + String.valueOf(Soap)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(row4Struct other) { int returnValue = -1; return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } public void tSOAP_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tSOAP_1_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 { String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row4Struct row4 = new row4Struct(); /** * [tFileOutputXML_1 begin ] start */ ok_Hash.put("tFileOutputXML_1", false); start_Hash.put("tFileOutputXML_1", System.currentTimeMillis()); currentComponent = "tFileOutputXML_1"; int tos_count_tFileOutputXML_1 = 0; String originalFileName_tFileOutputXML_1 = "C:/ETL_FASTWEB/ZUORA/data/responses/ots/subscribe-" + globalMap.get("tLoop_1_CURRENT_VALUE") + ".xml"; java.io.File originalFile_tFileOutputXML_1 = new java.io.File(originalFileName_tFileOutputXML_1); String fileName_tFileOutputXML_1 = originalFileName_tFileOutputXML_1; java.io.File file_tFileOutputXML_1 = new java.io.File(fileName_tFileOutputXML_1); if (!file_tFileOutputXML_1.isAbsolute()) { file_tFileOutputXML_1 = file_tFileOutputXML_1.getCanonicalFile(); } // create directory only if not exists file_tFileOutputXML_1.getParentFile().mkdirs(); int nb_line_tFileOutputXML_1 = 0; org.dom4j.io.OutputFormat format_tFileOutputXML_1 = org.dom4j.io.OutputFormat.createPrettyPrint(); format_tFileOutputXML_1.setEncoding("ISO-8859-15"); format_tFileOutputXML_1.setNewLineAfterDeclaration(false); format_tFileOutputXML_1.setTrimText(false); org.dom4j.io.XMLWriter writer_tFileOutputXML_1 = new org.dom4j.io.XMLWriter( new java.io.OutputStreamWriter(new java.io.FileOutputStream(file_tFileOutputXML_1), "ISO-8859-15"), format_tFileOutputXML_1); /** * [tFileOutputXML_1 begin ] stop */ /** * [tSOAP_1 begin ] start */ ok_Hash.put("tSOAP_1", false); start_Hash.put("tSOAP_1", System.currentTimeMillis()); currentComponent = "tSOAP_1"; int tos_count_tSOAP_1 = 0; org.talend.soap.SOAPUtil soapUtil_tSOAP_1 = new org.talend.soap.SOAPUtil(); final String decryptedPassword_tSOAP_1 = routines.system.PasswordEncryptUtil .decryptPassword("a54bbfcc1190b7e1f4f7aba1746784ea"); /** * [tSOAP_1 begin ] stop */ /** * [tSOAP_1 main ] start */ currentComponent = "tSOAP_1"; String document_tSOAP_1 = soapUtil_tSOAP_1.extractContentAsDocument(org.talend.soap.SOAPUtil.SOAP11, ((String) globalMap.get("server_url")), "http://api.zuora.com/subscribe", "" + (String) globalMap.get("request")); // for output row4 = new row4Struct(); row4.Soap = ParserUtils.parseTo_Document(document_tSOAP_1); tos_count_tSOAP_1++; /** * [tSOAP_1 main ] stop */ /** * [tFileOutputXML_1 main ] start */ currentComponent = "tFileOutputXML_1"; nb_line_tFileOutputXML_1++; writer_tFileOutputXML_1.write(row4.Soap.getDocument()); tos_count_tFileOutputXML_1++; /** * [tFileOutputXML_1 main ] stop */ /** * [tSOAP_1 end ] start */ currentComponent = "tSOAP_1"; soapUtil_tSOAP_1.close(); ok_Hash.put("tSOAP_1", true); end_Hash.put("tSOAP_1", System.currentTimeMillis()); /** * [tSOAP_1 end ] stop */ /** * [tFileOutputXML_1 end ] start */ currentComponent = "tFileOutputXML_1"; writer_tFileOutputXML_1.close(); ok_Hash.put("tFileOutputXML_1", true); end_Hash.put("tFileOutputXML_1", System.currentTimeMillis()); /** * [tFileOutputXML_1 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 { /** * [tSOAP_1 finally ] start */ currentComponent = "tSOAP_1"; /** * [tSOAP_1 finally ] stop */ /** * [tFileOutputXML_1 finally ] start */ currentComponent = "tFileOutputXML_1"; /** * [tFileOutputXML_1 finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tSOAP_1_SUBPROCESS_STATE", 1); } public static class stage_OKStruct implements routines.system.IPersistableRow<stage_OKStruct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; protected static final int DEFAULT_HASHCODE = 1; protected static final int PRIME = 31; protected int hashCode = DEFAULT_HASHCODE; public boolean hashCodeDirty = true; public String loopKey; public long id; public long getId() { return this.id; } public Object stage; public Object getStage() { return this.stage; } public Object result; public Object getResult() { return this.result; } public String error; public String getError() { return this.error; } public String server_url; public String getServer_url() { return this.server_url; } public String session; public String getSession() { return this.session; } public java.util.Date timestamp; public java.util.Date getTimestamp() { return this.timestamp; } @Override public int hashCode() { if (this.hashCodeDirty) { final int prime = PRIME; int result = DEFAULT_HASHCODE; result = prime * result + (int) this.id; this.hashCode = result; this.hashCodeDirty = false; } return this.hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final stage_OKStruct other = (stage_OKStruct) obj; if (this.id != other.id) return false; return true; } public void copyDataTo(stage_OKStruct other) { other.id = this.id; other.stage = this.stage; other.result = this.result; other.error = this.error; other.server_url = this.server_url; other.session = this.session; other.timestamp = this.timestamp; } public void copyKeysDataTo(stage_OKStruct other) { other.id = this.id; } private String readString(ObjectInputStream dis) throws IOException { String strReturn = null; int length = 0; length = dis.readInt(); if (length == -1) { strReturn = null; } else { if (length > commonByteArray_ZUORA_OTS_Subscription.length) { if (length < 1024 && commonByteArray_ZUORA_OTS_Subscription.length == 0) { commonByteArray_ZUORA_OTS_Subscription = new byte[1024]; } else { commonByteArray_ZUORA_OTS_Subscription = new byte[2 * length]; } } dis.readFully(commonByteArray_ZUORA_OTS_Subscription, 0, length); strReturn = new String(commonByteArray_ZUORA_OTS_Subscription, 0, length, utf8Charset); } return strReturn; } private void writeString(String str, ObjectOutputStream dos) throws IOException { if (str == null) { dos.writeInt(-1); } else { byte[] byteArray = str.getBytes(utf8Charset); dos.writeInt(byteArray.length); dos.write(byteArray); } } private java.util.Date readDate(ObjectInputStream dis) throws IOException { java.util.Date dateReturn = null; int length = 0; length = dis.readByte(); if (length == -1) { dateReturn = null; } else { dateReturn = new Date(dis.readLong()); } return dateReturn; } private void writeDate(java.util.Date date1, ObjectOutputStream dos) throws IOException { if (date1 == null) { dos.writeByte(-1); } else { dos.writeByte(0); dos.writeLong(date1.getTime()); } } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.id = dis.readLong(); this.stage = (Object) dis.readObject(); this.result = (Object) dis.readObject(); this.error = readString(dis); this.server_url = readString(dis); this.session = readString(dis); this.timestamp = readDate(dis); } catch (IOException e) { throw new RuntimeException(e); } catch (ClassNotFoundException eCNFE) { throw new RuntimeException(eCNFE); } } } public void writeData(ObjectOutputStream dos) { try { // long dos.writeLong(this.id); // Object dos.writeObject(this.stage); // Object dos.writeObject(this.result); // String writeString(this.error, dos); // String writeString(this.server_url, dos); // String writeString(this.session, dos); // java.util.Date writeDate(this.timestamp, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("id=" + String.valueOf(id)); sb.append(",stage=" + String.valueOf(stage)); sb.append(",result=" + String.valueOf(result)); sb.append(",error=" + error); sb.append(",server_url=" + server_url); sb.append(",session=" + session); sb.append(",timestamp=" + String.valueOf(timestamp)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(stage_OKStruct other) { int returnValue = -1; returnValue = checkNullsAndCompare(this.id, other.id); if (returnValue != 0) { return returnValue; } return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } public static class row1Struct implements routines.system.IPersistableRow<row1Struct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; public String stage; public String getStage() { return this.stage; } public String result; public String getResult() { return this.result; } public String data; public String getData() { return this.data; } private String readString(ObjectInputStream dis) throws IOException { String strReturn = null; int length = 0; length = dis.readInt(); if (length == -1) { strReturn = null; } else { if (length > commonByteArray_ZUORA_OTS_Subscription.length) { if (length < 1024 && commonByteArray_ZUORA_OTS_Subscription.length == 0) { commonByteArray_ZUORA_OTS_Subscription = new byte[1024]; } else { commonByteArray_ZUORA_OTS_Subscription = new byte[2 * length]; } } dis.readFully(commonByteArray_ZUORA_OTS_Subscription, 0, length); strReturn = new String(commonByteArray_ZUORA_OTS_Subscription, 0, length, utf8Charset); } return strReturn; } private void writeString(String str, ObjectOutputStream dos) throws IOException { if (str == null) { dos.writeInt(-1); } else { byte[] byteArray = str.getBytes(utf8Charset); dos.writeInt(byteArray.length); dos.write(byteArray); } } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.stage = readString(dis); this.result = readString(dis); this.data = readString(dis); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // String writeString(this.stage, dos); // String writeString(this.result, dos); // String writeString(this.data, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("stage=" + stage); sb.append(",result=" + result); sb.append(",data=" + data); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(row1Struct other) { int returnValue = -1; return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } public void tFixedFlowInput_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFixedFlowInput_1_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 { String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row1Struct row1 = new row1Struct(); stage_OKStruct stage_OK = new stage_OKStruct(); /** * [tMysqlOutput_1 begin ] start */ ok_Hash.put("tMysqlOutput_1", false); start_Hash.put("tMysqlOutput_1", System.currentTimeMillis()); currentComponent = "tMysqlOutput_1"; int tos_count_tMysqlOutput_1 = 0; int nb_line_tMysqlOutput_1 = 0; int nb_line_update_tMysqlOutput_1 = 0; int nb_line_inserted_tMysqlOutput_1 = 0; int nb_line_deleted_tMysqlOutput_1 = 0; int nb_line_rejected_tMysqlOutput_1 = 0; int deletedCount_tMysqlOutput_1 = 0; int updatedCount_tMysqlOutput_1 = 0; int insertedCount_tMysqlOutput_1 = 0; int rejectedCount_tMysqlOutput_1 = 0; String tableName_tMysqlOutput_1 = "ots_job_state"; boolean whetherReject_tMysqlOutput_1 = false; java.util.Calendar calendar_tMysqlOutput_1 = java.util.Calendar.getInstance(); calendar_tMysqlOutput_1.set(1, 0, 1, 0, 0, 0); long year1_tMysqlOutput_1 = calendar_tMysqlOutput_1.getTime().getTime(); calendar_tMysqlOutput_1.set(10000, 0, 1, 0, 0, 0); long year10000_tMysqlOutput_1 = calendar_tMysqlOutput_1.getTime().getTime(); long date_tMysqlOutput_1; java.sql.Connection conn_tMysqlOutput_1 = null; String dbProperties_tMysqlOutput_1 = "noDatetimeStringSync=true"; String url_tMysqlOutput_1 = null; if (dbProperties_tMysqlOutput_1 == null || dbProperties_tMysqlOutput_1.trim().length() == 0) { url_tMysqlOutput_1 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + "rewriteBatchedStatements=true"; } else { String properties_tMysqlOutput_1 = "noDatetimeStringSync=true"; if (!properties_tMysqlOutput_1.contains("rewriteBatchedStatements")) { properties_tMysqlOutput_1 += "&rewriteBatchedStatements=true"; } url_tMysqlOutput_1 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + properties_tMysqlOutput_1; } String driverClass_tMysqlOutput_1 = "org.gjt.mm.mysql.Driver"; String dbUser_tMysqlOutput_1 = "root"; final String decryptedPassword_tMysqlOutput_1 = routines.system.PasswordEncryptUtil .decryptPassword("7a440551249af37a"); String dbPwd_tMysqlOutput_1 = decryptedPassword_tMysqlOutput_1; java.lang.Class.forName(driverClass_tMysqlOutput_1); conn_tMysqlOutput_1 = java.sql.DriverManager.getConnection(url_tMysqlOutput_1, dbUser_tMysqlOutput_1, dbPwd_tMysqlOutput_1); resourceMap.put("conn_tMysqlOutput_1", conn_tMysqlOutput_1); conn_tMysqlOutput_1.setAutoCommit(false); int commitEvery_tMysqlOutput_1 = 10000; int commitCounter_tMysqlOutput_1 = 0; int count_tMysqlOutput_1 = 0; String insert_tMysqlOutput_1 = "INSERT INTO `" + "ots_job_state" + "` (`id`,`stage`,`result`,`error`,`server_url`,`session`,`timestamp`) VALUES (?,?,?,?,?,?,?)"; int batchSize_tMysqlOutput_1 = 100; int batchSizeCounter_tMysqlOutput_1 = 0; java.sql.PreparedStatement pstmt_tMysqlOutput_1 = conn_tMysqlOutput_1 .prepareStatement(insert_tMysqlOutput_1); /** * [tMysqlOutput_1 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 */ /** * [tFixedFlowInput_1 begin ] start */ ok_Hash.put("tFixedFlowInput_1", false); start_Hash.put("tFixedFlowInput_1", System.currentTimeMillis()); currentComponent = "tFixedFlowInput_1"; int tos_count_tFixedFlowInput_1 = 0; for (int i_tFixedFlowInput_1 = 0; i_tFixedFlowInput_1 < 1; i_tFixedFlowInput_1++) { row1.stage = (String) globalMap.get("stage"); row1.result = "OK"; row1.data = ""; /** * [tFixedFlowInput_1 begin ] stop */ /** * [tFixedFlowInput_1 main ] start */ currentComponent = "tFixedFlowInput_1"; tos_count_tFixedFlowInput_1++; /** * [tFixedFlowInput_1 main ] stop */ /** * [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 = row1.stage; stage_OK_tmp.result = row1.result; stage_OK_tmp.error = null; stage_OK_tmp.server_url = null; stage_OK_tmp.session = null; 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_1 main ] start */ currentComponent = "tMysqlOutput_1"; whetherReject_tMysqlOutput_1 = false; pstmt_tMysqlOutput_1.setLong(1, stage_OK.id); if (stage_OK.stage == null) { pstmt_tMysqlOutput_1.setNull(2, java.sql.Types.OTHER); } else { pstmt_tMysqlOutput_1.setObject(2, stage_OK.stage); } if (stage_OK.result == null) { pstmt_tMysqlOutput_1.setNull(3, java.sql.Types.OTHER); } else { pstmt_tMysqlOutput_1.setObject(3, stage_OK.result); } if (stage_OK.error == null) { pstmt_tMysqlOutput_1.setNull(4, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_1.setString(4, stage_OK.error); } if (stage_OK.server_url == null) { pstmt_tMysqlOutput_1.setNull(5, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_1.setString(5, stage_OK.server_url); } if (stage_OK.session == null) { pstmt_tMysqlOutput_1.setNull(6, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_1.setString(6, stage_OK.session); } if (stage_OK.timestamp != null) { date_tMysqlOutput_1 = stage_OK.timestamp.getTime(); if (date_tMysqlOutput_1 < year1_tMysqlOutput_1 || date_tMysqlOutput_1 >= year10000_tMysqlOutput_1) { pstmt_tMysqlOutput_1.setString(7, "0000-00-00 00:00:00"); } else { pstmt_tMysqlOutput_1.setTimestamp(7, new java.sql.Timestamp(date_tMysqlOutput_1)); } } else { pstmt_tMysqlOutput_1.setNull(7, java.sql.Types.DATE); } pstmt_tMysqlOutput_1.addBatch(); nb_line_tMysqlOutput_1++; batchSizeCounter_tMysqlOutput_1++; if (batchSize_tMysqlOutput_1 <= batchSizeCounter_tMysqlOutput_1) { try { int countSum_tMysqlOutput_1 = 0; for (int countEach_tMysqlOutput_1 : pstmt_tMysqlOutput_1.executeBatch()) { countSum_tMysqlOutput_1 += (countEach_tMysqlOutput_1 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_1 += countSum_tMysqlOutput_1; } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_1 = 0; for (int countEach_tMysqlOutput_1 : e.getUpdateCounts()) { countSum_tMysqlOutput_1 += (countEach_tMysqlOutput_1 < 0 ? 0 : countEach_tMysqlOutput_1); } insertedCount_tMysqlOutput_1 += countSum_tMysqlOutput_1; System.err.println(e.getMessage()); } batchSizeCounter_tMysqlOutput_1 = 0; } commitCounter_tMysqlOutput_1++; if (commitEvery_tMysqlOutput_1 <= commitCounter_tMysqlOutput_1) { try { int countSum_tMysqlOutput_1 = 0; for (int countEach_tMysqlOutput_1 : pstmt_tMysqlOutput_1.executeBatch()) { countSum_tMysqlOutput_1 += (countEach_tMysqlOutput_1 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_1 += countSum_tMysqlOutput_1; } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_1 = 0; for (int countEach_tMysqlOutput_1 : e.getUpdateCounts()) { countSum_tMysqlOutput_1 += (countEach_tMysqlOutput_1 < 0 ? 0 : countEach_tMysqlOutput_1); } insertedCount_tMysqlOutput_1 += countSum_tMysqlOutput_1; System.err.println(e.getMessage()); } conn_tMysqlOutput_1.commit(); commitCounter_tMysqlOutput_1 = 0; } tos_count_tMysqlOutput_1++; /** * [tMysqlOutput_1 main ] stop */ } // End of branch "stage_OK" /** * [tFixedFlowInput_1 end ] start */ currentComponent = "tFixedFlowInput_1"; } globalMap.put("tFixedFlowInput_1_NB_LINE", 1); ok_Hash.put("tFixedFlowInput_1", true); end_Hash.put("tFixedFlowInput_1", System.currentTimeMillis()); /** * [tFixedFlowInput_1 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_1 end ] start */ currentComponent = "tMysqlOutput_1"; try { if (batchSizeCounter_tMysqlOutput_1 != 0) { int countSum_tMysqlOutput_1 = 0; for (int countEach_tMysqlOutput_1 : pstmt_tMysqlOutput_1.executeBatch()) { countSum_tMysqlOutput_1 += (countEach_tMysqlOutput_1 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_1 += countSum_tMysqlOutput_1; } } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_1 = 0; for (int countEach_tMysqlOutput_1 : e.getUpdateCounts()) { countSum_tMysqlOutput_1 += (countEach_tMysqlOutput_1 < 0 ? 0 : countEach_tMysqlOutput_1); } insertedCount_tMysqlOutput_1 += countSum_tMysqlOutput_1; System.err.println(e.getMessage()); } batchSizeCounter_tMysqlOutput_1 = 0; if (pstmt_tMysqlOutput_1 != null) { pstmt_tMysqlOutput_1.close(); } if (commitCounter_tMysqlOutput_1 > 0) { conn_tMysqlOutput_1.commit(); } conn_tMysqlOutput_1.close(); resourceMap.put("finish_tMysqlOutput_1", true); nb_line_deleted_tMysqlOutput_1 = nb_line_deleted_tMysqlOutput_1 + deletedCount_tMysqlOutput_1; nb_line_update_tMysqlOutput_1 = nb_line_update_tMysqlOutput_1 + updatedCount_tMysqlOutput_1; nb_line_inserted_tMysqlOutput_1 = nb_line_inserted_tMysqlOutput_1 + insertedCount_tMysqlOutput_1; nb_line_rejected_tMysqlOutput_1 = nb_line_rejected_tMysqlOutput_1 + rejectedCount_tMysqlOutput_1; globalMap.put("tMysqlOutput_1_NB_LINE", nb_line_tMysqlOutput_1); globalMap.put("tMysqlOutput_1_NB_LINE_UPDATED", nb_line_update_tMysqlOutput_1); globalMap.put("tMysqlOutput_1_NB_LINE_INSERTED", nb_line_inserted_tMysqlOutput_1); globalMap.put("tMysqlOutput_1_NB_LINE_DELETED", nb_line_deleted_tMysqlOutput_1); globalMap.put("tMysqlOutput_1_NB_LINE_REJECTED", nb_line_rejected_tMysqlOutput_1); ok_Hash.put("tMysqlOutput_1", true); end_Hash.put("tMysqlOutput_1", System.currentTimeMillis()); /** * [tMysqlOutput_1 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 { /** * [tFixedFlowInput_1 finally ] start */ currentComponent = "tFixedFlowInput_1"; /** * [tFixedFlowInput_1 finally ] stop */ /** * [tMap_1 finally ] start */ currentComponent = "tMap_1"; /** * [tMap_1 finally ] stop */ /** * [tMysqlOutput_1 finally ] start */ currentComponent = "tMysqlOutput_1"; if (resourceMap.get("finish_tMysqlOutput_1") == null) { if (resourceMap.get("conn_tMysqlOutput_1") != null) { try { ((java.sql.Connection) resourceMap.get("conn_tMysqlOutput_1")).close(); } catch (java.sql.SQLException sqlEx_tMysqlOutput_1) { String errorMessage_tMysqlOutput_1 = "failed to close the connection in tMysqlOutput_1 :" + sqlEx_tMysqlOutput_1.getMessage(); System.err.println(errorMessage_tMysqlOutput_1); } } } /** * [tMysqlOutput_1 finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tFixedFlowInput_1_SUBPROCESS_STATE", 1); } public static class stageKOStruct implements routines.system.IPersistableRow<stageKOStruct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; protected static final int DEFAULT_HASHCODE = 1; protected static final int PRIME = 31; protected int hashCode = DEFAULT_HASHCODE; public boolean hashCodeDirty = true; public String loopKey; public long id; public long getId() { return this.id; } public Object stage; public Object getStage() { return this.stage; } public Object result; public Object getResult() { return this.result; } public String error; public String getError() { return this.error; } public String server_url; public String getServer_url() { return this.server_url; } public String session; public String getSession() { return this.session; } public java.util.Date timestamp; public java.util.Date getTimestamp() { return this.timestamp; } @Override public int hashCode() { if (this.hashCodeDirty) { final int prime = PRIME; int result = DEFAULT_HASHCODE; result = prime * result + (int) this.id; this.hashCode = result; this.hashCodeDirty = false; } return this.hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final stageKOStruct other = (stageKOStruct) obj; if (this.id != other.id) return false; return true; } public void copyDataTo(stageKOStruct other) { other.id = this.id; other.stage = this.stage; other.result = this.result; other.error = this.error; other.server_url = this.server_url; other.session = this.session; other.timestamp = this.timestamp; } public void copyKeysDataTo(stageKOStruct other) { other.id = this.id; } private String readString(ObjectInputStream dis) throws IOException { String strReturn = null; int length = 0; length = dis.readInt(); if (length == -1) { strReturn = null; } else { if (length > commonByteArray_ZUORA_OTS_Subscription.length) { if (length < 1024 && commonByteArray_ZUORA_OTS_Subscription.length == 0) { commonByteArray_ZUORA_OTS_Subscription = new byte[1024]; } else { commonByteArray_ZUORA_OTS_Subscription = new byte[2 * length]; } } dis.readFully(commonByteArray_ZUORA_OTS_Subscription, 0, length); strReturn = new String(commonByteArray_ZUORA_OTS_Subscription, 0, length, utf8Charset); } return strReturn; } private void writeString(String str, ObjectOutputStream dos) throws IOException { if (str == null) { dos.writeInt(-1); } else { byte[] byteArray = str.getBytes(utf8Charset); dos.writeInt(byteArray.length); dos.write(byteArray); } } private java.util.Date readDate(ObjectInputStream dis) throws IOException { java.util.Date dateReturn = null; int length = 0; length = dis.readByte(); if (length == -1) { dateReturn = null; } else { dateReturn = new Date(dis.readLong()); } return dateReturn; } private void writeDate(java.util.Date date1, ObjectOutputStream dos) throws IOException { if (date1 == null) { dos.writeByte(-1); } else { dos.writeByte(0); dos.writeLong(date1.getTime()); } } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.id = dis.readLong(); this.stage = (Object) dis.readObject(); this.result = (Object) dis.readObject(); this.error = readString(dis); this.server_url = readString(dis); this.session = readString(dis); this.timestamp = readDate(dis); } catch (IOException e) { throw new RuntimeException(e); } catch (ClassNotFoundException eCNFE) { throw new RuntimeException(eCNFE); } } } public void writeData(ObjectOutputStream dos) { try { // long dos.writeLong(this.id); // Object dos.writeObject(this.stage); // Object dos.writeObject(this.result); // String writeString(this.error, dos); // String writeString(this.server_url, dos); // String writeString(this.session, dos); // java.util.Date writeDate(this.timestamp, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("id=" + String.valueOf(id)); sb.append(",stage=" + String.valueOf(stage)); sb.append(",result=" + String.valueOf(result)); sb.append(",error=" + error); sb.append(",server_url=" + server_url); sb.append(",session=" + session); sb.append(",timestamp=" + String.valueOf(timestamp)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(stageKOStruct other) { int returnValue = -1; returnValue = checkNullsAndCompare(this.id, other.id); if (returnValue != 0) { return returnValue; } return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } public static class row6Struct implements routines.system.IPersistableRow<row6Struct> { final static byte[] commonByteArrayLock_ZUORA_OTS_Subscription = new byte[0]; static byte[] commonByteArray_ZUORA_OTS_Subscription = new byte[0]; public String result; public String getResult() { return this.result; } private String readString(ObjectInputStream dis) throws IOException { String strReturn = null; int length = 0; length = dis.readInt(); if (length == -1) { strReturn = null; } else { if (length > commonByteArray_ZUORA_OTS_Subscription.length) { if (length < 1024 && commonByteArray_ZUORA_OTS_Subscription.length == 0) { commonByteArray_ZUORA_OTS_Subscription = new byte[1024]; } else { commonByteArray_ZUORA_OTS_Subscription = new byte[2 * length]; } } dis.readFully(commonByteArray_ZUORA_OTS_Subscription, 0, length); strReturn = new String(commonByteArray_ZUORA_OTS_Subscription, 0, length, utf8Charset); } return strReturn; } private void writeString(String str, ObjectOutputStream dos) throws IOException { if (str == null) { dos.writeInt(-1); } else { byte[] byteArray = str.getBytes(utf8Charset); dos.writeInt(byteArray.length); dos.write(byteArray); } } public void readData(ObjectInputStream dis) { synchronized (commonByteArrayLock_ZUORA_OTS_Subscription) { try { int length = 0; this.result = readString(dis); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // String writeString(this.result, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("result=" + result); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(row6Struct other) { int returnValue = -1; return returnValue; } private int checkNullsAndCompare(Object object1, Object object2) { int returnValue = 0; if (object1 instanceof Comparable && object2 instanceof Comparable) { returnValue = ((Comparable) object1).compareTo(object2); } else if (object1 != null && object2 != null) { returnValue = compareStrings(object1.toString(), object2.toString()); } else if (object1 == null && object2 != null) { returnValue = 1; } else if (object1 != null && object2 == null) { returnValue = -1; } else { returnValue = 0; } return returnValue; } private int compareStrings(String string1, String string2) { return string1.compareTo(string2); } } public void tWriteJSONField_1_InProcess(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tWriteJSONField_1_In_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 { String currentMethodName = new java.lang.Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row6Struct row6 = new row6Struct(); stageKOStruct stageKO = new stageKOStruct(); /** * [tMysqlOutput_2 begin ] start */ ok_Hash.put("tMysqlOutput_2", false); start_Hash.put("tMysqlOutput_2", System.currentTimeMillis()); currentComponent = "tMysqlOutput_2"; int tos_count_tMysqlOutput_2 = 0; int nb_line_tMysqlOutput_2 = 0; int nb_line_update_tMysqlOutput_2 = 0; int nb_line_inserted_tMysqlOutput_2 = 0; int nb_line_deleted_tMysqlOutput_2 = 0; int nb_line_rejected_tMysqlOutput_2 = 0; int deletedCount_tMysqlOutput_2 = 0; int updatedCount_tMysqlOutput_2 = 0; int insertedCount_tMysqlOutput_2 = 0; int rejectedCount_tMysqlOutput_2 = 0; String tableName_tMysqlOutput_2 = "ots_job_state"; boolean whetherReject_tMysqlOutput_2 = false; java.util.Calendar calendar_tMysqlOutput_2 = java.util.Calendar.getInstance(); calendar_tMysqlOutput_2.set(1, 0, 1, 0, 0, 0); long year1_tMysqlOutput_2 = calendar_tMysqlOutput_2.getTime().getTime(); calendar_tMysqlOutput_2.set(10000, 0, 1, 0, 0, 0); long year10000_tMysqlOutput_2 = calendar_tMysqlOutput_2.getTime().getTime(); long date_tMysqlOutput_2; java.sql.Connection conn_tMysqlOutput_2 = null; String dbProperties_tMysqlOutput_2 = "noDatetimeStringSync=true"; String url_tMysqlOutput_2 = null; if (dbProperties_tMysqlOutput_2 == null || dbProperties_tMysqlOutput_2.trim().length() == 0) { url_tMysqlOutput_2 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + "rewriteBatchedStatements=true"; } else { String properties_tMysqlOutput_2 = "noDatetimeStringSync=true"; if (!properties_tMysqlOutput_2.contains("rewriteBatchedStatements")) { properties_tMysqlOutput_2 += "&rewriteBatchedStatements=true"; } url_tMysqlOutput_2 = "jdbc:mysql://" + "localhost" + ":" + "3306" + "/" + "fw_zuora" + "?" + properties_tMysqlOutput_2; } String driverClass_tMysqlOutput_2 = "org.gjt.mm.mysql.Driver"; String dbUser_tMysqlOutput_2 = "root"; final String decryptedPassword_tMysqlOutput_2 = routines.system.PasswordEncryptUtil .decryptPassword("7a440551249af37a"); String dbPwd_tMysqlOutput_2 = decryptedPassword_tMysqlOutput_2; java.lang.Class.forName(driverClass_tMysqlOutput_2); conn_tMysqlOutput_2 = java.sql.DriverManager.getConnection(url_tMysqlOutput_2, dbUser_tMysqlOutput_2, dbPwd_tMysqlOutput_2); resourceMap.put("conn_tMysqlOutput_2", conn_tMysqlOutput_2); conn_tMysqlOutput_2.setAutoCommit(false); int commitEvery_tMysqlOutput_2 = 10000; int commitCounter_tMysqlOutput_2 = 0; int count_tMysqlOutput_2 = 0; java.sql.Statement stmtTruncCount_tMysqlOutput_2 = conn_tMysqlOutput_2.createStatement(); java.sql.ResultSet rsTruncCount_tMysqlOutput_2 = stmtTruncCount_tMysqlOutput_2 .executeQuery("SELECT COUNT(1) FROM `" + tableName_tMysqlOutput_2 + "`"); int rsTruncCountNumber_tMysqlOutput_2 = 0; if (rsTruncCount_tMysqlOutput_2.next()) { rsTruncCountNumber_tMysqlOutput_2 = rsTruncCount_tMysqlOutput_2.getInt(1); } rsTruncCount_tMysqlOutput_2.close(); stmtTruncCount_tMysqlOutput_2.close(); java.sql.Statement stmtTrunc_tMysqlOutput_2 = conn_tMysqlOutput_2.createStatement(); stmtTrunc_tMysqlOutput_2.executeUpdate("TRUNCATE TABLE `" + tableName_tMysqlOutput_2 + "`"); deletedCount_tMysqlOutput_2 += rsTruncCountNumber_tMysqlOutput_2; stmtTrunc_tMysqlOutput_2.close(); String insert_tMysqlOutput_2 = "INSERT INTO `" + "ots_job_state" + "` (`id`,`stage`,`result`,`error`,`server_url`,`session`,`timestamp`) VALUES (?,?,?,?,?,?,?)"; int batchSize_tMysqlOutput_2 = 100; int batchSizeCounter_tMysqlOutput_2 = 0; java.sql.PreparedStatement pstmt_tMysqlOutput_2 = conn_tMysqlOutput_2 .prepareStatement(insert_tMysqlOutput_2); /** * [tMysqlOutput_2 begin ] stop */ /** * [tMap_2 begin ] start */ ok_Hash.put("tMap_2", false); start_Hash.put("tMap_2", System.currentTimeMillis()); currentComponent = "tMap_2"; int tos_count_tMap_2 = 0; // ############################### // # Lookup's keys initialization // ############################### // ############################### // # Vars initialization class Var__tMap_2__Struct { } Var__tMap_2__Struct Var__tMap_2 = new Var__tMap_2__Struct(); // ############################### // ############################### // # Outputs initialization stageKOStruct stageKO_tmp = new stageKOStruct(); // ############################### /** * [tMap_2 begin ] stop */ /** * [tWriteJSONField_1_In begin ] start */ ok_Hash.put("tWriteJSONField_1_In", false); start_Hash.put("tWriteJSONField_1_In", System.currentTimeMillis()); currentVirtualComponent = "tWriteJSONField_1"; currentComponent = "tWriteJSONField_1_In"; int tos_count_tWriteJSONField_1_In = 0; int nb_line_tWriteJSONField_1_In = 0; net.sf.json.xml.XMLSerializer xmlSerializer_tWriteJSONField_1_In = new net.sf.json.xml.XMLSerializer(); xmlSerializer_tWriteJSONField_1_In.clearNamespaces(); xmlSerializer_tWriteJSONField_1_In.setSkipNamespaces(true); xmlSerializer_tWriteJSONField_1_In.setForceTopLevelObject(true); java.util.Queue<row6Struct> queue_tWriteJSONField_1_In = (java.util.Queue<row6Struct>) globalMap .get("queue_tWriteJSONField_1_In"); String readFinishMarkWithPipeId_tWriteJSONField_1_In = "tWriteJSONField_1_In_FINISH" + (queue_tWriteJSONField_1_In == null ? "" : queue_tWriteJSONField_1_In.hashCode()); String str_tWriteJSONField_1_In = null; while (!globalMap.containsKey(readFinishMarkWithPipeId_tWriteJSONField_1_In) || !queue_tWriteJSONField_1_In.isEmpty()) { if (!queue_tWriteJSONField_1_In.isEmpty()) { /** * [tWriteJSONField_1_In begin ] stop */ /** * [tWriteJSONField_1_In main ] start */ currentVirtualComponent = "tWriteJSONField_1"; currentComponent = "tWriteJSONField_1_In"; row6Struct result_tWriteJSONField_1_In = queue_tWriteJSONField_1_In.poll(); str_tWriteJSONField_1_In = result_tWriteJSONField_1_In.result; row6.result = result_tWriteJSONField_1_In.result; row6.result = result_tWriteJSONField_1_In.result; row6.result = result_tWriteJSONField_1_In.result; row6.result = result_tWriteJSONField_1_In.result; row6.result = result_tWriteJSONField_1_In.result; row6.result = result_tWriteJSONField_1_In.result; row6.result = result_tWriteJSONField_1_In.result; // Convert XML to JSON net.sf.json.JSON json_tWriteJSONField_1_In = xmlSerializer_tWriteJSONField_1_In .read(str_tWriteJSONField_1_In); row6.result = json_tWriteJSONField_1_In.toString(); nb_line_tWriteJSONField_1_In++; tos_count_tWriteJSONField_1_In++; /** * [tWriteJSONField_1_In main ] stop */ /** * [tMap_2 main ] start */ currentComponent = "tMap_2"; boolean hasCasePrimitiveKeyWithNull_tMap_2 = false; // ############################### // # Input tables (lookups) boolean rejectedInnerJoin_tMap_2 = false; boolean mainRowRejected_tMap_2 = false; // ############################### { // start of Var scope // ############################### // # Vars tables Var__tMap_2__Struct Var = Var__tMap_2;// ############################### // ############################### // # Output tables stageKO = null; // # Output table : 'stageKO' stageKO_tmp.id = 0; stageKO_tmp.stage = "CREATE_SUBSCRIPTION"; stageKO_tmp.result = "KO"; stageKO_tmp.error = row6.result; stageKO_tmp.server_url = null; stageKO_tmp.session = null; stageKO_tmp.timestamp = TalendDate.getCurrentDate(); stageKO = stageKO_tmp; // ############################### } // end of Var scope rejectedInnerJoin_tMap_2 = false; tos_count_tMap_2++; /** * [tMap_2 main ] stop */ // Start of branch "stageKO" if (stageKO != null) { /** * [tMysqlOutput_2 main ] start */ currentComponent = "tMysqlOutput_2"; whetherReject_tMysqlOutput_2 = false; pstmt_tMysqlOutput_2.setLong(1, stageKO.id); if (stageKO.stage == null) { pstmt_tMysqlOutput_2.setNull(2, java.sql.Types.OTHER); } else { pstmt_tMysqlOutput_2.setObject(2, stageKO.stage); } if (stageKO.result == null) { pstmt_tMysqlOutput_2.setNull(3, java.sql.Types.OTHER); } else { pstmt_tMysqlOutput_2.setObject(3, stageKO.result); } if (stageKO.error == null) { pstmt_tMysqlOutput_2.setNull(4, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_2.setString(4, stageKO.error); } if (stageKO.server_url == null) { pstmt_tMysqlOutput_2.setNull(5, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_2.setString(5, stageKO.server_url); } if (stageKO.session == null) { pstmt_tMysqlOutput_2.setNull(6, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_2.setString(6, stageKO.session); } if (stageKO.timestamp != null) { date_tMysqlOutput_2 = stageKO.timestamp.getTime(); if (date_tMysqlOutput_2 < year1_tMysqlOutput_2 || date_tMysqlOutput_2 >= year10000_tMysqlOutput_2) { pstmt_tMysqlOutput_2.setString(7, "0000-00-00 00:00:00"); } else { pstmt_tMysqlOutput_2.setTimestamp(7, new java.sql.Timestamp(date_tMysqlOutput_2)); } } else { pstmt_tMysqlOutput_2.setNull(7, java.sql.Types.DATE); } pstmt_tMysqlOutput_2.addBatch(); nb_line_tMysqlOutput_2++; batchSizeCounter_tMysqlOutput_2++; if (batchSize_tMysqlOutput_2 <= batchSizeCounter_tMysqlOutput_2) { try { int countSum_tMysqlOutput_2 = 0; for (int countEach_tMysqlOutput_2 : pstmt_tMysqlOutput_2.executeBatch()) { countSum_tMysqlOutput_2 += (countEach_tMysqlOutput_2 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_2 += countSum_tMysqlOutput_2; } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_2 = 0; for (int countEach_tMysqlOutput_2 : e.getUpdateCounts()) { countSum_tMysqlOutput_2 += (countEach_tMysqlOutput_2 < 0 ? 0 : countEach_tMysqlOutput_2); } insertedCount_tMysqlOutput_2 += countSum_tMysqlOutput_2; System.err.println(e.getMessage()); } batchSizeCounter_tMysqlOutput_2 = 0; } commitCounter_tMysqlOutput_2++; if (commitEvery_tMysqlOutput_2 <= commitCounter_tMysqlOutput_2) { try { int countSum_tMysqlOutput_2 = 0; for (int countEach_tMysqlOutput_2 : pstmt_tMysqlOutput_2.executeBatch()) { countSum_tMysqlOutput_2 += (countEach_tMysqlOutput_2 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_2 += countSum_tMysqlOutput_2; } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_2 = 0; for (int countEach_tMysqlOutput_2 : e.getUpdateCounts()) { countSum_tMysqlOutput_2 += (countEach_tMysqlOutput_2 < 0 ? 0 : countEach_tMysqlOutput_2); } insertedCount_tMysqlOutput_2 += countSum_tMysqlOutput_2; System.err.println(e.getMessage()); } conn_tMysqlOutput_2.commit(); commitCounter_tMysqlOutput_2 = 0; } tos_count_tMysqlOutput_2++; /** * [tMysqlOutput_2 main ] stop */ } // End of branch "stageKO" /** * [tWriteJSONField_1_In end ] start */ currentVirtualComponent = "tWriteJSONField_1"; currentComponent = "tWriteJSONField_1_In"; } } String readFinishWithExceptionMarkWithPipeId_tWriteJSONField_1_In = "tWriteJSONField_1_In_FINISH_WITH_EXCEPTION" + (queue_tWriteJSONField_1_In == null ? "" : queue_tWriteJSONField_1_In.hashCode()); if (globalMap.containsKey(readFinishWithExceptionMarkWithPipeId_tWriteJSONField_1_In)) { if (!(globalMap instanceof java.util.concurrent.ConcurrentHashMap)) { globalMap.put(readFinishWithExceptionMarkWithPipeId_tWriteJSONField_1_In, null);// syn } globalMap.remove(readFinishWithExceptionMarkWithPipeId_tWriteJSONField_1_In); return; } globalMap.remove("queue_tWriteJSONField_1_In"); if (!(globalMap instanceof java.util.concurrent.ConcurrentHashMap)) { globalMap.put(readFinishMarkWithPipeId_tWriteJSONField_1_In, null);// syn } globalMap.remove(readFinishMarkWithPipeId_tWriteJSONField_1_In); globalMap.put("tWriteJSONField_1_NB_LINE", nb_line_tWriteJSONField_1_In); ok_Hash.put("tWriteJSONField_1_In", true); end_Hash.put("tWriteJSONField_1_In", System.currentTimeMillis()); /** * [tWriteJSONField_1_In end ] stop */ /** * [tMap_2 end ] start */ currentComponent = "tMap_2"; // ############################### // # Lookup hashes releasing // ############################### ok_Hash.put("tMap_2", true); end_Hash.put("tMap_2", System.currentTimeMillis()); /** * [tMap_2 end ] stop */ /** * [tMysqlOutput_2 end ] start */ currentComponent = "tMysqlOutput_2"; try { if (batchSizeCounter_tMysqlOutput_2 != 0) { int countSum_tMysqlOutput_2 = 0; for (int countEach_tMysqlOutput_2 : pstmt_tMysqlOutput_2.executeBatch()) { countSum_tMysqlOutput_2 += (countEach_tMysqlOutput_2 < 0 ? 0 : 1); } insertedCount_tMysqlOutput_2 += countSum_tMysqlOutput_2; } } catch (java.sql.BatchUpdateException e) { int countSum_tMysqlOutput_2 = 0; for (int countEach_tMysqlOutput_2 : e.getUpdateCounts()) { countSum_tMysqlOutput_2 += (countEach_tMysqlOutput_2 < 0 ? 0 : countEach_tMysqlOutput_2); } insertedCount_tMysqlOutput_2 += countSum_tMysqlOutput_2; System.err.println(e.getMessage()); } batchSizeCounter_tMysqlOutput_2 = 0; if (pstmt_tMysqlOutput_2 != null) { pstmt_tMysqlOutput_2.close(); } if (commitCounter_tMysqlOutput_2 > 0) { conn_tMysqlOutput_2.commit(); } conn_tMysqlOutput_2.close(); resourceMap.put("finish_tMysqlOutput_2", true); nb_line_deleted_tMysqlOutput_2 = nb_line_deleted_tMysqlOutput_2 + deletedCount_tMysqlOutput_2; nb_line_update_tMysqlOutput_2 = nb_line_update_tMysqlOutput_2 + updatedCount_tMysqlOutput_2; nb_line_inserted_tMysqlOutput_2 = nb_line_inserted_tMysqlOutput_2 + insertedCount_tMysqlOutput_2; nb_line_rejected_tMysqlOutput_2 = nb_line_rejected_tMysqlOutput_2 + rejectedCount_tMysqlOutput_2; globalMap.put("tMysqlOutput_2_NB_LINE", nb_line_tMysqlOutput_2); globalMap.put("tMysqlOutput_2_NB_LINE_UPDATED", nb_line_update_tMysqlOutput_2); globalMap.put("tMysqlOutput_2_NB_LINE_INSERTED", nb_line_inserted_tMysqlOutput_2); globalMap.put("tMysqlOutput_2_NB_LINE_DELETED", nb_line_deleted_tMysqlOutput_2); globalMap.put("tMysqlOutput_2_NB_LINE_REJECTED", nb_line_rejected_tMysqlOutput_2); ok_Hash.put("tMysqlOutput_2", true); end_Hash.put("tMysqlOutput_2", System.currentTimeMillis()); /** * [tMysqlOutput_2 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 { /** * [tWriteJSONField_1_In finally ] start */ currentVirtualComponent = "tWriteJSONField_1"; currentComponent = "tWriteJSONField_1_In"; /** * [tWriteJSONField_1_In finally ] stop */ /** * [tMap_2 finally ] start */ currentComponent = "tMap_2"; /** * [tMap_2 finally ] stop */ /** * [tMysqlOutput_2 finally ] start */ currentComponent = "tMysqlOutput_2"; if (resourceMap.get("finish_tMysqlOutput_2") == null) { if (resourceMap.get("conn_tMysqlOutput_2") != null) { try { ((java.sql.Connection) resourceMap.get("conn_tMysqlOutput_2")).close(); } catch (java.sql.SQLException sqlEx_tMysqlOutput_2) { String errorMessage_tMysqlOutput_2 = "failed to close the connection in tMysqlOutput_2 :" + sqlEx_tMysqlOutput_2.getMessage(); System.err.println(errorMessage_tMysqlOutput_2); } } } /** * [tMysqlOutput_2 finally ] stop */ } catch (java.lang.Exception e) { // ignore } catch (java.lang.Error error) { // ignore } resourceMap = null; } globalMap.put("tWriteJSONField_1_In_SUBPROCESS_STATE", 1); } public String resuming_logs_dir_path = null; public String resuming_checkpoint_path = null; public String parent_part_launcher = null; private String resumeEntryMethodName = null; private boolean globalResumeTicket = false; public boolean watch = false; // portStats is null, it means don't execute the statistics public Integer portStats = null; public int portTraces = 4334; public String clientHost; public String defaultClientHost = "localhost"; public String contextStr = "Default"; public boolean isDefaultContext = true; public String pid = "0"; public String rootPid = null; public String fatherPid = null; public String fatherNode = null; public long startTime = 0; public boolean isChildJob = false; public String log4jLevel = ""; private boolean execStat = true; private ThreadLocal<java.util.Map<String, String>> threadLocal = new ThreadLocal<java.util.Map<String, String>>() { protected java.util.Map<String, String> initialValue() { java.util.Map<String, String> threadRunResultMap = new java.util.HashMap<String, String>(); threadRunResultMap.put("errorCode", null); threadRunResultMap.put("status", ""); return threadRunResultMap; }; }; private java.util.Properties context_param = new java.util.Properties(); public java.util.Map<String, Object> parentContextMap = new java.util.HashMap<String, Object>(); public String status = ""; public static void main(String[] args) { final OTS_Subscription OTS_SubscriptionClass = new OTS_Subscription(); int exitCode = OTS_SubscriptionClass.runJobInTOS(args); System.exit(exitCode); } public String[][] runJob(String[] args) { int exitCode = runJobInTOS(args); String[][] bufferValue = new String[][] { { Integer.toString(exitCode) } }; return bufferValue; } public boolean hastBufferOutputComponent() { boolean hastBufferOutput = false; return hastBufferOutput; } public int runJobInTOS(String[] args) { // reset status status = ""; String lastStr = ""; for (String arg : args) { if (arg.equalsIgnoreCase("--context_param")) { lastStr = arg; } else if (lastStr.equals("")) { evalParam(arg); } else { evalParam(lastStr + " " + arg); lastStr = ""; } } if (clientHost == null) { clientHost = defaultClientHost; } if (pid == null || "0".equals(pid)) { pid = TalendString.getAsciiRandomString(6); } if (rootPid == null) { rootPid = pid; } if (fatherPid == null) { fatherPid = pid; } else { isChildJob = true; } try { // call job/subjob with an existing context, like: // --context=production. if without this parameter, there will use // the default context instead. java.io.InputStream inContext = OTS_Subscription.class.getClassLoader() .getResourceAsStream("zuora/ots_subscription_0_1/contexts/" + contextStr + ".properties"); if (isDefaultContext && inContext == null) { } else { if (inContext != null) { // defaultProps is in order to keep the original context // value defaultProps.load(inContext); inContext.close(); context = new ContextProperties(defaultProps); } else { // print info and job continue to run, for case: // context_param is not empty. System.err.println("Could not find the context " + contextStr); } } if (!context_param.isEmpty()) { context.putAll(context_param); } } catch (java.io.IOException ie) { System.err.println("Could not load context " + contextStr); ie.printStackTrace(); } // get context value from parent directly if (parentContextMap != null && !parentContextMap.isEmpty()) { } // Resume: init the resumeUtil resumeEntryMethodName = ResumeUtil.getResumeEntryMethodName(resuming_checkpoint_path); resumeUtil = new ResumeUtil(resuming_logs_dir_path, isChildJob, rootPid); resumeUtil.initCommonInfo(pid, rootPid, fatherPid, projectName, jobName, contextStr, jobVersion); List<String> parametersToEncrypt = new java.util.ArrayList<String>(); // Resume: jobStart resumeUtil.addLog("JOB_STARTED", "JOB:" + jobName, parent_part_launcher, Thread.currentThread().getId() + "", "", "", "", "", resumeUtil.convertToJsonText(context, parametersToEncrypt)); java.util.concurrent.ConcurrentHashMap<Object, Object> concurrentHashMap = new java.util.concurrent.ConcurrentHashMap<Object, Object>(); globalMap.put("concurrentHashMap", concurrentHashMap); long startUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); long endUsedMemory = 0; long end = 0; startTime = System.currentTimeMillis(); this.globalResumeTicket = true;// to run tPreJob this.globalResumeTicket = false;// to run others jobs try { errorCode = null; tMysqlInput_4Process(globalMap); if (!"failure".equals(status)) { status = "end"; } } catch (TalendException e_tMysqlInput_4) { globalMap.put("tMysqlInput_4_SUBPROCESS_STATE", -1); e_tMysqlInput_4.printStackTrace(); } this.globalResumeTicket = true;// to run tPostJob end = System.currentTimeMillis(); if (watch) { System.out.println((end - startTime) + " milliseconds"); } endUsedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); if (false) { System.out.println( (endUsedMemory - startUsedMemory) + " bytes memory increase when running : OTS_Subscription"); } int returnCode = 0; if (errorCode == null) { returnCode = status != null && status.equals("failure") ? 1 : 0; } else { returnCode = errorCode.intValue(); } resumeUtil.addLog("JOB_ENDED", "JOB:" + jobName, parent_part_launcher, Thread.currentThread().getId() + "", "", "" + returnCode, "", "", ""); return returnCode; } // only for OSGi env public void destroy() { } private java.util.Map<String, Object> getSharedConnections4REST() { java.util.Map<String, Object> connections = new java.util.HashMap<String, Object>(); return connections; } private void evalParam(String arg) { if (arg.startsWith("--resuming_logs_dir_path")) { resuming_logs_dir_path = arg.substring(25); } else if (arg.startsWith("--resuming_checkpoint_path")) { resuming_checkpoint_path = arg.substring(27); } else if (arg.startsWith("--parent_part_launcher")) { parent_part_launcher = arg.substring(23); } else if (arg.startsWith("--watch")) { watch = true; } else if (arg.startsWith("--stat_port=")) { String portStatsStr = arg.substring(12); if (portStatsStr != null && !portStatsStr.equals("null")) { portStats = Integer.parseInt(portStatsStr); } } else if (arg.startsWith("--trace_port=")) { portTraces = Integer.parseInt(arg.substring(13)); } else if (arg.startsWith("--client_host=")) { clientHost = arg.substring(14); } else if (arg.startsWith("--context=")) { contextStr = arg.substring(10); isDefaultContext = false; } else if (arg.startsWith("--father_pid=")) { fatherPid = arg.substring(13); } else if (arg.startsWith("--root_pid=")) { rootPid = arg.substring(11); } else if (arg.startsWith("--father_node=")) { fatherNode = arg.substring(14); } else if (arg.startsWith("--pid=")) { pid = arg.substring(6); } else if (arg.startsWith("--context_param")) { String keyValue = arg.substring(16); int index = -1; if (keyValue != null && (index = keyValue.indexOf('=')) > -1) { if (fatherPid == null) { context_param.put(keyValue.substring(0, index), replaceEscapeChars(keyValue.substring(index + 1))); } else { // the subjob won't escape the especial chars context_param.put(keyValue.substring(0, index), keyValue.substring(index + 1)); } } } else if (arg.startsWith("--log4jLevel=")) { log4jLevel = arg.substring(13); } } private final String[][] escapeChars = { { "\\\\", "\\" }, { "\\n", "\n" }, { "\\'", "\'" }, { "\\r", "\r" }, { "\\f", "\f" }, { "\\b", "\b" }, { "\\t", "\t" } }; private String replaceEscapeChars(String keyValue) { if (keyValue == null || ("").equals(keyValue.trim())) { return keyValue; } StringBuilder result = new StringBuilder(); int currIndex = 0; while (currIndex < keyValue.length()) { int index = -1; // judege if the left string includes escape chars for (String[] strArray : escapeChars) { index = keyValue.indexOf(strArray[0], currIndex); if (index >= 0) { result.append(keyValue.substring(currIndex, index + strArray[0].length()).replace(strArray[0], strArray[1])); currIndex = index + strArray[0].length(); break; } } // if the left string doesn't include escape chars, append the left // into the result if (index < 0) { result.append(keyValue.substring(currIndex)); currIndex = currIndex + keyValue.length(); } } return result.toString(); } public Integer getErrorCode() { return errorCode; } public String getStatus() { return status; } ResumeUtil resumeUtil = null; } /************************************************************************************************ * 177311 characters generated by Talend Open Studio for ESB on the 6 maggio * 2016 14.41.50 CEST ************************************************************************************************/