Пример #1
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 datablockname = ElementParameterParser.getValue(node, "__DATABLOCKNAME__");
    String filename = ElementParameterParser.getValue(node, "__FILENAME__");
    boolean create = "true".equals(ElementParameterParser.getValue(node, "__CREATE__"));
    List<IMetadataTable> metadatas = node.getMetadataList();
    if ((metadatas != null) && (metadatas.size() > 0)) {}

    stringBuffer.append(TEXT_2);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_3);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_4);
    stringBuffer.append(datablockname);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_6);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_7);
    stringBuffer.append(filename);
    stringBuffer.append(TEXT_8);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_9);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_10);

    if (create) {

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

    stringBuffer.append(TEXT_15);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_16);
    stringBuffer.append(filename);
    stringBuffer.append(TEXT_17);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_18);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_19);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_20);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_21);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_22);
    stringBuffer.append(TEXT_23);
    return stringBuffer.toString();
  }
Пример #2
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 connection = ElementParameterParser.getValue(node, "__CONNECTION__");

    boolean close = ("true").equals(ElementParameterParser.getValue(node, "__CLOSE__"));

    String conn = "conn_" + connection;

    stringBuffer.append(TEXT_2);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_3);
    stringBuffer.append(conn);
    stringBuffer.append(TEXT_4);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_6);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_7);
    if (close) {
      stringBuffer.append(TEXT_8);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_9);
    }
    stringBuffer.append(TEXT_10);
    stringBuffer.append(TEXT_11);
    return stringBuffer.toString();
  }
 public void dbConnectionParamsForELT(INode previousNode) {
   cid = previousNode.getUniqueName();
   dbhost = ElementParameterParser.getValue(previousNode, "__HOST__");
   dbname = ElementParameterParser.getValue(previousNode, "__DBNAME__");
   dbuser = ElementParameterParser.getValue(previousNode, "__USER__");
   dbpwd = ElementParameterParser.getValue(previousNode, "__PASS__");
 }
  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 useExistingConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__");
    boolean isLog4jEnabled =
        ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
    if (!("true").equals(useExistingConn)) {

      stringBuffer.append(TEXT_2);
      if (isLog4jEnabled) {
        stringBuffer.append(TEXT_3);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_4);
      }
      stringBuffer.append(TEXT_5);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_6);
      if (isLog4jEnabled) {
        stringBuffer.append(TEXT_7);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_8);
      }
      stringBuffer.append(TEXT_9);
    }
    stringBuffer.append(TEXT_10);
    return stringBuffer.toString();
  }
 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 void beforeComponentProcess(INode node) {
   cid = node.getUniqueName();
   log4jCodeGenerateUtil = new DefaultLog4jCodeGenerateUtil();
   dbproperties = ElementParameterParser.getValue(node, "__PROPERTIES__");
   dbhost = ElementParameterParser.getValue(node, "__HOST__");
   dbport = ElementParameterParser.getValue(node, "__PORT__");
   dbname = ElementParameterParser.getValue(node, "__DBNAME__");
   dbuser = ElementParameterParser.getValue(node, "__USER__");
 }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

    BigDataCodeGeneratorArgument codeGenArgument = (BigDataCodeGeneratorArgument) 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);
      if (metadata != null) {

        String folder = ElementParameterParser.getValue(node, "__FILENAME__");
        String fileAction = ElementParameterParser.getValue(node, "__FILE_ACTION__");

        List<? extends IConnection> conns = node.getIncomingConnections();
        if (conns != null) {

          if (conns.size() > 0) {

            IConnection conn = conns.get(0);
            String connName = conn.getName();

            if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
              List<IMetadataColumn> columns = metadata.getListColumns();
              if (((org.talend.core.model.process.AbstractNode) node).isMapOnlyAfterReduce()) {

                stringBuffer.append(TEXT_1);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_2);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_3);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_4);

              } else {

                stringBuffer.append(TEXT_5);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_6);
                stringBuffer.append(cid);
                stringBuffer.append(TEXT_7);
                stringBuffer.append(connName);
                stringBuffer.append(TEXT_8);
              }
            }
          }
        }
      }
    }

    return stringBuffer.toString();
  }
      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);
      }
Пример #9
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 dbname = ElementParameterParser.getValue(node, "__DBNAME__");
    String assemblyName = ElementParameterParser.getValue(node, "__ASSEMBLY_NAME__");
    String className = ElementParameterParser.getValue(node, "__CLASS_NAME__");
    String dbquery = ElementParameterParser.getValue(node, "__QUERY__");
    dbquery = dbquery.replaceAll("\n", " ");
    dbquery = dbquery.replaceAll("\r", " ");
    boolean usePrepareStatement =
        "true".equals(ElementParameterParser.getValue(node, "__USE_PREPAREDSTATEMENT__"));

    stringBuffer.append(TEXT_2);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_3);
    stringBuffer.append(assemblyName);
    stringBuffer.append(TEXT_4);
    stringBuffer.append(className);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(dbname);
    stringBuffer.append(TEXT_6);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_7);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_8);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_9);

    if (usePrepareStatement) {

      stringBuffer.append(TEXT_10);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_11);
      stringBuffer.append(assemblyName);
      stringBuffer.append(TEXT_12);
      stringBuffer.append(dbquery);
      stringBuffer.append(TEXT_13);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_14);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_15);
    }

    stringBuffer.append(TEXT_16);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_17);
    stringBuffer.append(TEXT_18);
    return stringBuffer.toString();
  }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();
    stringBuffer.append(TEXT_1);

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

    String accessToken = ElementParameterParser.getValue(node, "__ACCESS_TOKEN__");

    String useProxy = ElementParameterParser.getValue(node, "__USE_PROXY__");
    String proxyHost = ElementParameterParser.getValue(node, "__PROXY_HOST__");
    String proxyPort = ElementParameterParser.getValue(node, "__PROXY_PORT__");

    String clientIdentifier = "\"" + cid + "\"";

    String localeName = "\"" + java.util.Locale.getDefault().toString() + "\"";

    stringBuffer.append(TEXT_2);
    if ("true".equals(useProxy)) {
      stringBuffer.append(TEXT_3);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_4);
      stringBuffer.append(clientIdentifier);
      stringBuffer.append(TEXT_5);
      stringBuffer.append(localeName);
      stringBuffer.append(TEXT_6);
      stringBuffer.append(proxyHost);
      stringBuffer.append(TEXT_7);
      stringBuffer.append(proxyPort);
      stringBuffer.append(TEXT_8);
    } else {
      stringBuffer.append(TEXT_9);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_10);
      stringBuffer.append(clientIdentifier);
      stringBuffer.append(TEXT_11);
      stringBuffer.append(localeName);
      stringBuffer.append(TEXT_12);
    }
    stringBuffer.append(TEXT_13);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_14);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_15);
    stringBuffer.append(accessToken);
    stringBuffer.append(TEXT_16);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_17);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_18);
    stringBuffer.append(TEXT_19);
    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();

    boolean dieOnError = ("true").equals(ElementParameterParser.getValue(node, "__DIE_ON_ERROR__"));
    String clientMode = ElementParameterParser.getValue(node, "__CLIENT_MODE__");

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

    if (dieOnError) {

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

    } else {

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

    stringBuffer.append(TEXT_8);

    if ("HTTP_CLIENT".equals(clientMode)) {

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

    } else {

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

    stringBuffer.append(TEXT_15);
    stringBuffer.append(TEXT_16);
    return stringBuffer.toString();
  }
      public Neo4JTransactionHelper(INode node) {
        this.node = node;
        this.cid = node.getUniqueName();

        this.batchImport =
            "true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__BATCH_IMPORT__"));
        this.commitEvery = ElementParameterParser.getValue(node, "__COMMIT_EVERY__");
        boolean useExistingConnection =
            "true"
                .equalsIgnoreCase(
                    ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"));

        if (useExistingConnection) {
          String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
          for (INode targetNode : node.getProcess().getNodesOfType("tNeo4jConnection")) {
            if (targetNode.getUniqueName().equals(connection)) {
              this.dbVersion = ElementParameterParser.getValue(targetNode, "__DB_VERSION__");
              this.remoteServer =
                  "true"
                      .equalsIgnoreCase(
                          ElementParameterParser.getValue(targetNode, "__REMOTE_SERVER__"));
              break;
            }
          }
        } else {
          this.dbVersion = ElementParameterParser.getValue(node, "__DB_VERSION__");
          this.remoteServer =
              "true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__REMOTE_SERVER__"));
        }
      }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    INode node = (INode) codeGenArgument.getArgument();
    String cid = node.getUniqueName();
    String dllLoad = ElementParameterParser.getValue(node, "__LIBRARY__");
    String clazz = ElementParameterParser.getValue(node, "__CLASS_NAME__");
    List<Map<String, String>> values =
        (List<Map<String, String>>) ElementParameterParser.getObjectValue(node, "__PARAMETERS__");
    String call = "org.talend.net.Object.createInstance(" + dllLoad + "," + clazz + ")";
    if (values.size() > 0) {
      call =
          "org.talend.net.Object.createInstance("
              + dllLoad
              + ","
              + clazz
              + ",parameterList_"
              + cid
              + ")";

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

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

        stringBuffer.append(TEXT_3);
        stringBuffer.append(line.get("PARAMETER"));

        if (i < values.size() - 1) {

          stringBuffer.append(TEXT_4);
        }
      }

      stringBuffer.append(TEXT_5);
    }
    stringBuffer.append(TEXT_6);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_7);
    stringBuffer.append(call);
    stringBuffer.append(TEXT_8);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_9);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_10);
    return stringBuffer.toString();
  }
      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);
        }
      }
Пример #15
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();
    List<? extends IConnection> connections = node.getOutgoingSortedConnections();
    String mode = ElementParameterParser.getValue(node, "__GENERATION_MODE__");

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

      boolean hasConn = false;

      // get all the children collections of the loop node.
      for (IConnection conn : connections) {
        if (conn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
          hasConn = true;
        }
      }
      if (hasConn == true && ("Dom4j").equals(mode)) {

        stringBuffer.append(TEXT_2);
      }
    }

    stringBuffer.append(TEXT_3);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_4);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_5);
    stringBuffer.append(TEXT_6);
    return stringBuffer.toString();
  }
      public void setURL(INode node) {
        String dbserver = ElementParameterParser.getValue(node, "__DBSERVER__");
        if (dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {

          stringBuffer.append(TEXT_122);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_123);
          stringBuffer.append(dbhost);
          stringBuffer.append(TEXT_124);
          stringBuffer.append(dbport);
          stringBuffer.append(TEXT_125);
          stringBuffer.append(dbname);
          stringBuffer.append(TEXT_126);
          stringBuffer.append(dbserver);
          stringBuffer.append(TEXT_127);

        } else {

          stringBuffer.append(TEXT_128);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_129);
          stringBuffer.append(dbhost);
          stringBuffer.append(TEXT_130);
          stringBuffer.append(dbport);
          stringBuffer.append(TEXT_131);
          stringBuffer.append(dbname);
          stringBuffer.append(TEXT_132);
          stringBuffer.append(dbserver);
          stringBuffer.append(TEXT_133);
          stringBuffer.append(dbproperties);
          stringBuffer.append(TEXT_134);
        }
      }
      private void writeBatchMode(Set<String> indexNames, List<String> autoIndexedColumns) {
        String nodeMappedMemory = ElementParameterParser.getValue(node, "__NODE_MAPPED_MEMORY__");
        String relationshipMappedMemory =
            ElementParameterParser.getValue(node, "__RELATIONSHIP_MAPPED_MEMORY__");
        String propertyMappedMemory =
            ElementParameterParser.getValue(node, "__PROPERTY_MAPPED_MEMORY__");
        String stringsMappedMemory =
            ElementParameterParser.getValue(node, "__STRINGS_MAPPED_MEMORY__");
        String arraysMappedMemory =
            ElementParameterParser.getValue(node, "__ARRAYS_MAPPED_MEMORY__");

        stringBuffer.append(TEXT_126);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_127);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_128);
        stringBuffer.append(nodeMappedMemory);
        stringBuffer.append(TEXT_129);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_130);
        stringBuffer.append(relationshipMappedMemory);
        stringBuffer.append(TEXT_131);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_132);
        stringBuffer.append(propertyMappedMemory);
        stringBuffer.append(TEXT_133);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_134);
        stringBuffer.append(stringsMappedMemory);
        stringBuffer.append(TEXT_135);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_136);
        stringBuffer.append(arraysMappedMemory);
        stringBuffer.append(TEXT_137);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_138);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_139);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_140);

        if ("NEO4J_1_X_X".equals(dbVersion)) {
          writeBatchModeVersion1_9(indexNames, autoIndexedColumns);
        } else { // NEO4J_2_1_X
          writeBatchModeVersion2_1(indexNames, autoIndexedColumns);
        }
      }
 public void query(INode node) {
   beforeComponentProcess(node);
   // for input
   String dbquery = ElementParameterParser.getValue(node, "__QUERY__");
   dbquery = dbquery.replaceAll("\n", " ");
   dbquery = dbquery.replaceAll("\r", " ");
   logInfo(node, "info", cid + " - Executing the query: '\" + " + dbquery + " + \"'.");
 }
 public DefaultLog4jFileUtil(INode node) {
   this.node = node;
   this.cid = node.getUniqueName();
   this.label = cid;
   this.isLog4jEnabled =
       ("true")
           .equals(
               org.talend.core.model.process.ElementParameterParser.getValue(
                   node.getProcess(), "__LOG4J_ACTIVATE__"));
 }
      public void 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 setCommit(INode node) {
        if (!("true").equals(useExistingConn)) {
          String commitEvery = ElementParameterParser.getValue(node, "__COMMIT_EVERY__");
          boolean useTransaction =
              !("false").equals(ElementParameterParser.getValue(node, "__USE_TRANSACTION__"));
          if (!("").equals(commitEvery) && !("0").equals(commitEvery) && useTransaction) {

            stringBuffer.append(TEXT_116);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_117);
            log4jCodeGenerateUtil.autoCommit(node, false);
            stringBuffer.append(TEXT_118);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_119);
            stringBuffer.append(commitEvery);
            stringBuffer.append(TEXT_120);
            stringBuffer.append(cid);
            stringBuffer.append(TEXT_121);
          }
        }
      }
Пример #22
0
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

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

    if (("exitloop").equals(ElementParameterParser.getValue(node, "__THEN__"))) {

      stringBuffer.append(TEXT_1);

    } else {

      stringBuffer.append(TEXT_2);
      stringBuffer.append(ElementParameterParser.getValue(node, "__WAIT__"));
      stringBuffer.append(TEXT_3);
    }

    stringBuffer.append(TEXT_4);
    stringBuffer.append(TEXT_5);
    return stringBuffer.toString();
  }
      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);
        }
      }
Пример #24
0
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

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

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

        String cid = node.getUniqueName();
        String tablePrint = ElementParameterParser.getValue(node, "__TABLE_PRINT__");

        stringBuffer.append(TEXT_1);

        if (("true").equals(tablePrint)) { // print all records one time

          stringBuffer.append(TEXT_2);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_3);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_4);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_5);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_6);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_7);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_8);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_9);
        }

        stringBuffer.append(TEXT_10);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_11);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_12);
      } // 2
    } // 1

    stringBuffer.append(TEXT_13);
    return stringBuffer.toString();
  }
 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 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 String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

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

    String endpoint = ElementParameterParser.getValue(node, "__ENDPOINT__");
    String modulename = ElementParameterParser.getValue(node, "__MODULENAME__");
    String packageName = ElementParameterParser.getValue(node, "__CUSTOM_MODULE_PACKAGE__");
    String customModuleName = ElementParameterParser.getValue(node, "__CUSTOM_MODULE_NAME__");

    String username = ElementParameterParser.getValue(node, "__USER__");
    String password = ElementParameterParser.getValue(node, "__PASS__");

    stringBuffer.append(TEXT_1);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_2);
    if ("CustomModule".equals(modulename)) {
      stringBuffer.append(TEXT_3);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_4);
      stringBuffer.append(packageName);
      stringBuffer.append(TEXT_5);
      stringBuffer.append(customModuleName);
      stringBuffer.append(TEXT_6);
    } else {
      stringBuffer.append(TEXT_7);
      stringBuffer.append(cid);
      stringBuffer.append(TEXT_8);
      stringBuffer.append(modulename);
      stringBuffer.append(TEXT_9);
    }
    stringBuffer.append(TEXT_10);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_11);
    stringBuffer.append(username);
    stringBuffer.append(TEXT_12);
    stringBuffer.append(password);
    stringBuffer.append(TEXT_13);
    stringBuffer.append(endpoint);
    stringBuffer.append(TEXT_14);
    stringBuffer.append(cid);
    stringBuffer.append(TEXT_15);
    return stringBuffer.toString();
  }
 private void init() {
   if (hasInit) {
     return;
   }
   this.cid = node.getUniqueName();
   this.isLog4jEnabled =
       ("true")
           .equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
   String useConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__");
   if (useConn == null || "".equals(useConn) || "true".equals(useConn)) {
     connection = ElementParameterParser.getValue(node, "__CONNECTION__");
     if (!"".equals(connection)) {
       connection = "'" + connection + "' ";
     }
   }
   // for output
   dataAction = ElementParameterParser.getValue(node, "__DATA_ACTION__");
   if (dataAction != null && !("").equals(dataAction)) {
     logCommitCounter = true;
   }
   useBatchSize = ElementParameterParser.getValue(node, "__USE_BATCH_SIZE__");
   batchSize = ElementParameterParser.getValue(node, "__BATCH_SIZE__");
   hasInit = true;
 }
  public String generate(Object argument) {
    final StringBuffer stringBuffer = new StringBuffer();

    CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
    INode node = (INode) codeGenArgument.getArgument();
    List<IMetadataTable> metadatas = node.getMetadataList();
    if ((metadatas != null) && (metadatas.size() > 0)) {
      IMetadataTable metadata = metadatas.get(0);
      if (metadata != null) {
        String cid = node.getUniqueName();
        String filename = ElementParameterParser.getValue(node, "__FILENAME__");
        boolean isAppend = ("true").equals(ElementParameterParser.getValue(node, "__APPEND__"));
        List<Map<String, String>> colDef =
            (List<Map<String, String>>)
                ElementParameterParser.getObjectValue(node, "__COLDEFINE__");
        String relation = ElementParameterParser.getValue(node, "__RELATION__");

        stringBuffer.append(TEXT_1);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_2);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_3);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_4);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_5);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_6);
        stringBuffer.append(filename);
        stringBuffer.append(TEXT_7);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_8);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_9);
        if (("true").equals(ElementParameterParser.getValue(node, "__CREATE__"))) {
          stringBuffer.append(TEXT_10);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_11);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_12);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_13);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_14);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_15);
        }

        List<IMetadataColumn> columns = metadata.getListColumns();
        int sizeColumns = columns.size();

        for (int i = 0; i < colDef.size(); i++) {
          if (("Nominal").equals(colDef.get(i).get("TYPE"))) {

            stringBuffer.append(TEXT_16);
            stringBuffer.append(cid);
            stringBuffer.append(i);
            stringBuffer.append(TEXT_17);
            stringBuffer.append(cid);
            stringBuffer.append(i);
            stringBuffer.append(TEXT_18);
            stringBuffer.append(colDef.get(i).get("PATTERN"));
            stringBuffer.append(TEXT_19);
            stringBuffer.append(cid);
            stringBuffer.append(i);
            stringBuffer.append(TEXT_20);
            stringBuffer.append(cid);
            stringBuffer.append(i);
            stringBuffer.append(TEXT_21);
            stringBuffer.append(cid);
            stringBuffer.append(i);
            stringBuffer.append(TEXT_22);
            stringBuffer.append(cid);
            stringBuffer.append(i);
            stringBuffer.append(TEXT_23);
            stringBuffer.append(cid);
            stringBuffer.append(i);
            stringBuffer.append(TEXT_24);
          }
        }

        stringBuffer.append(TEXT_25);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_26);
        stringBuffer.append(sizeColumns);
        stringBuffer.append(TEXT_27);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_28);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_29);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_30);
        if (isAppend) {
          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);
          stringBuffer.append(colDef.size());
          stringBuffer.append(TEXT_35);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_36);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_37);
          int attIndex = 0;
          for (Map<String, String> colD : colDef) {
            if (("String").equals(colD.get("TYPE"))) {
              stringBuffer.append(TEXT_38);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_39);
              stringBuffer.append(columns.get(attIndex).getLabel());
              stringBuffer.append(TEXT_40);
            } else if (("Numeric").equals(colD.get("TYPE"))) {
              stringBuffer.append(TEXT_41);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_42);
              stringBuffer.append(columns.get(attIndex).getLabel());
              stringBuffer.append(TEXT_43);
            } else if (("Date").equals(colD.get("TYPE"))) {
              stringBuffer.append(TEXT_44);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_45);
              stringBuffer.append(columns.get(attIndex).getLabel());
              stringBuffer.append(TEXT_46);
              stringBuffer.append(colD.get("PATTERN"));
              stringBuffer.append(TEXT_47);
            } else if (("Nominal").equals(colD.get("TYPE"))) {
              stringBuffer.append(TEXT_48);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_49);
              stringBuffer.append(columns.get(attIndex).getLabel());
              stringBuffer.append(TEXT_50);
              stringBuffer.append(cid);
              stringBuffer.append(attIndex);
              stringBuffer.append(TEXT_51);
            }
            attIndex++;
          }

          stringBuffer.append(TEXT_52);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_53);
          stringBuffer.append(relation);
          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);
        } else {
          stringBuffer.append(TEXT_58);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_59);
          stringBuffer.append(colDef.size());
          stringBuffer.append(TEXT_60);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_61);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_62);
          int attIndex = 0;
          for (Map<String, String> colD : colDef) { // for 1
            if (("String").equals(colD.get("TYPE"))) {
              stringBuffer.append(TEXT_63);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_64);
              stringBuffer.append(columns.get(attIndex).getLabel());
              stringBuffer.append(TEXT_65);
            } else if (("Numeric").equals(colD.get("TYPE"))) {
              stringBuffer.append(TEXT_66);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_67);
              stringBuffer.append(columns.get(attIndex).getLabel());
              stringBuffer.append(TEXT_68);
            } else if (("Date").equals(colD.get("TYPE"))) {
              stringBuffer.append(TEXT_69);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_70);
              stringBuffer.append(columns.get(attIndex).getLabel());
              stringBuffer.append(TEXT_71);
              stringBuffer.append(colD.get("PATTERN"));
              stringBuffer.append(TEXT_72);
            } else if (("Nominal").equals(colD.get("TYPE"))) {
              stringBuffer.append(TEXT_73);
              stringBuffer.append(cid);
              stringBuffer.append(TEXT_74);
              stringBuffer.append(columns.get(attIndex).getLabel());
              stringBuffer.append(TEXT_75);
              stringBuffer.append(cid);
              stringBuffer.append(attIndex);
              stringBuffer.append(TEXT_76);
            }
            attIndex++;
          } // for 1

          stringBuffer.append(TEXT_77);
          stringBuffer.append(cid);
          stringBuffer.append(TEXT_78);
          stringBuffer.append(relation);
          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(TEXT_83);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_84);
        stringBuffer.append(cid);
        stringBuffer.append(TEXT_85);
      }
    }

    stringBuffer.append(TEXT_86);
    stringBuffer.append(TEXT_87);
    return stringBuffer.toString();
  }
      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"));
      }