Compare commits

..

51 Commits

Author SHA1 Message Date
kjwang-talend
d9e50fc49f Fake patch test 2021-11-04 17:34:49 +08:00
Chao MENG
16d300f0ad Cmeng/patch/7.3/tup 28063 improve start (#5092)
* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063

* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063

* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063

Conflicts:
	main/plugins/org.talend.repository/src/main/java/org/talend/repository/RepositoryService.java
2021-10-22 16:57:22 +08:00
bhe-talendbj
89675c4b23 bugfix(TUP-28659): backport (#6472)
* fix(TUP-28659): migrate jobs because remove snapshot jars

* fix(TUP-28659): backport

* fix(TUP-28659): backport
2021-08-02 09:48:10 +08:00
vdrokov
0133dd05e8 APPINT-33068: Fix variable duplication 2021-06-01 09:46:38 +02:00
bkatiukhov
b9e13df05d APPINT-32699 Fix error while deploying a route with tAzureStorageQueue (#6153)
Co-authored-by: Bohdan Katiukhov <bohdan.katiukhov@synapse.com>
2021-05-25 14:13:39 +03:00
vdrokov
f777b52c4a APPINT-32689: Undeploying a Service causes java.io.FileNotFoundException: {runtime}\data\cache\org.eclipse.osgi\xxxx\0\bundleFile (#6154) 2021-05-17 16:39:50 +03:00
apoltavtsev
c5e0d7119b bugfix(APPINT-32738) Job execution for Linux is corrected 2021-04-07 12:54:19 +02:00
apoltavtsev
2819dc3566 bugfix(APPINT-32723) Jobs bundle name is corrected 2021-04-07 06:54:00 +02:00
SunChaoqun
ad979090a0 fix the backport code conflict (#6034) 2021-04-02 17:51:07 +08:00
hcyi
db0a65fcdb Patch/7.2.1 tps 4713 (#5887)
* fix(TUP-30438):Issue when updating snowflake table using tELTOutput.

* fix(TUP-30438):add junits

* TPS-4713:Issue when updating snowflake table using tELTOutput
(TUP-30438)

* TPS-4713:add code change of TDI-41651

* TPS-4718: [7.2.1] Issue when updating snowflake table using tELTOutput
(TDI-41651)

* TPS-4713:Issue when updating snowflake table using tELTOutput(TPS-4072)

* TPS-4713:Issue when updating snowflake table using tELTOutput
(TUP-30438)

Co-authored-by: Dmytro Sylaiev <dmytro.sylaiev@globallogic.com>
2021-04-02 11:21:47 +08:00
vdrokov
7b0ccc6793 APPINT-32452: After applying the latest patch, trunjob component fails with "java.io.IOException: Cannot run program "java.exe": error=2, No such file or directory" (#6016)
Co-authored-by: Denis Sergent <32458402+dsergent@users.noreply.github.com>
2021-03-31 17:35:47 +02:00
vdrokov
2637f4f0e4 TESB-32452: After applying the latest patch, trunjob component fails … (#5989)
* TESB-32452: After applying the latest patch, trunjob component fails with "java.io.IOException: Cannot run program "java.exe": error=2, No such file or directory"

* TESB-32452: After applying the latest patch, trunjob component fails with "java.io.IOException: Cannot run program "java.exe": error=2, No such file or directory"
2021-03-31 17:28:04 +02:00
bkatiukhov
409131fac1 TESB-32307 tESBConsumer - wrong header content-type (#5978)
Co-authored-by: bohdan.katiukhov <bohdan.katiukhov@KBP1-LHP-A00125.synapse.com>
2021-03-29 10:17:52 +02:00
hcyi
636c261cf5 TPS-4674:[7.2.1]Add a new option for tELTOracleMap to generate column alias on selection. (TUP-30043) (#5865)
* TPS-4674:[7.2.1]Add a new option for tELTOracleMap to generate column
alias on selection. (TUP-30043)

* fix(TUP-30043):Add a new option for tELTOracleMap to generate column
alias on selection.
2021-03-02 18:03:52 +08:00
bhe-talendbj
0e09d928c1 fix(TUP-30360): add an option to disable sharing libraries (#5814) (#5841)
* fix(TUP-30360): add an option to disable sharing libraries

* fix(TUP-30360): add an option to disable sharing libraries, default to true
2021-03-01 17:05:09 +08:00
hzhao-talendbj
7f2b14e9fe TUP-30333 tMap with Lookup model Reload at each row freezes Studio (#5817)
* TUP-30333 tMap with Lookup model Reload at each row freezes Studio

* TUP-30333 add comments

* TUP-30333 add condition for refresh background
2021-02-25 18:50:38 +08:00
apoltavtsev
67dec82a79 feat(TESB-31727) message about version inheritance for child job is added 2021-01-29 09:50:11 +01:00
apoltavtsev
7988529bfd fix(TESB-31274) jobs containing tRestClient build issues 2021-01-22 08:31:16 +01:00
apoltavtsev
6e5e614f62 fix(TESB-31274) jobs containing tRestClient build issues 2021-01-20 14:07:12 +01:00
SunChaoqun
9158251a31 TESB-29921:Build/Deploy of a route snapshot with CommandLine has 0 byte bundle in Nexus (#5693) 2021-01-05 16:40:20 +08:00
sponomarova
2193cb5bc6 fix(TBD-10285):Add contains predicate to expressions (#4613) (#5563)
Co-authored-by: Laurent BOURGEOIS <lbourgeois@talend.com>
2020-12-02 17:07:55 +02:00
hcyi
92143bc9d9 fix(TUP-29090):[7.2.1] Extra plus '+' signs in generated SQL (#5559) (#5564)
* fix(TUP-29090):[7.2.1] Extra plus '+' signs in generated SQL (#5559)

* fix(TUP-29090):fix some failed junits .
2020-11-30 20:05:58 +08:00
hcyi
5886a9ea1e fix(TUP-29072):When renaming link (table) between teltinput and teltmap (#5507)
, the generated SQL query is not updated.
2020-11-30 10:12:39 +08:00
undx
8e11d18951 fix(TUP-25152): backport to patch/7.2.1 2020-10-08 13:38:59 +02:00
Emmanuel GALLOIS
18ae07abed fix(TPS-4351): Make component-runtime class loader find classes in JobServer (#5247)
* fix(TPS-4351): Make component-runtime class loader find classes in JobServer
* fix(TPS-4351): fix AsciidoctorService
* fix(TPS-4351): bump asciidoctorj
* fix(TPS-4351): fix MANIFEST.MF
2020-10-06 13:56:40 +02:00
vdrokov
89a48f51e3 fix(TESB-30317): [CI Builder] Some models throw error "context file d… (#5242)
* fix(TESB-30317): [CI Builder] Some models throw error "context file doesn't exist" during CITEST compilation phase
Fix by catching error from the members() function call which will throw error if the folder it is working with doens't exist.

* TESB-30317:[CI Builder] Some models throw error "context file doesn't
exist" during CITEST compilation phase

Co-authored-by: SunChaoqun <csun@talend.com>
2020-10-06 12:52:59 +03:00
Zhiwei Xue
6b0ccf8623 fix(TUP-28576):Reference projects routine POM file is modified and can't (#5181)
be committed to GIT
2020-09-21 15:00:31 +08:00
SunChaoqun
3df34392cd TESB-30188:CI builder doesn't publish feature folders for some artifacts (#5177)
(jobs, routes, services)

Co-authored-by: Mike Yan <yyan@talend.com>
2020-09-08 16:43:40 +08:00
hzhao-talendbj
17687cbe3d fix change metadata table ,column list wrong order. (#5131) 2020-08-28 11:21:27 +08:00
apoltavtsev
386eec46c3 fix(TESB-29963) MQ Dependency issues in Runtime 2020-08-24 15:45:03 +02:00
Chao MENG
fd72c4d991 Cmeng/patch/7.2.1/tup 28304 backport (#5088)
* fix(TUP-27953): tSalesforceInput component displays in-job (#4996)

tSalesforceConnection incorrectly
https://jira.talendforge.org/browse/TUP-27953

Conflicts:
	main/plugins/org.talend.designer.core.generic/src/main/java/org/talend/designer/core/generic/controller/ComponentRefController.java

* fix(TUP-28295): UI Problem of TCOMPV0 in the recent 741NB and 731
Release + Aug. Nightly Build Patch
https://jira.talendforge.org/browse/TUP-28295
2020-08-19 10:47:01 +08:00
bhe-talendbj
2f5a499389 fix(TUP-27374): Fix test case (#5055) 2020-08-10 18:25:22 +08:00
jiezhang-tlnd
759eaa73f0 feat(TUP-27862)Add possibility to customize pattern for dates when (#4977) (#5021)
retrieve table
2020-08-07 10:51:42 +08:00
bhe-talendbj
d85a5c0e08 fix(TUP-28009): Save relationship index after version change (#5017) 2020-08-07 10:26:43 +08:00
bhe-talendbj
5c9f99b54e fix(TUP-27374): Get default jvm arguments (#4792)
* fix(TUP-27374): Get default jvm arguments

* fix(TUP-27374): add back default vm arguments
2020-08-07 10:24:58 +08:00
Mike Yan
e5ce502008 fix(TESB-29210): Build type not updated for consumer job (#5015) 2020-08-03 16:14:57 +08:00
apoltavtsev
ccfbf51dff TESB-29071 Bean in route gives wrong output on running in studio 2020-07-31 12:09:37 +02:00
nrousseau
d2b0c87288 Revert "fix(TDI-42522): avoid 65535 issue (#3636) (#3893) (#4895)" (#5020)
This reverts commit 6cf2cae1b6.
2020-07-31 17:46:47 +08:00
msheverda-talend
6cf2cae1b6 fix(TDI-42522): avoid 65535 issue (#3636) (#3893) (#4895)
Co-authored-by: wang wei <wwang@talend.com>
2020-07-30 18:08:10 +03:00
Chao MENG
604fb23a71 patch(TPS-4193): remove localprovider, make it compatible with javajet modifications (#4984)
* patch(TPS-4193): remove localprovider, make it compatible with javajet
modifications

* patch(TPS-4193): remove localprovider, make it compatible with javajet
modifications
2020-07-23 18:56:58 +08:00
apoltavtsev
e3f6f81cde TESB-29647 Bundle version for Jobs is corrected 2020-07-20 15:23:29 +02:00
Andreas Mattes
26ff46ddeb TESB-27583 TESB-29690 Ensure WSDL is included in WS consumer build. (#4966)
This fix corrects TESB-27081 and TESB-27583 ensuring SOAP Action is set from binding definition in WSDL, and TESB-2960 ensuring the WSDL is present for properly configuring the SOAP 1.2 binding. This fix is identical with the temporarily reverted fix from pull request #4926.
2020-07-20 11:25:28 +02:00
Andreas Mattes
cd955b7ad4 Revert "TESB-29690 Ensure WSDL is included in WS consumer build". 2020-07-14 11:36:46 +02:00
Andreas Mattes
dc11694fd1 TESB-29690 Ensure WSDL is included in WS consumer build. (#4926)
This fix includes fixes for TESB-27081 and TESB-27583 handling missing SOAP Action due to missing WSDL and TESB-2960 ensuring the WSDL is present for properly configuring the SOAP 1.2 binding.
2020-07-13 18:25:54 +02:00
hzhao-talendbj
b1598aca9f tup-27447 backport to patch721 (#4822) 2020-07-02 14:28:41 +08:00
hzhao-talendbj
938c1dadb2 TUP-27070 (#4855)
on patch721, eltmap don't have 'update' option  so remove this junit
from 721
2020-06-24 15:36:07 +08:00
hzhao-talendbj
ba7622b528 tup-27070 (#4848)
add this junit by mistake,it should not in branch patch721, so remove it
2020-06-23 18:18:04 +08:00
hzhao-talendbj
2cdfb08e18 tup-27070 fix junit failed on patch 7.2.1 (#4846) 2020-06-23 09:18:11 +08:00
bhe-talendbj
33fb855c55 fix(TUP-27053): backport (#4767) (#4801) 2020-06-19 15:13:02 +08:00
hzhao-talendbj
e6458bc956 Hengzhao/backport patch721/tup 27070 (#4774)
* Tup-27070 (#4734)
backport to 7.2.1 and fix conflicts

Conflicts:
	main/plugins/org.talend.designer.dbmap/src/main/java/org/talend/designer/dbmap/language/generation/DbGenerationManager.java

* TUP-27070  fix cross join cases

* Fix(TDI-43264):Fix issues. (#4182)

Co-authored-by: vyu-talend <49019399+vyu-talend@users.noreply.github.com>
2020-06-19 15:01:05 +08:00
hcyi
699ac6f1d4 fix(TUP-26939:Tmap shows null values when using Expression Builder. (#4802)
(#4632)

Conflicts:
	main/plugins/org.talend.expressionbuilder/src/main/java/org/talend/expressionbuilder/test/shadow/VirtualRowGeneratorNode.java
2020-06-19 14:55:49 +08:00
79 changed files with 3643 additions and 479 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-4158
| Info | Value |
| ---------------- | ---------------- |
| Patch Name | Patch\_20200619\_TPS-4158\_v1-7.2.1 |
| Release Date | 2020-06-19 |
| 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-4158 [7.2.1] tSSH component hangs if Command takes time to complete (TDI-43670)
## 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,16 +1166,36 @@ 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 (null != obj_conn) {
((java.sql.Connection) obj_conn).close();
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;
}
}
<% } %>
} 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

@@ -25,7 +25,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
org.talend.designer.dbmap.language.generation.GenericDbGenerationManager gm = new org.talend.designer.dbmap.language.generation.GenericDbGenerationManager();
org.talend.designer.dbmap.language.mssql.MssqlGenerationManager gm = new org.talend.designer.dbmap.language.mssql.MssqlGenerationManager();
String uniqueNameComponent = null;
IDbLanguage currentLanguage = gm.getLanguage();

View File

@@ -305,48 +305,54 @@ for(Column colStmt:stmtStructure){
if(("INSERT").equals(dataAction)){
%>
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
<%
}else if (("UPDATE").equals(dataAction)){
if(useUpdateStatement){
if(useUpdateStatement){
%>
String updateQuery_<%=cid %> = select_query_<%=cid %>
String updateQuery_<%=cid %> = select_query_<%=cid %>;
<%
}else{
}else{
%>
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ";
<%
}
}
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
if(useUpdateStatement){
%>
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
updateQuery_<%=cid %> +=" WHERE ";
}else{
updateQuery_<%=cid %> +=" AND ";
}
updateQuery_<%=cid %>+= <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
<%
}else{
%>
updateQuery_<%=cid %> += " WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
<%
}
}
%>
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
<%
}else if (("DELETE").equals(dataAction)){
%>
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
<%
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
%>
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
<%
}
%>
;
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
<%
}
%>
;
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
<%
}else if (("DELETE").equals(dataAction)){
%>
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
<%
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
%>
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
<%
}
%>
;
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
<%
}
%>
int nb_line_<%=cid%> = 0;
int nb_line_updated_<%=cid%> = 0;
int nb_line_inserted_<%=cid%> = 0;

View File

@@ -33,4 +33,4 @@ USE_DIFFERENT_TABLE.NAME=Use different table name
DIFFERENT_TABLE_NAME.NAME=Table name
IS_TABLE_NAME_VARIABLE.NAME=Table name from connection name is variable
USE_UPDATE_STATEMENT.NAME=Use update statement
USE_UPDATE_STATEMENT.NAME=Use update statement without subqueries

View File

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

View File

@@ -35,6 +35,7 @@ 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;
@@ -156,21 +157,36 @@ 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)){
%>
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)){
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)%>
<%
}
%>
;
<%
}
} else if (("DELETE").equals(dataAction)){
%>
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "

View File

@@ -40,4 +40,6 @@ 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
TABLE_ACTION.NAME=Action on table
USE_UPDATE_STATEMENT.NAME=Use update statement without subqueries

View File

@@ -189,6 +189,4 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
}
%>
StringBuilder stringStdout_<%=cid%> =new StringBuilder();
StringBuilder stringStderr_<%=cid%> =new StringBuilder();
String out_content_<%=cid%> = null;
String err_content_<%=cid%> = null;
StringBuilder stringStderr_<%=cid%> =new StringBuilder();

View File

@@ -23,7 +23,7 @@ imports="
if("TO_CONSOLE".equals(standardOutput) || "TO_CONSOLE_AND_GLOBAL_VARIABLE".equals(standardOutput)){
%>
if(stringStdout_<%=cid%>.length() > 0) {
System.out.println(out_content_<%=cid%>);
System.out.println(stringStdout_<%=cid%>.toString());
}
<%
}
@@ -31,7 +31,7 @@ imports="
if("TO_CONSOLE".equals(errorOutput) || "TO_CONSOLE_AND_GLOBAL_VARIABLE".equals(errorOutput)){
%>
if(stringStderr_<%=cid%>.length() > 0) {
System.out.println(err_content_<%=cid%>);
System.out.println(stringStderr_<%=cid%>.toString());
}
<%
}

View File

@@ -77,9 +77,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
<%
}
%>
java.io.InputStream stdout_<%=cid%> = new ch.ethz.ssh2.StreamGobbler(sess_<%=cid%>.getStdout());
java.io.InputStream stderr_<%=cid%> = new ch.ethz.ssh2.StreamGobbler(sess_<%=cid%>.getStderr());
java.io.InputStream stdout_<%=cid%> = sess_<%=cid%>.getStdout();
java.io.BufferedReader brout_<%=cid%>= new java.io.BufferedReader(new java.io.InputStreamReader(stdout_<%=cid%>));
String line_<%=cid%> = "";
@@ -93,6 +91,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
brout_<%=cid%>.close();
stdout_<%=cid%>.close();
java.io.InputStream stderr_<%=cid%> = sess_<%=cid%>.getStderr();
java.io.BufferedReader breer_<%=cid%>= new java.io.BufferedReader(new java.io.InputStreamReader(stderr_<%=cid%>));
String line1_<%=cid%> = "";
@@ -111,41 +110,37 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
/* Close this session */
sess_<%=cid%>.close();
out_content_<%=cid%> = stringStdout_<%=cid%>.toString();
err_content_<%=cid%> = stringStderr_<%=cid%>.toString();
<%if(isLog4jEnabled){%>
log.debug("<%=cid%> - Command line standard result: " + out_content_<%=cid%>);
log.debug("<%=cid%> - Command line error result: " + err_content_<%=cid%>);
log.debug("<%=cid%> - Command line standard result: " + stringStdout_<%=cid%>.toString());
log.debug("<%=cid%> - Command line error result: " + stringStderr_<%=cid%>.toString());
<%}%>
<%
//-----begin to handle output
if(("TO_GLOBAL_VARIABLE").equals(standardOutput)){
%>
globalMap.put("<%=cid %>_STDOUT", out_content_<%=cid%>);
globalMap.put("<%=cid %>_STDOUT", stringStdout_<%=cid%>.toString());
<%
}else if(("TO_CONSOLE_AND_GLOBAL_VARIABLE").equals(standardOutput)){
%>
globalMap.put("<%=cid %>_STDOUT", out_content_<%=cid%>);
globalMap.put("<%=cid %>_STDOUT", stringStdout_<%=cid%>.toString());
<%
}else if(("NORMAL_OUTPUT").equals(standardOutput)){
%>
output_<%=cid%>.add(out_content_<%=cid%>);
output_<%=cid%>.add(stringStdout_<%=cid%>.toString());
stringStdout_<%=cid%>.delete(0,stringStdout_<%=cid%>.length());
<%
}
if(("TO_GLOBAL_VARIABLE").equals(errorOutput)){
%>
globalMap.put("<%=cid %>_STDERR", err_content_<%=cid%>);
globalMap.put("<%=cid %>_STDERR", stringStderr_<%=cid%>.toString());
<%
}else if(("TO_CONSOLE_AND_GLOBAL_VARIABLE").equals(errorOutput)){
%>
globalMap.put("<%=cid %>_STDERR", err_content_<%=cid%>);
globalMap.put("<%=cid %>_STDERR", stringStderr_<%=cid%>.toString());
<%
}else if(("NORMAL_OUTPUT").equals(errorOutput)){
%>
output_<%=cid%>.add(err_content_<%=cid%>);
output_<%=cid%>.add(stringStderr_<%=cid%>.toString());
stringStderr_<%=cid%>.delete(0, stringStderr_<%=cid%>.length());
<%
}

View File

@@ -15,8 +15,10 @@ package org.talend.designer.core.generic.controller;
import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
@@ -41,6 +43,7 @@ import org.talend.components.api.properties.ComponentReferenceProperties;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IReplaceNodeHandler;
import org.talend.core.model.utils.TalendTextUtils;
import org.talend.core.ui.properties.tab.IDynamicProperty;
import org.talend.designer.core.generic.constants.IGenericConstants;
@@ -282,12 +285,12 @@ public class ComponentRefController extends AbstractElementPropertySectionContro
INode currentNode = (INode) elem;
List<INode> refNodes = getRefNodes(param, props);
List<String> itemsLabel = new ArrayList<>();
List<String> itemsValue = new ArrayList<>();
Map<String, INode> itemsValue = new LinkedHashMap<>();
// First item is this component (see also createComboCommand)
// FIXME - I18N for this message
itemsLabel.add("Use this Component");
itemsValue.add(currentNode.getUniqueName());
itemsValue.put(currentNode.getUniqueName(), currentNode);
String selectedValue;
Object referenceType = props.referenceType.getValue();
if (referenceType != null && referenceType.equals(ComponentReferenceProperties.ReferenceType.COMPONENT_INSTANCE)) {
@@ -311,19 +314,20 @@ public class ComponentRefController extends AbstractElementPropertySectionContro
displayName = uniqueName + " - " + displayName; //$NON-NLS-1$
}
itemsLabel.add(displayName);
itemsValue.add(uniqueName);
itemsValue.put(uniqueName, node);
labelToValueMap.put(displayName, uniqueName);
}
List<String> itemValueList = new ArrayList<>(itemsValue.keySet());
param.setListItemsDisplayName(itemsLabel.toArray(new String[0]));
param.setListItemsDisplayCodeName(itemsLabel.toArray(new String[0]));
param.setListItemsValue(itemsValue.toArray(new String[0]));
param.setListItemsValue(itemValueList.toArray(new String[0]));
combo.setItems(itemsLabel.toArray(new String[0]));
String iLabel = null;
int selection = 0;
for (int i = 0; i < itemsValue.size(); i++) {
String iValue = itemsValue.get(i);
for (int i = 0; i < itemValueList.size(); i++) {
String iValue = itemValueList.get(i);
if ((selectedValue == null && (((INode) elem).getUniqueName()).equals(iValue))
|| (selectedValue != null && StringUtils.isNotEmpty(iValue) && iValue.endsWith(selectedValue))) {
|| isRefernceNode(currentNode, itemsValue.get(iValue), selectedValue, props)) {
iLabel = itemsLabel.get(i);
break;
}
@@ -336,6 +340,33 @@ public class ComponentRefController extends AbstractElementPropertySectionContro
}
private boolean isRefernceNode(INode selectedNode, INode checkingNode, String selectedUniqueName, ComponentReferenceProperties props) {
IReplaceNodeHandler selectedHandler = selectedNode.getReplaceNodeHandler();
IReplaceNodeHandler checkingHandler = checkingNode.getReplaceNodeHandler();
String selectedPrefix = Optional.ofNullable(selectedHandler).map(h -> h.getPrefix()).orElse("");
String checkingPrefix = Optional.ofNullable(checkingHandler).map(h -> h.getPrefix()).orElse("");
if (checkingPrefix.startsWith(selectedPrefix)) {
String selectedNameWithoutPrefix = selectedUniqueName;
String checkingUniqueNameWithoutPrefix = checkingNode.getUniqueName();
if (selectedNameWithoutPrefix.startsWith(selectedPrefix)) {
selectedNameWithoutPrefix = selectedNameWithoutPrefix.substring(selectedPrefix.length());
}
if (checkingUniqueNameWithoutPrefix.startsWith(selectedPrefix)) {
checkingUniqueNameWithoutPrefix = checkingUniqueNameWithoutPrefix.substring(selectedPrefix.length());
}
boolean isReferenceNode = StringUtils.equals(selectedNameWithoutPrefix, checkingUniqueNameWithoutPrefix);
if (isReferenceNode && selectedNode != checkingNode) {
props.componentInstanceId.setValue(selectedNameWithoutPrefix);
props.setReference(checkingNode.getComponentProperties());
}
return isReferenceNode;
} else {
return false;
}
}
private List<INode> getRefNodes(IElementParameter param, ComponentReferenceProperties props) {
callBeforeActive(param);
List<INode> refNodes = new ArrayList<>();

View File

@@ -12,106 +12,100 @@
// ============================================================================
package org.talend.designer.core.build;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
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;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.repository.utils.ItemResourceUtil;
import org.talend.core.runtime.process.IBuildJobHandler;
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
import org.talend.core.runtime.repository.build.BuildType;
import org.talend.core.runtime.repository.build.IBuildExportHandler;
import org.talend.core.runtime.repository.build.IMavenPomCreator;
import org.talend.core.runtime.repository.build.RepositoryObjectTypeBuildProvider;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
import org.talend.designer.maven.tools.creator.CreateMavenStandardJobOSGiPom;
import org.talend.designer.runprocess.IProcessor;
import org.talend.repository.constants.BuildJobConstants;
import org.talend.repository.ui.wizards.exportjob.handler.BuildOSGiBundleHandler;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice;
/**
* DOC ggu class global comment. Detailled comment
* Build Provider for OSGI build type (ESB bundle)
*/
public class StandardJobOSGiBundleBuildProvider extends RepositoryObjectTypeBuildProvider {
private static final List<String> ESB_COMPONENTS;
static {
final List<String> esbComponents = Arrays.asList("tRESTClient", "tRESTRequest", "tRESTResponse", "tESBConsumer",
"tESBProviderFault", "tESBProviderRequest", "tESBProviderResponse", "tRouteInput", "tREST");
ESB_COMPONENTS = Collections.unmodifiableList(esbComponents);
}
private static final String OSGI = "OSGI";
@Override
public boolean valid(Map<String, Object> parameters) {
if (parameters == null || parameters.isEmpty()) {
return false;
}
ERepositoryObjectType type = null;
Property property = null;
boolean containsEsbComponent = false;
Object object = parameters.get(PROCESS);
if (object != null && object instanceof IProcess2) {
Property property = ((IProcess2) object).getProperty();
if (isOsgiBuildType(property)) {
return true;
}
IProcess2 process = (IProcess2) object;
for (INode node : process.getGraphicalNodes()) {
if (ESB_COMPONENTS.contains(node.getComponent().getName())) {
containsEsbComponent = true;
break;
}
}
property = ((IProcess2) object).getProperty();
if (property != null) {
type = ERepositoryObjectType.getType(property);
}
}
if (type == null) {
object = parameters.get(ITEM);
if (object != null && object instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) object;
ProcessType process = processItem.getProcess();
for (Object node : process.getNode()) {
NodeType nodeType = (NodeType) node;
if (ESB_COMPONENTS.contains(nodeType.getComponentName())) {
containsEsbComponent = true;
break;
}
}
property = ((Item) object).getProperty();
if (property != null) {
type = ERepositoryObjectType.getType(property);
if (node.isActivate() && BuildJobConstants.esbComponents.contains(node.getComponent().getName())) {
fixDefaultBuildType(property);
return true;
}
}
}
if (type == null) {
object = parameters.get(REPOSITORY_OBJECT);
if (object != null && object instanceof IRepositoryViewObject) {
type = ((IRepositoryViewObject) object).getRepositoryObjectType();
property = ((IRepositoryViewObject) object).getProperty();
object = parameters.get(ITEM);
if (object != null && object instanceof ProcessItem) {
Property property = ((Item) object).getProperty();
if (isOsgiBuildType(property)) {
return true;
}
ProcessItem processItem = (ProcessItem) object;
for (Object node : processItem.getProcess().getNode()) {
NodeType nodeType = (NodeType) node;
if (BuildJobConstants.esbComponents.contains(nodeType.getComponentName())) {
fixDefaultBuildType(property);
return true;
}
}
}
// && !isServiceOperation(property)
if (containsEsbComponent) {
return true;
}
return false;
}
/**
* @param property
* @return true if the build type is OSGI
*/
private boolean isOsgiBuildType(Property property) {
return property != null && "OSGI".equals(property.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE));
}
/**
* Fix the default build type if it is a ESB job
* @param property
*/
@SuppressWarnings("unchecked")
private void fixDefaultBuildType(Property property) {
if(CommonsPlugin.isHeadless() && property != null && property.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE) == null) {
property.getAdditionalProperties().put(TalendProcessArgumentConstant.ARG_BUILD_TYPE, OSGI);
}
}
@Override
protected ERepositoryObjectType getObjectType() {
return ERepositoryObjectType.PROCESS;
@@ -204,5 +198,4 @@ public class StandardJobOSGiBundleBuildProvider extends RepositoryObjectTypeBuil
contextGroup.toString(), (Map<ExportChoice, Object>) choiceOption);
return buildHandler;
}
}

View File

@@ -45,6 +45,8 @@ import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManag
*/
public class StandardJobStandaloneBuildProvider extends RepositoryObjectTypeBuildProvider {
private static final String REST_REQUEST = "tRESTRequest";
/*
* (non-Javadoc)
*
@@ -74,7 +76,7 @@ public class StandardJobStandaloneBuildProvider extends RepositoryObjectTypeBuil
if (object != null && object instanceof IProcess2) {
for (INode node : ((IProcess2) object).getGraphicalNodes()) {
if ("tRESTRequest".equals(node.getComponent().getName())) {
if (node.isActivate() && REST_REQUEST.equals(node.getComponent().getName())) {
isRestServiceProvider = true;
break;
}
@@ -97,7 +99,7 @@ public class StandardJobStandaloneBuildProvider extends RepositoryObjectTypeBuil
ProcessItem processItem = (ProcessItem) object;
for (Object node : processItem.getProcess().getNode()) {
NodeType nodeType = (NodeType) node;
if ("tRESTRequest".equals(nodeType.getComponentName())) {
if (REST_REQUEST.equals(nodeType.getComponentName())) {
isRestServiceProvider = true;
break;
}

View File

@@ -379,6 +379,8 @@ 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,6 +106,8 @@ public final class Expression {
}
}
private static final String CONTAINS = "CONTAINS"; //$NON-NLS-1$
private Expression(String expressionString) {
this.expressionString = expressionString;
}
@@ -305,6 +307,10 @@ 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) {
@@ -1063,5 +1069,28 @@ 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

@@ -514,6 +514,7 @@ public class DataProcess implements IGeneratingProcess {
((IExternalNode) dataNode).setInternalMapperModel(externalNode.getInternalMapperModel());
}
}
dataNode.setReplaceNodeHandler(graphicalNode.getReplaceNodeHandler());
dataNode.setActivate(graphicalNode.isActivate());
dataNode.setStart(graphicalNode.isStart());

View File

@@ -429,6 +429,8 @@ public abstract class Processor implements IProcessor, IEclipseProcessor, Talend
*/
@Override
public String getInterpreter() throws ProcessorException {
if (this.isLinuxTargetPlatform())
return "java";
return interpreter;
}
@@ -774,6 +776,13 @@ 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,11 +12,15 @@
// ============================================================================
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;
@@ -91,6 +95,8 @@ public class ChangeConnTextCommand extends Command {
UpgradeElementHelper.renameData(connection.getTarget(), oldName, newName);
((Process) connection.getSource().getProcess()).checkProcess();
updateELTElementParameter(connection.getSource(), newName);
}
@Override
@@ -128,4 +134,52 @@ 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

@@ -557,6 +557,7 @@ public class ChangeMetadataCommand extends Command {
}
}
MetadataToolHelper.copyTable(newInputMetadata, currentInputMetadata);
currentOutputMetadata.setOriginalColumns(newOutputMetadata.getOriginalColumns());
}
}
@@ -573,6 +574,7 @@ public class ChangeMetadataCommand extends Command {
}
}
MetadataToolHelper.copyTable(newOutputMetadata, currentOutputMetadata);
currentOutputMetadata.setOriginalColumns(newOutputMetadata.getOriginalColumns());
}
if (inputSchemaParam != null
&& inputSchemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()) != null

View File

@@ -14,6 +14,7 @@ import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.graphics.Image;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.ui.gmf.util.DisplayUtils;
import org.talend.commons.ui.runtime.image.ECoreImage;
import org.talend.commons.ui.runtime.image.ImageProvider;
@@ -28,6 +29,7 @@ import org.talend.core.model.process.INode;
import org.talend.core.model.process.INodeConnector;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.process.JobletReplaceNodeHandler;
import org.talend.core.model.properties.Project;
import org.talend.core.ui.IJobletProviderService;
import org.talend.designer.core.DesignerPlugin;
@@ -379,6 +381,12 @@ public class JobletContainer extends AbstractJobletContainer {
conns.addAll(temNode.getIncomingConnections());
conns.addAll(temNode.getOutgoingConnections());
Node jnode = util.cloneNode(temNode, this.node.getProcess(), paraMap, lockByOther);
try {
JobletReplaceNodeHandler replaceHandler = new JobletReplaceNodeHandler(node.getUniqueName() + "_");
jnode.setReplaceNodeHandler(replaceHandler);
} catch (Throwable e) {
ExceptionHandler.process(e);
}
if (!this.node.isActivate()) {
jnode.setActivate(this.node.isActivate());
}

View File

@@ -89,6 +89,7 @@ import org.talend.core.model.process.INodeReturn;
import org.talend.core.model.process.IPerformance;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.process.IReplaceNodeHandler;
import org.talend.core.model.process.Problem;
import org.talend.core.model.process.Problem.ProblemStatus;
import org.talend.core.model.properties.JobletProcessItem;
@@ -320,6 +321,8 @@ public class Node extends Element implements IGraphicalNode {
private List<String> previousCustomLibs = null;
private IReplaceNodeHandler replaceNodeHandler;
/**
* Getter for index.
*
@@ -5630,4 +5633,13 @@ public class Node extends Element implements IGraphicalNode {
return this.delegateComponent;
}
@Override
public IReplaceNodeHandler getReplaceNodeHandler() {
return replaceNodeHandler;
}
public void setReplaceNodeHandler(IReplaceNodeHandler replaceNodeHandler) {
this.replaceNodeHandler = replaceNodeHandler;
}
}

View File

@@ -1372,7 +1372,8 @@ 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)) {
if (EParameterName.ACTIVE_DATABASE_DELIMITED_IDENTIFIERS.getName().equals(paramName)
|| EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName().equals(paramName)) {
canAddElementParameter = true;
}
if (canAddElementParameter) {

View File

@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.gef.commands.Command;
@@ -58,6 +59,7 @@ import org.talend.core.language.LanguageManager;
import org.talend.core.model.metadata.IMetadataColumn;
import org.talend.core.model.metadata.IMetadataConnection;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MappingTypeRetriever;
import org.talend.core.model.metadata.MetadataColumn;
import org.talend.core.model.metadata.MetadataTable;
import org.talend.core.model.metadata.MetadataTalendType;
@@ -355,6 +357,14 @@ public class GuessSchemaController extends AbstractElementPropertySectionControl
columns.clear();
}
if (!schemaContent.isEmpty()) {
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(dbmsId);
if (mappingTypeRetriever == null) {
@SuppressWarnings("null")
EDatabaseTypeName dbType = EDatabaseTypeName.getTypeFromDbType(connt.getDatabaseType(), false);
if (dbType != null) {
mappingTypeRetriever = MetadataTalendType.getMappingTypeRetrieverByProduct(dbType.getProduct());
}
}
int numbOfColumn = schemaContent.get(0).length;
for (int i = 1; i <= numbOfColumn; i++) {
@@ -425,6 +435,21 @@ public class GuessSchemaController extends AbstractElementPropertySectionControl
dbType = TypesManager.getDBTypeFromTalendType(dbmsId, oneColum.getTalendType());
}
oneColum.setType(dbType);
if (oneColum.getTalendType() != null) {
if (oneColum.getTalendType().equals(JavaTypesManager.DATE.getId())
|| oneColum.getTalendType().equals(PerlTypesManager.DATE)) {
if ("".equals(oneColum.getPattern())) { //$NON-NLS-1$
if (mappingTypeRetriever != null) {
String pattern = mappingTypeRetriever.getDefaultPattern(dbmsId,
oneColum.getType());
oneColum.setPattern(StringUtils.isNotBlank(pattern) ? TalendQuoteUtils.addQuotes(pattern)
: TalendQuoteUtils.addQuotes("dd-MM-yyyy"));//$NON-NLS-1$
} else {
oneColum.setPattern(TalendQuoteUtils.addQuotes("dd-MM-yyyy")); //$NON-NLS-1$
}
}
}
}
}
}
// oneColum.setTalendType(JavaTypesManager.STRING.getId());

View File

@@ -175,6 +175,8 @@ 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,6 +114,8 @@ 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) {
@@ -139,6 +141,7 @@ 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();
@@ -149,6 +152,13 @@ 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();
@@ -211,6 +221,17 @@ 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;
@@ -297,7 +318,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,7 +490,8 @@ public class JavaProcessUtil {
mn = getModuleValue(process, moduleName);
}
if (line.get("JAR_NEXUS_VERSION") != null) {
String nexusJarVersion = (String) line.get("JAR_NEXUS_VERSION");
if (StringUtils.isNotBlank(nexusJarVersion)) {
String a = moduleName.replaceFirst("[.][^.]+$", "");
mn.setMavenUri("mvn:org.talend.libraries/" + a + "/"
+ line.get("JAR_NEXUS_VERSION") + "/jar");

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@@ -68,9 +68,7 @@ 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 :
@@ -159,3 +157,7 @@ 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

@@ -54,6 +54,7 @@ import org.talend.designer.dbmap.i18n.Messages;
import org.talend.designer.dbmap.language.generation.DbGenerationManager;
import org.talend.designer.dbmap.language.generation.GenericDbGenerationManager;
import org.talend.designer.dbmap.language.hive.HiveGenerationManager;
import org.talend.designer.dbmap.language.mssql.MssqlGenerationManager;
import org.talend.designer.dbmap.language.mysql.MysqlGenerationManager;
import org.talend.designer.dbmap.language.oracle.OracleGenerationManager;
import org.talend.designer.dbmap.language.postgres.PostgresGenerationManager;
@@ -180,6 +181,29 @@ 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();
@@ -602,6 +626,8 @@ public class DbMapComponent extends AbstractMapComponent {
generationManager = new PostgresGenerationManager();
} else if (value.contains("tELTHiveMap")) { //$NON-NLS-1$
generationManager = new HiveGenerationManager();
} else if (value.contains("tELTMSSqlMap")) {
generationManager = new MssqlGenerationManager();
} else if (value.startsWith("tELT") && value.endsWith("Map")) //$NON-NLS-1$ //$NON-NLS-2$
{
generationManager = new GenericDbGenerationManager();
@@ -609,6 +635,7 @@ public class DbMapComponent extends AbstractMapComponent {
throw new IllegalArgumentException(Messages.getString("DbMapComponent.unknowValue") + value); //$NON-NLS-1$
}
updateUseDelimitedIdentifiersStatus();
updateUseAliasInOutputTableStatus();
}
return generationManager;
@@ -618,6 +645,7 @@ public class DbMapComponent extends AbstractMapComponent {
public void setOriginalNode(INode originalNode) {
super.setOriginalNode(originalNode);
updateUseDelimitedIdentifiersStatus();
updateUseAliasInOutputTableStatus();
}
private void updateUseDelimitedIdentifiersStatus() {
@@ -639,6 +667,25 @@ 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,7 +12,11 @@
// ============================================================================
package org.talend.designer.dbmap.language.generation;
import static java.util.Optional.*;
import static java.util.stream.Collectors.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -91,6 +95,8 @@ public abstract class DbGenerationManager {
private Boolean useDelimitedIdentifiers;
private Boolean useAliasInOutputTable;
protected Set<String> subQueryTable = new HashSet<String>();
protected INode source;
@@ -272,6 +278,9 @@ public abstract class DbGenerationManager {
return tableName;
}
protected String addQuotes(String name) {
return name;
}
/**
*
* ggu Comment method "buildSqlSelect".
@@ -641,12 +650,15 @@ public abstract class DbGenerationManager {
}
}
// Update
String targetSchemaTable = outTableName;
String targetSchemaTable = getDifferentTable(dbMapComponent, outputTableName);
if (targetSchemaTable == null) {
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 + outTableName;
targetSchemaTable = schema + DbMapSqlConstants.DOT + targetSchemaTable;
}
}
@@ -667,7 +679,7 @@ public abstract class DbGenerationManager {
int lstSizeOutTableEntries = metadataTableEntries.size();
for (int i = 0; i < lstSizeOutTableEntries; i++) {
ExternalDbMapEntry dbMapEntry = metadataTableEntries.get(i);
String columnEntry = outTableName + DbMapSqlConstants.DOT + dbMapEntry.getName();
String columnEntry = dbMapEntry.getName();
String expression = dbMapEntry.getExpression();
expression = initExpression(component, dbMapEntry);
expression = addQuoteForSpecialChar(expression, component);
@@ -714,13 +726,6 @@ 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
@@ -739,35 +744,17 @@ 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;
boolean isFirstClause = true;
for (int i = 0; i < lstSizeInputTables; i++) {
ExternalDbMapTable inputTable = inputTables.get(i);
if (buildConditions(component, sbWhere, inputTable, false, isFirstClause, false)) {
if (buildConditions4WhereClause(isFirstClause, component, sbWhere, inputTable, false)) {
isFirstClause = false;
}
}
@@ -876,7 +863,7 @@ public abstract class DbGenerationManager {
}
protected void checkParameters(DbMapComponent component) {
checkUseDelimitedIdentifiers(component);
checkSpecialParameters(component);
}
protected boolean checkUseUpdateStatement(DbMapComponent dbMapComponent, String outputTableName) {
@@ -895,7 +882,68 @@ public abstract class DbGenerationManager {
return false;
}
protected void checkUseDelimitedIdentifiers(DbMapComponent component) {
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
* <b>USE_UPDATE_STATEMENT</b>
*
* @return List of columns that going to be skipped, if no <b>SET_COLUMN</b> specified then return empty list.
*/
protected List<Boolean> getSetColumnsForUpdateQuery() {
return ofNullable(source.getElementParameter("SET_COLUMN")).filter(iep -> iep.isShow(source.getElementParameters()))
.flatMap(iep -> ofNullable((List<Map<String, ? extends Object>>) iep.getValue()))
.orElseGet(Collections::emptyList).stream().map(m -> !Boolean.valueOf(m.get("UPDATE_COLUMN").toString()))
.collect(toList());
}
protected void checkSpecialParameters(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
@@ -912,6 +960,18 @@ 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()));
}
}
}
}
/**
@@ -942,10 +1002,17 @@ 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;
}
@@ -973,6 +1040,10 @@ 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);
}
@@ -1056,7 +1127,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);
}
/**
@@ -1088,6 +1159,35 @@ public abstract class DbGenerationManager {
return atLeastOneConditionWritten;
}
/**
* build conditions for update case only DOC hzhao Comment method "buildConditions".
*
* @param isFirstClause
* @param component
* @param sb
* @param inputTable
* @param isSqlQuert
* @return
*/
protected boolean buildConditions4WhereClause(boolean isFirstClause, DbMapComponent component, StringBuilder sb,
ExternalDbMapTable inputTable,
boolean isSqlQuert) {
List<ExternalDbMapEntry> inputEntries = inputTable.getMetadataTableEntries();
int lstSizeEntries = inputEntries.size();
boolean atLeastOneConditionWritten = false;
for (int j = 0; j < lstSizeEntries; j++) {
ExternalDbMapEntry dbMapEntry = inputEntries.get(j);
boolean conditionWritten = buildCondition(component, sb, inputTable, isFirstClause, dbMapEntry, true, isSqlQuert);
if (conditionWritten) {
atLeastOneConditionWritten = true;
}
if (isFirstClause && conditionWritten) {
isFirstClause = false;
}
}
return atLeastOneConditionWritten;
}
/**
* DOC amaumont Comment method "buildCondition".
*
@@ -1365,8 +1465,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;
@@ -1539,23 +1639,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) {
@@ -1712,4 +1812,337 @@ public abstract class DbGenerationManager {
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;
for (ExternalDbMapEntry dbMapEntry : inputEntries) {
if (dbMapEntry.isJoin()) {
if (org.apache.commons.lang.StringUtils.isNotEmpty(dbMapEntry.getExpression())
&& org.apache.commons.lang.StringUtils.isNotEmpty(dbMapEntry.getOperator())) {
atLeastOneConditionIsChecked = true;
break;
}
}
}
return atLeastOneConditionIsChecked;
}
public String buildSqlUpdate(DbMapComponent dbMapComponent, String outputTableName, String tabString) {
queryColumnsName = "\""; //$NON-NLS-1$
aliasAlreadyDeclared.clear();
queryColumnsSegments.clear();
querySegments.clear();
subQueryTable.clear();
inputSchemaContextSet.clear();
this.tabSpaceString = tabString;
DbMapComponent component = getDbMapComponent(dbMapComponent);
List<IConnection> outputConnections = (List<IConnection>) component.getOutgoingConnections();
Map<String, IConnection> nameToOutputConnection = new HashMap<String, IConnection>();
for (IConnection connection : outputConnections) {
nameToOutputConnection.put(connection.getUniqueName(), connection);
}
ExternalDbMapData data = component.getExternalData();
StringBuilder sb = new StringBuilder();
List<ExternalDbMapTable> outputTables = data.getOutputTables();
int lstOutputTablesSize = outputTables.size();
ExternalDbMapTable outputTable = null;
for (int i = 0; i < lstOutputTablesSize; i++) {
ExternalDbMapTable temp = outputTables.get(i);
if (outputTableName.equals(temp.getName())) {
outputTable = temp;
break;
}
}
if (outputTable != null) {
String outTableName = outputTable.getTableName();
IConnection connection = nameToOutputConnection.get(outputTable.getName());
List<IMetadataColumn> columns = new ArrayList<IMetadataColumn>();
if (connection != null) {
IMetadataTable metadataTable = connection.getMetadataTable();
if (metadataTable != null) {
columns.addAll(metadataTable.getListColumns());
}
}
// Update
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 = addQuotes(schema) + DbMapSqlConstants.DOT + addQuotes(outTableName);
}
}
appendSqlQuery(sb, "\"", false); //$NON-NLS-1$
appendSqlQuery(sb, DbMapSqlConstants.UPDATE);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, targetSchemaTable);
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
// Set
String keyColumn = DbMapSqlConstants.EMPTY;
List<ExternalDbMapEntry> metadataTableEntries = outputTable.getMetadataTableEntries();
if (metadataTableEntries != null) {
appendSqlQuery(sb, "SET"); //$NON-NLS-1$
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
boolean isKey = false;
int lstSizeOutTableEntries = metadataTableEntries.size();
List<Boolean> setColumns = getSetColumnsForUpdateQuery();
final boolean hasDeactivatedColumns = !setColumns.isEmpty();
boolean isFirstColumn = true;
for (int i = 0; i < lstSizeOutTableEntries; i++) {
if (hasDeactivatedColumns && setColumns.get(i)) {
continue;
}
ExternalDbMapEntry dbMapEntry = metadataTableEntries.get(i);
String columnEntry = dbMapEntry.getName();
String expression = dbMapEntry.getExpression();
expression = initExpression(component, dbMapEntry);
expression = addQuoteForSpecialChar(expression, component);
//
if (!DEFAULT_TAB_SPACE_STRING.equals(this.tabSpaceString)) {
expression += DbMapSqlConstants.SPACE + DbMapSqlConstants.AS + DbMapSqlConstants.SPACE
+ getAliasOf(dbMapEntry.getName());
}
String exp = replaceVariablesForExpression(component, expression);
String columnSegment = exp;
// Added isFirstColumn to conform old behaior if first column is skipped
if (i > 0 && !isFirstColumn) {
queryColumnsName += DbMapSqlConstants.COMMA + DbMapSqlConstants.SPACE;
columnSegment = DbMapSqlConstants.COMMA + DbMapSqlConstants.SPACE + columnSegment;
}
if (expression != null && expression.trim().length() > 0) {
queryColumnsName += exp;
queryColumnsSegments.add(columnSegment);
}
//
if (!isKey) {
for (IMetadataColumn column : columns) {
String columnName = column.getLabel();
if (columnName.equals(dbMapEntry.getName()) && column.isKey()) {
isKey = column.isKey();
keyColumn = addQuotes(columnEntry) + " = " + expression;//$NON-NLS-1$
break;
}
}
if (isKey) {
continue;
}
}
if (expression != null && expression.trim().length() > 0) {
// Append COMMA and NEW_LINE for all columns except FIRST.
if (!isFirstColumn) {
appendSqlQuery(sb, DbMapSqlConstants.COMMA);
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
} else {
isFirstColumn = false;
}
appendSqlQuery(sb, addQuotes(columnEntry) + " = " + expression); //$NON-NLS-1$
}
}
}
if ("\"".equals(queryColumnsName)) {
throw new IllegalArgumentException("Specify at least 1 column for UPDATE QUERY in SET section");
}
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
// From
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.FROM);
// load input table in hash
List<ExternalDbMapTable> inputTables = data.getInputTables();
// load input table in hash
boolean explicitJoin = false;
int lstSizeInputTables = inputTables.size();
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, tabSpaceString);
IJoinType previousJoinType = null;
for (int i = 0; i < lstSizeInputTables; i++) {
ExternalDbMapTable inputTable = inputTables.get(i);
IJoinType joinType = language.getJoin(inputTable.getJoinType());
if (!language.unuseWithExplicitJoin().contains(joinType) && i > 0) {
explicitJoin = true;
} else {
explicitJoin = false;
}
if (i == 0) {
joinType = AbstractDbLanguage.JOIN.NO_JOIN;
previousJoinType = joinType;
} else {
joinType = language.getJoin(inputTable.getJoinType());
}
boolean commaCouldBeAdded = !explicitJoin && i > 0;
boolean crCouldBeAdded = false;
if (language.unuseWithExplicitJoin().contains(joinType) && !explicitJoin) {
buildTableDeclaration(component, sb, inputTable, commaCouldBeAdded, crCouldBeAdded, false);
} else if (!language.unuseWithExplicitJoin().contains(joinType) && explicitJoin) {
if (i > 0) {
if (previousJoinType == null) {
buildTableDeclaration(component, sb, inputTables.get(i - 1), commaCouldBeAdded, crCouldBeAdded, true);
previousJoinType = joinType;
} else {
// appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, tabSpaceString);
}
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
}
String labelJoinType = joinType.getLabel();
if (joinType == AbstractDbLanguage.JOIN.CROSS_JOIN) {
ExternalDbMapTable nextTable = null;
if (i < lstSizeInputTables) {
nextTable = inputTables.get(i);
appendSqlQuery(sb, labelJoinType);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
buildTableDeclaration(component, sb, nextTable, false, true, true);
}
} else {
if (isConditionChecked(component, inputTable)) {
appendSqlQuery(sb, labelJoinType);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
buildTableDeclaration(component, sb, inputTable, false, false, true);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, DbMapSqlConstants.ON);
appendSqlQuery(sb, DbMapSqlConstants.LEFT_BRACKET);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
buildConditions(component, sb, inputTable, true, true, true);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, DbMapSqlConstants.RIGHT_BRACKET);
} else {
commaCouldBeAdded = true;
buildTableDeclaration(component, sb, inputTable, commaCouldBeAdded, crCouldBeAdded, false);
}
}
}
}
// where
StringBuilder sbWhere = new StringBuilder();
this.tabSpaceString = DEFAULT_TAB_SPACE_STRING;
boolean isFirstClause = true;
for (int i = 0; i < lstSizeInputTables; i++) {
ExternalDbMapTable inputTable = inputTables.get(i);
IJoinType joinType = language.getJoin(inputTable.getJoinType());
if (joinType == AbstractDbLanguage.JOIN.CROSS_JOIN) {
// if join type is CROSS JOIN the condition will only in where clause no matter explicit join
// checked or not
if (buildConditions4WhereClause(isFirstClause, component, sbWhere, inputTable, false)) {
isFirstClause = false;
}
} else {
if (buildConditions(component, sbWhere, inputTable, false, isFirstClause, false)) {
isFirstClause = false;
}
}
}
/*
* for addition conditions
*/
// like as input.newcolumn1>100
List<String> whereAddition = new ArrayList<String>();
// olny pure start with group or order, like as order/group by input.newcolumn1
// List<String> byAddition = new ArrayList<String>();
// like as input.newcolumn1>100 group/oder by input.newcolumn1
// List<String> containWhereAddition = new ArrayList<String>();
// like as "OR/AND input.newcolumn1", will keep original
List<String> originalWhereAddition = new ArrayList<String>();
List<String> otherAddition = new ArrayList<String>();
if (outputTable != null) {
List<ExternalDbMapEntry> customWhereConditionsEntries = outputTable.getCustomWhereConditionsEntries();
if (customWhereConditionsEntries != null) {
for (ExternalDbMapEntry entry : customWhereConditionsEntries) {
String exp = initExpression(component, entry);
if (exp != null && !DbMapSqlConstants.EMPTY.equals(exp.trim())) {
if (containWith(exp, DbMapSqlConstants.OR, true) || containWith(exp, DbMapSqlConstants.AND, true)) {
exp = replaceVariablesForExpression(component, exp);
originalWhereAddition.add(exp);
} else {
exp = replaceVariablesForExpression(component, exp);
whereAddition.add(exp);
}
}
}
}
List<ExternalDbMapEntry> customOtherConditionsEntries = outputTable.getCustomOtherConditionsEntries();
if (customOtherConditionsEntries != null) {
for (ExternalDbMapEntry entry : customOtherConditionsEntries) {
String exp = initExpression(component, entry);
if (exp != null && !DbMapSqlConstants.EMPTY.equals(exp.trim())) {
exp = replaceVariablesForExpression(component, exp);
otherAddition.add(exp);
}
}
}
}
this.tabSpaceString = tabString;
String whereClauses = sbWhere.toString();
boolean whereFlag = whereClauses.trim().length() > 0;
boolean whereAddFlag = !whereAddition.isEmpty();
boolean whereOriginalFlag = !originalWhereAddition.isEmpty();
if (whereFlag || whereAddFlag || whereOriginalFlag) {
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.WHERE);
}
if (whereFlag) {
appendSqlQuery(sb, whereClauses);
}
if (whereAddFlag) {
for (int i = 0; i < whereAddition.size(); i++) {
if (i == 0 && whereFlag || i > 0) {
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, tabSpaceString);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, DbMapSqlConstants.AND);
}
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, whereAddition.get(i));
}
}
if (whereOriginalFlag) {
for (String s : originalWhereAddition) {
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
appendSqlQuery(sb, s);
}
}
if (!otherAddition.isEmpty()) {
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, tabSpaceString);
for (String s : otherAddition) {
appendSqlQuery(sb, s);
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
appendSqlQuery(sb, tabSpaceString);
}
}
}
String sqlQuery = sb.toString();
sqlQuery = handleQuery(sqlQuery);
queryColumnsName = handleQuery(queryColumnsName);
return sqlQuery;
}
}

View File

@@ -12,8 +12,12 @@
// ============================================================================
package org.talend.designer.dbmap.language.generation;
import java.util.Optional;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.designer.dbmap.DbMapComponent;
import org.talend.designer.dbmap.language.GenericDbLanguage;
import org.talend.designer.dbmap.language.mssql.MssqlGenerationManager;
/**
* wzhang class global comment. Detailled comment
@@ -26,6 +30,17 @@ public class GenericDbGenerationManager extends DbGenerationManager {
@Override
public String buildSqlSelect(DbMapComponent component, String outputTableName) {
try {
if (Optional.ofNullable(component).map(c -> c.getComponent()).map(c -> "tELTMSSqlMap".equals(c.getName()))
.orElse(false)) {
MssqlGenerationManager genManager = new MssqlGenerationManager();
String result = genManager.buildSqlSelect(component, outputTableName);
this.queryColumnsName = genManager.getQueryColumnsName();
return result;
}
} catch (Throwable e) {
ExceptionHandler.process(e);
}
return super.buildSqlSelect(component, outputTableName);
}
}

View File

@@ -0,0 +1,34 @@
// ============================================================================
//
// Copyright (C) 2006-2019 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.language.mssql;
import org.talend.designer.dbmap.DbMapComponent;
import org.talend.designer.dbmap.language.GenericDbLanguage;
import org.talend.designer.dbmap.language.generation.DbGenerationManager;
public class MssqlGenerationManager extends DbGenerationManager {
public MssqlGenerationManager() {
super(new GenericDbLanguage());
}
@Override
public String buildSqlSelect(DbMapComponent component, String outputTableName) {
boolean checkUseUpdateStatement = checkUseUpdateStatement(component, outputTableName);
if (checkUseUpdateStatement) {
return buildSqlUpdate(component, outputTableName, DEFAULT_TAB_SPACE_STRING);
} else {
return super.buildSqlSelect(component, outputTableName, DEFAULT_TAB_SPACE_STRING);
}
}
}

View File

@@ -140,24 +140,8 @@ public class OracleGenerationManager extends DbGenerationManager {
if (expression != null && expression.trim().length() > 0) {
String exp = replaceVariablesForExpression(component, expression);
appendSqlQuery(sb, exp);
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) {
boolean needAlias = needAlias(columns, dbMapEntry, expression);
if (!added && needAlias && isUseAliasInOutputTable()) {
String name = DbMapSqlConstants.SPACE + DbMapSqlConstants.AS + DbMapSqlConstants.SPACE
+ getAliasOf(dbMapEntry.getName());
appendSqlQuery(sb, name);
@@ -443,4 +427,22 @@ 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,6 +781,11 @@ public class MapperManager extends AbstractMapperManager {
uiManager.refreshSqlExpression();
}
public void useAliasInOutputTable(boolean useAliasInOutputTable) {
getComponent().getGenerationManager().setUseAliasInOutputTable(useAliasInOutputTable);
uiManager.refreshSqlExpression();
}
/**
* Getter for problemsManager.
*
@@ -790,6 +795,15 @@ 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".
*/
@@ -892,4 +906,4 @@ public class MapperManager extends AbstractMapperManager {
return false;
}
}
}

View File

@@ -86,6 +86,7 @@ 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;
@@ -1367,6 +1368,11 @@ public class UIManager extends AbstractUIManager {
return getMapperContainer().getDisplay();
}
@Override
public void openPropertySetDialog() {
new PropertySetDialog(getShell(), mapperManager).open();
}
/**
*
* DOC amaumont Comment method "moveSelectedTable".

View File

@@ -0,0 +1,144 @@
// ============================================================================
//
// 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,6 +28,7 @@ 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,8 +36,6 @@ 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$
@@ -84,11 +82,6 @@ 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());
}
/**
@@ -123,15 +116,6 @@ 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,6 +45,8 @@ public abstract class ToolbarZone {
private ToolItem downTableButton;
private ToolItem propertyButton;
private ToolItem minimizeButton;
protected boolean minimized;
@@ -72,9 +74,6 @@ public abstract class ToolbarZone {
}
}
/**
* DOC amaumont Comment method "createComponents".
*/
public void addCommonsComponents() {
upTableButton = new ToolItem(toolBarActions, SWT.PUSH);
@@ -91,6 +90,13 @@ 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);
@@ -127,6 +133,14 @@ 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,6 +46,9 @@ 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 + ")|("
@@ -216,7 +219,7 @@ public class DataMapExpressionParser {
} else {
patternMatcherInput.setInput(sqlQuery);
}
recompilePatternIfNecessary(GLOBALMAP_PATTERN);
recompilePatternIfNecessary(GLOBALMAP_PATTERN2);
while (matcher.contains(patternMatcherInput, pattern)) {
MatchResult matchResult = matcher.getMatch();
if (matchResult.group(1) != null) {

View File

@@ -2427,7 +2427,9 @@ 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);
mapperManager.getUiManager().refreshBackground(false, false);
if (headerComposite != null && !headerComposite.isDisposed()) {
mapperManager.getUiManager().refreshBackground(false, false);
}
}
}

View File

@@ -826,8 +826,13 @@ public class InputDataMapTableView extends DataMapTableView {
previousStateAtLeastOneHashKey = stateAtLeastOneHashKey;
}
checkLookupTableProblems(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);
}
mapSettingViewerCreator.refresh();
}

View File

@@ -14,6 +14,7 @@
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**/*.class</include>
<include>${talend.job.path}/**/*.wsdl</include>
<include>__tdm/**</include>
</includes>
</fileSet>
@@ -22,8 +23,8 @@
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>OSGI-INF/**</include>
<include>TALEND-INF/**</include>
<include>MAVEN-INF/**</include>
<include>TALEND-INF/**</include>
<include>MAVEN-INF/**</include>
</includes>
</fileSet>
<fileSet> <!-- add resources -->
@@ -46,8 +47,8 @@
<includes>
<include>**</include>
</includes>
</fileSet>
</fileSet>
<fileSet> <!-- add metadata -->
<directory>${basedir}/src/main/resources</directory>
<outputDirectory>${file.separator}</outputDirectory>
@@ -55,7 +56,7 @@
<include>metadata/**</include>
</includes>
</fileSet>
<fileSet>
<directory>${current.resources.dir}</directory>
<outputDirectory>${file.separator}</outputDirectory>

View File

@@ -1,67 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>jar-with-dependencies</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>jar</format>
</formats>
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>jar-with-dependencies</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSets>
<fileSet> <!-- add java classes -->
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**/*.class</include>
<include>__tdm/**</include>
</includes>
</fileSet>
<fileSet> <!-- add osgi resources -->
<directory>${current.bundle.resources.dir}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>OSGI-INF/**</include>
<include>TALEND-INF/**</include>
<include>MAVEN-INF/**</include>
</includes>
</fileSet>
<fileSet> <!-- add java classes -->
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**/*.class</include>
<include>${talend.job.path}/**/*.wsdl</include>
<include>__tdm/**</include>
</includes>
</fileSet>
<fileSet> <!-- add route resources -->
<directory>${current.bundle.resources.dir}/resources</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
<fileSet> <!-- add osgi resources -->
<directory>${current.bundle.resources.dir}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>OSGI-INF/**</include>
<include>TALEND-INF/**</include>
<include>MAVEN-INF/**</include>
</includes>
</fileSet>
<fileSet> <!-- add route lib -->
<directory>${current.bundle.resources.dir}/lib</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
<fileSet> <!-- add route resources -->
<directory>${current.bundle.resources.dir}/resources</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
<fileSet> <!-- add route lib -->
<directory>${current.bundle.resources.dir}/lib</directory>
<outputDirectory>lib</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
<fileSet> <!-- add context resources -->
<directory>${current.resources.dir}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**</include>
</includes>
</fileSet>
<fileSet> <!-- add context resources -->
<directory>${resources.path}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**</include>
</includes>
</fileSet>
<fileSet><!-- add context resources -->
<directory>${current.resources.dir}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**</include>
</includes>
</fileSet>
<fileSet><!-- add context resources -->
<directory>${resources.path}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**</include>
</includes>
</fileSet>
<fileSet> <!-- add provided-lib -->
<directory>${current.bundle.resources.dir}/provided-lib</directory>
<outputDirectory>lib</outputDirectory>
@@ -69,17 +70,17 @@
<include>**</include>
</includes>
</fileSet>
</fileSets>
<!-- <dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<includes>
<include>${routines.binaries.includes.set}</include>
</includes>
without version for talend libraries
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
<useProjectArtifact>false</useProjectArtifact>
</dependencySet>
</dependencySets> -->
</fileSets>
<!-- <dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<includes>
<include>${routines.binaries.includes.set}</include>
</includes>
without version for talend libraries
<outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
<useProjectArtifact>false</useProjectArtifact>
</dependencySet>
</dependencySets> -->
</assembly>

View File

@@ -44,6 +44,7 @@
</dependencies>
<build>
<finalName>${talend.job.finalName}</finalName>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
@@ -63,8 +64,32 @@
<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>
@@ -90,7 +115,7 @@
</descriptors>
<tarLongFileMode>gnu</tarLongFileMode>
<appendAssemblyId>false</appendAssemblyId>
<finalName>${talend.job.name}-bundle-${project.version}</finalName>
<finalName>${talend.job.finalName}</finalName>
</configuration>
</execution>
</executions>

View File

@@ -44,6 +44,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.osgi.framework.Bundle;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.CorePlugin;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.IESBService;
@@ -295,7 +296,7 @@ public class DefaultRunProcessService implements IRunProcessService {
return new MavenJavaProcessor(process, property, filenameFromLabel);
} else {
if (property != null) {
if (!ProcessorUtilities.isGeneratePomOnly()) {
// if (!ProcessorUtilities.isGeneratePomOnly()) {
// for esb type only
boolean servicePart = false;
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(property.getId(),
@@ -337,7 +338,7 @@ public class DefaultRunProcessService implements IRunProcessService {
return soapService.createOSGIJavaProcessor(process, property, filenameFromLabel);
}
}
}
// }
return new MavenJavaProcessor(process, property, filenameFromLabel);
} else {
return new MavenJavaProcessor(process, property, filenameFromLabel);
@@ -931,7 +932,7 @@ public class DefaultRunProcessService implements IRunProcessService {
IFolder targetFolder = mainProject.getFolder(refPath.removeLastSegments(1));
if (!targetFolder.exists()) {
targetFolder.create(true, false, progressMonitor);
ResourceUtils.createFolder(targetFolder);
}
if (codeFile.getLocation().removeLastSegments(1).equals(targetFolder.getLocation())) {
continue;

View File

@@ -596,6 +596,10 @@ public class RunProcessContext {
TimeMeasure.begin(generateCodeId);
try {
BuildCacheManager.getInstance().clearCurrentCache();
//TESB-29071
if (ProcessorUtilities.isRemoteProject()) {
BuildCacheManager.getInstance().clearAllCodesCache();
}
ProcessorUtilities.resetExportConfig();
ProcessorUtilities
.generateCode(processor, process, context,

View File

@@ -41,6 +41,7 @@ import java.util.zip.ZipInputStream;
import org.apache.commons.codec.binary.Base64InputStream;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
@@ -216,6 +217,8 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
private String jobVersion;
private static final Logger LOGGER = Logger.getLogger(JavaProcessor.class);
/**
* Set current status.
*
@@ -1213,12 +1216,28 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
} else {
localM2Path = localM2Path + PomUtil.getLocalRepositoryPath();
}
asList.add(3, localM2Path);
insertArgument(asList, localM2Path);
}
return asList.toArray(new String[0]);
}
}
private static void insertArgument(List<String> asList, String arg) throws ProcessorException {
// https://jira.talendforge.org/browse/TUP-27053
int idx = -1;
for (int i = 0; i < asList.size(); i++) {
if (asList.get(i).equals("-cp")) {
idx = i;
break;
}
}
if (idx > -1) {
asList.add(idx, arg);
} else {
throw new ProcessorException("Can not insert " + arg);
}
}
@Override
public List<String> extractAheadCommandSegments() {
List<String> aheadSegments = new ArrayList<>();
@@ -1310,6 +1329,7 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
final String rootWorkingDir = getRootWorkingDir(false);
StringBuffer basePath = new StringBuffer(50);
if (isExportConfig() || isRunAsExport()) {
// current path.
basePath.append('.');
@@ -1469,7 +1489,9 @@ 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) {
@@ -1561,7 +1583,7 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
Set<JobInfo> infos = getBuildChildrenJobs();
for (JobInfo jobInfo : infos) {
String childJarName = JavaResourcesHelper.getJobFolderName(jobInfo.getJobName(), jobInfo.getJobVersion());
String childJarName = JavaResourcesHelper.getJobFolderName(jobInfo);
exportJar += classPathSeparator + rootWorkingDir + childJarName + FileExtensions.JAR_FILE_SUFFIX;
}
return exportJar;
@@ -1658,13 +1680,21 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
}
}
}
// if not check or the value is empty, should use preference
if (string == null || "".equals(string)) { //$NON-NLS-1$
string = RunProcessPlugin.getDefault().getPreferenceStore().getString(RunProcessPrefsConstants.VMARGUMENTS);
// https://jira.talendforge.org/browse/TUP-27374
String[] vmargs = null;
try {
// if not check or the value is empty, should use preference
if (string == null || "".equals(string)) { //$NON-NLS-1$
string = RunProcessPlugin.getDefault().getPreferenceStore().getString(RunProcessPrefsConstants.VMARGUMENTS);
}
String replaceAll = string.trim();
List<String> vmList = new JobVMArgumentsUtil().readString(replaceAll);
vmargs = vmList.toArray(new String[0]);
} catch (Exception e) {
LOGGER.debug(e.getMessage(), e);
// UI can not be loaded, use default jvm args
vmargs = JobVMArgumentsUtil.DEFAULT_JVM_ARGS;
}
String replaceAll = string.trim();
List<String> vmList = new JobVMArgumentsUtil().readString(replaceAll);
String[] vmargs = vmList.toArray(new String[0]);
return vmargs;
}
@@ -1964,13 +1994,17 @@ 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());
}
resourcesPath.refreshLocal(IResource.DEPTH_INFINITE, null);
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

@@ -203,7 +203,10 @@ public class TalendJavaProjectManager {
if (!javaProject.isOpen()) {
javaProject.open(monitor);
}
helper.updateCodeProjectPom(monitor, type, codeProject.getFile(TalendMavenConstants.POM_FILE_NAME));
// only update code pom for main project.
if (ProjectManager.getInstance().getCurrentProject().getTechnicalLabel().equals(projectTechName)) {
helper.updateCodeProjectPom(monitor, type, codeProject.getFile(TalendMavenConstants.POM_FILE_NAME));
}
talendCodeJavaProject = new TalendProcessJavaProject(javaProject);
BuildCacheManager.getInstance().clearCodesCache(type);
talendCodeJavaProjects.put(codeProjectId, talendCodeJavaProject);

View File

@@ -209,7 +209,14 @@ public class MavenJavaProcessor extends JavaProcessor {
jobName = basePrcess.getName();
jobVersion = basePrcess.getVersion();
}
String jarName = JavaResourcesHelper.getJobJarName(jobName, jobVersion);
String jarName = null;
if (process instanceof Process) {
jarName = JavaResourcesHelper.getJobJarName(jobName, jobVersion, ((Process) process).getProperty());
}
else {
jarName = JavaResourcesHelper.getJobJarName(jobName, jobVersion);
}
String exportJar = libPrefixPath + jarName + FileExtensions.JAR_FILE_SUFFIX;
if (!isMainJob || isMainJob && !ProcessorUtilities.hasLoopDependency()) {
@@ -218,7 +225,7 @@ public class MavenJavaProcessor extends JavaProcessor {
if (jobInfo.isTestContainer()) {
continue;
}
String childJarName = JavaResourcesHelper.getJobJarName(jobInfo.getJobName(), jobInfo.getJobVersion());
String childJarName = JavaResourcesHelper.getJobJarName(jobInfo);
if (!childJarName.equals(jarName)) {
exportJar += classPathSeparator + libPrefixPath + childJarName + FileExtensions.JAR_FILE_SUFFIX;
}
@@ -227,7 +234,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.getJobName(), mainJobInfo.getJobVersion());
String mainJobName = JavaResourcesHelper.getJobJarName(mainJobInfo);
exportJar += classPathSeparator + libPrefixPath + mainJobName + FileExtensions.JAR_FILE_SUFFIX;
}
return exportJar;
@@ -389,8 +396,9 @@ public class MavenJavaProcessor extends JavaProcessor {
if (!isMainJob && isGoalInstall) {
if (!buildCacheManager.isJobBuild(getProperty())) {
deleteExistedJobJarFile(talendJavaProject);
if ("ROUTE".equalsIgnoreCase(getBuildType(getProperty())) && project != null &&
ERepositoryObjectType.PROCESS.equals(ERepositoryObjectType.getType(getProperty()))) {
String buildType = getBuildType(getProperty());
if (("ROUTE".equalsIgnoreCase(buildType) || "OSGI".equalsIgnoreCase(buildType) || "STANDALONE".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
@@ -461,7 +469,7 @@ public class MavenJavaProcessor extends JavaProcessor {
private IFile deleteExistedJobJarFile(final ITalendProcessJavaProject talendJavaProject) throws CoreException {
IFile jobJarFile;
String jobJarName = JavaResourcesHelper.getJobJarName(property.getLabel(), property.getVersion())
String jobJarName = JavaResourcesHelper.getJobJarName(property)
+ FileExtensions.JAR_FILE_SUFFIX;
jobJarFile = talendJavaProject.getTargetFolder().getFile(jobJarName);
if (jobJarFile != null && jobJarFile.exists()) {

View File

@@ -28,6 +28,7 @@ import org.talend.designer.maven.template.AbstractMavenTemplateManager;
import org.talend.designer.maven.template.MavenTemplateManager;
import org.talend.designer.runprocess.IRunProcessService;
import org.talend.designer.runprocess.RunProcessPlugin;
import org.talend.designer.runprocess.utils.JobVMArgumentsUtil;
import us.monoid.json.JSONArray;
import us.monoid.json.JSONException;
@@ -54,8 +55,9 @@ public class RunProcessPreferenceInitializer extends AbstractPreferenceInitializ
JSONObject root = new JSONObject();
try {
JSONArray args = new JSONArray();
args.put("-Xms256M");//$NON-NLS-1$
args.put("-Xmx1024M");//$NON-NLS-1$
for (String arg : JobVMArgumentsUtil.DEFAULT_JVM_ARGS) {
args.put(arg);
}
root.put("JOB_RUN_VM_ARGUMENTS", args);//$NON-NLS-1$
} catch (JSONException e) {
ExceptionHandler.process(e);

View File

@@ -16,6 +16,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.log4j.Logger;
import org.talend.commons.exception.ExceptionHandler;
import us.monoid.json.JSONArray;
@@ -27,8 +28,12 @@ import us.monoid.json.JSONObject;
*/
public class JobVMArgumentsUtil {
private static final Logger LOGGER = Logger.getLogger(JobVMArgumentsUtil.class);
private static final List<String> EMPTY_STRING_LIST = Collections.unmodifiableList(new ArrayList<String>());
public static final String[] DEFAULT_JVM_ARGS = new String[] { "-Xms256M", "-Xmx1024M" };
public List<String> readString(String stringList) {
if (stringList == null || "".equals(stringList)) { //$NON-NLS-1$
return EMPTY_STRING_LIST;
@@ -44,7 +49,10 @@ public class JobVMArgumentsUtil {
}
}
} catch (JSONException e) {
ExceptionHandler.process(e);
for (String arg : JobVMArgumentsUtil.DEFAULT_JVM_ARGS) {
result.add(arg);
}
LOGGER.debug(e.getMessage(), e);
}
return result;
}

View File

@@ -36,6 +36,7 @@ import org.talend.core.model.metadata.types.JavaTypesManager;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.runprocess.shadow.ObjectElementParameter;
import org.talend.core.model.runprocess.shadow.TextElementParameter;
import org.talend.core.utils.TalendQuoteUtils;
import org.talend.designer.rowgenerator.PluginUtils;
import org.talend.designer.rowgenerator.RowGeneratorComponent;
import org.talend.designer.rowgenerator.data.Function;
@@ -123,7 +124,7 @@ public class VirtualRowGeneratorNode extends RowGeneratorComponent {
}
} catch (NumberFormatException e1) {
for (Variable var : variables) {
expression = renameValues(expression, var.getName(), "\"" + var.getValue() + "\"");//$NON-NLS-1$ //$NON-NLS-2$
expression = renameValues(expression, var.getName(), TalendQuoteUtils.addQuotesIfNotExist(var.getValue()));
}
}
value.put(RowGeneratorComponent.ARRAY, "\"\"+(" + expression + ")+\"\""); //$NON-NLS-1$ //$NON-NLS-2$
@@ -182,6 +183,15 @@ public class VirtualRowGeneratorNode extends RowGeneratorComponent {
}
private String renameVaribleValue(String newValue, String type) {
if (newValue == null) {
return newValue;
}
if (JavaTypesManager.STRING.getLabel().equals(type)) {
return TalendQuoteUtils.addQuotesIfNotExist(newValue);
}
if (newValue.equals("null")) { //$NON-NLS-1$
return newValue;
}
if (JavaTypesManager.BIGDECIMAL.getLabel().equals(type)) {
newValue = " new " + JavaTypesManager.BIGDECIMAL.getNullableClass().getName() + "(" + newValue + ")";//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else if (JavaTypesManager.CHARACTER.getLabel().contains(type)) {

View File

@@ -3224,6 +3224,33 @@
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,6 +28,10 @@ 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

@@ -16,6 +16,7 @@ import java.beans.PropertyChangeEvent;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -87,6 +88,7 @@ import org.talend.core.model.process.INode;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
import org.talend.core.model.properties.RulesItem;
import org.talend.core.model.properties.SAPConnectionItem;
@@ -110,6 +112,7 @@ import org.talend.core.repository.model.repositoryObject.SalesforceModuleReposit
import org.talend.core.repository.utils.ProjectHelper;
import org.talend.core.repository.utils.RepositoryPathProvider;
import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.services.ICoreTisService;
import org.talend.core.services.IGITProviderService;
import org.talend.core.services.ISVNProviderService;
import org.talend.core.ui.branding.IBrandingService;
@@ -333,6 +336,28 @@ public class RepositoryService implements IRepositoryService, IRepositoryContext
logged = LoginHelper.getInstance().loginAuto();
}
if (!logged) {
if (ArrayUtils.contains(Platform.getApplicationArgs(), EclipseCommandLine.LOGIN_ONLINE_UPDATE)) {
ICoreTisService tisService = ICoreTisService.get();
if (tisService != null) {
LoginHelper loginHelper = LoginHelper.getInstance();
ConnectionBean connBean = loginHelper.getCurrentSelectedConnBean();
try {
User user = PropertiesFactory.eINSTANCE.createUser();
user.setLogin(connBean.getUser());
user.setPassword(connBean.getPassword().getBytes(StandardCharsets.UTF_8));
LoginHelper.setRepositoryContextInContext(connBean, user, null, null);
tisService.downLoadAndInstallUpdates(connBean.getUser(), connBean.getPassword(),
LoginHelper.getAdminURL(connBean));
tisService.setNeedResartAfterUpdate(true);
LoginHelper.isRestart = true;
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.LOGIN_ONLINE_UPDATE, null,
true, true);
return true;
} catch (Throwable e) {
ExceptionHandler.process(e);
}
}
}
LoginDialogV2 loginDialog = new LoginDialogV2(shell);
logged = (loginDialog.open() == LoginDialogV2.OK);
}
@@ -358,7 +383,7 @@ public class RepositoryService implements IRepositoryService, IRepositoryContext
if (ArrayUtils.contains(Platform.getApplicationArgs(), EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND)) {
boolean deleteProjectIfExist = ArrayUtils.contains(Platform.getApplicationArgs(), "--deleteProjectIfExist"); //$NON-NLS-1$
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
IBrandingService brandingService = GlobalServiceRegister.getDefault().getService(
IBrandingService.class);
brandingService.getBrandingConfiguration().setUseProductRegistration(false);
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
@@ -472,7 +497,7 @@ public class RepositoryService implements IRepositoryService, IRepositoryContext
}
if (project != null && reload && lastBean != null && repositoryFactory.getRepositoryContext().isOffline()) {
if (PluginChecker.isSVNProviderPluginLoaded()) {
ISVNProviderService svnProviderService = (ISVNProviderService) GlobalServiceRegister.getDefault()
ISVNProviderService svnProviderService = GlobalServiceRegister.getDefault()
.getService(ISVNProviderService.class);
if (svnProviderService.isSVNProject(project)) {
String projectUrl = svnProviderService.getProjectUrl(project);
@@ -791,7 +816,7 @@ public class RepositoryService implements IRepositoryService, IRepositoryContext
public String getRulesProviderPath(RulesItem currentRepositoryItem) {
IRulesProviderService rulesService = null;
if (PluginChecker.isRulesPluginLoaded()) {
rulesService = (IRulesProviderService) GlobalServiceRegister.getDefault().getService(IRulesProviderService.class);
rulesService = GlobalServiceRegister.getDefault().getService(IRulesProviderService.class);
try {
rulesService.syncRule(currentRepositoryItem);
IFile ruleFile = rulesService.getRuleFile(currentRepositoryItem, FileConstants.XLS_FILE_SUFFIX);
@@ -915,9 +940,9 @@ public class RepositoryService implements IRepositoryService, IRepositoryContext
private void initProviderService() {
if (PluginChecker.isSVNProviderPluginLoaded()) {
try {
svnProviderService = (ISVNProviderService) GlobalServiceRegister.getDefault()
svnProviderService = GlobalServiceRegister.getDefault()
.getService(ISVNProviderService.class);
gitProviderService = (IGITProviderService) GlobalServiceRegister.getDefault()
gitProviderService = GlobalServiceRegister.getDefault()
.getService(IGITProviderService.class);
} catch (RuntimeException e) {
// nothing to do
@@ -1008,7 +1033,7 @@ public class RepositoryService implements IRepositoryService, IRepositoryContext
@Override
public boolean isSVN() {
if (svnProviderService == null && PluginChecker.isSVNProviderPluginLoaded()) {
svnProviderService = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
svnProviderService = GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
}
if (svnProviderService != null) {
return svnProviderService.isProjectInSvnMode();
@@ -1019,7 +1044,7 @@ public class RepositoryService implements IRepositoryService, IRepositoryContext
@Override
public boolean isGIT() {
if (gitProviderService == null && PluginChecker.isGITProviderPluginLoaded()) {
gitProviderService = (IGITProviderService) GlobalServiceRegister.getDefault().getService(IGITProviderService.class);
gitProviderService = GlobalServiceRegister.getDefault().getService(IGITProviderService.class);
}
if (gitProviderService != null) {
return gitProviderService.isProjectInGitMode();

View File

@@ -0,0 +1,93 @@
// ============================================================================
//
// 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

@@ -0,0 +1,143 @@
// ============================================================================
//
// 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

@@ -0,0 +1,80 @@
// ============================================================================
//
// 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

@@ -658,6 +658,7 @@ public class VersionManagementPage extends AbstractVersionManagementProjectSetti
}
builder.addOrUpdateItem(item, true);
}
builder.saveRelations();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}

View File

@@ -171,7 +171,7 @@ public class LoginDialogV2 extends TrayDialog {
super.configureShell(newShell);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
IBrandingService.class);
newShell.setText(Messages.getString("LoginDialog.title", brandingService.getFullProductName())); //$NON-NLS-1$
newShell.setText(Messages.getString("LoginDialog.title", brandingService.getFullProductName()) + " R2021-11-04"); //$NON-NLS-1$
}
@Override

View File

@@ -1079,8 +1079,20 @@ public class LoginProjectPage extends AbstractLoginActionPage {
ICoreTisService.class);
afterUpdate = false;
if (tisService != null) {
tisService.downLoadAndInstallUpdates(getConnection().getUser(), getConnection().getPassword(),
loginFetchLicenseHelper.getAdminURL());
if (tisService.isDefaultLicenseAndProjectType()) {
tisService.downLoadAndInstallUpdates(getConnection().getUser(), getConnection().getPassword(),
loginFetchLicenseHelper.getAdminURL());
} else {
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.LOGIN_ONLINE_UPDATE, null,
false, true);
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.CLEAN, null, false, true);
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.TALEND_RELOAD_COMMAND,
Boolean.TRUE.toString(), false);
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
EclipseCommandLine.TALEND_PROJECT_TYPE_COMMAND, "", true);
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.ARG_TALEND_LICENCE_PATH,
"", true);
}
afterUpdate = true;
tisService.setNeedResartAfterUpdate(afterUpdate);
}

View File

@@ -38,6 +38,7 @@ import org.talend.core.model.properties.ProcessItem;
import org.talend.designer.maven.launch.MavenPomCommandLauncher;
import org.talend.designer.maven.model.MavenSystemFolders;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.utils.PomIdsHelper;
import org.talend.designer.runprocess.IProcessor;
import org.talend.repository.documentation.ExportFileResource;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager;
@@ -61,7 +62,17 @@ public class BuildOSGiBundleHandler extends BuildJobHandler {
IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
osgiMavenManager.setJobVersion(version);
osgiMavenManager.setBundleVersion(version);
osgiMavenManager.setBundleVersion(getArtifactVersion(processItem));
}
protected String getArtifactVersion(ProcessItem processItem) {
if (processItem != null) {
String v = PomIdsHelper.getJobVersion(processItem.getProperty());
if (v != null) {
return v.replace("-", ".");
}
}
return null;
}
/*

View File

@@ -26,6 +26,7 @@ import org.talend.core.runtime.repository.build.BuildExportManager;
import org.talend.core.runtime.repository.build.IBuildExportHandler;
import org.talend.core.runtime.repository.build.IBuildJobParameters;
import org.talend.core.runtime.repository.build.IBuildParametes;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.repository.constants.BuildJobConstants;
import org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType;
import org.talend.repository.ui.wizards.exportjob.handler.BuildJobHandler;
@@ -37,6 +38,8 @@ import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManag
*/
public class BuildJobFactory {
private static final String ROUTE_MICROSERVICE = "ROUTE_MICROSERVICE";
/**
* Create the build job handler according the job export type. Now only implement the handler of standalone job.
* <p>
@@ -89,27 +92,23 @@ public class BuildJobFactory {
if (StringUtils.isEmpty(buildType)) {
final Object type = processItem.getProperty().getAdditionalProperties()
.get(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
boolean esb = false;
if (processItem instanceof ProcessItem) {
if (type != null && processItem instanceof ProcessItem) {
ERepositoryObjectType repositoryObjectType = ERepositoryObjectType.getItemType(processItem);
if (repositoryObjectType == ERepositoryObjectType.PROCESS_ROUTE && "ROUTE_MICROSERVICE".equals(type)) {
esb = true;
} else if ("REST_MS".equals(type)) {
esb = true;
if (repositoryObjectType == ERepositoryObjectType.PROCESS_ROUTE) {
buildType = String.valueOf(type);
} else if (repositoryObjectType == ERepositoryObjectType.PROCESS) {
for (Object o : ((ProcessItem) processItem).getProcess().getNode()) {
if (o instanceof NodeType) {
NodeType currentNode = (NodeType) o;
if (BuildJobConstants.esbComponents.contains(currentNode.getComponentName())) {
buildType = String.valueOf(type);
break;
}
}
}
}
}
if (type != null) {
if (!esb) {
buildType = null;
} else {
buildType = type.toString();
}
} // else{ // if didn't set, should use default provider to create it.
}
Map<String, Object> parameters = new HashMap<>();

View File

@@ -929,10 +929,11 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
Set<URL> resources = libResource.getResourcesByRelativePath(path);
for (URL url : resources) {
// TESB-21804:Fail to deploy cMessagingEndpoint with quartz component in runtime for ClassCastException
if (url.getPath().matches("(.*)camel-(.*)-alldep-(.*)$")
|| url.getPath().matches("(.*)activemq-all-[\\d\\.]*.jar$")
|| url.getPath().matches("(.*)jms[\\d\\.-]*.jar$")
|| url.getPath().matches("(.*)tdm-lib-di-[\\d\\.-]*.jar$")) {
String urlStr = url.getPath().replace("\\", "/");
if (urlStr.matches("(.*)camel-(.*)-alldep-(.*)$")
|| urlStr.matches("(.*)activemq-all-[\\d\\.]*.jar$")
|| urlStr.matches("(.*)/jms[\\d\\.-]*.jar$")
|| urlStr.matches("(.*)tdm-lib-di-[\\d\\.-]*.jar$")) {
continue;
}
File dependencyFile = new File(FilesUtils.getFileRealPath(url.getPath()));

View File

@@ -42,45 +42,44 @@ 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/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
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
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.emf.common,
@@ -114,3 +113,4 @@ 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.14</component-runtime.version>
<component-runtime.version>1.1.15.2</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>1.6.0-alpha.7</version>
<version>2.3.0</version>
</dependency>
<dependency>

View File

@@ -30,6 +30,7 @@ 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;
@@ -61,6 +62,11 @@ 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,6 +22,8 @@ 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;
@@ -74,8 +76,16 @@ public class TaCoKitGenericProvider implements IGenericProvider {
details.forEach(pair -> {
ComponentIndex index = pair.getFirst();
ComponentDetail detail = pair.getSecond();
components.add(new ComponentModel(index, detail, configTypes, service.toEclipseIcon(index.getIcon()), reportPath,
isCatcherAvailable));
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));
});
}
}

View File

@@ -24,6 +24,7 @@ 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;
@@ -62,7 +63,7 @@ public class AsciidoctorService {
final RubyInstanceConfig config = new RubyInstanceConfig();
config.setLoader(Thread.currentThread().getContextClassLoader());
try {
instance = Asciidoctor.Factory.create(singletonList("uri:classloader:/gems/asciidoctor-1.5.7.1/lib"));
instance = JRubyAsciidoctor.create(singletonList("uri:classloader:/gems/asciidoctor-2.0.10/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);
private static final ImageDescriptor DEFAULT_IMAGE = ImageProvider.getImageDesc(EImage.COMPONENT_MISSING);
public static final ImageDescriptor DEFAULT_IMAGE = ImageProvider.getImageDesc(EImage.COMPONENT_MISSING);
private final Function<String, File> mvnResolver;

View File

@@ -22,9 +22,14 @@ 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;
@@ -147,6 +152,15 @@ 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<>();
@@ -238,7 +252,19 @@ 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"));
@@ -255,5 +281,4 @@ public class ExpressionTest {
assertFalse(Expression.isThereCondition("standard='aaa'", "and"));
assertFalse(Expression.isThereCondition("story='aaa'", "or"));
}
}

View File

@@ -1,8 +1,7 @@
package org.talend.designer.dbmap.language.generation;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.Collections;
@@ -26,8 +25,10 @@ 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;
@@ -36,6 +37,8 @@ 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;
@@ -792,4 +795,409 @@ public class DbGenerationManagerTest extends DbGenerationManagerTestHelper {
+ " FROM\n" + " table1\n" + " WHERE t.column2 = '\" +context.param2+ \"'\n" + " ) table2\"";
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,6 +129,87 @@ 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,9 +12,8 @@
// ============================================================================
package org.talend.designer.dbmap.language.oracle;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.Collections;
@@ -283,7 +282,7 @@ public class OracleGenerationManagerTest extends DbGenerationManagerTestHelper {
}
@Test
public void testBuildSqlSelectWithAlias() {
public void testBuildSqlSelect() {
String schema = "";
String main_table = "((String)globalMap.get(\"main_table\"))";
String main_alias = "main1";
@@ -306,14 +305,77 @@ 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 AS score\n"
+ " +context.schema+ \".\" +((String)globalMap.get(\"lookup_table\"))+ \".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.*;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
@@ -134,6 +134,49 @@ 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 ";

View File

@@ -37,7 +37,14 @@ public class JobVMArgumentsUtilTest {
vm = "";
Assert.assertTrue(jobVM.readString(vm).isEmpty());
vm = "hhh jjjj kkkk";
Assert.assertTrue(jobVM.readString(vm).isEmpty());
List<String> vmargs = jobVM.readString(vm);
Assert.assertEquals(jobVM.DEFAULT_JVM_ARGS.length, vmargs.size());
for (String vmarg : jobVM.DEFAULT_JVM_ARGS) {
Assert.assertTrue(vmargs.contains(vmarg));
}
String value = "{\"JOB_RUN_VM_ARGUMENTS\":[\"{[<,>]};:' \\\"/\\\\+\\\\t+\\\\b+\\\\f+\\\\n=\\\\r|\",\"String a = \\\\\\\\ + [array];\"]}";
List<String> list = jobVM.readString(value);
Assert.assertTrue(list.get(0).equals("{[<,>]};:' \"/\\+\\t+\\b+\\f+\\n=\\r|"));