public void logCompSetting() {
        if (log4jEnabled) {

          stringBuffer.append(TEXT_10);
          stringBuffer.append(var("log4jParamters"));
          stringBuffer.append(TEXT_11);
          stringBuffer.append(TEXT_12);
          stringBuffer.append(var("log4jParamters"));
          stringBuffer.append(TEXT_13);

          java.util.Set<org.talend.core.model.process.EParameterFieldType> ignoredParamsTypes =
              new java.util.HashSet<org.talend.core.model.process.EParameterFieldType>();
          ignoredParamsTypes.addAll(
              java.util.Arrays.asList(
                  org.talend.core.model.process.EParameterFieldType.SCHEMA_TYPE,
                  org.talend.core.model.process.EParameterFieldType.LABEL,
                  org.talend.core.model.process.EParameterFieldType.EXTERNAL,
                  org.talend.core.model.process.EParameterFieldType.MAPPING_TYPE,
                  org.talend.core.model.process.EParameterFieldType.IMAGE,
                  org.talend.core.model.process.EParameterFieldType.TNS_EDITOR,
                  org.talend.core.model.process.EParameterFieldType.WSDL2JAVA,
                  org.talend.core.model.process.EParameterFieldType.GENERATEGRAMMARCONTROLLER,
                  org.talend.core.model.process.EParameterFieldType
                      .GENERATE_SURVIVORSHIP_RULES_CONTROLLER,
                  org.talend.core.model.process.EParameterFieldType.REFRESH_REPORTS,
                  org.talend.core.model.process.EParameterFieldType.BROWSE_REPORTS,
                  org.talend.core.model.process.EParameterFieldType.PALO_DIM_SELECTION,
                  org.talend.core.model.process.EParameterFieldType.GUESS_SCHEMA,
                  org.talend.core.model.process.EParameterFieldType.MATCH_RULE_IMEX_CONTROLLER,
                  org.talend.core.model.process.EParameterFieldType.MEMO_PERL,
                  org.talend.core.model.process.EParameterFieldType.DBTYPE_LIST,
                  org.talend.core.model.process.EParameterFieldType.VERSION,
                  org.talend.core.model.process.EParameterFieldType.TECHNICAL,
                  org.talend.core.model.process.EParameterFieldType.ICON_SELECTION,
                  org.talend.core.model.process.EParameterFieldType.JAVA_COMMAND,
                  org.talend.core.model.process.EParameterFieldType.TREE_TABLE,
                  org.talend.core.model.process.EParameterFieldType.VALIDATION_RULE_TYPE,
                  org.talend.core.model.process.EParameterFieldType.DCSCHEMA,
                  org.talend.core.model.process.EParameterFieldType.SURVIVOR_RELATION,
                  org.talend.core.model.process.EParameterFieldType.REST_RESPONSE_SCHEMA_TYPE));
          for (org.talend.core.model.process.IElementParameter ep :
              org.talend.core.model.utils.NodeUtil.getDisplayedParameters(node)) {
            if (!ep.isLog4JEnabled() || ignoredParamsTypes.contains(ep.getFieldType())) {
              continue;
            }
            String name = ep.getName();
            if (org.talend.core.model.process.EParameterFieldType.PASSWORD.equals(
                ep.getFieldType())) {
              String epName = "__" + name + "__";
              String password = "";
              if (org.talend.core.model.process.ElementParameterParser.canEncrypt(node, epName)) {
                password =
                    org.talend.core.model.process.ElementParameterParser.getEncryptedValue(
                        node, epName);
              } else {
                String passwordValue =
                    org.talend.core.model.process.ElementParameterParser.getValue(node, epName);
                if (passwordValue == null
                    || "".equals(passwordValue.trim())) { // for the value which empty
                  passwordValue = "\"\"";
                }
                password =
                    "******" + passwordValue + ")";
              }

              stringBuffer.append(TEXT_14);
              stringBuffer.append(var("log4jParamters"));
              stringBuffer.append(TEXT_15);
              stringBuffer.append(name);
              stringBuffer.append(TEXT_16);
              stringBuffer.append(password);
              stringBuffer.append(TEXT_17);

            } else {
              String value =
                  org.talend.core.model.utils.NodeUtil.getNormalizeParameterValue(node, ep);

              stringBuffer.append(TEXT_18);
              stringBuffer.append(var("log4jParamters"));
              stringBuffer.append(TEXT_19);
              stringBuffer.append(name);
              stringBuffer.append(TEXT_20);
              stringBuffer.append(value);
              stringBuffer.append(TEXT_21);
            }

            stringBuffer.append(TEXT_22);
            stringBuffer.append(var("log4jParamters"));
            stringBuffer.append(TEXT_23);
          }
        }
        debug(var("log4jParamters"));
      }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

    // this util class use by set log4j debug paramters
    class DefaultLog4jFileUtil {

      INode node = null;
      String cid = null;
      boolean isLog4jEnabled = false;
      String label = null;

      public DefaultLog4jFileUtil() {}

      public DefaultLog4jFileUtil(INode node) {
        this.node = node;
        this.cid = node.getUniqueName();
        this.label = cid;
        this.isLog4jEnabled =
            ("true")
                .equals(
                    org.talend.core.model.process.ElementParameterParser.getValue(
                        node.getProcess(), "__LOG4J_ACTIVATE__"));
      }

      public void setCid(String cid) {
        this.cid = cid;
      }

      // for all tFileinput* components
      public void startRetriveDataInfo() {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_1);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_2);
        }
      }

      public void retrievedDataNumberInfo() {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_3);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_4);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_5);
        }
      }

      public void retrievedDataNumberInfoFromGlobalMap(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_6);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_7);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_8);
        }
      }

      // for all tFileinput* components
      public void retrievedDataNumberInfo(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_9);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_10);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_11);
        }
      }

      public void writeDataFinishInfo(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_12);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_13);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_14);
        }
      }

      // TODO delete it and remove all log4jSb parameter from components
      public void componentStartInfo(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_15);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_16);
        }
      }

      // TODO rename or delete it
      public void debugRetriveData(INode node, boolean hasIncreased) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_17);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_18);
          stringBuffer.append(cid);
          stringBuffer.append(hasIncreased ? "" : "+1");
          stringBuffer.append(TEXT_19);
        }
      }

      // TODO rename or delete it
      public void debugRetriveData(INode node) {
        debugRetriveData(node, true);
      }

      // TODO rename or delete it
      public void debugWriteData(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_20);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_21);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_22);
        }
      }

      public void logCurrentRowNumberInfo() {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_23);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_24);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_25);
        }
      }

      public void logDataCountInfo() {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_26);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_27);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_28);
        }
      }
    }

    final DefaultLog4jFileUtil log4jFileUtil =
        new DefaultLog4jFileUtil(
            (INode)
                (((org.talend.designer.codegen.config.CodeGeneratorArgument) argument)
                    .getArgument()));

    class DefaultLog4jCodeGenerateUtil extends DefaultLog4jFileUtil {

      String connection = "";
      boolean hasInit = false;
      String dataAction;
      String dataOperationPrefix;
      String useBatchSize;
      String batchSize;
      String dbSchema;
      boolean logCommitCounter = false;

      public DefaultLog4jCodeGenerateUtil() {}

      public DefaultLog4jCodeGenerateUtil(INode node) {
        super(node);
        init();
      }

      public void beforeComponentProcess(INode node) {
        this.node = node;
        init();
      }

      private void init() {
        if (hasInit) {
          return;
        }
        this.cid = node.getUniqueName();
        this.isLog4jEnabled =
            ("true")
                .equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
        String useConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__");
        if (useConn == null || "".equals(useConn) || "true".equals(useConn)) {
          connection = ElementParameterParser.getValue(node, "__CONNECTION__");
          if (!"".equals(connection)) {
            connection = "'" + connection + "' ";
          }
        }
        // for output
        dataAction = ElementParameterParser.getValue(node, "__DATA_ACTION__");
        if (dataAction != null && !("").equals(dataAction)) {
          logCommitCounter = true;
        }
        useBatchSize = ElementParameterParser.getValue(node, "__USE_BATCH_SIZE__");
        batchSize = ElementParameterParser.getValue(node, "__BATCH_SIZE__");
        hasInit = true;
      }

      public void debugDriverClassName() {
        logInfo(node, "debug", cid + " - Driver ClassName: \"+driverClass_" + cid + "+\".");
      }

      public void debugConnectionParams(INode node) {
        beforeComponentProcess(node);
        debugDriverClassName();
      }

      public void useExistConnection(INode node) {
        beforeComponentProcess(node);
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_29);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_30);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_31);
          if (cid.startsWith("tImpala") || cid.startsWith("tHive")) {
            stringBuffer.append(TEXT_32);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_33);
            stringBuffer.append(connection);
            stringBuffer.append(TEXT_34);
          } else {
            stringBuffer.append(TEXT_35);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_36);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_37);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_38);
          }
          stringBuffer.append(TEXT_39);
        }
      }

      public void connect(INode node) {
        beforeComponentProcess(node);
        connect();
      }

      public void connect() {
        connect_begin();

        stringBuffer.append(TEXT_40);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_41);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_42);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_43);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_44);

        connect_end();
      }

      public void connect_begin() {
        logInfo(
            node,
            "info",
            cid
                + " - Connection attempt to '\" + url_"
                + cid
                + " + \"' with the username '\" + dbUser_"
                + cid
                + " + \"'.");
      }

      public void connect_begin_noUser() {
        logInfo(node, "info", cid + " - Connection attempt to '\" + url_" + cid + " + \"'.");
      }

      public void connect_end() {
        logInfo(node, "info", cid + " - Connection to '\" + url_" + cid + " + \"' has succeeded.");
      }

      public void rollback(INode node) {
        beforeComponentProcess(node);
        logInfo(node, "debug", cid + " - Connection " + connection + "starting to rollback.");

        stringBuffer.append(TEXT_45);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_46);

        logInfo(node, "debug", cid + " - Connection " + connection + "rollback has succeeded.");
      }

      public void commit(INode node) {
        beforeComponentProcess(node);
        commit();
      }

      private void commit() {
        commit_begin();

        stringBuffer.append(TEXT_47);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_48);

        commit_end();
      }

      private void commit_begin() {
        if (logCommitCounter) {
          logInfo(
              node,
              "debug",
              cid
                  + " - Connection "
                  + connection
                  + "starting to commit \" + commitCounter_"
                  + cid
                  + "+ \" records.");
        } else {
          logInfo(node, "debug", cid + " - Connection " + connection + "starting to commit.");
        }
      }

      private void commit_end() {
        logInfo(node, "debug", cid + " - Connection " + connection + "commit has succeeded.");
      }

      public void close(INode node) {
        beforeComponentProcess(node);
        close();
      }

      private void close() {
        close_begin();

        stringBuffer.append(TEXT_49);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_50);

        close_end();
      }

      public void close_begin() {
        logInfo(node, "info", cid + " - Closing the connection " + connection + "to the database.");
      }

      public void close_end() {
        logInfo(node, "info", cid + " - Connection " + connection + "to the database closed.");
      }

      public void autoCommit(INode node, boolean autoCommit) {
        beforeComponentProcess(node);
        logInfo(node, "debug", cid + " - Connection is set auto commit to '" + autoCommit + "'.");

        stringBuffer.append(TEXT_51);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_52);
        stringBuffer.append(autoCommit);
        stringBuffer.append(TEXT_53);
      }

      public void query(INode node) {
        beforeComponentProcess(node);
        // for input
        String dbquery = ElementParameterParser.getValue(node, "__QUERY__");
        dbquery = dbquery.replaceAll("\n", " ");
        dbquery = dbquery.replaceAll("\r", " ");
        logInfo(node, "info", cid + " - Executing the query: '\" + " + dbquery + " + \"'.");
      }

      public void retrieveRecordsCount(INode node) {
        beforeComponentProcess(node);
        logInfo(node, "info", cid + " - Retrieved records count: \"+nb_line_" + cid + " + \" .");
      }

      public void logError(INode node, String logLevel, String exception) {
        beforeComponentProcess(node);
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_54);
          stringBuffer.append(logLevel);
          stringBuffer.append(TEXT_55);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_56);
          stringBuffer.append(exception);
          stringBuffer.append(TEXT_57);
        }
      }

      public void logError(INode node, String logLevel) {
        logError(node, logLevel, "e");
      }

      public void logInfo(INode node, String logLevel, String message) {
        beforeComponentProcess(node);
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_58);
          stringBuffer.append(logLevel);
          stringBuffer.append(TEXT_59);
          stringBuffer.append(message);
          stringBuffer.append(TEXT_60);
        }
      }
      /**
       * batchType : 1: do not get return value of executeBatch(); 2: get return value of
       * executeBatch();
       */
      public void executeBatch(INode node, int batchType) {
        beforeComponentProcess(node);
        boolean logBatch =
            ("true").equals(useBatchSize) && !("").equals(batchSize) && !("0").equals(batchSize);
        if (logBatch) {
          logInfo(node, "debug", cid + " - Executing the " + dataAction + " batch.");
        }
        if (batchType == 1) {

          stringBuffer.append(TEXT_61);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_62);

        } else if (batchType == 2) {
          boolean isMysqlBatchInsert = false;
          if ((node.getUniqueName().contains("tMysqlOutput")
                  || node.getUniqueName().contains("tAmazonMysqlOutput"))
              && ("INSERT").equals(dataAction)) {
            isMysqlBatchInsert = true;
          }

          stringBuffer.append(TEXT_63);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_64);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_65);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_66);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_67);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_68);
          stringBuffer.append(isMysqlBatchInsert ? "1" : "countEach_" + cid);
          stringBuffer.append(TEXT_69);
        }
        if (logBatch) {
          logInfo(node, "debug", cid + " - The " + dataAction + " batch execution has succeeded.");
        }
      }
    }

    DefaultLog4jCodeGenerateUtil log4jCodeGenerateUtil = new DefaultLog4jCodeGenerateUtil();

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    INode node = (INode) codeGenArgument.getArgument();
    String cid = node.getUniqueName();
    String localServiceName = ElementParameterParser.getValue(node, "__LOCAL_SERVICE_NAME__");
    String dbuser = ElementParameterParser.getValue(node, "__USER__");
    String dataTable = ElementParameterParser.getValue(node, "__DATATABLE__");
    String tableSchema = ElementParameterParser.getValue(node, "__SCHEMA_DB__");
    String dbVersion = ElementParameterParser.getValue(node, "__DB_VERSION__");
    boolean setDataSchema =
        "true".equals(ElementParameterParser.getValue(node, "__SET_DATA_TABLE_SCHEMA__"));
    String dataSchema = ElementParameterParser.getValue(node, "__DATA_TABLE_SCHEMA__");
    String inBoundServer = ElementParameterParser.getValue(node, "__INBOUND_SERVER__");
    boolean isUseExistingConn =
        "true".equals(ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"));
    String inputField = ElementParameterParser.getValue(node, "__INPUT_FIELD__");
    String ackInterval = ElementParameterParser.getValue(node, "__ACK_INTERVAL__");

    List<IMetadataTable> metadatas = node.getMetadataList();
    if ((metadatas != null) && (metadatas.size() > 0)) {
      IMetadataTable metadata = metadatas.get(0);
      if (metadata != null) {

        stringBuffer.append(TEXT_70);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_71);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_72);

        if (isUseExistingConn) {
          String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
          String conn = "conn_" + connection;

          stringBuffer.append(TEXT_73);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_74);
          stringBuffer.append(conn);
          stringBuffer.append(TEXT_75);

          log4jCodeGenerateUtil.useExistConnection(node);
        } else {

          stringBuffer.append(TEXT_76);
          if ("ORACLE_11".equals(dbVersion)
              || "ORACLE_11-6".equals(dbVersion)
              || "ORACLE_12".equals(dbVersion)) {
            stringBuffer.append(TEXT_77);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_78);

          } else {

            stringBuffer.append(TEXT_79);
          }

          stringBuffer.append(TEXT_80);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_81);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_82);
          stringBuffer.append(localServiceName);
          stringBuffer.append(TEXT_83);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_84);
          stringBuffer.append(dbuser);
          stringBuffer.append(TEXT_85);

          String passwordFieldName = "__PASS__";

          stringBuffer.append(TEXT_86);
          if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
            stringBuffer.append(TEXT_87);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_88);
            stringBuffer.append(ElementParameterParser.getEncryptedValue(node, passwordFieldName));
            stringBuffer.append(TEXT_89);
          } else {
            stringBuffer.append(TEXT_90);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_91);
            stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
            stringBuffer.append(TEXT_92);
          }
          stringBuffer.append(TEXT_93);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_94);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_95);

          log4jCodeGenerateUtil.debugConnectionParams(node);
          log4jCodeGenerateUtil.connect(node);
        }
        List<IMetadataColumn> columns = metadata.getListColumns();
        boolean isInputLCRObj = false;
        boolean isInputXMLDoc = false;
        for (IMetadataColumn column : columns) {
          JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
          boolean isPrimitive = JavaTypesManager.isJavaPrimitiveType(javaType, column.isNullable());
          if (inputField.equals(column.getLabel())) {
            if ("id_Document".equals(column.getTalendType())) {
              isInputXMLDoc = true;
            }
            if ((javaType == JavaTypesManager.OBJECT)) {
              isInputLCRObj = true;
            }
          }
          break;
        }
        if (!isInputXMLDoc && !isInputLCRObj) {

          stringBuffer.append(TEXT_96);
          stringBuffer.append(inputField);
          stringBuffer.append(TEXT_97);
        }
        if (isInputXMLDoc) {

          stringBuffer.append(TEXT_98);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_99);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_100);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_101);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_102);
        }

        stringBuffer.append(TEXT_103);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_104);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_105);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_106);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_107);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_108);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_109);

        log4jCodeGenerateUtil.logInfo(
            node, "info", cid + " - Try to attach to inbound server:\"+" + inBoundServer + "+\"");

        stringBuffer.append(TEXT_110);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_111);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_112);
        stringBuffer.append(inBoundServer);
        stringBuffer.append(TEXT_113);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_114);
        stringBuffer.append(ackInterval);
        stringBuffer.append(TEXT_115);

        log4jCodeGenerateUtil.logInfo(node, "info", cid + " - Attached successfully.");

        stringBuffer.append(TEXT_116);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_117);
        stringBuffer.append(inBoundServer);
        stringBuffer.append(TEXT_118);

        log4jCodeGenerateUtil.logInfo(
            node,
            "error",
            cid + " - Cannot attach to the inbound server:  \"+" + inBoundServer + "+\"");

        stringBuffer.append(TEXT_119);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_120);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_121);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_122);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_123);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_124);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_125);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_126);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_127);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_128);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_129);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_130);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_131);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_132);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_133);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_134);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_135);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_136);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_137);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_138);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_139);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_140);
      }
    }

    stringBuffer.append(TEXT_141);
    stringBuffer.append(TEXT_142);
    return stringBuffer.toString();
  }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    INode node = (INode) codeGenArgument.getArgument();
    String cid = node.getUniqueName();

    List<? extends IConnection> outputConnections = node.getOutgoingSortedConnections();
    if ((outputConnections == null) || (outputConnections.size() == 0)) {
      return "";
    }
    IConnection outputConnection = outputConnections.get(0);

    if (!outputConnection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
      return "";
    }

    List<IMetadataTable> metadatas = node.getMetadataList();
    if ((metadatas == null) && (metadatas.size() == 0) || (metadatas.get(0) == null)) {
      return "";
    }
    IMetadataTable metadata = metadatas.get(0);

    List<IMetadataColumn> columnList = metadata.getListColumns();
    if ((columnList == null) || (columnList.size() == 0)) {
      return "";
    }

    String client = ElementParameterParser.getValue(node, "__CLIENT__");
    String userid = ElementParameterParser.getValue(node, "__USERID__");
    String password = ElementParameterParser.getValue(node, "__PASSWORD__");
    String language = ElementParameterParser.getValue(node, "__LANGUAGE__");
    String hostname = ElementParameterParser.getValue(node, "__HOSTNAME__");
    String systemnumber = ElementParameterParser.getValue(node, "__SYSTEMNUMBER__");

    String systemId = ElementParameterParser.getValue(node, "__SYSTEMID__");
    String groupName = ElementParameterParser.getValue(node, "__GROUPNAME__");

    String serverType = ElementParameterParser.getValue(node, "__SERVERTYPE__");

    String tableName = ElementParameterParser.getValue(node, "__TABLE__");
    String filter = ElementParameterParser.getValue(node, "__FILTER__");

    String startRowNumber = ElementParameterParser.getValue(node, "__START_ROW__");
    String maxRowCount = ElementParameterParser.getValue(node, "__MAX_ROW_COUNT__");

    List<Map<String, String>> sapProps =
        (List<Map<String, String>>)
            ElementParameterParser.getObjectValue(node, "__SAP_PROPERTIES__");

    String passwordFieldName = "__PASSWORD__";

    boolean activeSNC = ("true").equals(ElementParameterParser.getValue(node, "__SNC_ACTIVE__"));
    String partnerSNCName = ElementParameterParser.getValue(node, "__SNC_PARTNER_NAME__");
    String mySNCName = ElementParameterParser.getValue(node, "__SNC_MY_NAME__");
    String sncLevel = ElementParameterParser.getValue(node, "__SNC_LEVEL__");
    String sncLibPath = ElementParameterParser.getValue(node, "__SNC_LIB_PATH__");
    boolean hasSNCLibPath = sncLibPath != null && !"".equals(sncLibPath);
    boolean hasMySNCName = mySNCName != null && !"".equals(mySNCName);

    boolean useExistingConn =
        ("true").equals(ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"));
    String connection = ElementParameterParser.getValue(node, "__CONNECTION__");

    stringBuffer.append(TEXT_2);
    if (useExistingConn) {
      stringBuffer.append(TEXT_3);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_4);
      stringBuffer.append(connection);
      stringBuffer.append(TEXT_5);

      INode connectionNode = null;
      for (INode processNode : node.getProcess().getGeneratingNodes()) {
        if (connection.equals(processNode.getUniqueName())) {
          connectionNode = processNode;
          break;
        }
      }
      boolean specify_alias =
          "true"
              .equals(
                  ElementParameterParser.getValue(connectionNode, "__SPECIFY_DATASOURCE_ALIAS__"));
      if (specify_alias) {
        String alias = ElementParameterParser.getValue(connectionNode, "__SAP_DATASOURCE_ALIAS__");
        if (null != alias && !("".equals(alias))) {

          stringBuffer.append(TEXT_6);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_7);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_8);
          stringBuffer.append(alias);
          stringBuffer.append(TEXT_9);
        }
      }

      stringBuffer.append(TEXT_10);
    } else {
      stringBuffer.append(TEXT_11);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_12);

      boolean specify_alias =
          "true".equals(ElementParameterParser.getValue(node, "__SPECIFY_DATASOURCE_ALIAS__"));
      if (specify_alias) {
        String alias = ElementParameterParser.getValue(node, "__SAP_DATASOURCE_ALIAS__");
        if (null != alias && !("".equals(alias))) {

          stringBuffer.append(TEXT_13);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_14);
          stringBuffer.append(alias);
          stringBuffer.append(TEXT_15);
        }

        stringBuffer.append(TEXT_16);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_17);
      }

      stringBuffer.append(TEXT_18);
      if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
        stringBuffer.append(TEXT_19);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_20);
        stringBuffer.append(ElementParameterParser.getEncryptedValue(node, passwordFieldName));
        stringBuffer.append(TEXT_21);
      } else {
        stringBuffer.append(TEXT_22);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_23);
        stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
        stringBuffer.append(TEXT_24);
      }
      stringBuffer.append(TEXT_25);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_26);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_27);
      stringBuffer.append(client);
      stringBuffer.append(TEXT_28);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_29);
      stringBuffer.append(userid);
      stringBuffer.append(TEXT_30);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_31);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_32);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_33);
      stringBuffer.append(language);
      stringBuffer.append(TEXT_34);
      if ("ApplicationServer".equals(serverType)) {
        stringBuffer.append(TEXT_35);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_36);
        stringBuffer.append(hostname);
        stringBuffer.append(TEXT_37);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_38);
        stringBuffer.append(systemnumber);
        stringBuffer.append(TEXT_39);
      } else {
        stringBuffer.append(TEXT_40);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_41);
        stringBuffer.append(hostname);
        stringBuffer.append(TEXT_42);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_43);
        stringBuffer.append(systemId);
        stringBuffer.append(TEXT_44);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_45);
        stringBuffer.append(groupName);
        stringBuffer.append(TEXT_46);
      }
      stringBuffer.append(TEXT_47);

      if (activeSNC) {

        stringBuffer.append(TEXT_48);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_49);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_50);
        stringBuffer.append(partnerSNCName);
        stringBuffer.append(TEXT_51);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_52);
        stringBuffer.append(sncLevel);
        stringBuffer.append(TEXT_53);
        if (hasMySNCName) {
          stringBuffer.append(TEXT_54);
          stringBuffer.append(mySNCName);
          stringBuffer.append(TEXT_55);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_56);
          stringBuffer.append(mySNCName);
          stringBuffer.append(TEXT_57);
        }
        stringBuffer.append(TEXT_58);
        if (hasSNCLibPath) {
          stringBuffer.append(TEXT_59);
          stringBuffer.append(sncLibPath);
          stringBuffer.append(TEXT_60);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_61);
          stringBuffer.append(sncLibPath);
          stringBuffer.append(TEXT_62);
        }
        stringBuffer.append(TEXT_63);
      }

      stringBuffer.append(TEXT_64);

      if (sapProps != null) {
        for (Map<String, String> item : sapProps) {

          stringBuffer.append(TEXT_65);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_66);
          stringBuffer.append(item.get("PROPERTY"));
          stringBuffer.append(TEXT_67);
          stringBuffer.append(item.get("VALUE"));
          stringBuffer.append(TEXT_68);
        }
      }

      stringBuffer.append(TEXT_69);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_70);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_71);

      if (specify_alias) {

        stringBuffer.append(TEXT_72);
      }
    }

    stringBuffer.append(TEXT_73);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_74);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_75);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_76);

    for (int i = 0; i < columnList.size(); i++) {
      IMetadataColumn column = columnList.get(i);

      String tableField = column.getOriginalDbColumnName();

      stringBuffer.append(TEXT_77);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_78);
      stringBuffer.append(tableField);
      stringBuffer.append(TEXT_79);
    }

    stringBuffer.append(TEXT_80);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_81);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_82);
    stringBuffer.append(tableName);
    stringBuffer.append(TEXT_83);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_84);
    stringBuffer.append(filter);
    stringBuffer.append(TEXT_85);
    stringBuffer.append(maxRowCount);
    stringBuffer.append(TEXT_86);
    stringBuffer.append(startRowNumber);
    stringBuffer.append(TEXT_87);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_88);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_89);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_90);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_91);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_92);

    for (int i = 0; i < columnList.size(); i++) {
      IMetadataColumn column = columnList.get(i);
      String typeToGenerate =
          JavaTypesManager.getTypeToGenerate(column.getTalendType(), column.isNullable());
      JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
      String dbType = column.getType();

      if (javaType == JavaTypesManager.STRING) {

        stringBuffer.append(TEXT_93);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_94);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_95);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_96);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_97);

      } else if (javaType == JavaTypesManager.INTEGER) {

        stringBuffer.append(TEXT_98);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_99);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_100);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_101);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_102);

      } else if (javaType == JavaTypesManager.SHORT) {

        stringBuffer.append(TEXT_103);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_104);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_105);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_106);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_107);

      } else if (javaType == JavaTypesManager.DATE) {

        stringBuffer.append(TEXT_108);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_109);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_110);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_111);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_112);

      } else if (javaType == JavaTypesManager.BYTE) {

        stringBuffer.append(TEXT_113);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_114);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_115);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_116);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_117);

      } else if (javaType == JavaTypesManager.BYTE_ARRAY) {

        stringBuffer.append(TEXT_118);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_119);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_120);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_121);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_122);

      } else if (javaType == JavaTypesManager.DOUBLE) {

        stringBuffer.append(TEXT_123);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_124);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_125);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_126);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_127);

      } else if (javaType == JavaTypesManager.BIGDECIMAL) {

        stringBuffer.append(TEXT_128);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_129);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_130);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_131);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_132);

      } else if (javaType == JavaTypesManager.OBJECT && "BIG_INTEGER".equals(dbType)) {

        stringBuffer.append(TEXT_133);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_134);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_135);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_136);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_137);

      } else if (javaType == JavaTypesManager.OBJECT) {

        stringBuffer.append(TEXT_138);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_139);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_140);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_141);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_142);

      } else {

        stringBuffer.append(TEXT_143);
        stringBuffer.append(outputConnection.getName());
        stringBuffer.append(TEXT_144);
        stringBuffer.append(column.getLabel());
        stringBuffer.append(TEXT_145);
        stringBuffer.append(typeToGenerate);
        stringBuffer.append(TEXT_146);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_147);
        stringBuffer.append(i);
        stringBuffer.append(TEXT_148);
      }
    }

    return stringBuffer.toString();
  }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    INode node = (INode) codeGenArgument.getArgument();
    String cid = node.getUniqueName();
    String destination = ElementParameterParser.getValue(node, "__DESTINATION__");
    if (destination != null && !"".equals(destination)) {
      cid = destination;
    }

    boolean useExistingConn =
        ("true").equals(ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"));
    String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
    String conn = "TMDMService_" + connection;
    String mdmUrl = ElementParameterParser.getValue(node, "__MDMURL__");
    String username = ElementParameterParser.getValue(node, "__USERNAME__");

    String dataModel = ElementParameterParser.getValue(node, "__DATAMODEL__");
    String dataCluster = ElementParameterParser.getValue(node, "__DATACLUSTER__");
    boolean isStaging =
        "STAGING".equalsIgnoreCase(ElementParameterParser.getValue(node, "__CONTAINER_TYPE__"));

    boolean withReport = ("true").equals(ElementParameterParser.getValue(node, "__WITHREPORT__"));
    boolean isMassInsert =
        ("true").equals(ElementParameterParser.getValue(node, "__EXTENDINSERT__"));

    boolean addTaskID = ("true").equals(ElementParameterParser.getValue(node, "__ADD_TASKID__"));
    boolean usePartialUpdate =
        ("true").equals(ElementParameterParser.getValue(node, "__USE_PARTIAL_UPDATE__"));
    boolean usePartialDelete =
        ("true").equals(ElementParameterParser.getValue(node, "__PARTIAL_DELETE__"));
    boolean isLog4jEnabled =
        ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));

    stringBuffer.append(TEXT_1);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_2);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_3);
    if (!usePartialUpdate) {
      stringBuffer.append(TEXT_4);
      if (addTaskID) {
        stringBuffer.append(TEXT_5);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_6);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_7);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_8);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_9);
      }
      stringBuffer.append(TEXT_10);
      if (isMassInsert) {
        if (!isStaging && withReport) {
          stringBuffer.append(TEXT_11);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_12);
        } else {
          stringBuffer.append(TEXT_13);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_14);
        }
        if (addTaskID) {

          stringBuffer.append(TEXT_15);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_16);
        }
      }
    }
    stringBuffer.append(TEXT_17);
    if (!useExistingConn) {
      stringBuffer.append(TEXT_18);
      stringBuffer.append(mdmUrl);
      stringBuffer.append(TEXT_19);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_20);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_21);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_22);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_23);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_24);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_25);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_26);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_27);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_28);
      stringBuffer.append(username);
      stringBuffer.append(TEXT_29);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_30);

      String passwordFieldName = "__PASSWORD__";

      stringBuffer.append(TEXT_31);
      if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
        stringBuffer.append(TEXT_32);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_33);
        stringBuffer.append(ElementParameterParser.getEncryptedValue(node, passwordFieldName));
        stringBuffer.append(TEXT_34);
      } else {
        stringBuffer.append(TEXT_35);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_36);
        stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
        stringBuffer.append(TEXT_37);
      }
      stringBuffer.append(TEXT_38);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_39);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_40);
    } else {
      stringBuffer.append(TEXT_41);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_42);
      stringBuffer.append(conn);
      stringBuffer.append(TEXT_43);
    }
    stringBuffer.append(TEXT_44);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_45);
    stringBuffer.append(dataCluster);
    stringBuffer.append(TEXT_46);
    stringBuffer.append(isStaging ? "#STAGING" : "");
    stringBuffer.append(TEXT_47);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_48);
    stringBuffer.append(dataModel);
    stringBuffer.append(TEXT_49);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_50);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_51);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_52);
    stringBuffer.append(TEXT_53);
    return stringBuffer.toString();
  }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;

    INode node = (INode) codeGenArgument.getArgument();
    String cid = node.getUniqueName();
    String dbhost = ElementParameterParser.getValue(node, "__HOST__");
    String dbname = ElementParameterParser.getValue(node, "__DATABASE__");
    String dbuser = ElementParameterParser.getValue(node, "__USERNAME__");
    String dbpass = ElementParameterParser.getValue(node, "__PASSWORD__");
    boolean authentication =
        "true"
            .equalsIgnoreCase(ElementParameterParser.getValue(node, "__REQUIRED_AUTHENTICATION__"));
    if (!authentication) {
      dbuser = null;
      dbpass = null;
    }

    String passwordFieldName = "__PASSWORD__";

    stringBuffer.append(TEXT_2);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_3);
    if (!authentication) {
      // do nothing
    } else if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
      stringBuffer.append(TEXT_4);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_5);
      stringBuffer.append(ElementParameterParser.getEncryptedValue(node, passwordFieldName));
      stringBuffer.append(TEXT_6);
    } else {
      stringBuffer.append(TEXT_7);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_8);
      stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
      stringBuffer.append(TEXT_9);
    }

    boolean useTriggerReplicate =
        "true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__USE_TRIGGER_REPLICATE__"));
    String dbport = ElementParameterParser.getValue(node, "__PORT__");
    List<Map<String, String>> replicaTargetDB =
        (List<Map<String, String>>)
            ElementParameterParser.getObjectValue(node, "__REPLICATE_TARGET_DB__");
    boolean useExistingConn =
        "true"
            .equalsIgnoreCase(ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"));
    String connection = ElementParameterParser.getValue(node, "__CONNECTION__");

    boolean isLog4jEnabled =
        ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));

    stringBuffer.append(TEXT_10);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_11);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_12);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_13);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_14);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_15);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_16);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_17);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_18);

    if (useExistingConn) {
      INode connectionNode = NodeUtil.getNodeByUniqueName(node.getProcess(), connection);
      dbname = ElementParameterParser.getValue(connectionNode, "__DATABASE__");

      stringBuffer.append(TEXT_19);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_20);
      stringBuffer.append(connection);
      stringBuffer.append(TEXT_21);

      if (isLog4jEnabled) {

        stringBuffer.append(TEXT_22);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_23);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_24);
        stringBuffer.append(connection);
        stringBuffer.append(TEXT_25);
      }
    } else {

      stringBuffer.append(TEXT_26);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_27);
      stringBuffer.append(dbname);
      stringBuffer.append(TEXT_28);
      stringBuffer.append(dbhost);
      stringBuffer.append(TEXT_29);
      stringBuffer.append(dbport);
      stringBuffer.append(TEXT_30);
      stringBuffer.append(dbuser);
      stringBuffer.append(TEXT_31);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_32);

      if (useTriggerReplicate) {

        stringBuffer.append(TEXT_33);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_34);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_35);

        int index = 0;
        for (Map<String, String> targetDB : replicaTargetDB) {
          String targetDBName = targetDB.get("TARGET_DB_NAME");
          boolean isCreateTargetDB = "true".equalsIgnoreCase(targetDB.get("CREATE_TARGET"));
          boolean isContinuous = "true".equalsIgnoreCase(targetDB.get("CONTINUOUS"));
          boolean isCancel = "true".equalsIgnoreCase(targetDB.get("CANCEL_REPLICATE"));

          stringBuffer.append(TEXT_36);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_37);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_38);
          stringBuffer.append(dbname);
          stringBuffer.append(TEXT_39);
          stringBuffer.append(targetDBName);
          stringBuffer.append(TEXT_40);
          stringBuffer.append(isCreateTargetDB);
          stringBuffer.append(TEXT_41);
          stringBuffer.append(isContinuous);
          stringBuffer.append(TEXT_42);

          if (isContinuous && isCancel) {

            stringBuffer.append(TEXT_43);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_44);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_45);
            stringBuffer.append(index);
            stringBuffer.append(TEXT_46);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_47);
            stringBuffer.append(dbname);
            stringBuffer.append(TEXT_48);
            stringBuffer.append(targetDBName);
            stringBuffer.append(TEXT_49);
            stringBuffer.append(isCreateTargetDB);
            stringBuffer.append(TEXT_50);
            stringBuffer.append(isContinuous);
            stringBuffer.append(TEXT_51);
            stringBuffer.append(isCancel);
            stringBuffer.append(TEXT_52);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_53);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_54);
            stringBuffer.append(index);
            stringBuffer.append(TEXT_55);

            index++;
          }
        }
      }
    }
    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_56);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_57);
      stringBuffer.append(dbname);
      stringBuffer.append(TEXT_58);
    }

    return stringBuffer.toString();
  }
      public void createConnection(INode node, boolean needUserAndPassword) {
        useExistingConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__");
        if (("true").equals(useExistingConn)) {
          String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
          String conn = "conn_" + connection;
          ;

          stringBuffer.append(TEXT_80);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_81);
          stringBuffer.append(conn);
          stringBuffer.append(TEXT_82);

          INode connectionNode = null;
          for (INode processNode : node.getProcess().getGeneratingNodes()) {
            if (connection.equals(processNode.getUniqueName())) {
              connectionNode = processNode;
              break;
            }
          }
          boolean specify_alias =
              "true"
                  .equals(
                      ElementParameterParser.getValue(
                          connectionNode, "__SPECIFY_DATASOURCE_ALIAS__"));
          if (specify_alias) {
            String alias = ElementParameterParser.getValue(connectionNode, "__DATASOURCE_ALIAS__");
            String autoCommit =
                "true".equals(ElementParameterParser.getValue(connectionNode, "__AUTO_COMMIT__"))
                    ? "true"
                    : "false";

            stringBuffer.append(TEXT_83);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_84);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_85);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_86);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_87);
            stringBuffer.append((null != alias && !("".equals(alias))) ? alias : "\"\"");
            stringBuffer.append(TEXT_88);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_89);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_90);
            stringBuffer.append(autoCommit);
            stringBuffer.append(TEXT_91);
          }
          this.afterUseExistConnection(node);
        } else {
          boolean specify_alias =
              "true".equals(ElementParameterParser.getValue(node, "__SPECIFY_DATASOURCE_ALIAS__"));
          if (specify_alias) {

            stringBuffer.append(TEXT_92);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_93);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_94);

            String alias = ElementParameterParser.getValue(node, "__DATASOURCE_ALIAS__");

            stringBuffer.append(TEXT_95);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_96);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_97);
            stringBuffer.append((null != alias && !("".equals(alias))) ? alias : "\"\"");
            stringBuffer.append(TEXT_98);
          }
          this.classForName(node);
          this.setURL(node);
          log4jCodeGenerateUtil.debugConnectionParams(node);
          if (needUserAndPassword) {

            stringBuffer.append(TEXT_99);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_100);
            stringBuffer.append(dbuser);
            stringBuffer.append(TEXT_101);

            String passwordFieldName = "__PASS__";

            stringBuffer.append(TEXT_102);
            if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
              stringBuffer.append(TEXT_103);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_104);
              stringBuffer.append(
                  ElementParameterParser.getEncryptedValue(node, passwordFieldName));
              stringBuffer.append(TEXT_105);
            } else {
              stringBuffer.append(TEXT_106);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_107);
              stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
              stringBuffer.append(TEXT_108);
            }
            stringBuffer.append(TEXT_109);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_110);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_111);
            log4jCodeGenerateUtil.connect_begin();
            newConnection();
          } else {
            log4jCodeGenerateUtil.connect_begin_noUser();

            stringBuffer.append(TEXT_112);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_113);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_114);
          }
          log4jCodeGenerateUtil.connect_end();
          if (specify_alias) {

            stringBuffer.append(TEXT_115);
          }
        }
      }
      public void createDatabaseService() {
        if (this.useExistingConnection) {

          stringBuffer.append(TEXT_37);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_38);
          stringBuffer.append(dbConnectionName);
          stringBuffer.append(TEXT_39);

        } else {
          if (this.remoteServer) {
            String serverUrl = ElementParameterParser.getValue(node, "__SERVER_URL__");
            boolean setUsername = ElementParameterParser.getBooleanValue(node, "__SET_USERNAME__");
            String username = ElementParameterParser.getValue(node, "__USERNAME__");
            String passwordFieldName = "__PASSWORD__";
            if ((setUsername) || ("NEO4J_2_2_X".equals(dbVersion))) {

              if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
                stringBuffer.append(TEXT_40);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_41);
                stringBuffer.append(
                    ElementParameterParser.getEncryptedValue(node, passwordFieldName));
                stringBuffer.append(TEXT_42);
              } else {
                stringBuffer.append(TEXT_43);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_44);
                stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
                stringBuffer.append(TEXT_45);
              }
              stringBuffer.append(TEXT_46);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_47);
              stringBuffer.append(serverUrl);
              stringBuffer.append(TEXT_48);
              stringBuffer.append(username);
              stringBuffer.append(TEXT_49);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_50);

            } else {

              stringBuffer.append(TEXT_51);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_52);
              stringBuffer.append(serverUrl);
              stringBuffer.append(TEXT_53);
            }
          } else {
            String databasePath = ElementParameterParser.getValue(node, "__DATABASE_PATH__");

            stringBuffer.append(TEXT_54);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_55);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_56);
            stringBuffer.append(databasePath);
            stringBuffer.append(TEXT_57);
          }
        }
      }
Ejemplo n.º 8
0
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    INode node = (INode) codeGenArgument.getArgument();
    String cid = node.getUniqueName();
    String bucket = ElementParameterParser.getValue(node, "__BUCKET__");
    String key = ElementParameterParser.getValue(node, "__KEY__");
    String file = ElementParameterParser.getValue(node, "__FILE__");
    boolean dieOnError = "true".equals(ElementParameterParser.getValue(node, "__DIE_ON_ERROR__"));

    stringBuffer.append(TEXT_2);

    boolean isLog4jEnabled =
        ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));

    String accessKey = ElementParameterParser.getValue(node, "__ACCESS_KEY__");

    boolean configClient =
        "true".equals(ElementParameterParser.getValue(node, "__CONFIG_CLIENT__"));
    String useExistingConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__");
    List<Map<String, String>> clientConfiguration =
        (List<Map<String, String>>)
            ElementParameterParser.getObjectValue(node, "__CLIENT_CONFIGURATION__");
    String region = ElementParameterParser.getValue(node, "__REGION__");
    if (("true").equals(useExistingConn)) {
      String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
      String conn = "conn_" + connection;
      ;

      stringBuffer.append(TEXT_3);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_4);
      stringBuffer.append(conn);
      stringBuffer.append(TEXT_5);

      if (isLog4jEnabled) {

        stringBuffer.append(TEXT_6);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_7);
        stringBuffer.append(connection);
        stringBuffer.append(TEXT_8);
      }
    } else {

      stringBuffer.append(TEXT_9);

      if (isLog4jEnabled) {

        stringBuffer.append(TEXT_10);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_11);
      }
      String passwordFieldName = "__SECRET_KEY__";

      stringBuffer.append(TEXT_12);
      if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
        stringBuffer.append(TEXT_13);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_14);
        stringBuffer.append(ElementParameterParser.getEncryptedValue(node, passwordFieldName));
        stringBuffer.append(TEXT_15);
      } else {
        stringBuffer.append(TEXT_16);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_17);
        stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
        stringBuffer.append(TEXT_18);
      }
      stringBuffer.append(TEXT_19);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_20);
      stringBuffer.append(accessKey);
      stringBuffer.append(TEXT_21);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_22);

      if (configClient && clientConfiguration.size() > 0) {

        stringBuffer.append(TEXT_23);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_24);

        boolean setBuffer = false;
        for (Map<String, String> map : clientConfiguration) {
          String client_parameter = map.get("CLIENT_PARAMETER");
          String value = map.get("VALUE");
          if (!setBuffer
              && ("SocketSendBufferSizeHints".equals(client_parameter)
                  || "SocketReceiveBufferSizeHints".equals(client_parameter))) {
            setBuffer = true;

            stringBuffer.append(TEXT_25);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_26);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_27);
          }
          if ("SocketSendBufferSizeHints".equals(client_parameter)) {

            stringBuffer.append(TEXT_28);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_29);
            stringBuffer.append(value);
            stringBuffer.append(TEXT_30);

          } else if ("SocketReceiveBufferSizeHints".equals(client_parameter)) {

            stringBuffer.append(TEXT_31);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_32);
            stringBuffer.append(value);
            stringBuffer.append(TEXT_33);

          } else if ("Protocol".equals(client_parameter)) {

            stringBuffer.append(TEXT_34);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_35);
            stringBuffer.append(value.toUpperCase().replaceAll("\"", ""));
            stringBuffer.append(TEXT_36);

          } else {

            stringBuffer.append(TEXT_37);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_38);
            stringBuffer.append(client_parameter);
            stringBuffer.append(TEXT_39);
            stringBuffer.append(value);
            stringBuffer.append(TEXT_40);
          }
        }
        if (setBuffer) {

          stringBuffer.append(TEXT_41);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_42);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_43);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_44);
        }

        stringBuffer.append(TEXT_45);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_46);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_47);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_48);

      } else {

        stringBuffer.append(TEXT_49);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_50);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_51);
      }
      if (region != null && !region.isEmpty() && !"DEFAULT".equalsIgnoreCase(region)) {

        stringBuffer.append(TEXT_52);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_53);
        stringBuffer.append(region);
        stringBuffer.append(TEXT_54);
      }
      if (isLog4jEnabled) {

        stringBuffer.append(TEXT_55);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_56);
      }
    }

    stringBuffer.append(TEXT_57);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_58);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_59);
      stringBuffer.append(key);
      stringBuffer.append(TEXT_60);
    }

    stringBuffer.append(TEXT_61);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_62);
    stringBuffer.append(bucket);
    stringBuffer.append(TEXT_63);
    stringBuffer.append(key);
    stringBuffer.append(TEXT_64);
    stringBuffer.append(file);
    stringBuffer.append(TEXT_65);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_66);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_67);
    }

    stringBuffer.append(TEXT_68);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_69);

    if (dieOnError) {

      stringBuffer.append(TEXT_70);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_71);

    } else {

      if (isLog4jEnabled) {

        stringBuffer.append(TEXT_72);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_73);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_74);
      }

      stringBuffer.append(TEXT_75);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_76);
    }
    if (!("true").equals(useExistingConn)) {

      stringBuffer.append(TEXT_77);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_78);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_79);
    }

    stringBuffer.append(TEXT_80);
    stringBuffer.append(TEXT_81);
    return stringBuffer.toString();
  }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

    // this util class use by set log4j debug paramters
    class DefaultLog4jFileUtil {

      INode node = null;
      String cid = null;
      boolean isLog4jEnabled = false;
      String label = null;

      public DefaultLog4jFileUtil() {}

      public DefaultLog4jFileUtil(INode node) {
        this.node = node;
        this.cid = node.getUniqueName();
        this.label = cid;
        this.isLog4jEnabled =
            ("true")
                .equals(
                    org.talend.core.model.process.ElementParameterParser.getValue(
                        node.getProcess(), "__LOG4J_ACTIVATE__"));
      }

      public void setCid(String cid) {
        this.cid = cid;
      }

      // for all tFileinput* components
      public void startRetriveDataInfo() {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_2);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_3);
        }
      }

      public void retrievedDataNumberInfo() {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_4);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_5);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_6);
        }
      }

      public void retrievedDataNumberInfoFromGlobalMap(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_7);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_8);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_9);
        }
      }

      // for all tFileinput* components
      public void retrievedDataNumberInfo(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_10);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_11);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_12);
        }
      }

      public void writeDataFinishInfo(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_13);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_14);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_15);
        }
      }

      // TODO delete it and remove all log4jSb parameter from components
      public void componentStartInfo(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_16);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_17);
        }
      }

      // TODO rename or delete it
      public void debugRetriveData(INode node, boolean hasIncreased) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_18);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_19);
          stringBuffer.append(cid);
          stringBuffer.append(hasIncreased ? "" : "+1");
          stringBuffer.append(TEXT_20);
        }
      }

      // TODO rename or delete it
      public void debugRetriveData(INode node) {
        debugRetriveData(node, true);
      }

      // TODO rename or delete it
      public void debugWriteData(INode node) {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_21);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_22);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_23);
        }
      }

      public void logCurrentRowNumberInfo() {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_24);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_25);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_26);
        }
      }

      public void logDataCountInfo() {
        if (isLog4jEnabled) {

          stringBuffer.append(TEXT_27);
          stringBuffer.append(label);
          stringBuffer.append(TEXT_28);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_29);
        }
      }
    }

    final DefaultLog4jFileUtil log4jFileUtil =
        new DefaultLog4jFileUtil(
            (INode)
                (((org.talend.designer.codegen.config.CodeGeneratorArgument) argument)
                    .getArgument()));

    stringBuffer.append(TEXT_30);

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;

    INode node = (INode) codeGenArgument.getArgument();

    String cid = node.getUniqueName();

    String clientId = ElementParameterParser.getValue(node, "__CLIENT_ID__");
    String clientSecret = ElementParameterParser.getValue(node, "__CLIENT_SECRET__");
    String projectId = ElementParameterParser.getValue(node, "__PROJECT_ID__");
    String authorizationCode = ElementParameterParser.getValue(node, "__AUTHORIZATION_CODE__");
    String query = ElementParameterParser.getValue(node, "__QUERY__");
    query = query.replaceAll("\n", " ");
    query = query.replaceAll("\r", " ");

    String tokenFile = ElementParameterParser.getValue(node, "__TOKEN_NAME__");
    boolean isLog4jEnabled =
        ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));

    stringBuffer.append(TEXT_31);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_32);
    stringBuffer.append(clientId);
    stringBuffer.append(TEXT_33);

    String passwordFieldName = "__CLIENT_SECRET__";

    stringBuffer.append(TEXT_34);
    if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
      stringBuffer.append(TEXT_35);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_36);
      stringBuffer.append(ElementParameterParser.getEncryptedValue(node, passwordFieldName));
      stringBuffer.append(TEXT_37);
    } else {
      stringBuffer.append(TEXT_38);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_39);
      stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
      stringBuffer.append(TEXT_40);
    }
    stringBuffer.append(TEXT_41);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_42);
    stringBuffer.append(clientId);
    stringBuffer.append(TEXT_43);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_44);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_45);
    stringBuffer.append(projectId);
    stringBuffer.append(TEXT_46);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_47);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_48);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_49);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_50);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_51);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_52);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_53);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_54);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_55);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_56);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_57);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_58);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_59);
    }

    stringBuffer.append(TEXT_60);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_61);
    stringBuffer.append(tokenFile);
    stringBuffer.append(TEXT_62);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_63);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_64);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_65);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_66);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_67);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_68);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_69);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_70);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_71);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_72);
    }

    stringBuffer.append(TEXT_73);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_74);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_75);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_76);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_77);
    }

    stringBuffer.append(TEXT_78);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_79);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_80);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_81);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_82);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_83);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_84);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_85);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_86);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_87);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_88);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_89);
    }

    stringBuffer.append(TEXT_90);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_91);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_92);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_93);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_94);
    }
    if (authorizationCode == null
        || "".equals(authorizationCode)
        || "\"\"".equals(authorizationCode)) {

      stringBuffer.append(TEXT_95);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_96);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_97);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_98);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_99);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_100);

      if (isLog4jEnabled) {

        stringBuffer.append(TEXT_101);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_102);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_103);
      }

      stringBuffer.append(TEXT_104);

    } else {

      stringBuffer.append(TEXT_105);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_106);
      stringBuffer.append(authorizationCode);
      stringBuffer.append(TEXT_107);

      if (isLog4jEnabled) {

        stringBuffer.append(TEXT_108);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_109);
      }

      stringBuffer.append(TEXT_110);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_111);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_112);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_113);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_114);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_115);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_116);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_117);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_118);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_119);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_120);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_121);

      if (isLog4jEnabled) {

        stringBuffer.append(TEXT_122);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_123);
      }

      stringBuffer.append(TEXT_124);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_125);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_126);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_127);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_128);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_129);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_130);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_131);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_132);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_133);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_134);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_135);
    }

    stringBuffer.append(TEXT_136);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_137);
    stringBuffer.append(query);
    stringBuffer.append(TEXT_138);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_139);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_140);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_141);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_142);
    }

    stringBuffer.append(TEXT_143);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_144);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_145);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_146);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_147);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_148);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_149);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_150);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_151);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_152);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_153);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_154);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_155);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_156);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_157);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_158);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_159);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_160);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_161);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_162);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_163);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_164);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_165);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_166);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_167);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_168);
    }

    stringBuffer.append(TEXT_169);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_170);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_171);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_172);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_173);
    }

    stringBuffer.append(TEXT_174);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_175);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_176);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_177);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_178);
    }

    stringBuffer.append(TEXT_179);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_180);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_181);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_182);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_183);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_184);

    if (isLog4jEnabled) {

      stringBuffer.append(TEXT_185);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_186);
    }

    stringBuffer.append(TEXT_187);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_188);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_189);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_190);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_191);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_192);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_193);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_194);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_195);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_196);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_197);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_198);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_199);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_200);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_201);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_202);

    List<? extends IConnection> conns = node.getOutgoingSortedConnections();
    if (conns != null) {
      if (conns.size() > 0) {
        IConnection conn = conns.get(0);
        String connName = conn.getName();
        if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
          List<IMetadataTable> metadatas = node.getMetadataList();
          if ((metadatas != null) && (metadatas.size() > 0)) {
            IMetadataTable metadata = metadatas.get(0);
            if (metadata != null) {
              String encoding = ElementParameterParser.getValue(node, "__ENCODING__");
              String advancedSeparatorStr =
                  ElementParameterParser.getValue(node, "__ADVANCED_SEPARATOR__");
              boolean advancedSeparator =
                  (advancedSeparatorStr != null && !("").equals(advancedSeparatorStr))
                      ? ("true").equals(advancedSeparatorStr)
                      : false;
              String thousandsSeparator =
                  ElementParameterParser.getValueWithJavaType(
                      node, "__THOUSANDS_SEPARATOR__", JavaTypesManager.CHARACTER);
              String decimalSeparator =
                  ElementParameterParser.getValueWithJavaType(
                      node, "__DECIMAL_SEPARATOR__", JavaTypesManager.CHARACTER);

              List<IMetadataColumn> columns = metadata.getListColumns();
              int nbColumns = columns.size();
              for (int i = 0; i < nbColumns; i++) {
                IMetadataColumn column = columns.get(i);
                String columnName = column.getLabel();

                String typeToGenerate =
                    JavaTypesManager.getTypeToGenerate(column.getTalendType(), column.isNullable());
                JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
                String patternValue =
                    column.getPattern() == null || column.getPattern().trim().length() == 0
                        ? null
                        : column.getPattern();

                stringBuffer.append(TEXT_203);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_204);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_205);
                stringBuffer.append(i);
                stringBuffer.append(TEXT_206);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_207);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_208);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_209);

                if (javaType == JavaTypesManager.STRING) {

                  stringBuffer.append(TEXT_210);
                  stringBuffer.append(connName);
                  stringBuffer.append(TEXT_211);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_212);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_213);

                } else if (javaType == JavaTypesManager.OBJECT) {

                  stringBuffer.append(TEXT_214);
                  stringBuffer.append(connName);
                  stringBuffer.append(TEXT_215);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_216);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_217);

                } else if (javaType == JavaTypesManager.DATE) {

                  stringBuffer.append(TEXT_218);
                  stringBuffer.append(connName);
                  stringBuffer.append(TEXT_219);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_220);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_221);
                  stringBuffer.append(patternValue);
                  stringBuffer.append(TEXT_222);

                } else if (advancedSeparator && JavaTypesManager.isNumberType(javaType)) {

                  stringBuffer.append(TEXT_223);
                  stringBuffer.append(connName);
                  stringBuffer.append(TEXT_224);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_225);
                  stringBuffer.append(typeToGenerate);
                  stringBuffer.append(TEXT_226);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_227);
                  stringBuffer.append(thousandsSeparator);
                  stringBuffer.append(TEXT_228);
                  stringBuffer.append(decimalSeparator);
                  stringBuffer.append(TEXT_229);

                } else if (javaType == JavaTypesManager.BYTE_ARRAY) {

                  stringBuffer.append(TEXT_230);
                  stringBuffer.append(connName);
                  stringBuffer.append(TEXT_231);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_232);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_233);
                  stringBuffer.append(encoding);
                  stringBuffer.append(TEXT_234);

                } else {

                  stringBuffer.append(TEXT_235);
                  stringBuffer.append(connName);
                  stringBuffer.append(TEXT_236);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_237);
                  stringBuffer.append(typeToGenerate);
                  stringBuffer.append(TEXT_238);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_239);
                }

                stringBuffer.append(TEXT_240);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_241);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_242);
                stringBuffer.append(
                    JavaTypesManager.getDefaultValueFromJavaType(
                        typeToGenerate, column.getDefault()));
                stringBuffer.append(TEXT_243);
              }
              log4jFileUtil.debugRetriveData(node);
            }
          }
        }
      }
    }

    stringBuffer.append(TEXT_244);
    return stringBuffer.toString();
  }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);
    stringBuffer.append(TEXT_2);

    class BasicLogUtil {
      protected String cid = "";
      protected org.talend.core.model.process.INode node = null;
      protected boolean log4jEnabled = false;
      private String logID = "";

      private BasicLogUtil() {}

      public BasicLogUtil(org.talend.core.model.process.INode node) {
        this.node = node;
        String cidx = this.node.getUniqueName();
        if (cidx.matches("^.*?tAmazonAuroraOutput_\\d+_out$")) {
          cidx = cidx.substring(0, cidx.length() - 4); // 4 ==> "_out".length();
        }
        this.cid = cidx;
        this.log4jEnabled =
            ("true")
                .equals(
                    org.talend.core.model.process.ElementParameterParser.getValue(
                        this.node.getProcess(), "__LOG4J_ACTIVATE__"));
        this.log4jEnabled =
            this.log4jEnabled
                && this.node.getComponent().isLog4JEnabled()
                && !"JOBLET".equals(node.getComponent().getComponentType().toString());
        this.logID = this.cid;
      }

      public String var(String varName) {
        return varName + "_" + this.cid;
      }

      public String str(String content) {
        return "\"" + content + "\"";
      }

      public void info(String... message) {
        log4j("info", message);
      }

      public void debug(String... message) {
        log4j("debug", message);
      }

      public void warn(String... message) {
        log4j("warn", message);
      }

      public void error(String... message) {
        log4j("error", message);
      }

      public void fatal(String... message) {
        log4j("fatal", message);
      }

      public void trace(String... message) {
        log4j("trace", message);
      }

      java.util.List<String> checkableList =
          java.util.Arrays.asList(new String[] {"info", "debug", "trace"});

      public void log4j(String level, String... messages) {
        if (this.log4jEnabled) {
          if (checkableList.contains(level)) {

            stringBuffer.append(TEXT_3);
            stringBuffer.append(level.substring(0, 1).toUpperCase() + level.substring(1));
            stringBuffer.append(TEXT_4);
          }

          stringBuffer.append(TEXT_5);
          stringBuffer.append(level);
          stringBuffer.append(TEXT_6);
          stringBuffer.append(logID);
          stringBuffer.append(TEXT_7);
          for (String message : messages) {
            stringBuffer.append(TEXT_8);
            stringBuffer.append(message);
            stringBuffer.append(TEXT_9);
          }
          stringBuffer.append(TEXT_10);
        }
      }

      public boolean isActive() {
        return this.log4jEnabled;
      }
    }

    class LogUtil extends BasicLogUtil {

      private LogUtil() {}

      public LogUtil(org.talend.core.model.process.INode node) {
        super(node);
      }

      public void startWork() {
        info(str("Start to work."));
      }

      public void endWork() {
        info(str("Done."));
      }

      public void logIgnoredException(String exception) {
        warn(exception);
      }

      public void logPrintedException(String exception) {
        error(exception);
      }

      public void logException(String exception) {
        fatal(exception);
      }

      public void logCompSetting() {
        if (log4jEnabled) {

          stringBuffer.append(TEXT_11);
          stringBuffer.append(var("log4jParamters"));
          stringBuffer.append(TEXT_12);
          stringBuffer.append(TEXT_13);
          stringBuffer.append(var("log4jParamters"));
          stringBuffer.append(TEXT_14);

          java.util.Set<org.talend.core.model.process.EParameterFieldType> ignoredParamsTypes =
              new java.util.HashSet<org.talend.core.model.process.EParameterFieldType>();
          ignoredParamsTypes.addAll(
              java.util.Arrays.asList(
                  org.talend.core.model.process.EParameterFieldType.SCHEMA_TYPE,
                  org.talend.core.model.process.EParameterFieldType.LABEL,
                  org.talend.core.model.process.EParameterFieldType.EXTERNAL,
                  org.talend.core.model.process.EParameterFieldType.MAPPING_TYPE,
                  org.talend.core.model.process.EParameterFieldType.IMAGE,
                  org.talend.core.model.process.EParameterFieldType.TNS_EDITOR,
                  org.talend.core.model.process.EParameterFieldType.WSDL2JAVA,
                  org.talend.core.model.process.EParameterFieldType.GENERATEGRAMMARCONTROLLER,
                  org.talend.core.model.process.EParameterFieldType
                      .GENERATE_SURVIVORSHIP_RULES_CONTROLLER,
                  org.talend.core.model.process.EParameterFieldType.REFRESH_REPORTS,
                  org.talend.core.model.process.EParameterFieldType.BROWSE_REPORTS,
                  org.talend.core.model.process.EParameterFieldType.PALO_DIM_SELECTION,
                  org.talend.core.model.process.EParameterFieldType.GUESS_SCHEMA,
                  org.talend.core.model.process.EParameterFieldType.MATCH_RULE_IMEX_CONTROLLER,
                  org.talend.core.model.process.EParameterFieldType.MEMO_PERL,
                  org.talend.core.model.process.EParameterFieldType.DBTYPE_LIST,
                  org.talend.core.model.process.EParameterFieldType.VERSION,
                  org.talend.core.model.process.EParameterFieldType.TECHNICAL,
                  org.talend.core.model.process.EParameterFieldType.ICON_SELECTION,
                  org.talend.core.model.process.EParameterFieldType.JAVA_COMMAND,
                  org.talend.core.model.process.EParameterFieldType.TREE_TABLE,
                  org.talend.core.model.process.EParameterFieldType.VALIDATION_RULE_TYPE,
                  org.talend.core.model.process.EParameterFieldType.DCSCHEMA,
                  org.talend.core.model.process.EParameterFieldType.SURVIVOR_RELATION,
                  org.talend.core.model.process.EParameterFieldType.REST_RESPONSE_SCHEMA_TYPE));
          for (org.talend.core.model.process.IElementParameter ep :
              org.talend.core.model.utils.NodeUtil.getDisplayedParameters(node)) {
            if (!ep.isLog4JEnabled() || ignoredParamsTypes.contains(ep.getFieldType())) {
              continue;
            }
            String name = ep.getName();
            if (org.talend.core.model.process.EParameterFieldType.PASSWORD.equals(
                ep.getFieldType())) {
              String epName = "__" + name + "__";
              String password = "";
              if (org.talend.core.model.process.ElementParameterParser.canEncrypt(node, epName)) {
                password =
                    org.talend.core.model.process.ElementParameterParser.getEncryptedValue(
                        node, epName);
              } else {
                String passwordValue =
                    org.talend.core.model.process.ElementParameterParser.getValue(node, epName);
                if (passwordValue == null
                    || "".equals(passwordValue.trim())) { // for the value which empty
                  passwordValue = "\"\"";
                }
                password =
                    "******" + passwordValue + ")";
              }

              stringBuffer.append(TEXT_15);
              stringBuffer.append(var("log4jParamters"));
              stringBuffer.append(TEXT_16);
              stringBuffer.append(name);
              stringBuffer.append(TEXT_17);
              stringBuffer.append(password);
              stringBuffer.append(TEXT_18);

            } else {
              String value =
                  org.talend.core.model.utils.NodeUtil.getNormalizeParameterValue(node, ep);

              stringBuffer.append(TEXT_19);
              stringBuffer.append(var("log4jParamters"));
              stringBuffer.append(TEXT_20);
              stringBuffer.append(name);
              stringBuffer.append(TEXT_21);
              stringBuffer.append(value);
              stringBuffer.append(TEXT_22);
            }

            stringBuffer.append(TEXT_23);
            stringBuffer.append(var("log4jParamters"));
            stringBuffer.append(TEXT_24);
          }
        }
        debug(var("log4jParamters"));
      }

      // no use for now, because we log the data by rowStruct
      public void traceData(
          String rowStruct,
          java.util.List<org.talend.core.model.metadata.IMetadataColumn> columnList,
          String nbline) {
        if (log4jEnabled) {

          stringBuffer.append(TEXT_25);
          stringBuffer.append(var("log4jSb"));
          stringBuffer.append(TEXT_26);

          for (org.talend.core.model.metadata.IMetadataColumn column : columnList) {
            org.talend.core.model.metadata.types.JavaType javaType =
                org.talend.core.model.metadata.types.JavaTypesManager.getJavaTypeFromId(
                    column.getTalendType());
            String columnName = column.getLabel();
            boolean isPrimit =
                org.talend.core.model.metadata.types.JavaTypesManager.isJavaPrimitiveType(
                    column.getTalendType(), column.isNullable());
            if (isPrimit) {

              stringBuffer.append(TEXT_27);
              stringBuffer.append(var("log4jSb"));
              stringBuffer.append(TEXT_28);
              stringBuffer.append(rowStruct);
              stringBuffer.append(TEXT_29);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_30);

            } else {

              stringBuffer.append(TEXT_31);
              stringBuffer.append(rowStruct);
              stringBuffer.append(TEXT_32);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_33);
              stringBuffer.append(TEXT_34);
              stringBuffer.append(var("log4jSb"));
              stringBuffer.append(TEXT_35);
              stringBuffer.append(TEXT_36);
              stringBuffer.append(var("log4jSb"));
              stringBuffer.append(TEXT_37);
              stringBuffer.append(rowStruct);
              stringBuffer.append(TEXT_38);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_39);
            }

            stringBuffer.append(TEXT_40);
            stringBuffer.append(var("log4jSb"));
            stringBuffer.append(TEXT_41);
          }
        }
        trace(str("Content of the record "), nbline, str(": "), var("log4jSb"));
      }
    }

    class LogHelper {

      java.util.Map<String, String> pastDict = null;

      public LogHelper() {
        pastDict = new java.util.HashMap<String, String>();
        pastDict.put("insert", "inserted");
        pastDict.put("update", "updated");
        pastDict.put("delete", "deleted");
        pastDict.put("upsert", "upserted");
      }

      public String upperFirstChar(String data) {
        return data.substring(0, 1).toUpperCase() + data.substring(1);
      }

      public String toPastTense(String data) {
        return pastDict.get(data);
      }
    }
    LogHelper logHelper = new LogHelper();

    LogUtil log = null;

    stringBuffer.append(TEXT_42);

    class DBConnLogUtil extends BasicLogUtil {

      private DBConnLogUtil() {}

      protected DBConnLogUtil(org.talend.core.model.process.INode node) {
        super(node);
      }

      public void logJDBCDriver(String driverClass) {
        debug(str("Driver ClassName: "), driverClass, str("."));
      }

      public void connTry(String url, String dbUser) {
        if (dbUser != null) {
          info(
              str("Connection attempts to '"),
              url,
              str("' with the username '"),
              dbUser,
              str("'."));
        } else {
          info(str("Connection attempts to '"), url, str("'."));
        }
      }

      public void connDone(String url) {
        info(str("Connection to '"), url, str("' has succeeded."));
      }

      public void useExistConn(String url, String dbUser) {
        if (dbUser != null) {
          info(
              str("Uses an existing connection with username '"),
              dbUser,
              str("'. Connection URL: "),
              url,
              str("."));
        } else {
          info(str("Uses an existing connection. Connection URL: "), url, str("."));
        }
      }

      public void closeTry(String connCompID) {
        if (connCompID == null) {
          info(str("Closing the connection to the database."));
        } else {
          info(str("Closing the connection "), connCompID, str(" to the database."));
        }
      }

      public void closeDone(String connCompID) {
        if (connCompID == null) {
          info(str("Connection to the database has closed."));
        } else {
          info(str("Connection "), connCompID, str(" to the database has closed."));
        }
      }
    }

    class DBTableActionLogUtil extends BasicLogUtil {
      private DBTableActionLogUtil() {}

      protected DBTableActionLogUtil(org.talend.core.model.process.INode node) {
        super(node);
      }

      public void dropTry(String tableName) {
        tableActionTry(tableName, str("Dropping"));
      }

      public void dropDone(String tableName) {
        tableActionDone(tableName, str("Drop"));
      }

      public void createTry(String tableName) {
        tableActionTry(tableName, str("Creating"));
      }

      public void createDone(String tableName) {
        tableActionDone(tableName, str("Create"));
      }

      public void clearTry(String tableName) {
        tableActionTry(tableName, str("Clearing"));
      }

      public void clearDone(String tableName) {
        tableActionDone(tableName, str("Clear"));
      }

      public void truncateTry(String tableName) {
        tableActionTry(tableName, str("Truncating"));
      }

      public void truncateDone(String tableName) {
        tableActionDone(tableName, str("Truncate"));
      }

      public void truncateReuseStorageTry(String tableName) {
        tableActionTry(tableName, str("Truncating reuse storage"));
      }

      public void truncateReuseStorageDone(String tableName) {
        tableActionDone(tableName, str("Truncate reuse stroage"));
      }

      private void tableActionTry(String tableName, String action) {
        info(action, str(" table '"), tableName, str("'."));
      }

      private void tableActionDone(String tableName, String action) {
        info(action, str(" table '"), tableName, str("' has succeeded."));
      }
    }

    class DBCommitLogUtil extends BasicLogUtil {
      private DBCommitLogUtil() {}

      protected DBCommitLogUtil(org.talend.core.model.process.INode node) {
        super(node);
      }

      public void logAutoCommit(String autoCommit) {
        debug(str("Connection is set auto commit to '"), autoCommit, str("'."));
      }

      public void commitTry(String connCompID, String commitCount) {
        if (commitCount == null && connCompID == null) {
          debug(str("Connection starting to commit."));
        } else if (commitCount == null) {
          debug(str("Connection "), connCompID, str(" starting to commit."));
        } else if (connCompID == null) {
          debug(str("Connection starting to commit "), commitCount, str(" record(s)."));
        } else {
          debug(
              str("Connection "),
              connCompID,
              str(" starting to commit "),
              commitCount,
              str(" record(s)."));
        }
      }

      public void commitDone(String connCompID) {
        if (connCompID == null) {
          debug(str("Connection commit has succeeded."));
        } else {
          debug(str("Connection "), connCompID, (" commit has succeeded."));
        }
      }
    }

    class DBBatchLogUtil extends BasicLogUtil {
      private DBBatchLogUtil() {}

      protected DBBatchLogUtil(org.talend.core.model.process.INode node) {
        super(node);
      }

      public void executeTry(String action) {
        debug(str("Executing the "), action, str(" batch."));
      }

      public void executeDone(String action) {
        debug(str("The "), action, str(" batch execution has succeeded."));
      }
    }

    class DBDataActionLogUtil extends BasicLogUtil {
      private DBDataActionLogUtil() {}

      protected DBDataActionLogUtil(org.talend.core.model.process.INode node) {
        super(node);
      }

      public void inserting(String nbline) {
        sqlAction(nbline, str("Inserting"));
      }

      public void deleting(String nbline) {
        sqlAction(nbline, str("Deleting"));
      }

      public void updating(String nbline) {
        sqlAction(nbline, str("Updating"));
      }

      public void replacing(String nbline) {
        sqlAction(nbline, str("Replacing"));
      }

      public void insertingOnDuplicateKeyUpdating(String nbline) {
        sqlAction(nbline, str("Inserting on duplicate key updating"));
      }

      public void insertingIgnore(String nbline) {
        sqlAction(nbline, str("Inserting ignore"));
      }

      private void sqlAction(String nbline, String action) {
        if (nbline == null) {
          debug(action, str(" the record."));
        } else {
          debug(action, str(" the record "), nbline, str("."));
        }
      }

      public void sqlExecuteTry(String sql) {
        debug(str("Executing '"), sql, str("'."));
      }

      public void sqlExecuteDone(String sql) {
        debug(str("Execute '"), sql, str("' has succeeded."));
      }

      public void addingToBatch(String nbline, String batchAction) {
        debug(str("Adding the record "), nbline, str(" to the "), batchAction, str(" batch."));
      }
    }

    class DBStateLogUtil extends BasicLogUtil {
      private DBStateLogUtil() {}

      protected DBStateLogUtil(org.talend.core.model.process.INode node) {
        super(node);
      }

      public void logInsertedLines(String nbline) {
        logFinishedLines(nbline, str("inserted"));
      }

      public void logUpdatedLines(String nbline) {
        logFinishedLines(nbline, str("updated"));
      }

      public void logDeletedLines(String nbline) {
        logFinishedLines(nbline, str("deleted"));
      }

      public void logRejectedLines(String nbline) {
        logFinishedLines(nbline, str("rejected"));
      }

      private void logFinishedLines(String nbline, String action) {
        info(str("Has "), action, str(" "), nbline, str(" record(s)."));
      }
    }
    class DBLogUtil extends LogUtil {
      DBConnLogUtil conn = null;
      DBTableActionLogUtil table = null;
      DBCommitLogUtil commit = null;
      DBBatchLogUtil batch = null;
      DBDataActionLogUtil data = null;
      DBStateLogUtil state = null;

      private DBLogUtil() {}

      protected DBLogUtil(org.talend.core.model.process.INode node) {
        super(node);
        conn = new DBConnLogUtil(node);
        table = new DBTableActionLogUtil(node);
        commit = new DBCommitLogUtil(node);
        batch = new DBBatchLogUtil(node);
        data = new DBDataActionLogUtil(node);
        state = new DBStateLogUtil(node);
      }

      public DBConnLogUtil conn() {
        return conn;
      }

      public DBTableActionLogUtil table() {
        return table;
      }

      public DBCommitLogUtil commit() {
        return commit;
      }

      public DBBatchLogUtil batch() {
        return batch;
      }

      public DBDataActionLogUtil data() {
        return data;
      }

      public DBStateLogUtil state() {
        return state;
      }
    }
    DBLogUtil dbLog = null;

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    INode node = (INode) codeGenArgument.getArgument();
    String cid = node.getUniqueName();
    dbLog = new DBLogUtil(node);

    String dbhost = ElementParameterParser.getValue(node, "__HOST__");
    String dbport = ElementParameterParser.getValue(node, "__PORT__");
    String dbname = ElementParameterParser.getValue(node, "__DBNAME__");
    String dbuser = ElementParameterParser.getValue(node, "__USER__");

    String spName = ElementParameterParser.getValue(node, "__SP_NAME__");
    boolean isFunction = ("true").equals(ElementParameterParser.getValue(node, "__IS_FUNCTION__"));
    List<Map<String, String>> spArgs =
        (List<Map<String, String>>) ElementParameterParser.getObjectValue(node, "__SP_ARGS__");

    stringBuffer.append(TEXT_43);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_44);

    String useExistingConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__");
    if (("true").equals(useExistingConn)) {
      String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
      String conn = "conn_" + connection;

      stringBuffer.append(TEXT_45);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_46);
      stringBuffer.append(conn);
      stringBuffer.append(TEXT_47);

      INode connectionNode = NodeUtil.getNodeByUniqueName(node.getProcess(), connection);
      boolean specify_alias =
          "true"
              .equals(
                  ElementParameterParser.getValue(connectionNode, "__SPECIFY_DATASOURCE_ALIAS__"));
      if (specify_alias) {
        String alias = ElementParameterParser.getValue(connectionNode, "__DATASOURCE_ALIAS__");
        String autoCommit =
            "true".equals(ElementParameterParser.getValue(connectionNode, "__AUTO_COMMIT__"))
                ? "true"
                : "false";

        stringBuffer.append(TEXT_48);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_49);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_50);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_51);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_52);
        stringBuffer.append((null != alias && !("".equals(alias))) ? alias : "\"\"");
        stringBuffer.append(TEXT_53);
      }

      dbLog
          .conn()
          .useExistConn(
              "connection_" + cid + ".getMetaData().getURL()",
              "connection_" + cid + ".getMetaData().getUserName()");

    } else {
      boolean specify_alias =
          "true".equals(ElementParameterParser.getValue(node, "__SPECIFY_DATASOURCE_ALIAS__"));
      if (specify_alias) {
        String alias = ElementParameterParser.getValue(node, "__DATASOURCE_ALIAS__");

        stringBuffer.append(TEXT_54);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_55);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_56);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_57);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_58);
        stringBuffer.append((null != alias && !("".equals(alias))) ? alias : "\"\"");
        stringBuffer.append(TEXT_59);
      }
      String dbproperties = ElementParameterParser.getValue(node, "__PROPERTIES__");
      if (dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {

        stringBuffer.append(TEXT_60);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_61);
        stringBuffer.append(dbhost);
        stringBuffer.append(TEXT_62);
        stringBuffer.append(dbport);
        stringBuffer.append(TEXT_63);
        stringBuffer.append(dbname);
        stringBuffer.append(TEXT_64);

      } else {

        stringBuffer.append(TEXT_65);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_66);
        stringBuffer.append(dbhost);
        stringBuffer.append(TEXT_67);
        stringBuffer.append(dbport);
        stringBuffer.append(TEXT_68);
        stringBuffer.append(dbname);
        stringBuffer.append(TEXT_69);
        stringBuffer.append(dbproperties);
        stringBuffer.append(TEXT_70);
      }

      stringBuffer.append(TEXT_71);
      dbLog.conn().logJDBCDriver(dbLog.str("com.ibm.db2.jcc.DB2Driver"));

      String passwordFieldName = "__PASS__";

      stringBuffer.append(TEXT_72);
      if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
        stringBuffer.append(TEXT_73);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_74);
        stringBuffer.append(ElementParameterParser.getEncryptedValue(node, passwordFieldName));
        stringBuffer.append(TEXT_75);
      } else {
        stringBuffer.append(TEXT_76);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_77);
        stringBuffer.append(ElementParameterParser.getValue(node, passwordFieldName));
        stringBuffer.append(TEXT_78);
      }
      dbLog.conn().connTry(dbLog.var("url"), dbuser);
      stringBuffer.append(TEXT_79);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_80);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_81);
      stringBuffer.append(dbuser);
      stringBuffer.append(TEXT_82);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_83);
      dbLog.conn().connDone(dbLog.var("url"));

      if (specify_alias) {

        stringBuffer.append(TEXT_84);
      }
    }
    dbLog.commit().logAutoCommit("connection_" + cid + ".getAutoCommit()");

    stringBuffer.append(TEXT_85);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_86);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_87);
    stringBuffer.append(isFunction ? "? = " : "");
    stringBuffer.append(TEXT_88);
    stringBuffer.append(spName);
    stringBuffer.append(TEXT_89);

    boolean isFirstArg = true;
    for (int i = 0; i < spArgs.size(); i++) {
      if (!("RECORDSET").equals(spArgs.get(i).get("TYPE"))) {
        if (isFirstArg) {

          stringBuffer.append(TEXT_90);

          isFirstArg = false;
        } else {

          stringBuffer.append(TEXT_91);
        }
      }
    }

    stringBuffer.append(TEXT_92);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_93);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_94);
    stringBuffer.append(TEXT_95);
    return stringBuffer.toString();
  }