diff --git a/main/plugins/org.talend.designer.codegen/src/main/java/messages_ja.properties b/main/plugins/org.talend.designer.codegen/src/main/java/messages_ja.properties index 867202e2a78..7f26ab2dc3d 100644 --- a/main/plugins/org.talend.designer.codegen/src/main/java/messages_ja.properties +++ b/main/plugins/org.talend.designer.codegen/src/main/java/messages_ja.properties @@ -10,7 +10,7 @@ CodeGenerator.getGraphicalNode2=------process.getGeneratingNodes()------ CodeGenerator.JET.TimeOut=JET\u306E\u521D\u671F\u5316\u51E6\u7406\u304C\u30BF\u30A4\u30E0\u30A2\u30A6\u30C8\u3057\u307E\u3057\u305F CodeGenerator.newLine=\n\n\n\n CodeGenerator.Node.NotFound=\u73FE\u5728\u306E\u30D7\u30ED\u30BB\u30B9\u306B\u30CE\u30FC\u30C9\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093 -CodeGenerator.Component.NotFound=\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u6B20\u843D\u3057\u3066\u3044\u307E\u3059: {0}\u3002Studio\u3067 -D{1}=false\u3092\u4F7F\u3046\u3068\u3053\u306E\u30C1\u30A7\u30C3\u30AF\u304C\u30B9\u30AD\u30C3\u30D7\u3055\u308C\u3001\u8B66\u544A\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u30ED\u30B0\u30D5\u30A1\u30A4\u30EB\u306B\u8A18\u9332\u3055\u308C\u307E\u3059\u3002 +CodeGenerator.Components.NotFound={0}: \u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u6B20\u843D\u3057\u3066\u3044\u307E\u3059: {1}\u3002Studio\u3067 -D{2}=false\u3092\u4F7F\u3046\u3068\u3053\u306E\u30C1\u30A7\u30C3\u30AF\u304C\u30B9\u30AD\u30C3\u30D7\u3055\u308C\u3001\u8B66\u544A\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u30ED\u30B0\u30D5\u30A1\u30A4\u30EB\u306B\u8A18\u9332\u3055\u308C\u307E\u3059\u3002 JavaRoutineSynchronizer.UnsupportedOperation.Exception1=\u30E1\u30BD\u30C3\u30C9\u304C\u5B9F\u88C5\u3055\u308C\u3066\u3044\u307E\u305B\u3093\\: org.talend.designer.codegen.JavaRoutineSynchronizer line\\:49 JavaRoutineSynchronizer.UnsupportedOperation.Exception2=\u30E1\u30BD\u30C3\u30C9\u304C\u5B9F\u88C5\u3055\u308C\u3066\u3044\u307E\u305B\u3093\\: org.talend.designer.codegen.JavaRoutineSynchronizer line\\:58 JetSkeletonManager.unableLoad=\u30B9\u30B1\u30EB\u30C8\u30F3\u66F4\u65B0\u30AD\u30E3\u30C3\u30B7\u30E5\u30D5\u30A1\u30A4\u30EB\u3092\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093 diff --git a/main/plugins/org.talend.designer.codegen/src/main/java/messages_zh_CN.properties b/main/plugins/org.talend.designer.codegen/src/main/java/messages_zh_CN.properties index 7366aa6132b..6d7272124ef 100644 --- a/main/plugins/org.talend.designer.codegen/src/main/java/messages_zh_CN.properties +++ b/main/plugins/org.talend.designer.codegen/src/main/java/messages_zh_CN.properties @@ -10,7 +10,7 @@ CodeGenerator.getGraphicalNode2=\u8FDB\u7A0B\u5F97\u5230\u751F\u6210\u8282\u70B9 CodeGenerator.JET.TimeOut=JET \u521D\u59CB\u5316\u8D85\u65F6 CodeGenerator.newLine=\n\n\n\n CodeGenerator.Node.NotFound=\u5728\u5F53\u524D -CodeGenerator.Component.NotFound=\u7EC4\u4EF6\u7F3A\u5931: {0}; \u5728 Studio \u6216\u547D\u4EE4\u884C\u4E2D\u4F7F\u7528 -D{1}=false \u53EF\u8DF3\u8FC7\u6B64\u9879\u68C0\u67E5\uFF0C\u540C\u65F6\u89E6\u53D1\u8B66\u544A\u6D88\u606F\u3002 +CodeGenerator.Components.NotFound={0}: \u7EC4\u4EF6\u7F3A\u5931: {1}; \u5728 Studio \u6216\u547D\u4EE4\u884C\u4E2D\u4F7F\u7528 -D{2}=false \u53EF\u8DF3\u8FC7\u6B64\u9879\u68C0\u67E5\uFF0C\u540C\u65F6\u89E6\u53D1\u8B66\u544A\u6D88\u606F\u3002 JavaRoutineSynchronizer.UnsupportedOperation.Exception1=\u65B9\u6CD5\u672A\u5B9E\u65BD\uFF1Aorg.talend.designer.codegen.JavaRoutineSynchronizer line:49 JavaRoutineSynchronizer.UnsupportedOperation.Exception2=\u65B9\u6CD5\u672A\u5B9E\u65BD\uFF1Aorg.talend.designer.codegen.JavaRoutineSynchronizer line:58 JetSkeletonManager.unableLoad=\u65E0\u6CD5\u52A0\u8F7D\u4E3B\u5E72\u66F4\u65B0\u7F13\u5B58\u6587\u4EF6 diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_java.xml index 7a7be895c38..5d49ef87800 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_java.xml @@ -257,6 +257,18 @@ + + + + + + + "" "prompt=false" + + + + + + + + + + false @@ -854,12 +886,12 @@ - - + - + + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_main.javajet index 96678da4bf1..bee683f6f92 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_main.javajet @@ -1997,12 +1997,51 @@ class RedshiftManager extends Manager { public String getSpecificConnectionURL() { return "\"jdbc:redshift://\" + " + host + " + \":\" + " + port + " + \"/\" + " + dbName; } + + public String getConnectionURL(){ + boolean useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); + int driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__REDSHIFT_DRIVER_VERSION__"))? 2 : 1; + + if (getAdditionalParams() == null || "\"\"".equals(getAdditionalParams().trim()) || (!useStringProperties && driveVersion == 2) ){ + return getSpecificConnectionURL(); + }else{ + return getSpecificConnectionURL() + " + \"" + getSeparator() + "\" + " + getAdditionalParams(); + } + } + public String getConnection() { + boolean useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); + int driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__REDSHIFT_DRIVER_VERSION__"))? 2 : 1; StringBuilder javaCode = new StringBuilder(); if(useExistingConnection) { javaCode.append(retrieveTable()); javaCode.append("java.sql.Connection conn_" + cid + " = (java.sql.Connection)globalMap.get(\"conn_" + connection + "\");"); - } else { + } else if(!useStringProperties && driveVersion == 2){ + + javaCode.append(retrieveTable()); + javaCode.append("java.lang.Class jdbcclazz_" + cid + "= java.lang.Class.forName(\"" + getDriver()+ "\");\r\n"); + + newInstance(javaCode); + + log4jCodeGenerateUtil.connect_begin(); + String passwordFieldName = "__PASS__"; + if(ElementParameterParser.canEncrypt(node, passwordFieldName)) { + javaCode.append("final String decryptedPassword_" + cid + "= routines.system.PasswordEncryptUtil.decryptPassword(" + ElementParameterParser.getEncryptedValue(node, passwordFieldName) + ");\r\n"); + } else { + javaCode.append("final String decryptedPassword_" + cid + "= " + ElementParameterParser.getValue(node, passwordFieldName) + ";\r\n"); + } + java.util.List> properties = (java.util.List>)ElementParameterParser.getObjectValue(node, "__ENTRY_PROPERTIES__"); + + + javaCode.append("java.util.Properties atnParamsPrope_" + cid + "= new java.util.Properties();\r\n"); + javaCode.append("atnParamsPrope_" + cid + ".put(\"user\",dbUser_"+ cid + ");\r\n"); + javaCode.append("atnParamsPrope_" + cid + ".put(\"password\",decryptedPassword_" + cid + ");\r\n"); + for(java.util.Map entry : properties){ + javaCode.append("atnParamsPrope_" + cid + ".put(" + entry.get("KEY") + "," + entry.get("VALUE") + ");\r\n"); + } + javaCode.append("java.sql.Connection conn_" + cid + " = java.sql.DriverManager.getConnection(url_" + cid + ", atnParamsPrope_" + cid + ");\r\n"); + + }else { javaCode.append(super.getConnection()); } return javaCode.toString(); @@ -2690,10 +2729,13 @@ if(columnList != null && columnList.size() > 0) { <% } } - log4jCodeGenerateUtil.close_begin(); + if(!useExistingConnection){ + log4jCodeGenerateUtil.close_begin(); + %> + <%=manager.closeConnection()%> + <%log4jCodeGenerateUtil.close_end(); + } %> - <%=manager.closeConnection()%> - <%log4jCodeGenerateUtil.close_end();%> globalMap.put("<%=cid%>_QUERY", "<%=manager.getCreateTableSQL(columnList)%>"); } catch(java.lang.Exception e) { globalMap.put("<%=cid%>_ERROR_MESSAGE",e.getMessage()); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_messages.properties index 60dc8a096be..5c2606b3ccc 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tCreateTable/tCreateTable_messages.properties @@ -137,3 +137,12 @@ ACCOUNT.NAME=Account ROLE.NAME=Role ENFORCE_DELIMITED_IDENTIFIERS.NAME=Enforce database delimited identifiers UNLOGGED.NAME=Unlogged Table + +REDSHIFT_DRIVER_VERSION.NAME=Driver version +REDSHIFT_DRIVER_VERSION.ITEM.DRIVER_V1=Driver v1 +REDSHIFT_DRIVER_VERSION.ITEM.DRIVER_V2=Driver v2 + +USE_STRING_PROPERTIES.NAME=Use String JDBC parameters +ENTRY_PROPERTIES.NAME=Additional JDBC Parameters +ENTRY_PROPERTIES.ITEM.KEY=Key +ENTRY_PROPERTIES.ITEM.VALUE=Value \ No newline at end of file diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tELTOutput/tELTOutput_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tELTOutput/tELTOutput_main.javajet index ae668f5fdcc..81d5d78ff21 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tELTOutput/tELTOutput_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tELTOutput/tELTOutput_main.javajet @@ -13,7 +13,7 @@ imports=" java.util.List java.util.ArrayList java.util.LinkedList - java.util.StringJoiner + java.util.StringJoiner java.util.Map java.util.HashMap " @@ -80,6 +80,7 @@ skeleton="../templates/db_output_bulk.skeleton" String dbuser = null; boolean useExistingConn = false; boolean dryRun = false; + boolean autoWrapColumnName = false; if(previousNode != null) { dryRun = ("true").equals(ElementParameterParser.getValue(previousNode, "__DRY_RUN__")); if(!dryRun){ @@ -88,6 +89,7 @@ skeleton="../templates/db_output_bulk.skeleton" dbuser = ElementParameterParser.getValue(previousNode, "__USER__"); useExistingConn = ("true").equals(ElementParameterParser.getValue(previousNode, "__USE_EXISTING_CONNECTION__")); } + autoWrapColumnName = "true".equals(ElementParameterParser.getValue(previousNode, "__ACTIVE_DATABASE_DELIMITED_IDENTIFIERS__")); } boolean useWhereTable = ("true").equals(ElementParameterParser.getValue(node, "__USE_WHERE_CONDITIONS_TABLE__")); @@ -140,7 +142,7 @@ skeleton="../templates/db_output_bulk.skeleton" columnList = metadata.getListColumns(); } } - + if(columnList != null && columnList.size()>0){ StringBuilder insertColName = new StringBuilder(); @@ -148,6 +150,7 @@ skeleton="../templates/db_output_bulk.skeleton" boolean isUpdate = "UPDATE".equals(dataAction); List> setColumns = (List>)ElementParameterParser.getObjectValue(node, "__SET_COLUMN__"); int counterOuter = 0; + for(IMetadataColumn column : columnList){ String suffix = ","; @@ -159,12 +162,16 @@ skeleton="../templates/db_output_bulk.skeleton" if(columnName==null || columnName.trim().isEmpty()){ columnName = column.getLabel(); } - if (columnName.startsWith("\"")) { - columnName = "\\" + columnName; - } - if (columnName.endsWith("\"") && !columnName.endsWith("\\\"")) { - columnName = columnName.substring(0, columnName.lastIndexOf("\"")) + "\\" + "\""; + + //use empty string as need to keep old action if not autoWrapColumnName + if(MYSQL.equalsIgnoreCase(dbmsId) || SINGLESTORE.equalsIgnoreCase(dbmsId) || "amazon_aurora_id".equalsIgnoreCase(dbmsId)) { + columnName = ColumnHelper.wrapColumnNameByGraveAccentIfNecessary(autoWrapColumnName, "", columnName, ""); + } else if(ACCESS.equalsIgnoreCase(dbmsId) || MSSQL.equalsIgnoreCase(dbmsId)) { + columnName = ColumnHelper.wrapColumnNameByBracketIfNecessary(autoWrapColumnName, "", columnName, ""); + } else { + columnName = ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, "", columnName, ""); } + boolean isUpdateColumn = "true".equals(setColumns.get(counterOuter).get("UPDATE_COLUMN")); insertColName.append(columnName).append(suffix); if (isUpdate && isUpdateColumn) { @@ -289,8 +296,8 @@ skeleton="../templates/db_output_bulk.skeleton" Manager manager = null; String tableAction = ElementParameterParser.getValue(node,"__TABLE_ACTION__"); - - List stmtStructure = getELTManager(dbmsId, cid, node).createColumnList(columnList, false, null, null); + + List stmtStructure = getELTManager(dbmsId, cid, node, autoWrapColumnName).createColumnList(columnList, false, null, null); String table = tableName; dbLog = new DBLogUtil(node); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tELTTeradataMap/tELTTeradataMap_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tELTTeradataMap/tELTTeradataMap_java.xml index 85f5e0d0d62..370a87c027b 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tELTTeradataMap/tELTTeradataMap_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tELTTeradataMap/tELTTeradataMap_java.xml @@ -128,8 +128,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tHiveConnection/tHiveConnection_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tHiveConnection/tHiveConnection_java.xml index 61c2c14c7dc..b6e8e5bfce9 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tHiveConnection/tHiveConnection_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tHiveConnection/tHiveConnection_java.xml @@ -32,13 +32,6 @@ - - This distribution is deprecated - - @@ -685,68 +678,6 @@ REQUIRED="false" REQUIRED_IF="(CONFIGURATIONS_FROM_CLASSPATH == 'false') AND (DISTRIBUTION!='CUSTOM') AND (isShow[USE_KRB] AND USE_KRB=='true') AND (DISTRIB[DISTRIBUTION, HIVE_VERSION].doSupportKerberos[] AND ((DISTRIB[DISTRIBUTION, HIVE_VERSION].doSupportHive1[] AND DISTRIB[DISTRIBUTION, HIVE_VERSION].doSupportEmbeddedMode[] AND HIVE_SERVER=='HIVE' AND CONNECTION_MODE=='EMBEDDED') OR (DISTRIB[DISTRIBUTION, HIVE_VERSION].doSupportHive2[] AND HIVE_SERVER=='HIVE2')))" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages.properties index 3bb04707758..2d4c196685b 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages.properties @@ -70,27 +70,6 @@ DISTRIBUTION.ITEM.CUSTOM=Custom - Unsupported DISTRIBUTION.ITEM.AMAZON_EMR=Amazon EMR DISTRIBUTION.ITEM.MICROSOFT_HD_INSIGHT=Microsoft HD Insight HIVE_VERSION.NAME=Hive version -HIVE_VERSION.ITEM.HDP_1_2=Hortonworks Data Platform V1.2.0(Bimota) -HIVE_VERSION.ITEM.HDP_1_3=Hortonworks Data Platform V1.3.0(Condor) -HIVE_VERSION.ITEM.HDP_2_0=Hortonworks Data Platform V2.0.0(BigWheel) -HIVE_VERSION.ITEM.HDP_2_1=Hortonworks Data Platform V2.1.0(Baikal) -HIVE_VERSION.ITEM.HDP_2_2=Hortonworks Data Platform V2.2.0 -HIVE_VERSION.ITEM.HDP_2_3=Hortonworks Data Platform V2.3.2 -HIVE_VERSION.ITEM.APACHE_1_0_0=Apache 1.0.0 (Hive 0.9.0) -HIVE_VERSION.ITEM.MAPR2=MapR 2.0.0 -HIVE_VERSION.ITEM.MAPR212=MapR 2.1.2 -HIVE_VERSION.ITEM.MAPR213=MapR 2.1.3 -HIVE_VERSION.ITEM.MAPR301=MapR 3.0.1 -HIVE_VERSION.ITEM.MAPR310=MapR 3.1.0 -HIVE_VERSION.ITEM.MAPR401=MapR 4.0.1(YARN mode) -HIVE_VERSION.ITEM.MAPR410=MapR 4.1.0(YARN mode) -HIVE_VERSION.ITEM.MAPR500=MapR 5.0.0(YARN mode) -HIVE_VERSION.ITEM.EMR_4_0_0=EMR 4.0.0 (Hive 1.0.0) -HIVE_VERSION.ITEM.APACHE_1_0_3_EMR=Apache 1.0.3 (Hive 0.8.1) -HIVE_VERSION.ITEM.APACHE_2_4_0_EMR=Apache 2.4.0 (Hive 0.11.0) -HIVE_VERSION.ITEM.APACHE_2_4_0_EMR_0_13_1=Apache 2.4.0 (Hive 0.13.1) -HIVE_VERSION.ITEM.MICROSOFT_HD_INSIGHT_3_1=Microsoft HD Insight 3.1 -HIVE_VERSION.ITEM.MICROSOFT_HD_INSIGHT_3_2=Microsoft HD Insight 3.2 HIVE_SERVER.NAME=Hive Server HIVE_SERVER.ITEM.HIVE=Hive 1 HIVE_SERVER.ITEM.HIVE2=Hive 2 diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_fr.properties b/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_fr.properties index b97737f78d8..b2fcafb8db0 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_fr.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_fr.properties @@ -70,27 +70,7 @@ DISTRIBUTION.ITEM.CUSTOM=Personnalis\u00E9 - Non support\u00E9 DISTRIBUTION.ITEM.AMAZON_EMR=Amazon EMR DISTRIBUTION.ITEM.MICROSOFT_HD_INSIGHT=Microsoft HD Insight HIVE_VERSION.NAME=Version de Hive -HIVE_VERSION.ITEM.HDP_1_2=Hortonworks Data Platform V1.2.0 (Bimota) -HIVE_VERSION.ITEM.HDP_1_3=Hortonworks Data Platform V1.3.0 (Condor) -HIVE_VERSION.ITEM.HDP_2_0=Hortonworks Data Platform V2.0.0 (BigWheel) -HIVE_VERSION.ITEM.HDP_2_1=Hortonworks Data Platform V2.1.0 (Baikal) -HIVE_VERSION.ITEM.HDP_2_2=Hortonworks Data Platform V2.2.0 -HIVE_VERSION.ITEM.HDP_2_3=Hortonworks Data Platform V2.3.2 HIVE_VERSION.ITEM.APACHE_1_0_0=Apache 1.0.0 (Hive 0.9.0) -HIVE_VERSION.ITEM.MAPR2=MapR 2.0.0 -HIVE_VERSION.ITEM.MAPR212=MapR 2.1.2 -HIVE_VERSION.ITEM.MAPR213=MapR 2.1.3 -HIVE_VERSION.ITEM.MAPR301=MapR 3.0.1 -HIVE_VERSION.ITEM.MAPR310=MapR 3.1.0 -HIVE_VERSION.ITEM.MAPR401=MapR 4.0.1 (mode YARN) -HIVE_VERSION.ITEM.MAPR410=MapR 4.1.0 (mode YARN) -HIVE_VERSION.ITEM.MAPR500=MapR 5.0.0 (mode YARN) -HIVE_VERSION.ITEM.EMR_4_0_0=EMR 4.0.0 (Hive 1.0.0) -HIVE_VERSION.ITEM.APACHE_1_0_3_EMR=Apache 1.0.3 (Hive 0.8.1) -HIVE_VERSION.ITEM.APACHE_2_4_0_EMR=Apache 2.4.0 (Hive 0.11.0) -HIVE_VERSION.ITEM.APACHE_2_4_0_EMR_0_13_1=Apache 2.4.0 (Hive 0.13.1) -HIVE_VERSION.ITEM.MICROSOFT_HD_INSIGHT_3_1=Microsoft HD Insight 3.1 -HIVE_VERSION.ITEM.MICROSOFT_HD_INSIGHT_3_2=Microsoft HD Insight 3.2 HIVE_SERVER.NAME=Serveur de Hive HIVE_SERVER.ITEM.HIVE=Hive 1 HIVE_SERVER.ITEM.HIVE2=Hive 2 diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_ja.properties b/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_ja.properties index 64bb88e47fa..4982d1ca181 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_ja.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_ja.properties @@ -70,27 +70,6 @@ DISTRIBUTION.ITEM.CUSTOM=\u30AB\u30B9\u30BF\u30E0 - \u975E\u30B5\u30DD\u30FC\u30 DISTRIBUTION.ITEM.AMAZON_EMR=Amazon EMR DISTRIBUTION.ITEM.MICROSOFT_HD_INSIGHT=Microsoft HD Insight HIVE_VERSION.NAME=HIve\u30D0\u30FC\u30B8\u30E7\u30F3 -HIVE_VERSION.ITEM.HDP_1_2=Hortonworks Data Platform V1.2.0(Bimota) -HIVE_VERSION.ITEM.HDP_1_3=Hortonworks Data Platform V1.3.0(Condor) -HIVE_VERSION.ITEM.HDP_2_0=Hortonworks Data Platform V2.0.0 (BigWheel) -HIVE_VERSION.ITEM.HDP_2_1=Hortonworks Data Platform V2.1.0 (Baikal) -HIVE_VERSION.ITEM.HDP_2_2=Hortonworks Data Platform V2.2.0 -HIVE_VERSION.ITEM.HDP_2_3=Hortonworks Data Platform V2.3.2 -HIVE_VERSION.ITEM.APACHE_1_0_0=Apache 1.0.0 (Hive 0.9.0) -HIVE_VERSION.ITEM.MAPR2=MapR 2.0.0 -HIVE_VERSION.ITEM.MAPR212=MapR 2.1.2 -HIVE_VERSION.ITEM.MAPR213=MapR 2.1.3 -HIVE_VERSION.ITEM.MAPR301=MapR 3.0.1 -HIVE_VERSION.ITEM.MAPR310=MapR 3.1.0 -HIVE_VERSION.ITEM.MAPR401=MapR 4.0.1(YARN\u30E2\u30FC\u30C9) -HIVE_VERSION.ITEM.MAPR410=MapR 4.1.0(YARN\u30E2\u30FC\u30C9) -HIVE_VERSION.ITEM.MAPR500=MapR 5.0.0(YARN\u30E2\u30FC\u30C9) -HIVE_VERSION.ITEM.EMR_4_0_0=EMR 4.0.0 (Hive 1.0.0) -HIVE_VERSION.ITEM.APACHE_1_0_3_EMR=Apache 1.0.3 (Hive 0.8.1) -HIVE_VERSION.ITEM.APACHE_2_4_0_EMR=Apache 2.4.0 (Hive 0.11.0) -HIVE_VERSION.ITEM.APACHE_2_4_0_EMR_0_13_1=Apache 2.4.0 (Hive 0.13.1) -HIVE_VERSION.ITEM.MICROSOFT_HD_INSIGHT_3_1=Microsoft HD Insight 3.1 -HIVE_VERSION.ITEM.MICROSOFT_HD_INSIGHT_3_2=Microsoft HD Insight 3.2 HIVE_SERVER.NAME=Hive\u30B5\u30FC\u30D0\u30FC HIVE_SERVER.ITEM.HIVE=Hive 1 HIVE_SERVER.ITEM.HIVE2=Hive 2 diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_zh_CN.properties b/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_zh_CN.properties index 8ad3e9c342d..87ae175c700 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_zh_CN.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tHiveRow/tHiveRow_messages_zh_CN.properties @@ -77,20 +77,6 @@ HIVE_VERSION.ITEM.HDP_2_1=Hortonworks Data Platform V2.1.0 (Baikal) HIVE_VERSION.ITEM.HDP_2_2=Hortonworks Data Platform V2.2.0 HIVE_VERSION.ITEM.HDP_2_3=Hortonworks Data Platform V2.3.2 HIVE_VERSION.ITEM.APACHE_1_0_0=Apache 1.0.0 (Hive 0.9.0) -HIVE_VERSION.ITEM.MAPR2=MapR 2.0.0 -HIVE_VERSION.ITEM.MAPR212=MapR 2.1.2 -HIVE_VERSION.ITEM.MAPR213=MapR 2.1.3 -HIVE_VERSION.ITEM.MAPR301=MapR 3.0.1 -HIVE_VERSION.ITEM.MAPR310=MapR 3.1.0 -HIVE_VERSION.ITEM.MAPR401=MapR 4.0.1 (YARN \u6A21\u5F0F) -HIVE_VERSION.ITEM.MAPR410=MapR 4.1.0 (YARN \u6A21\u5F0F) -HIVE_VERSION.ITEM.MAPR500=MapR 5.0.0 (YARN \u6A21\u5F0F) -HIVE_VERSION.ITEM.EMR_4_0_0=EMR 4.0.0 (Hive 1.0.0) -HIVE_VERSION.ITEM.APACHE_1_0_3_EMR=Apache 1.0.3 (Hive 0.8.1) -HIVE_VERSION.ITEM.APACHE_2_4_0_EMR=Apache 2.4.0 (Hive 0.11.0) -HIVE_VERSION.ITEM.APACHE_2_4_0_EMR_0_13_1=Apache 2.4.0 (Hive 0.13.1) -HIVE_VERSION.ITEM.MICROSOFT_HD_INSIGHT_3_1=Microsoft HD Insight 3.1 -HIVE_VERSION.ITEM.MICROSOFT_HD_INSIGHT_3_2=Microsoft HD Insight 3.2 HIVE_SERVER.NAME=Hive Server HIVE_SERVER.ITEM.HIVE=Hive 1 HIVE_SERVER.ITEM.HIVE2=Hive 2 diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tOracleSP/tOracleSP_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tOracleSP/tOracleSP_main.javajet index d0094e423de..1e354bc25bf 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tOracleSP/tOracleSP_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tOracleSP/tOracleSP_main.javajet @@ -39,6 +39,7 @@ imports=" CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument; INode node = (INode) codeGenArgument.getArgument(); String cid = node.getUniqueName(); +boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__")); List> spArgs = (List>) ElementParameterParser.getObjectValue(node, "__SP_ARGS__"); @@ -195,7 +196,7 @@ if (canGenerate) { method = "Bytes"; } else if (("Integer").equals(typeToGenerate)) { method = "Int"; - } else { + } else { method = typeToGenerate.substring(0, 1).toUpperCase() + typeToGenerate.substring(1); } @@ -229,12 +230,25 @@ if (canGenerate) { oracle.xdb.XMLType xmlType_<%=cid%> = oracle.xdb.XMLType.createXML(connection_<%=cid%>, <%=inConnectionName%>.<%=argName%>); statement_<%=cid%>.setObject(<%=argIndex%>, xmlType_<%=cid%>); <% - } else { - %> - statement_<%=cid%>.set<%=method%>(<%=argIndex%>, <%=inConnectionName%>.<%=argName%>); - <% - } - + } else if (("String").equals(typeToGenerate) && "CLOB".equals(dbType)) { +%> + java.sql.Clob clob_<%=cid %> = connection_<%=cid %>.createClob(); + clob_<%=cid %>.setString(1, <%=inConnectionName%>.<%=argName%>); + statement_<%=cid%>.setClob(<%=argIndex%>, clob_<%=cid %>); +<% + } else { + if (isLog4jEnabled && ("String").equals(typeToGenerate)) { +%> + if (<%=inConnectionName%>.<%=argName%>.length() > 4000) { + log.warn("String value is too long for VARCHAR type"); + } +<% + } +%> + statement_<%=cid%>.set<%=method%>(<%=argIndex%>, <%=inConnectionName%>.<%=argName%>); +<% + } + if (nullable) { %> } diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_begin.javajet index bea444a7910..e641df2b94e 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_begin.javajet @@ -33,6 +33,9 @@ skeleton="../templates/db_output_bulk.skeleton" boolean useExistingS3Connection = "true".equalsIgnoreCase(ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION_S3__")); String s3ConnectionCid = ElementParameterParser.getValue(node,"__CONNECTION_S3__"); + int driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__DRIVER_VERSION__"))? 2 : 1; + boolean useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); + INode current_node = node; if(useExistingS3Connection){ current_node = NodeUtil.getNodeByUniqueName(node.getProcess(),s3ConnectionCid,true); @@ -80,6 +83,7 @@ skeleton="../templates/db_output_bulk.skeleton" sbuilder_<%=cid%>.append("jdbc:redshift:"); <% if ("SSO".equals(jdbcUrl)){ + %> sbuilder_<%=cid%>.append("iam:"); <% @@ -92,7 +96,7 @@ skeleton="../templates/db_output_bulk.skeleton" .append("/") .append(<%=dbName%>); <% - if(dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { + if(( useStringProperties || driveVersion == 1) && dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { %> sbuilder_<%=cid%>.append("?").append(<%=dbproperties%>); <% @@ -110,8 +114,12 @@ skeleton="../templates/db_output_bulk.skeleton" String dbUser_<%=cid %> = <%=userName%>; String dbPwd_<%=cid %> = decryptedPass_<%=cid%>; <% + if(driveVersion == 2 && !useStringProperties){ - log4jCodeGenerateUtil.connect(node); + log4jCodeGenerateUtil.connectWithProperties(node); + } else { + log4jCodeGenerateUtil.connect(node); + } } String tableAction = ElementParameterParser.getValue(node,"__TABLE_ACTION__"); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_java.xml index fdcb69a1af8..73297d713f9 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_java.xml @@ -39,42 +39,55 @@ SHOW_IF="USE_EXISTING_CONNECTION == 'true'" DYNAMIC_SETTINGS="true" GROUP="DB_CONFIG" /> - + + + + + + + "" - "5439" - "" - "" - Redshift - "" - "" @@ -83,13 +96,37 @@ + SHOW_IF="(USE_EXISTING_CONNECTION == 'false') AND ((USE_STRING_PROPERTIES == 'true') AND (DRIVER_VERSION == 'DRIVER_V2')) OR (DRIVER_VERSION == 'DRIVER_V1')" + GROUP="DB_CONFIG"> "" - + + + + + + + + + + "" @@ -97,7 +134,7 @@ @@ -110,11 +147,11 @@ - + "" - redshift_id @@ -122,7 +159,7 @@ @@ -424,9 +461,10 @@ - + + @@ -457,6 +495,9 @@ + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_messages.properties index f655ce8e0e3..de37453fa16 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftBulkExec/tRedshiftBulkExec_messages.properties @@ -12,6 +12,16 @@ USER.NAME=Username TABLE_ACTION.NAME=Action on table USE_SHARED_CONNECTION.NAME=Use or register a shared DB Connection SHARED_CONNECTION_NAME.NAME=Shared DB Connection Name + +DRIVER_VERSION.NAME=Driver version +DRIVER_VERSION.ITEM.DRIVER_V1=Driver v1 +DRIVER_VERSION.ITEM.DRIVER_V2=Driver v2 + +USE_STRING_PROPERTIES.NAME=Use String JDBC parameters +ENTRY_PROPERTIES.NAME=Additional JDBC Parameters +ENTRY_PROPERTIES.ITEM.KEY=Key +ENTRY_PROPERTIES.ITEM.VALUE=Value + TABLE_ACTION.ITEM.NONE=None TABLE_ACTION.ITEM.CREATE=Create table TABLE_ACTION.ITEM.CREATE_IF_NOT_EXISTS=Create table if not exists diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_begin.javajet index 67a000c4b8e..3199e1a1a74 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_begin.javajet @@ -3,19 +3,28 @@ imports=" org.talend.core.model.process.INode org.talend.core.model.process.ElementParameterParser org.talend.designer.codegen.config.CodeGeneratorArgument + java.util.List + java.util.Map " %> <%@ include file="../templates/DB/HelpClass/HelpClass.javajet"%> <% class ConnectionUtil extends DefaultConnectionUtil{ + + int driveVersion; + Boolean useStringProperties ; + String logLevel; public void createURL(INode node) { super.createURL(node); boolean useLogFile= "true".equals(ElementParameterParser.getValue(node, "__USE_LOG_FILE__")); - String logLevel= ElementParameterParser.getValue(node, "__LOG_LEVEL__"); String logFile= ElementParameterParser.getValue(node, "__LOG_FILE__"); String jdbcUrl = ElementParameterParser.getValue(node, "__JDBC_URL__"); + driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__DRIVER_VERSION__"))? 2 : 1; + useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); + logLevel= ElementParameterParser.getValue(node, "__LOG_LEVEL__"); + if(!logLevel.equals("0")){ if (useLogFile) { @@ -43,11 +52,16 @@ imports=" .append(":") .append(<%=dbport%>) .append("/") - .append(<%=dbname%>) - .append("?loglevel=") - .append(<%=logLevel%>); + .append(<%=dbname%>); + + <% + if( useStringProperties || driveVersion == 1){ + %> + + sbuilder_<%=cid%>.append("?loglevel=").append(<%=logLevel%>); <% - if(dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { + } + if((driveVersion == 1 || useStringProperties) && dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { %> sbuilder_<%=cid%>.append("&").append(<%=dbproperties%>); <% @@ -56,6 +70,32 @@ imports=" String url_<%=cid%> = sbuilder_<%=cid%>.toString(); <% } + + public void createConnection(INode node) { + if(driveVersion == 2 && !useStringProperties){ + List> properties = (List>)ElementParameterParser.getObjectValue(node, "__ENTRY_PROPERTIES__"); + %> + + java.util.Properties properties_<%=cid%> = new java.util.Properties(); + properties_<%=cid%>.setProperty("user",dbUser_<%=cid%>); + properties_<%=cid%>.setProperty("password",dbPwd_<%=cid%>); + <% + for(Map entry : properties){ + %> + properties_<%=cid%>.setProperty(<%=entry.get("KEY")%>,<%=entry.get("VALUE")%>); + <%}%> + properties_<%=cid%>.setProperty("loglevel","<%=logLevel%>"); + + conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid%>,properties_<%=cid%>); + <% + } else { + + %> + conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid%>,dbUser_<%=cid%>,dbPwd_<%=cid%>); + <% + + } + } public String getDirverClassName(INode node){ return "com.amazon.redshift.jdbc42.Driver"; diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_java.xml index 65646b6e2c4..08cb398f74c 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_java.xml @@ -44,10 +44,21 @@ REPOSITORY_VALUE="DATABASE:REDSHIFT" /> + + + + + + + @@ -57,7 +68,7 @@ @@ -67,7 +78,7 @@ @@ -77,7 +88,7 @@ @@ -87,7 +98,7 @@ "" @@ -96,7 +107,7 @@ @@ -106,25 +117,46 @@ "" + + + "" + + + + + + + @@ -134,7 +166,7 @@ @@ -142,7 +174,7 @@ @@ -196,9 +228,13 @@ - + + + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_messages.properties index c4d611a2913..c0e87f7cdb2 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftConnection/tRedshiftConnection_messages.properties @@ -22,3 +22,12 @@ PROPERTIES.NAME=Additional JDBC Parameters JDBC_URL.NAME=JDBC url JDBC_URL.ITEM.STANDARD=Standard JDBC_URL.ITEM.SSO=SSO + +DRIVER_VERSION.NAME=Driver version +DRIVER_VERSION.ITEM.DRIVER_V1=Driver v1 +DRIVER_VERSION.ITEM.DRIVER_V2=Driver v2 + +USE_STRING_PROPERTIES.NAME=Use String JDBC parameters +ENTRY_PROPERTIES.NAME=Additional JDBC Parameters +ENTRY_PROPERTIES.ITEM.KEY=Key +ENTRY_PROPERTIES.ITEM.VALUE=Value \ No newline at end of file diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_begin.javajet index 39668d96033..beac8f1349f 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_begin.javajet @@ -17,12 +17,19 @@ imports=" class DBInputBeginUtil extends DefaultDBInputUtil{ + int driveVersion; + Boolean useStringProperties ; + String logLevel; + public void setURL(INode node) { boolean useLogFile= "true".equals(ElementParameterParser.getValue(node, "__USE_LOG_FILE__")); String logLevel= ElementParameterParser.getValue(node, "__LOG_LEVEL__"); String logFile= ElementParameterParser.getValue(node, "__LOG_FILE__"); String jdbcUrl = ElementParameterParser.getValue(node, "__JDBC_URL__"); + driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__DRIVER_VERSION__"))? 2 : 1; + useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); + logLevel= ElementParameterParser.getValue(node, "__LOG_LEVEL__"); if(!logLevel.equals("0")){ if (useLogFile) { @@ -51,11 +58,16 @@ imports=" .append(":") .append(<%=dbport%>) .append("/") - .append(<%=dbname%>) - .append("?loglevel=") - .append(<%=logLevel%>); + .append(<%=dbname%>); + + <% + if( useStringProperties || driveVersion == 1){ + %> + + sbuilder_<%=cid%>.append("?loglevel=").append(<%=logLevel%>); <% - if(dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { + } + if(( useStringProperties || driveVersion == 1) && dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { %> sbuilder_<%=cid%>.append("&").append(<%=dbproperties%>); <% @@ -64,19 +76,48 @@ imports=" String url_<%=cid%> = sbuilder_<%=cid%>.toString(); <% } + + public void createConnection(INode node) { + driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__DRIVER_VERSION__"))? 2 : 1; + useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); + %> + //<%=driveVersion%> useStringProperties: <%=useStringProperties%> + <% + + + if(driveVersion == 2 && !useStringProperties){ + super.createConnection(node,2);//without connection + List> properties = (List>)ElementParameterParser.getObjectValue(node, "__ENTRY_PROPERTIES__"); + %> + + java.util.Properties properties_<%=cid%> = new java.util.Properties(); + properties_<%=cid%>.setProperty("user",dbUser_<%=cid%>); + properties_<%=cid%>.setProperty("password",dbPwd_<%=cid%>); + <% + for(Map entry : properties){ + %> + properties_<%=cid%>.setProperty(<%=entry.get("KEY")%>,<%=entry.get("VALUE")%>); + <%}%> + properties_<%=cid%>.setProperty("loglevel","<%=logLevel%>"); + + conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid%>,properties_<%=cid%>); + + + <% + log4jCodeGenerateUtil.connect_end(); + }else{ + super.createConnection(node); + } + String useCursor= ElementParameterParser.getValue(node, "__USE_CURSOR__"); + if(("true").equals(useCursor)) { + log4jCodeGenerateUtil.autoCommit(node,false); + } + } public String getDirverClassName(INode node){ return "com.amazon.redshift.jdbc42.Driver"; } - - public void createConnection(INode node) { - String jdbcUrl = ElementParameterParser.getValue(node, "__JDBC_URL__"); - super.createConnection(node); - String useCursor= ElementParameterParser.getValue(node, "__USE_CURSOR__"); - if(("true").equals(useCursor)) { - log4jCodeGenerateUtil.autoCommit(node,false); - } - } + public void createStatement(INode node) { super.createStatement(node); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_java.xml index 09c080f7dd2..279c31a1320 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_java.xml @@ -44,10 +44,22 @@ SHOW_IF="USE_EXISTING_CONNECTION == 'false'" /> + + + + + + + false @@ -56,7 +68,7 @@ NAME="CONNECTION" FIELD="COMPONENT_LIST" REQUIRED="true" FILTER="tRedshiftConnection" - NUM_ROW="2" + NUM_ROW="12" SHOW_IF="USE_EXISTING_CONNECTION == 'true'" DYNAMIC_SETTINGS="true" /> @@ -64,7 +76,7 @@ @@ -85,7 +97,7 @@ @@ -117,7 +129,7 @@ + > "" + + + + + + + + + + "" @@ -156,7 +190,7 @@ "" @@ -164,7 +198,7 @@ "" @@ -172,7 +206,7 @@ "" @@ -180,7 +214,7 @@ "select id, name from employee" @@ -189,7 +223,7 @@ redshift_id @@ -279,9 +313,13 @@ - + + + @@ -290,6 +328,7 @@ + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_messages.properties index e4ff94fe525..839ad47d7a4 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftInput/tRedshiftInput_messages.properties @@ -46,3 +46,12 @@ PROPERTIES.NAME=Additional JDBC Parameters JDBC_URL.NAME=JDBC url JDBC_URL.ITEM.STANDARD=Standard JDBC_URL.ITEM.SSO=SSO + +DRIVER_VERSION.NAME=Driver version +DRIVER_VERSION.ITEM.DRIVER_V1=Driver v1 +DRIVER_VERSION.ITEM.DRIVER_V2=Driver v2 + +USE_STRING_PROPERTIES.NAME=Use String JDBC parameters +ENTRY_PROPERTIES.NAME=Additional JDBC Parameters +ENTRY_PROPERTIES.ITEM.KEY=Key +ENTRY_PROPERTIES.ITEM.VALUE=Value diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_begin.javajet index ee0ccfc0aac..614209da81b 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_begin.javajet @@ -198,6 +198,8 @@ if(("true").equals(useExistingConn)) { %> <% } else { + int driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__DRIVER_VERSION__"))? 2 : 1; + boolean useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); %> java.lang.Class.forName("com.amazon.redshift.jdbc42.Driver"); <%dbLog.conn().logJDBCDriver(dbLog.str("com.amazon.redshift.jdbc42.Driver"));%> @@ -217,7 +219,7 @@ if(("true").equals(useExistingConn)) { .append("/") .append(<%=dbname%>); <% - if(dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { + if(( useStringProperties || driveVersion == 1) && dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { %> sbuilder_<%=cid%>.append("?").append(<%=dbproperties%>); <% @@ -232,7 +234,27 @@ if(("true").equals(useExistingConn)) { <%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%> String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>; + <% + if(driveVersion == 2 && !useStringProperties){ + List> properties = (List>)ElementParameterParser.getObjectValue(node, "__ENTRY_PROPERTIES__"); + %> + + java.util.Properties properties_<%=cid%> = new java.util.Properties(); + properties_<%=cid%>.setProperty("user",dbUser_<%=cid%>); + properties_<%=cid%>.setProperty("password",dbPwd_<%=cid%>); + <% + for(Map entry : properties){ + %> + properties_<%=cid%>.setProperty(<%=entry.get("KEY")%>,<%=entry.get("VALUE")%>); + <%}%> + + conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid%>,properties_<%=cid%>); + <% + }else{ + + %> conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>,dbUser_<%=cid%>,dbPwd_<%=cid%>); + <%}%> <%dbLog.conn().connTry(dbLog.var("url"), dbLog.var("dbUser"));%> <%dbLog.conn().connDone(dbLog.var("url"));%> diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_java.xml index 56803ecb10a..50e68a38dde 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_java.xml @@ -56,6 +56,18 @@ false + + + + + + + @@ -111,7 +123,7 @@ @@ -121,7 +133,7 @@ + > "" + + + + + + + + + + "" @@ -161,7 +194,7 @@ @@ -177,7 +210,7 @@ @@ -191,7 +224,7 @@ "" @@ -200,7 +233,7 @@ NAME="SCHEMA_REJECT" FIELD="SCHEMA_TYPE" REQUIRED="true" - NUM_ROW="9" + NUM_ROW="40" CONTEXT="REJECT" SHOW="true"> @@ -212,7 +245,7 @@ false @@ -220,7 +253,7 @@ redshift_id @@ -388,9 +421,13 @@ - + + + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_messages.properties index edbbf88ac2f..3c7e4457ee1 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutput/tRedshiftOutput_messages.properties @@ -88,3 +88,12 @@ JDBC_URL.ITEM.STANDARD=Standard JDBC_URL.ITEM.SSO=SSO USE_ALTERNATE_SCHEMA.NAME=Use alternate schema ALTERNATE_SCHEMA.NAME=Schema + +DRIVER_VERSION.NAME=Driver version +DRIVER_VERSION.ITEM.DRIVER_V1=Driver v1 +DRIVER_VERSION.ITEM.DRIVER_V2=Driver v2 + +USE_STRING_PROPERTIES.NAME=Use String JDBC parameters +ENTRY_PROPERTIES.NAME=Additional JDBC Parameters +ENTRY_PROPERTIES.ITEM.KEY=Key +ENTRY_PROPERTIES.ITEM.VALUE=Value \ No newline at end of file diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutputBulkExec/tRedshiftOutputBulkExec_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutputBulkExec/tRedshiftOutputBulkExec_java.xml index dd1a4fea766..28e7b250294 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutputBulkExec/tRedshiftOutputBulkExec_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutputBulkExec/tRedshiftOutputBulkExec_java.xml @@ -38,37 +38,51 @@ SHOW_IF="USE_EXISTING_CONNECTION == 'true'" DYNAMIC_SETTINGS="true" GROUP="DB_CONFIG" /> - + + + + + + + "" - "5439" - "" - "" - Redshift - "" - "" @@ -76,19 +90,41 @@ "" - + + + + + + + + + + "" - @@ -100,16 +136,16 @@ - + "" - redshift_id - "__COMP_DEFAULT_FILE_DIR__/redshift_bulk.txt" @@ -598,6 +634,9 @@ + + + @@ -675,15 +714,19 @@ - + + + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutputBulkExec/tRedshiftOutputBulkExec_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutputBulkExec/tRedshiftOutputBulkExec_messages.properties index 83721e596e9..2316843117e 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutputBulkExec/tRedshiftOutputBulkExec_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftOutputBulkExec/tRedshiftOutputBulkExec_messages.properties @@ -182,3 +182,12 @@ ROLE_TABLE.ITEM.ROLE_ARN=Role ARN JDBC_URL.NAME=JDBC url JDBC_URL.ITEM.STANDARD=Standard JDBC_URL.ITEM.SSO=SSO + +DRIVER_VERSION.NAME=Driver version +DRIVER_VERSION.ITEM.DRIVER_V1=Driver v1 +DRIVER_VERSION.ITEM.DRIVER_V2=Driver v2 + +USE_STRING_PROPERTIES.NAME=Use String JDBC parameters +ENTRY_PROPERTIES.NAME=Additional JDBC Parameters +ENTRY_PROPERTIES.ITEM.KEY=Key +ENTRY_PROPERTIES.ITEM.VALUE=Value \ No newline at end of file diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_begin.javajet index 98d19aa56ae..7dd71d7d5de 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_begin.javajet @@ -4,6 +4,7 @@ imports=" org.talend.core.model.process.ElementParameterParser org.talend.designer.codegen.config.CodeGeneratorArgument java.util.List + java.util.Map java.util.ArrayList " %> @@ -11,6 +12,10 @@ imports=" <% class DBRowBeginUtil extends DefaultDBRowUtil{ + + int driveVersion; + Boolean useStringProperties ; + String logLevel; public void beforeComponentProcess(INode node){ super.beforeComponentProcess(node); @@ -19,6 +24,9 @@ imports=" public void setURL(INode node) { String jdbcUrl = ElementParameterParser.getValue(node, "__JDBC_URL__"); + driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__DRIVER_VERSION__"))? 2 : 1; + useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); + %> StringBuilder sbuilder_<%=cid%> = new StringBuilder(); sbuilder_<%=cid%>.append("jdbc:redshift:"); @@ -36,7 +44,7 @@ imports=" .append("/") .append(<%=dbname%>); <% - if(dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { + if(( useStringProperties || driveVersion == 1) && dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { %> sbuilder_<%=cid%>.append("?").append(<%=dbproperties%>); <% @@ -45,6 +53,30 @@ imports=" String url_<%=cid%> = sbuilder_<%=cid%>.toString(); <% } + + public void newConnection(INode node) { + if(driveVersion == 2 && !useStringProperties){ + List> properties = (List>)ElementParameterParser.getObjectValue(node, "__ENTRY_PROPERTIES__"); + %> + java.util.Properties properties_<%=cid%> = new java.util.Properties(); + properties_<%=cid%>.setProperty("user",dbUser_<%=cid%>); + properties_<%=cid%>.setProperty("password",dbPwd_<%=cid%>); + <% + for(Map entry : properties){ + %> + properties_<%=cid%>.setProperty(<%=entry.get("KEY")%>,<%=entry.get("VALUE")%>); + <%}%> + + conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid%>,properties_<%=cid%>); + <% + }else{ + + %> + conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid%>,dbUser_<%=cid%>,dbPwd_<%=cid%>); + <% + + } + } public String getDirverClassName(INode node){ return "com.amazon.redshift.jdbc42.Driver"; diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_java.xml index 4d36dfed0d3..68602fbdf3c 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_java.xml @@ -63,10 +63,22 @@ DYNAMIC_SETTINGS="true" /> + + + + + + + @@ -109,7 +121,7 @@ @@ -119,7 +131,7 @@ + > "" + + + + + + + + + + "" @@ -159,7 +192,7 @@ NAME="SCHEMA_REJECT" FIELD="SCHEMA_TYPE" REQUIRED="true" - NUM_ROW="7" + NUM_ROW="25" CONTEXT="REJECT" SHOW="true">
@@ -171,7 +204,7 @@ "" @@ -180,7 +213,7 @@ "" @@ -188,7 +221,7 @@ "select id, name from employee" @@ -196,7 +229,7 @@ false @@ -297,9 +330,13 @@ - + + + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_messages.properties index 9d433129e05..16d0c9e1db6 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftRow/tRedshiftRow_messages.properties @@ -61,3 +61,12 @@ PROPERTIES.NAME=Additional JDBC Parameters JDBC_URL.NAME=JDBC url JDBC_URL.ITEM.STANDARD=Standard JDBC_URL.ITEM.SSO=SSO + +DRIVER_VERSION.NAME=Driver version +DRIVER_VERSION.ITEM.DRIVER_V1=Driver v1 +DRIVER_VERSION.ITEM.DRIVER_V2=Driver v2 + +USE_STRING_PROPERTIES.NAME=Use String JDBC parameters +ENTRY_PROPERTIES.NAME=Additional JDBC Parameters +ENTRY_PROPERTIES.ITEM.KEY=Key +ENTRY_PROPERTIES.ITEM.VALUE=Value diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_begin.javajet index 73ab681b9a7..fdd65429ee2 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_begin.javajet @@ -50,6 +50,8 @@ imports=" <% log4jCodeGenerateUtil.useExistConnection(node); } else { + int driveVersion = "DRIVER_V2".equals(ElementParameterParser.getValue(node, "__DRIVER_VERSION__"))? 2 : 1; + boolean useStringProperties = "true".equals(ElementParameterParser.getValue(node, "__USE_STRING_PROPERTIES__")); %> String driverClass_<%=cid%> = "com.amazon.redshift.jdbc42.Driver"; Class.forName(driverClass_<%=cid%>).newInstance(); @@ -69,7 +71,7 @@ imports=" .append("/") .append(<%=dbName%>); <% - if(dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { + if(( useStringProperties || driveVersion == 1) && dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) { %> sbuilder_<%=cid%>.append("?").append(<%=dbproperties%>); <% @@ -86,8 +88,13 @@ imports=" <%}%> String dbUser_<%=cid %> = <%=userName%>; String dbPwd_<%=cid %> = decryptedPass_<%=cid%>; -<% - log4jCodeGenerateUtil.connect(node); +<% + if(driveVersion == 2 && !useStringProperties){ + List> properties = (List>)ElementParameterParser.getObjectValue(node, "__ENTRY_PROPERTIES__"); + log4jCodeGenerateUtil.connectWithProperties(node); + } else { + log4jCodeGenerateUtil.connect(node); + } } boolean log4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__")); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_java.xml index ada619d9ee7..e372304df18 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_java.xml @@ -38,22 +38,35 @@ SHOW_IF="USE_EXISTING_CONNECTION == 'true'" DYNAMIC_SETTINGS="true" GROUP="DB_CONFIG" /> - + + + + + + + "" - "5439" - "" - "" @@ -63,12 +76,12 @@ Redshift - "" - "" @@ -76,26 +89,48 @@ "" - + + + + + + + + + + "" - + "" "" @@ -104,29 +139,29 @@ "select id, name from employee" - redshift_id + NUM_ROW="460" GROUP="S3_CONFIG" SHOW_IF="ASSUME_ROLE == 'false'"> false + NUM_ROW="460" SHOW_IF="USE_EXISTING_CONNECTION_S3 == 'true'" GROUP="S3_CONFIG"/> @@ -171,7 +206,7 @@ @@ -181,7 +216,7 @@ @@ -283,9 +318,13 @@ - + + + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_messages.properties b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_messages.properties index ba8a1980e5a..02327632421 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_messages.properties +++ b/main/plugins/org.talend.designer.components.localprovider/components/tRedshiftUnload/tRedshiftUnload_messages.properties @@ -49,3 +49,13 @@ ROLE_TABLE.ITEM.ROLE_ARN=Role ARN JDBC_URL.NAME=JDBC url JDBC_URL.ITEM.STANDARD=Standard JDBC_URL.ITEM.SSO=SSO + + +DRIVER_VERSION.NAME=Driver version +DRIVER_VERSION.ITEM.DRIVER_V1=Driver v1 +DRIVER_VERSION.ITEM.DRIVER_V2=Driver v2 + +USE_STRING_PROPERTIES.NAME=Use String JDBC parameters +ENTRY_PROPERTIES.NAME=Additional JDBC Parameters +ENTRY_PROPERTIES.ITEM.KEY=Key +ENTRY_PROPERTIES.ITEM.VALUE=Value diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPClose/tSCPClose_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPClose/tSCPClose_main.javajet index c0552abde99..a65ff7760fc 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPClose/tSCPClose_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPClose/tSCPClose_main.javajet @@ -11,13 +11,12 @@ imports=" INode node = (INode)codeGenArgument.getArgument(); String cid = node.getUniqueName(); String connection = ElementParameterParser.getValue(node,"__CONNECTION__"); - String conn = "conn_" + connection; boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__")); %> <%if(isLog4jEnabled){%> log.info("<%=cid%> - Closing the connection '<%= connection %>' to the server."); <%}%> - closeCloseableConnections("<%=conn%>"); + closeCloseableConnections("session_<%=connection%>","conn_<%=connection%>"); <%if(isLog4jEnabled){%> log.info("<%=cid%> - Connection '<%= connection %>' to the server closed."); <%}%> diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPConnection/tSCPConnection_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPConnection/tSCPConnection_begin.javajet index 82bcff88a9f..9811e04210c 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPConnection/tSCPConnection_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPConnection/tSCPConnection_begin.javajet @@ -144,13 +144,12 @@ imports=" }else{ throw se_<%=cid%>; } - }finally{ - session_<%=cid%>.close(); } globalMap.put("conn_<%=cid%>",client_<%=cid%>); + globalMap.put("session_<%=cid%>",session_<%=cid%>); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPDelete/tSCPDelete_end.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPDelete/tSCPDelete_end.javajet index 9963df1f3d8..e4fb0a39703 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPDelete/tSCPDelete_end.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPDelete/tSCPDelete_end.javajet @@ -16,6 +16,7 @@ imports=" <%if(isLog4jEnabled){%> log.info("<%=cid%> - Closing the connection to the server."); <%}%> + session_<%=cid%>.close(); client_<%=cid%>.close(); <%if(isLog4jEnabled){%> log.info("<%=cid%> - Connection to the server closed."); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPDelete/tSCPDelete_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPDelete/tSCPDelete_main.javajet index 1b715ca8f29..8ef160c3bf6 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPDelete/tSCPDelete_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPDelete/tSCPDelete_main.javajet @@ -31,30 +31,6 @@ imports=" } %> StringBuilder command_<%=cid %> = new StringBuilder("rm -f"); - /* open a session */ - - <%if(isLog4jEnabled){%> - log.info("<%=cid%> - Open up a session."); - log.debug("<%=cid%> - execute the command: " + command_<%=cid %>.toString()); - <%}%> - - session_<%=cid%> = client_<%=cid%>.connect(username_<%=cid%>, hostname_<%=cid%>, port_<%=cid%>).verify().getClientSession(); - try { - session_<%=cid%>.auth().verify(); - }catch (org.apache.sshd.common.SshException se_<%=cid%>){ - globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); - <% - if (("PUBLICKEY").equals(authMethod)) { - %> - java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); - <%}%> - if(14 == se_<%=cid%>.getDisconnectCode()){ - throw new IllegalArgumentException("Authentication failed."); - }else{ - throw se_<%=cid%>; - } - } - <% @@ -85,7 +61,7 @@ imports=" org.apache.sshd.client.channel.ClientChannelEvent.CLOSED,org.apache.sshd.client.channel.ClientChannelEvent.EXIT_STATUS), 0L); exit_code_<%=cid%> = channel_<%=cid%>.getExitStatus(); channel_<%=cid%>.close(); - session_<%=cid%>.close(); + <%if(isLog4jEnabled){%> log.debug("Channel Events: "+ java.util.Arrays.toString(clientChannelEvents_<%=cid %>.toArray())); <%}%> diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_begin.javajet index 2c07f581f5d..9112a2c212b 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_begin.javajet @@ -21,12 +21,13 @@ imports=" String privatekey = ElementParameterParser.getValue(node,"__PRIVATEKEY__"); String password = ElementParameterParser.getValue(node,"__PASSWORD__"); String passphrase = ElementParameterParser.getValue(node,"__PASSPHRASE__"); + String connection = ElementParameterParser.getValue(node, "__CONNECTION__"); %> /* Create a connection instance */ <% String useExistingConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"); if(("true").equals(useExistingConn)){ - String connection = ElementParameterParser.getValue(node, "__CONNECTION__"); + String conn= "conn_" + connection; INode connectionNode = NodeUtil.getNodeByUniqueName(node.getProcess(), connection); host = ElementParameterParser.getValue(connectionNode, "__HOST__"); @@ -138,13 +139,40 @@ imports=" <%}%> client_<%=cid%>.start(); <% - }//if(isExistingConn) + }//if(useExistingConn) %> - /* Create a session */ - org.apache.sshd.client.session.ClientSession session_<%=cid%> = null; + int port_<%=cid%> = Integer.parseInt(<%=port %>+""); StringBuilder stringStdout_<%=cid%> =new StringBuilder(); StringBuilder stringStderr_<%=cid%> =new StringBuilder(); Integer exit_code_<%=cid%> = null; + + + /* open a session */ + + + <%if(("true").equals(useExistingConn)){%> + org.apache.sshd.client.session.ClientSession session_<%=cid%> = (org.apache.sshd.client.session.ClientSession)globalMap.get("session_<%=connection%>"); + <%}else{%> + <%if(isLog4jEnabled){%> + log.info("<%=cid%> - Open up a session."); + <%}%> + org.apache.sshd.client.session.ClientSession session_<%=cid%> = client_<%=cid%>.connect(username_<%=cid%>, hostname_<%=cid%>, port_<%=cid%>).verify().getClientSession(); + try { + session_<%=cid%>.auth().verify(); + }catch (org.apache.sshd.common.SshException se_<%=cid%>){ + globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); + <% + if (("PUBLICKEY").equals(authMethod)) { + %> + java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); + <%}%> + if(14 == se_<%=cid%>.getDisconnectCode()){ + throw new IllegalArgumentException("Authentication failed."); + }else{ + throw se_<%=cid%>; + } + } + <%}%> diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_end.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_end.javajet index 8ae436f4ddd..335d5faf8ba 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_end.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_end.javajet @@ -17,6 +17,7 @@ imports=" <%if(isLog4jEnabled){%> log.info("<%=cid%> - Closing the connection to the server."); <%}%> + session_<%=cid%>.close(); client_<%=cid%>.close(); <%if(isLog4jEnabled){%> log.info("<%=cid%> - Connection to the server closed."); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_main.javajet index b56d1381e63..3f7876be2ef 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileExists/tSCPFileExists_main.javajet @@ -45,29 +45,10 @@ imports=" } globalMap.put("<%=cid %>_FILENAME", <%=fileExists %>); - /* open a session */ + <%if(isLog4jEnabled){%> + log.debug("<%=cid%> - execute the command: " + command_<%=cid %>.toString()); + <%}%> - <%if(isLog4jEnabled){%> - log.info("<%=cid%> - Open up a session."); - log.debug("<%=cid%> - execute the command: " + command_<%=cid %>.toString()); - <%}%> - - session_<%=cid%> = client_<%=cid%>.connect(username_<%=cid%>, hostname_<%=cid%>, port_<%=cid%>).verify().getClientSession(); - try { - session_<%=cid%>.auth().verify(); - }catch (org.apache.sshd.common.SshException se_<%=cid%>){ - globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); - <% - if (("PUBLICKEY").equals(authMethod)) { - %> - java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); - <%}%> - if(14 == se_<%=cid%>.getDisconnectCode()){ - throw new IllegalArgumentException("Authentication failed."); - }else{ - throw se_<%=cid%>; - } - } org.apache.sshd.client.channel.ClientChannel channel_<%=cid %> = session_<%=cid %>.createExecChannel((command_<%=cid %>).toString()); java.io.ByteArrayOutputStream stdout_<%=cid %> = new java.io.ByteArrayOutputStream(); java.io.ByteArrayOutputStream stderr_<%=cid %> = new java.io.ByteArrayOutputStream(); @@ -79,7 +60,7 @@ imports=" org.apache.sshd.client.channel.ClientChannelEvent.CLOSED,org.apache.sshd.client.channel.ClientChannelEvent.EXIT_STATUS), 0L); exit_code_<%=cid%> = channel_<%=cid%>.getExitStatus(); channel_<%=cid%>.close(); - session_<%=cid%>.close(); + <%if(isLog4jEnabled){%> log.debug("Channel Events: "+ java.util.Arrays.toString(clientChannelEvents_<%=cid %>.toArray())); <%}%> @@ -106,3 +87,6 @@ imports=" <%}%> globalMap.put("<%=cid %>_STATUS", stringStderr_<%=cid %>.toString()); } + + stringStdout_<%=cid%> =new StringBuilder(); + stringStderr_<%=cid%> =new StringBuilder(); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileList/tSCPFileList_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileList/tSCPFileList_begin.javajet index b3b380d3f74..08c10b5c180 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileList/tSCPFileList_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileList/tSCPFileList_begin.javajet @@ -23,13 +23,14 @@ imports=" String password = ElementParameterParser.getValue(node,"__PASSWORD__"); String passphrase = ElementParameterParser.getValue(node,"__PASSPHRASE__"); String commandSeparator = ElementParameterParser.getValue(node, "__COMMANDSEPARATOR__"); - List> filelist = (List>)ElementParameterParser.getObjectValue(node, "__FILELIST__"); + List> filelist = (List>)ElementParameterParser.getObjectValue(node, "__FILELIST__"); + String connection = ElementParameterParser.getValue(node, "__CONNECTION__"); %> /* Create a connection instance */ <% String useExistingConn = ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"); if(("true").equals(useExistingConn)){ - String connection = ElementParameterParser.getValue(node, "__CONNECTION__"); + INode connectionNode = NodeUtil.getNodeByUniqueName(node.getProcess(), connection); host = ElementParameterParser.getValue(connectionNode, "__HOST__"); port = ElementParameterParser.getValue(connectionNode, "__PORT__"); @@ -141,39 +142,35 @@ imports=" %> client_<%=cid%>.start(); + int port_<%=cid%> = Integer.parseInt(<%=port %>+""); - /* Create a session */ - org.apache.sshd.client.session.ClientSession session_<%=cid%> = null; + /* open a session */ - /* Now connect */ - <%if(isLog4jEnabled){%> - log.info("<%=cid%> - Connection to '" +<%=host%> + "' has succeeded."); - <%}%> - - /* open a session */ - - <%if(isLog4jEnabled){%> - log.info("<%=cid%> - Authentication using a password."); - <%}%> - - session_<%=cid%> = client_<%=cid%>.connect(<%=user%>, <%=host%>, Integer.parseInt(<%=port %>+"")).verify().getClientSession(); - try { - session_<%=cid%>.auth().verify(); - }catch (org.apache.sshd.common.SshException se_<%=cid%>){ - globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); - <% - if (("PUBLICKEY").equals(authMethod)) { - %> - java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); - <%}%> - if(14 == se_<%=cid%>.getDisconnectCode()){ - throw new IllegalArgumentException("Authentication failed."); - }else{ - throw se_<%=cid%>; + <%if(("true").equals(useExistingConn)){%> + org.apache.sshd.client.session.ClientSession session_<%=cid%> = (org.apache.sshd.client.session.ClientSession)globalMap.get("session_<%=connection%>"); + <%}else{%> + <%if(isLog4jEnabled){%> + log.info("<%=cid%> - Open up a session."); + <%}%> + org.apache.sshd.client.session.ClientSession session_<%=cid%> = client_<%=cid%>.connect(username_<%=cid%>, hostname_<%=cid%>, port_<%=cid%>).verify().getClientSession(); + try { + session_<%=cid%>.auth().verify(); + }catch (org.apache.sshd.common.SshException se_<%=cid%>){ + globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); + <% + if (("PUBLICKEY").equals(authMethod)) { + %> + java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); + <%}%> + if(14 == se_<%=cid%>.getDisconnectCode()){ + throw new IllegalArgumentException("Authentication failed."); + }else{ + throw se_<%=cid%>; + } } - } + <%}%> //execute the command //initial the command @@ -205,7 +202,6 @@ imports=" org.apache.sshd.client.channel.ClientChannelEvent.CLOSED,org.apache.sshd.client.channel.ClientChannelEvent.EXIT_STATUS), 0L); exit_code_<%=cid%> = channel_<%=cid%>.getExitStatus(); channel_<%=cid%>.close(); - session_<%=cid%>.close(); <%if(isLog4jEnabled){%> log.debug("Channel Events: "+ java.util.Arrays.toString(clientChannelEvents_<%=cid %>.toArray())); <%}%> diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileList/tSCPFileList_end.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileList/tSCPFileList_end.javajet index bc2c80fd1a4..ad4b66b7c57 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileList/tSCPFileList_end.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPFileList/tSCPFileList_end.javajet @@ -21,6 +21,7 @@ imports=" <%if(isLog4jEnabled){%> log.info("<%=cid%> - Closing the connection to the server."); <%}%> + session_<%=cid%>.close(); client_<%=cid%>.close(); <%if(isLog4jEnabled){%> log.info("<%=cid%> - Connection to the server closed."); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPGet/tSCPGet_end.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPGet/tSCPGet_end.javajet index 25079923fd0..837a1b2fb0f 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPGet/tSCPGet_end.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPGet/tSCPGet_end.javajet @@ -17,6 +17,7 @@ imports=" <%if(isLog4jEnabled){%> log.info("<%=cid%> - Closing the connection to the server."); <%}%> + session_<%=cid%>.close(); client_<%=cid%>.close(); <%if(isLog4jEnabled){%> log.info("<%=cid%> - Connection to the server closed."); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPGet/tSCPGet_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPGet/tSCPGet_main.javajet index c9196bcfdc9..3ff29e647ff 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPGet/tSCPGet_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPGet/tSCPGet_main.javajet @@ -25,28 +25,7 @@ imports=" authMethod = ElementParameterParser.getValue(connectionNode,"__AUTH_METHOD__"); } %> -/* open a session */ - <%if(isLog4jEnabled){%> - log.info("<%=cid%> - Open up a session."); - <%}%> - - session_<%=cid%> = client_<%=cid%>.connect(username_<%=cid%>, hostname_<%=cid%>, port_<%=cid%>).verify().getClientSession(); - try { - session_<%=cid%>.auth().verify(); - }catch (org.apache.sshd.common.SshException se_<%=cid%>){ - globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); - <% - if (("PUBLICKEY").equals(authMethod)) { - %> - java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); - <%}%> - if(14 == se_<%=cid%>.getDisconnectCode()){ - throw new IllegalArgumentException("Authentication failed."); - }else{ - throw se_<%=cid%>; - } - } org.apache.sshd.scp.client.ScpClientCreator instance_<%=cid%> = org.talend.components.talendscp.TalendScpClientCreator.INSTANCE; org.apache.sshd.scp.client.ScpClient scp_<%=cid%> = instance_<%=cid%>.createScpClient(session_<%=cid%>); @@ -166,7 +145,7 @@ globalMap.put("<%=cid%>_ERROR_MESSAGE",e_<%=cid%>.getMessage()); scp_<%=cid%>.download("\""+sourceFile_<%=cid %>+"\"",out_<%=cid %>); } catch(java.lang.Exception e_<%=cid%>) { -globalMap.put("<%=cid%>_ERROR_MESSAGE",e_<%=cid%>.getMessage()); + globalMap.put("<%=cid%>_ERROR_MESSAGE",e_<%=cid%>.getMessage()); if(out_<%=cid %> != null){ out_<%=cid %>.close(); } @@ -209,8 +188,4 @@ globalMap.put("<%=cid%>_ERROR_MESSAGE",e_<%=cid%>.getMessage()); globalMap.put("<%=cid %>_NB_FILE",nb_file_<%=cid%>); globalMap.put("<%=cid %>_ERROR_MESSAGE",e_<%=cid%>.getMessage()); throw e_<%=cid%>; - }finally { - if(session_<%=cid%> != null) { - session_<%=cid%>.close(); - } } diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPPut/tSCPPut_end.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPPut/tSCPPut_end.javajet index 1f0154d0fd6..ab92d80a21c 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPPut/tSCPPut_end.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPPut/tSCPPut_end.javajet @@ -17,6 +17,7 @@ imports=" <%if(isLog4jEnabled){%> log.info("<%=cid%> - Closing the connection to the server."); <%}%> + session_<%=cid%>.close(); client_<%=cid%>.close(); <%if(isLog4jEnabled){%> log.info("<%=cid%> - Connection to the server closed."); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPPut/tSCPPut_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPPut/tSCPPut_main.javajet index 76c8fa3dfa0..3d6032e133f 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPPut/tSCPPut_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPPut/tSCPPut_main.javajet @@ -50,28 +50,6 @@ imports=" java.nio.file.Path[] sourceFileNames_<%=cid%> = sourceList_<%=cid %>.toArray(new java.nio.file.Path[0]); - /* open a session */ - - <%if(isLog4jEnabled){%> - log.info("<%=cid%> - Open up a session."); - <%}%> - - session_<%=cid%> = client_<%=cid%>.connect(username_<%=cid%>, hostname_<%=cid%>, port_<%=cid%>).verify().getClientSession(); - try { - session_<%=cid%>.auth().verify(); - }catch (org.apache.sshd.common.SshException se_<%=cid%>){ - globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); - <% - if (("PUBLICKEY").equals(authMethod)) { - %> - java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); - <%}%> - if(14 == se_<%=cid%>.getDisconnectCode()){ - throw new IllegalArgumentException("Authentication failed."); - }else{ - throw se_<%=cid%>; - } - } org.apache.sshd.scp.client.ScpClientCreator instance_<%=cid%> = org.talend.components.talendscp.TalendScpClientCreator.INSTANCE; org.apache.sshd.scp.client.ScpClient scp_<%=cid%> = instance_<%=cid%>.createScpClient(session_<%=cid%>); try{ @@ -92,4 +70,3 @@ globalMap.put("<%=cid%>_ERROR_MESSAGE",e.getMessage()); <%}%> globalMap.put("<%=cid %>_STATUS", "File put fail."); } - session_<%=cid%>.close(); \ No newline at end of file diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPRename/tSCPRename_end.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPRename/tSCPRename_end.javajet index 63f38e6310e..0447759214b 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPRename/tSCPRename_end.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPRename/tSCPRename_end.javajet @@ -18,6 +18,7 @@ imports=" <%if(isLog4jEnabled){%> log.info("<%=cid%> - Closing the connection to the server."); <%}%> + session_<%=cid%>.close(); client_<%=cid%>.close(); <%if(isLog4jEnabled){%> log.info("<%=cid%> - Connection to the server closed."); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPRename/tSCPRename_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPRename/tSCPRename_main.javajet index 6202700e5ef..97ba11544dc 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPRename/tSCPRename_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPRename/tSCPRename_main.javajet @@ -27,29 +27,9 @@ imports=" //initial the command StringBuilder command_<%=cid %> = new StringBuilder(); command_<%=cid %>.append("mv \"").append(<%=fromName%>).append("\" \"").append(<%=toName%>).append("\""); - /* Create a session */ - //execute the command - <%if(isLog4jEnabled){%> - log.info("<%=cid%> - Open up a session."); - log.debug("<%=cid%> - execute the command: " + command_<%=cid %>.toString()); - <%}%> - session_<%=cid%> = client_<%=cid%>.connect(username_<%=cid%>, hostname_<%=cid%>, port_<%=cid%>).verify().getClientSession(); - try { - session_<%=cid%>.auth().verify(); - }catch (org.apache.sshd.common.SshException se_<%=cid%>){ - globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); - <% - if (("PUBLICKEY").equals(authMethod)) { - %> - java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); - <%}%> - if(14 == se_<%=cid%>.getDisconnectCode()){ - throw new IllegalArgumentException("Authentication failed."); - }else{ - throw se_<%=cid%>; - } - } + //execute the command + org.apache.sshd.client.channel.ClientChannel channel_<%=cid %> = session_<%=cid %>.createExecChannel((command_<%=cid %>).toString()); java.io.ByteArrayOutputStream stdout_<%=cid %> = new java.io.ByteArrayOutputStream(); java.io.ByteArrayOutputStream stderr_<%=cid %> = new java.io.ByteArrayOutputStream(); @@ -61,7 +41,7 @@ imports=" org.apache.sshd.client.channel.ClientChannelEvent.CLOSED,org.apache.sshd.client.channel.ClientChannelEvent.EXIT_STATUS), 0L); exit_code_<%=cid%> = channel_<%=cid%>.getExitStatus(); channel_<%=cid%>.close(); - session_<%=cid%>.close(); + <%if(isLog4jEnabled){%> log.debug("Channel Events: "+ java.util.Arrays.toString(clientChannelEvents_<%=cid %>.toArray())); <%}%> diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPTruncate/tSCPTruncate_end.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPTruncate/tSCPTruncate_end.javajet index a152a94e517..7218e6b3078 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPTruncate/tSCPTruncate_end.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPTruncate/tSCPTruncate_end.javajet @@ -20,6 +20,7 @@ imports=" <%if(isLog4jEnabled){%> log.info("<%=cid%> - Closing the connection to the server."); <%}%> + session_<%=cid%>.close(); client_<%=cid%>.close(); <%if(isLog4jEnabled){%> log.info("<%=cid%> - Connection to the server closed."); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tSCPTruncate/tSCPTruncate_main.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tSCPTruncate/tSCPTruncate_main.javajet index e171fe35e33..c0fa2a24e99 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tSCPTruncate/tSCPTruncate_main.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tSCPTruncate/tSCPTruncate_main.javajet @@ -25,28 +25,6 @@ imports=" } %> - /* open a session */ - - <%if(isLog4jEnabled){%> - log.info("<%=cid%> - Open up a session."); - <%}%> - - session_<%=cid%> = client_<%=cid%>.connect(username_<%=cid%>, hostname_<%=cid%>, port_<%=cid%>).verify().getClientSession(); - try { - session_<%=cid%>.auth().verify(); - }catch (org.apache.sshd.common.SshException se_<%=cid%>){ - globalMap.put("<%=cid %>_EXIT_CODE",se_<%=cid%>.getDisconnectCode()); - <% - if (("PUBLICKEY").equals(authMethod)) { - %> - java.nio.file.Files.write(privateKey_<%=cid%>,lines_<%=cid%>); - <%}%> - if(14 == se_<%=cid%>.getDisconnectCode()){ - throw new IllegalArgumentException("Authentication failed."); - }else{ - throw se_<%=cid%>; - } - } org.apache.sshd.scp.client.ScpClientCreator instance_<%=cid%> = org.talend.components.talendscp.TalendScpClientCreator.INSTANCE; org.apache.sshd.scp.client.ScpClient scp_<%=cid%> = instance_<%=cid%>.createScpClient(session_<%=cid%>); @@ -81,4 +59,3 @@ globalMap.put("<%=cid%>_ERROR_MESSAGE",e_<%=cid%>.getMessage()); globalMap.put("<%=cid %>_STATUS", "File truncate fail."); } } - session_<%=cid%>.close(); \ No newline at end of file diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_begin.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_begin.javajet index f868ef3b495..85f6f69616c 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_begin.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_begin.javajet @@ -205,61 +205,79 @@ if(!hasDynamic) { %> //Set limit <% -if(!("").equals(limit)) { - %> - int limit_<%=cid%> = <%=limit%>; - <% -} +if(limit!=null && !("").equals(limit) && !("\"\"").equals(limit)) { %> -//URL builder -org.apache.http.client.methods.HttpGet <%=cid%>_httpget = new org.apache.http.client.methods.HttpGet( - <%=cid%>_URL - + "/api/now/table/" - + <%=tablename%> - + "?sysparm_exclude_reference_link=true&sysparm_limit=" - + limit_<%=cid%> - + <%=cid%>_conditions + final int LIMIT_<%=cid%> = <%=limit%>; <% -if(!hasDynamic) { +} else { %> - + <%=cid%>_fields + final int LIMIT_<%=cid%> = 0; <% -} +} %> - ); -//Header builder -<%=cid%>_httpget.setHeader("Accept", "application/json"); -//activate Cookie header only if unreliable connection -//<%=cid%>_httpget.setHeader("Cookie", "BIGipServerpool_sandbox=440453642.33598.0000; JSESSIONID=4100538B6BBF00B5568DF143FF815AF7; _ga=GA1.2.1976595674.1437483024; __CJ_tabs2_list_sys_user=%220%22; __CJ_g_startTime=%221437483102682%22; glide_user_route=glide.a1e7d977b734181b528e29363f053207"); -<% -if(isLog4jEnabled){ - %> - log.info("<%=cid%> - Executing method '" + <%=cid%>_httpget.getRequestLine().getMethod() + "'"); - <% -} -%> -//Get -org.apache.http.client.methods.CloseableHttpResponse <%=cid%>_response = <%=cid%>_httpclient.execute(<%=cid%>_httpget); -<% -if(isLog4jEnabled){ - %> - log.info("<%=cid%> - Execution code '" + <%=cid%>_response.getStatusLine().getStatusCode() + "'"); - <% -} -%> -try { - String <%=cid%>_responseBody; - org.json.JSONObject <%=cid%>_json; - org.json.JSONArray <%=cid%>_resultArray; - int <%=cid%>_responseLength, <%=cid%>_i; - org.json.JSONObject <%=cid%>_result = null; - try { - <%=cid%>_responseBody = org.apache.http.util.EntityUtils.toString(<%=cid%>_response.getEntity()); - <%=cid%>_json = new org.json.JSONObject(<%=cid%>_responseBody); - if (<%=cid%>_response.getStatusLine().getStatusCode() == 200) { -//Store result as JSON - <%=cid%>_resultArray = (org.json.JSONArray) <%=cid%>_json.get("result"); - <%=cid%>_responseLength = <%=cid%>_resultArray.length(); -//Pass values to output - for (<%=cid%>_i = 0; <%=cid%>_i < <%=cid%>_responseLength; <%=cid%>_i++) { +int offset_<%=cid%> = 0; +int limit_<%=cid%> = LIMIT_<%=cid%> > 0 ? LIMIT_<%=cid%> : 1000; +int total_<%=cid%> = 0; + +try { +while(true) { + //URL builder + StringBuilder strb_<%=cid%> = new StringBuilder(); + strb_<%=cid%>.append(<%=cid%>_URL).append("/api/now/table/").append(<%=tablename%>).append("?sysparm_exclude_reference_link=true") + .append("&sysparm_offset=").append(offset_<%=cid%>).append("&sysparm_limit=").append(limit_<%=cid%>).append(<%=cid%>_conditions); + + offset_<%=cid%> += limit_<%=cid%>; + + <% + if(!hasDynamic) { + %> + strb_<%=cid%>.append(<%=cid%>_fields); + <% + } + %> + + org.apache.http.client.methods.HttpGet <%=cid%>_httpget = new org.apache.http.client.methods.HttpGet(strb_<%=cid%>.toString()); + + //Header builder + <%=cid%>_httpget.setHeader("Accept", "application/json"); + //activate Cookie header only if unreliable connection + //<%=cid%>_httpget.setHeader("Cookie", "BIGipServerpool_sandbox=440453642.33598.0000; JSESSIONID=4100538B6BBF00B5568DF143FF815AF7; _ga=GA1.2.1976595674.1437483024; __CJ_tabs2_list_sys_user=%220%22; __CJ_g_startTime=%221437483102682%22; glide_user_route=glide.a1e7d977b734181b528e29363f053207"); + <% + if(isLog4jEnabled){ + %> + log.info("<%=cid%> - Executing method '" + <%=cid%>_httpget.getRequestLine().getMethod() + "'"); + <% + } + %> + //Get + org.apache.http.client.methods.CloseableHttpResponse <%=cid%>_response = <%=cid%>_httpclient.execute(<%=cid%>_httpget); + <% + if(isLog4jEnabled){ + %> + log.info("<%=cid%> - Execution code '" + <%=cid%>_response.getStatusLine().getStatusCode() + "'"); + <% + } + %> + + org.apache.http.Header header_<%=cid%> = <%=cid%>_response.getFirstHeader("Link"); + + String <%=cid%>_responseBody; + org.json.JSONObject <%=cid%>_json; + org.json.JSONArray <%=cid%>_resultArray; + int <%=cid%>_responseLength, <%=cid%>_i; + org.json.JSONObject <%=cid%>_result = null; + try { + <%=cid%>_responseBody = org.apache.http.util.EntityUtils.toString(<%=cid%>_response.getEntity()); + <%=cid%>_json = new org.json.JSONObject(<%=cid%>_responseBody); + + if (<%=cid%>_response.getStatusLine().getStatusCode() == 200) { + //Store result as JSON + <%=cid%>_resultArray = (org.json.JSONArray) <%=cid%>_json.get("result"); + <%=cid%>_responseLength = <%=cid%>_resultArray.length(); + total_<%=cid%> += <%=cid%>_responseLength; + if(<%=cid%>_responseLength == 0) {//already read limit number records, so quit + break; + } + //Pass values to output + for (<%=cid%>_i = 0; <%=cid%>_i < <%=cid%>_responseLength; <%=cid%>_i++) { diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_end.javajet b/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_end.javajet index f446ea808d5..684da788f22 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_end.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_end.javajet @@ -16,7 +16,7 @@ INode node = (INode)codeGenArgument.getArgument(); String cid = node.getUniqueName(); boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__")); %> -}// responce loop +}// response loop try{ String error_<%=cid%> = ((org.json.JSONObject)<%=cid%>_json.get("error")).getString("message"); String detail_<%=cid%> = ((org.json.JSONObject)<%=cid%>_json.get("error")).getString("detail"); @@ -31,7 +31,7 @@ if(isLog4jEnabled){ <% } %> - }catch(org.json.JSONException je_<%=cid%>){ + }catch(org.json.JSONException je_<%=cid%>){ //ignore } } else { @@ -44,7 +44,14 @@ if(isLog4jEnabled){ } finally { <%=cid%>_response.close(); } + + if(LIMIT_<%=cid%> == total_<%=cid%>) { + break; + } +}// end outside while loop + } finally { - <%=cid%>_httpclient.close(); + <%=cid%>_httpclient.close(); } -globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>); + +globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_java.xml index 0d8102807c2..7d680bf0cb1 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tServiceNowInput/tServiceNowInput_java.xml @@ -437,7 +437,7 @@ 1000 - If limit set to empty "" string or 0 it will be disabled. + Limit is disabled if set to 0 or empty "" string. false diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataConnection/tTeradataConnection_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataConnection/tTeradataConnection_java.xml index b580bff3f93..71841aa227d 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataConnection/tTeradataConnection_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataConnection/tTeradataConnection_java.xml @@ -149,8 +149,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataFastExport/tTeradataFastExport_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataFastExport/tTeradataFastExport_java.xml index 9d505555e0f..71f1d8c7d16 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataFastExport/tTeradataFastExport_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataFastExport/tTeradataFastExport_java.xml @@ -281,10 +281,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataFastLoad/tTeradataFastLoad_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataFastLoad/tTeradataFastLoad_java.xml index 7a7fc686473..92c0e68bd7e 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataFastLoad/tTeradataFastLoad_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataFastLoad/tTeradataFastLoad_java.xml @@ -162,8 +162,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataInput/tTeradataInput_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataInput/tTeradataInput_java.xml index 57794761676..0518c867d08 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataInput/tTeradataInput_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataInput/tTeradataInput_java.xml @@ -130,10 +130,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataOutput/tTeradataOutput_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataOutput/tTeradataOutput_java.xml index 4af3237217d..9696b693dcc 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataOutput/tTeradataOutput_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataOutput/tTeradataOutput_java.xml @@ -351,8 +351,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataRow/tTeradataRow_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataRow/tTeradataRow_java.xml index f5f7695b489..55a4a40db60 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataRow/tTeradataRow_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataRow/tTeradataRow_java.xml @@ -276,8 +276,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataSCD/tTeradataSCD_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataSCD/tTeradataSCD_java.xml index 27f22d201aa..b6a342207cc 100755 --- a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataSCD/tTeradataSCD_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataSCD/tTeradataSCD_java.xml @@ -239,8 +239,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataSCDELT/tTeradataSCDELT_java.xml b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataSCDELT/tTeradataSCDELT_java.xml index c00dd77db25..c30811cf052 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/tTeradataSCDELT/tTeradataSCDELT_java.xml +++ b/main/plugins/org.talend.designer.components.localprovider/components/tTeradataSCDELT/tTeradataSCDELT_java.xml @@ -334,8 +334,7 @@ - - + diff --git a/main/plugins/org.talend.designer.components.localprovider/components/templates/DB/Input/HelpClass.javajet b/main/plugins/org.talend.designer.components.localprovider/components/templates/DB/Input/HelpClass.javajet index 9a209e130ee..44e86f74026 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/templates/DB/Input/HelpClass.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/templates/DB/Input/HelpClass.javajet @@ -51,6 +51,19 @@ imports=" } public void createConnection(INode node, boolean needUserAndPassword) { + createConnection(node,needUserAndPassword ? 1 : 0); + + + } + +/* +* mode: +* 0. Without User and Password +* 1. need User And Password +* 2. without connection +*/ + public void createConnection(INode node, int mode) { + cid = node.getUniqueName(); dbproperties = ElementParameterParser.getValue(node, "__PROPERTIES__"); dbhost = ElementParameterParser.getValue(node, "__HOST__"); @@ -90,23 +103,25 @@ imports=" <%this.setURL(node);%> <% log4jCodeGenerateUtil.debugConnectionParams(node); - if (!needUserAndPassword){ + if (mode == 0){ log4jCodeGenerateUtil.connect_begin_noUser(); } else { log4jCodeGenerateUtil.connect_begin(); } %> <% - if(needUserAndPassword) { + if(mode == 1) { %> conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>,dbUser_<%=cid%>,dbPwd_<%=cid%>); <% - } else { + } else if(mode ==0){ %> conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>); <% } + if(mode != 2){ log4jCodeGenerateUtil.connect_end(); + } %> <%this.afterUseNewConnection(node);%> <% diff --git a/main/plugins/org.talend.designer.components.localprovider/components/templates/DB/Row/HelpClass.javajet b/main/plugins/org.talend.designer.components.localprovider/components/templates/DB/Row/HelpClass.javajet index 8cf4e4025ba..c216c73a988 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/templates/DB/Row/HelpClass.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/templates/DB/Row/HelpClass.javajet @@ -51,12 +51,18 @@ //do nothing as default //for sybase jdbc in java 11, we have to call jdbcclazz.newInstance method } - + public void newConnection(){ %> conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>,dbUser_<%=cid%>,dbPwd_<%=cid%>); <% } + + public void newConnection(INode node){ + %> + conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>,dbUser_<%=cid%>,dbPwd_<%=cid%>); + <% + } public void createConnection(INode node, boolean needUserAndPassword) { useExistingConn = ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__"); @@ -104,7 +110,7 @@ String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>; <%log4jCodeGenerateUtil.connect_begin(); - newConnection(); + newConnection(node); } else { log4jCodeGenerateUtil.connect_begin_noUser(); %> diff --git a/main/plugins/org.talend.designer.components.localprovider/components/templates/Log4j/Log4jDBConnUtil.javajet b/main/plugins/org.talend.designer.components.localprovider/components/templates/Log4j/Log4jDBConnUtil.javajet index 46d400fd2c8..c633afb626c 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/templates/Log4j/Log4jDBConnUtil.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/templates/Log4j/Log4jDBConnUtil.javajet @@ -92,6 +92,26 @@ imports=" <% connect_end(); } + + public void connectWithProperties(INode node){ + beforeComponentProcess(node); + + connect_begin(); + java.util.List> properties = (java.util.List>)ElementParameterParser.getObjectValue(node, "__ENTRY_PROPERTIES__"); + %> + java.util.Properties properties_<%=cid%> = new java.util.Properties(); + properties_<%=cid%>.setProperty("user",dbUser_<%=cid%>); + properties_<%=cid%>.setProperty("password",dbPwd_<%=cid%>); + <% + for(java.util.Map entry : properties){ + %> + properties_<%=cid%>.setProperty(<%=entry.get("KEY")%>,<%=entry.get("VALUE")%>); + <%}%> + + conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid%>,properties_<%=cid%>); + <% + connect_end(); + } public void connect_begin(){ logInfo(node,"debug",cid+" - Connection attempt to '\" + url_"+cid+" + \"' with the username '\" + dbUser_"+cid+" + \"'."); diff --git a/main/plugins/org.talend.designer.components.localprovider/components/templates/_tableActionForELT.javajet b/main/plugins/org.talend.designer.components.localprovider/components/templates/_tableActionForELT.javajet index 16f7d9e4776..cbf4152f09a 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/templates/_tableActionForELT.javajet +++ b/main/plugins/org.talend.designer.components.localprovider/components/templates/_tableActionForELT.javajet @@ -3,7 +3,7 @@ <% Boolean isParallelize ="true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__PARALLELIZE__")); if (!isParallelize) { - manager = getELTManager(dbmsId, cid, node); + manager = getELTManager(dbmsId, cid, node, autoWrapColumnName); String ending=""; diff --git a/main/plugins/org.talend.designer.components.localprovider/components/templates/db_output_bulk.skeleton b/main/plugins/org.talend.designer.components.localprovider/components/templates/db_output_bulk.skeleton index a237de62c1e..4f1fd845464 100644 --- a/main/plugins/org.talend.designer.components.localprovider/components/templates/db_output_bulk.skeleton +++ b/main/plugins/org.talend.designer.components.localprovider/components/templates/db_output_bulk.skeleton @@ -241,21 +241,6 @@ public class CLASS { public void setDynamic(boolean isDynamic) { this.isDynamic = isDynamic; } - - public String getWrappedColumnName(String lProtectedChar, String rProtectedChar) { - String wrappedColumnName = getColumnName(); - if (!isDynamic()) { - if (!lProtectedChar.equals("\\\"") && wrappedColumnName.startsWith("\"")) { - wrappedColumnName = "\\" + wrappedColumnName; - } - - if (!rProtectedChar.equals("\\\"") && wrappedColumnName.endsWith("\"") && !wrappedColumnName.endsWith("\\\"")) { - wrappedColumnName = wrappedColumnName.substring(0, wrappedColumnName.lastIndexOf("\"")) + "\\" + "\""; - } - } - - return lProtectedChar + wrappedColumnName + rProtectedChar; - } } public Column getColumn(IMetadataColumn column) { @@ -282,7 +267,10 @@ public class CLASS { this.dbVersion = dbVersion; } - protected String cid; + protected String cid; + + protected boolean autoWrapColumnName; + protected abstract String getDBMSId(); protected abstract String getLProtectedChar(); protected abstract String getRProtectedChar(); @@ -290,32 +278,44 @@ public class CLASS { public Manager(String cid) { this.cid = cid; } - protected String getLProtectedChar(String columName) { - return getLProtectedChar(); - } - protected String getRProtectedChar(String columName) { - return getRProtectedChar(); - } - protected boolean contaionsSpaces(String columnName) { - if (columnName != null) { - if (columnName.startsWith("\" + ") && columnName.endsWith(" + \"")) { - return false; - } + + protected String getLProtectedChar(String columName) { + return getLProtectedChar(); + } + protected String getRProtectedChar(String columName) { + return getRProtectedChar(); + } + + protected void setAutoWrapColumnName(boolean autoWrapColumnName) { + this.autoWrapColumnName = autoWrapColumnName; + } + + //if autoWrapColumnName, may not use lProtectedChar/rProtectedChar, as they will be empty char if not need to wrap without key words of current database + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return lProtectedChar + columnName + rProtectedChar; + } + + //wrap column name when white space or something appear + protected boolean contaionsSpaces(String columnName) { + if (columnName != null) { + if (columnName.startsWith("\" + ") && columnName.endsWith(" + \"")) { + return false; + } - if (columnName.startsWith("\\\"") && columnName.endsWith("\\\"")) { - return false; - } + if (columnName.startsWith("\\\"") && columnName.endsWith("\\\"")) { + return false; + } - if (columnName.contains(" ")) { - return true; - } - // minus are also a problem - if (columnName.contains("-")) { - return true; - } - } - return false; - } + if (columnName.contains(" ")) { + return true; + } + // minus are also a problem + if (columnName.contains("-")) { + return true; + } + } + return false; + } public String getSelectionSQL() { StringBuilder selectionSQL = new StringBuilder(); @@ -380,9 +380,9 @@ public class CLASS { createSQL.append(" {TALEND_DYNAMIC_COLUMN} ").append(ending); } else { if (column.isKey()) { - pkList.add(column.getWrappedColumnName(getLProtectedChar(column.getColumnName()), getRProtectedChar(column.getColumnName()))); + pkList.add(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName()))); } - createSQL.append(column.getWrappedColumnName(getLProtectedChar(column.getColumnName()), getRProtectedChar(column.getColumnName())) + " "); + createSQL.append(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())) + " "); String dataType = null; if (column.getColumn().getType() == null || column.getColumn().getType().trim().equals("")) { dataType = mappingType.getDefaultSelectedDbType(column.getColumn().getTalendType()); @@ -476,7 +476,7 @@ public class CLASS { if(column.isAutoIncrement()) { // move the autoincrease key column to the first index in the primary defination. Otherwise, it will throw exception if(MYSQL.equalsIgnoreCase(getDBMSId()) || SINGLESTORE.equalsIgnoreCase(getDBMSId())) { - String columnStr = column.getWrappedColumnName(getLProtectedChar(column.getColumnName()), getRProtectedChar(column.getColumnName())); + String columnStr = getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())); int index = pkList.indexOf(columnStr); if(index !=-1){ for (int i=index;i>0;i--) { @@ -1527,7 +1527,7 @@ public class CLASS { return dropTableSQL.toString(); } - public String getCreateTableSQL(List columnList) { + public String getCreateTableSQL(List columnList) { MappingTypeRetriever mappingType = MetadataTalendType.getMappingTypeRetriever(getDBMSId()); StringBuilder createSQL = new StringBuilder(); createSQL.append("CREATE TABLE " + getLProtectedChar() + "\" + tableName_" + cid + " + \"" + getRProtectedChar() + "("); @@ -1564,9 +1564,9 @@ public class CLASS { createSQL.append(" {TALEND_DYNAMIC_COLUMN} ").append(ending); } else { if (column.isKey()) { - pkList.add(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() )); + pkList.add(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName()))); } - createSQL.append(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() ) + " "); + createSQL.append(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())) + " "); String dataType = null; if (column.getColumn().getType() == null || column.getColumn().getType().trim().equals("")) { dataType = mappingType.getDefaultSelectedDbType(column.getColumn().getTalendType()); @@ -2132,9 +2132,9 @@ public class CLASS { createSQL.append(" {TALEND_DYNAMIC_COLUMN} ").append(ending); } else { if (column.isKey()) { - pkList.add(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() )); + pkList.add(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName()))); } - createSQL.append(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() ) + " "); + createSQL.append(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())) + " "); String dataType = null; if (column.getColumn().getType() == null || column.getColumn().getType().trim().equals("")) { dataType = mappingType.getDefaultSelectedDbType(column.getColumn().getTalendType()); @@ -2967,8 +2967,6 @@ public class CLASS { MappingTypeRetriever mappingType = MetadataTalendType.getMappingTypeRetriever(getDBMSId()); StringBuilder createSQL = new StringBuilder(); - - createSQL.append(redshiftTracker +" \\n " + "CREATE TABLE " + getLProtectedChar() + "\" + tableName_" + cid + " + \"" + getRProtectedChar() + "("); List pkList = new ArrayList(); int count = 0; @@ -3003,9 +3001,9 @@ public class CLASS { createSQL.append(" {TALEND_DYNAMIC_COLUMN} ").append(ending); } else { if (column.isKey()) { - pkList.add(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() )); + pkList.add(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName()))); } - createSQL.append(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() ) + " "); + createSQL.append(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())) + " "); String dataType = null; if (column.getColumn().getType() == null || column.getColumn().getType().trim().equals("")) { dataType = mappingType.getDefaultSelectedDbType(column.getColumn().getTalendType()); @@ -3696,9 +3694,9 @@ public class CLASS { createSQL.append(" {TALEND_DYNAMIC_COLUMN} ").append(ending); } else { if (column.isKey()) { - pkList.add(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() )); + pkList.add(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName()))); } - createSQL.append(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() ) + " "); + createSQL.append(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())) + " "); String dataType = null; if (column.getColumn().getType() == null || column.getColumn().getType().trim().equals("")) { dataType = mappingType.getDefaultSelectedDbType(column.getColumn().getTalendType()); @@ -4056,9 +4054,9 @@ public class CLASS { createSQL.append(" {TALEND_DYNAMIC_COLUMN} ").append(ending); } else { if (column.isKey()) { - pkList.add(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() )); + pkList.add(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName()))); } - createSQL.append(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() ) + " "); + createSQL.append(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())) + " "); if(column.isAutoIncrement()) { createSQL.append(getAutoIncrement(column.getStartValue(), column.getStep())); } else { @@ -4281,9 +4279,9 @@ public class CLASS { createSQL.append(" {TALEND_DYNAMIC_COLUMN} ").append(ending); } else { if (column.isKey()) { - pkList.add(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() )); + pkList.add(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName()))); } - createSQL.append(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() ) + " "); + createSQL.append(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())) + " "); String dataType = null; if (column.getColumn().getType() == null || column.getColumn().getType().trim().equals("")) { dataType = mappingType.getDefaultSelectedDbType(column.getColumn().getTalendType()); @@ -4528,9 +4526,9 @@ public class CLASS { createSQL.append(" {TALEND_DYNAMIC_COLUMN} ").append(ending); } else { if (column.isKey()) { - pkList.add(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() )); + pkList.add(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName()))); } - createSQL.append(getLProtectedChar( column.getColumnName() ) + column.getColumnName() + getRProtectedChar( column.getColumnName() ) + " "); + createSQL.append(getWrappedColumnName(getLProtectedChar(column.getColumnName()), column.getColumnName(), getRProtectedChar(column.getColumnName())) + " "); String dataType = null; if (column.getColumn().getType() == null || column.getColumn().getType().trim().equals("")) { dataType = mappingType.getDefaultSelectedDbType(column.getColumn().getTalendType()); @@ -4639,8 +4637,8 @@ public class CLASS { return ""; } } - - public class DELTALAKEManager extends Manager { + + public class DELTALAKEManager extends Manager { public DELTALAKEManager(String cid) { super(cid); } @@ -4682,6 +4680,87 @@ public class CLASS { ////////////////////////////////////////////////////////////////////////////////// //the managers which only work for tELTJDBCOutput component, we add it to ignore the text quote which wrap the schema, table or column name. + //getLProtectedChar()/getRProtectedChar() works for schema/table quote more + //getRProtectedChar(String columName) works for wrap column name + //ELT not support dynamic column, add and replace column + + static class ColumnHelper { + + static java.util.regex.Pattern basicNamePattern = java.util.regex.Pattern.compile("[\\p{Alpha}][\\p{Alnum}_]*"); + + //lProtectedChar and rProtectedChar may be empty string or other char which is not double quote, do this for old job migration + static String wrapColumnNameByDoubleQuoteIfNecessary(boolean autoWrapColumnName, String lProtectedChar, String columnName, String rProtectedChar) { + //any head or tail invisible char is not valid column name + columnName = columnName.trim(); + + boolean alreadyWrapped = columnName.startsWith("\\\"") && columnName.endsWith("\\\""); + + if(alreadyWrapped) { + return lProtectedChar + columnName + rProtectedChar; + } + + if(autoWrapColumnName) { + if(basicNamePattern.matcher(columnName).matches()) { + return lProtectedChar + columnName + rProtectedChar; + } + + return "\\\"" + columnName + "\\\""; + } + + //if db column name starts with double quote or (ends with double quote and not escape that double quote), sure compiler issue, + //so correct it here, so no migration issue as break already before + if (columnName.startsWith("\"")) { + columnName = "\\" + columnName; + } + + if (columnName.endsWith("\"") && !columnName.endsWith("\\\"")) { + columnName = columnName.substring(0, columnName.lastIndexOf("\"")) + "\\\""; + } + + return lProtectedChar + columnName + rProtectedChar; + } + + static String wrapColumnNameByGraveAccentIfNecessary(boolean autoWrapColumnName, String lProtectedChar, String columnName, String rProtectedChar) { + columnName = columnName.trim(); + + boolean alreadyWrapped = columnName.startsWith("`") && columnName.endsWith("`"); + + if(alreadyWrapped) { + return lProtectedChar + columnName + rProtectedChar; + } + + if(autoWrapColumnName) { + if(basicNamePattern.matcher(columnName).matches()) { + return lProtectedChar + columnName + rProtectedChar; + } + + return "`" + columnName + "`"; + } + + return lProtectedChar + columnName + rProtectedChar; + } + + static String wrapColumnNameByBracketIfNecessary(boolean autoWrapColumnName, String lProtectedChar, String columnName, String rProtectedChar) { + columnName = columnName.trim(); + + boolean alreadyWrapped = columnName.startsWith("[") && columnName.endsWith("]"); + + if(alreadyWrapped) { + return lProtectedChar + columnName + rProtectedChar; + } + + if(autoWrapColumnName) { + if(basicNamePattern.matcher(columnName).matches()) { + return lProtectedChar + columnName + rProtectedChar; + } + + return "[" + columnName + "]"; + } + + return lProtectedChar + columnName + rProtectedChar; + } + + } public class AS400ELTManager extends AS400Manager { public AS400ELTManager(String cid) { @@ -4693,6 +4772,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class AccessELTManager extends AccessManager { @@ -4705,6 +4788,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByBracketIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class DB2ELTManager extends DB2Manager { @@ -4717,6 +4804,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class FirebirdELTManager extends FirebirdManager { @@ -4729,6 +4820,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class HSQLDBELTManager extends HSQLDBManager { @@ -4741,6 +4836,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class HiveELTManager extends HiveManager { @@ -4753,6 +4852,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class InformixELTManager extends InformixManager { @@ -4765,6 +4868,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class IngresELTManager extends IngresManager { @@ -4777,6 +4884,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class VectorWiseELTManager extends VectorWiseManager { @@ -4789,6 +4900,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class InterbaseELTManager extends InterbaseManager { @@ -4801,6 +4916,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class JavaDBELTManager extends JavaDBManager { @@ -4813,6 +4932,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class MaxDBELTManager extends MaxDBManager { @@ -4825,6 +4948,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class MSSQLELTManager extends MSSQLManager { @@ -4837,6 +4964,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByBracketIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class MysqlELTManager extends MysqlManager { @@ -4849,6 +4980,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByGraveAccentIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class NetezzaELTManager extends NetezzaManager { @@ -4861,6 +4996,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class OracleELTManager extends OracleManager { @@ -4873,6 +5012,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class PostgrePlusELTManager extends PostgrePlusManager { @@ -4885,6 +5028,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class GreenplumELTManager extends GreenplumManager { @@ -4897,6 +5044,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class PostgreELTManager extends PostgreManager { @@ -4909,6 +5060,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class RedshiftELTManager extends RedshiftManager { @@ -4921,6 +5076,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class SQLiteELTManager extends SQLiteManager { @@ -4933,6 +5092,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class SybaseELTManager extends SybaseManager { @@ -4945,6 +5108,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class TeradataELTManager extends TeradataManager { @@ -4957,6 +5124,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class VerticaELTManager extends VerticaManager { @@ -4969,6 +5140,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class ExasolELTManager extends ExasolManager { @@ -4981,6 +5156,10 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class SAPHanaELTManager extends SAPHanaManager { @@ -4993,12 +5172,20 @@ public class CLASS { protected String getRProtectedChar() { return ""; } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public class SnowflakeELTManager extends SnowflakeManager { public SnowflakeELTManager(String cid) { super(cid); } + + protected String getWrappedColumnName(String lProtectedChar, String columnName, String rProtectedChar) { + return ColumnHelper.wrapColumnNameByDoubleQuoteIfNecessary(autoWrapColumnName, lProtectedChar, columnName, rProtectedChar); + } } public Manager getELTManager(String dbmsId, String cid) { @@ -5063,6 +5250,7 @@ public class CLASS { ((UnDefinedManager)manager).setDBMSId(dbmsId); } } + managerMap.put(dbmsId + cid, manager); return manager; } @@ -5150,9 +5338,13 @@ public class CLASS { return manager; } - public Manager getELTManager(String dbmsId, String cid, INode node) { + public Manager getELTManager(String dbmsId, String cid, INode node, boolean autoWrapColumnName) { Manager manager = getELTManager(dbmsId, cid); + + //the manager have status, no issue for multi thread or no multi thread case? manager.setNode(node); + manager.setAutoWrapColumnName(autoWrapColumnName); + return manager; } diff --git a/main/plugins/org.talend.designer.core/src/main/java/messages_ja.properties b/main/plugins/org.talend.designer.core/src/main/java/messages_ja.properties index 989c54a239c..d38adb85c77 100644 --- a/main/plugins/org.talend.designer.core/src/main/java/messages_ja.properties +++ b/main/plugins/org.talend.designer.core/src/main/java/messages_ja.properties @@ -596,7 +596,7 @@ Process.errorLoadingConnectionMessage=\u4EE5\u4E0B\u306E\u63A5\u7D9A\u306B\u79FB Process.errorLoadingConnectionTitle=\u30B8\u30E7\u30D6\u306E\u30ED\u30FC\u30C9\u4E2D\u306B\u30A8\u30E9\u30FC\u304C\u767A\u751F\u3057\u307E\u3057\u305F Process.metadataModificationDetected=\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u5909\u66F4\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F Process.errorCircleConnectionDetected=\u30B5\u30FC\u30AF\u30EB\u63A5\u7D9A\u304C\u691C\u51FA\u3055\u308C\u307E\u3057\u305F\u3002\u63A5\u7D9A\u306F<{0}>\u3001\u30BD\u30FC\u30B9\u306F<{1}>\u3001\u30BF\u30FC\u30B2\u30C3\u30C8\u306F<{2}>\u3067\u3059\u3002 -Process.Component.NotFound=\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C1\u3064(\u307E\u305F\u306F\u8907\u6570)\u6B20\u843D\u3057\u3066\u3044\u307E\u3059: {0}\u3002Maven\u30B3\u30DE\u30F3\u30C9\u3067 -D{1}=false\u3092\u4F7F\u3046\u3068\u3053\u306E\u30C1\u30A7\u30C3\u30AF\u304C\u30B9\u30AD\u30C3\u30D7\u3055\u308C\u307E\u3059\u3002 +Process.Components.NotFound={0}: \u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C1\u3064(\u307E\u305F\u306F\u8907\u6570)\u6B20\u843D\u3057\u3066\u3044\u307E\u3059: {1}\u3002Maven\u30B3\u30DE\u30F3\u30C9\u3067 -D{2}=false\u3092\u4F7F\u3046\u3068\u3053\u306E\u30C1\u30A7\u30C3\u30AF\u304C\u30B9\u30AD\u30C3\u30D7\u3055\u308C\u307E\u3059\u3002 ProcessUpdateManager.ReadOnlyProcessUpdateWarningMessages=\u3053\u306E\u30B8\u30E7\u30D6\u306F\u30EA\u30DD\u30B8\u30C8\u30EA\u30FC\u304B\u3089\u66F4\u65B0\u304C\u5FC5\u8981\u3067\u3059\u304C\u3001\u30B8\u30E7\u30D6\u304C\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u306E\u5834\u5408\u306F\u66F4\u65B0\u3067\u304D\u307E\u305B\u3093\u3002 ProcessUpdateManager.Question=\u8CEA\u554F ProcessUpdateManager.QuestionString=\u30B8\u30E7\u30D6\u3067\u4F7F\u7528\u3055\u308C\u3066\u3044\u308B\u3088\u3046\u306B\u65B0\u898F\u30AB\u30E9\u30E0\u3092\u8A2D\u5B9A\u3057\u307E\u3059\u304B? diff --git a/main/plugins/org.talend.designer.core/src/main/java/messages_zh_CN.properties b/main/plugins/org.talend.designer.core/src/main/java/messages_zh_CN.properties index 51730f0edc1..0e4c0e576c5 100644 --- a/main/plugins/org.talend.designer.core/src/main/java/messages_zh_CN.properties +++ b/main/plugins/org.talend.designer.core/src/main/java/messages_zh_CN.properties @@ -596,7 +596,7 @@ Process.errorLoadingConnectionMessage=\u5728\u540E\u9762\u7684\u8FDE\u63A5\u4E2D Process.errorLoadingConnectionTitle=\u52A0\u8F7D\u4F5C\u4E1A\u7684\u65F6\u5019\u51FA\u73B0\u9519\u8BEF Process.metadataModificationDetected=\u5143\u6570\u636E\u88AB\u4FEE\u6539 Process.errorCircleConnectionDetected=\u68C0\u6D4B\u5230\u5706\u5F62\u8FDE\u63A5\u3002\u8FDE\u63A5\u662F <{0}>\uFF0C\u6765\u6E90\u662F <{1}>\uFF0C\u76EE\u6807\u662F <{2}>\u3002 -Process.Component.NotFound=\u7F3A\u5931\u4E00\u4E2A\u6216\u591A\u4E2A\u7EC4\u4EF6: {0}; \u5728 Maven \u547D\u4EE4\u4E2D\u4F7F\u7528 -D{1}=false \u53EF\u8DF3\u8FC7\u6B64\u9879\u68C0\u67E5\u3002 +Process.Components.NotFound={0}\u7F3A\u5931\u4E00\u4E2A\u6216\u591A\u4E2A\u7EC4\u4EF6: {1}; \u5728 Maven \u547D\u4EE4\u4E2D\u4F7F\u7528 -D{2}=false \u53EF\u8DF3\u8FC7\u6B64\u9879\u68C0\u67E5\u3002 ProcessUpdateManager.ReadOnlyProcessUpdateWarningMessages=\u8FD9\u4E2A\u4F5C\u4E1A\u9700\u8981\u4ECE\u5E93\u4E2D\u66F4\u65B0\uFF0C\u4F46\u662F\u4F5C\u4E1A\u4E0D\u80FD\u4E3A\u53EA\u8BFB\u72B6\u6001\u3002 ProcessUpdateManager.Question=\u95EE\u9898 ProcessUpdateManager.QuestionString=\u5728\u4F5C\u4E1A\u4E2D\u5C06\u65B0\u5217\u8BBE\u5B9A\u4E3A\u201C\u5DF2\u4F7F\u7528\u201D\uFF1F diff --git a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/cmd/ChangeMetadataCommand.java b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/cmd/ChangeMetadataCommand.java index 48d411517c3..91b3a146c5e 100644 --- a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/cmd/ChangeMetadataCommand.java +++ b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/cmd/ChangeMetadataCommand.java @@ -591,7 +591,7 @@ public class ChangeMetadataCommand extends Command { } } if (GlobalServiceRegister.getDefault().isServiceRegistered(IDQComponentService.class)) { - final IDQComponentService service = (IDQComponentService) GlobalServiceRegister + final IDQComponentService service = GlobalServiceRegister .getDefault() .getService(IDQComponentService.class); service.externalComponentInputMetadataChange(node, newInputMetadata, currentInputMetadata); @@ -615,7 +615,7 @@ public class ChangeMetadataCommand extends Command { } if (GlobalServiceRegister.getDefault().isServiceRegistered(IDQComponentService.class)) { final IDQComponentService service = - (IDQComponentService) GlobalServiceRegister.getDefault().getService(IDQComponentService.class); + GlobalServiceRegister.getDefault().getService(IDQComponentService.class); service.externalComponentOutputMetadataChange(node, newOutputMetadata, currentOutputMetadata); } MetadataToolHelper.copyTable(newOutputMetadata, currentOutputMetadata); @@ -906,6 +906,9 @@ public class ChangeMetadataCommand extends Command { changeTableNameParameter(newdbTableName, olddbTableName, uniqueName, dbTableElementField); if (((Node) curNode).getComponent().getName().startsWith("tSAPADSO")) { //$NON-NLS-1$ IElementParameter serviceNameElementField = curNode.getElementParameter("SERVICE_NAME"); //$NON-NLS-1$ + if (((Node) curNode).getComponent().getName().startsWith("tSAPADSOOutput")) {//$NON-NLS-1$ + serviceNameElementField = curNode.getElementParameter("ADSO_NAME");//$NON-NLS-1$ + } changeTableNameParameter(newdbTableName, olddbTableName, uniqueName, serviceNameElementField); } if (((Node) curNode).isELTComponent()) { diff --git a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/process/Process.java b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/process/Process.java index f7a009b67d6..9bc42ff735e 100644 --- a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/process/Process.java +++ b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/process/Process.java @@ -1422,7 +1422,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer param.setCategory(EComponentCategory.TECHNICAL); String fieldName = pType.getField(); if (isActiveDatabase && fieldName == null) { - fieldName = EParameterFieldType.TEXT.getName(); + fieldName = EParameterFieldType.CHECK.getName(); } EParameterFieldType fieldType = null; if (StringUtils.isNotBlank(fieldName)) { @@ -2441,7 +2441,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer } if (!unloadedNode.isEmpty()) { - if (CommonsPlugin.isScriptCmdlineMode() && !CommonsPlugin.isDevMode()) { + if (CommonsPlugin.isScriptCmdlineMode() && !CommonsPlugin.isDevMode() && !CommonsPlugin.isJunitWorking()) { if (ERR_ON_COMPONENT_MISSING) { StringBuilder missingComps = new StringBuilder(); try { diff --git a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/process/ProcessUpdateManager.java b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/process/ProcessUpdateManager.java index b05818f6672..5a4837952c9 100644 --- a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/process/ProcessUpdateManager.java +++ b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/process/ProcessUpdateManager.java @@ -131,7 +131,6 @@ import org.talend.designer.core.ui.editor.nodes.Node; import org.talend.designer.core.ui.editor.update.UpdateCheckResult; import org.talend.designer.core.ui.editor.update.UpdateManagerUtils; import org.talend.designer.core.ui.preferences.TalendDesignerPrefConstants; -import org.talend.designer.core.utils.ConnectionUtil; import org.talend.designer.core.utils.SAPParametersUtils; import org.talend.metadata.managment.ui.utils.ConnectionContextHelper; import org.talend.repository.UpdateRepositoryUtils; @@ -2190,6 +2189,24 @@ public class ProcessUpdateManager extends AbstractUpdateManager { if (!sameValues) { break; } + } else if ("ENTRY_PROPERTIES".equals(param.getName()) && oldList != null //$NON-NLS-1$ + && objectValue instanceof List) { + List objectList = (List) objectValue; + if (oldList.size() != objectList.size()) { + sameValues = false; + } else { + for (int i = 0; i < oldList.size(); i++) { + Map oldMap = oldList.get(i); + Map objectMap = (Map) objectList.get(i); + if (oldMap.get("KEY").equals(objectMap.get("KEY")) //$NON-NLS-1$ + && oldMap.get("VALUE").equals(objectMap.get("VALUE"))) { //$NON-NLS-1$ + sameValues = true; + } else { + sameValues = false; + break; + } + } + } } } else // check the value diff --git a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/properties/controllers/GenerateCryptoFileController.java b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/properties/controllers/GenerateCryptoFileController.java index a147945e201..1fbc42034c3 100644 --- a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/properties/controllers/GenerateCryptoFileController.java +++ b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/ui/editor/properties/controllers/GenerateCryptoFileController.java @@ -77,7 +77,10 @@ public class GenerateCryptoFileController extends AbstractElementPropertySection String passwordM1 = removeQuotes( service.getOriginalValue(node, ElementParameterParser.getValue(node, "__PASSWORD_M1__"))); - + String algoVersion = + removeQuotes( + service.getOriginalValue(node, ElementParameterParser.getValue(node, "__ALGO_VERSION__"))); + boolean isParameterValidation = service.checkParameterValidation(cryptoFilePath, passwordM1); if (!isParameterValidation) { return; @@ -100,7 +103,7 @@ public class GenerateCryptoFileController extends AbstractElementPropertySection disp.syncExec(new Runnable() { public void run() { - service.generateCryptoFile(passwordM1, cryptoMethod, cryptoFilePath); + service.generateCryptoFile(passwordM1, cryptoMethod, cryptoFilePath, Integer.parseInt(algoVersion)); } }); } diff --git a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/utils/UnifiedComponentUtil.java b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/utils/UnifiedComponentUtil.java index 9d726a5bdb9..a1e136a2c0d 100644 --- a/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/utils/UnifiedComponentUtil.java +++ b/main/plugins/org.talend.designer.core/src/main/java/org/talend/designer/core/utils/UnifiedComponentUtil.java @@ -28,7 +28,6 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.talend.components.api.properties.ComponentProperties; import org.talend.core.GlobalServiceRegister; -import org.talend.core.database.EDatabaseTypeName; import org.talend.core.model.components.IComponent; import org.talend.core.model.components.IComponentsHandler; import org.talend.core.model.components.IComponentsService; @@ -138,11 +137,7 @@ public class UnifiedComponentUtil { for (IComponent component : componentList) { String databaseName = service.getUnifiedCompDisplayName(service.getDelegateComponent(component), component.getName()); - if (StringUtils.isNotBlank(databaseName) && !databaseName.equals(dbTypeName) - && (!EDatabaseTypeName.SYBASEASE.getDisplayName().equals(dbTypeName) - || !EDatabaseTypeName.SYBASEASE.getXmlName().equals(databaseName))) { - // sybase can be dbType as database - // org.talend.designer.unifiedcomponent.unifier.sybase.SybaseComponentsUnifier + if (("JDBC".equals(databaseName) || isAdditionalJDBC(databaseName)) && !dbTypeName.equals(databaseName)) { continue; } diff --git a/main/plugins/org.talend.designer.dbmap/src/main/java/org/talend/designer/dbmap/DbMapComponent.java b/main/plugins/org.talend.designer.dbmap/src/main/java/org/talend/designer/dbmap/DbMapComponent.java index a976e05e448..d4c6691e9d7 100644 --- a/main/plugins/org.talend.designer.dbmap/src/main/java/org/talend/designer/dbmap/DbMapComponent.java +++ b/main/plugins/org.talend.designer.dbmap/src/main/java/org/talend/designer/dbmap/DbMapComponent.java @@ -172,7 +172,6 @@ public class DbMapComponent extends AbstractMapComponent { if (activeDelimitedIdentifiersEP == null) { activeDelimitedIdentifiersEP = new ElementParameter(origNode); activeDelimitedIdentifiersEP.setShow(false); - activeDelimitedIdentifiersEP.setFieldType(EParameterFieldType.TEXT); activeDelimitedIdentifiersEP.setName(EParameterName.ACTIVE_DATABASE_DELIMITED_IDENTIFIERS.getName()); activeDelimitedIdentifiersEP.setCategory(EComponentCategory.TECHNICAL); activeDelimitedIdentifiersEP.setNumRow(99); @@ -180,6 +179,7 @@ public class DbMapComponent extends AbstractMapComponent { List elemParams = (List) origNode.getElementParameters(); elemParams.add(activeDelimitedIdentifiersEP); } + activeDelimitedIdentifiersEP.setFieldType(EParameterFieldType.CHECK); activeDelimitedIdentifiersEP.setValue(getGenerationManager().isUseDelimitedIdentifiers()); // diff --git a/main/plugins/org.talend.libraries.hadoop.mapr.5.0.0/plugin.xml b/main/plugins/org.talend.libraries.hadoop.mapr.5.0.0/plugin.xml index e52878953bd..48adee5e145 100644 --- a/main/plugins/org.talend.libraries.hadoop.mapr.5.0.0/plugin.xml +++ b/main/plugins/org.talend.libraries.hadoop.mapr.5.0.0/plugin.xml @@ -199,9 +199,6 @@ - - @@ -224,32 +221,6 @@ id="commons-io-2.4.jar"> - - - - - - - - - - - - - - - - > variableModels = JSONConnectionContextHelper - .exportAsContext(connectionItem, getConetxtParams()); + .exportAsContext(connectionItem, getContextParams()); contextManager = JSONConnectionContextHelper.contextManager; if (variableModels != null) { @@ -101,11 +101,11 @@ public abstract class AbstractJSONStepForm extends AbstractForm { Map map = ((JobContextManager) contextManager).getNameMap(); // set properties for context mode JSONConnectionContextHelper.setPropertiesForContextMode(connectionItem, contextItem, - getConetxtParams(), map); + getContextParams(), map); } } else { // set properties for exist context - JSONConnectionContextHelper.setPropertiesForExistContextMode(connectionItem, getConetxtParams(), + JSONConnectionContextHelper.setPropertiesForExistContextMode(connectionItem, getContextParams(), variableModels); } // refresh current UI. @@ -144,9 +144,9 @@ public abstract class AbstractJSONStepForm extends AbstractForm { * @see org.talend.repository.ui.swt.utils.AbstractForm#getConetxtParams() */ @Override - protected Set getConetxtParams() { + protected Set getContextParams() { // TODO Auto-generated method stub - return super.getConetxtParams(); + return super.getContextParams(); } } diff --git a/main/plugins/org.talend.repository/plugin.xml b/main/plugins/org.talend.repository/plugin.xml index 54348d3050f..80d5e8cbbbc 100644 --- a/main/plugins/org.talend.repository/plugin.xml +++ b/main/plugins/org.talend.repository/plugin.xml @@ -3713,6 +3713,15 @@ name="ApplySecurityAfterAdvancedKafkaProperties" version="8.0.1"> + + { + if (node == null) { + return; + } + if (ComponentUtilities.getNodeProperty(node, "DRIVER_VERSION") == null ) { + ComponentUtilities.addNodeProperty(node, "DRIVER_VERSION", "CLOSED_LIST");//$NON-NLS-1$ //$NON-NLS-2$ + ComponentUtilities.getNodeProperty(node, "DRIVER_VERSION") + .setValue("DRIVER_V1");//$NON-NLS-1$ //$NON-NLS-2$ + + } + + }; + + IComponentConversion createTableAction = node -> { + if (node == null) { + return; + } + if (ComponentUtilities.getNodeProperty(node, "REDSHIFT_DRIVER_VERSION") == null ) { + ComponentUtilities.addNodeProperty(node, "REDSHIFT_DRIVER_VERSION", "CLOSED_LIST");//$NON-NLS-1$ //$NON-NLS-2$ + ComponentUtilities.getNodeProperty(node, "REDSHIFT_DRIVER_VERSION") + .setValue("DRIVER_V1");//$NON-NLS-1$ //$NON-NLS-2$ + + } + + }; + + boolean modified = false; + + IComponentFilter createTableFilter = new NameComponentFilter("tCreateTable"); + + try { + modified |= ModifyComponentsAction.searchAndModify(item, processType, createTableFilter, Arrays.asList(createTableAction)); + } catch (PersistenceException e) { + ExceptionHandler.process(e); + return ExecutionResult.FAILURE; + } + + + + for (String name : compNames) { + IComponentFilter filter = new NameComponentFilter(name); + + try { + modified |= ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.asList(action)); + } catch (PersistenceException e) { + ExceptionHandler.process(e); + return ExecutionResult.FAILURE; + } + } + + return modified ? ExecutionResult.SUCCESS_NO_ALERT : ExecutionResult.NOTHING_TO_DO; + } + + @Override public Date getOrder() { + GregorianCalendar gc = new GregorianCalendar(2022, Calendar.MARCH, 23, 0, 0, 0); + return gc.getTime(); + } +} \ No newline at end of file diff --git a/main/plugins/org.talend.sdk.component.studio-integration/src/main/java/org/talend/sdk/component/studio/update/TaCoKitCarFeature.java b/main/plugins/org.talend.sdk.component.studio-integration/src/main/java/org/talend/sdk/component/studio/update/TaCoKitCarFeature.java index 9b90dbce7cd..3c9297bd4bd 100644 --- a/main/plugins/org.talend.sdk.component.studio-integration/src/main/java/org/talend/sdk/component/studio/update/TaCoKitCarFeature.java +++ b/main/plugins/org.talend.sdk.component.studio-integration/src/main/java/org/talend/sdk/component/studio/update/TaCoKitCarFeature.java @@ -14,9 +14,15 @@ package org.talend.sdk.component.studio.update; import java.io.BufferedReader; import java.io.File; +import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; @@ -25,6 +31,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -34,6 +41,8 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.m2e.core.MavenPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.talend.commons.exception.ExceptionHandler; import org.talend.commons.runtime.service.ITaCoKitService; import org.talend.commons.utils.resource.FileExtensions; @@ -57,10 +66,19 @@ import org.talend.updates.runtime.storage.IFeatureStorage; import org.talend.updates.runtime.utils.PathUtils; import org.talend.utils.io.FilesUtils; + /** * DOC cmeng class global comment. Detailled comment */ public class TaCoKitCarFeature extends AbstractExtraFeature implements ITaCoKitCarFeature { + + private static final Logger LOGGER = LoggerFactory.getLogger(TaCoKitCarFeature.class); + + private static final String JAVAW_CMD_EXE = "javaw.exe"; + + private static final String JAVA_CMD_EXE = "java.exe"; + + private static final String JAVA_CMD = "java"; private boolean autoReloadAfterInstalled = true; @@ -158,25 +176,102 @@ public class TaCoKitCarFeature extends AbstractExtraFeature implements ITaCoKitC return status; } - private String getJavaCMD() { - String javacmd = "java"; + public static String getJavaCMD() { String vm = System.getProperty(EclipseCommandLine.PROP_VM); if (!Platform.getOS().equals(Platform.OS_MACOSX) && !StringUtils.isBlank(vm)) { - if (!vm.endsWith(javacmd)) { - ExceptionHandler.logDebug("vm: " + vm); - if (vm.endsWith(".dll") || vm.endsWith(".so")) { - vm = Paths.get(vm).getParent().getParent().getParent().resolve("bin").toFile().getAbsolutePath(); + if (!vm.endsWith(JAVA_CMD) || !vm.endsWith(JAVA_CMD_EXE)) { + LOGGER.info("vm: " + vm); + String javaCMD = Platform.getOS().equals(Platform.OS_WIN32) ? JAVA_CMD_EXE : JAVA_CMD; + Finder f = new Finder(javaCMD); + Path p = Paths.get(vm); + if (Files.isSymbolicLink(p)) { + try { + p = p.toRealPath(); + } catch (IOException e) { + LOGGER.error("toRealPath error", e); + } } - - if (!vm.endsWith(File.separator)) { - vm = vm + File.separator; + findJava(Paths.get(vm), f); + if (f.getJavaFile() != null) { + return f.getJavaFile().getAbsolutePath(); } - - vm = vm + javacmd; } - return vm; } - return javacmd; + return JAVA_CMD; + } + + public static File findJava(Path p, Finder f) { + + if (p == null) { + return null; + } + + try { + Files.walkFileTree(p, f); + } catch (IOException e) { + LOGGER.error("findJava error", e); + } + if (f.getJavaFile() == null && f.getLevel() < 4) { + f.setLevel(f.getLevel() + 1); + findJava(p.getParent(), f); + } + + return f.getJavaFile(); + } + + public static class Finder extends SimpleFileVisitor { + + private final String javaCMD; + + private File javaFile; + + private int level = 0; + + Finder(String javaCMD) { + this.javaCMD = javaCMD; + } + + /** + * @return the level + */ + public int getLevel() { + return level; + } + + /** + * @param level the level to set + */ + public void setLevel(int level) { + this.level = level; + } + + public File getJavaFile() { + return javaFile; + } + + // Invoke the pattern matching + // method on each file. + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { + if (StringUtils.equals(javaCMD, FilenameUtils.getName(file.toFile().getName()))) { + javaFile = file.toFile(); + return FileVisitResult.TERMINATE; + } + return FileVisitResult.CONTINUE; + } + + // Invoke the pattern matching + // method on each directory. + @Override + public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFileFailed(Path file, IOException exc) { + LOGGER.error("vist " + file, exc); + return FileVisitResult.CONTINUE; + } } @SuppressWarnings("nls") @@ -185,7 +280,7 @@ public class TaCoKitCarFeature extends AbstractExtraFeature implements ITaCoKitC String installationPath = URIUtil.toFile(URIUtil.toURI(Platform.getInstallLocation().getURL())).getAbsolutePath(); String commandType = "studio-deploy"; List cmds = new ArrayList(); - String javaCMD = this.getJavaCMD(); + String javaCMD = getJavaCMD(); cmds.add(javaCMD); cmds.add("-jar"); cmds.add(tckCarPath); diff --git a/test/plugins/org.talend.designer.core.test/src/org/talend/designer/core/utils/UnifiedComponentUtilTest.java b/test/plugins/org.talend.designer.core.test/src/org/talend/designer/core/utils/UnifiedComponentUtilTest.java index dbb9ef8c0e4..7ce67ad00fe 100644 --- a/test/plugins/org.talend.designer.core.test/src/org/talend/designer/core/utils/UnifiedComponentUtilTest.java +++ b/test/plugins/org.talend.designer.core.test/src/org/talend/designer/core/utils/UnifiedComponentUtilTest.java @@ -86,10 +86,11 @@ public class UnifiedComponentUtilTest { } @Test - public void testFilterUnifiedComponent4Sybase() throws Exception { + public void testFilterUnifiedComponent4Filter() throws Exception { ProxyRepositoryFactory proxyRepositoryFactory = ProxyRepositoryFactory.getInstance(); IRepositoryViewObject metadataRepObject = null; try { + // sybase Property metadataProperty = PropertiesFactory.eINSTANCE.createProperty(); DatabaseConnectionItem metadataItem = PropertiesFactory.eINSTANCE.createDatabaseConnectionItem(); ItemState metadataItemState = PropertiesFactory.eINSTANCE.createItemState(); @@ -133,10 +134,33 @@ public class UnifiedComponentUtilTest { EDatabaseTypeName.SYBASEASE.getDisplayName()); boolean componentExist = isComponentExist(filterUnifiedComponent, "tSybaseOutputBulkExec"); assertTrue(componentExist); - componentExist = isComponentExist(filterUnifiedComponent, "tSybaseIQOutputBulkExec"); - assertFalse(componentExist); componentExist = isComponentExist(filterUnifiedComponent, "tDBOutputBulkExec"); assertTrue(componentExist); + + // redshift + connection.setDatabaseType(EDatabaseTypeName.REDSHIFT.getDisplayName()); + proxyRepositoryFactory.save(metadataItem); + metadataRepObject = proxyRepositoryFactory.getSpecificVersion(metadataProperty.getId(), metadataProperty.getVersion(), + true); + RepositoryNode metadataNode1 = new RepositoryNode(metadataRepObject, null, ENodeType.REPOSITORY_ELEMENT); + IComponentName rcSetting1 = RepositoryComponentManager.getSetting(metadataItem, + ERepositoryObjectType.METADATA_CONNECTIONS); + List neededComponents1 = RepositoryComponentManager.filterNeededComponents(metadataItem, metadataNode1, + ERepositoryObjectType.METADATA_CONNECTIONS, true, metadataRepObject.getProjectLabel()); + RepositoryComponentSetting compsetting1 = new RepositoryComponentSetting(); + compsetting1.setInputComponent(rcSetting1.getInputComponentName()); + compsetting1.setOutputComponent(rcSetting1.getOutPutComponentName()); + compsetting1.setDefaultComponent(rcSetting1.getDefaultComponentName()); + List filterUnifiedComponent1 = UnifiedComponentUtil.filterUnifiedComponent(compsetting1, + neededComponents1, EDatabaseTypeName.REDSHIFT.getDisplayName()); + componentExist = isComponentExist(filterUnifiedComponent1, "tRedshiftInput"); + assertTrue(componentExist); + componentExist = isComponentExist(filterUnifiedComponent1, "tRedshiftOutput"); + assertTrue(componentExist); + componentExist = isComponentExist(filterUnifiedComponent1, "tDBInput"); + assertTrue(componentExist); + componentExist = isComponentExist(filterUnifiedComponent1, "tDBOutput"); + assertTrue(componentExist); } finally { if (metadataRepObject != null) { proxyRepositoryFactory.deleteObjectPhysical(metadataRepObject); diff --git a/test/plugins/org.talend.designer.dbmap.test/src/org/talend/designer/dbmap/managers/MapperManagerTest.java b/test/plugins/org.talend.designer.dbmap.test/src/org/talend/designer/dbmap/managers/MapperManagerTest.java index 54dd9b87f20..b66a1b52b70 100644 --- a/test/plugins/org.talend.designer.dbmap.test/src/org/talend/designer/dbmap/managers/MapperManagerTest.java +++ b/test/plugins/org.talend.designer.dbmap.test/src/org/talend/designer/dbmap/managers/MapperManagerTest.java @@ -14,6 +14,7 @@ package org.talend.designer.dbmap.managers; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; @@ -28,11 +29,14 @@ import org.talend.core.context.RepositoryContext; import org.talend.core.model.components.ComponentCategory; import org.talend.core.model.components.IComponent; import org.talend.core.model.process.EConnectionType; +import org.talend.core.model.process.ElementParameterParser; import org.talend.core.model.process.IConnection; +import org.talend.core.model.process.IElementParameter; import org.talend.core.model.process.INodeConnector; import org.talend.core.model.properties.PropertiesFactory; import org.talend.core.model.properties.Property; import org.talend.core.ui.component.ComponentsFactoryProvider; +import org.talend.designer.core.model.components.EParameterName; import org.talend.designer.core.model.components.ElementParameter; import org.talend.designer.core.model.components.NodeConnector; import org.talend.designer.core.ui.editor.connections.Connection; @@ -215,4 +219,39 @@ public class MapperManagerTest { property.setVersion(VersionUtils.DEFAULT_VERSION); return property; } + + @Test + public void testRestoreMapperModelFromInternalData() { + dbMapComponent.initialize(); + dbMapComponent.setOriginalNode(targetNode); + dbMapComponent.restoreMapperModelFromInternalData(); + String activeDelimited = ElementParameterParser.getValue(targetNode, "__ACTIVE_DATABASE_DELIMITED_IDENTIFIERS__"); + String useAlias = ElementParameterParser.getValue(targetNode, "__USE_ALIAS_IN_OUTPUT_TABLE__"); + assertTrue("false".equals(activeDelimited)); + assertTrue("false".equals(useAlias)); + + IElementParameter activeDelimitedParam = targetNode + .getElementParameter(EParameterName.ACTIVE_DATABASE_DELIMITED_IDENTIFIERS.getName()); + IElementParameter useAliasParam = targetNode.getElementParameter(EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName()); + activeDelimitedParam.setValue("true"); + useAliasParam.setValue("true"); + activeDelimited = ElementParameterParser.getValue(targetNode, "__ACTIVE_DATABASE_DELIMITED_IDENTIFIERS__"); + useAlias = ElementParameterParser.getValue(targetNode, "__USE_ALIAS_IN_OUTPUT_TABLE__"); + assertTrue("true".equals(activeDelimited)); + assertTrue("true".equals(useAlias)); + + activeDelimitedParam.setValue(false); + useAliasParam.setValue(false); + activeDelimited = ElementParameterParser.getValue(targetNode, "__ACTIVE_DATABASE_DELIMITED_IDENTIFIERS__"); + useAlias = ElementParameterParser.getValue(targetNode, "__USE_ALIAS_IN_OUTPUT_TABLE__"); + assertTrue("false".equals(activeDelimited)); + assertTrue("false".equals(useAlias)); + + activeDelimitedParam.setValue(true); + useAliasParam.setValue(true); + activeDelimited = ElementParameterParser.getValue(targetNode, "__ACTIVE_DATABASE_DELIMITED_IDENTIFIERS__"); + useAlias = ElementParameterParser.getValue(targetNode, "__USE_ALIAS_IN_OUTPUT_TABLE__"); + assertTrue("true".equals(activeDelimited)); + assertTrue("true".equals(useAlias)); + } } diff --git a/test/plugins/org.talend.sdk.component.studio-integration.test/src/main/java/org/talend/sdk/component/studio/util/TaCokitCarFeatureTest.java b/test/plugins/org.talend.sdk.component.studio-integration.test/src/main/java/org/talend/sdk/component/studio/util/TaCokitCarFeatureTest.java new file mode 100644 index 00000000000..c390c627811 --- /dev/null +++ b/test/plugins/org.talend.sdk.component.studio-integration.test/src/main/java/org/talend/sdk/component/studio/util/TaCokitCarFeatureTest.java @@ -0,0 +1,63 @@ +// ============================================================================ +// +// Copyright (C) 2006-2022 Talend Inc. - www.talend.com +// +// This source code is available under agreement available at +// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt +// +// You should have received a copy of the agreement +// along with this program; if not, write to Talend SA +// 9 rue Pages 92150 Suresnes, France +// +// ============================================================================ +package org.talend.sdk.component.studio.util; + +import org.eclipse.core.runtime.Platform; + +import static org.junit.Assert.assertTrue; + +import java.io.File; + +import org.apache.commons.lang3.StringUtils; +import org.talend.commons.utils.system.EclipseCommandLine; +import org.talend.sdk.component.studio.update.TaCoKitCarFeature; +import org.junit.Test; + +/** + * @author bhe created on Apr 8, 2022 + * + */ +public class TaCokitCarFeatureTest { + + @Test + public void testGetJavaCMD() throws Exception { + + String vm = System.getProperty(EclipseCommandLine.PROP_VM); + + // windows + if (Platform.getOS().equals(Platform.OS_WIN32)) { + + if (!StringUtils.isEmpty(vm)) { + + String javaCMD = TaCoKitCarFeature.getJavaCMD(); + assertTrue(StringUtils.endsWith(javaCMD, "java.exe")); + + assertTrue(new File(javaCMD).exists()); + } + + } + + // linux + if (!Platform.getOS().equals(Platform.OS_WIN32)) { + + if (!StringUtils.isEmpty(vm)) { + + String javaCMD = TaCoKitCarFeature.getJavaCMD(); + assertTrue(StringUtils.endsWith(javaCMD, "java")); + + assertTrue(new File(javaCMD).exists()); + } + } + } + +}