public void createURL(INode node) {
        super.createURL(node);
        String driverJar = ElementParameterParser.getValue(node, "__DRIVER_JAR__");
        String jdbcUrl = ElementParameterParser.getValue(node, "__URL__");

        stringBuffer.append(TEXT_21);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_22);
        stringBuffer.append(jdbcUrl);
        stringBuffer.append(TEXT_23);
      }
      public void createURL(INode node) {
        super.createURL(node);

        stringBuffer.append(TEXT_22);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_23);
        stringBuffer.append(dbhost);
        stringBuffer.append(TEXT_24);
        stringBuffer.append(dbname);
        stringBuffer.append(TEXT_25);
      }
      public void createConnection(INode node) {
        String connectionMode = ElementParameterParser.getValue(node, "__CONNECTION_MODE__");
        String hiveVersion = ElementParameterParser.getValue(node, "__HIVE_VERSION__");
        String hiveServer = ElementParameterParser.getValue(node, "__HIVE_SERVER__");
        boolean isCustom =
            "CUSTOM".equals(ElementParameterParser.getValue(node, "__DISTRIBUTION__"));

        boolean useKrb = "true".equals(ElementParameterParser.getValue(node, "__USE_KRB__"));
        boolean cdh4CanBeSecured =
            "Cloudera_CDH4".equals(hiveVersion)
                && (("HIVE".equalsIgnoreCase(hiveServer)
                        && "EMBEDDED".equalsIgnoreCase(connectionMode))
                    || "HIVE2".equalsIgnoreCase(hiveServer));
        boolean securityIsEnabled =
            useKrb
                && (isCustom
                    || ("HDP_1_0".equals(hiveVersion)
                        || "HDP_1_2".equals(hiveVersion)
                        || "HDP_1_3".equals(hiveVersion)
                        || cdh4CanBeSecured));
        boolean securedStandaloneHive2 =
            securityIsEnabled
                && "HIVE2".equalsIgnoreCase(hiveServer)
                && "STANDALONE".equalsIgnoreCase(connectionMode);
        if (securedStandaloneHive2) {

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

        } else {
          super.createConnection(node);
        }
      }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

    class DefaultConnectionUtil {

      protected String cid;
      protected String dbproperties;
      protected String dbhost;
      protected String dbport;
      protected String dbname;

      public void beforeComponentProcess(INode node) {}

      public void createURL(INode node) {
        cid = node.getUniqueName();
        dbproperties = ElementParameterParser.getValue(node, "__PROPERTIES__");
        dbhost = ElementParameterParser.getValue(node, "__HOST__");
        dbport = ElementParameterParser.getValue(node, "__PORT__");
        dbname = ElementParameterParser.getValue(node, "__DBNAME__");
      }

      public String getDirverClassName(INode node) {
        return "";
      }

      public void classForName(INode node) {

        stringBuffer.append(TEXT_2);
        stringBuffer.append(this.getDirverClassName(node));
        stringBuffer.append(TEXT_3);
      }

      public void useShareConnection(INode node) {
        String sharedConnectionName =
            ElementParameterParser.getValue(node, "__SHARED_CONNECTION_NAME__");

        stringBuffer.append(TEXT_4);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_5);
        stringBuffer.append(sharedConnectionName);
        stringBuffer.append(TEXT_6);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_7);
        stringBuffer.append(this.getDirverClassName(node));
        stringBuffer.append(TEXT_8);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_9);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_10);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_11);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_12);
      }

      public void createConnection(INode node) {

        stringBuffer.append(TEXT_13);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_14);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_15);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_16);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_17);
      }

      public void setAutoCommit(INode node) {
        boolean setAutoCommit =
            "true".equals(ElementParameterParser.getValue(node, "__AUTO_COMMIT__"));

        stringBuffer.append(TEXT_18);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_19);
        stringBuffer.append(setAutoCommit);
        stringBuffer.append(TEXT_20);
      }

      public void afterComponentProcess(INode node) {}
    } // end DefaultUtil class

    DefaultConnectionUtil connUtil = new DefaultConnectionUtil();

    class ConnectionUtil extends DefaultConnectionUtil {

      String driverJar;

      public void beforeComponentProcess(INode node) {
        driverJar = ElementParameterParser.getValue(node, "__DRIVER_JAR__");
      }

      public void createURL(INode node) {
        super.createURL(node);
        String driverJar = ElementParameterParser.getValue(node, "__DRIVER_JAR__");
        String jdbcUrl = ElementParameterParser.getValue(node, "__URL__");

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

      public String getDirverClassName(INode node) {
        String dirverClass = ElementParameterParser.getValue(node, "__DRIVER_CLASS__");
        return dirverClass;
      }

      public void classForName(INode node) {

        stringBuffer.append(TEXT_24);
        stringBuffer.append(this.getDirverClassName(node));
        stringBuffer.append(TEXT_25);
      }

      public void useShareConnection(INode node) {
        String sharedConnectionName =
            ElementParameterParser.getValue(node, "__SHARED_CONNECTION_NAME__");

        stringBuffer.append(TEXT_26);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_27);
        stringBuffer.append(sharedConnectionName);
        stringBuffer.append(TEXT_28);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_29);
        stringBuffer.append(this.getDirverClassName(node));
        stringBuffer.append(TEXT_30);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_31);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_32);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_33);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_34);
      }

      public void setAutoCommit(INode node) {
        boolean useTransaction =
            ("true").equals(ElementParameterParser.getValue(node, "__IS_USE_AUTO_COMMIT__"));
        boolean setAutoCommit =
            "true".equals(ElementParameterParser.getValue(node, "__AUTO_COMMIT__"));
        if (useTransaction) {

          stringBuffer.append(TEXT_35);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_36);
          stringBuffer.append(setAutoCommit);
          stringBuffer.append(TEXT_37);
        }
      }
    } // end class
    connUtil = new ConnectionUtil();

    // ----------------------------component codes-----------------------------------------
    stringBuffer.append(TEXT_38);

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

    String cid = node.getUniqueName();
    String dbhost = ElementParameterParser.getValue(node, "__HOST__");
    String dbport = ElementParameterParser.getValue(node, "__PORT__");
    String dbschema = ElementParameterParser.getValue(node, "__DB_SCHEMA__");
    if (dbschema == null || dbschema.trim().length() == 0) {
      dbschema = ElementParameterParser.getValue(node, "__SCHEMA_DB__");
    }
    String dbname = ElementParameterParser.getValue(node, "__DBNAME__");
    String dbuser = ElementParameterParser.getValue(node, "__USER__");
    String dbpass = ElementParameterParser.getValue(node, "__PASS__");
    String encoding = ElementParameterParser.getValue(node, "__ENCODING__");

    boolean isUseSharedConnection =
        ("true").equals(ElementParameterParser.getValue(node, "__USE_SHARED_CONNECTION__"));

    connUtil.beforeComponentProcess(node);

    connUtil.createURL(node);

    stringBuffer.append(TEXT_39);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_40);
    stringBuffer.append((dbuser != null && dbuser.trim().length() == 0) ? "null" : dbuser);
    stringBuffer.append(TEXT_41);
    // the tSQLiteConnection component not contain user and pass return null
    stringBuffer.append(TEXT_42);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_43);
    stringBuffer.append((dbpass != null && dbpass.trim().length() == 0) ? "null" : dbpass);
    stringBuffer.append(TEXT_44);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_45);

    if (isUseSharedConnection) {

      stringBuffer.append(TEXT_46);
      connUtil.useShareConnection(node);

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

        stringBuffer.append(TEXT_47);
        stringBuffer.append((null != alias && !("".equals(alias))) ? alias : "\"\"");
        stringBuffer.append(TEXT_48);
      }

      stringBuffer.append(TEXT_49);
      connUtil.classForName(node);
      stringBuffer.append(TEXT_50);
      connUtil.createConnection(node);
      stringBuffer.append(TEXT_51);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_52);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_53);

      if (specify_alias) {

        stringBuffer.append(TEXT_54);
      }
    }

    stringBuffer.append(TEXT_55);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_56);
    connUtil.setAutoCommit(node);
    stringBuffer.append(TEXT_57);

    connUtil.afterComponentProcess(node);

    stringBuffer.append(TEXT_58);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_59);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_60);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_61);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_62);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_63);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_64);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_65);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_66);
    stringBuffer.append(TEXT_67);
    return stringBuffer.toString();
  }
      public void createURL(INode node) {
        super.createURL(node);
        String connectionMode = ElementParameterParser.getValue(node, "__CONNECTION_MODE__");
        String hiveVersion = ElementParameterParser.getValue(node, "__HIVE_VERSION__");
        String fsDefalutName = "fs.default.name";
        String hiveServer = ElementParameterParser.getValue(node, "__HIVE_SERVER__");

        boolean setMapredJT =
            "true".equals(ElementParameterParser.getValue(node, "__SET_MAPRED_JT__"));
        boolean setNamenode =
            "true".equals(ElementParameterParser.getValue(node, "__SET_FS_DEFAULT_NAME__"));
        List<Map<String, String>> hadoopProps =
            (List<Map<String, String>>)
                ElementParameterParser.getObjectValue(node, "__HADOOP_ADVANCED_PROPERTIES__");

        boolean isCustom =
            "CUSTOM".equals(ElementParameterParser.getValue(node, "__DISTRIBUTION__"));
        boolean useYarn = "true".equals(ElementParameterParser.getValue(node, "__USE_YARN__"));

        boolean useKrb = "true".equals(ElementParameterParser.getValue(node, "__USE_KRB__"));
        boolean cdh4CanBeSecured =
            "Cloudera_CDH4".equals(hiveVersion)
                && (("HIVE".equalsIgnoreCase(hiveServer)
                        && "EMBEDDED".equalsIgnoreCase(connectionMode))
                    || "HIVE2".equalsIgnoreCase(hiveServer));

        boolean securityIsEnabled =
            useKrb
                && (isCustom
                    || ("HDP_1_0".equals(hiveVersion)
                        || "HDP_1_2".equals(hiveVersion)
                        || "HDP_1_3".equals(hiveVersion)
                        || cdh4CanBeSecured));
        boolean securedStandaloneHive2 =
            securityIsEnabled
                && "HIVE2".equalsIgnoreCase(hiveServer)
                && "STANDALONE".equalsIgnoreCase(connectionMode);
        boolean securedEmbedded = securityIsEnabled && "EMBEDDED".equalsIgnoreCase(connectionMode);
        String hivePrincipal = ElementParameterParser.getValue(node, "__HIVE_PRINCIPAL__");

        if (hiveServer != null
            && !"".equals(hiveServer.trim())
            && (isCustom
                || ("HDP_1_2".equals(hiveVersion)
                    || "HDP_1_3".equals(hiveVersion)
                    || "Cloudera_CDH4".equals(hiveVersion)
                    || "Cloudera_CDH4_YARN".equals(hiveVersion)
                    || "MAPR213".equals(hiveVersion)
                    || "MAPR301".equals(hiveVersion)
                    || "HDP_2_0".equals(hiveVersion)))) {
          hiveServer = hiveServer.toLowerCase();
          if ("hive2".equals(hiveServer)) {
            javaDbDriver = "org.apache.hive.jdbc.HiveDriver";
          }
        } else {
          hiveServer = "hive";
        }
        if (!isCustom
            && (("HDP_1_0".equals(hiveVersion) && "STANDALONE".equals(connectionMode))
                || ("HDP_1_2".equals(hiveVersion)
                    && "STANDALONE".equals(connectionMode)
                    && "HIVE".equalsIgnoreCase(hiveServer))
                || ("HDP_1_3".equals(hiveVersion)
                    && "STANDALONE".equals(connectionMode)
                    && "HIVE".equalsIgnoreCase(hiveServer))
                || ("HDP_2_0".equals(hiveVersion)
                    && "STANDALONE".equals(connectionMode)
                    && "HIVE".equalsIgnoreCase(hiveServer))
                || ("APACHE_0_20_203".equals(hiveVersion) && "EMBEDDED".equals(connectionMode))
                || ("MAPR1".equals(hiveVersion) && "EMBEDDED".equals(connectionMode))
                || ("MapR_EMR".equals(hiveVersion) && "EMBEDDED".equals(connectionMode))
                || ("Cloudera_CDH3".equals(hiveVersion) && "EMBEDDED".equals(connectionMode)))) {

          stringBuffer.append(TEXT_25);
        }

        if (hadoopProps.size() > 0) {
          for (Map<String, String> item : hadoopProps) {

            stringBuffer.append(TEXT_26);
            stringBuffer.append(item.get("PROPERTY"));
            stringBuffer.append(TEXT_27);
            stringBuffer.append(item.get("VALUE"));
            stringBuffer.append(TEXT_28);
          }
        }

        if (securedEmbedded) {
          String metastoreUrl = ElementParameterParser.getValue(node, "__METASTORE_JDBC_URL__");
          String driverClass = ElementParameterParser.getValue(node, "__METASTORE_CLASSNAME__");
          String metastoreUsername =
              ElementParameterParser.getValue(node, "__METASTORE_USERNAME__");
          String metastorePassword =
              ElementParameterParser.getValue(node, "__METASTORE_PASSWORD__");
          boolean useKeytab =
              "true".equals(ElementParameterParser.getValue(node, "__USE_KEYTAB__"));
          String userPrincipal = ElementParameterParser.getValue(node, "__PRINCIPAL__");
          String keytabPath = ElementParameterParser.getValue(node, "__KEYTAB_PATH__");

          stringBuffer.append(TEXT_29);
          stringBuffer.append(driverClass);
          stringBuffer.append(TEXT_30);
          stringBuffer.append(metastoreUrl);
          stringBuffer.append(TEXT_31);
          stringBuffer.append(metastoreUsername);
          stringBuffer.append(TEXT_32);
          stringBuffer.append(metastorePassword);
          stringBuffer.append(TEXT_33);
          stringBuffer.append(hivePrincipal);
          stringBuffer.append(TEXT_34);

          if (useKeytab) {

            stringBuffer.append(TEXT_35);
            stringBuffer.append(userPrincipal);
            stringBuffer.append(TEXT_36);
            stringBuffer.append(keytabPath);
            stringBuffer.append(TEXT_37);
          }
        }

        if (((isCustom && !useYarn)
                || (!isCustom
                    && !"PIVOTAL_HD_1_0_1".equals(hiveVersion)
                    && !"HDP_2_0".equals(hiveVersion)
                    && !"Cloudera_CDH4_YARN".equals(hiveVersion)))
            && setMapredJT) {
          String mapredJT = ElementParameterParser.getValue(node, "__MAPRED_JT__");

          stringBuffer.append(TEXT_38);
          stringBuffer.append(mapredJT);
          stringBuffer.append(TEXT_39);
        }

        if (setNamenode) {
          String namenode = ElementParameterParser.getValue(node, "__FS_DEFAULT_NAME__");

          stringBuffer.append(TEXT_40);
          stringBuffer.append(fsDefalutName);
          stringBuffer.append(TEXT_41);
          stringBuffer.append(namenode);
          stringBuffer.append(TEXT_42);
        }

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

        if ("EMBEDDED".equals(connectionMode)) {

          stringBuffer.append(TEXT_45);
          stringBuffer.append(dbhost);
          stringBuffer.append(TEXT_46);
          stringBuffer.append(dbport);
          stringBuffer.append(TEXT_47);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_48);
          stringBuffer.append(hiveServer);
          stringBuffer.append(TEXT_49);

          if (isCustom
              || (!isCustom
                  && ("HDP_1_0,HDP_1_2,HDP_1_3,HDP_2_0,Cloudera_CDH4,Cloudera_CDH4_YARN,PIVOTAL_HD_1_0_1"
                      .contains(hiveVersion)))) {
            String dbuser = ElementParameterParser.getValue(node, "__USER__");

            stringBuffer.append(TEXT_50);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_51);
            stringBuffer.append(dbuser);
            stringBuffer.append(TEXT_52);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_53);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_54);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_55);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_56);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_57);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_58);
          }
        } else {
          if (securedStandaloneHive2) {

            stringBuffer.append(TEXT_59);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_60);
            stringBuffer.append(hiveServer);
            stringBuffer.append(TEXT_61);
            stringBuffer.append(dbhost);
            stringBuffer.append(TEXT_62);
            stringBuffer.append(dbport);
            stringBuffer.append(TEXT_63);
            stringBuffer.append(dbname);
            stringBuffer.append(TEXT_64);
            stringBuffer.append(hivePrincipal);
            stringBuffer.append(TEXT_65);

          } else {

            stringBuffer.append(TEXT_66);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_67);
            stringBuffer.append(hiveServer);
            stringBuffer.append(TEXT_68);
            stringBuffer.append(dbhost);
            stringBuffer.append(TEXT_69);
            stringBuffer.append(dbport);
            stringBuffer.append(TEXT_70);
            stringBuffer.append(dbname);
            stringBuffer.append(TEXT_71);
          }
        }
      }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

    class DefaultConnectionUtil {

      protected String cid;
      protected String dbproperties;
      protected String dbhost;
      protected String dbport;
      protected String dbname;

      public void beforeComponentProcess(INode node) {}

      public void createURL(INode node) {
        cid = node.getUniqueName();
        dbproperties = ElementParameterParser.getValue(node, "__PROPERTIES__");
        dbhost = ElementParameterParser.getValue(node, "__HOST__");
        dbport = ElementParameterParser.getValue(node, "__PORT__");
        dbname = ElementParameterParser.getValue(node, "__DBNAME__");
      }

      public String getDirverClassName(INode node) {
        return "";
      }

      public void classForName(INode node) {

        stringBuffer.append(TEXT_2);
        stringBuffer.append(this.getDirverClassName(node));
        stringBuffer.append(TEXT_3);
      }

      public void useShareConnection(INode node) {
        String sharedConnectionName =
            ElementParameterParser.getValue(node, "__SHARED_CONNECTION_NAME__");

        stringBuffer.append(TEXT_4);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_5);
        stringBuffer.append(sharedConnectionName);
        stringBuffer.append(TEXT_6);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_7);
        stringBuffer.append(this.getDirverClassName(node));
        stringBuffer.append(TEXT_8);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_9);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_10);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_11);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_12);
      }

      public void createConnection(INode node) {

        stringBuffer.append(TEXT_13);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_14);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_15);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_16);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_17);
      }

      public void setAutoCommit(INode node) {
        boolean setAutoCommit =
            "true".equals(ElementParameterParser.getValue(node, "__AUTO_COMMIT__"));

        stringBuffer.append(TEXT_18);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_19);
        stringBuffer.append(setAutoCommit);
        stringBuffer.append(TEXT_20);
      }

      public void afterComponentProcess(INode node) {}
    } // end DefaultUtil class

    DefaultConnectionUtil connUtil = new DefaultConnectionUtil();

    stringBuffer.append(TEXT_21);

    class ConnectionUtil extends DefaultConnectionUtil {
      private String javaDbDriver = "org.apache.hadoop.hive.jdbc.HiveDriver";

      public void createConnection(INode node) {
        String connectionMode = ElementParameterParser.getValue(node, "__CONNECTION_MODE__");
        String hiveVersion = ElementParameterParser.getValue(node, "__HIVE_VERSION__");
        String hiveServer = ElementParameterParser.getValue(node, "__HIVE_SERVER__");
        boolean isCustom =
            "CUSTOM".equals(ElementParameterParser.getValue(node, "__DISTRIBUTION__"));

        boolean useKrb = "true".equals(ElementParameterParser.getValue(node, "__USE_KRB__"));
        boolean cdh4CanBeSecured =
            "Cloudera_CDH4".equals(hiveVersion)
                && (("HIVE".equalsIgnoreCase(hiveServer)
                        && "EMBEDDED".equalsIgnoreCase(connectionMode))
                    || "HIVE2".equalsIgnoreCase(hiveServer));
        boolean securityIsEnabled =
            useKrb
                && (isCustom
                    || ("HDP_1_0".equals(hiveVersion)
                        || "HDP_1_2".equals(hiveVersion)
                        || "HDP_1_3".equals(hiveVersion)
                        || cdh4CanBeSecured));
        boolean securedStandaloneHive2 =
            securityIsEnabled
                && "HIVE2".equalsIgnoreCase(hiveServer)
                && "STANDALONE".equalsIgnoreCase(connectionMode);
        if (securedStandaloneHive2) {

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

        } else {
          super.createConnection(node);
        }
      }

      public void createURL(INode node) {
        super.createURL(node);
        String connectionMode = ElementParameterParser.getValue(node, "__CONNECTION_MODE__");
        String hiveVersion = ElementParameterParser.getValue(node, "__HIVE_VERSION__");
        String fsDefalutName = "fs.default.name";
        String hiveServer = ElementParameterParser.getValue(node, "__HIVE_SERVER__");

        boolean setMapredJT =
            "true".equals(ElementParameterParser.getValue(node, "__SET_MAPRED_JT__"));
        boolean setNamenode =
            "true".equals(ElementParameterParser.getValue(node, "__SET_FS_DEFAULT_NAME__"));
        List<Map<String, String>> hadoopProps =
            (List<Map<String, String>>)
                ElementParameterParser.getObjectValue(node, "__HADOOP_ADVANCED_PROPERTIES__");

        boolean isCustom =
            "CUSTOM".equals(ElementParameterParser.getValue(node, "__DISTRIBUTION__"));
        boolean useYarn = "true".equals(ElementParameterParser.getValue(node, "__USE_YARN__"));

        boolean useKrb = "true".equals(ElementParameterParser.getValue(node, "__USE_KRB__"));
        boolean cdh4CanBeSecured =
            "Cloudera_CDH4".equals(hiveVersion)
                && (("HIVE".equalsIgnoreCase(hiveServer)
                        && "EMBEDDED".equalsIgnoreCase(connectionMode))
                    || "HIVE2".equalsIgnoreCase(hiveServer));

        boolean securityIsEnabled =
            useKrb
                && (isCustom
                    || ("HDP_1_0".equals(hiveVersion)
                        || "HDP_1_2".equals(hiveVersion)
                        || "HDP_1_3".equals(hiveVersion)
                        || cdh4CanBeSecured));
        boolean securedStandaloneHive2 =
            securityIsEnabled
                && "HIVE2".equalsIgnoreCase(hiveServer)
                && "STANDALONE".equalsIgnoreCase(connectionMode);
        boolean securedEmbedded = securityIsEnabled && "EMBEDDED".equalsIgnoreCase(connectionMode);
        String hivePrincipal = ElementParameterParser.getValue(node, "__HIVE_PRINCIPAL__");

        if (hiveServer != null
            && !"".equals(hiveServer.trim())
            && (isCustom
                || ("HDP_1_2".equals(hiveVersion)
                    || "HDP_1_3".equals(hiveVersion)
                    || "Cloudera_CDH4".equals(hiveVersion)
                    || "Cloudera_CDH4_YARN".equals(hiveVersion)
                    || "MAPR213".equals(hiveVersion)
                    || "MAPR301".equals(hiveVersion)
                    || "HDP_2_0".equals(hiveVersion)))) {
          hiveServer = hiveServer.toLowerCase();
          if ("hive2".equals(hiveServer)) {
            javaDbDriver = "org.apache.hive.jdbc.HiveDriver";
          }
        } else {
          hiveServer = "hive";
        }
        if (!isCustom
            && (("HDP_1_0".equals(hiveVersion) && "STANDALONE".equals(connectionMode))
                || ("HDP_1_2".equals(hiveVersion)
                    && "STANDALONE".equals(connectionMode)
                    && "HIVE".equalsIgnoreCase(hiveServer))
                || ("HDP_1_3".equals(hiveVersion)
                    && "STANDALONE".equals(connectionMode)
                    && "HIVE".equalsIgnoreCase(hiveServer))
                || ("HDP_2_0".equals(hiveVersion)
                    && "STANDALONE".equals(connectionMode)
                    && "HIVE".equalsIgnoreCase(hiveServer))
                || ("APACHE_0_20_203".equals(hiveVersion) && "EMBEDDED".equals(connectionMode))
                || ("MAPR1".equals(hiveVersion) && "EMBEDDED".equals(connectionMode))
                || ("MapR_EMR".equals(hiveVersion) && "EMBEDDED".equals(connectionMode))
                || ("Cloudera_CDH3".equals(hiveVersion) && "EMBEDDED".equals(connectionMode)))) {

          stringBuffer.append(TEXT_25);
        }

        if (hadoopProps.size() > 0) {
          for (Map<String, String> item : hadoopProps) {

            stringBuffer.append(TEXT_26);
            stringBuffer.append(item.get("PROPERTY"));
            stringBuffer.append(TEXT_27);
            stringBuffer.append(item.get("VALUE"));
            stringBuffer.append(TEXT_28);
          }
        }

        if (securedEmbedded) {
          String metastoreUrl = ElementParameterParser.getValue(node, "__METASTORE_JDBC_URL__");
          String driverClass = ElementParameterParser.getValue(node, "__METASTORE_CLASSNAME__");
          String metastoreUsername =
              ElementParameterParser.getValue(node, "__METASTORE_USERNAME__");
          String metastorePassword =
              ElementParameterParser.getValue(node, "__METASTORE_PASSWORD__");
          boolean useKeytab =
              "true".equals(ElementParameterParser.getValue(node, "__USE_KEYTAB__"));
          String userPrincipal = ElementParameterParser.getValue(node, "__PRINCIPAL__");
          String keytabPath = ElementParameterParser.getValue(node, "__KEYTAB_PATH__");

          stringBuffer.append(TEXT_29);
          stringBuffer.append(driverClass);
          stringBuffer.append(TEXT_30);
          stringBuffer.append(metastoreUrl);
          stringBuffer.append(TEXT_31);
          stringBuffer.append(metastoreUsername);
          stringBuffer.append(TEXT_32);
          stringBuffer.append(metastorePassword);
          stringBuffer.append(TEXT_33);
          stringBuffer.append(hivePrincipal);
          stringBuffer.append(TEXT_34);

          if (useKeytab) {

            stringBuffer.append(TEXT_35);
            stringBuffer.append(userPrincipal);
            stringBuffer.append(TEXT_36);
            stringBuffer.append(keytabPath);
            stringBuffer.append(TEXT_37);
          }
        }

        if (((isCustom && !useYarn)
                || (!isCustom
                    && !"PIVOTAL_HD_1_0_1".equals(hiveVersion)
                    && !"HDP_2_0".equals(hiveVersion)
                    && !"Cloudera_CDH4_YARN".equals(hiveVersion)))
            && setMapredJT) {
          String mapredJT = ElementParameterParser.getValue(node, "__MAPRED_JT__");

          stringBuffer.append(TEXT_38);
          stringBuffer.append(mapredJT);
          stringBuffer.append(TEXT_39);
        }

        if (setNamenode) {
          String namenode = ElementParameterParser.getValue(node, "__FS_DEFAULT_NAME__");

          stringBuffer.append(TEXT_40);
          stringBuffer.append(fsDefalutName);
          stringBuffer.append(TEXT_41);
          stringBuffer.append(namenode);
          stringBuffer.append(TEXT_42);
        }

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

        if ("EMBEDDED".equals(connectionMode)) {

          stringBuffer.append(TEXT_45);
          stringBuffer.append(dbhost);
          stringBuffer.append(TEXT_46);
          stringBuffer.append(dbport);
          stringBuffer.append(TEXT_47);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_48);
          stringBuffer.append(hiveServer);
          stringBuffer.append(TEXT_49);

          if (isCustom
              || (!isCustom
                  && ("HDP_1_0,HDP_1_2,HDP_1_3,HDP_2_0,Cloudera_CDH4,Cloudera_CDH4_YARN,PIVOTAL_HD_1_0_1"
                      .contains(hiveVersion)))) {
            String dbuser = ElementParameterParser.getValue(node, "__USER__");

            stringBuffer.append(TEXT_50);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_51);
            stringBuffer.append(dbuser);
            stringBuffer.append(TEXT_52);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_53);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_54);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_55);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_56);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_57);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_58);
          }
        } else {
          if (securedStandaloneHive2) {

            stringBuffer.append(TEXT_59);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_60);
            stringBuffer.append(hiveServer);
            stringBuffer.append(TEXT_61);
            stringBuffer.append(dbhost);
            stringBuffer.append(TEXT_62);
            stringBuffer.append(dbport);
            stringBuffer.append(TEXT_63);
            stringBuffer.append(dbname);
            stringBuffer.append(TEXT_64);
            stringBuffer.append(hivePrincipal);
            stringBuffer.append(TEXT_65);

          } else {

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

      public void setAutoCommit(INode node) {
        boolean useTransaction =
            false; // ("true").equals(ElementParameterParser.getValue(node,"__IS_USE_AUTO_COMMIT__"));
        boolean setAutoCommit =
            "true".equals(ElementParameterParser.getValue(node, "__AUTO_COMMIT__"));
        if (useTransaction) {

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

      public String getDirverClassName(INode node) {
        return javaDbDriver;
      }
    } // end class

    connUtil = new ConnectionUtil();

    // ----------------------------component codes-----------------------------------------
    stringBuffer.append(TEXT_75);

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

    String cid = node.getUniqueName();
    String dbhost = ElementParameterParser.getValue(node, "__HOST__");
    String dbport = ElementParameterParser.getValue(node, "__PORT__");
    String dbschema = ElementParameterParser.getValue(node, "__DB_SCHEMA__");
    if (dbschema == null || dbschema.trim().length() == 0) {
      dbschema = ElementParameterParser.getValue(node, "__SCHEMA_DB__");
    }
    String dbname = ElementParameterParser.getValue(node, "__DBNAME__");
    String dbuser = ElementParameterParser.getValue(node, "__USER__");
    String dbpass = ElementParameterParser.getValue(node, "__PASS__");
    String encoding = ElementParameterParser.getValue(node, "__ENCODING__");

    boolean isUseSharedConnection =
        ("true").equals(ElementParameterParser.getValue(node, "__USE_SHARED_CONNECTION__"));

    connUtil.beforeComponentProcess(node);

    connUtil.createURL(node);

    stringBuffer.append(TEXT_76);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_77);
    stringBuffer.append((dbuser != null && dbuser.trim().length() == 0) ? "null" : dbuser);
    stringBuffer.append(TEXT_78);
    // the tSQLiteConnection component not contain user and pass return null
    stringBuffer.append(TEXT_79);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_80);
    stringBuffer.append((dbpass != null && dbpass.trim().length() == 0) ? "null" : dbpass);
    stringBuffer.append(TEXT_81);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_82);

    if (isUseSharedConnection) {

      stringBuffer.append(TEXT_83);
      connUtil.useShareConnection(node);

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

        stringBuffer.append(TEXT_84);
        stringBuffer.append((null != alias && !("".equals(alias))) ? alias : "\"\"");
        stringBuffer.append(TEXT_85);
      }

      stringBuffer.append(TEXT_86);
      connUtil.classForName(node);
      stringBuffer.append(TEXT_87);
      connUtil.createConnection(node);
      stringBuffer.append(TEXT_88);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_89);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_90);

      if (specify_alias) {

        stringBuffer.append(TEXT_91);
      }
    }

    stringBuffer.append(TEXT_92);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_93);
    connUtil.setAutoCommit(node);
    stringBuffer.append(TEXT_94);

    connUtil.afterComponentProcess(node);

    stringBuffer.append(TEXT_95);

    String storeByHBase = ElementParameterParser.getValue(node, "__STORE_BY_HBASE__");
    String connectionMode = ElementParameterParser.getValue(node, "__CONNECTION_MODE__");
    String hiveVersion = ElementParameterParser.getValue(node, "__HIVE_VERSION__");
    String zookeeperQuorumForHBase = ElementParameterParser.getValue(node, "__ZOOKEEPER_QUORUM__");
    String zookeeperClientPortForHBase =
        ElementParameterParser.getValue(node, "__ZOOKEEPER_CLIENT_PORT__");
    String defineRegisterJar = ElementParameterParser.getValue(node, "__DEFINE_REGISTER_JAR__");
    List<Map<String, String>> registerJarForHBase =
        (List<Map<String, String>>) ElementParameterParser.getObjectValue(node, "__REGISTER_JAR__");
    String hiveServer = ElementParameterParser.getValue(node, "__HIVE_SERVER__");

    boolean isCustom = "CUSTOM".equals(ElementParameterParser.getValue(node, "__DISTRIBUTION__"));
    boolean useYarn = "true".equals(ElementParameterParser.getValue(node, "__USE_YARN__"));
    boolean setResourceManager =
        "true".equals(ElementParameterParser.getValue(node, "__SET_RESOURCE_MANAGER__"));

    String yarnClasspathSeparator =
        ElementParameterParser.getValue(node, "__CLASSPATH_SEPARATOR__");

    boolean useKrb = "true".equals(ElementParameterParser.getValue(node, "__USE_KRB__"));
    boolean cdh4CanBeSecured =
        "Cloudera_CDH4".equals(hiveVersion)
            && (("HIVE".equalsIgnoreCase(hiveServer) && "EMBEDDED".equalsIgnoreCase(connectionMode))
                || "HIVE2".equalsIgnoreCase(hiveServer));

    boolean securityIsEnabled =
        useKrb
            && (isCustom
                || ("HDP_1_0".equals(hiveVersion)
                    || "HDP_1_2".equals(hiveVersion)
                    || "HDP_1_3".equals(hiveVersion)
                    || cdh4CanBeSecured));
    boolean securedStandaloneHive2 =
        securityIsEnabled
            && "HIVE2".equalsIgnoreCase(hiveServer)
            && "STANDALONE".equalsIgnoreCase(connectionMode);
    boolean securedEmbedded = securityIsEnabled && "EMBEDDED".equalsIgnoreCase(connectionMode);

    stringBuffer.append(TEXT_96);
    stringBuffer.append(yarnClasspathSeparator);
    stringBuffer.append(TEXT_97);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_98);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_99);

    if (!isCustom && ("HDP_1_2".equals(hiveVersion) || "HDP_1_3".equals(hiveVersion))) {
      String mapMemory = ElementParameterParser.getValue(node, "__MAPRED_JOB_MAP_MEMORY_MB__");
      String reduceMemory =
          ElementParameterParser.getValue(node, "__MAPRED_JOB_REDUCE_MEMORY_MB__");

      stringBuffer.append(TEXT_100);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_101);
      stringBuffer.append(mapMemory);
      stringBuffer.append(TEXT_102);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_103);
      stringBuffer.append(reduceMemory);
      stringBuffer.append(TEXT_104);
    }

    if (securedEmbedded) {
      String namenodePrincipal = ElementParameterParser.getValue(node, "__NAMENODE_PRINCIPAL__");
      String jobtrackerPrincipal =
          ElementParameterParser.getValue(node, "__JOBTRACKER_PRINCIPAL__");

      stringBuffer.append(TEXT_105);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_106);
      stringBuffer.append(namenodePrincipal);
      stringBuffer.append(TEXT_107);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_108);
      stringBuffer.append(jobtrackerPrincipal);
      stringBuffer.append(TEXT_109);
    }

    if ((isCustom && useYarn)
        || (!isCustom
            && ("PIVOTAL_HD_1_0_1".equals(hiveVersion)
                || "HDP_2_0".equals(hiveVersion)
                || "Cloudera_CDH4_YARN".equals(hiveVersion)))) {
      if (setResourceManager) {
        String resourceManager = ElementParameterParser.getValue(node, "__RESOURCE_MANAGER__");

        stringBuffer.append(TEXT_110);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_111);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_112);
        stringBuffer.append(resourceManager);
        stringBuffer.append(TEXT_113);
      }

      boolean setSchedulerAddress =
          "true".equals(ElementParameterParser.getValue(node, "__SET_SCHEDULER_ADDRESS__"));
      if (setSchedulerAddress) {
        String schedulerAddress =
            ElementParameterParser.getValue(node, "__RESOURCEMANAGER_SCHEDULER_ADDRESS__");

        stringBuffer.append(TEXT_114);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_115);
        stringBuffer.append(schedulerAddress);
        stringBuffer.append(TEXT_116);
      }

      if ("EMBEDDED".equals(connectionMode)) {

        stringBuffer.append(TEXT_117);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_118);
      }

      boolean setMemory = "true".equals(ElementParameterParser.getValue(node, "__SET_MEMORY__"));
      if (setMemory) {
        String mapMemory = ElementParameterParser.getValue(node, "__MAPREDUCE_MAP_MEMORY_MB__");
        String reduceMemory =
            ElementParameterParser.getValue(node, "__MAPREDUCE_REDUCE_MEMORY_MB__");
        String amMemory =
            ElementParameterParser.getValue(node, "__YARN_APP_MAPREDUCE_AM_RESOURCE_MB__");

        stringBuffer.append(TEXT_119);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_120);
        stringBuffer.append(mapMemory);
        stringBuffer.append(TEXT_121);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_122);
        stringBuffer.append(reduceMemory);
        stringBuffer.append(TEXT_123);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_124);
        stringBuffer.append(amMemory);
        stringBuffer.append(TEXT_125);
      }
    }

    List<Map<String, String>> advProps =
        (List<Map<String, String>>)
            ElementParameterParser.getObjectValue(node, "__ADVANCED_PROPERTIES__");
    if (advProps != null) {
      for (Map<String, String> item : advProps) {

        stringBuffer.append(TEXT_126);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_127);
        stringBuffer.append(item.get("PROPERTY"));
        stringBuffer.append(TEXT_128);
        stringBuffer.append(item.get("VALUE"));
        stringBuffer.append(TEXT_129);
      }
    }

    stringBuffer.append(TEXT_130);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_131);
    if ("true".equalsIgnoreCase(storeByHBase)
        && !("EMBEDDED".equals(connectionMode) && "MAPR2".equals(hiveVersion))) {
      stringBuffer.append(TEXT_132);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_133);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_134);
      if (zookeeperQuorumForHBase != null
          && !"".equals(zookeeperQuorumForHBase)
          && !"\"\"".equals(zookeeperQuorumForHBase)) {
        stringBuffer.append(TEXT_135);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_136);
        stringBuffer.append(zookeeperQuorumForHBase);
        stringBuffer.append(TEXT_137);
      }
      stringBuffer.append(TEXT_138);
      if (zookeeperClientPortForHBase != null
          && !"".equals(zookeeperClientPortForHBase)
          && !"\"\"".equals(zookeeperClientPortForHBase)) {
        stringBuffer.append(TEXT_139);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_140);
        stringBuffer.append(zookeeperClientPortForHBase);
        stringBuffer.append(TEXT_141);
      }
      stringBuffer.append(TEXT_142);
      if ("true".equalsIgnoreCase(defineRegisterJar)
          && registerJarForHBase != null
          && registerJarForHBase.size() > 0) {
        for (Map<String, String> jar : registerJarForHBase) {
          String path = jar.get("JAR_PATH");
          if (path == null || "".equals(path) || "\"\"".equals(path)) {
            continue;
          }

          stringBuffer.append(TEXT_143);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_144);
          stringBuffer.append(path);
          stringBuffer.append(TEXT_145);
        }
      }
      stringBuffer.append(TEXT_146);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_147);
    }
    stringBuffer.append(TEXT_148);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_149);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_150);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_151);
    stringBuffer.append(dbname);
    stringBuffer.append(TEXT_152);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_153);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_154);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_155);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_156);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_157);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_158);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_159);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_160);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_161);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_162);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_163);
    return stringBuffer.toString();
  }