Java tutorial
// ============================================================================ // // Copyright (c) 2005-2012, Talend Inc. // // This source code has been automatically generated by_Talend Open Studio for Data Integration // / JobDesigner (CodeGenerator version 5.2.1.r95165) // You can find more information about Talend products at www.talend.com. // You may distribute this code under the terms of the GNU LGPL license // http://www.gnu.org/licenses/lgpl.html). // // ============================================================================ package talonetl.loadpropertyimages_0_2; import routines.Mathematical; import routines.DataOperation; import routines.Relational; import routines.TalendDate; import routines.TalendDataGenerator; import routines.Numeric; import routines.TalendString; import routines.StringHandling; 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 tJava_4 //import java.util.List; //the import part of tJavaRow_1 //import java.util.List; //the import part of tJava_6 //import java.util.List; //the import part of tJava_3 //import java.util.List; @SuppressWarnings("unused") /** * Job: loadPropertyImages Purpose: <br> * Description: <br> * @author test@talend.com * @version 5.2.1.r95165 * @status */ public class loadPropertyImages 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() { if (propertyUUId != null) { this.setProperty("propertyUUId", propertyUUId.toString()); } if (propertySourceUri != null) { this.setProperty("propertySourceUri", propertySourceUri.toString()); } if (talon_Password != null) { this.setProperty("talon_Password", talon_Password.toString()); } if (talon_AdditionalParams != null) { this.setProperty("talon_AdditionalParams", talon_AdditionalParams.toString()); } if (talon_Port != null) { this.setProperty("talon_Port", talon_Port.toString()); } if (talon_Database != null) { this.setProperty("talon_Database", talon_Database.toString()); } if (talon_Server != null) { this.setProperty("talon_Server", talon_Server.toString()); } if (talon_Login != null) { this.setProperty("talon_Login", talon_Login.toString()); } if (propertyImage != null) { this.setProperty("propertyImage", propertyImage.toString()); } if (tmpDataStore != null) { this.setProperty("tmpDataStore", tmpDataStore.toString()); } if (propBaseXml != null) { this.setProperty("propBaseXml", propBaseXml.toString()); } } public String propertyUUId; public String getPropertyUUId() { return this.propertyUUId; } public String propertySourceUri; public String getPropertySourceUri() { return this.propertySourceUri; } public java.lang.String talon_Password; public java.lang.String getTalon_Password() { return this.talon_Password; } public String talon_AdditionalParams; public String getTalon_AdditionalParams() { return this.talon_AdditionalParams; } public String talon_Port; public String getTalon_Port() { return this.talon_Port; } public String talon_Database; public String getTalon_Database() { return this.talon_Database; } public String talon_Server; public String getTalon_Server() { return this.talon_Server; } public String talon_Login; public String getTalon_Login() { return this.talon_Login; } public String propertyImage; public String getPropertyImage() { return this.propertyImage; } public String tmpDataStore; public String getTmpDataStore() { return this.tmpDataStore; } public String propBaseXml; public String getPropBaseXml() { return this.propBaseXml; } } private ContextProperties context = new ContextProperties(); public ContextProperties getContext() { return this.context; } private final String jobVersion = "0.2"; private final String jobName = "loadPropertyImages"; private final String projectName = "TALONETL"; public Integer errorCode = null; private String currentComponent = ""; 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>(); private final java.util.Map<String, Object> globalMap = new java.util.HashMap<String, Object>(); public final java.util.List<String[]> globalBuffer = new java.util.ArrayList<String[]>(); public boolean isExportedAsOSGI = false; // 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); } 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 = null; 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 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; } @Override public void printStackTrace() { if (!(e instanceof TalendException || e instanceof TDieException)) { globalMap.put(currentComponent + "_ERROR_MESSAGE", e.getMessage()); System.err.println("Exception in component " + currentComponent); } if (!(e instanceof TDieException)) { if (e instanceof TalendException) { e.printStackTrace(); } else { e.printStackTrace(); e.printStackTrace(errorMessagePS); loadPropertyImages.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(loadPropertyImages.this, new Object[] { e, currentComponent, globalMap }); break; } } if (!(e instanceof TDieException)) { } } catch (java.lang.SecurityException e) { this.e.printStackTrace(); } catch (java.lang.IllegalArgumentException e) { this.e.printStackTrace(); } catch (java.lang.IllegalAccessException e) { this.e.printStackTrace(); } catch (java.lang.reflect.InvocationTargetException e) { this.e.printStackTrace(); } } else { status = "failure"; } } } public void tFileFetch_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put("tFileFetch_1", System.currentTimeMillis()); status = "failure"; tFileFetch_1_onSubJobError(exception, errorComponent, globalMap); } public void tJava_4_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put("tJava_4", System.currentTimeMillis()); status = "failure"; tJava_4_onSubJobError(exception, errorComponent, globalMap); } public void tFileInputXML_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put("tFileInputXML_1", System.currentTimeMillis()); status = "failure"; tFileInputXML_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("tMap_1", System.currentTimeMillis()); status = "failure"; tFileInputXML_1_onSubJobError(exception, errorComponent, globalMap); } public void tJavaRow_1_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put("tJavaRow_1", System.currentTimeMillis()); status = "failure"; tFileInputXML_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("tMap_2", System.currentTimeMillis()); status = "failure"; tFileInputXML_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("tMysqlOutput_1", System.currentTimeMillis()); status = "failure"; tFileInputXML_1_onSubJobError(exception, errorComponent, globalMap); } public void tJava_6_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put("tJava_6", System.currentTimeMillis()); status = "failure"; tJava_6_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("tMysqlInput_2", System.currentTimeMillis()); status = "failure"; tMysqlInput_2_onSubJobError(exception, errorComponent, globalMap); } public void tJava_3_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put("tJava_3", System.currentTimeMillis()); status = "failure"; tJava_3_onSubJobError(exception, errorComponent, globalMap); } public void tAdvancedHash_row2_error(Exception exception, String errorComponent, final java.util.Map<String, Object> globalMap) throws TalendException { end_Hash.put("tAdvancedHash_row2", System.currentTimeMillis()); status = "failure"; tMysqlInput_2_onSubJobError(exception, errorComponent, globalMap); } public void tFileFetch_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 tJava_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 tFileInputXML_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 tJava_6_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 tJava_3_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), ""); } private ESBProviderCallback callback = null; public void setProviderCallback(ESBProviderCallback callback) { } public ESBEndpointInfo getEndpoint() { return null; } public void tFileFetch_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFileFetch_1_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try { String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; /** * [tFileFetch_1 begin ] start */ ok_Hash.put("tFileFetch_1", false); start_Hash.put("tFileFetch_1", System.currentTimeMillis()); currentComponent = "tFileFetch_1"; int tos_count_tFileFetch_1 = 0; /** * [tFileFetch_1 begin ] stop */ /** * [tFileFetch_1 main ] start */ currentComponent = "tFileFetch_1"; java.io.InputStream retIS_tFileFetch_1 = null; org.apache.commons.httpclient.HttpClient client_tFileFetch_1 = new org.apache.commons.httpclient.HttpClient(); client_tFileFetch_1.getHttpConnectionManager().getParams().setConnectionTimeout(30000); client_tFileFetch_1.getParams() .setCookiePolicy(org.apache.commons.httpclient.cookie.CookiePolicy.DEFAULT); org.apache.commons.httpclient.methods.GetMethod method_tFileFetch_1 = new org.apache.commons.httpclient.methods.GetMethod( context.propertySourceUri); boolean isContinue_tFileFetch_1 = true; int status_tFileFetch_1; String finalURL_tFileFetch_1 = context.propertySourceUri; try { // B_01 status_tFileFetch_1 = client_tFileFetch_1.executeMethod(method_tFileFetch_1); if (status_tFileFetch_1 != org.apache.commons.httpclient.HttpStatus.SC_OK) { throw new Exception("Method failed: " + method_tFileFetch_1.getStatusLine()); } } catch (Exception e) { throw (e); } if (isContinue_tFileFetch_1) { retIS_tFileFetch_1 = method_tFileFetch_1.getResponseBodyAsStream(); } // B_01 java.io.InputStream streamtFileFetch_1 = (java.io.InputStream) globalMap .get("tFileFetch_1_INPUT_STREAM"); if (streamtFileFetch_1 != null) { streamtFileFetch_1.close(); } globalMap.put("tFileFetch_1_INPUT_STREAM", retIS_tFileFetch_1); tos_count_tFileFetch_1++; /** * [tFileFetch_1 main ] stop */ /** * [tFileFetch_1 end ] start */ currentComponent = "tFileFetch_1"; ok_Hash.put("tFileFetch_1", true); end_Hash.put("tFileFetch_1", System.currentTimeMillis()); tJava_4Process(globalMap); /** * [tFileFetch_1 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tFileFetch_1_SUBPROCESS_STATE", 1); } public void tJava_4Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tJava_4_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try { String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; /** * [tJava_4 begin ] start */ ok_Hash.put("tJava_4", false); start_Hash.put("tJava_4", System.currentTimeMillis()); currentComponent = "tJava_4"; int tos_count_tJava_4 = 0; System.out.println("***** Load new Property Image Data *****"); /** * [tJava_4 begin ] stop */ /** * [tJava_4 main ] start */ currentComponent = "tJava_4"; tos_count_tJava_4++; /** * [tJava_4 main ] stop */ /** * [tJava_4 end ] start */ currentComponent = "tJava_4"; ok_Hash.put("tJava_4", true); end_Hash.put("tJava_4", System.currentTimeMillis()); tFileInputXML_1Process(globalMap); /** * [tJava_4 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tJava_4_SUBPROCESS_STATE", 1); } public static class loadDataStruct implements routines.system.IPersistableRow<loadDataStruct> { final static byte[] commonByteArrayLock_TALONETL_loadPropertyImages = new byte[0]; static byte[] commonByteArray_TALONETL_loadPropertyImages = 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 int ID; public int getID() { return this.ID; } public String TITLE; public String getTITLE() { return this.TITLE; } public String TYPE; public String getTYPE() { return this.TYPE; } public int SIZE; public int getSIZE() { return this.SIZE; } public String SRC_URL; public String getSRC_URL() { return this.SRC_URL; } public int PROPERTY_DATA_ID; public int getPROPERTY_DATA_ID() { return this.PROPERTY_DATA_ID; } @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 loadDataStruct other = (loadDataStruct) obj; if (this.ID != other.ID) return false; return true; } public void copyDataTo(loadDataStruct other) { other.ID = this.ID; other.TITLE = this.TITLE; other.TYPE = this.TYPE; other.SIZE = this.SIZE; other.SRC_URL = this.SRC_URL; other.PROPERTY_DATA_ID = this.PROPERTY_DATA_ID; } public void copyKeysDataTo(loadDataStruct 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_TALONETL_loadPropertyImages.length) { if (length < 1024 && commonByteArray_TALONETL_loadPropertyImages.length == 0) { commonByteArray_TALONETL_loadPropertyImages = new byte[1024]; } else { commonByteArray_TALONETL_loadPropertyImages = new byte[2 * length]; } } dis.readFully(commonByteArray_TALONETL_loadPropertyImages, 0, length); strReturn = new String(commonByteArray_TALONETL_loadPropertyImages, 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_TALONETL_loadPropertyImages) { try { int length = 0; this.ID = dis.readInt(); this.TITLE = readString(dis); this.TYPE = readString(dis); this.SIZE = dis.readInt(); this.SRC_URL = readString(dis); this.PROPERTY_DATA_ID = dis.readInt(); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // int dos.writeInt(this.ID); // String writeString(this.TITLE, dos); // String writeString(this.TYPE, dos); // int dos.writeInt(this.SIZE); // String writeString(this.SRC_URL, dos); // int dos.writeInt(this.PROPERTY_DATA_ID); } 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(",TITLE=" + TITLE); sb.append(",TYPE=" + TYPE); sb.append(",SIZE=" + String.valueOf(SIZE)); sb.append(",SRC_URL=" + SRC_URL); sb.append(",PROPERTY_DATA_ID=" + String.valueOf(PROPERTY_DATA_ID)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(loadDataStruct 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 row5Struct implements routines.system.IPersistableRow<row5Struct> { final static byte[] commonByteArrayLock_TALONETL_loadPropertyImages = new byte[0]; static byte[] commonByteArray_TALONETL_loadPropertyImages = new byte[0]; public String image_title; public String getImage_title() { return this.image_title; } public String image_url; public String getImage_url() { return this.image_url; } public String propertyName; public String getPropertyName() { return this.propertyName; } public String type; public String getType() { return this.type; } 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_TALONETL_loadPropertyImages.length) { if (length < 1024 && commonByteArray_TALONETL_loadPropertyImages.length == 0) { commonByteArray_TALONETL_loadPropertyImages = new byte[1024]; } else { commonByteArray_TALONETL_loadPropertyImages = new byte[2 * length]; } } dis.readFully(commonByteArray_TALONETL_loadPropertyImages, 0, length); strReturn = new String(commonByteArray_TALONETL_loadPropertyImages, 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_TALONETL_loadPropertyImages) { try { int length = 0; this.image_title = readString(dis); this.image_url = readString(dis); this.propertyName = readString(dis); this.type = readString(dis); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // String writeString(this.image_title, dos); // String writeString(this.image_url, dos); // String writeString(this.propertyName, dos); // String writeString(this.type, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("image_title=" + image_title); sb.append(",image_url=" + image_url); sb.append(",propertyName=" + propertyName); sb.append(",type=" + type); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(row5Struct 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 static class imageDataStruct implements routines.system.IPersistableRow<imageDataStruct> { final static byte[] commonByteArrayLock_TALONETL_loadPropertyImages = new byte[0]; static byte[] commonByteArray_TALONETL_loadPropertyImages = new byte[0]; public String image_title; public String getImage_title() { return this.image_title; } public String image_url; public String getImage_url() { return this.image_url; } public String propertyName; public String getPropertyName() { return this.propertyName; } 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_TALONETL_loadPropertyImages.length) { if (length < 1024 && commonByteArray_TALONETL_loadPropertyImages.length == 0) { commonByteArray_TALONETL_loadPropertyImages = new byte[1024]; } else { commonByteArray_TALONETL_loadPropertyImages = new byte[2 * length]; } } dis.readFully(commonByteArray_TALONETL_loadPropertyImages, 0, length); strReturn = new String(commonByteArray_TALONETL_loadPropertyImages, 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_TALONETL_loadPropertyImages) { try { int length = 0; this.image_title = readString(dis); this.image_url = readString(dis); this.propertyName = readString(dis); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // String writeString(this.image_title, dos); // String writeString(this.image_url, dos); // String writeString(this.propertyName, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("image_title=" + image_title); sb.append(",image_url=" + image_url); sb.append(",propertyName=" + propertyName); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(imageDataStruct 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 static class row1Struct implements routines.system.IPersistableRow<row1Struct> { final static byte[] commonByteArrayLock_TALONETL_loadPropertyImages = new byte[0]; static byte[] commonByteArray_TALONETL_loadPropertyImages = new byte[0]; public String name; public String getName() { return this.name; } public String image_url; public String getImage_url() { return this.image_url; } public String image_title; public String getImage_title() { return this.image_title; } 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_TALONETL_loadPropertyImages.length) { if (length < 1024 && commonByteArray_TALONETL_loadPropertyImages.length == 0) { commonByteArray_TALONETL_loadPropertyImages = new byte[1024]; } else { commonByteArray_TALONETL_loadPropertyImages = new byte[2 * length]; } } dis.readFully(commonByteArray_TALONETL_loadPropertyImages, 0, length); strReturn = new String(commonByteArray_TALONETL_loadPropertyImages, 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_TALONETL_loadPropertyImages) { try { int length = 0; this.name = readString(dis); this.image_url = readString(dis); this.image_title = readString(dis); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // String writeString(this.name, dos); // String writeString(this.image_url, dos); // String writeString(this.image_title, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("name=" + name); sb.append(",image_url=" + image_url); sb.append(",image_title=" + image_title); 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 static class after_tFileInputXML_1Struct implements routines.system.IPersistableRow<after_tFileInputXML_1Struct> { final static byte[] commonByteArrayLock_TALONETL_loadPropertyImages = new byte[0]; static byte[] commonByteArray_TALONETL_loadPropertyImages = new byte[0]; public String name; public String getName() { return this.name; } public String image_url; public String getImage_url() { return this.image_url; } public String image_title; public String getImage_title() { return this.image_title; } 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_TALONETL_loadPropertyImages.length) { if (length < 1024 && commonByteArray_TALONETL_loadPropertyImages.length == 0) { commonByteArray_TALONETL_loadPropertyImages = new byte[1024]; } else { commonByteArray_TALONETL_loadPropertyImages = new byte[2 * length]; } } dis.readFully(commonByteArray_TALONETL_loadPropertyImages, 0, length); strReturn = new String(commonByteArray_TALONETL_loadPropertyImages, 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_TALONETL_loadPropertyImages) { try { int length = 0; this.name = readString(dis); this.image_url = readString(dis); this.image_title = readString(dis); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeData(ObjectOutputStream dos) { try { // String writeString(this.name, dos); // String writeString(this.image_url, dos); // String writeString(this.image_title, dos); } catch (IOException e) { throw new RuntimeException(e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append(super.toString()); sb.append("["); sb.append("name=" + name); sb.append(",image_url=" + image_url); sb.append(",image_title=" + image_title); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(after_tFileInputXML_1Struct 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 tFileInputXML_1Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tFileInputXML_1_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try { String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; tMysqlInput_2Process(globalMap); row1Struct row1 = new row1Struct(); imageDataStruct imageData = new imageDataStruct(); row5Struct row5 = new row5Struct(); loadDataStruct loadData = new loadDataStruct(); /** * [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 = "PROPERTY_IMAGES"; 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; java.util.Map<String, routines.system.TalendDataSource> dataSources_tMysqlOutput_1 = (java.util.Map<String, routines.system.TalendDataSource>) globalMap .get(KEY_DB_DATASOURCES); if (null != dataSources_tMysqlOutput_1) { conn_tMysqlOutput_1 = dataSources_tMysqlOutput_1.get("").getConnection(); } else { String dbProperties_tMysqlOutput_1 = context.talon_AdditionalParams; String url_tMysqlOutput_1 = null; if (dbProperties_tMysqlOutput_1 == null || dbProperties_tMysqlOutput_1.trim().length() == 0) { url_tMysqlOutput_1 = "jdbc:mysql://" + context.talon_Server + ":" + context.talon_Port + "/" + context.talon_Database + "?" + "rewriteBatchedStatements=true"; } else { String properties_tMysqlOutput_1 = context.talon_AdditionalParams; if (!properties_tMysqlOutput_1.contains("rewriteBatchedStatements")) { properties_tMysqlOutput_1 += "&rewriteBatchedStatements=true"; } url_tMysqlOutput_1 = "jdbc:mysql://" + context.talon_Server + ":" + context.talon_Port + "/" + context.talon_Database + "?" + properties_tMysqlOutput_1; } String dbUser_tMysqlOutput_1 = context.talon_Login; String dbPwd_tMysqlOutput_1 = context.talon_Password; java.lang.Class.forName("org.gjt.mm.mysql.Driver"); conn_tMysqlOutput_1 = java.sql.DriverManager.getConnection(url_tMysqlOutput_1, dbUser_tMysqlOutput_1, dbPwd_tMysqlOutput_1); } conn_tMysqlOutput_1.setAutoCommit(false); int commitEvery_tMysqlOutput_1 = 10; int commitCounter_tMysqlOutput_1 = 0; int count_tMysqlOutput_1 = 0; String insert_tMysqlOutput_1 = "INSERT INTO `" + "PROPERTY_IMAGES" + "` (`ID`,`TITLE`,`TYPE`,`SIZE`,`SRC_URL`,`PROPERTY_DATA_ID`) VALUES (?,?,?,?,?,?)"; int batchSize_tMysqlOutput_1 = 10; int batchSizeCounter_tMysqlOutput_1 = 0; java.sql.PreparedStatement pstmt_tMysqlOutput_1 = conn_tMysqlOutput_1 .prepareStatement(insert_tMysqlOutput_1); /** * [tMysqlOutput_1 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 org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row2Struct> tHash_Lookup_row2 = (org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row2Struct>) ((org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row2Struct>) globalMap .get("tHash_Lookup_row2")); row2Struct row2HashKey = new row2Struct(); row2Struct row2Default = new row2Struct(); // ############################### // ############################### // # Vars initialization class Var__tMap_2__Struct { } Var__tMap_2__Struct Var__tMap_2 = new Var__tMap_2__Struct(); // ############################### // ############################### // # Outputs initialization loadDataStruct loadData_tmp = new loadDataStruct(); // ############################### /** * [tMap_2 begin ] stop */ /** * [tJavaRow_1 begin ] start */ ok_Hash.put("tJavaRow_1", false); start_Hash.put("tJavaRow_1", System.currentTimeMillis()); currentComponent = "tJavaRow_1"; int tos_count_tJavaRow_1 = 0; int nb_line_tJavaRow_1 = 0; /** * [tJavaRow_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 imageDataStruct imageData_tmp = new imageDataStruct(); // ############################### /** * [tMap_1 begin ] stop */ /** * [tFileInputXML_1 begin ] start */ ok_Hash.put("tFileInputXML_1", false); start_Hash.put("tFileInputXML_1", System.currentTimeMillis()); currentComponent = "tFileInputXML_1"; int tos_count_tFileInputXML_1 = 0; int nb_line_tFileInputXML_1 = 0; String os_tFileInputXML_1 = System.getProperty("os.name").toLowerCase(); boolean isWindows_tFileInputXML_1 = false; if (os_tFileInputXML_1.indexOf("windows") > -1 || os_tFileInputXML_1.indexOf("nt") > -1) { isWindows_tFileInputXML_1 = true; } class XML_API_tFileInputXML_1 { public boolean isDefNull(String[] node) throws javax.xml.transform.TransformerException { if (node[0] != null && node[1] != null && ("true").equals(node[1])) { return true; } return false; } public boolean isMissing(String[] node) throws javax.xml.transform.TransformerException { return node[0] == null ? true : false; } public boolean isEmpty(String[] node) throws javax.xml.transform.TransformerException { if (node[0] != null) { return node[0].length() == 0; } return false; } } XML_API_tFileInputXML_1 xml_api_tFileInputXML_1 = new XML_API_tFileInputXML_1(); String[] queryPaths_tFileInputXML_1 = new String[] { "../../../data/name", "../../../data/name" + "/@xsi:nil", "url", "url" + "/@xsi:nil", "title", "title" + "/@xsi:nil" }; boolean[] asXMLs_tFileInputXML_1 = new boolean[] { false, false, false, false, false, false }; String str_tFileInputXML_1 = ""; String[] node_tFileInputXML_1 = null; org.talend.xml.sax.SAXLooper looper_tFileInputXML_1 = new org.talend.xml.sax.SAXLooper( "/result/listings/listing/media/images/image", queryPaths_tFileInputXML_1, asXMLs_tFileInputXML_1); looper_tFileInputXML_1.setEncoding("UTF-8"); Object filename_tFileInputXML_1 = null; try { filename_tFileInputXML_1 = ((java.io.InputStream) globalMap.get("tFileFetch_1_INPUT_STREAM")); } catch (Exception e) { System.err.println(e.getMessage()); } if (filename_tFileInputXML_1 != null && filename_tFileInputXML_1 instanceof String && filename_tFileInputXML_1.toString().startsWith("//")) { if (!isWindows_tFileInputXML_1) { filename_tFileInputXML_1 = filename_tFileInputXML_1.toString().replaceFirst("//", "/"); } } if (filename_tFileInputXML_1 instanceof java.io.InputStream) { looper_tFileInputXML_1.parse((java.io.InputStream) filename_tFileInputXML_1); } else { looper_tFileInputXML_1.parse(String.valueOf(filename_tFileInputXML_1)); } java.util.Iterator<java.util.Map<String, String>> it_tFileInputXML_1 = looper_tFileInputXML_1 .iterator(); while (it_tFileInputXML_1.hasNext()) { java.util.Map<String, String> row_tFileInputXML_1 = it_tFileInputXML_1.next(); nb_line_tFileInputXML_1++; row1 = null; boolean whetherReject_tFileInputXML_1 = false; row1 = new row1Struct(); try { str_tFileInputXML_1 = row_tFileInputXML_1.get("../../../data/name"); node_tFileInputXML_1 = new String[] { str_tFileInputXML_1, row_tFileInputXML_1.get("../../../data/name" + "/@xsi:nil") }; if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) { row1.name = null; } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) { row1.name = ""; } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) { row1.name = null; } else { row1.name = str_tFileInputXML_1; } str_tFileInputXML_1 = row_tFileInputXML_1.get("url"); node_tFileInputXML_1 = new String[] { str_tFileInputXML_1, row_tFileInputXML_1.get("url" + "/@xsi:nil") }; if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) { row1.image_url = null; } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) { row1.image_url = ""; } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) { row1.image_url = null; } else { row1.image_url = str_tFileInputXML_1; } str_tFileInputXML_1 = row_tFileInputXML_1.get("title"); node_tFileInputXML_1 = new String[] { str_tFileInputXML_1, row_tFileInputXML_1.get("title" + "/@xsi:nil") }; if (xml_api_tFileInputXML_1.isDefNull(node_tFileInputXML_1)) { row1.image_title = null; } else if (xml_api_tFileInputXML_1.isEmpty(node_tFileInputXML_1)) { row1.image_title = ""; } else if (xml_api_tFileInputXML_1.isMissing(node_tFileInputXML_1)) { row1.image_title = null; } else { row1.image_title = str_tFileInputXML_1; } } catch (Exception e) { whetherReject_tFileInputXML_1 = true; System.err.println(e.getMessage()); row1 = null; } /** * [tFileInputXML_1 begin ] stop */ /** * [tFileInputXML_1 main ] start */ currentComponent = "tFileInputXML_1"; tos_count_tFileInputXML_1++; /** * [tFileInputXML_1 main ] stop */ // Start of branch "row1" if (row1 != null) { /** * [tMap_1 main ] start */ currentComponent = "tMap_1"; boolean hasCasePrimitiveKeyWithNull_tMap_1 = false; // ############################### // # Input tables (lookups) boolean rejectedInnerJoin_tMap_1 = false; boolean mainRowRejected_tMap_1 = false; // ############################### { // start of Var scope // ############################### // # Vars tables Var__tMap_1__Struct Var = Var__tMap_1;// ############################### // ############################### // # Output tables imageData = null; // # Output table : 'imageData' imageData_tmp.image_title = row1.image_title; imageData_tmp.image_url = row1.image_url; imageData_tmp.propertyName = row1.name; imageData = imageData_tmp; // ############################### } // end of Var scope rejectedInnerJoin_tMap_1 = false; tos_count_tMap_1++; /** * [tMap_1 main ] stop */ // Start of branch "imageData" if (imageData != null) { /** * [tJavaRow_1 main ] start */ currentComponent = "tJavaRow_1"; // Code generated according to input schema and // output schema row5.image_title = imageData.image_title; String image = imageData.image_title; if (image.startsWith("1_")) { row5.type = "header"; } else { row5.type = "gallery"; } context.propertyImage = imageData.propertyName; row5.image_url = imageData.image_url; row5.propertyName = imageData.propertyName; nb_line_tJavaRow_1++; tos_count_tJavaRow_1++; /** * [tJavaRow_1 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; // ///////////////////////////////////////////// // Starting Lookup Table "row2" // ///////////////////////////////////////////// boolean forceLooprow2 = false; row2Struct row2ObjectFromLookup = null; if (!rejectedInnerJoin_tMap_2) { // G_TM_M_020 hasCasePrimitiveKeyWithNull_tMap_2 = false; row2HashKey.PROP_NAME = imageData.propertyName; row2HashKey.hashCodeDirty = true; tHash_Lookup_row2.lookup(row2HashKey); if (!tHash_Lookup_row2.hasNext()) { // G_TM_M_090 rejectedInnerJoin_tMap_2 = true; } // G_TM_M_090 } // G_TM_M_020 if (tHash_Lookup_row2 != null && tHash_Lookup_row2.getCount(row2HashKey) > 1) { // G // 071 // System.out.println("WARNING: UNIQUE MATCH is configured for the lookup 'row2' and it contains more one result from keys : row2.PROP_NAME = '" // + row2HashKey.PROP_NAME + "'"); } // G 071 row2Struct row2 = null; row2Struct fromLookup_row2 = null; row2 = row2Default; if (tHash_Lookup_row2 != null && tHash_Lookup_row2.hasNext()) { // G 099 fromLookup_row2 = tHash_Lookup_row2.next(); } // G 099 if (fromLookup_row2 != null) { row2 = fromLookup_row2; } // ############################### { // start of Var scope // ############################### // # Vars tables Var__tMap_2__Struct Var = Var__tMap_2;// ############################### // ############################### // # Output tables loadData = null; if (!rejectedInnerJoin_tMap_2) { // # Output table : 'loadData' loadData_tmp.ID = 0; loadData_tmp.TITLE = row5.image_title; loadData_tmp.TYPE = row5.type; loadData_tmp.SIZE = 0; loadData_tmp.SRC_URL = row5.image_url; loadData_tmp.PROPERTY_DATA_ID = row2.ID; loadData = loadData_tmp; } // closing inner join bracket (2) // ############################### } // end of Var scope rejectedInnerJoin_tMap_2 = false; tos_count_tMap_2++; /** * [tMap_2 main ] stop */ // Start of branch "loadData" if (loadData != null) { /** * [tMysqlOutput_1 main ] start */ currentComponent = "tMysqlOutput_1"; whetherReject_tMysqlOutput_1 = false; pstmt_tMysqlOutput_1.setInt(1, loadData.ID); if (loadData.TITLE == null) { pstmt_tMysqlOutput_1.setNull(2, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_1.setString(2, loadData.TITLE); } if (loadData.TYPE == null) { pstmt_tMysqlOutput_1.setNull(3, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_1.setString(3, loadData.TYPE); } pstmt_tMysqlOutput_1.setInt(4, loadData.SIZE); if (loadData.SRC_URL == null) { pstmt_tMysqlOutput_1.setNull(5, java.sql.Types.VARCHAR); } else { pstmt_tMysqlOutput_1.setString(5, loadData.SRC_URL); } pstmt_tMysqlOutput_1.setInt(6, loadData.PROPERTY_DATA_ID); pstmt_tMysqlOutput_1.addBatch(); nb_line_tMysqlOutput_1++; batchSizeCounter_tMysqlOutput_1++; if (!whetherReject_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 : countEach_tMysqlOutput_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 : countEach_tMysqlOutput_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.out.println(e.getMessage()); } conn_tMysqlOutput_1.commit(); commitCounter_tMysqlOutput_1 = 0; } tos_count_tMysqlOutput_1++; /** * [tMysqlOutput_1 main ] stop */ } // End of branch "loadData" } // End of branch "imageData" } // End of branch "row1" /** * [tFileInputXML_1 end ] start */ currentComponent = "tFileInputXML_1"; } try { looper_tFileInputXML_1.handleTaskResponse(); } catch (Exception e) { System.err.println(e.getMessage()); } globalMap.put("tFileInputXML_1_NB_LINE", nb_line_tFileInputXML_1); ok_Hash.put("tFileInputXML_1", true); end_Hash.put("tFileInputXML_1", System.currentTimeMillis()); /** * [tFileInputXML_1 end ] stop */ /** * [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 */ /** * [tJavaRow_1 end ] start */ currentComponent = "tJavaRow_1"; globalMap.put("tJavaRow_1_NB_LINE", nb_line_tJavaRow_1); ok_Hash.put("tJavaRow_1", true); end_Hash.put("tJavaRow_1", System.currentTimeMillis()); /** * [tJavaRow_1 end ] stop */ /** * [tMap_2 end ] start */ currentComponent = "tMap_2"; // ############################### // # Lookup hashes releasing if (tHash_Lookup_row2 != null) { tHash_Lookup_row2.endGet(); } globalMap.remove("tHash_Lookup_row2"); // ############################### ok_Hash.put("tMap_2", true); end_Hash.put("tMap_2", System.currentTimeMillis()); /** * [tMap_2 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 : countEach_tMysqlOutput_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; try { if (pstmt_tMysqlOutput_1 != null) { int countSum_tMysqlOutput_1 = 0; for (int countEach_tMysqlOutput_1 : pstmt_tMysqlOutput_1.executeBatch()) { countSum_tMysqlOutput_1 += (countEach_tMysqlOutput_1 < 0 ? 0 : countEach_tMysqlOutput_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.out.println(e.getMessage()); } if (pstmt_tMysqlOutput_1 != null) { pstmt_tMysqlOutput_1.close(); } conn_tMysqlOutput_1.commit(); conn_tMysqlOutput_1.close(); 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()); tJava_6Process(globalMap); /** * [tMysqlOutput_1 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } finally { // free memory for "tMap_2" globalMap.put("tHash_Lookup_row2", null); } globalMap.put("tFileInputXML_1_SUBPROCESS_STATE", 1); } public void tJava_6Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tJava_6_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try { String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; /** * [tJava_6 begin ] start */ ok_Hash.put("tJava_6", false); start_Hash.put("tJava_6", System.currentTimeMillis()); currentComponent = "tJava_6"; int tos_count_tJava_6 = 0; String message = String.format("*** New Image Added for:%s Image:%s ***", context.propertyUUId, context.propertyImage); System.out.println(message); /** * [tJava_6 begin ] stop */ /** * [tJava_6 main ] start */ currentComponent = "tJava_6"; tos_count_tJava_6++; /** * [tJava_6 main ] stop */ /** * [tJava_6 end ] start */ currentComponent = "tJava_6"; ok_Hash.put("tJava_6", true); end_Hash.put("tJava_6", System.currentTimeMillis()); /** * [tJava_6 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tJava_6_SUBPROCESS_STATE", 1); } public static class row2Struct implements routines.system.IPersistableComparableLookupRow<row2Struct> { final static byte[] commonByteArrayLock_TALONETL_loadPropertyImages = new byte[0]; static byte[] commonByteArray_TALONETL_loadPropertyImages = 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 int ID; public int getID() { return this.ID; } public String UUID; public String getUUID() { return this.UUID; } public String PROP_NAME; public String getPROP_NAME() { return this.PROP_NAME; } public float PRICE; public float getPRICE() { return this.PRICE; } public float SQFT; public float getSQFT() { return this.SQFT; } public String DESCRIPTION; public String getDESCRIPTION() { return this.DESCRIPTION; } public float NUM_BEDS; public float getNUM_BEDS() { return this.NUM_BEDS; } public float NUM_BATHS; public float getNUM_BATHS() { return this.NUM_BATHS; } public String TYPE; public String getTYPE() { return this.TYPE; } public String STATUS; public String getSTATUS() { return this.STATUS; } public int DATA_SOURCE_ID; public int getDATA_SOURCE_ID() { return this.DATA_SOURCE_ID; } public int ZIP_CODE; public int getZIP_CODE() { return this.ZIP_CODE; } @Override public int hashCode() { if (this.hashCodeDirty) { final int prime = PRIME; int result = DEFAULT_HASHCODE; result = prime * result + ((this.PROP_NAME == null) ? 0 : this.PROP_NAME.hashCode()); 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 row2Struct other = (row2Struct) obj; if (this.PROP_NAME == null) { if (other.PROP_NAME != null) return false; } else if (!this.PROP_NAME.equals(other.PROP_NAME)) return false; return true; } public void copyDataTo(row2Struct other) { other.ID = this.ID; other.UUID = this.UUID; other.PROP_NAME = this.PROP_NAME; other.PRICE = this.PRICE; other.SQFT = this.SQFT; other.DESCRIPTION = this.DESCRIPTION; other.NUM_BEDS = this.NUM_BEDS; other.NUM_BATHS = this.NUM_BATHS; other.TYPE = this.TYPE; other.STATUS = this.STATUS; other.DATA_SOURCE_ID = this.DATA_SOURCE_ID; other.ZIP_CODE = this.ZIP_CODE; } public void copyKeysDataTo(row2Struct other) { other.PROP_NAME = this.PROP_NAME; } private String readString(DataInputStream dis, ObjectInputStream ois) throws IOException { String strReturn = null; int length = 0; length = dis.readInt(); if (length == -1) { strReturn = null; } else { byte[] byteArray = new byte[length]; dis.read(byteArray); strReturn = new String(byteArray, utf8Charset); } return strReturn; } private void writeString(String str, DataOutputStream dos, ObjectOutputStream oos) throws IOException { if (str == null) { dos.writeInt(-1); } else { byte[] byteArray = str.getBytes(utf8Charset); dos.writeInt(byteArray.length); dos.write(byteArray); } } 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_TALONETL_loadPropertyImages.length) { if (length < 1024 && commonByteArray_TALONETL_loadPropertyImages.length == 0) { commonByteArray_TALONETL_loadPropertyImages = new byte[1024]; } else { commonByteArray_TALONETL_loadPropertyImages = new byte[2 * length]; } } dis.readFully(commonByteArray_TALONETL_loadPropertyImages, 0, length); strReturn = new String(commonByteArray_TALONETL_loadPropertyImages, 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 readKeysData(ObjectInputStream dis) { synchronized (commonByteArrayLock_TALONETL_loadPropertyImages) { try { int length = 0; this.PROP_NAME = readString(dis); } catch (IOException e) { throw new RuntimeException(e); } } } public void writeKeysData(ObjectOutputStream dos) { try { // String writeString(this.PROP_NAME, dos); } catch (IOException e) { throw new RuntimeException(e); } } /** * Fill Values data by reading ObjectInputStream. */ public void readValuesData(DataInputStream dis, ObjectInputStream ois) { try { int length = 0; this.ID = dis.readInt(); this.UUID = readString(dis, ois); this.PRICE = dis.readFloat(); this.SQFT = dis.readFloat(); this.DESCRIPTION = readString(dis, ois); this.NUM_BEDS = dis.readFloat(); this.NUM_BATHS = dis.readFloat(); this.TYPE = readString(dis, ois); this.STATUS = readString(dis, ois); this.DATA_SOURCE_ID = dis.readInt(); this.ZIP_CODE = dis.readInt(); } catch (IOException e) { throw new RuntimeException(e); } } /** * Return a byte array which represents Values data. */ public void writeValuesData(DataOutputStream dos, ObjectOutputStream oos) { try { dos.writeInt(this.ID); writeString(this.UUID, dos, oos); dos.writeFloat(this.PRICE); dos.writeFloat(this.SQFT); writeString(this.DESCRIPTION, dos, oos); dos.writeFloat(this.NUM_BEDS); dos.writeFloat(this.NUM_BATHS); writeString(this.TYPE, dos, oos); writeString(this.STATUS, dos, oos); dos.writeInt(this.DATA_SOURCE_ID); dos.writeInt(this.ZIP_CODE); } 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(",UUID=" + UUID); sb.append(",PROP_NAME=" + PROP_NAME); sb.append(",PRICE=" + String.valueOf(PRICE)); sb.append(",SQFT=" + String.valueOf(SQFT)); sb.append(",DESCRIPTION=" + DESCRIPTION); sb.append(",NUM_BEDS=" + String.valueOf(NUM_BEDS)); sb.append(",NUM_BATHS=" + String.valueOf(NUM_BATHS)); sb.append(",TYPE=" + TYPE); sb.append(",STATUS=" + STATUS); sb.append(",DATA_SOURCE_ID=" + String.valueOf(DATA_SOURCE_ID)); sb.append(",ZIP_CODE=" + String.valueOf(ZIP_CODE)); sb.append("]"); return sb.toString(); } /** * Compare keys */ public int compareTo(row2Struct other) { int returnValue = -1; returnValue = checkNullsAndCompare(this.PROP_NAME, other.PROP_NAME); 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_2Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tMysqlInput_2_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try { String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; row2Struct row2 = new row2Struct(); /** * [tAdvancedHash_row2 begin ] start */ ok_Hash.put("tAdvancedHash_row2", false); start_Hash.put("tAdvancedHash_row2", System.currentTimeMillis()); currentComponent = "tAdvancedHash_row2"; int tos_count_tAdvancedHash_row2 = 0; // connection name:row2 // source node:tMysqlInput_2 - inputs:(after_tFileInputXML_1) // outputs:(row2,row2) | target node:tAdvancedHash_row2 - // inputs:(row2) outputs:() // linked node: tMap_2 - inputs:(row5,row2) outputs:(loadData) org.talend.designer.components.lookup.common.ICommonLookup.MATCHING_MODE matchingModeEnum_row2 = org.talend.designer.components.lookup.common.ICommonLookup.MATCHING_MODE.UNIQUE_MATCH; org.talend.designer.components.lookup.memory.AdvancedMemoryLookup<row2Struct> tHash_Lookup_row2 = org.talend.designer.components.lookup.memory.AdvancedMemoryLookup .<row2Struct>getLookup(matchingModeEnum_row2); globalMap.put("tHash_Lookup_row2", tHash_Lookup_row2); /** * [tAdvancedHash_row2 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; java.util.Map<String, routines.system.TalendDataSource> dataSources_tMysqlInput_2 = (java.util.Map<String, routines.system.TalendDataSource>) globalMap .get(KEY_DB_DATASOURCES); if (null != dataSources_tMysqlInput_2) { conn_tMysqlInput_2 = dataSources_tMysqlInput_2.get("").getConnection(); } else { java.lang.Class.forName("org.gjt.mm.mysql.Driver"); String url_tMysqlInput_2 = "jdbc:mysql://" + context.talon_Server + ":" + context.talon_Port + "/" + context.talon_Database + "?" + context.talon_AdditionalParams; String dbUser_tMysqlInput_2 = context.talon_Login; String dbPwd_tMysqlInput_2 = context.talon_Password; 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 `PROPERTY_DATA`.`ID`, `PROPERTY_DATA`.`UUID`, `PROPERTY_DATA`.`PROP_NAME`, `PROPERTY_DATA`.`PRICE`, `PROPERTY_DATA`.`SQFT`, `PROPERTY_DATA`.`DESCRIPTION`, `PROPERTY_DATA`.`NUM_BEDS`, `PROPERTY_DATA`.`NUM_BATHS`, `PROPERTY_DATA`.`TYPE`, `PROPERTY_DATA`.`STATUS`, `PROPERTY_DATA`.`ZIP_CODE`, `PROPERTY_DATA`.`DATA_SOURCE_ID` FROM `PROPERTY_DATA`"; globalMap.put("tMysqlInput_2_QUERY", dbquery_tMysqlInput_2); java.sql.ResultSet 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.ID = 0; } else { if (rs_tMysqlInput_2.getObject(1) != null) { row2.ID = rs_tMysqlInput_2.getInt(1); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_2 < 2) { row2.UUID = null; } else { tmpContent_tMysqlInput_2 = rs_tMysqlInput_2.getString(2); if (tmpContent_tMysqlInput_2 != null) { row2.UUID = tmpContent_tMysqlInput_2; } else { row2.UUID = null; } } if (colQtyInRs_tMysqlInput_2 < 3) { row2.PROP_NAME = null; } else { tmpContent_tMysqlInput_2 = rs_tMysqlInput_2.getString(3); if (tmpContent_tMysqlInput_2 != null) { row2.PROP_NAME = tmpContent_tMysqlInput_2; } else { row2.PROP_NAME = null; } } if (colQtyInRs_tMysqlInput_2 < 4) { row2.PRICE = 0; } else { if (rs_tMysqlInput_2.getObject(4) != null) { row2.PRICE = rs_tMysqlInput_2.getFloat(4); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_2 < 5) { row2.SQFT = 0; } else { if (rs_tMysqlInput_2.getObject(5) != null) { row2.SQFT = rs_tMysqlInput_2.getFloat(5); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_2 < 6) { row2.DESCRIPTION = null; } else { tmpContent_tMysqlInput_2 = rs_tMysqlInput_2.getString(6); if (tmpContent_tMysqlInput_2 != null) { row2.DESCRIPTION = tmpContent_tMysqlInput_2; } else { row2.DESCRIPTION = null; } } if (colQtyInRs_tMysqlInput_2 < 7) { row2.NUM_BEDS = 0; } else { if (rs_tMysqlInput_2.getObject(7) != null) { row2.NUM_BEDS = rs_tMysqlInput_2.getFloat(7); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_2 < 8) { row2.NUM_BATHS = 0; } else { if (rs_tMysqlInput_2.getObject(8) != null) { row2.NUM_BATHS = rs_tMysqlInput_2.getFloat(8); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_2 < 9) { row2.TYPE = null; } else { tmpContent_tMysqlInput_2 = rs_tMysqlInput_2.getString(9); if (tmpContent_tMysqlInput_2 != null) { row2.TYPE = tmpContent_tMysqlInput_2; } else { row2.TYPE = null; } } if (colQtyInRs_tMysqlInput_2 < 10) { row2.STATUS = null; } else { tmpContent_tMysqlInput_2 = rs_tMysqlInput_2.getString(10); if (tmpContent_tMysqlInput_2 != null) { row2.STATUS = tmpContent_tMysqlInput_2; } else { row2.STATUS = null; } } if (colQtyInRs_tMysqlInput_2 < 11) { row2.DATA_SOURCE_ID = 0; } else { if (rs_tMysqlInput_2.getObject(11) != null) { row2.DATA_SOURCE_ID = rs_tMysqlInput_2.getInt(11); } else { throw new RuntimeException("Null value in non-Nullable column"); } } if (colQtyInRs_tMysqlInput_2 < 12) { row2.ZIP_CODE = 0; } else { if (rs_tMysqlInput_2.getObject(12) != null) { row2.ZIP_CODE = rs_tMysqlInput_2.getInt(12); } 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 */ /** * [tAdvancedHash_row2 main ] start */ currentComponent = "tAdvancedHash_row2"; row2Struct row2_HashRow = new row2Struct(); row2_HashRow.ID = row2.ID; row2_HashRow.UUID = row2.UUID; row2_HashRow.PROP_NAME = row2.PROP_NAME; row2_HashRow.PRICE = row2.PRICE; row2_HashRow.SQFT = row2.SQFT; row2_HashRow.DESCRIPTION = row2.DESCRIPTION; row2_HashRow.NUM_BEDS = row2.NUM_BEDS; row2_HashRow.NUM_BATHS = row2.NUM_BATHS; row2_HashRow.TYPE = row2.TYPE; row2_HashRow.STATUS = row2.STATUS; row2_HashRow.DATA_SOURCE_ID = row2.DATA_SOURCE_ID; row2_HashRow.ZIP_CODE = row2.ZIP_CODE; tHash_Lookup_row2.put(row2_HashRow); tos_count_tAdvancedHash_row2++; /** * [tAdvancedHash_row2 main ] stop */ /** * [tMysqlInput_2 end ] start */ currentComponent = "tMysqlInput_2"; } rs_tMysqlInput_2.close(); stmt_tMysqlInput_2.close(); 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 */ /** * [tAdvancedHash_row2 end ] start */ currentComponent = "tAdvancedHash_row2"; tHash_Lookup_row2.endPut(); ok_Hash.put("tAdvancedHash_row2", true); end_Hash.put("tAdvancedHash_row2", System.currentTimeMillis()); /** * [tAdvancedHash_row2 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tMysqlInput_2_SUBPROCESS_STATE", 1); } public void tJava_3Process(final java.util.Map<String, Object> globalMap) throws TalendException { globalMap.put("tJava_3_SUBPROCESS_STATE", 0); final boolean execStat = this.execStat; String iterateId = ""; int iterateLoop = 0; String currentComponent = ""; try { String currentMethodName = new Exception().getStackTrace()[0].getMethodName(); boolean resumeIt = currentMethodName.equals(resumeEntryMethodName); if (resumeEntryMethodName == null || resumeIt || globalResumeTicket) {// start // the // resume globalResumeTicket = true; /** * [tJava_3 begin ] start */ ok_Hash.put("tJava_3", false); start_Hash.put("tJava_3", System.currentTimeMillis()); currentComponent = "tJava_3"; int tos_count_tJava_3 = 0; System.out.println("***** Retrive new Property Image Data *****"); /** * [tJava_3 begin ] stop */ /** * [tJava_3 main ] start */ currentComponent = "tJava_3"; tos_count_tJava_3++; /** * [tJava_3 main ] stop */ /** * [tJava_3 end ] start */ currentComponent = "tJava_3"; ok_Hash.put("tJava_3", true); end_Hash.put("tJava_3", System.currentTimeMillis()); tFileFetch_1Process(globalMap); /** * [tJava_3 end ] stop */ } // end the resume } catch (Exception e) { throw new TalendException(e, currentComponent, globalMap); } catch (java.lang.Error error) { throw new java.lang.Error(error); } globalMap.put("tJava_3_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; 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 loadPropertyImages loadPropertyImagesClass = new loadPropertyImages(); int exitCode = loadPropertyImagesClass.runJobInTOS(args); System.exit(exitCode); } public String[][] runJob(String[] args) { int exitCode = runJobInTOS(args); String[][] bufferValue = new String[][] { { Integer.toString(exitCode) } }; return bufferValue; } public int runJobInTOS(String[] args) { 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 = loadPropertyImages.class.getClassLoader() .getResourceAsStream("talonetl/loadpropertyimages_0_2/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); } context.propertyUUId = (String) context.getProperty("propertyUUId"); context.propertySourceUri = (String) context.getProperty("propertySourceUri"); context.talon_Password = (java.lang.String) context.getProperty("talon_Password"); context.talon_AdditionalParams = (String) context.getProperty("talon_AdditionalParams"); context.talon_Port = (String) context.getProperty("talon_Port"); context.talon_Database = (String) context.getProperty("talon_Database"); context.talon_Server = (String) context.getProperty("talon_Server"); context.talon_Login = (String) context.getProperty("talon_Login"); context.propertyImage = (String) context.getProperty("propertyImage"); context.tmpDataStore = (String) context.getProperty("tmpDataStore"); context.propBaseXml = (String) context.getProperty("propBaseXml"); } 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()) { if (parentContextMap.containsKey("propertyUUId")) { context.propertyUUId = (String) parentContextMap.get("propertyUUId"); } if (parentContextMap.containsKey("propertySourceUri")) { context.propertySourceUri = (String) parentContextMap.get("propertySourceUri"); } if (parentContextMap.containsKey("talon_Password")) { context.talon_Password = (java.lang.String) parentContextMap.get("talon_Password"); } if (parentContextMap.containsKey("talon_AdditionalParams")) { context.talon_AdditionalParams = (String) parentContextMap.get("talon_AdditionalParams"); } if (parentContextMap.containsKey("talon_Port")) { context.talon_Port = (String) parentContextMap.get("talon_Port"); } if (parentContextMap.containsKey("talon_Database")) { context.talon_Database = (String) parentContextMap.get("talon_Database"); } if (parentContextMap.containsKey("talon_Server")) { context.talon_Server = (String) parentContextMap.get("talon_Server"); } if (parentContextMap.containsKey("talon_Login")) { context.talon_Login = (String) parentContextMap.get("talon_Login"); } if (parentContextMap.containsKey("propertyImage")) { context.propertyImage = (String) parentContextMap.get("propertyImage"); } if (parentContextMap.containsKey("tmpDataStore")) { context.tmpDataStore = (String) parentContextMap.get("tmpDataStore"); } if (parentContextMap.containsKey("propBaseXml")) { context.propBaseXml = (String) parentContextMap.get("propBaseXml"); } } // 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); // Resume: jobStart resumeUtil.addLog("JOB_STARTED", "JOB:" + jobName, parent_part_launcher, Thread.currentThread().getId() + "", "", "", "", "", resumeUtil.convertToJsonText(context)); 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; tJava_3Process(globalMap); if (!"failure".equals(status)) { status = "end"; } } catch (TalendException e_tJava_3) { e_tJava_3.printStackTrace(); globalMap.put("tJava_3_SUBPROCESS_STATE", -1); } 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 : loadPropertyImages"); } 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; } public void destroy() { } 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)); } } } } 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; } for (String[] strArray : escapeChars) { keyValue = keyValue.replace(strArray[0], strArray[1]); } return keyValue; } public Integer getErrorCode() { return errorCode; } public String getStatus() { return status; } ResumeUtil resumeUtil = null; } /************************************************************************************************ * 102770 characters generated by Talend Open Studio for Data Integration on the * June 18, 2013 6:08:18 AM MDT ************************************************************************************************/