Compare commits

..

1 Commits

Author SHA1 Message Date
vdrokov
142733c3ce Revert "fix(TESB-30317): [CI Builder] Some models throw error "context file d… (#5242)"
This reverts commit 89a48f51e3.
2020-10-06 12:53:59 +03:00
59 changed files with 214 additions and 1739 deletions

View File

@@ -1,57 +0,0 @@
---
version: 7.2.1
module: https://talend.poolparty.biz/coretaxonomy/42
product:
- https://talend.poolparty.biz/coretaxonomy/23
---
# TPS-4894
| Info | Value |
| ---------------- | ---------------- |
| Patch Name | Patch\_20210806\_TPS-4894\_v1-7.2.1 |
| Release Date | 2021-08-06 |
| Target Version | 20190620_1446-V7.2.1 |
| Product affected | Talend Studio |
## Introduction
This is a self-contained patch.
**NOTE**: For information on how to obtain this patch, reach out to your Support contact at Talend.
## Fixed issues
This patch contains the following fixes:
- TPS-4894 [7.2.1] FTPS issue with JAVA Open JDK - 1.8.0_282-b08 (TDI-46016)
## Prerequisites
Consider the following requirements for your system:
- Talend Studio 7.2.1 must be installed.
## Installation
### Installing the patch using Software update
1) Logon TAC and switch to Configuration->Software Update, then enter the correct values and save referring to the documentation: https://help.talend.com/reader/f7Em9WV_cPm2RRywucSN0Q/j9x5iXV~vyxMlUafnDejaQ
2) Switch to Software update page, where the new patch will be listed. The patch can be downloaded from here into the nexus repository.
3) On Studio Side: Logon Studio with remote mode, on the logon page the Update button is displayed: click this button to install the patch.
### Installing the patch using Talend Studio
1) Create a folder named "patches" under your studio installer directory and copy the patch .zip file to this folder.
2) Restart your studio: a window pops up, then click OK to install the patch, or restart the commandline and the patch will be installed automatically.
### Installing the patch using Commandline
Execute the following commands:
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}

View File

@@ -1166,36 +1166,16 @@ if (execStat) {
<% if(exist_tSQLDB) { %>
private void closeSqlDbConnections() {
boolean shutdownAbandonedConnections = false;
try {
Object obj_conn;
<% for (INode sqlDbComponent : sqlDbComponentsList) { %>
obj_conn = globalMap.remove("conn_<%=sqlDbComponent.getUniqueName() %>");
if (obj_conn != null) {
java.sql.Connection conn = (java.sql.Connection)obj_conn;
String originalURL = conn.getMetaData().getURL();
java.sql.Driver drv = java.sql.DriverManager.getDriver(originalURL);
String driverClass = drv.getClass().getName();
conn.close();
if("com.mysql.cj.jdbc.Driver".equals(driverClass) && routines.system.BundleUtils.inOSGi()) {
shutdownAbandonedConnections = true;
}
if (null != obj_conn) {
((java.sql.Connection) obj_conn).close();
}
<% } %>
} catch (java.lang.Exception e) {
}
if (shutdownAbandonedConnections) {
try {
Class.forName("com.mysql.cj.jdbc.AbandonedConnectionCleanupThread").
getMethod("uncheckedShutdown").invoke(null, (Object[]) null);
} catch(java.lang.Exception e) {
}
}
}
<% } %>

View File

@@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.talend.components.lib</groupId>
<groupId>org.talend.libraries</groupId>
<artifactId>commons-net-ftps-proxy</artifactId>
<version>3.6.1-talend-20190819</version>
<version>3.6.1-talend-20190128</version>
<name>commons-net-talend</name>

View File

@@ -3,7 +3,6 @@ package org.talend.ftp;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.Socket;
import java.net.InetAddress;
import java.util.Locale;
import javax.net.ssl.SSLContext;
@@ -30,13 +29,11 @@ public class SSLSessionReuseFTPSClient extends FTPSClient {
final Object cache = sessionHostPortCache.get(context);
final Method putMethod = cache.getClass().getDeclaredMethod("put", Object.class, Object.class);
putMethod.setAccessible(true);
InetAddress address = socket.getInetAddress();
int port = socket.getPort();
String key = String.format("%s:%s", address.getHostName(), String.valueOf(port)).toLowerCase(Locale.ROOT);
putMethod.invoke(cache, key, session);
key = String.format("%s:%s", address.getHostAddress(), String.valueOf(port)).toLowerCase(Locale.ROOT);
final Method getHostMethod = socket.getClass().getDeclaredMethod("getHost");
getHostMethod.setAccessible(true);
Object host = getHostMethod.invoke(socket);
final String key =
String.format("%s:%s", host, String.valueOf(socket.getPort())).toLowerCase(Locale.ROOT);
putMethod.invoke(cache, key, session);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -140,15 +140,7 @@
</PARAMETERS>
<ADVANCED_PARAMETERS>
<PARAMETER
NAME="USE_UPDATE_STATEMENT"
FIELD="CHECK"
NUM_ROW="10"
SHOW_IF="DATA_ACTION=='UPDATE'"
>
<DEFAULT>false</DEFAULT>
</PARAMETER>
<ADVANCED_PARAMETERS>
</ADVANCED_PARAMETERS>
<CODEGENERATION>

View File

@@ -35,7 +35,6 @@ skeleton="../templates/db_output_bulk.skeleton"
String differenttable = ElementParameterParser.getValue(node, "__DIFFERENT_TABLE_NAME__");
boolean useDifferentTable = "true".equals(ElementParameterParser.getValue(node, "__USE_DIFFERENT_TABLE__"));
boolean isTableNameVariable="true".equals(ElementParameterParser.getValue(node, "__IS_TABLE_NAME_VARIABLE__"));
boolean useUpdateStatement="true".equals(ElementParameterParser.getValue(node, "__USE_UPDATE_STATEMENT__"));
%>
String select_query_<%=cid %> = null;
String tableName_<%=cid%> = null;
@@ -157,36 +156,21 @@ skeleton="../templates/db_output_bulk.skeleton"
}
if(("INSERT").equals(dataAction)){
%>
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
<%
} else if (("UPDATE").equals(dataAction)){
if(useUpdateStatement){
%>
String updateQuery_<%=cid %> = select_query_<%=cid %>;
<%
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
%>
if (updateQuery_<%=cid %>.toUpperCase().contains(" WHERE ")) {
updateQuery_<%=cid %> += " AND (" + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%> + ")";
} else {
updateQuery_<%=cid %> += " WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
}
<%
}
} else {
%>
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
<%
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
%>
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
<%
}
%>
;
%>
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
<%
} else if (("UPDATE").equals(dataAction)){
%>
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
<%
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
%>
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
<%
}
%>
;
<%
}
} else if (("DELETE").equals(dataAction)){
%>
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "

View File

@@ -40,6 +40,4 @@ TABLE_ACTION.ITEM.CREATE_IF_NOT_EXISTS=Create table if not exists
TABLE_ACTION.ITEM.DROP_IF_EXISTS_AND_CREATE=Drop table if exists and create
TABLE_ACTION.ITEM.DROP_CREATE=Drop and create table
TABLE_ACTION.ITEM.NONE=None
TABLE_ACTION.NAME=Action on table
USE_UPDATE_STATEMENT.NAME=Use update statement without subqueries
TABLE_ACTION.NAME=Action on table

View File

@@ -239,7 +239,7 @@
<IMPORT NAME="Java-FTP" MODULE="edtftpj-2.5.0.jar" MVN="mvn:com.enterprisedt/edtftpj/2.5.0" UrlPath="platform:/plugin/org.talend.libraries.ftp/lib/edtftpj-2.5.0.jar" REQUIRED_IF="(SFTP == 'false') AND (FTPS == 'false')"/>
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true')"/>
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true')" />
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar" MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819" REQUIRED_IF="(FTPS == 'true')" />
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar" MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" REQUIRED_IF="(FTPS == 'true')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -296,8 +296,8 @@
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="jakarta-oro" MODULE="jakarta-oro-2.0.8.jar" MVN="mvn:org.talend.libraries/jakarta-oro-2.0.8/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache/lib/jakarta-oro-2.0.8.jar" REQUIRED="true" />
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar"
MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819"
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" UrlPath="platform:/plugin/org.talend.designer.components.localprovider/components/tFTPConnection/commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -283,8 +283,8 @@ COMPATIBILITY="ALL"
<IMPORT NAME="Java-FTP" MODULE="edtftpj-2.5.0.jar" MVN="mvn:com.enterprisedt/edtftpj/2.5.0" UrlPath="platform:/plugin/org.talend.libraries.ftp/lib/edtftpj-2.5.0.jar" REQUIRED_IF="(SFTP == 'false') AND (FTPS == 'false') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar"
MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819"
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" UrlPath="platform:/plugin/org.talend.designer.components.localprovider/components/tFTPConnection/commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -261,8 +261,8 @@
<IMPORT NAME="Java-FTP" MODULE="edtftpj-2.5.0.jar" MVN="mvn:com.enterprisedt/edtftpj/2.5.0" REQUIRED_IF="(SFTP == 'false') AND (FTPS == 'false') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar"
MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819"
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" UrlPath="platform:/plugin/org.talend.designer.components.localprovider/components/tFTPConnection/commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -258,8 +258,8 @@
<IMPORT NAME="Java-FTP" MODULE="edtftpj-2.5.0.jar" MVN="mvn:com.enterprisedt/edtftpj/2.5.0" UrlPath="platform:/plugin/org.talend.libraries.ftp/lib/edtftpj-2.5.0.jar" REQUIRED_IF="(SFTP == 'false') AND (FTPS == 'false') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar"
MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819"
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" UrlPath="platform:/plugin/org.talend.designer.components.localprovider/components/tFTPConnection/commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -302,8 +302,8 @@ COMPATIBILITY="ALL"
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="jakarta-oro" MODULE="jakarta-oro-2.0.8.jar" MVN="mvn:org.talend.libraries/jakarta-oro-2.0.8/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache/lib/jakarta-oro-2.0.8.jar" REQUIRED="true" />
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar"
MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819"
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" UrlPath="platform:/plugin/org.talend.designer.components.localprovider/components/tFTPConnection/commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -346,8 +346,8 @@ COMPATIBILITY="ALL"
<IMPORT NAME="Java-FTP" MODULE="edtftpj-2.5.0.jar" MVN="mvn:com.enterprisedt/edtftpj/2.5.0" UrlPath="platform:/plugin/org.talend.libraries.ftp/lib/edtftpj-2.5.0.jar" REQUIRED_IF="(SFTP == 'false') AND (FTPS == 'false') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar"
MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819"
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" UrlPath="platform:/plugin/org.talend.designer.components.localprovider/components/tFTPConnection/commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -264,8 +264,8 @@ COMPATIBILITY="ALL"
<IMPORT NAME="Java-FTP" MODULE="edtftpj-2.5.0.jar" MVN="mvn:com.enterprisedt/edtftpj/2.5.0" UrlPath="platform:/plugin/org.talend.libraries.ftp/lib/edtftpj-2.5.0.jar" REQUIRED_IF="(SFTP == 'false') AND (FTPS == 'false') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar"
MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819"
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" UrlPath="platform:/plugin/org.talend.designer.components.localprovider/components/tFTPConnection/commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -253,8 +253,8 @@ COMPATIBILITY="ALL"
<IMPORT NAME="Java-SFTP" MODULE="jsch-0.1.55.jar" MVN="mvn:com.jcraft/jsch/0.1.55" REQUIRED_IF="(SFTP == 'true') AND (USE_EXISTING_CONNECTION == 'false')"/>
<IMPORT NAME="jakarta-oro" MODULE="jakarta-oro-2.0.8.jar" MVN="mvn:org.talend.libraries/jakarta-oro-2.0.8/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache/lib/jakarta-oro-2.0.8.jar" REQUIRED="true" />
<IMPORT NAME="Java-FTPS" MODULE="commons-net-3.6.jar" MVN="mvn:commons-net/commons-net/3.6" REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190819.jar"
MVN="mvn:org.talend.components.lib/commons-net-ftps-proxy/3.6.1-talend-20190819"
<IMPORT NAME="Java-FTPS-talend" MODULE="commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
MVN="mvn:org.talend.libraries/commons-net-ftps-proxy/3.6.1-talend-20190128" UrlPath="platform:/plugin/org.talend.designer.components.localprovider/components/tFTPConnection/commons-net-ftps-proxy-3.6.1-talend-20190128.jar"
REQUIRED_IF="(FTPS == 'true') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -18,7 +18,7 @@
<thashfile.dir>${project.basedir}/components/tHashInput</thashfile.dir>
<thashfile.version>3.0-20170711</thashfile.version>
<ftpProxy.dir>${project.basedir}/components/tFTPConnection</ftpProxy.dir>
<ftpProxy.version>3.6.1-talend-20190819</ftpProxy.version>
<ftpProxy.version>3.6.1-talend-20190128</ftpProxy.version>
<talendMQRFH2.dir>${project.basedir}/components/tMomInput</talendMQRFH2.dir>
<talendMQRFH2.version>1.0.1-20190206</talendMQRFH2.version>
<talendMQConnectionUtil.dir>${project.basedir}/components/tMomConnection</talendMQConnectionUtil.dir>
@@ -125,7 +125,7 @@
<outputDirectory>${thashfile.dir}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.talend.components.lib</groupId>
<groupId>org.talend.libraries</groupId>
<artifactId>commons-net-ftps-proxy</artifactId>
<version>${ftpProxy.version}</version>
<type>jar</type>

View File

@@ -18,7 +18,6 @@ import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IPath;
import org.talend.commons.CommonsPlugin;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.properties.Item;
@@ -101,7 +100,7 @@ public class StandardJobOSGiBundleBuildProvider extends RepositoryObjectTypeBuil
*/
@SuppressWarnings("unchecked")
private void fixDefaultBuildType(Property property) {
if(CommonsPlugin.isHeadless() && property != null && property.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE) == null) {
if(property != null && property.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE) == null) {
property.getAdditionalProperties().put(TalendProcessArgumentConstant.ARG_BUILD_TYPE, OSGI);
}
}

View File

@@ -379,8 +379,6 @@ public enum EParameterName {
ACTIVE_DATABASE_DELIMITED_IDENTIFIERS("Active database delimited identifiers"), //$NON-NLS-1$
USE_ALIAS_IN_OUTPUT_TABLE("Use alias in output table"), //$NON-NLS-1$
// for tDataprepRun
PREPARATION_ID("PREPARATION_ID");

View File

@@ -106,8 +106,6 @@ public final class Expression {
}
}
private static final String CONTAINS = "CONTAINS"; //$NON-NLS-1$
private Expression(String expressionString) {
this.expressionString = expressionString;
}
@@ -307,10 +305,6 @@ public final class Expression {
if ((simpleExpression.contains("SPARK_VERSION["))) { //$NON-NLS-1$
return evaluateSparkVersion(simpleExpression, listParam, currentParam);
}
if ((simpleExpression.contains(CONTAINS))) { //$NON-NLS-1$
return evaluateContains(simpleExpression, listParam);
}
List<String> paraNames = getParaNamesFromIsShowFunc(simpleExpression);
if (paraNames.size() > 0) {
@@ -1069,28 +1063,5 @@ public final class Expression {
}
return false;
}
public static boolean evaluateContains(String simpleExpression, List<? extends IElementParameter> listParam) {
//Split to get param name and param value to look after
String[] splitted = simpleExpression.split(CONTAINS);
if (splitted.length != 2) {
return false;
}
String paramName = splitted[0].trim();
String paramValue = splitted[1].trim();
//Look for the param name in list
IElementParameter param = listParam.stream()
.filter(p -> paramName.equals(p.getName()))
.findAny()
.orElse(null);
if (param == null || ! EParameterFieldType.TABLE.equals(param.getFieldType())) {
return false;
}
// Check if we can find paraValue among table lines
return ((List<Map<String, Object>>) param.getValue()).stream()
.anyMatch(line -> paramValue.equals(line.toString()));
}
}

View File

@@ -429,8 +429,6 @@ public abstract class Processor implements IProcessor, IEclipseProcessor, Talend
*/
@Override
public String getInterpreter() throws ProcessorException {
if (this.isLinuxTargetPlatform())
return "java";
return interpreter;
}
@@ -776,13 +774,6 @@ public abstract class Processor implements IProcessor, IEclipseProcessor, Talend
}
return false;
}
protected boolean isLinuxTargetPlatform() {
if (targetPlatform != null && Platform.OS_LINUX.equals(targetPlatform.toLowerCase())) {
return true;
}
return false;
}
public boolean shouldRunAsExport() {
return false; // by default, for standard job, run in .Java project

View File

@@ -12,15 +12,11 @@
// ============================================================================
package org.talend.designer.core.ui.editor.cmd;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.gef.commands.Command;
import org.talend.core.model.process.IConnection;
import org.talend.core.model.process.IConnectionCategory;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.IExternalNode;
import org.talend.core.model.process.INode;
import org.talend.core.model.utils.ContextParameterUtils;
import org.talend.core.model.utils.TalendTextUtils;
import org.talend.designer.core.i18n.Messages;
import org.talend.designer.core.model.components.EParameterName;
import org.talend.designer.core.ui.editor.process.Process;
@@ -95,8 +91,6 @@ public class ChangeConnTextCommand extends Command {
UpgradeElementHelper.renameData(connection.getTarget(), oldName, newName);
((Process) connection.getSource().getProcess()).checkProcess();
updateELTElementParameter(connection.getSource(), newName);
}
@Override
@@ -134,52 +128,4 @@ public class ChangeConnTextCommand extends Command {
((Process) connection.getSource().getProcess()).checkProcess();
}
public void updateELTElementParameter(INode iNode, String newName) {
// TUP-29072 Solution :if link name equals the schema.tablename,when edit on the link,should update the default
// schema/default table in the input component , then the table name will updated automatically in the sql.The
// solution will only work for simple cases. For complex case with java code and global map in link/default
// schema/default table , it won't work.
if (iNode != null && iNode.isELTComponent()) {
boolean update = false;
String defaultSchemaName = null;
String defaultTableName = null;
if (StringUtils.isNotBlank(newName)) {
String newNameTemp = newName;
int newNameLength = newNameTemp.length();
// Name cases:context.a.context.b /context.a.b /a.context.b /a.b /b
if (ContextParameterUtils.isContainContextParam(newNameTemp)) {
if (newNameTemp.startsWith(ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX)) {
int index = newNameTemp.indexOf(".", //$NON-NLS-1$
ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX.length());
defaultSchemaName = newNameTemp.substring(0, index);
defaultTableName = newNameTemp.substring(index + 1, newNameLength);
update = true;
} else {
int index = newNameTemp.indexOf(".");//$NON-NLS-1$
defaultSchemaName = newNameTemp.substring(0, index);
defaultTableName = newNameTemp.substring(index + 1, newNameLength);
update = true;
}
} else {
String[] names = newNameTemp.split("\\.");//$NON-NLS-1$
if (names.length == 2) {
defaultSchemaName = names[0];
defaultTableName = names[1];
update = true;
}
}
}
if (update) {
IElementParameter schemaParam = iNode.getElementParameter("ELT_SCHEMA_NAME");//$NON-NLS-1$
IElementParameter tableParam = iNode.getElementParameter("ELT_TABLE_NAME"); //$NON-NLS-1$
if (schemaParam != null && StringUtils.isNotBlank(defaultSchemaName)) {
schemaParam.setValue(TalendTextUtils.addQuotes(defaultSchemaName));
}
if (tableParam != null && StringUtils.isNotBlank(defaultTableName)) {
tableParam.setValue(TalendTextUtils.addQuotes(defaultTableName));
}
}
}
}
}

View File

@@ -1372,8 +1372,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
} else {
boolean canAddElementParameter = false;
String paramName = pType.getName();
if (EParameterName.ACTIVE_DATABASE_DELIMITED_IDENTIFIERS.getName().equals(paramName)
|| EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName().equals(paramName)) {
if (EParameterName.ACTIVE_DATABASE_DELIMITED_IDENTIFIERS.getName().equals(paramName)) {
canAddElementParameter = true;
}
if (canAddElementParameter) {

View File

@@ -175,8 +175,6 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
store.setDefault(ITalendCorePrefConstants.NEXUS_TIMEOUT, 20000);
store.setDefault(ITalendCorePrefConstants.NEXUS_REFRESH_FREQUENCY, 0);
store.setDefault(ITalendCorePrefConstants.NEXUS_SHARE_LIBS, true);
if (!CommonUIPlugin.isFullyHeadless()) {
Display display = Display.getDefault();
if (display == null) {

View File

@@ -114,8 +114,6 @@ public class DeploymentComposite extends AbstractTabComposite {
private boolean isServiceItem;
private boolean isDataServiceJob; // Is ESB SOAP Service Job
private boolean isChildJob;
public DeploymentComposite(Composite parent, int style, TabbedPropertySheetWidgetFactory widgetFactory,
IRepositoryViewObject repositoryViewObject) {
@@ -141,7 +139,6 @@ public class DeploymentComposite extends AbstractTabComposite {
defaultVersion = getDefaultVersion(process.getVersion());
isDataServiceJob = false;
isChildJob = false;
// Disable widgests in case of the job is for ESB data service
if (!process.getComponentsType().equals(ComponentCategory.CATEGORY_4_CAMEL.getName())) {
List<INode> nodes = (List<INode>) process.getGraphicalNodes();
@@ -152,13 +149,6 @@ public class DeploymentComposite extends AbstractTabComposite {
break;
}
}
for (INode node : nodes) {
if ("tRouteInput".equals(node.getComponent().getName())) {
isChildJob = true;
break;
}
}
}
} else {
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
@@ -221,17 +211,6 @@ public class DeploymentComposite extends AbstractTabComposite {
widgetFactory.createLabel(messageComposite,
"SOAP data service cannot be published, deployment setting is \naccording to the defined service.");
}
if (isChildJob) {
Composite messageComposite = new Composite(this, SWT.NONE);
GridLayout layout = new GridLayout(1, false);
layout.horizontalSpacing = 10;
layout.verticalSpacing = 10;
messageComposite.setLayout(layout);
messageComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
widgetFactory.createLabel(messageComposite,
"Deployment parameters will be inherited from parent route during publishing from Studio and Command Line");
}
Composite composite = new Composite(this, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 10;
@@ -318,7 +297,7 @@ public class DeploymentComposite extends AbstractTabComposite {
final Control buildTypeControl = buildTypeCombo.getControl();
buildTypeControl.setVisible(showBuildType);
buildTypeLabel.setVisible(showBuildType);
if (showBuildType) {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put(getObjectType(), getObject());

View File

@@ -490,8 +490,7 @@ public class JavaProcessUtil {
mn = getModuleValue(process, moduleName);
}
String nexusJarVersion = (String) line.get("JAR_NEXUS_VERSION");
if (StringUtils.isNotBlank(nexusJarVersion)) {
if (line.get("JAR_NEXUS_VERSION") != null) {
String a = moduleName.replaceFirst("[.][^.]+$", "");
mn.setMavenUri("mvn:org.talend.libraries/" + a + "/"
+ line.get("JAR_NEXUS_VERSION") + "/jar");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -68,7 +68,9 @@ ToolbarInputZone.widgetTooltip.removeAlias=Remove alias
ToolbarOutputZone.widgetTooltip.addOutputTable=Add output table
ToolbarOutputZone.widgetTooltip.removeOutputTable=Remove selected output table
ToolbarOutputZone.widgetTooltip.mapInputAndOutput=Map automatically inputs and outputs (for empty expressions only)
ToolbarOutputZone.widgetTooltip.delimitedIdentifiers=Active me to add double quotes for schemas to support delimited identifiers.
ToolbarOutputZone.widgetText.autoMap=Auto map\!
ToolbarOutputZone.widgetText.delimitedIdentifiers=Delimited identifiers
EntryContentProposal.metadataColumn=Metadata column
EntryContentProposal.properties=properties :
@@ -157,7 +159,3 @@ HTMLDocGenerator.value=Value
HTMLDocGenerator.values=Values
HTMLDocGenerator.version=Version
ProblemsAnalyser.needAlias.error1=The '{0}' linked table name '{1}' is too complex ,please use alias to generate sql!
PropertySetDialog.title=Property Settings
PropertySetDialog.delimitedIdentifiers.title=Delimited identifiers
PropertySetDialog.useAlias.oracle.title=Automatic alias

View File

@@ -181,29 +181,6 @@ public class DbMapComponent extends AbstractMapComponent {
elemParams.add(activeDelimitedIdentifiersEP);
}
activeDelimitedIdentifiersEP.setValue(getGenerationManager().isUseDelimitedIdentifiers());
//
IElementParameter useAliasInOutputTableEP = origNode
.getElementParameter(EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName());
if (useAliasInOutputTableEP == null) {
useAliasInOutputTableEP = new ElementParameter(origNode);
useAliasInOutputTableEP.setShow(false);
useAliasInOutputTableEP.setFieldType(EParameterFieldType.CHECK);
useAliasInOutputTableEP.setName(EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName());
useAliasInOutputTableEP.setCategory(EComponentCategory.TECHNICAL);
useAliasInOutputTableEP.setNumRow(99);
useAliasInOutputTableEP.setReadOnly(false);
if (getGenerationManager() instanceof OracleGenerationManager) {
boolean disableAlias = Boolean
.valueOf(System.getProperty("elt.oracle.disableColumnAlias", Boolean.FALSE.toString())); //$NON-NLS-1$
if (!disableAlias) {
getGenerationManager().setUseAliasInOutputTable(true);
}
}
List<IElementParameter> elemParams = (List<IElementParameter>) origNode.getElementParameters();
elemParams.add(useAliasInOutputTableEP);
}
useAliasInOutputTableEP.setValue(getGenerationManager().isUseAliasInOutputTable());
}
mapperMain.loadModelFromInternalData();
metadataListOut = mapperMain.getMetadataListOut();
@@ -635,7 +612,6 @@ public class DbMapComponent extends AbstractMapComponent {
throw new IllegalArgumentException(Messages.getString("DbMapComponent.unknowValue") + value); //$NON-NLS-1$
}
updateUseDelimitedIdentifiersStatus();
updateUseAliasInOutputTableStatus();
}
return generationManager;
@@ -645,7 +621,6 @@ public class DbMapComponent extends AbstractMapComponent {
public void setOriginalNode(INode originalNode) {
super.setOriginalNode(originalNode);
updateUseDelimitedIdentifiersStatus();
updateUseAliasInOutputTableStatus();
}
private void updateUseDelimitedIdentifiersStatus() {
@@ -667,25 +642,6 @@ public class DbMapComponent extends AbstractMapComponent {
}
}
private void updateUseAliasInOutputTableStatus() {
if (generationManager == null) {
return;
}
INode oriNode = getOriginalNode();
if (oriNode != null) {
IElementParameter useAliasInOutputTableEP = oriNode
.getElementParameter(EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName());
boolean useAliasInOutputTable = false;
if (useAliasInOutputTableEP != null) {
Object value = useAliasInOutputTableEP.getValue();
if (value != null) {
useAliasInOutputTable = Boolean.valueOf(value.toString());
}
}
generationManager.setUseAliasInOutputTable(useAliasInOutputTable);
}
}
/*
* (non-Javadoc)
*

View File

@@ -12,8 +12,8 @@
// ============================================================================
package org.talend.designer.dbmap.language.generation;
import static java.util.Optional.*;
import static java.util.stream.Collectors.*;
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
import java.util.ArrayList;
import java.util.Collections;
@@ -95,8 +95,6 @@ public abstract class DbGenerationManager {
private Boolean useDelimitedIdentifiers;
private Boolean useAliasInOutputTable;
protected Set<String> subQueryTable = new HashSet<String>();
protected INode source;
@@ -650,15 +648,12 @@ public abstract class DbGenerationManager {
}
}
// Update
String targetSchemaTable = getDifferentTable(dbMapComponent, outputTableName);
if (targetSchemaTable == null) {
targetSchemaTable = outTableName;
}
String targetSchemaTable = outTableName;
IElementParameter eltSchemaNameParam = source.getElementParameter("ELT_SCHEMA_NAME"); //$NON-NLS-1$
if (eltSchemaNameParam != null && eltSchemaNameParam.getValue() != null) {
String schema = TalendQuoteUtils.removeQuotesIfExist(String.valueOf(eltSchemaNameParam.getValue()));
if (org.apache.commons.lang.StringUtils.isNotEmpty(schema)) {
targetSchemaTable = schema + DbMapSqlConstants.DOT + targetSchemaTable;
targetSchemaTable = schema + DbMapSqlConstants.DOT + outTableName;
}
}
@@ -679,7 +674,7 @@ public abstract class DbGenerationManager {
int lstSizeOutTableEntries = metadataTableEntries.size();
for (int i = 0; i < lstSizeOutTableEntries; i++) {
ExternalDbMapEntry dbMapEntry = metadataTableEntries.get(i);
String columnEntry = dbMapEntry.getName();
String columnEntry = outTableName + DbMapSqlConstants.DOT + dbMapEntry.getName();
String expression = dbMapEntry.getExpression();
expression = initExpression(component, dbMapEntry);
expression = addQuoteForSpecialChar(expression, component);
@@ -726,6 +721,13 @@ public abstract class DbGenerationManager {
// From
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.FROM);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, targetSchemaTable);
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
// Inner Join
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.INNER_JOIN);
List<ExternalDbMapTable> inputTables = data.getInputTables();
// load input table in hash
@@ -744,10 +746,30 @@ public abstract class DbGenerationManager {
for (int i = 0; i < lstSizeInputTables; i++) {
ExternalDbMapTable inputTable = inputTables.get(i);
IJoinType joinType = null;
if (i == 0) {
joinType = AbstractDbLanguage.JOIN.NO_JOIN;
} else {
joinType = language.getJoin(inputTable.getJoinType());
}
if (language.unuseWithExplicitJoin().contains(joinType) && !explicitJoin) {
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, inputTable.getTableName());
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, inputTable.getAlias());
}
boolean commaCouldBeAdded = i > 0;
buildTableDeclaration(component, sb, inputTable, commaCouldBeAdded, false, false);
}
// On
if (org.apache.commons.lang.StringUtils.isNotEmpty(keyColumn)) {
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.ON);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, keyColumn);
}
// where
StringBuilder sbWhere = new StringBuilder();
this.tabSpaceString = DEFAULT_TAB_SPACE_STRING;
@@ -863,7 +885,7 @@ public abstract class DbGenerationManager {
}
protected void checkParameters(DbMapComponent component) {
checkSpecialParameters(component);
checkUseDelimitedIdentifiers(component);
}
protected boolean checkUseUpdateStatement(DbMapComponent dbMapComponent, String outputTableName) {
@@ -882,53 +904,6 @@ public abstract class DbGenerationManager {
return false;
}
protected String getDifferentTable(DbMapComponent dbMapComponent, String outputTableName) {
if (!"Snowflake".equalsIgnoreCase(getDbType(dbMapComponent))) {//$NON-NLS-1$
return null;
}
List<IConnection> outputConnections = (List<IConnection>) dbMapComponent.getOutgoingConnections();
if (outputConnections != null) {
IConnection iconn = this.getConnectonByMetadataName(outputConnections, outputTableName);
if (iconn != null && iconn.getTarget() != null) {
source = iconn.getTarget();
IElementParameter useDifferentTable = source.getElementParameter("USE_DIFFERENT_TABLE"); //$NON-NLS-1$
if (useDifferentTable != null && useDifferentTable.isShow(source.getElementParameters())
&& useDifferentTable.getValue() != null) {
if (Boolean.valueOf(useDifferentTable.getValue().toString())) {
IElementParameter differentTable = source.getElementParameter("DIFFERENT_TABLE_NAME"); //$NON-NLS-1$
if (differentTable != null && differentTable.getValue() != null) {
String table = TalendTextUtils.removeQuotes(String.valueOf(differentTable.getValue()));
if (org.apache.commons.lang.StringUtils.isNotBlank(table)) {
return table;
}
}
}
}
}
}
return null;
}
protected String getDbType(DbMapComponent component) {
IElementParameter mappingPara = component.getElementParameter(EParameterName.MAPPING.getName());
if (mappingPara == null) {
return null;
}
String mapping = (String) mappingPara.getValue();
if (mapping == null) {
return null;
}
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(mapping);
if (mappingTypeRetriever == null) {
return null;
}
Dbms dbms = mappingTypeRetriever.getDbms();
if (dbms == null) {
return null;
}
return dbms.getProduct();
}
/**
* This piece regulates which columns are going to be skipped in UPDATE QUERY generation in SET section if
* <b>SET_COLUMN</b> property exists. This enhancement is needed for tELTOutput component in case of
@@ -943,7 +918,7 @@ public abstract class DbGenerationManager {
.collect(toList());
}
protected void checkSpecialParameters(DbMapComponent component) {
protected void checkUseDelimitedIdentifiers(DbMapComponent component) {
/**
* in elt related component javajets(like tELTMSSqlMap_main.javajet), they don't get DbGenerationManager by
* DbMapComponent#getGenerationManager() while they construct a new manager manually, so some parameters may not
@@ -960,18 +935,6 @@ public abstract class DbGenerationManager {
}
}
}
if (this.useAliasInOutputTable == null) {
this.useAliasInOutputTable = false;
IElementParameter useAliasInOutputTableEP = component
.getElementParameter(EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName());
if (useAliasInOutputTableEP != null) {
Object value = useAliasInOutputTableEP.getValue();
if (value != null) {
setUseAliasInOutputTable(Boolean.valueOf(value.toString()));
}
}
}
}
/**
@@ -1002,17 +965,10 @@ public abstract class DbGenerationManager {
}
}
Set<String> globalMapList = getGlobalMapList(component, expression);
if (globalMapList.size() > 0) {
String tempExpression = expression.trim();
if ((tempExpression.startsWith("\"+") && tempExpression.endsWith("+\"")) //$NON-NLS-1$//$NON-NLS-2$
|| (tempExpression.startsWith("\" +") && tempExpression.endsWith("+ \""))) {//$NON-NLS-1$ //$NON-NLS-2$
return expression;
}
}
for (String globalMapStr : globalMapList) {
String regex = parser.getGlobalMapExpressionRegex(globalMapStr);
String replacement = parser.getGlobalMapReplacement(globalMapStr);
expression = expression.replaceAll(regex, "\" +" + replacement + "+ \"");//$NON-NLS-1$ //$NON-NLS-2$
expression = expression.replaceAll(regex, "\" +" + replacement + "+ \""); //$NON-NLS-1$ //$NON-NLS-2$
}
return expression;
}
@@ -1040,10 +996,6 @@ public abstract class DbGenerationManager {
}
}
protected boolean needAlias(List<IMetadataColumn> columns, ExternalDbMapEntry dbMapEntry, String expression) {
return false;
}
protected void appendSqlQuery(StringBuilder sb, String value) {
appendSqlQuery(sb, value, true);
}
@@ -1127,7 +1079,7 @@ public abstract class DbGenerationManager {
*/
protected boolean buildConditions(DbMapComponent component, StringBuilder sb, ExternalDbMapTable inputTable,
boolean writeForJoin, boolean isFirstClause) {
return buildConditions(component, sb, inputTable, writeForJoin, isFirstClause, false);
return buildConditions(component, sb, inputTable, writeForJoin, isFirstClause, false);
}
/**
@@ -1465,8 +1417,8 @@ public abstract class DbGenerationManager {
}
protected String initExpression(DbMapComponent component, ExternalDbMapEntry dbMapEntry) {
String quote = getQuote(component);
String quto_mark = TalendQuoteUtils.QUOTATION_MARK;
String quote = getQuote(component);
String quto_mark = TalendQuoteUtils.QUOTATION_MARK;
String expression = dbMapEntry.getExpression();
if (expression != null) {
List<Map<String, String>> itemNameList = null;
@@ -1639,23 +1591,23 @@ public abstract class DbGenerationManager {
}
private String getQuote(DbMapComponent component){
String quote = TalendQuoteUtils.QUOTATION_MARK;
IElementParameter mappingPara = component.getElementParameter(EParameterName.MAPPING.getName());
if(mappingPara == null){
return quote;
}
String mapping = (String) mappingPara.getValue();
if(mapping == null){
return quote;
}
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(mapping);
if (mappingTypeRetriever == null) {
return quote;
}
Dbms dbms = mappingTypeRetriever.getDbms();
String product = dbms.getProduct();
EDatabaseTypeName type = EDatabaseTypeName.getTypeFromProductName(product);
return TalendQuoteUtils.getQuoteByDBType(type);
String quote = TalendQuoteUtils.QUOTATION_MARK;
IElementParameter mappingPara = component.getElementParameter(EParameterName.MAPPING.getName());
if(mappingPara == null){
return quote;
}
String mapping = (String) mappingPara.getValue();
if(mapping == null){
return quote;
}
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(mapping);
if (mappingTypeRetriever == null) {
return quote;
}
Dbms dbms = mappingTypeRetriever.getDbms();
String product = dbms.getProduct();
EDatabaseTypeName type = EDatabaseTypeName.getTypeFromProductName(product);
return TalendQuoteUtils.getQuoteByDBType(type);
}
private String getOriginalColumnName(String entryName, DbMapComponent component, ExternalDbMapTable table) {
@@ -1811,15 +1763,6 @@ public abstract class DbGenerationManager {
public void setUseDelimitedIdentifiers(boolean useDelimitedIdentifiers) {
this.useDelimitedIdentifiers = useDelimitedIdentifiers;
}
public boolean isUseAliasInOutputTable() {
return Boolean.TRUE.equals(this.useAliasInOutputTable);
}
public void setUseAliasInOutputTable(boolean useAliasInOutputTable) {
this.useAliasInOutputTable = useAliasInOutputTable;
}
public boolean isConditionChecked(DbMapComponent component, ExternalDbMapTable inputTable) {
List<ExternalDbMapEntry> inputEntries = inputTable.getMetadataTableEntries();
boolean atLeastOneConditionIsChecked = false;

View File

@@ -140,8 +140,24 @@ public class OracleGenerationManager extends DbGenerationManager {
if (expression != null && expression.trim().length() > 0) {
String exp = replaceVariablesForExpression(component, expression);
appendSqlQuery(sb, exp);
boolean needAlias = needAlias(columns, dbMapEntry, expression);
if (!added && needAlias && isUseAliasInOutputTable()) {
DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(language);
TableEntryLocation[] tableEntriesLocationsSources = dataMapExpressionParser
.parseTableEntryLocations(expression);
boolean columnChanged = false;
if (tableEntriesLocationsSources.length > 1) {
columnChanged = true;
} else {
for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
TableEntryLocation location = tableEntriesLocationsSource;
String entryName = getAliasOf(dbMapEntry.getName());
if (location != null && entryName != null
&& !entryName.startsWith("_") && !entryName.equals(location.columnName)) {//$NON-NLS-1$
columnChanged = true;
}
}
}
if (!added && columnChanged) {
String name = DbMapSqlConstants.SPACE + DbMapSqlConstants.AS + DbMapSqlConstants.SPACE
+ getAliasOf(dbMapEntry.getName());
appendSqlQuery(sb, name);
@@ -427,22 +443,4 @@ public class OracleGenerationManager extends DbGenerationManager {
return expression;
}
@Override
protected boolean needAlias(List<IMetadataColumn> columns, ExternalDbMapEntry dbMapEntry, String expression) {
DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(language);
TableEntryLocation[] tableEntriesLocationsSources = dataMapExpressionParser.parseTableEntryLocations(expression);
if (tableEntriesLocationsSources.length > 1) {
return true;
} else {
for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
TableEntryLocation location = tableEntriesLocationsSource;
String entryName = getAliasOf(dbMapEntry.getName());
if (location != null && entryName != null && !entryName.startsWith("_") //$NON-NLS-1$
&& !entryName.equals(location.columnName)) {
return true;
}
}
}
return false;
}
}

View File

@@ -781,11 +781,6 @@ public class MapperManager extends AbstractMapperManager {
uiManager.refreshSqlExpression();
}
public void useAliasInOutputTable(boolean useAliasInOutputTable) {
getComponent().getGenerationManager().setUseAliasInOutputTable(useAliasInOutputTable);
uiManager.refreshSqlExpression();
}
/**
* Getter for problemsManager.
*
@@ -795,15 +790,6 @@ public class MapperManager extends AbstractMapperManager {
return this.problemsManager;
}
public boolean componentIsReadOnly() {
if (getAbstractMapComponent().getOriginalNode().getJobletNode() != null) {
return getAbstractMapComponent().isReadOnly() || getAbstractMapComponent().getOriginalNode().isReadOnly();
}
return getAbstractMapComponent().isReadOnly() || getAbstractMapComponent().getProcess().isReadOnly()
|| getAbstractMapComponent().getOriginalNode().isReadOnly();
}
/**
* DOC amaumont Comment method "addAlias".
*/
@@ -906,4 +892,4 @@ public class MapperManager extends AbstractMapperManager {
return false;
}
}
}

View File

@@ -86,7 +86,6 @@ import org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry;
import org.talend.designer.dbmap.model.tableentry.TableEntryLocation;
import org.talend.designer.dbmap.ui.MapperUI;
import org.talend.designer.dbmap.ui.commands.DataMapTableViewSelectedCommand;
import org.talend.designer.dbmap.ui.dialog.PropertySetDialog;
import org.talend.designer.dbmap.ui.tabs.TabFolderEditors;
import org.talend.designer.dbmap.ui.visualmap.TableEntryProperties;
import org.talend.designer.dbmap.ui.visualmap.link.Link;
@@ -1368,11 +1367,6 @@ public class UIManager extends AbstractUIManager {
return getMapperContainer().getDisplay();
}
@Override
public void openPropertySetDialog() {
new PropertySetDialog(getShell(), mapperManager).open();
}
/**
*
* DOC amaumont Comment method "moveSelectedTable".

View File

@@ -1,144 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2020 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.designer.dbmap.ui.dialog;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.talend.core.model.components.IComponent;
import org.talend.designer.dbmap.i18n.Messages;
import org.talend.designer.dbmap.language.generation.DbGenerationManager;
import org.talend.designer.dbmap.managers.MapperManager;
/**
*
* created by hcyi on Nov 24, 2020 Detailled comment
*
*/
public class PropertySetDialog extends Dialog {
private MapperManager mapperManager;
private DbGenerationManager generationManager;
private Button delimitedIdentifiersButton;
private Button useAliasButton;
private final Color color = new Color(Display.getDefault(), 238, 238, 0);
public PropertySetDialog(Shell parentShell, MapperManager mapperManager) {
super(parentShell);
this.mapperManager = mapperManager;
generationManager = mapperManager.getComponent().getGenerationManager();
}
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
final GridLayout gridLayout = new GridLayout();
gridLayout.marginLeft = 10;
gridLayout.marginTop = 20;
gridLayout.marginHeight = 0;
container.setLayout(gridLayout);
delimitedIdentifiersButton = new Button(container, SWT.CHECK);
delimitedIdentifiersButton.setText(Messages.getString("PropertySetDialog.delimitedIdentifiers.title")); //$NON-NLS-1$
useAliasButton = new Button(container, SWT.CHECK);
useAliasButton.setText(Messages.getString("PropertySetDialog.useAlias.oracle.title")); //$NON-NLS-1$
init();
addListener();
updateStatus();
return container;
}
private void init() {
delimitedIdentifiersButton.setSelection(generationManager.isUseDelimitedIdentifiers());
useAliasButton.setSelection(generationManager.isUseAliasInOutputTable());
// Implement the column alias only for tELTOracleMap now.
boolean enabled = false;
IComponent component = mapperManager.getComponent().getComponent();
if (component != null && "tELTOracleMap".equals(component.getName())) { //$NON-NLS-1$
enabled = true;
}
useAliasButton.setVisible(enabled);
}
private void addListener() {
delimitedIdentifiersButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
mapperManager.useDelimitedIdentifiers(delimitedIdentifiersButton.getSelection());
updateStatus();
}
});
useAliasButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
mapperManager.useAliasInOutputTable(useAliasButton.getSelection());
updateStatus();
}
});
}
private void updateStatus() {
if (generationManager.isUseDelimitedIdentifiers() == delimitedIdentifiersButton.getSelection()) {
delimitedIdentifiersButton.setBackground(null);
} else {
delimitedIdentifiersButton.setBackground(color);
}
if (generationManager.isUseAliasInOutputTable() == useAliasButton.getSelection()) {
useAliasButton.setBackground(null);
} else {
useAliasButton.setBackground(color);
}
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
@Override
protected Point getInitialSize() {
return new Point(500, 300);
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.getString("PropertySetDialog.title")); //$NON-NLS-1$
}
@Override
protected void okPressed() {
mapperManager.useDelimitedIdentifiers(delimitedIdentifiersButton.getSelection());
mapperManager.useAliasInOutputTable(useAliasButton.getSelection());
super.okPressed();
}
}

View File

@@ -28,7 +28,6 @@ public enum ImageInfo {
CHECKED_ICON("/icons/checked.png"), //$NON-NLS-1$
UNCHECKED_ICON("/icons/unchecked.png"), //$NON-NLS-1$
ADD_FILTER_ICON("/icons/addfilter.png"), //$NON-NLS-1$
PROPERTY_TOOL_ICON("/icons/property.png"), //$NON-NLS-1$
;
private String path;

View File

@@ -36,6 +36,8 @@ public class ToolbarOutputZone extends ToolbarZone {
private ToolItem guessItem;
private ToolItem delimitedIdentifiersItem;
public static final String MINIMIZE_TOOLTIP = Messages.getString("ToolbarOutputZone.minimizeTooltip"); //$NON-NLS-1$
public static final String RESTORE_TOOLTIP = Messages.getString("ToolbarOutputZone.restorTooltip"); //$NON-NLS-1$
@@ -82,6 +84,11 @@ public class ToolbarOutputZone extends ToolbarZone {
guessItem.setToolTipText(Messages.getString("ToolbarOutputZone.widgetTooltip.mapInputAndOutput")); //$NON-NLS-1$
guessItem.setText(Messages.getString("ToolbarOutputZone.widgetText.autoMap")); //$NON-NLS-1$
delimitedIdentifiersItem = new ToolItem(getToolBarActions(), SWT.CHECK);
delimitedIdentifiersItem.setToolTipText(Messages.getString("ToolbarOutputZone.widgetTooltip.delimitedIdentifiers")); //$NON-NLS-1$
delimitedIdentifiersItem.setText(Messages.getString("ToolbarOutputZone.widgetText.delimitedIdentifiers")); //$NON-NLS-1$
delimitedIdentifiersItem
.setSelection(getMapperManager().getComponent().getGenerationManager().isUseDelimitedIdentifiers());
}
/**
@@ -116,6 +123,15 @@ public class ToolbarOutputZone extends ToolbarZone {
});
delimitedIdentifiersItem.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
getMapperManager().useDelimitedIdentifiers(delimitedIdentifiersItem.getSelection());
}
});
}
@Override

View File

@@ -45,8 +45,6 @@ public abstract class ToolbarZone {
private ToolItem downTableButton;
private ToolItem propertyButton;
private ToolItem minimizeButton;
protected boolean minimized;
@@ -74,6 +72,9 @@ public abstract class ToolbarZone {
}
}
/**
* DOC amaumont Comment method "createComponents".
*/
public void addCommonsComponents() {
upTableButton = new ToolItem(toolBarActions, SWT.PUSH);
@@ -90,13 +91,6 @@ public abstract class ToolbarZone {
new ToolItem(getToolBarActions(), SWT.SEPARATOR);
if (this instanceof ToolbarInputZone) {
propertyButton = new ToolItem(toolBarActions, SWT.PUSH);
propertyButton.setImage(ImageProviderMapper.getImage(ImageInfo.PROPERTY_TOOL_ICON));
propertyButton.setToolTipText("Setup the configurations of elt map"); //$NON-NLS-1$
propertyButton.setEnabled(!getMapperManager().componentIsReadOnly());
}
minimizeButton = new ToolItem(toolBarActions, SWT.PUSH);
minimizeButton.setEnabled(false);
@@ -133,14 +127,6 @@ public abstract class ToolbarZone {
});
if (propertyButton != null) {
propertyButton.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
uiManager.openPropertySetDialog();
}
});
}
}
public Composite getComposite() {

View File

@@ -46,9 +46,6 @@ public class DataMapExpressionParser {
private static String TABLE_PATTERN = EXPRESSION + SEPARATOR;
private static final String GLOBALMAP_PATTERN = "\\s*(\\(\\s*\\(\\s*String\\s*\\)\\s*globalMap\\s*\\.\\s*get\\s*\\(\\s*\\\"(.+?)\\\"\\s*\\)\\s*\\))\\s*";
private static final String GLOBALMAP_PATTERN2 = "\\s*(\\(\\s*\\(\\s*[a-zA-Z]+\\s*\\)\\s*globalMap\\s*\\.\\s*get\\s*\\(\\s*\\\"(.+?)\\\"\\s*\\)\\s*\\))\\s*";
private static final String GLOBALMAP_PATTERN_ALL = "\\s*\\+\\s*(\\(\\w*\\))?globalMap.get\\s*\\(\\s*\\\"(.+?)\\\"\\s*\\)\\s*\\+\\s*";
private static final String GLOBALMAP_TABLE_EXPRESSION = "(" + GLOBALMAP_PATTERN + "\\." + GLOBALMAP_PATTERN + ")|("
@@ -219,7 +216,7 @@ public class DataMapExpressionParser {
} else {
patternMatcherInput.setInput(sqlQuery);
}
recompilePatternIfNecessary(GLOBALMAP_PATTERN2);
recompilePatternIfNecessary(GLOBALMAP_PATTERN);
while (matcher.contains(patternMatcherInput, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult.group(1) != null) {

View File

@@ -2427,9 +2427,7 @@ public abstract class DataMapTableView extends Composite implements IDataMapTabl
private void parseExpression(ModifiedBeanEvent event, TableViewerCreator tableViewerCreator, ITableEntry tableEntry) {
if (event.column == tableViewerCreator.getColumn(DataMapTableView.ID_EXPRESSION_COLUMN)) {
mapperManager.getUiManager().parseExpression(tableEntry.getExpression(), tableEntry, false, false, false);
if (headerComposite != null && !headerComposite.isDisposed()) {
mapperManager.getUiManager().refreshBackground(false, false);
}
mapperManager.getUiManager().refreshBackground(false, false);
}
}

View File

@@ -826,13 +826,8 @@ public class InputDataMapTableView extends DataMapTableView {
previousStateAtLeastOneHashKey = stateAtLeastOneHashKey;
}
// if user didn't trigger save mapper action ,and click ok to close the window diretly, then it will cause
// closeMapper first then here checkChangementsAfterEntryModifiedOrAdded , the Composite will be disposed.
// so when try to checkLookupTableProblems on a disposed Widget , will cause org.eclipse.swt.SWTException:
// Widget is disposed
if (headerComposite != null && !headerComposite.isDisposed()) {
checkLookupTableProblems(stateAtLeastOneHashKey);
}
checkLookupTableProblems(stateAtLeastOneHashKey);
mapSettingViewerCreator.refresh();
}

View File

@@ -44,7 +44,6 @@
</dependencies>
<build>
<finalName>${talend.job.finalName}</finalName>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
@@ -64,32 +63,8 @@
<Import-Package>${bundle.config.import.package}, *;resolution:=optional</Import-Package>
<Bundle-ClassPath>., {maven-dependencies}</Bundle-ClassPath>
</instructions>
<finalName>${talend.job.finalName}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/assemblies/assembly.xml</descriptor>
</descriptors>
<tarLongFileMode>gnu</tarLongFileMode>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${talend.job.finalName}</finalName>
<archive>
<manifestFile>${current.bundle.resources.dir}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
@@ -115,7 +90,7 @@
</descriptors>
<tarLongFileMode>gnu</tarLongFileMode>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${talend.job.finalName}</finalName>
<finalName>${talend.job.name}-bundle-${project.version}</finalName>
</configuration>
</execution>
</executions>

View File

@@ -1329,7 +1329,6 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
final String rootWorkingDir = getRootWorkingDir(false);
StringBuffer basePath = new StringBuffer(50);
if (isExportConfig() || isRunAsExport()) {
// current path.
basePath.append('.');
@@ -1489,9 +1488,7 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
}
StringBuffer libPath = new StringBuffer();
if (isExportConfig() || isRunAsExport()) {
boolean hasLibPrefix = libPrefixPath.length() > 0;
for (ModuleNeeded neededModule : neededModules) {
if (hasLibPrefix) {
@@ -1583,7 +1580,7 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
Set<JobInfo> infos = getBuildChildrenJobs();
for (JobInfo jobInfo : infos) {
String childJarName = JavaResourcesHelper.getJobFolderName(jobInfo);
String childJarName = JavaResourcesHelper.getJobFolderName(jobInfo.getJobName(), jobInfo.getJobVersion());
exportJar += classPathSeparator + rootWorkingDir + childJarName + FileExtensions.JAR_FILE_SUFFIX;
}
return exportJar;
@@ -1994,17 +1991,13 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
IFolder extResourcePath = externalResourcesFolder.getFolder(jobContextFolderPath);
IFolder resourcesPath = resourcesFolder.getFolder(jobContextFolderPath);
if(!resourcesPath.exists()) {
tProcessJvaProject.createSubFolder(null, resourcesFolder, jobContextFolderPath.toString());
}
if (!extResourcePath.exists()) {
tProcessJvaProject.createSubFolder(null, externalResourcesFolder, jobContextFolderPath.toString());
}
resourcesPath.refreshLocal(IResource.DEPTH_INFINITE, null);
extResourcePath.refreshLocal(IResource.DEPTH_INFINITE, null);
for (IResource resource : extResourcePath.members()) {
IFile context = resourcesPath.getFile(resource.getName());

View File

@@ -209,14 +209,7 @@ public class MavenJavaProcessor extends JavaProcessor {
jobName = basePrcess.getName();
jobVersion = basePrcess.getVersion();
}
String jarName = null;
if (process instanceof Process) {
jarName = JavaResourcesHelper.getJobJarName(jobName, jobVersion, ((Process) process).getProperty());
}
else {
jarName = JavaResourcesHelper.getJobJarName(jobName, jobVersion);
}
String jarName = JavaResourcesHelper.getJobJarName(jobName, jobVersion);
String exportJar = libPrefixPath + jarName + FileExtensions.JAR_FILE_SUFFIX;
if (!isMainJob || isMainJob && !ProcessorUtilities.hasLoopDependency()) {
@@ -225,7 +218,7 @@ public class MavenJavaProcessor extends JavaProcessor {
if (jobInfo.isTestContainer()) {
continue;
}
String childJarName = JavaResourcesHelper.getJobJarName(jobInfo);
String childJarName = JavaResourcesHelper.getJobJarName(jobInfo.getJobName(), jobInfo.getJobVersion());
if (!childJarName.equals(jarName)) {
exportJar += classPathSeparator + libPrefixPath + childJarName + FileExtensions.JAR_FILE_SUFFIX;
}
@@ -234,7 +227,7 @@ public class MavenJavaProcessor extends JavaProcessor {
// for loop dependency, add main classPath
JobInfo mainJobInfo = ProcessorUtilities.getMainJobInfo();
if (!isMainJob && ProcessorUtilities.hasLoopDependency() && mainJobInfo != null) {
String mainJobName = JavaResourcesHelper.getJobJarName(mainJobInfo);
String mainJobName = JavaResourcesHelper.getJobJarName(mainJobInfo.getJobName(), mainJobInfo.getJobVersion());
exportJar += classPathSeparator + libPrefixPath + mainJobName + FileExtensions.JAR_FILE_SUFFIX;
}
return exportJar;
@@ -397,8 +390,8 @@ public class MavenJavaProcessor extends JavaProcessor {
if (!buildCacheManager.isJobBuild(getProperty())) {
deleteExistedJobJarFile(talendJavaProject);
String buildType = getBuildType(getProperty());
if (("ROUTE".equalsIgnoreCase(buildType) || "OSGI".equalsIgnoreCase(buildType) || "STANDALONE".equalsIgnoreCase(buildType)) &&
project != null && ERepositoryObjectType.PROCESS.equals(ERepositoryObjectType.getType(getProperty()))) {
if (("ROUTE".equalsIgnoreCase(buildType) || "OSGI".equalsIgnoreCase(buildType)) && project != null &&
ERepositoryObjectType.PROCESS.equals(ERepositoryObjectType.getType(getProperty()))) {
// TESB-23870
// child routes job project must be compiled explicitly for
// correct child job manifest generation during OSGi packaging
@@ -469,7 +462,7 @@ public class MavenJavaProcessor extends JavaProcessor {
private IFile deleteExistedJobJarFile(final ITalendProcessJavaProject talendJavaProject) throws CoreException {
IFile jobJarFile;
String jobJarName = JavaResourcesHelper.getJobJarName(property)
String jobJarName = JavaResourcesHelper.getJobJarName(property.getLabel(), property.getVersion())
+ FileExtensions.JAR_FILE_SUFFIX;
jobJarFile = talendJavaProject.getTargetFolder().getFile(jobJarName);
if (jobJarFile != null && jobJarFile.exists()) {

View File

@@ -3224,33 +3224,6 @@
name="SpecialUpdateELTTableNameMigrationTask"
version="7.2.1">
</projecttask>
<projecttask
beforeLogon="false"
breaks="7.2.0"
class="org.talend.repository.model.migration.SpecialUpdateELTDefaultNameMigrationTask"
description="Update ELT default table name or schema name"
id="org.talend.repository.model.migration.SpecialUpdateELTDefaultNameMigrationTask"
name="SpecialUpdateELTDefaultNameMigrationTask"
version="7.2.1">
</projecttask>
<projecttask
beforeLogon="false"
breaks="7.2.0"
class="org.talend.repository.model.migration.SpecialUpdateELTEnableColumnAliasMigrationTask"
description="Update ELT to enable oracle column alias"
id="org.talend.repository.model.migration.SpecialUpdateELTEnableColumnAliasMigrationTask"
name="SpecialUpdateELTEnableColumnAliasMigrationTask"
version="7.2.1">
</projecttask>
<projecttask
beforeLogon="true"
breaks="7.2.0"
class="org.talend.repository.model.migration.RemoveSnapshotJarMigrationTask"
id="org.talend.repository.model.migration.RemoveSnapshotJarMigrationTask"
description="Regnerate all poms"
name="RemoveSnapshotJarMigrationTask"
version="7.2.1">
</projecttask>
</extension>
<extension

View File

@@ -28,10 +28,6 @@ jtds
# tdm-lib-di
tdm-lib-di
# Azure
azure-storage
azure-keyvault-core
# JDK8
java8.excludes = geronimo-ws-metadata,\
jakarta.xml.ws-api,\

View File

@@ -1,93 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2020 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.repository.model.migration;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.logging.Logger;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2e.core.MavenPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.general.Project;
import org.talend.core.model.migration.AbstractProjectMigrationTask;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.designer.maven.tools.AggregatorPomsHelper;
/*
* Created by bhe on Sep 29, 2020
*/
public class RemoveSnapshotJarMigrationTask extends AbstractProjectMigrationTask {
private static final Logger LOGGER = Logger.getLogger(RemoveSnapshotJarMigrationTask.class.getCanonicalName());
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2020, 9, 30, 12, 00, 00);
return gc.getTime();
}
@Override
public ExecutionResult execute(Project project) {
AggregatorPomsHelper pomHelper = new AggregatorPomsHelper();
IFile rootPomFile = pomHelper.getProjectRootPom();
if (rootPomFile.exists()) {
try {
boolean isRegeneratePoms = false;
Model model = MavenPlugin.getMaven().readModel(rootPomFile.getLocation().toFile());
if (model.getModules() != null) {
for (String module : model.getModules()) {
Path modPath = Paths.get(rootPomFile.getLocation().toFile().getParent(), module, "pom.xml");
Model modModel = MavenPlugin.getMaven().readModel(modPath.toFile());
isRegeneratePoms = doMigration(modModel.getDependencies());
if (isRegeneratePoms) {
break;
}
}
}
LOGGER.info("modules: " + model.getModules() + ", isRegeneratePoms: " + isRegeneratePoms);
if (isRegeneratePoms) {
pomHelper.syncAllPomsWithoutProgress(new NullProgressMonitor());
return ExecutionResult.SUCCESS_NO_ALERT;
}
return ExecutionResult.NOTHING_TO_DO;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
private static boolean doMigration(List<Dependency> deps) {
if (deps == null || deps.isEmpty()) {
return false;
}
for (Dependency dep : deps) {
if (StringUtils.equals("org.talend.libraries", dep.getGroupId())
&& StringUtils.equals("6.0.0-SNAPSHOT", dep.getVersion())) {
if (StringUtils.equals("crypto-utils", dep.getArtifactId())) {
return true;
}
}
}
return false;
}
}

View File

@@ -1,143 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2020 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.repository.model.migration;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.model.components.ComponentUtilities;
import org.talend.core.model.components.ModifyComponentsAction;
import org.talend.core.model.components.conversions.IComponentConversion;
import org.talend.core.model.components.filters.IComponentFilter;
import org.talend.core.model.components.filters.NameComponentFilter;
import org.talend.core.model.migration.AbstractAllJobMigrationTask;
import org.talend.core.model.properties.Item;
import org.talend.core.model.utils.ContextParameterUtils;
import org.talend.core.model.utils.TalendTextUtils;
import org.talend.core.utils.TalendQuoteUtils;
import org.talend.designer.core.model.utils.emf.talendfile.ConnectionType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
import org.talend.designer.core.model.utils.emf.talendfile.impl.MetadataTypeImpl;
/**
* created by hcyi on Nov 12, 2020 Detailled comment
*
*/
public class SpecialUpdateELTDefaultNameMigrationTask extends AbstractAllJobMigrationTask {
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null || !Boolean
.valueOf(System.getProperty("talend.import.specialUpdateELTDefaultNameParameter", Boolean.FALSE.toString()))) { //$NON-NLS-1$
return ExecutionResult.NOTHING_TO_DO;
}
IComponentFilter filter = new NameComponentFilter("tELTOracleInput"); //$NON-NLS-1$
try {
ModifyComponentsAction.searchAndModify(item, processType, filter,
Arrays.<IComponentConversion> asList(new IComponentConversion() {
public void transform(NodeType node) {
boolean update = false;
String connectionName = null;
String orginalTableValue = ComponentUtilities.getNodePropertyValue(node, "ELT_TABLE_NAME"); //$NON-NLS-1$
String orginalSchemaValue = ComponentUtilities.getNodePropertyValue(node, "ELT_SCHEMA_NAME"); //$NON-NLS-1$
String tableValue = TalendQuoteUtils.removeQuotes(orginalTableValue);
String schemaValue = TalendQuoteUtils.removeQuotes(orginalSchemaValue);
if (StringUtils.isBlank(schemaValue)) {
connectionName = tableValue;
} else {
connectionName = schemaValue + "." + tableValue; //$NON-NLS-1$
}
for (ConnectionType connection : (List<ConnectionType>) processType.getConnection()) {
String label = connection.getLabel();
// if user custom connection name, keep everything currently they had , will update the
// default table name value .
if (!connectionName.equals(label)) {
String sourceNodeName = connection.getSource();
MetadataTypeImpl table = (MetadataTypeImpl) node.getMetadata().get(0);
if (table.getName().equals(sourceNodeName)) {
connectionName = label;
update = true;
break;
}
}
}
// get from connection label
if (update) {
if (StringUtils.isNotBlank(connectionName)) {
String connectionNameTemp = connectionName;
int connNameLength = connectionNameTemp.length();
String schemaNewValue = null;
String tableNewValue = null;
// Connection name cases:context.a.context.b /context.a.b /a.context.b /a.b /b
if (ContextParameterUtils.isContainContextParam(connectionNameTemp)) {
if (connectionNameTemp.startsWith(ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX)) {
int index = connectionNameTemp.indexOf(".", //$NON-NLS-1$
ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX.length());
schemaNewValue = connectionNameTemp.substring(0, index);
tableNewValue = connectionNameTemp.substring(index + 1, connNameLength);
} else {
int index = connectionNameTemp.indexOf(".");//$NON-NLS-1$
schemaNewValue = connectionNameTemp.substring(0, index);
tableNewValue = connectionNameTemp.substring(index + 1, connNameLength);
}
} else {
String[] names = connectionNameTemp.split("\\.");//$NON-NLS-1$
if (names.length == 2) {
schemaNewValue = names[0];
tableNewValue = names[1];
}
}
// If global map in link
schemaNewValue = TalendTextUtils.removeQuotesIfExist(schemaNewValue);
if (schemaNewValue.startsWith("+") && schemaNewValue.endsWith("+")) { //$NON-NLS-1$ //$NON-NLS-2$
schemaNewValue = schemaNewValue.substring(1, schemaNewValue.length() - 1);
}
tableNewValue = TalendTextUtils.removeQuotesIfExist(tableNewValue);
if (tableNewValue.startsWith("+") && tableNewValue.endsWith("+")) { //$NON-NLS-1$ //$NON-NLS-2$
tableNewValue = tableNewValue.substring(1, tableNewValue.length() - 1);
}
// Update the value
if (!schemaNewValue.equals(schemaValue)) {
ComponentUtilities.setNodeValue(node, "ELT_SCHEMA_NAME", schemaNewValue); //$NON-NLS-1$
}
if (!tableNewValue.equals(tableValue)) {
ComponentUtilities.setNodeValue(node, "ELT_TABLE_NAME", tableNewValue); //$NON-NLS-1$
}
}
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2020, 11, 13, 12, 0, 0);
return gc.getTime();
}
}

View File

@@ -1,80 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2021 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.repository.model.migration;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.model.components.ComponentUtilities;
import org.talend.core.model.components.ModifyComponentsAction;
import org.talend.core.model.components.conversions.IComponentConversion;
import org.talend.core.model.components.filters.IComponentFilter;
import org.talend.core.model.components.filters.NameComponentFilter;
import org.talend.core.model.migration.AbstractAllJobMigrationTask;
import org.talend.core.model.properties.Item;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
/**
* created by hcyi on Feb 24, 2021
* Detailled comment
*
*/
public class SpecialUpdateELTEnableColumnAliasMigrationTask extends AbstractAllJobMigrationTask {
private static final String ELT_ORACLE_DISABLE_COLUMN_ALIAS = "elt.oracle.disableColumnAlias"; //$NON-NLS-1$
private static final String USE_ALIAS_IN_OUTPUT_TABLE = "USE_ALIAS_IN_OUTPUT_TABLE"; //$NON-NLS-1$
private String field = "CHECK"; //$NON-NLS-1$
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
boolean disableOracleAlias = Boolean
.valueOf(System.getProperty(ELT_ORACLE_DISABLE_COLUMN_ALIAS, Boolean.FALSE.toString()));
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null || disableOracleAlias) {
return ExecutionResult.NOTHING_TO_DO;
}
IComponentFilter filter = new NameComponentFilter("tELTOracleMap"); //$NON-NLS-1$
try {
ModifyComponentsAction.searchAndModify(item, processType, filter,
Arrays.<IComponentConversion> asList(new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType use_alias = ComponentUtilities.getNodeProperty(node, USE_ALIAS_IN_OUTPUT_TABLE);
if (use_alias == null) {
ComponentUtilities.addNodeProperty(node, USE_ALIAS_IN_OUTPUT_TABLE, field);
}
ComponentUtilities.setNodeValue(node, USE_ALIAS_IN_OUTPUT_TABLE, String.valueOf(!disableOracleAlias));
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2021, 01, 07, 12, 0, 0);
return gc.getTime();
}
}

View File

@@ -42,44 +42,45 @@ Export-Package: org.talend.sdk.component.studio.metadata.provider,
org.talend.sdk.component.studio.mvn,
org.talend.sdk.component.studio.toolbar
Bundle-ClassPath: .,
lib/asciidoctorj-api.jar,
lib/asciidoctorj.jar,
lib/component-form-core.jar,
lib/component-server-model.jar,
lib/dirgra.jar,
lib/geronimo-json_1.1_spec.jar,
lib/geronimo-jsonb_1.0_spec.jar,
lib/invokebinder.jar,
lib/jcodings.jar,
lib/jcommander.jar,
lib/jffi.jar,
lib/jffi-native.jar,
lib/jnr-constants.jar,
lib/jnr-enxio.jar,
lib/jnr-netdb.jar,
lib/jnr-posix.jar,
lib/jnr-unixsocket.jar,
lib/joda-time.jar,
lib/johnzon-core.jar,
lib/johnzon-jsonb.jar,
lib/johnzon-mapper.jar,
lib/joni.jar,
lib/jruby-core.jar,
lib/jruby.jar,
lib/jruby-stdlib.jar,
lib/jzlib.jar,
lib/nailgun-server.jar,
lib/options.jar,
lib/slf4j-api.jar,
lib/tomcat-api.jar,
lib/tomcat-juli.jar,
lib/tomcat-servlet-api.jar,
lib/tomcat-util.jar,
lib/tomcat-websocket-api.jar,
lib/tomcat-websocket.jar,
lib/slf4j-simple.jar,
lib/backport9.jar,
lib/javax.annotation-api.jar
lib/asciidoctorj-api.jar,
lib/asciidoctorj.jar,
lib/bytelist.jar,
lib/commons-cli.jar,
lib/component-form-core.jar,
lib/component-server-model.jar,
lib/dirgra.jar,
lib/geronimo-json_1.1_spec.jar,
lib/geronimo-jsonb_1.0_spec.jar,
lib/invokebinder.jar,
lib/jcodings.jar,
lib/jcommander.jar,
lib/jffi.jar,
lib/jffi-native.jar,
lib/jnr-constants.jar,
lib/jnr-enxio.jar,
lib/jnr-netdb.jar,
lib/jnr-posix.jar,
lib/jnr-unixsocket.jar,
lib/jnr-x86asm.jar,
lib/joda-time.jar,
lib/johnzon-core.jar,
lib/johnzon-jsonb.jar,
lib/johnzon-mapper.jar,
lib/joni.jar,
lib/jruby-core.jar,
lib/jruby.jar,
lib/jruby-stdlib.jar,
lib/jzlib.jar,
lib/modulator.jar,
lib/nailgun-server.jar,
lib/options.jar,
lib/slf4j-api.jar,
lib/tomcat-api.jar,
lib/tomcat-juli.jar,
lib/tomcat-servlet-api.jar,
lib/tomcat-util.jar,
lib/tomcat-websocket-api.jar,
lib/tomcat-websocket.jar
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.emf.common,
@@ -113,4 +114,3 @@ Require-Bundle: org.eclipse.core.runtime,
org.talend.updates.runtime,
org.eclipse.equinox.p2.metadata
Import-Package: org.talend.components.api.properties
Bundle-Localization: plugin

View File

@@ -14,7 +14,7 @@
<description>Studio integration of the Talend Component Kit framework.</description>
<properties>
<component-runtime.version>1.1.15.2</component-runtime.version>
<component-runtime.version>1.1.14</component-runtime.version>
<commons-lang3.version>3.6</commons-lang3.version>
<mockito.version>2.23.0</mockito.version>
<oro.version>2.0.8</oro.version>
@@ -71,7 +71,7 @@
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj</artifactId>
<version>2.3.0</version>
<version>1.6.0-alpha.7</version>
</dependency>
<dependency>

View File

@@ -30,7 +30,6 @@ import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.VersionUtils;
import org.talend.osgi.hook.maven.MavenResolver;
import org.talend.sdk.component.studio.debounce.DebounceManager;
import org.talend.sdk.component.studio.metadata.TaCoKitCache;
@@ -62,11 +61,6 @@ public class ServerManager {
private static Object lock = new Object();
private ServerManager() {
/**
* update/set "talend.studio.version", because TCK server need to know whether running on studio by checking
* this parameter
*/
VersionUtils.getInternalVersion();
}
public static ServerManager getInstance() {

View File

@@ -22,8 +22,6 @@ import java.util.Locale;
import java.util.Set;
import java.util.stream.Stream;
import org.eclipse.jface.resource.ImageDescriptor;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.CorePlugin;
import org.talend.core.model.components.ComponentCategory;
import org.talend.core.model.components.IComponent;
@@ -76,16 +74,8 @@ public class TaCoKitGenericProvider implements IGenericProvider {
details.forEach(pair -> {
ComponentIndex index = pair.getFirst();
ComponentDetail detail = pair.getSecond();
ImageDescriptor imageDesc = null;
try {
imageDesc = service.toEclipseIcon(index.getIcon());
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (imageDesc == null) {
imageDesc = ComponentService.DEFAULT_IMAGE;
}
components.add(new ComponentModel(index, detail, configTypes, imageDesc, reportPath, isCatcherAvailable));
components.add(new ComponentModel(index, detail, configTypes, service.toEclipseIcon(index.getIcon()), reportPath,
isCatcherAvailable));
});
}
}

View File

@@ -24,7 +24,6 @@ import org.asciidoctor.Asciidoctor;
import org.asciidoctor.AttributesBuilder;
import org.asciidoctor.Options;
import org.asciidoctor.OptionsBuilder;
import org.asciidoctor.jruby.internal.JRubyAsciidoctor;
import org.jruby.RubyInstanceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,7 +62,7 @@ public class AsciidoctorService {
final RubyInstanceConfig config = new RubyInstanceConfig();
config.setLoader(Thread.currentThread().getContextClassLoader());
try {
instance = JRubyAsciidoctor.create(singletonList("uri:classloader:/gems/asciidoctor-2.0.10/lib"));
instance = Asciidoctor.Factory.create(singletonList("uri:classloader:/gems/asciidoctor-1.5.7.1/lib"));
} catch (final Throwable e) {
LOGGER.error("Can't load asciidoctor. Components documentation will not be available", e);
} finally {

View File

@@ -56,7 +56,7 @@ public class ComponentService {
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(ComponentService.class);
public static final ImageDescriptor DEFAULT_IMAGE = ImageProvider.getImageDesc(EImage.COMPONENT_MISSING);
private static final ImageDescriptor DEFAULT_IMAGE = ImageProvider.getImageDesc(EImage.COMPONENT_MISSING);
private final Function<String, File> mvnResolver;

View File

@@ -22,14 +22,9 @@ import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Test;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IElement;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
@@ -152,15 +147,6 @@ public class ExpressionTest {
}
}
private ElementParameter createMockParameterWithLineInTable(String paramName, Map<String, Object> line) {
ElementParameter param = mock(ElementParameter.class);
when(param.getFieldType()).thenReturn(EParameterFieldType.TABLE);
when(param.getName()).thenReturn(paramName);
List<Map<String, Object>> list = Stream.of(line).collect(Collectors.toList());
when(param.getValue()).thenReturn(list);
return param;
}
@Test
public void testEvaluateDistrib_simplecase() {
List<IElementParameter> params = new ArrayList<>();
@@ -252,19 +238,7 @@ public class ExpressionTest {
"!DISTRIB[#LINK@NODE.CONNECTION.DISTRIBUTION, #LINK@NODE.CONNECTION.HIVE_VERSION].doSupportUseDatanodeHostname[]",
params, paramNode));
}
@Test
public void testEvaluateContains() {
List<IElementParameter> params = new ArrayList<>();
Map<String, Object> line = new LinkedHashMap<String, Object>() {{
put("ADDITIONAL_ARGUMENT", "'hive.import'");
put("ADDITIONAL_VALUE", "'true'");
}};
ElementParameter param1 = createMockParameterWithLineInTable("ADDITIONAL_JAVA", line);
params.add(param1);
assertTrue(Expression.evaluateContains("ADDITIONAL_JAVA CONTAINS {ADDITIONAL_ARGUMENT='hive.import', ADDITIONAL_VALUE='true'}", params));
}
@Test
public void testIsThereCondition() {
assertTrue(Expression.isThereCondition("a=1 and b=2", "and"));
@@ -281,4 +255,5 @@ public class ExpressionTest {
assertFalse(Expression.isThereCondition("standard='aaa'", "and"));
assertFalse(Expression.isThereCondition("story='aaa'", "or"));
}
}

View File

@@ -1,7 +1,8 @@
package org.talend.designer.dbmap.language.generation;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Collections;
@@ -25,10 +26,8 @@ import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MetadataColumn;
import org.talend.core.model.metadata.MetadataTable;
import org.talend.core.model.process.EConnectionType;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IConnection;
import org.talend.core.model.process.IContextParameter;
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;
@@ -37,8 +36,6 @@ 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.model.process.DataConnection;
import org.talend.designer.core.model.process.DataNode;
import org.talend.designer.core.ui.editor.connections.Connection;
import org.talend.designer.core.ui.editor.nodes.Node;
import org.talend.designer.core.ui.editor.process.Process;
@@ -796,408 +793,4 @@ public class DbGenerationManagerTest extends DbGenerationManagerTestHelper {
assertEquals(exceptQuery.replaceAll("\n", "").trim(), query.trim());
}
@Test
public void testELTMapWithUpdateIfCheckUseDifferentTable() {
dbManager = new GenericDbGenerationManager();
String schema = "dbo";
String inputTable1 = "src1";
String inputTable2 = "src2";
String outTable1 = "tar";
// Snowflake
dbMapComponent = new DbMapComponent();
ElementParameter param = new ElementParameter(dbMapComponent);
param.setFieldType(EParameterFieldType.MAPPING_TYPE);
param.setName(EParameterName.MAPPING.getName());
param.setValue("snowflake_id");
((List<IElementParameter>) dbMapComponent.getElementParameters()).add(param);
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
MetadataTable metadataTable = getMetadataTable(new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" });
metadataTable.setLabel(schema + "." + outTable1);
metadataList.add(metadataTable);
dbMapComponent.setMetadataList(metadataList);
// main table
ExternalDbMapData externalData = new ExternalDbMapData();
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
// main table
ExternalDbMapTable inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + inputTable1);
inputTable.setName(schema + "." + inputTable1);
inputTable.setAlias("A");
List<ExternalDbMapEntry> entities = getMetadataEntities(new String[] { "newColumn", "newColumn1" }, new String[2]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// lookup table
inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + inputTable2);
inputTable.setName(schema + "." + inputTable2);
inputTable.setAlias("B");
entities = getMetadataEntities(new String[] { "newColumn", "newColumn1" }, new String[2]);
ExternalDbMapEntry newColumn = entities.get(0);
newColumn.setExpression("A.newColumn");
newColumn.setOperator("=");
inputTable.setJoinType("INNER_JOIN");
newColumn.setJoin(true);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
ExternalDbMapTable outputTable = new ExternalDbMapTable();
outputTable.setName(schema + "." + outTable1);
outputTable.setTableName(schema + "." + outTable1);
String[] names = new String[] { "tarColumn", "tarColumn1" };
String[] expressions = new String[] { "A.newColumn", "A.newColumn1" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
outputs.add(outputTable);
externalData.setInputTables(inputs);
externalData.setOutputTables(outputs);
dbMapComponent.setExternalData(externalData);
List<IConnection> incomingConnections = new ArrayList<IConnection>();
incomingConnections.add(
mockConnection(schema, inputTable1, new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" }));
incomingConnections.add(
mockConnection(schema, inputTable2, new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" }));
dbMapComponent.setIncomingConnections(incomingConnections);
List<IConnection> outputConnections = new ArrayList<IConnection>();
Node map1 = mockNode(dbMapComponent);
IConnection connection = mockConnection(map1, schema, inputTable1, new String[] { "id", "name" });
targetComponent = ComponentsFactoryProvider.getInstance().get("tELTMSSqlOutput",
ComponentCategory.CATEGORY_4_DI.getName());
connection.getMetadataTable().getColumn("id").setLabel("newColumn");
connection.getMetadataTable().getColumn("name").setLabel("newColumn1");
// add target
DataNode output = new DataNode();
List<IElementParameter> paraList = new ArrayList<IElementParameter>();
//
param = new ElementParameter(output);
param.setName("USE_UPDATE_STATEMENT"); //$NON-NLS-1$
param.setValue("true"); //$NON-NLS-1$
paraList.add(param);
//
param = new ElementParameter(output);
param.setName("USE_DIFFERENT_TABLE"); //$NON-NLS-1$
param.setValue("true"); //$NON-NLS-1$
paraList.add(param);
//
param = new ElementParameter(output);
param.setName("DIFFERENT_TABLE_NAME"); //$NON-NLS-1$
param.setValue("ABC"); //$NON-NLS-1$
paraList.add(param);
output.setElementParameters(paraList);
output.setComponent(targetComponent);
DataConnection dataConnection = new DataConnection();
dataConnection.setName(schema + "." + outTable1);
dataConnection.setActivate(true);
dataConnection.setLineStyle(EConnectionType.FLOW_MAIN);
dataConnection.setTarget(output);
IMetadataTable table = new MetadataTable();
table.setLabel(outTable1);
table.setTableName(outTable1);
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (String columnName : new String[] { "id", "name" }) {
IMetadataColumn column = new MetadataColumn();
column.setLabel(columnName);
column.setOriginalDbColumnName(columnName);
listColumns.add(column);
}
table.setListColumns(listColumns);
dataConnection.setMetadataTable(table);
// List<DataConnection> dataConnections = new ArrayList<>();
outputConnections.add(dataConnection);
outputConnections.add(connection);
dbMapComponent.setOutgoingConnections(outputConnections);
Process process = mock(Process.class);
when(process.getContextManager()).thenReturn(new JobContextManager());
dbMapComponent.setProcess(process);
IContextParameter lookupTableContext = new JobContextParameter();
lookupTableContext.setName("lookup");
lookupTableContext.setValue("lookupTable");
lookupTableContext.setType("String");
String query = dbManager.buildSqlSelect(dbMapComponent, schema + "." + outTable1);
String expectedQuery = "\"UPDATE ABC\n" + "SET tarColumn = A.id,\n" + "tarColumn1 = A.name\n"
+ "FROM \" +dbo+\".\"+src1+ \" A , \" +dbo+\".\"+src2+ \" B\n" + "WHERE\n" + " B.id = A.id\"";
assertEquals(expectedQuery, query);
}
@Test
public void testELTMapWithUpdateIfCheckUseDifferentTable4Alias() {
dbManager = new GenericDbGenerationManager();
String schema = "dbo";
String inputTable1 = "src1";
String inputTable2 = "src2";
String outTable1 = "tar";
// Snowflake
dbMapComponent = new DbMapComponent();
ElementParameter param = new ElementParameter(dbMapComponent);
param.setFieldType(EParameterFieldType.MAPPING_TYPE);
param.setName(EParameterName.MAPPING.getName());
param.setValue("snowflake_id");
((List<IElementParameter>) dbMapComponent.getElementParameters()).add(param);
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
MetadataTable metadataTable = getMetadataTable(new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" });
metadataTable.setLabel(schema + "." + outTable1);
metadataList.add(metadataTable);
dbMapComponent.setMetadataList(metadataList);
// main table
ExternalDbMapData externalData = new ExternalDbMapData();
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
// main table
ExternalDbMapTable inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + inputTable1);
inputTable.setName(schema + "." + inputTable1);
inputTable.setAlias("A");
List<ExternalDbMapEntry> entities = getMetadataEntities(new String[] { "newColumn", "newColumn1" }, new String[2]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// lookup table
inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + inputTable2);
inputTable.setName(schema + "." + inputTable2);
inputTable.setAlias("B");
entities = getMetadataEntities(new String[] { "newColumn", "newColumn1" }, new String[2]);
ExternalDbMapEntry newColumn = entities.get(0);
newColumn.setExpression("A.newColumn");
newColumn.setOperator("=");
inputTable.setJoinType("INNER_JOIN");
newColumn.setJoin(true);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
ExternalDbMapTable outputTable = new ExternalDbMapTable();
outputTable.setName(schema + "." + outTable1);
outputTable.setTableName(schema + "." + outTable1);
String[] names = new String[] { "tarColumn", "tarColumn1" };
String[] expressions = new String[] { "A.newColumn", "A.newColumn1" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
outputs.add(outputTable);
externalData.setInputTables(inputs);
externalData.setOutputTables(outputs);
dbMapComponent.setExternalData(externalData);
List<IConnection> incomingConnections = new ArrayList<IConnection>();
incomingConnections.add(
mockConnection(schema, inputTable1, new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" }));
incomingConnections.add(
mockConnection(schema, inputTable2, new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" }));
dbMapComponent.setIncomingConnections(incomingConnections);
List<IConnection> outputConnections = new ArrayList<IConnection>();
Node map1 = mockNode(dbMapComponent);
IConnection connection = mockConnection(map1, schema, inputTable1, new String[] { "id", "name" });
targetComponent = ComponentsFactoryProvider.getInstance().get("tELTMSSqlOutput",
ComponentCategory.CATEGORY_4_DI.getName());
connection.getMetadataTable().getColumn("id").setLabel("newColumn");
connection.getMetadataTable().getColumn("name").setLabel("newColumn1");
// add target
DataNode output = new DataNode();
List<IElementParameter> paraList = new ArrayList<IElementParameter>();
//
param = new ElementParameter(output);
param.setName("USE_UPDATE_STATEMENT"); //$NON-NLS-1$
param.setValue("true"); //$NON-NLS-1$
paraList.add(param);
//
param = new ElementParameter(output);
param.setName("USE_DIFFERENT_TABLE"); //$NON-NLS-1$
param.setValue("true"); //$NON-NLS-1$
paraList.add(param);
//
param = new ElementParameter(output);
param.setName("DIFFERENT_TABLE_NAME"); //$NON-NLS-1$
param.setValue("ABC A"); //$NON-NLS-1$
paraList.add(param);
output.setElementParameters(paraList);
output.setComponent(targetComponent);
DataConnection dataConnection = new DataConnection();
dataConnection.setName(schema + "." + outTable1);
dataConnection.setActivate(true);
dataConnection.setLineStyle(EConnectionType.FLOW_MAIN);
dataConnection.setTarget(output);
IMetadataTable table = new MetadataTable();
table.setLabel(outTable1);
table.setTableName(outTable1);
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (String columnName : new String[] { "id", "name" }) {
IMetadataColumn column = new MetadataColumn();
column.setLabel(columnName);
column.setOriginalDbColumnName(columnName);
listColumns.add(column);
}
table.setListColumns(listColumns);
dataConnection.setMetadataTable(table);
// List<DataConnection> dataConnections = new ArrayList<>();
outputConnections.add(dataConnection);
outputConnections.add(connection);
dbMapComponent.setOutgoingConnections(outputConnections);
Process process = mock(Process.class);
when(process.getContextManager()).thenReturn(new JobContextManager());
dbMapComponent.setProcess(process);
IContextParameter lookupTableContext = new JobContextParameter();
lookupTableContext.setName("lookup");
lookupTableContext.setValue("lookupTable");
lookupTableContext.setType("String");
String query = dbManager.buildSqlSelect(dbMapComponent, schema + "." + outTable1);
String expectedQuery = "\"UPDATE ABC A\n" + "SET tarColumn = A.id,\n" + "tarColumn1 = A.name\n"
+ "FROM \" +dbo+\".\"+src1+ \" A , \" +dbo+\".\"+src2+ \" B\n" + "WHERE\n" + " B.id = A.id\"";
assertEquals(expectedQuery, query);
}
@Test
public void testELTMapWithUpdateIfUnCheckUseDifferentTable() {
dbManager = new GenericDbGenerationManager();
String schema = "dbo";
String inputTable1 = "src1";
String inputTable2 = "src2";
String outTable1 = "tar";
// Snowflake
dbMapComponent = new DbMapComponent();
ElementParameter param = new ElementParameter(dbMapComponent);
param.setFieldType(EParameterFieldType.MAPPING_TYPE);
param.setName(EParameterName.MAPPING.getName());
param.setValue("snowflake_id");
((List<IElementParameter>) dbMapComponent.getElementParameters()).add(param);
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
MetadataTable metadataTable = getMetadataTable(new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" });
metadataTable.setLabel(schema + "." + outTable1);
metadataList.add(metadataTable);
dbMapComponent.setMetadataList(metadataList);
// main table
ExternalDbMapData externalData = new ExternalDbMapData();
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
// main table
ExternalDbMapTable inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + inputTable1);
inputTable.setName(schema + "." + inputTable1);
inputTable.setAlias("A");
List<ExternalDbMapEntry> entities = getMetadataEntities(new String[] { "newColumn", "newColumn1" }, new String[2]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// lookup table
inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + inputTable2);
inputTable.setName(schema + "." + inputTable2);
inputTable.setAlias("B");
entities = getMetadataEntities(new String[] { "newColumn", "newColumn1" }, new String[2]);
ExternalDbMapEntry newColumn = entities.get(0);
newColumn.setExpression("A.newColumn");
newColumn.setOperator("=");
inputTable.setJoinType("INNER_JOIN");
newColumn.setJoin(true);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
ExternalDbMapTable outputTable = new ExternalDbMapTable();
outputTable.setName(schema + "." + outTable1);
outputTable.setTableName(schema + "." + outTable1);
String[] names = new String[] { "tarColumn", "tarColumn1" };
String[] expressions = new String[] { "A.newColumn", "A.newColumn1" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
outputs.add(outputTable);
externalData.setInputTables(inputs);
externalData.setOutputTables(outputs);
dbMapComponent.setExternalData(externalData);
List<IConnection> incomingConnections = new ArrayList<IConnection>();
incomingConnections.add(
mockConnection(schema, inputTable1, new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" }));
incomingConnections.add(
mockConnection(schema, inputTable2, new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" }));
dbMapComponent.setIncomingConnections(incomingConnections);
List<IConnection> outputConnections = new ArrayList<IConnection>();
Node map1 = mockNode(dbMapComponent);
IConnection connection = mockConnection(map1, schema, inputTable1, new String[] { "id", "name" });
targetComponent = ComponentsFactoryProvider.getInstance().get("tELTMSSqlOutput",
ComponentCategory.CATEGORY_4_DI.getName());
connection.getMetadataTable().getColumn("id").setLabel("newColumn");
connection.getMetadataTable().getColumn("name").setLabel("newColumn1");
// add target
DataNode output = new DataNode();
List<IElementParameter> paraList = new ArrayList<IElementParameter>();
//
param = new ElementParameter(output);
param.setName("USE_UPDATE_STATEMENT"); //$NON-NLS-1$
param.setValue("true"); //$NON-NLS-1$
paraList.add(param);
//
param = new ElementParameter(output);
param.setName("USE_DIFFERENT_TABLE"); //$NON-NLS-1$
param.setValue("false"); //$NON-NLS-1$
paraList.add(param);
//
param = new ElementParameter(output);
param.setName("DIFFERENT_TABLE_NAME"); //$NON-NLS-1$
param.setValue("ABC"); //$NON-NLS-1$
paraList.add(param);
output.setElementParameters(paraList);
output.setComponent(targetComponent);
DataConnection dataConnection = new DataConnection();
dataConnection.setName(schema + "." + outTable1);
dataConnection.setActivate(true);
dataConnection.setLineStyle(EConnectionType.FLOW_MAIN);
dataConnection.setTarget(output);
IMetadataTable table = new MetadataTable();
table.setLabel(outTable1);
table.setTableName(outTable1);
List<IMetadataColumn> listColumns = new ArrayList<IMetadataColumn>();
for (String columnName : new String[] { "id", "name" }) {
IMetadataColumn column = new MetadataColumn();
column.setLabel(columnName);
column.setOriginalDbColumnName(columnName);
listColumns.add(column);
}
table.setListColumns(listColumns);
dataConnection.setMetadataTable(table);
// List<DataConnection> dataConnections = new ArrayList<>();
outputConnections.add(dataConnection);
outputConnections.add(connection);
dbMapComponent.setOutgoingConnections(outputConnections);
Process process = mock(Process.class);
when(process.getContextManager()).thenReturn(new JobContextManager());
dbMapComponent.setProcess(process);
IContextParameter lookupTableContext = new JobContextParameter();
lookupTableContext.setName("lookup");
lookupTableContext.setValue("lookupTable");
lookupTableContext.setType("String");
String query = dbManager.buildSqlSelect(dbMapComponent, schema + "." + outTable1);
String expectedQuery = "\"UPDATE dbo.tar\n" + "SET tarColumn = A.id,\n" + "tarColumn1 = A.name\n"
+ "FROM \" +dbo+\".\"+src1+ \" A , \" +dbo+\".\"+src2+ \" B\n" + "WHERE\n" + " B.id = A.id\"";
assertEquals(expectedQuery, query);
}
}

View File

@@ -129,87 +129,6 @@ public class DbGenerationManagerTestHelper {
}
protected void init4ColumnAlias(String schema, String main_table, String main_alias, String lookup_table,
String lookup_alias) {
List<IConnection> incomingConnections = new ArrayList<IConnection>();
String[] mainTableEntities = new String[] { "id", "name", "age" };
String[] lookupEndtities = new String[] { "id", "score" };
incomingConnections.add(mockConnection(schema, main_table, mainTableEntities));
incomingConnections.add(mockConnection(schema, lookup_table, lookupEndtities));
dbMapComponent.setIncomingConnections(incomingConnections);
ExternalDbMapData externalData = new ExternalDbMapData();
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
// main table
ExternalDbMapTable inputTable = new ExternalDbMapTable();
String mainTableName = "".equals(schema) ? main_table : schema + "." + main_table;
// quote will be removed in the ui for connections ,so we do the same for test
String mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
inputTable.setTableName(mainTableNameNoQuote);
inputTable.setName(mainTableName);
if (main_alias != null && !"".equals(main_alias)) {
inputTable.setAlias(main_alias);
}
List<ExternalDbMapEntry> entities = getMetadataEntities(mainTableEntities, new String[3]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// lookup table
inputTable = new ExternalDbMapTable();
String lookupName = "".equals(schema) ? lookup_table : schema + "." + lookup_table;
inputTable.setTableName(lookupName);
inputTable.setName(lookupName);
if (lookup_alias != null && !"".equals(lookup_alias)) {
inputTable.setAlias(lookup_alias);
}
entities = getMetadataEntities(lookupEndtities, new String[2]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
ExternalDbMapTable outputTable = new ExternalDbMapTable();
outputTable.setName("grade");
String[] names = new String[] { "id", "name", "age", "score" };
String mainTable = mainTableName;
if (main_alias != null && !"".equals(main_alias)) {
mainTable = main_alias;
}
String lookupTable = lookupName;
if (lookup_alias != null && !"".equals(lookup_alias)) {
lookupTable = lookup_alias;
}
String[] expressions = new String[] { mainTable + ".id", mainTable + ".name_alias", mainTable + ".age_alias",
lookupTable + ".score" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
outputs.add(outputTable);
externalData.setInputTables(inputs);
externalData.setOutputTables(outputs);
dbMapComponent.setExternalData(externalData);
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
MetadataTable metadataTable = getMetadataTable(names);
metadataTable.setLabel("grade");
metadataList.add(metadataTable);
dbMapComponent.setMetadataList(metadataList);
JobContext newContext = new JobContext("Default");
List<IContextParameter> newParamList = new ArrayList<IContextParameter>();
newContext.setContextParameterList(newParamList);
JobContextParameter param = new JobContextParameter();
param.setName("schema");
newParamList.add(param);
param = new JobContextParameter();
param.setName("main_table");
newParamList.add(param);
param = new JobContextParameter();
param.setName("lookup");
newParamList.add(param);
process = mock(Process.class);
JobContextManager contextManger = new JobContextManager();
contextManger.setDefaultContext(newContext);
when(process.getContextManager()).thenReturn(contextManger);
dbMapComponent.setProcess(process);
}
protected IConnection mockConnection(String schemaName, String tableName, String[] columns) {
return mockConnection(null, schemaName, tableName, columns);
}

View File

@@ -12,8 +12,9 @@
// ============================================================================
package org.talend.designer.dbmap.language.oracle;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Collections;
@@ -282,7 +283,7 @@ public class OracleGenerationManagerTest extends DbGenerationManagerTestHelper {
}
@Test
public void testBuildSqlSelect() {
public void testBuildSqlSelectWithAlias() {
String schema = "";
String main_table = "((String)globalMap.get(\"main_table\"))";
String main_alias = "main1";
@@ -305,77 +306,14 @@ public class OracleGenerationManagerTest extends DbGenerationManagerTestHelper {
init(schema, main_table, main_alias, lookup_table, lookup_alias);
expectedQuery = "\"SELECT\n"
+ "main_table.id, main_table.name, main_table.age, \""
+ " +context.schema+ \".\" +((String)globalMap.get(\"lookup_table\"))+ \".score\n"
+ " +context.schema+ \".\" +((String)globalMap.get(\"lookup_table\"))+ \".score AS score\n"
+ "FROM\n"
+ " \" +context.schema+\".\"+((String)globalMap.get(\"main_table\"))+((String)globalMap.get(\"main_table1\"))+ \" main_table , \""
+ " +context.schema+ \".\" +((String)globalMap.get(\"lookup_table\"))";
manager = new OracleGenerationManager();
query = manager.buildSqlSelect(dbMapComponent, "grade");
assertEquals(expectedQuery, query);
}
@Test
public void testBuildSqlSelectWithAlias() {
String schema = "";
String main_table = "((String)globalMap.get(\"main_table\"))";
String main_alias = "main1";
String lookup_table = "((String)globalMap.get(\"lookup_table\"))";
String lookup_alias = "lookup1";
init(schema, main_table, main_alias, lookup_table, lookup_alias);
String expectedQuery = "\"SELECT\n" + "main1.id, main1.name, main1.age, lookup1.score\n"
+ "FROM\n"
+ " \" +((String)globalMap.get(\"main_table\"))+ \" main1 , \" +((String)globalMap.get(\"lookup_table\"))+ \" lookup1\"";
OracleGenerationManager manager = new OracleGenerationManager();
manager.setUseAliasInOutputTable(true);
String query = manager.buildSqlSelect(dbMapComponent, "grade");
assertEquals(expectedQuery, query);
schema = "context.schema";
main_table = "((String)globalMap.get(\"main_table\"))+((String)globalMap.get(\"main_table1\"))";
main_alias = "main_table";
lookup_table = "((String)globalMap.get(\"lookup_table\"))";
lookup_alias = "";
init(schema, main_table, main_alias, lookup_table, lookup_alias);
expectedQuery = "\"SELECT\n" + "main_table.id, main_table.name, main_table.age, \""
+ " +context.schema+ \".\" +((String)globalMap.get(\"lookup_table\"))+ \".score AS score\n" + "FROM\n"
+ " \" +context.schema+\".\"+((String)globalMap.get(\"main_table\"))+((String)globalMap.get(\"main_table1\"))+ \" main_table , \""
+ " +context.schema+ \".\" +((String)globalMap.get(\"lookup_table\"))";
manager = new OracleGenerationManager();
manager.setUseAliasInOutputTable(true);
query = manager.buildSqlSelect(dbMapComponent, "grade");
assertEquals(expectedQuery, query);
}
@Test
public void testBuildSqlSelectWithColumnsAliasIfChecked() {
OracleGenerationManager manager = new OracleGenerationManager();
manager.setUseAliasInOutputTable(true);
String schema = "";
String main_table = "main_table";
String main_alias = "";
String lookup_table = "lookup_table";
String lookup_alias = "";
init4ColumnAlias(schema, main_table, main_alias, lookup_table, lookup_alias);
String expectedQuery = "\"SELECT\n"
+ "main_table.id, main_table.name_alias AS name, main_table.age_alias AS age, lookup_table.score\n"
+ "FROM\n" + " main_table , lookup_table\"";
String query = manager.buildSqlSelect(dbMapComponent, "grade");
assertEquals(expectedQuery, query);
}
@Test
public void testBuildSqlSelectWithColumnsAliasIfunChecked() {
OracleGenerationManager manager = new OracleGenerationManager();
manager.setUseAliasInOutputTable(false);
String schema = "";
String main_table = "main_table";
String main_alias = "";
String lookup_table = "lookup_table";
String lookup_alias = "";
init4ColumnAlias(schema, main_table, main_alias, lookup_table, lookup_alias);
String expectedQuery = "\"SELECT\n" + "main_table.id, main_table.name_alias, main_table.age_alias, lookup_table.score\n"
+ "FROM\n" + " main_table , lookup_table\"";
String query = manager.buildSqlSelect(dbMapComponent, "grade");
assertEquals(expectedQuery, query);
}
}

View File

@@ -1,6 +1,6 @@
package org.talend.designer.dbmap.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
@@ -134,49 +134,6 @@ public class DataMapExpressionParserTest {
}
@Test
public void testGetGlobalMapSet4ExpressionString1() {
String sqlQuery = "((String)globalMap.get(\"TECH_SYSTEM_SOURCE\"))";
Set<String> globalList = parser.getGlobalMapSet(sqlQuery);
Assert.assertEquals(globalList.size(), 1);
List<String> list = new ArrayList<String>(globalList);
Assert.assertEquals(list.get(0), "((String)globalMap.get(\"TECH_SYSTEM_SOURCE\"))");
}
@Test
public void testGetGlobalMapSet4ExpressionString2() {
String sqlQuery = "\"+((String)globalMap.get(\"TECH_SYSTEM_SOURCE\"))+\"";
Set<String> globalList = parser.getGlobalMapSet(sqlQuery);
Assert.assertEquals(globalList.size(), 1);
List<String> list = new ArrayList<String>(globalList);
Assert.assertEquals(list.get(0), "((String)globalMap.get(\"TECH_SYSTEM_SOURCE\"))");
}
@Test
public void testGetGlobalMapSet4ExpressionString3() {
String sqlQuery = "globalMap.get(\"TECH_SYSTEM_SOURCE\")";
Set<String> globalList = parser.getGlobalMapSet(sqlQuery);
Assert.assertEquals(globalList.size(), 0);
}
@Test
public void testGetGlobalMapSet4ExpressionInteger1() {
String sqlQuery = "((Integer)globalMap.get(\"TECH_SYSTEM_SOURCE\"))";
Set<String> globalList = parser.getGlobalMapSet(sqlQuery);
Assert.assertEquals(globalList.size(), 1);
List<String> list = new ArrayList<String>(globalList);
Assert.assertEquals(list.get(0), "((Integer)globalMap.get(\"TECH_SYSTEM_SOURCE\"))");
}
@Test
public void testGetGlobalMapSet4ExpressionInteger2() {
String sqlQuery = "\"+((Integer)globalMap.get(\"TECH_SYSTEM_SOURCE\"))+\"";
Set<String> globalList = parser.getGlobalMapSet(sqlQuery);
Assert.assertEquals(globalList.size(), 1);
List<String> list = new ArrayList<String>(globalList);
Assert.assertEquals(list.get(0), "((Integer)globalMap.get(\"TECH_SYSTEM_SOURCE\"))");
}
@Test
public void testReplaceLocation() {
String expression = "((String)globalMap.get(\"schema\")). ((String)globalMap.get(\"main_table\")).column ";