示例#1
0
  public void rebuildModelInputs(List<? extends IConnection> inputConn, PigMapData mapData) {
    // remove no used input table
    if (mapData.getInputTables().size() != inputConn.size()) {
      List tableToRemove = new ArrayList();
      for (InputTable inputTable : mapData.getInputTables()) {
        boolean found = false;
        for (IConnection connection : inputConn) {
          if (inputTable.getName().equals(connection.getName())) {
            found = true;
          }
        }
        if (!found) {
          for (TableNode tableNode : inputTable.getNodes()) {
            PigMapUtil.detachNodeConnections(tableNode, mapData);
          }
          tableToRemove.add(inputTable);
          PigMapUtil.detachFilterSource(inputTable, mapData);
        }
      }
      mapData.getInputTables().removeAll(tableToRemove);
    }

    for (IConnection inData : inputConn) {
      String name = inData.getName();
      InputTable inputTable = null;
      for (InputTable in : mapData.getInputTables()) {
        if (in.getName() != null && in.getName().equals(name)) {
          inputTable = in;
          break;
        }
      }
      if (inputTable == null) {
        inputTable = PigmapFactory.eINSTANCE.createInputTable();
        inputTable.setName(name);
        inputTable.setLookup(EConnectionType.FLOW_MAIN != inData.getLineStyle());
        mapData
            .getInputTables()
            .add(inputTable.isLookup() ? mapData.getInputTables().size() : 0, inputTable);
      } else {
        inputTable.setLookup(EConnectionType.FLOW_MAIN != inData.getLineStyle());
      }
      // by default
      if (inputTable.isLookup() && inputTable.getJoinModel() == null) {
        inputTable.setJoinModel(TableSettingsConstant.LEFT_OUTER_JOIN);
      }
      if (inputTable.isLookup() && inputTable.getJoinOptimization() == null) {
        inputTable.setJoinOptimization(PIG_MAP_JOIN_OPTIMIZATION.NONE.toString());
      }
      rebuildInputTable(inputTable, inData.getMetadataTable(), mapData);
    }
  }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

    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_2);
            stringBuffer.append(level.substring(0, 1).toUpperCase() + level.substring(1));
            stringBuffer.append(TEXT_3);
          }

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

      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_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"));
      }

      // 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_24);
          stringBuffer.append(var("log4jSb"));
          stringBuffer.append(TEXT_25);

          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_26);
              stringBuffer.append(var("log4jSb"));
              stringBuffer.append(TEXT_27);
              stringBuffer.append(rowStruct);
              stringBuffer.append(TEXT_28);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_29);

            } else {

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

            stringBuffer.append(TEXT_39);
            stringBuffer.append(var("log4jSb"));
            stringBuffer.append(TEXT_40);
          }
        }
        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;

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

    log = new LogUtil(node);
    boolean useExistingConn =
        ("true").equals(ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"));

    stringBuffer.append(TEXT_41);

    List<? extends IConnection> inputConnections = node.getIncomingConnections();
    if ((inputConnections == null) || (inputConnections.size() == 0)) {
      return "";
    }

    IConnection inputConnection = inputConnections.get(0);

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

    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 "";
    }

    IMetadataTable inputMetadata = inputConnection.getMetadataTable();
    if (inputMetadata == null) {
      return "";
    }

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

    IMetadataTable outputMetadata = outputConnection.getMetadataTable();
    if (outputMetadata == null) {
      return "";
    }

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

    int count = 0;
    for (IConnection inConnection : inputConnections) {
      if (inConnection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
        count++;
      }
    }

    for (IConnection outConnection : outputConnections) {
      if (outConnection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
        count++;
      }
    }

    if (count != 2) {
      return "";
    }

    stringBuffer.append(TEXT_42);
    if (!useExistingConn) {
      stringBuffer.append(TEXT_43);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_44);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_45);
      log.info(log.str("Closing the connection."));
      stringBuffer.append(TEXT_46);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_47);
      log.info(log.str("Connection has closed."));
      stringBuffer.append(TEXT_48);
    }
    stringBuffer.append(TEXT_49);
    stringBuffer.append(TEXT_50);
    return stringBuffer.toString();
  }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

    /* Algorithm:
     * For each procedure arguments
     *   If argument type is IN or IN OUT
     *     Bind parameter to procedure call
     *   If argument type is OUT or IN OUT
     *     Register output parameter in procedure call
     *
     * Execute procedure
     *
     * For each column in first output schema
     *   If column match a procedure argument
     *     If argument type is IN
     *       Copy argument value from input flow
     *     If argument type is OUT or IN OUT
     *       Retrieve argument value from procedure call
     *     Copy argument value from first output schema to each output schema
     *   Else
     *     If column is defined in input schema
     *       Copy column value from input schema to each output schema
     */

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

    List<Map<String, String>> spArgs =
        (List<Map<String, String>>) ElementParameterParser.getObjectValue(node, "__SP_ARGS__");

    // Functions have an additionnal output parameter
    boolean isFunction = ("true").equals(ElementParameterParser.getValue(node, "__IS_FUNCTION__"));
    if (isFunction) {
      // Add return value at first position of parameters list
      String returnField = ElementParameterParser.getValue(node, "__RETURN__");

      HashMap<String, String> returnValue = new HashMap<String, String>();
      returnValue.put("COLUMN", returnField);
      returnValue.put("TYPE", "RETURN_FUNCTION");
      spArgs.add(returnValue);
    }

    class JavaToDbType {
      public String convert(String javaType) {
        if (("String").equals(javaType)) {
          return "VARCHAR";
        } else if (javaType.equalsIgnoreCase("char") || ("Character").equals(javaType)) {
          return "CHAR";
        } else if (("byte[]").equals(javaType)) {
          return "RAW";
        } else if (("java.util.Date").equals(javaType)) {
          return "DATE";
        } else if (javaType.equalsIgnoreCase("boolean")) {
          return "BOOLEAN";
        } else if (javaType.equalsIgnoreCase("byte")) {
          return "TINYINT";
        } else if (javaType.equalsIgnoreCase("short")) {
          return "SMALLINT";
        } else if (javaType.equalsIgnoreCase("int") || ("Integer").equals(javaType)) {
          return "INTEGER";
        } else if (javaType.equalsIgnoreCase("long")) {
          return "BIGINT";
        } else if (javaType.equalsIgnoreCase("float")) {
          return "FLOAT";
        } else if (javaType.equalsIgnoreCase("double")) {
          return "DOUBLE";
        } else {
          return "OTHER";
        }
      }
    }
    JavaToDbType converter = new JavaToDbType();

    // Search incoming schema
    IMetadataTable inMetadata = null;
    IConnection inConnection = null;
    String inConnectionName = null;

    List<? extends IConnection> inConnections = node.getIncomingConnections();
    if (inConnections != null) {
      for (int i = 0; i < inConnections.size(); i++) {
        IConnection connection = inConnections.get(i);
        if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
          inConnection = connection;
          inConnectionName = inConnection.getName();
          inMetadata = inConnection.getMetadataTable();
        }
      }
    }

    // If there is an IN or an INOUT argument, the component must have an input
    // connection
    boolean canGenerate = true;
    if (inConnection == null) {
      for (int i = 0; i < spArgs.size(); i++) {
        String argType = spArgs.get(i).get("TYPE");
        if (("IN").equals(argType) || ("INOUT").equals(argType)) {

          stringBuffer.append(TEXT_2);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_3);

          canGenerate = false;
          break;
        }
      }
    }

    if (canGenerate) {
      // Search outgoing schema
      IMetadataTable metadata = null;

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

      // We only generate output if outgoing schema is defined
      if (metadata != null) {
        List<IMetadataColumn> columnList = metadata.getListColumns();

        // Iterate over procedure arguments
        for (int i = 0; i < spArgs.size(); i++) {
          Map<String, String> spArg = spArgs.get(i);
          String argName = spArg.get("COLUMN");
          String argType = spArg.get("TYPE");

          // Search Java type of argument, based on schema column
          String typeToGenerate = null;
          boolean nullable = false;
          for (IMetadataColumn column : columnList) {
            if (column.getLabel().equals(argName)) {
              typeToGenerate =
                  JavaTypesManager.getTypeToGenerate(column.getTalendType(), column.isNullable());
              nullable = column.isNullable();
              break;
            }
          }

          if (typeToGenerate == null) continue;

          // Note: first argument in JDBC is arg #1, and for functions, arg #1 is return value
          int argIndex = i + 1;

          // Input argument
          if (("IN").equals(argType) || ("INOUT").equals(argType)) {
            if (nullable) {

              stringBuffer.append(TEXT_4);
              stringBuffer.append(inConnectionName);
              stringBuffer.append(TEXT_5);
              stringBuffer.append(argName);
              stringBuffer.append(TEXT_6);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_7);
              stringBuffer.append(argIndex);
              stringBuffer.append(TEXT_8);
              stringBuffer.append(converter.convert(typeToGenerate));
              stringBuffer.append(TEXT_9);
            }

            String method;
            if (("byte[]").equals(typeToGenerate)) {
              method = "Bytes";
            } else if (("Integer").equals(typeToGenerate)) {
              method = "Int";
            } else {
              method = typeToGenerate.substring(0, 1).toUpperCase() + typeToGenerate.substring(1);
            }

            // Bind parameter to CallableStatement
            if (("char").equals(typeToGenerate) || ("Character").equals(typeToGenerate)) {

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

            } else if (("java.util.Date").equals(typeToGenerate)) {

              stringBuffer.append(TEXT_19);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_20);
              stringBuffer.append(argIndex);
              stringBuffer.append(TEXT_21);
              stringBuffer.append(inConnectionName);
              stringBuffer.append(TEXT_22);
              stringBuffer.append(argName);
              stringBuffer.append(TEXT_23);

            } else {

              stringBuffer.append(TEXT_24);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_25);
              stringBuffer.append(method);
              stringBuffer.append(TEXT_26);
              stringBuffer.append(argIndex);
              stringBuffer.append(TEXT_27);
              stringBuffer.append(inConnectionName);
              stringBuffer.append(TEXT_28);
              stringBuffer.append(argName);
              stringBuffer.append(TEXT_29);
            }

            if (nullable) {

              stringBuffer.append(TEXT_30);
            }
          }

          // Output argument
          if (("OUT").equals(argType) || ("INOUT").equals(argType)) {

            stringBuffer.append(TEXT_31);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_32);
            stringBuffer.append(argIndex);
            stringBuffer.append(TEXT_33);
            stringBuffer.append(converter.convert(typeToGenerate));
            stringBuffer.append(TEXT_34);
          }
        }

        stringBuffer.append(TEXT_35);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_36);

        List<? extends IConnection> outConnections = node.getOutgoingConnections();
        IConnection firstOutConnection = null;

        if (outConnections != null) {
          // Search first outgoing connection, if exists
          int connectionIndex = -1;
          for (int i = 0; i < outConnections.size(); i++) {
            IConnection connection = outConnections.get(i);
            if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
              firstOutConnection = connection;
              connectionIndex = i;
              break;
            }
          }

          if (firstOutConnection != null) {
            columns:
            for (IMetadataColumn column : columnList) {
              // Retrieve OUT arguments value, and copy IN arguments from input flow
              for (int i = 0; i < spArgs.size(); i++) {
                Map<String, String> spArg = spArgs.get(i);
                String argName = spArg.get("COLUMN");

                if (column.getLabel().equals(argName)) {
                  String argType = spArg.get("TYPE");
                  String typeToGenerate =
                      JavaTypesManager.getTypeToGenerate(
                          column.getTalendType(), column.isNullable());
                  boolean nullable = column.isNullable();
                  int argIndex = i + 1;

                  if (("IN").equals(argType)) {
                    // Copy parameter value from input flow

                    stringBuffer.append(TEXT_37);
                    stringBuffer.append(firstOutConnection.getName());
                    stringBuffer.append(TEXT_38);
                    stringBuffer.append(argName);
                    stringBuffer.append(TEXT_39);
                    stringBuffer.append(inConnectionName);
                    stringBuffer.append(TEXT_40);
                    stringBuffer.append(argName);
                    stringBuffer.append(TEXT_41);

                  } else if (("RECORDSET").equals(argType)) {

                    stringBuffer.append(TEXT_42);
                    stringBuffer.append(firstOutConnection.getName());
                    stringBuffer.append(TEXT_43);
                    stringBuffer.append(argName);
                    stringBuffer.append(TEXT_44);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_45);

                  } else if (("RETURN_FUNCTION").equals(argType)) {

                    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);

                    String method;
                    argIndex = 1;
                    if (("byte[]").equals(typeToGenerate)) {
                      method = "Bytes";
                    } else if (("java.util.Date").equals(typeToGenerate)) {
                      method = "Date";
                    } else if (("Integer").equals(typeToGenerate)) {
                      method = "Int";
                    } else {
                      method =
                          typeToGenerate.substring(0, 1).toUpperCase()
                              + typeToGenerate.substring(1);
                    }

                    if (method.equalsIgnoreCase("char") || ("Character").equals(method)) {

                      stringBuffer.append(TEXT_50);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_51);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_52);
                      stringBuffer.append(argIndex);
                      stringBuffer.append(TEXT_53);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_54);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_55);
                      stringBuffer.append(firstOutConnection.getName());
                      stringBuffer.append(TEXT_56);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_57);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_58);

                    } else if (("Date").equals(method)) {

                      stringBuffer.append(TEXT_59);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_60);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_61);
                      stringBuffer.append(argIndex);
                      stringBuffer.append(TEXT_62);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_63);
                      stringBuffer.append(firstOutConnection.getName());
                      stringBuffer.append(TEXT_64);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_65);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_66);

                    } else {

                      stringBuffer.append(TEXT_67);
                      stringBuffer.append(firstOutConnection.getName());
                      stringBuffer.append(TEXT_68);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_69);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_70);
                      stringBuffer.append(method);
                      stringBuffer.append(TEXT_71);
                      stringBuffer.append(argIndex);
                      stringBuffer.append(TEXT_72);
                    }

                    stringBuffer.append(TEXT_73);

                  } else {
                    // Retrieve parameter value (INOUT or OUT)
                    String method;
                    if (("byte[]").equals(typeToGenerate)) {
                      method = "Bytes";
                    } else if (("java.util.Date").equals(typeToGenerate)) {
                      method = "Date";
                    } else if (("Integer").equals(typeToGenerate)) {
                      method = "Int";
                    } else {
                      method =
                          typeToGenerate.substring(0, 1).toUpperCase()
                              + typeToGenerate.substring(1);
                    }

                    if (method.equalsIgnoreCase("char") || ("Character").equals(method)) {

                      stringBuffer.append(TEXT_74);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_75);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_76);
                      stringBuffer.append(argIndex);
                      stringBuffer.append(TEXT_77);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_78);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_79);
                      stringBuffer.append(firstOutConnection.getName());
                      stringBuffer.append(TEXT_80);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_81);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_82);

                    } else if (("Date").equals(method)) {

                      stringBuffer.append(TEXT_83);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_84);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_85);
                      stringBuffer.append(argIndex);
                      stringBuffer.append(TEXT_86);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_87);
                      stringBuffer.append(firstOutConnection.getName());
                      stringBuffer.append(TEXT_88);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_89);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_90);

                    } else {

                      stringBuffer.append(TEXT_91);
                      stringBuffer.append(firstOutConnection.getName());
                      stringBuffer.append(TEXT_92);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_93);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_94);
                      stringBuffer.append(method);
                      stringBuffer.append(TEXT_95);
                      stringBuffer.append(argIndex);
                      stringBuffer.append(TEXT_96);
                    }

                    if (nullable) {

                      stringBuffer.append(TEXT_97);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_98);
                      stringBuffer.append(firstOutConnection.getName());
                      stringBuffer.append(TEXT_99);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_100);
                    }
                  }

                  for (int j = connectionIndex + 1; j < outConnections.size(); j++) {
                    IConnection connection = outConnections.get(j);
                    if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {

                      stringBuffer.append(TEXT_101);
                      stringBuffer.append(connection.getName());
                      stringBuffer.append(TEXT_102);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_103);
                      stringBuffer.append(firstOutConnection.getName());
                      stringBuffer.append(TEXT_104);
                      stringBuffer.append(argName);
                      stringBuffer.append(TEXT_105);
                    }
                  }

                  continue columns;
                }
              }

              // Copy columns defined in input and output schema which are not arguments
              if (inMetadata != null && inMetadata.getListColumns() != null) {
                for (IMetadataColumn inColumn : inMetadata.getListColumns()) {
                  if (column.getLabel().equals(inColumn.getLabel())) {
                    for (int j = 0; j < outConnections.size(); j++) {
                      IConnection connection = outConnections.get(j);
                      if (connection
                          .getLineStyle()
                          .hasConnectionCategory(IConnectionCategory.DATA)) {

                        stringBuffer.append(TEXT_106);
                        stringBuffer.append(connection.getName());
                        stringBuffer.append(TEXT_107);
                        stringBuffer.append(column.getLabel());
                        stringBuffer.append(TEXT_108);
                        stringBuffer.append(inConnectionName);
                        stringBuffer.append(TEXT_109);
                        stringBuffer.append(column.getLabel());
                        stringBuffer.append(TEXT_110);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      } else {

        stringBuffer.append(TEXT_111);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_112);
      }
    }

    stringBuffer.append(TEXT_113);
    return stringBuffer.toString();
  }
示例#4
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 dieOnError = ElementParameterParser.getValue(node, "__DIE_ON_ERROR__");
    String commitEvery = ElementParameterParser.getValue(node, "__COMMIT_EVERY__");
    String useExistingConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__");
    String propagateRecordset = ElementParameterParser.getValue(node, "__PROPAGATE_RECORD_SET__");
    String recordsetColumn = ElementParameterParser.getValue(node, "__RECORD_SET_COLUMN__");

    boolean usePrepareStatement =
        "true".equals(ElementParameterParser.getValue(node, "__USE_PREPAREDSTATEMENT__"));
    String dbquery = ElementParameterParser.getValue(node, "__QUERY__");
    dbquery = dbquery.replaceAll("\n", " ");
    dbquery = dbquery.replaceAll("\r", " ");
    List<Map<String, String>> prepareStatementParameters =
        (List<Map<String, String>>)
            ElementParameterParser.getObjectValue(node, "__SET_PREPAREDSTATEMENT_PARAMETERS__");

    String incomingConnName = null;
    Set<String> inputCols = new HashSet<String>();

    List<IMetadataColumn> columnList = null;

    String rejectConnName = null;
    List<? extends IConnection> rejectConns = node.getOutgoingConnections("REJECT");
    if (rejectConns != null && rejectConns.size() > 0) {
      IConnection rejectConn = rejectConns.get(0);
      rejectConnName = rejectConn.getName();
    }
    List<IMetadataColumn> rejectColumnList = null;
    IMetadataTable metadataTable = node.getMetadataFromConnector("REJECT");
    if (metadataTable != null) {
      rejectColumnList = metadataTable.getListColumns();
    }

    List<? extends IConnection> outgoingConns = node.getOutgoingSortedConnections();

    boolean hasOutgoingDataConnection = false;
    for (IConnection conn : outgoingConns) {
      if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
        if (!hasOutgoingDataConnection) {
          hasOutgoingDataConnection = true;
        }

        stringBuffer.append(TEXT_2);
        stringBuffer.append(conn.getName());
        stringBuffer.append(TEXT_3);
      }
    }

    stringBuffer.append(TEXT_4);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(dbquery);
    stringBuffer.append(TEXT_6);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_7);

    List<IMetadataTable> metadatas = node.getMetadataList();
    if ((metadatas != null) && (metadatas.size() > 0)) {
      IMetadataTable metadata = metadatas.get(0);
      if (metadata != null) {
        List<? extends IConnection> inConnections = node.getIncomingConnections();
        columnList = metadata.getListColumns();
        if (inConnections != null && inConnections.size() > 0) {
          IConnection conn = inConnections.get(0);
          if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
            incomingConnName = conn.getName();
            IMetadataTable inputMetadataTable = conn.getMetadataTable();
            for (IMetadataColumn inputCol : inputMetadataTable.getListColumns()) {
              inputCols.add(inputCol.getLabel());
            }
          }
        } // end of connection size.
      } // end of metadatas
    }
    if (!hasOutgoingDataConnection || columnList == null || columnList.size() < 1) {
      propagateRecordset = "false";
    }

    stringBuffer.append(TEXT_8);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_9);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_10);

    if (("true").equals(propagateRecordset)) {

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

    stringBuffer.append(TEXT_13);

    if (usePrepareStatement) {

      for (Map<String, String> param : prepareStatementParameters) {

        if ("Date".equals(param.get("PARAMETER_TYPE"))) {

          stringBuffer.append(TEXT_14);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_15);
          stringBuffer.append(param.get("PARAMETER_INDEX"));
          stringBuffer.append(TEXT_16);
          stringBuffer.append(param.get("PARAMETER_VALUE"));
          stringBuffer.append(TEXT_17);

        } else {

          stringBuffer.append(TEXT_18);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_19);
          stringBuffer.append(param.get("PARAMETER_TYPE"));
          stringBuffer.append(TEXT_20);
          stringBuffer.append(param.get("PARAMETER_INDEX"));
          stringBuffer.append(TEXT_21);
          stringBuffer.append(param.get("PARAMETER_VALUE"));
          stringBuffer.append(TEXT_22);
        }
      }

      if (("true").equals(propagateRecordset)) {

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

      } else {

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

    } else {
      if (("true").equals(propagateRecordset)) {

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

      } else {

        stringBuffer.append(TEXT_32);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_33);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_34);
      }
    }

    stringBuffer.append(TEXT_35);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_36);

    if (("true").equals(dieOnError)) {

      stringBuffer.append(TEXT_37);

    } else {
      if (rejectConnName != null && rejectColumnList != null && rejectColumnList.size() > 0) {

        stringBuffer.append(TEXT_38);
        stringBuffer.append(rejectConnName);
        stringBuffer.append(TEXT_39);
        stringBuffer.append(rejectConnName);
        stringBuffer.append(TEXT_40);

        if (incomingConnName != null) {
          for (IMetadataColumn column : columnList) {
            if (inputCols.contains(column.getLabel())) {

              stringBuffer.append(TEXT_41);
              stringBuffer.append(rejectConnName);
              stringBuffer.append(TEXT_42);
              stringBuffer.append(column.getLabel());
              stringBuffer.append(TEXT_43);
              stringBuffer.append(incomingConnName);
              stringBuffer.append(TEXT_44);
              stringBuffer.append(column.getLabel());
              stringBuffer.append(TEXT_45);
            }
          }
        }

        stringBuffer.append(TEXT_46);
        stringBuffer.append(rejectConnName);
        stringBuffer.append(TEXT_47);
        stringBuffer.append(TEXT_48);
        stringBuffer.append(rejectConnName);
        stringBuffer.append(TEXT_49);
        stringBuffer.append(node.getUniqueName());
        stringBuffer.append(TEXT_50);

      } else {

        stringBuffer.append(TEXT_51);
      }
    }

    stringBuffer.append(TEXT_52);

    if (outgoingConns != null && outgoingConns.size() > 0) {

      stringBuffer.append(TEXT_53);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_54);

      for (IConnection outgoingConn : outgoingConns) {
        if (rejectConnName == null
            || (rejectConnName != null && !outgoingConn.getName().equals(rejectConnName))) {
          if (outgoingConn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {

            stringBuffer.append(TEXT_55);
            stringBuffer.append(outgoingConn.getName());
            stringBuffer.append(TEXT_56);
            stringBuffer.append(outgoingConn.getName());
            stringBuffer.append(TEXT_57);

            for (IMetadataColumn column : columnList) {
              if (("true").equals(propagateRecordset)
                  && column.getLabel().equals(recordsetColumn)) {

                stringBuffer.append(TEXT_58);
                stringBuffer.append(outgoingConn.getName());
                stringBuffer.append(TEXT_59);
                stringBuffer.append(column.getLabel());
                stringBuffer.append(TEXT_60);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_61);

              } else {
                if (incomingConnName != null) {
                  if (inputCols.contains(column.getLabel())) {

                    stringBuffer.append(TEXT_62);
                    stringBuffer.append(outgoingConn.getName());
                    stringBuffer.append(TEXT_63);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_64);
                    stringBuffer.append(incomingConnName);
                    stringBuffer.append(TEXT_65);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_66);
                  }
                }
              }
            }
          }
        }
      }

      stringBuffer.append(TEXT_67);
    }
    if (!("true").equals(useExistingConn)) {
      if (!("").equals(commitEvery) && !("0").equals(commitEvery)) {

        stringBuffer.append(TEXT_68);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_69);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_70);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_71);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_72);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_73);
      }
    }

    stringBuffer.append(TEXT_74);
    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<IMetadataTable> metadatas = node.getMetadataList();
    if ((metadatas != null) && (metadatas.size() > 0)) {
      IMetadataTable metadata = metadatas.get(0);
      List<? extends IConnection> conns = node.getIncomingConnections();
      IMetadataTable inMetadata = null;
      String connName = "";
      if (conns != null) {
        for (IConnection conn : conns) {
          if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
            connName = conn.getName();
            inMetadata = conn.getMetadataTable();
            break;
          }
        }
        if (metadata != null && inMetadata != null) {
          List<IMetadataColumn> columns = inMetadata.getListColumns();
          Map<String, String> typesMap = new HashMap<String, String>();
          Map<String, String> patternsMap = new HashMap<String, String>();
          for (IMetadataColumn column : columns) {
            String type =
                JavaTypesManager.getTypeToGenerate(column.getTalendType(), column.isNullable());
            typesMap.put(column.getLabel(), type);
            String pattern =
                ((column.getPattern() == null) || (column.getPattern().trim().length() == 0))
                    ? ""
                    : column.getPattern();
            patternsMap.put(column.getLabel(), pattern);
          }
          String rowCount =
              ElementParameterParser.getValue(node, "__ROW_COUNT__"); // ?? i think we need it

          List<Map<String, String>> denormalizes =
              (List<Map<String, String>>)
                  ElementParameterParser.getObjectValue(node, "__DENORMALIZE_COLUMNS__");
          List<String> denormalizeColumns = new ArrayList<String>();
          List<String> denormalizeColumnsType = new ArrayList<String>();
          List<String> denormalizeDelimiters = new ArrayList<String>();
          List<Boolean> denormalizeMergeFlags = new ArrayList<Boolean>();
          List<IMetadataColumn> groupColumns = new ArrayList<IMetadataColumn>();
          for (Map<String, String> denormalize : denormalizes) {
            String columnName = denormalize.get("INPUT_COLUMN");
            if (denormalizeColumns.contains(columnName)) {
              continue;
            }
            denormalizeColumns.add(columnName);
            denormalizeColumnsType.add(typesMap.get(columnName));
            denormalizeDelimiters.add(denormalize.get("DELIMITER"));
            denormalizeMergeFlags.add(("true").equals(denormalize.get("MERGE")));
          }
          for (IMetadataColumn column : columns) {
            String columnName = column.getLabel();
            if (denormalizeColumns.contains(columnName)) {
              continue;
            }
            groupColumns.add(column);
          }

          stringBuffer.append(TEXT_2);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_3);

          if (groupColumns.size() > 0) {

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

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

          for (IMetadataColumn column : groupColumns) {

            stringBuffer.append(TEXT_9);
            stringBuffer.append(column.getLabel());
            stringBuffer.append(TEXT_10);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_11);
            stringBuffer.append(connName);
            stringBuffer.append(TEXT_12);
            stringBuffer.append(column.getLabel());
            stringBuffer.append(TEXT_13);
          }
          for (int i = 0; i < denormalizeColumns.size(); i++) {
            String columnName = denormalizeColumns.get(i);
            String columnType = denormalizeColumnsType.get(i);
            if (denormalizeMergeFlags.get(i)) {

              stringBuffer.append(TEXT_14);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_15);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_16);
              stringBuffer.append(connName);
              stringBuffer.append(TEXT_17);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_18);

            } else {
              if ((("java.util.Date").equals(columnType))
                  && (patternsMap.get(columnName).length() != 0)) {

                stringBuffer.append(TEXT_19);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_20);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_21);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_22);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_23);
                stringBuffer.append(patternsMap.get(columnName));
                stringBuffer.append(TEXT_24);

              } else {

                stringBuffer.append(TEXT_25);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_26);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_27);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_28);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_29);
              }
            }
          }

          stringBuffer.append(TEXT_30);

          if (groupColumns.size() > 0) { // while loop

            stringBuffer.append(TEXT_31);
            for (int i = 0; i < groupColumns.size(); i++) {
              String columnName = groupColumns.get(i).getLabel();
              if (!JavaTypesManager.isJavaPrimitiveType(
                  groupColumns.get(i).getTalendType(), groupColumns.get(i).isNullable())) {

                stringBuffer.append(TEXT_32);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_33);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_34);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_35);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_36);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_37);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_38);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_39);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_40);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_41);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_42);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_43);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_44);
              } else {

                stringBuffer.append(TEXT_45);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_46);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_47);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_48);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_49);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_50);
              }
              if (i + 1 == groupColumns.size()) {

                stringBuffer.append(TEXT_51);
              }
            }

            stringBuffer.append(TEXT_52);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_53);
          } // while loop end

          for (int i = 0; i < denormalizeColumns.size(); i++) {
            String columnName = denormalizeColumns.get(i);
            String columnType = denormalizeColumnsType.get(i);
            if (denormalizeMergeFlags.get(i)) {

              stringBuffer.append(TEXT_54);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_55);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_56);
              stringBuffer.append(connName);
              stringBuffer.append(TEXT_57);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_58);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_59);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_60);
              stringBuffer.append(connName);
              stringBuffer.append(TEXT_61);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_62);

            } else {

              stringBuffer.append(TEXT_63);
              stringBuffer.append(columnName);
              stringBuffer.append(TEXT_64);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_65);
              stringBuffer.append(denormalizeDelimiters.get(i));
              stringBuffer.append(TEXT_66);

              if ((("java.util.Date").equals(columnType))
                  && (patternsMap.get(columnName).length() != 0)) {

                stringBuffer.append(TEXT_67);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_68);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_69);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_70);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_71);
                stringBuffer.append(patternsMap.get(columnName));
                stringBuffer.append(TEXT_72);

              } else {

                stringBuffer.append(TEXT_73);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_74);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_75);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_76);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_77);
              }
            }
          }

          if (groupColumns.size() > 0) {

            stringBuffer.append(TEXT_78);
          }

          stringBuffer.append(TEXT_79);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_80);

          if (groupColumns.size() > 0) {
            // ??

            stringBuffer.append(TEXT_81);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_82);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_83);

            // do out start ...
            conns = null;
            conns = node.getOutgoingSortedConnections();
            if (conns != null) {
              if (conns.size() > 0) {
                IConnection conn = conns.get(0);
                if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
                  for (IMetadataColumn column : groupColumns) {

                    stringBuffer.append(TEXT_84);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_85);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_86);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_87);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_88);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_89);
                  }

                  for (int i = 0; i < denormalizeColumns.size(); i++) {
                    String columnName = denormalizeColumns.get(i);
                    String columnType = denormalizeColumnsType.get(i);
                    if (denormalizeMergeFlags.get(i)) {

                      stringBuffer.append(TEXT_90);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_91);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_92);
                      stringBuffer.append(typesMap.get(columnName));
                      stringBuffer.append(TEXT_93);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_94);
                      stringBuffer.append(columnName);
                      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(denormalizeDelimiters.get(i));
                      stringBuffer.append(TEXT_99);

                      if ((("java.util.Date").equals(columnType))
                          && (patternsMap.get(columnName).length() != 0)) {

                        stringBuffer.append(TEXT_100);
                        stringBuffer.append(cid);
                        stringBuffer.append(TEXT_101);
                        stringBuffer.append(cid);
                        stringBuffer.append(TEXT_102);
                        stringBuffer.append(patternsMap.get(columnName));
                        stringBuffer.append(TEXT_103);

                      } else {

                        stringBuffer.append(TEXT_104);
                        stringBuffer.append(cid);
                        stringBuffer.append(TEXT_105);
                        stringBuffer.append(cid);
                        stringBuffer.append(TEXT_106);
                      }

                      stringBuffer.append(TEXT_107);
                      stringBuffer.append(columnName);
                      stringBuffer.append(TEXT_108);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_109);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_110);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_111);
                      stringBuffer.append(columnName);
                      stringBuffer.append(TEXT_112);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_113);

                    } else {

                      stringBuffer.append(TEXT_114);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_115);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_116);
                      stringBuffer.append(columnName);
                      stringBuffer.append(TEXT_117);
                      stringBuffer.append(columnName);
                      stringBuffer.append(TEXT_118);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_119);
                      stringBuffer.append(columnName);
                      stringBuffer.append(TEXT_120);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_121);
                      stringBuffer.append(columnName);
                      stringBuffer.append(TEXT_122);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_123);
                    }
                  }
                }
              }
            }
            // do out end ...

            // do first
            for (IMetadataColumn column : groupColumns) {

              stringBuffer.append(TEXT_124);
              stringBuffer.append(column.getLabel());
              stringBuffer.append(TEXT_125);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_126);
              stringBuffer.append(connName);
              stringBuffer.append(TEXT_127);
              stringBuffer.append(column.getLabel());
              stringBuffer.append(TEXT_128);
            }
            for (int i = 0; i < denormalizeColumns.size(); i++) {
              String columnName = denormalizeColumns.get(i);
              String columnType = denormalizeColumnsType.get(i);
              if (denormalizeMergeFlags.get(i)) {

                stringBuffer.append(TEXT_129);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_130);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_131);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_132);
                stringBuffer.append(columnName);
                stringBuffer.append(TEXT_133);

              } else {
                if ((("java.util.Date").equals(columnType))
                    && (patternsMap.get(columnName).length() != 0)) {

                  stringBuffer.append(TEXT_134);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_135);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_136);
                  stringBuffer.append(connName);
                  stringBuffer.append(TEXT_137);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_138);
                  stringBuffer.append(patternsMap.get(columnName));
                  stringBuffer.append(TEXT_139);

                } else {

                  stringBuffer.append(TEXT_140);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_141);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_142);
                  stringBuffer.append(connName);
                  stringBuffer.append(TEXT_143);
                  stringBuffer.append(columnName);
                  stringBuffer.append(TEXT_144);
                }
              }
            }

            stringBuffer.append(TEXT_145);
          }
          /////////////////////////////////////////////////

          stringBuffer.append(TEXT_146);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_147);
          stringBuffer.append(rowCount);
          stringBuffer.append(TEXT_148);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_149);

          // do out start ...
          conns = null;
          conns = node.getOutgoingSortedConnections();
          if (conns != null) {
            if (conns.size() > 0) {
              IConnection conn = conns.get(0);
              if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
                for (IMetadataColumn column : groupColumns) {

                  stringBuffer.append(TEXT_150);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_151);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_152);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_153);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_154);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_155);
                }

                for (int i = 0; i < denormalizeColumns.size(); i++) {
                  String columnName = denormalizeColumns.get(i);
                  String columnType = denormalizeColumnsType.get(i);
                  if (denormalizeMergeFlags.get(i)) {

                    stringBuffer.append(TEXT_156);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_157);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_158);
                    stringBuffer.append(typesMap.get(columnName));
                    stringBuffer.append(TEXT_159);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_160);
                    stringBuffer.append(columnName);
                    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(denormalizeDelimiters.get(i));
                    stringBuffer.append(TEXT_165);

                    if ((("java.util.Date").equals(columnType))
                        && (patternsMap.get(columnName).length() != 0)) {

                      stringBuffer.append(TEXT_166);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_167);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_168);
                      stringBuffer.append(patternsMap.get(columnName));
                      stringBuffer.append(TEXT_169);

                    } else {

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

                    stringBuffer.append(TEXT_173);
                    stringBuffer.append(columnName);
                    stringBuffer.append(TEXT_174);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_175);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_176);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_177);
                    stringBuffer.append(columnName);
                    stringBuffer.append(TEXT_178);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_179);

                  } else {

                    stringBuffer.append(TEXT_180);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_181);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_182);
                    stringBuffer.append(columnName);
                    stringBuffer.append(TEXT_183);
                    stringBuffer.append(columnName);
                    stringBuffer.append(TEXT_184);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_185);
                    stringBuffer.append(columnName);
                    stringBuffer.append(TEXT_186);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_187);
                    stringBuffer.append(columnName);
                    stringBuffer.append(TEXT_188);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_189);
                  }
                }
              }
            }
          }
          // do out end ...

          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);

          conns = null;
          conns = node.getOutgoingSortedConnections();
          if (conns != null) {
            for (int i = 0; i < conns.size(); i++) {
              IConnection conn = conns.get(i);
              if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
                for (IMetadataColumn column : metadata.getListColumns()) {

                  stringBuffer.append(conn.getName());
                  stringBuffer.append(TEXT_195);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_196);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_197);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_198);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_199);
                }
              }
            }
          }

          stringBuffer.append(TEXT_200);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_201);
        }
      }
    }

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

    boolean isStaging =
        "STAGING".equalsIgnoreCase(ElementParameterParser.getValue(node, "__CONTAINER_TYPE__"));

    String destination = ElementParameterParser.getValue(node, "__DESTINATION__");
    boolean withReport = ("true").equals(ElementParameterParser.getValue(node, "__WITHREPORT__"));
    String needCheck = ElementParameterParser.getValue(node, "__ISINVOKE__");
    boolean isMassInsert =
        ("true").equals(ElementParameterParser.getValue(node, "__EXTENDINSERT__"));
    String numMassInsert = ElementParameterParser.getValue(node, "__COMMIT_LEVEL__");
    String sourceName = ElementParameterParser.getValue(node, "__SOURCE__");
    boolean dieOnError = ("true").equals(ElementParameterParser.getValue(node, "__DIE_ON_ERROR__"));
    String isUpdate = ElementParameterParser.getValue(node, "__ISUPDATE__");
    List<Map<String, String>> keysReturn =
        (List<Map<String, String>>) ElementParameterParser.getObjectValue(node, "__RETURN_IDS__");

    boolean addTaskID = ("true").equals(ElementParameterParser.getValue(node, "__ADD_TASKID__"));
    boolean isCustom = "true".equals(ElementParameterParser.getValue(node, "__CUSTOM__"));
    String taskID = ElementParameterParser.getValue(node, "__TASKID__");
    String prevColumn = ElementParameterParser.getValue(node, "__PREV_COLUMN_TASK_ID__");

    boolean usePartialUpdate =
        ("true").equals(ElementParameterParser.getValue(node, "__USE_PARTIAL_UPDATE__"));
    boolean usePartialDelete =
        ("true").equals(ElementParameterParser.getValue(node, "__PARTIAL_DELETE__"));
    String pivot = ElementParameterParser.getValue(node, "__PIVOT__");
    boolean overwrite = ("true").equals(ElementParameterParser.getValue(node, "__OVERWRITE__"));
    String key = ElementParameterParser.getValue(node, "__KEY__");
    String position = ElementParameterParser.getValue(node, "__POSITION__");
    String dataModel = ElementParameterParser.getValue(node, "__DATAMODEL__");
    String dataCluster = ElementParameterParser.getValue(node, "__DATACLUSTER__");

    String doc = ElementParameterParser.getValue(node, "__DOCUMENT__");

    List<IMetadataTable> metadatas = node.getMetadataList();

    if (destination != null && !"".equals(destination)) {
      cid = destination;
    }

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

        List<? extends IConnection> outputConns =
            node.getOutgoingConnections(EConnectionType.FLOW_MAIN);
        List<IMetadataColumn> inputColumnList = null;
        List<IMetadataColumn> outputColumnList = null;
        List<IMetadataColumn> columnList = metadata.getListColumns();

        String rejectConnName = null;
        List<? extends IConnection> rejectConns = node.getOutgoingConnections("REJECT");
        List<IMetadataColumn> rejectColumnList = null;
        if (rejectConns != null && rejectConns.size() > 0) {
          IConnection rejectConn = rejectConns.get(0);
          if (rejectConn != null) {
            rejectConnName = rejectConn.getName();
            IMetadataTable metadataTable = rejectConn.getMetadataTable();
            if (metadataTable != null) {
              rejectColumnList = metadataTable.getListColumns();
            }
          }
        }

        String outConnName = null;
        String inputConnName = null;
        List<? extends IConnection> outgoingConns = node.getOutgoingSortedConnections();

        for (IConnection tmpconn : outgoingConns) {
          if (tmpconn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
            if (rejectConnName == null || !rejectConnName.equals(tmpconn.getName())) {
              outConnName = tmpconn.getName();
              IMetadataTable outputMetadata = tmpconn.getMetadataTable();
              if (outputMetadata != null) {
                outputColumnList = outputMetadata.getListColumns();
              }
            }
            stringBuffer.append(TEXT_1);
            stringBuffer.append(tmpconn.getName());
            stringBuffer.append(TEXT_2);
          }
        }

        List<? extends IConnection> inputConns = node.getIncomingConnections();
        if (inputConns != null && inputConns.size() > 0) {
          IConnection inputConn = inputConns.get(0);
          if (inputConn != null) {
            inputConnName = inputConn.getName();
            IMetadataTable inputMetadata = inputConn.getMetadataTable();
            if (inputMetadata != null) {
              inputColumnList = inputMetadata.getListColumns();
            }
          }
        }

        if (outConnName != null && inputConnName != null) {

          stringBuffer.append(TEXT_3);
          stringBuffer.append(outConnName);
          stringBuffer.append(TEXT_4);
          stringBuffer.append(outConnName);
          stringBuffer.append(TEXT_5);

          for (IMetadataColumn outputColumn : outputColumnList) {
            for (IMetadataColumn inputColumn : inputColumnList) {
              if (outputColumn.getLabel().equals(inputColumn.getLabel())) {
                if (doc != null && doc.equals(outputColumn.getLabel())) {
                  if ("id_Document".equals(outputColumn.getTalendType())) {

                    stringBuffer.append(TEXT_6);
                    stringBuffer.append(outConnName);
                    stringBuffer.append(TEXT_7);
                    stringBuffer.append(doc);
                    stringBuffer.append(TEXT_8);
                    stringBuffer.append(inputConnName);
                    stringBuffer.append(TEXT_9);
                    stringBuffer.append(doc);
                    stringBuffer.append(TEXT_10);

                  } else {

                    stringBuffer.append(TEXT_11);
                    stringBuffer.append(outConnName);
                    stringBuffer.append(TEXT_12);
                    stringBuffer.append(doc);
                    stringBuffer.append(TEXT_13);
                    stringBuffer.append(inputConnName);
                    stringBuffer.append(TEXT_14);
                    stringBuffer.append(doc);
                    stringBuffer.append(TEXT_15);
                  }
                } else { // to those which do not match doc columns

                  stringBuffer.append(TEXT_16);
                  stringBuffer.append(outConnName);
                  stringBuffer.append(TEXT_17);
                  stringBuffer.append(outputColumn.getLabel());
                  stringBuffer.append(TEXT_18);
                  stringBuffer.append(inputConnName);
                  stringBuffer.append(TEXT_19);
                  stringBuffer.append(inputColumn.getLabel());
                  stringBuffer.append(TEXT_20);
                }
              } // if input column matches output column
            } // for input column
          } // for output column
        }
        stringBuffer.append(TEXT_21);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_22);
        stringBuffer.append(inputConnName);
        stringBuffer.append(TEXT_23);
        stringBuffer.append(doc);
        stringBuffer.append(TEXT_24);
        if (usePartialUpdate) { // partial

          String dataclusterString = "";
          if (isStaging) {
            dataclusterString = dataCluster + " + \"#STAGING\"";
          } else {
            dataclusterString = dataCluster;
          }

          stringBuffer.append(TEXT_25);
          stringBuffer.append(usePartialDelete);
          stringBuffer.append(TEXT_26);
          stringBuffer.append(position.equals("") ? null : position);
          stringBuffer.append(TEXT_27);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_28);
          stringBuffer.append(dataclusterString);
          stringBuffer.append(TEXT_29);
          stringBuffer.append(dataModel);
          stringBuffer.append(TEXT_30);
          stringBuffer.append(usePartialDelete);
          stringBuffer.append(TEXT_31);
          stringBuffer.append(key.equals("") ? null : key);
          stringBuffer.append(TEXT_32);
          stringBuffer.append(overwrite);
          stringBuffer.append(TEXT_33);
          stringBuffer.append(pivot);
          stringBuffer.append(TEXT_34);
          stringBuffer.append(true == isStaging ? false : withReport);
          stringBuffer.append(TEXT_35);
          stringBuffer.append(sourceName);
          stringBuffer.append(TEXT_36);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_37);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_38);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_39);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_40);

          if (outConnName != null && !isMassInsert && keysReturn.size() > 0) {
            for (int i = 0; i < keysReturn.size(); i++) {
              Map<String, String> map = keysReturn.get(i);

              stringBuffer.append(TEXT_41);
              stringBuffer.append(outConnName);
              stringBuffer.append(TEXT_42);
              stringBuffer.append(map.get("OUTPUT_COLUMN"));
              stringBuffer.append(TEXT_43);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_44);
              stringBuffer.append(i);
              stringBuffer.append(TEXT_45);
            }
          }

          stringBuffer.append(TEXT_46);
        } else { // not partial
          stringBuffer.append(TEXT_47);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_48);
          stringBuffer.append(isUpdate);
          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);

          if (!isStaging && withReport) {
            stringBuffer.append(TEXT_53);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_54);
            stringBuffer.append(needCheck);
            stringBuffer.append(TEXT_55);
            stringBuffer.append(sourceName);
            stringBuffer.append(TEXT_56);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_57);
            if (isMassInsert) {
              stringBuffer.append(TEXT_58);
              if (addTaskID) {
                stringBuffer.append(TEXT_59);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_60);
                stringBuffer.append(isCustom ? taskID : inputConnName + "." + prevColumn);
                stringBuffer.append(TEXT_61);
              }
              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(numMassInsert);
              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);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_70);
              if (addTaskID) {
                stringBuffer.append(TEXT_71);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_72);
                stringBuffer.append(cid);
                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);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_77);
                stringBuffer.append(cid);
                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(TEXT_84);
            } else {
              stringBuffer.append(TEXT_85);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_86);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_87);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_88);
              if (addTaskID) {
                stringBuffer.append(TEXT_89);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_90);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_91);
                stringBuffer.append(isCustom ? taskID : inputConnName + "." + prevColumn);
                stringBuffer.append(TEXT_92);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_93);
              }
              stringBuffer.append(TEXT_94);
            }

            if (outConnName != null && !isMassInsert && keysReturn.size() > 0) {

              for (int i = 0; i < keysReturn.size(); i++) {
                Map<String, String> map = keysReturn.get(i);

                stringBuffer.append(TEXT_95);
                stringBuffer.append(outConnName);
                stringBuffer.append(TEXT_96);
                stringBuffer.append(map.get("OUTPUT_COLUMN"));
                stringBuffer.append(TEXT_97);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_98);
                stringBuffer.append(i);
                stringBuffer.append(TEXT_99);
              }
            }
          } else {

            if (isMassInsert) {

              stringBuffer.append(TEXT_100);
              if (addTaskID) {
                stringBuffer.append(TEXT_101);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_102);
                stringBuffer.append(isCustom ? taskID : inputConnName + "." + prevColumn);
                stringBuffer.append(TEXT_103);
              }
              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(numMassInsert);
              stringBuffer.append(TEXT_108);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_109);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_110);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_111);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_112);
              if (addTaskID) {
                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);
                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(TEXT_126);

            } else {
              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);
              if (addTaskID) {
                stringBuffer.append(TEXT_131);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_132);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_133);
                stringBuffer.append(isCustom ? taskID : inputConnName + "." + prevColumn);
                stringBuffer.append(TEXT_134);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_135);
              }
              stringBuffer.append(TEXT_136);

              if (outConnName != null && !isMassInsert && keysReturn.size() > 0) {
                for (int i = 0; i < keysReturn.size(); i++) {
                  Map<String, String> map = keysReturn.get(i);

                  stringBuffer.append(TEXT_137);
                  stringBuffer.append(outConnName);
                  stringBuffer.append(TEXT_138);
                  stringBuffer.append(map.get("OUTPUT_COLUMN"));
                  stringBuffer.append(TEXT_139);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_140);
                  stringBuffer.append(i);
                  stringBuffer.append(TEXT_141);
                }
              }
            }
          }

          stringBuffer.append(TEXT_142);
        } // end partial
        stringBuffer.append(TEXT_143);
        if (dieOnError) {
          stringBuffer.append(TEXT_144);
        } else {

          if (rejectConnName != null) {
            if (outConnName != null) {
              stringBuffer.append(TEXT_145);
              stringBuffer.append(outConnName);
              stringBuffer.append(TEXT_146);
            }
            stringBuffer.append(TEXT_147);
            stringBuffer.append(rejectConnName);
            stringBuffer.append(TEXT_148);
            stringBuffer.append(rejectConnName);
            stringBuffer.append(TEXT_149);

            for (IMetadataColumn column : columnList) {
              if (!"xml".equals(column.getLabel())
                  && !"errorCode".equals(column.getLabel())
                  && !"errorMessage".equals(column.getLabel())) {
                if (column.getLabel().equals(doc) && "id_String".equals(column.getTalendType())) {

                  stringBuffer.append(TEXT_150);
                  stringBuffer.append(rejectConnName);
                  stringBuffer.append(TEXT_151);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_152);
                  stringBuffer.append(inputConnName);
                  stringBuffer.append(TEXT_153);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_154);

                } else {

                  stringBuffer.append(TEXT_155);
                  stringBuffer.append(rejectConnName);
                  stringBuffer.append(TEXT_156);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_157);
                  stringBuffer.append(inputConnName);
                  stringBuffer.append(TEXT_158);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_159);
                }
              }
              if ("xml".equals(column.getLabel())) {
                if ("id_String".equals(column.getTalendType())) {

                  stringBuffer.append(TEXT_160);
                  stringBuffer.append(rejectConnName);
                  stringBuffer.append(TEXT_161);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_162);

                } else {

                  stringBuffer.append(TEXT_163);
                  stringBuffer.append(rejectConnName);
                  stringBuffer.append(TEXT_164);
                  stringBuffer.append(inputConnName);
                  stringBuffer.append(TEXT_165);
                }
              }
            }

            stringBuffer.append(TEXT_166);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_167);
            stringBuffer.append(TEXT_168);
            stringBuffer.append(rejectConnName);
            stringBuffer.append(TEXT_169);
            stringBuffer.append(node.getUniqueName());
            stringBuffer.append(TEXT_170);
          } else {
            stringBuffer.append(TEXT_171);
          }
        }
        stringBuffer.append(TEXT_172);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_173);
      }
    }
    stringBuffer.append(TEXT_174);
    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 incomingName = (String) codeGenArgument.getIncomingName();
    String customSetOriginalLengthStr = ElementParameterParser.getValue(node, "__NO_X2CJ_FILE__");
    String encoding = ElementParameterParser.getValue(node, "__ENCODING__");
    boolean customSetOriginalLength =
        (customSetOriginalLengthStr != null && !("").equals(customSetOriginalLengthStr))
            ? ("true").equals(customSetOriginalLengthStr)
            : true;
    if (!customSetOriginalLength) { // ------11111
      List<? extends IConnection> conns = node.getIncomingConnections();
      List<IMetadataTable> preMetadatas = null;

      for (int i = 0; i < conns.size(); i++) {
        IConnection conn = conns.get(i);
        if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
          if (conn.getName() == incomingName) {
            preMetadatas = conn.getSource().getMetadataList();

            stringBuffer.append(TEXT_1);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_2);

            for (IMetadataColumn column : preMetadatas.get(0).getListColumns()) {

              stringBuffer.append(TEXT_3);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_4);
              stringBuffer.append(conn.getName());
              stringBuffer.append(TEXT_5);
              stringBuffer.append(column.getLabel());
              stringBuffer.append(TEXT_6);
            }

            stringBuffer.append(TEXT_7);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_8);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_9);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_10);
          }
        }
      }
    } else { // ------1111
      List<IMetadataTable> metadatas = node.getMetadataList();
      if ((metadatas != null) && (metadatas.size() > 0)) { // ------2222
        List<? extends IConnection> conns = node.getIncomingConnections();
        for (IConnection conn : conns) { // ------3333
          if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) { // ------4444
            if (conn.getName() == incomingName) { // ------5555
              IMetadataTable metadata = metadatas.get(0);
              List<IMetadataColumn> columns = metadata.getListColumns();
              List<IMetadataColumn> extColumns = new java.util.ArrayList<IMetadataColumn>();
              for (IMetadataColumn tempColumn : columns) {
                extColumns.add(tempColumn);
              }
              List<IMetadataColumn> inColumns = conn.getMetadataTable().getListColumns();
              for (IMetadataColumn inColumn : inColumns) { // ------6666
                IMetadataColumn column = null;
                for (int j = 0;
                    j < extColumns.size();
                    j++) { // search the corresponding metadata column for the input column
                  if (inColumn.getLabel().equals(extColumns.get(j).getLabel())) {
                    column = extColumns.remove(j);
                    break;
                  }
                }
                // if not find, then the first one of the metadata columns is used to correspond the
                // input column
                if (column == null && !extColumns.isEmpty()) {
                  column = extColumns.remove(0);
                }
                if (column != null) { // ------77777
                  Integer orgainLength = column.getOriginalLength();
                  Integer length = column.getLength();
                  String orgainType = column.getType();
                  Integer precision = column.getPrecision();
                  if (precision == null) precision = 0;
                  if (orgainLength == null
                      || orgainLength.intValue() == 0
                      || orgainType == null
                      || "".endsWith(orgainType.trim())) {

                    stringBuffer.append(TEXT_11);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_12);

                    continue;
                  }

                  stringBuffer.append(TEXT_13);
                  stringBuffer.append(column.getLabel());
                  stringBuffer.append(TEXT_14);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_15);
                  stringBuffer.append(orgainLength);
                  stringBuffer.append(TEXT_16);

                  if (orgainType.equals("X")) {

                    stringBuffer.append(TEXT_17);
                    stringBuffer.append(length);
                    stringBuffer.append(TEXT_18);
                    stringBuffer.append(conn.getName());
                    stringBuffer.append(TEXT_19);
                    stringBuffer.append(inColumn.getLabel());
                    stringBuffer.append(TEXT_20);
                    stringBuffer.append(length);
                    stringBuffer.append(TEXT_21);
                    stringBuffer.append(conn.getName());
                    stringBuffer.append(TEXT_22);
                    stringBuffer.append(inColumn.getLabel());
                    stringBuffer.append(TEXT_23);
                    stringBuffer.append(conn.getName());
                    stringBuffer.append(TEXT_24);
                    stringBuffer.append(inColumn.getLabel());
                    stringBuffer.append(TEXT_25);
                    stringBuffer.append(conn.getName());
                    stringBuffer.append(TEXT_26);
                    stringBuffer.append(inColumn.getLabel());
                    stringBuffer.append(TEXT_27);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_28);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_29);
                    stringBuffer.append(conn.getName());
                    stringBuffer.append(TEXT_30);
                    stringBuffer.append(inColumn.getLabel());
                    stringBuffer.append(TEXT_31);
                    stringBuffer.append(encoding);
                    stringBuffer.append(TEXT_32);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_33);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_34);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_35);

                  } else if (orgainType.equals("3") || orgainType.equals("9")) {
                    String isImpliedDecimalStr = column.getAdditionalField().get("ImpliedDecimal");
                    boolean isImpliedDecimal =
                        (isImpliedDecimalStr != null && !("").equals(isImpliedDecimalStr))
                            ? ("true").equals(isImpliedDecimalStr)
                            : true;
                    String isSignedStr = column.getAdditionalField().get("Signed");
                    boolean isSigned =
                        (isSignedStr != null && !("").equals(isSignedStr))
                            ? ("true").equals(isSignedStr)
                            : true;
                    if (orgainType.equals("3")) {

                      stringBuffer.append(TEXT_36);
                      stringBuffer.append(column.getLabel());
                      stringBuffer.append(TEXT_37);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_38);
                      stringBuffer.append(conn.getName());
                      stringBuffer.append(TEXT_39);
                      stringBuffer.append(inColumn.getLabel());
                      stringBuffer.append(TEXT_40);
                      stringBuffer.append(column.getLabel());
                      stringBuffer.append(TEXT_41);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_42);
                      stringBuffer.append(orgainLength);
                      stringBuffer.append(TEXT_43);
                      stringBuffer.append(precision);
                      stringBuffer.append(TEXT_44);
                      stringBuffer.append(column.getLabel());
                      stringBuffer.append(TEXT_45);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_46);
                      stringBuffer.append(isSigned);
                      stringBuffer.append(TEXT_47);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_48);
                      stringBuffer.append(column.getLabel());
                      stringBuffer.append(TEXT_49);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_50);

                    } else {

                      stringBuffer.append(TEXT_51);
                      stringBuffer.append(column.getLabel());
                      stringBuffer.append(TEXT_52);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_53);
                      stringBuffer.append(conn.getName());
                      stringBuffer.append(TEXT_54);
                      stringBuffer.append(inColumn.getLabel());
                      stringBuffer.append(TEXT_55);
                      stringBuffer.append(column.getLabel());
                      stringBuffer.append(TEXT_56);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_57);
                      stringBuffer.append(length);
                      stringBuffer.append(TEXT_58);
                      stringBuffer.append(precision);
                      stringBuffer.append(TEXT_59);
                      stringBuffer.append(column.getLabel());
                      stringBuffer.append(TEXT_60);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_61);
                      stringBuffer.append(isSigned);
                      stringBuffer.append(TEXT_62);
                      stringBuffer.append(isImpliedDecimal);
                      stringBuffer.append(TEXT_63);
                      stringBuffer.append(encoding);
                      stringBuffer.append(TEXT_64);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_65);
                      stringBuffer.append(column.getLabel());
                      stringBuffer.append(TEXT_66);
                      stringBuffer.append(cid);
                      stringBuffer.append(TEXT_67);
                    }
                  } else if (orgainType.equals("B")) {
                    String isSignedStr = column.getAdditionalField().get("Signed");

                    stringBuffer.append(TEXT_68);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_69);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_70);
                    stringBuffer.append(conn.getName());
                    stringBuffer.append(TEXT_71);
                    stringBuffer.append(inColumn.getLabel());
                    stringBuffer.append(TEXT_72);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_73);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_74);
                    stringBuffer.append(orgainLength);
                    stringBuffer.append(TEXT_75);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_76);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_77);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_78);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_79);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_80);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_81);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_82);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_83);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_84);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_85);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_86);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_87);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_88);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_89);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_90);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_91);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_92);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_93);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_94);

                  } else if (orgainType.equals("T")) {

                    stringBuffer.append(TEXT_95);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_96);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_97);
                    stringBuffer.append(conn.getName());
                    stringBuffer.append(TEXT_98);
                    stringBuffer.append(inColumn.getLabel());
                    stringBuffer.append(TEXT_99);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_100);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_101);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_102);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_103);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_104);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_105);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_106);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_107);
                    stringBuffer.append(cid);
                    stringBuffer.append(TEXT_108);

                  } else {

                    stringBuffer.append(TEXT_109);
                    stringBuffer.append(column.getLabel());
                    stringBuffer.append(TEXT_110);
                  }

                  stringBuffer.append(TEXT_111);
                  stringBuffer.append(cid);
                  stringBuffer.append(TEXT_112);
                } // -----77777
              } // ------66666
            } // ------5555
          } // ------4444
        } // ------3333
      } // ------2222
    } // ------1111

    stringBuffer.append(TEXT_113);
    return stringBuffer.toString();
  }
示例#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 endpoint = ElementParameterParser.getValue(node, "__ENDPOINT__");
    String action = ElementParameterParser.getValue(node, "__ACTION__");
    String soapMessageStr = ElementParameterParser.getValue(node, "__SOAPMESSAGE__");
    soapMessageStr = soapMessageStr.replaceAll("[\r\n]", " ");

    String soapVersion = ElementParameterParser.getValue(node, "__SOAP_VERSION__");

    boolean useKerberos =
        ("true").equals(ElementParameterParser.getValue(node, "__USE_KERBEROS__"));
    String kerberosConfiguration =
        ElementParameterParser.getValue(node, "__KERBEROS_CONFIGURATION__");
    boolean useMessageFromSchema =
        "true".equals(ElementParameterParser.getValue(node, "__USE_MESSAGE_FROM_SCHEMA__"));
    boolean outputDocument =
        "true".equals(ElementParameterParser.getValue(node, "__OUTPUT_DOCUMENT__"));
    String soapMessageColumn = ElementParameterParser.getValue(node, "__SOAPMESSAGE_FROM_SCHEMA__");
    String connName = null;
    boolean schemaEmpty = false;
    if (node.getIncomingConnections().size() > 0) {
      IConnection conn = node.getIncomingConnections().get(0);
      if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
        connName = conn.getName();
        schemaEmpty = conn.getMetadataTable().getListColumns().size() == 0;
      }
    }
    if (useMessageFromSchema && (connName == null || schemaEmpty)) {

      stringBuffer.append(TEXT_2);

    } else {
      if (useKerberos) {

        stringBuffer.append(TEXT_3);

        if (useMessageFromSchema) {

          stringBuffer.append(TEXT_4);
          stringBuffer.append(connName);
          stringBuffer.append(TEXT_5);
          stringBuffer.append(connName);
          stringBuffer.append(TEXT_6);
          stringBuffer.append(connName);
          stringBuffer.append(TEXT_7);
          stringBuffer.append(connName);
          stringBuffer.append(TEXT_8);

        } else {

          stringBuffer.append(TEXT_9);
        }
        if (outputDocument) {

          stringBuffer.append(TEXT_10);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_11);
          stringBuffer.append(soapVersion.toUpperCase());
          stringBuffer.append(TEXT_12);
          stringBuffer.append(endpoint);
          stringBuffer.append(TEXT_13);
          stringBuffer.append(action);
          stringBuffer.append(TEXT_14);
          stringBuffer.append(
              useMessageFromSchema
                  ? connName + "." + soapMessageColumn + ".toString()"
                  : soapMessageStr);
          stringBuffer.append(TEXT_15);

        } else {

          stringBuffer.append(TEXT_16);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_17);
          stringBuffer.append(soapVersion.toUpperCase());
          stringBuffer.append(TEXT_18);
          stringBuffer.append(endpoint);
          stringBuffer.append(TEXT_19);
          stringBuffer.append(action);
          stringBuffer.append(TEXT_20);
          stringBuffer.append(
              useMessageFromSchema
                  ? connName + "." + soapMessageColumn + ".toString()"
                  : soapMessageStr);
          stringBuffer.append(TEXT_21);
        }

        stringBuffer.append(TEXT_22);
        if ("Soap12".equals(soapVersion)) {
          stringBuffer.append(TEXT_23);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_24);
        } else {
          stringBuffer.append(TEXT_25);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_26);
        }
        stringBuffer.append(TEXT_27);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_28);
        stringBuffer.append(kerberosConfiguration);
        stringBuffer.append(TEXT_29);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_30);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_31);
        stringBuffer.append(useMessageFromSchema ? connName + ", " : "");
        stringBuffer.append(TEXT_32);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_33);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_34);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_35);

        if (outputDocument) {

          stringBuffer.append(TEXT_36);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_37);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_38);
        }

        stringBuffer.append(TEXT_39);

      } else {
        if (outputDocument) {

          stringBuffer.append(TEXT_40);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_41);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_42);
          stringBuffer.append(soapVersion.toUpperCase());
          stringBuffer.append(TEXT_43);
          stringBuffer.append(endpoint);
          stringBuffer.append(TEXT_44);
          stringBuffer.append(action);
          stringBuffer.append(TEXT_45);
          stringBuffer.append(
              useMessageFromSchema
                  ? connName + "." + soapMessageColumn + ".toString()"
                  : soapMessageStr);
          stringBuffer.append(TEXT_46);

        } else {

          stringBuffer.append(TEXT_47);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_48);
          stringBuffer.append(soapVersion.toUpperCase());
          stringBuffer.append(TEXT_49);
          stringBuffer.append(endpoint);
          stringBuffer.append(TEXT_50);
          stringBuffer.append(action);
          stringBuffer.append(TEXT_51);
          stringBuffer.append(
              useMessageFromSchema
                  ? connName + "." + soapMessageColumn + ".toString()"
                  : soapMessageStr);
          stringBuffer.append(TEXT_52);
        }
      }

      stringBuffer.append(TEXT_53);

      List<? extends IConnection> conns = node.getOutgoingSortedConnections();
      if (conns != null) { // 1
        if (conns.size() > 0) { // 2
          IConnection conn = conns.get(0); // the first connection
          if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) { // 3

            stringBuffer.append(TEXT_54);
            stringBuffer.append(conn.getName());
            stringBuffer.append(TEXT_55);
            stringBuffer.append(conn.getName());
            stringBuffer.append(TEXT_56);
            if (outputDocument) {
              stringBuffer.append(TEXT_57);
              stringBuffer.append(conn.getName());
              stringBuffer.append(TEXT_58);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_59);
            } else {
              stringBuffer.append(TEXT_60);
              stringBuffer.append(conn.getName());
              stringBuffer.append(TEXT_61);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_62);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_63);
              stringBuffer.append(conn.getName());
              stringBuffer.append(TEXT_64);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_65);
              stringBuffer.append(conn.getName());
              stringBuffer.append(TEXT_66);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_67);
            }
          } // 3
        } // 2
      } // 1
    } // if (!useMessageFromSchema || connName!=null) {

    stringBuffer.append(TEXT_68);
    stringBuffer.append(TEXT_69);
    return stringBuffer.toString();
  }