public boolean isOnMainMergeBranch() {
   // return true even if got no branch.
   Map<INode, Integer> mapMerge = NodeUtil.getLinkedMergeInfo(this);
   if (mapMerge == null) {
     return true;
   } else {
     for (Integer i : mapMerge.values()) {
       if (i != 1) {
         return false;
       }
     }
     return true;
   }
 }
  /**
   * Will return the first item of the subprocess. If "withCondition" is true, if there is links
   * from type RunIf / RunAfter / RunBefore, it will return the first element found. If
   * "withCondition" is false, it will return the first element with no active link from type
   * Main/Ref/Iterate.<br>
   * <i><b>Note:</b></i> This function doesn't work if the node has several start points (will
   * return a random start node).
   *
   * @param withCondition
   * @return Start Node found.
   */
  public INode getSubProcessStartNode(boolean withConditions) {
    if (!withConditions) {
      Map<INode, Integer> mapMerge = NodeUtil.getLinkedMergeInfo(this);
      if (mapMerge == null) { // no merge after, so must be sub process start.
        if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)) {
          return this;
        }
      } else {
        for (Integer i : mapMerge.values()) {
          if (i != 1) {
            // not first merge, so will take the last merge from the tree, and retrieve the main sub
            // process start.
            return mapMerge.keySet().iterator().next().getSubProcessStartNode(withConditions);
          }
        }
        if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)) {
          return this; // main branch here, so we got the correct sub process start.
        }
      }
    } else {
      int nb = 0;
      for (IConnection connection : getIncomingConnections()) {
        if (connection.isActivate()) {
          nb++;
        }
      }
      if (nb == 0) {
        return this;
      }
    }
    IConnection connec;

    for (int j = 0; j < getIncomingConnections().size(); j++) {
      connec = getIncomingConnections().get(j);
      if (((AbstractNode) connec.getSource()).isOnMainMergeBranch()) {
        if (!connec.getLineStyle().equals(EConnectionType.FLOW_REF)) {
          return connec.getSource().getSubProcessStartNode(withConditions);
        }
      }
    }
    return null;
  }
      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 List<? extends IConnection> getIncomingConnections(String connectorName) {
   return org.talend.core.model.utils.NodeUtil.getIncomingConnections(this, connectorName);
 }
 /*
  * (non-Javadoc)
  *
  * @see org.talend.core.model.process.INode#getOutgoingConnections(org.talend .core.model.process.EConnectionType)
  */
 public List<? extends IConnection> getOutgoingConnections(EConnectionType connectionType) {
   return org.talend.core.model.utils.NodeUtil.getOutgoingConnections(this, connectionType);
 }
 public List<? extends IConnection> getMainOutgoingConnections() {
   return org.talend.core.model.utils.NodeUtil.getMainOutgoingConnections(this);
 }
  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 String getQueryString(INode node) {
        String dbquery = ElementParameterParser.getValue(node, "__QUERY__");
        dbquery = org.talend.core.model.utils.NodeUtil.replaceCRLFInMEMO_SQL(dbquery);

        return dbquery;
      }
Пример #9
0
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    Vector v = (Vector) codeGenArgument.getArgument();
    IProcess process = (IProcess) v.get(0);
    String version = (String) v.get(1);
    String exportAsOSGI = (String) v.get(2);

    List<? extends INode> processNodes = (List<? extends INode>) process.getGeneratingNodes();
    boolean stats = codeGenArgument.isStatistics();
    boolean trace = codeGenArgument.isTrace();
    boolean isRunInMultiThread = codeGenArgument.getIsRunInMultiThread();
    List<IContextParameter> params = new ArrayList<IContextParameter>();
    params = process.getContextManager().getDefaultContext().getContextParameterList();

    IBrandingService service =
        (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    if (service instanceof AbstractBrandingService) {

      stringBuffer.append(TEXT_1);
      stringBuffer.append(((AbstractBrandingService) service).getJobLicenseHeader(version));
    }
    String jobFolderName =
        JavaResourcesHelper.getJobFolderName(process.getName(), process.getVersion());
    String packageName =
        codeGenArgument.getCurrentProjectName().toLowerCase() + "." + jobFolderName;

    stringBuffer.append(TEXT_2);
    stringBuffer.append(packageName);
    stringBuffer.append(TEXT_3);
    for (String routine : CodeGeneratorRoutine.getRequiredRoutineName(process)) {
      if (!routine.equals(ITalendSynchronizer.TEMPLATE)) {
        stringBuffer.append(TEXT_4);
        stringBuffer.append(routine);
        stringBuffer.append(TEXT_5);
      }
    }
    stringBuffer.append(TEXT_6);
    stringBuffer.append(TEXT_7);
    stringBuffer.append(ElementParameterParser.getValue(process, "__HEADER_IMPORT__"));
    stringBuffer.append(TEXT_8);
    stringBuffer.append(ElementParameterParser.getValue(process, "__FOOTER_IMPORT__"));
    stringBuffer.append(TEXT_9);

    List<INode> nodesWithImport = process.getNodesWithImport();
    if (nodesWithImport != null) {
      for (INode node : nodesWithImport) {

        stringBuffer.append(TEXT_10);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_11);
        stringBuffer.append(ElementParameterParser.getValue(node, "__IMPORT__"));
        stringBuffer.append(TEXT_12);
      }
    }

    stringBuffer.append(TEXT_13);
    stringBuffer.append(process.getName());
    stringBuffer.append(TEXT_14);
    stringBuffer.append(ElementParameterParser.getValue(process, "__PURPOSE__"));
    stringBuffer.append(TEXT_15);
    stringBuffer.append(ElementParameterParser.getValue(process, "__DESCRIPTION__"));
    stringBuffer.append(TEXT_16);
    stringBuffer.append(ElementParameterParser.getValue(process, "__AUTHOR__"));
    stringBuffer.append(TEXT_17);
    stringBuffer.append(version);
    stringBuffer.append(TEXT_18);
    stringBuffer.append(ElementParameterParser.getValue(process, "__STATUS__"));
    stringBuffer.append(TEXT_19);

    String talendJobInterfaces = "TalendJob";

    boolean talendMdmJob =
        !process.getNodesOfType("tMDMTriggerInput").isEmpty()
            || !process.getNodesOfType("tMDMTriggerOutput").isEmpty();
    boolean talendEsbJob =
        !process.getNodesOfType("tESBProviderRequest").isEmpty()
            || !process.getNodesOfType("tESBConsumer").isEmpty();
    boolean talendEsbJobFactory = !process.getNodesOfType("tESBProviderRequest").isEmpty();

    if (talendMdmJob) {
      talendJobInterfaces += ", TalendMDMJob"; // Talend MDM job
    }
    if (talendEsbJob) {
      talendJobInterfaces += ", TalendESBJob"; // Talend ESB job
    }
    if (talendEsbJobFactory) {
      talendJobInterfaces += ", TalendESBJobFactory"; // Talend ESB provider job
    }

    stringBuffer.append(TEXT_20);
    stringBuffer.append(process.getName());
    stringBuffer.append(TEXT_21);
    stringBuffer.append(talendJobInterfaces);
    stringBuffer.append(TEXT_22);
    if (talendEsbJobFactory) {
      stringBuffer.append(TEXT_23);
      stringBuffer.append(process.getName());
      stringBuffer.append(TEXT_24);
      stringBuffer.append(process.getName());
      stringBuffer.append(TEXT_25);
    }
    stringBuffer.append(TEXT_26);

    if (isRunInMultiThread) {

      stringBuffer.append(TEXT_27);
    }

    stringBuffer.append(TEXT_28);
    // it will be use in job setting.
    stringBuffer.append(TEXT_29);
    // uft-8 is for temp file, for example: tSortRow, tMap. Because they need keep reversibility.
    stringBuffer.append(TEXT_30);
    for (IContextParameter ctxParam : params) {
      String cParaName = ctxParam.getName();

      stringBuffer.append(TEXT_31);
      stringBuffer.append(cParaName);
      stringBuffer.append(TEXT_32);
      if (ctxParam.getType().equals("id_Date")) {
        stringBuffer.append(TEXT_33);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_34);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_35);
        stringBuffer.append(ctxParam.getValue());
        stringBuffer.append(TEXT_36);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_37);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_38);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_39);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_40);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_41);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_42);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_43);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_44);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_45);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_46);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_47);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_48);
      } else {
        stringBuffer.append(TEXT_49);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_50);
        stringBuffer.append(cParaName);
        stringBuffer.append(TEXT_51);
      }
      stringBuffer.append(TEXT_52);
    }
    stringBuffer.append(TEXT_53);

    for (IContextParameter ctxParam : params) {
      if (ctxParam.getType().equals("id_List Of Value")
          || ctxParam.getType().equals("id_File")
          || ctxParam.getType().equals("id_Directory")) {

        stringBuffer.append(TEXT_54);
        stringBuffer.append(ctxParam.getName());
        stringBuffer.append(TEXT_55);
        stringBuffer.append(
            Character.toUpperCase(ctxParam.getName().charAt(0)) + ctxParam.getName().substring(1));
        stringBuffer.append(TEXT_56);
        stringBuffer.append(ctxParam.getName());
        stringBuffer.append(TEXT_57);

      } else {

        stringBuffer.append(TEXT_58);
        stringBuffer.append(JavaTypesManager.getTypeToGenerate(ctxParam.getType(), true));
        stringBuffer.append(TEXT_59);
        stringBuffer.append(ctxParam.getName());
        stringBuffer.append(TEXT_60);
        stringBuffer.append(JavaTypesManager.getTypeToGenerate(ctxParam.getType(), true));
        stringBuffer.append(TEXT_61);
        stringBuffer.append(
            Character.toUpperCase(ctxParam.getName().charAt(0)) + ctxParam.getName().substring(1));
        stringBuffer.append(TEXT_62);
        stringBuffer.append(ctxParam.getName());
        stringBuffer.append(TEXT_63);
      }
    }

    stringBuffer.append(TEXT_64);
    stringBuffer.append(process.getVersion());
    stringBuffer.append(TEXT_65);
    stringBuffer.append(codeGenArgument.getJobName());
    stringBuffer.append(TEXT_66);
    stringBuffer.append(codeGenArgument.getCurrentProjectName());
    stringBuffer.append(TEXT_67);

    if (!isRunInMultiThread) {

      stringBuffer.append(TEXT_68);

    } else {

      stringBuffer.append(TEXT_69);
    }
    stringBuffer.append(TEXT_70);

    if (stats) {

      stringBuffer.append(TEXT_71);
    }

    if (trace) {

      stringBuffer.append(TEXT_72);
    }

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

    for (INode logCatcher : process.getNodesOfType("tLogCatcher")) {

      stringBuffer.append(TEXT_75);
      stringBuffer.append(logCatcher.getUniqueName());
      stringBuffer.append(TEXT_76);
    }

    for (INode statCatcher : process.getNodesOfType("tStatCatcher")) {

      stringBuffer.append(TEXT_77);
      stringBuffer.append(statCatcher.getUniqueName());
      stringBuffer.append(TEXT_78);
      stringBuffer.append(process.getId());
      stringBuffer.append(TEXT_79);
      stringBuffer.append(process.getVersion());
      stringBuffer.append(TEXT_80);
    }

    for (INode metterCatcher : process.getNodesOfType("tFlowMeterCatcher")) {

      stringBuffer.append(TEXT_81);
      stringBuffer.append(metterCatcher.getUniqueName());
      stringBuffer.append(TEXT_82);
      stringBuffer.append(process.getId());
      stringBuffer.append(TEXT_83);
      stringBuffer.append(process.getVersion());
      stringBuffer.append(TEXT_84);
    }

    for (INode assertCatcher : process.getNodesOfType("tAssertCatcher")) {

      stringBuffer.append(TEXT_85);
      stringBuffer.append(assertCatcher.getUniqueName());
      stringBuffer.append(TEXT_86);
    }

    stringBuffer.append(TEXT_87);
    stringBuffer.append(process.getName());
    stringBuffer.append(TEXT_88);
    stringBuffer.append(process.getName());
    stringBuffer.append(TEXT_89);

    if (process.getNodesOfType("tLogCatcher").size() > 0) {
      List<INode> logCatchers = (List<INode>) process.getNodesOfType("tLogCatcher");
      for (INode logCatcher : logCatchers) {
        if (ElementParameterParser.getValue(logCatcher, "__CATCH_JAVA_EXCEPTION__")
            .equals("true")) {
          // 1) add the message to the stack

          stringBuffer.append(TEXT_90);
          stringBuffer.append(logCatcher.getUniqueName());
          stringBuffer.append(TEXT_91);
        }
      }

      INode virtualNCatchNode = null;
      boolean hasRealCatchNode = false;
      for (INode logCatcher : logCatchers) {
        if (ElementParameterParser.getValue(logCatcher, "__CATCH_JAVA_EXCEPTION__")
            .equals("true")) {
          if (logCatcher.isVirtualGenerateNode()) {
            virtualNCatchNode = logCatcher;
          } else {
            hasRealCatchNode = true;
          }
        }
      }
      if (hasRealCatchNode && virtualNCatchNode != null) {

        stringBuffer.append(TEXT_92);
      }
      for (INode logCatcher : logCatchers) {
        if (ElementParameterParser.getValue(logCatcher, "__CATCH_JAVA_EXCEPTION__")
            .equals("true")) {
          if (logCatcher != virtualNCatchNode) {
            // 2) launch logCatcher subProcess

            stringBuffer.append(TEXT_93);
            stringBuffer.append(logCatcher.getDesignSubjobStartNode().getUniqueName());
            stringBuffer.append(TEXT_94);
          }
        }
      }
      if (hasRealCatchNode && virtualNCatchNode != null) {

        stringBuffer.append(TEXT_95);
      }
      if (virtualNCatchNode != null) {

        stringBuffer.append(TEXT_96);
        stringBuffer.append(virtualNCatchNode.getDesignSubjobStartNode().getUniqueName());
        stringBuffer.append(TEXT_97);
      }
      if (hasRealCatchNode && virtualNCatchNode != null) {

        stringBuffer.append(TEXT_98);
      }
    }

    stringBuffer.append(TEXT_99);

    boolean needCatchTalendException = false;
    if (process.getNodesOfType("tLogCatcher").size() > 0) {
      for (INode node : process.getNodesOfType("tLogCatcher")) {
        if (ElementParameterParser.getValue(node, "__CATCH_JAVA_EXCEPTION__").equals("true")) {
          needCatchTalendException = true;
          break;
        }
      }
    }

    if ((!needCatchTalendException) && (process.getNodesOfType("tAssertCatcher").size() > 0)) {
      for (INode node : process.getNodesOfType("tAssertCatcher")) {
        if (ElementParameterParser.getValue(node, "__CATCH_JAVA_EXCEPTION__").equals("true")) {
          needCatchTalendException = true;
          break;
        }
      }
    }
    if (needCatchTalendException) {
      if (process.getNodesOfType("tLogCatcher").size() > 0) {

        stringBuffer.append(TEXT_100);
      }
    }

    stringBuffer.append(TEXT_101);

    if (isRunInMultiThread) {

      stringBuffer.append(TEXT_102);

    } else {
      stringBuffer.append(TEXT_103);
    }

    stringBuffer.append(TEXT_104);
    // Methods for RUN IF Error links

    for (INode node : processNodes) {
      if (node.isActivate()) {

        stringBuffer.append(TEXT_105);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_106);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_107);

        boolean ifBeforRunError = NodeUtil.checkComponentErrorConnectionAfterNode(node);
        if (!ifBeforRunError) {
          if (process.getNodesOfType("tAssertCatcher").size() > 0) {
            List<INode> assertCatchers = (List<INode>) process.getNodesOfType("tAssertCatcher");
            for (INode assertCatcher : assertCatchers) {
              if (ElementParameterParser.getValue(assertCatcher, "__CATCH_JAVA_EXCEPTION__")
                  .equals("true")) {
                // 1) add the message to the stack

                stringBuffer.append(TEXT_108);
                stringBuffer.append(assertCatcher.getUniqueName());
                stringBuffer.append(TEXT_109);
                stringBuffer.append(assertCatcher.getDesignSubjobStartNode().getUniqueName());
                stringBuffer.append(TEXT_110);
              }
            }
          }
        }
        if (!node.getComponent().getName().equals("tDie")) {
          String statCatcher = ElementParameterParser.getValue(node, "__TSTATCATCHER_STATS__");
          if (statCatcher.compareTo("true") == 0) {
            for (INode statCatcherNode : node.getProcess().getNodesOfType("tStatCatcher")) {

              stringBuffer.append(TEXT_111);
              stringBuffer.append(statCatcherNode.getUniqueName());
              stringBuffer.append(TEXT_112);
              stringBuffer.append(node.getUniqueName());
              stringBuffer.append(TEXT_113);
              stringBuffer.append(node.getUniqueName());
              stringBuffer.append(TEXT_114);
              stringBuffer.append(node.getUniqueName());
              stringBuffer.append(TEXT_115);
              stringBuffer.append(statCatcherNode.getDesignSubjobStartNode().getUniqueName());
              stringBuffer.append(TEXT_116);
            }
          }
        }
        boolean isExistOnCompErrorLink = false;
        List<? extends IConnection> conns = node.getOutgoingConnections();
        for (IConnection conn : conns) {
          if (conn.getLineStyle().equals(EConnectionType.ON_COMPONENT_ERROR)) {
            isExistOnCompErrorLink = true;

            stringBuffer.append(TEXT_117);
            if (stats) {
              stringBuffer.append(TEXT_118);
              stringBuffer.append(conn.getUniqueName());
              stringBuffer.append(TEXT_119);
            }
            stringBuffer.append(TEXT_120);

            if (isRunInMultiThread) {

              stringBuffer.append(TEXT_121);
              stringBuffer.append(conn.getTarget().getUniqueName());
              stringBuffer.append(TEXT_122);

            } else {

              stringBuffer.append(TEXT_123);
              stringBuffer.append(conn.getTarget().getUniqueName());
              stringBuffer.append(TEXT_124);
            }

            stringBuffer.append(TEXT_125);
          }
        }
        boolean isSubjobHasOnSubJobError = false;
        if (!isExistOnCompErrorLink) {
          INode subJobStartNode = node.getDesignSubjobStartNode();
          if (subJobStartNode != null) {
            List<? extends IConnection> tempConns = subJobStartNode.getOutgoingConnections();
            for (IConnection conn : tempConns) {
              if (conn.getLineStyle().equals(EConnectionType.ON_SUBJOB_ERROR)) {
                isSubjobHasOnSubJobError = true;
                break;
              }
            }
          }
        }

        if (!isSubjobHasOnSubJobError
            && !isExistOnCompErrorLink) { // when there is no subjoberror and no onComponentError
          if (isRunInMultiThread) {

            stringBuffer.append(TEXT_126);

          } else {

            stringBuffer.append(TEXT_127);
          }
        }
        // when use parallelize will add virtual components(tAsyncIn and tAsyncOut) but in graphical
        // these is visable=false
        if ("true".equals(ElementParameterParser.getValue(node, "__PARALLELIZE__"))) {
          for (INode gNode : node.getProcess().getGeneratingNodes()) {
            if (gNode.getUniqueName().equals(node.getUniqueName())) {
              if (gNode.getIncomingConnections(EConnectionType.FLOW_MAIN).size() != 0) {
                INode gSourceNode =
                    gNode.getIncomingConnections(EConnectionType.FLOW_MAIN).get(0).getSource();
                node = gSourceNode;
              }
            }
          }
        }
        // end

        stringBuffer.append(TEXT_128);
        stringBuffer.append(node.getDesignSubjobStartNode().getUniqueName());
        stringBuffer.append(TEXT_129);
      }
    }
    for (INode node : processNodes) {
      if (node.isDesignSubjobStartNode()) {

        stringBuffer.append(TEXT_130);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_131);

        List<? extends IConnection> conns = node.getOutgoingConnections();
        int count = 0;
        for (IConnection conn : conns) {
          if (conn.getLineStyle().equals(EConnectionType.ON_SUBJOB_ERROR)) {
            count++;
          }
        }

        String label = "ERROR";

        if (count == 0) { // FATAL
          label = "FATAL";
        } else { // ERROR------>RunSubJobError
          label = "ERROR";
        }

        stringBuffer.append(TEXT_132);
        stringBuffer.append(label);
        stringBuffer.append(TEXT_133);

        for (IConnection conn : conns) {
          if (conn.getLineStyle().equals(EConnectionType.ON_SUBJOB_ERROR)) {

            stringBuffer.append(TEXT_134);
            if (stats) {
              stringBuffer.append(TEXT_135);
              stringBuffer.append(conn.getUniqueName());
              stringBuffer.append(TEXT_136);
            }

            if (isRunInMultiThread) {

              stringBuffer.append(TEXT_137);
              stringBuffer.append(conn.getTarget().getUniqueName());
              stringBuffer.append(TEXT_138);

            } else {

              stringBuffer.append(TEXT_139);
              stringBuffer.append(conn.getTarget().getUniqueName());
              stringBuffer.append(TEXT_140);
            }

            stringBuffer.append(TEXT_141);
          }
        }

        stringBuffer.append(TEXT_142);
      }
    }

    stringBuffer.append(TEXT_143);
    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();
  }