Compare commits

...

34 Commits

Author SHA1 Message Date
oleksandr
9c3d2cfad4 TAC-15694 (#4757)
[7.2.1] TAC jobs cant be killed, and incorrect status reported

Co-authored-by: oleksandr <ovelychko@talend.com>
2021-11-03 20:41:32 +08:00
AlixMetivier
ca9868e83f fix(TBD-10269): force return in case of bad job design (#3287) (#3342) 2020-05-27 15:59:28 +02:00
kjwang
b961dc9002 Fix TUP-26288_Enhance context joblet build in param internal id change (#3331)
problem
https://jira.talendforge.org/browse/TUP-26288
2020-05-26 18:47:10 +08:00
kjwang
ff56cbc16b Fix TUP-26639 Talend Cloud studio Issue -Changes to Context Parameter (#3330)
* Fix TUP-26639 Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake

* Fix TUP-26639 Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake
2020-05-26 18:14:07 +08:00
kjwang
096be8c100 kjwang/Fix TUP-26288 Fix salesforce context var update issue (#3326)
https://jira.talendforge.org/browse/TUP-26288
2020-05-25 15:35:47 +08:00
kjwang
e5ef1fc64d Kjwang/temp 3840 (#3324)
TUP-26696 Enhance context propagation over reference project -
Propagation
https://jira.talendforge.org/browse/TUP-26696
2020-05-22 18:23:54 +08:00
AlixMetivier
f51d183a96 fix(TBD-10370):"Hadoop configuration jar not found" when run spark job (#3221) (#3323)
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
2020-05-22 10:24:19 +02:00
hcyi
7d3efda121 fix(TUP-27000):Talend Salesforce Einstein connector Repository (#3274)
connection issue in Talend 7.3
2020-05-22 12:44:04 +08:00
Chao MENG
c2ca0d161e feat(TUP-26569): merge known conflicts automatically
https://jira.talendforge.org/browse/TUP-26569
2020-05-22 11:11:56 +08:00
Jane Ding
cbd0b4035a fix(TUP-27003):Should disable the Commit button of Uncommitted files (#3273) (#3319)
found dialog when project is in MERGING state
https://jira.talendforge.org/browse/TUP-27003
2020-05-22 10:48:26 +08:00
hwang-talend
5ab96746ea Hwang/tup 26994 (#3282)
* bugfix(TUP-26994):Usage data collector : change the way Studio Unique Id
is calculated
2020-05-21 11:12:25 +08:00
zhangjie
da086ac7d1 feat(TUP-26284)Upgrade AWS SDK for driver in metadata 2020-05-21 11:08:45 +08:00
jiezhang-tlnd
52b5a1dd48 Jzhang/feat/tup 26284 upgrade aws sdk for driver in metadata (#3244)
* feat(TUP-26284)Upgrade AWS SDK for driver in metadata

* feat(TUP-26284)update other jar except aws-java-sdk
2020-05-21 11:08:25 +08:00
Jane Ding
4cec5920fc Jding/patch731/tup 26639 group context and connection issue (#3261)
* fix(TUP-26639):Talend Cloud studio Issues - Group context and (#3233) (#3243)

connections
https://jira.talendforge.org/browse/TUP-26639

* fix(TUP-26639):Talend Cloud studio Issue -Changes to Context Parameter (#3249) (#3256)

* fix(TUP-26639):Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake
https://jira.talendforge.org/browse/TUP-26639

* fix(TUP-26639):Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake
https://jira.talendforge.org/browse/TUP-26639

* fix(TUP-26639):Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake
https://jira.talendforge.org/browse/TUP-26639
2020-05-21 11:05:16 +08:00
hwang-talend
fc00adcb09 Hwang/tup 26870 (#3214)
* bugfix(TUP-26870):Incorrect sorting order
2020-05-19 14:41:16 +08:00
Zhiwei Xue
5d6e0f5bc3 fix(TUP-26961):When save/delete a test case, it might break the poms/CI (#3253) 2020-05-19 14:38:45 +08:00
hwang-talend
56f2c1a39f bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries (#3246)
* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding

* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding

* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding

* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding

* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding
2020-05-19 14:36:23 +08:00
Jane Ding
05c389a58c feat(TUP-16546)Prompt users for new password in Studio Connection when (#3119) (#3251)
* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546

* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546

* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546

* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546
2020-05-19 14:27:24 +08:00
Zhiwei Xue
2074d44db6 fix(TUP-27077): NoClassDefFoundException when using "independent process (#3286)
to run subjob" and tAzureAdlsGen2Input
2020-05-14 20:08:37 +08:00
Liu Xinquan
103829ad63 fix(TDQ-18049) add the "transform" to avoid class conflict when shaded (#3085) (#3263)
Co-authored-by: qiongli <qiongli@talend.com>
2020-05-11 09:55:03 +08:00
Liu Xinquan
25241eaf13 fix(TDQ-18322) throw NPE when retrieve the schema on Sybase (#3234) (#3248) 2020-05-08 21:12:01 +08:00
Zhiwei Xue
544535ecc7 fix(TUP-26809):Job zip should not contain jars from testcase only (#3237) 2020-04-27 17:59:28 +08:00
Zhiwei Xue
6fd415e029 Patch/7.3.1 TPS-3839 monthly patch backport (#3222)
* fix(TUP-26596)Proxy of libraries not working when studio have no (#3165) (#3172)

* fix(TUP-26596)Proxy of libraries not working when studio have no
internet access

* fix(TUP-26596)Proxy of libraries not working when studio have no
internet access

* fix(TUP-26596)Proxy of libraries not working when studio have no
internet access

* fix(TUP-26596)Proxy of libraries not working when studio have no
internet access

* fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy failure (#3101) (#3114)

* fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy failure

https://jira.talendforge.org/browse/TUP-26189

* fix(TUP-26793)JDBC Redshift in context mode still asked for jars
https://jira.talendforge.org/browse/TUP-26793

* fix(TUP-26212): Share more than one car component to nexus3.19.1 will fail to generate the right index file (#3100) (#3120)

* fix(TUP-26212): Share more than one car component to nexus3.19.1 will
fail to generate the right index file

https://jira.talendforge.org/browse/TUP-26212

* fix(TUP-26212): Share more than one car component to nexus3.19.1 will
fail to generate the right index file

https://jira.talendforge.org/browse/TUP-26212

Co-authored-by: bhe-talendbj <52311292+bhe-talendbj@users.noreply.github.com>

* fix(TUP-26539): Unassociate data from associateListeners (#3169)

* fix(TUP-26539): Fix wrong tree node implmentation

* fix(TUP-26539): add test case

* fix(TUP-26539): Remove reference to itself

* fix(TUP-26539): Return root node

* fix(TUP-26539): Update test case

* fix(TUP-26539): update test case

* fix(TUP-26539): Unassociate unnecessary listeners

* fix(TUP-26539): Revert changes of RepositoryNode

* fix(TUP-26539): Add override annotation

* fix(TUP-26876):NoClassDefFoundError when I run spark job with JobServer

Co-authored-by: hzhao-talendbj <49395568+hzhao-talendbj@users.noreply.github.com>
Co-authored-by: kjwang <kjwang@talend.com>
Co-authored-by: zhangjie <jie.zhang@talend.com>
Co-authored-by: Chao MENG <cmeng@talend.com>
Co-authored-by: bhe-talendbj <52311292+bhe-talendbj@users.noreply.github.com>
2020-04-17 14:44:26 +08:00
Liu Xinquan
93f0c89ae0 fix(TDQ-18135) support context variable in tDataEncrypt (#3180) (#3207) 2020-04-15 15:55:10 +08:00
Zhiwei Xue
89dd33e3b7 fix(TUP-26728):fix regression on preview function. 2020-04-09 11:25:39 +08:00
Zhiwei Xue
4f411af729 fix(TUP-26728):Missing spark dependencies when using test cases 2020-04-08 23:34:13 +08:00
Zhiwei Xue
f8b1e6ae34 fix(TUP-26728):The parent DI job misses to load some required libraries
from the Spark job
2020-04-07 17:46:45 +08:00
Jane Ding
4931b8835e fix(TUP-26576):Warning pops up cannot connect to the user libraries (#3154) (#3164)
artifact repository set in administrator
https://jira.talendforge.org/browse/TUP-26576
2020-03-26 11:04:55 +08:00
Zhiwei Xue
b067d61afd fix(TUP-26165):fix jar with classifier missing issue (#3152)
* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP (#3105)

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165):fix jar with classifier missing issue

Co-authored-by: Jane Ding <35018295+jding-tlnd@users.noreply.github.com>
2020-03-20 21:01:31 +08:00
Pierre Teyssier
8b19375bc0 chore(TDI-43696): cherry-pick on release (#3092) 2020-02-18 08:40:02 +08:00
Zhiwei Xue
7b8cd7b14f fix(TUP-26170):fix subjob dependencies missing in classpath problem of (#3090)
CI.
2020-02-17 21:38:12 +08:00
msjian
8f8e0261d5 fix(TDQ-17983 TDQ-17393): fix snowflake OutOfMemoryError (#3080) (#3089) 2020-02-17 08:31:57 +00:00
Jenkins Continuous Build server
68db523503 Set version to 7.3.1 2020-02-14 13:38:41 +01:00
Jenkins Continuous Build server
2901e5e77e Set runtime version to 7.3.1 2020-02-14 08:23:56 +01:00
267 changed files with 4804 additions and 2118 deletions

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.common.ui.runtime.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.commons.runtime.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.commons.ui.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core.repository.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core.runtime.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core.ui.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.cwm.mip.edit.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.cwm.mip.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.designer.maven.ui.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.help.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.helpers.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.librariesmanager.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.librariesmanager.ui.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.metadata.managment.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.metadata.managment.ui.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.migrationTool.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.model.edit.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.model.migration.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.model.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.presentation.onboarding.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.rcp.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.registration.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.repository.items.importexport.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.repository.items.importexport.ui.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.repository.localprovider.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.repository.mdm.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.repository.metadata.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.repository.view.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.resources.nl</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.commons.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.fragment.jars.common.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.help.di.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.help.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.jdt.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.libraries.jdbc.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.m2e.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.model.migration.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.rcp.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.update.p2.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.updates.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.utils.feature</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.common.ui.runtime</artifactId>

View File

@@ -21,6 +21,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
@@ -38,6 +39,8 @@ public class ExceptionMessageDialog extends MessageDialog {
private String exceptionString = null;
private int[] diabledButtonIndex = new int[] {};
public ExceptionMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
int dialogImageType, String[] dialogButtonLabels, int defaultIndex, Throwable ex) {
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
@@ -147,4 +150,21 @@ public class ExceptionMessageDialog extends MessageDialog {
this.exceptionString = exceptionString;
}
public void setDisabledButtons(int[] index) {
this.diabledButtonIndex = index;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
if (diabledButtonIndex == null) {
return;
}
for (int index : diabledButtonIndex) {
Button button = super.getButton(index);
button.setEnabled(false);
}
}
}

View File

@@ -13,7 +13,8 @@ Require-Bundle: org.apache.log4j;visibility:=reexport,
org.talend.libraries.apache,
com.ibm.icu,
org.apache.commons.io,
org.talend.utils
org.talend.utils,
org.eclipse.core.net
Export-Package: org.talend.commons,
org.talend.commons.exception,
org.talend.commons.i18n,

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.commons.runtime</artifactId>

View File

@@ -12,7 +12,7 @@
<parent>
<groupId>org.talend</groupId>
<artifactId>org.talend.tos</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../pom_server.xml</relativePath>
</parent>

View File

@@ -17,6 +17,7 @@ import java.io.InputStream;
import java.net.URL;
import org.apache.commons.lang.ArrayUtils;
import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -24,6 +25,7 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.talend.commons.exception.ExceptionService;
import org.talend.commons.runtime.debug.TalendDebugHandler;
import org.talend.commons.utils.system.EclipseCommandLine;
@@ -55,6 +57,8 @@ public class CommonsPlugin implements BundleActivator {
// TESB-17856: For commandline builds ESB Micorservice bundle
private static boolean isESBMicorservice = false;
private static ServiceTracker proxyTracker;
public static boolean isWorkbenchCreated() {
return isWorkbenchCreated;
}
@@ -179,4 +183,13 @@ public class CommonsPlugin implements BundleActivator {
return FileLocator.toFileURL(entry);
}
public static IProxyService getProxyService() {
if (proxyTracker == null) {
proxyTracker = new ServiceTracker(Platform.getBundle(PLUGIN_ID).getBundleContext(), IProxyService.class.getName(),
null);
proxyTracker.open();
}
return (IProxyService) proxyTracker.getService();
}
}

View File

@@ -0,0 +1,58 @@
// ============================================================================
//
// 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.commons.exception;
public class ClientException extends PersistenceException {
private Integer httpCode;
public ClientException(String message) {
super(message);
}
public ClientException(Integer httpCode, String message) {
super(message);
this.httpCode = httpCode;
}
public ClientException(String message, Throwable cause) {
super(message, cause);
}
public ClientException(Integer httpCode, String message, Throwable cause) {
super(message, cause);
this.httpCode = httpCode;
}
public ClientException(Throwable cause) {
super(cause);
}
public ClientException(Integer httpCode, Throwable cause) {
super(cause);
this.httpCode = httpCode;
}
public Integer getHttpCode() {
return httpCode;
}
public void setHttpCode(Integer httpCode) {
this.httpCode = httpCode;
}
@Override
public String toString() {
return getLocalizedMessage();
}
}

View File

@@ -42,6 +42,8 @@ public interface ITaCoKitService {
boolean isNeedMigration(String componentName, Map<String, String> properties);
boolean isTaCoKitType(Object repoType);
public static ITaCoKitService getInstance() throws Exception {
BundleContext bc = FrameworkUtil.getBundle(ITaCoKitService.class).getBundleContext();
Collection<ServiceReference<ITaCoKitService>> tacokitServices = Collections.emptyList();

View File

@@ -13,6 +13,8 @@
package org.talend.commons.utils.network;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
@@ -35,8 +37,14 @@ import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Priority;
import org.eclipse.core.internal.net.ProxyManager;
import org.eclipse.core.net.proxy.IProxyService;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.i18n.internal.Messages;
import org.talend.daikon.sandbox.properties.ClassLoaderIsolatedSystemProperties;
import sun.net.spi.DefaultProxySelector;
/**
* DOC cmeng class global comment. Detailled comment
@@ -51,9 +59,23 @@ public class TalendProxySelector extends ProxySelector {
private static final String PROP_ALLOW_PROXY_REDIRECT_EXCLUDE = "talend.studio.proxy.redirect.whiteList";
private static final String PROP_EXECUTE_CONNECTION_FAILED = "talend.studio.proxy.executeConnectionFailed";
private static final String PROP_UPDATE_SYSTEM_PROPERTIES_FOR_JRE = "talend.studio.proxy.jre.updateSystemProperties";
private static final String PROP_CHECK_PROXY = "talend.studio.proxy.checkProxy";
private static final String PROP_VALIDATE_URI = "talend.studio.proxy.validateUri";
private static final String PROP_PROXY_SELECTOR = "talend.studio.proxy.selector";
private static final String PROP_PROXY_SELECTOR_DEFAULT = "default";
private static final String PROP_PROXY_SELECTOR_JRE = "jre";
private static final String PROP_PROXY_HOST_MAP = "talend.studio.proxy.hostMap";
private static final String PROP_DISABLE_DEFAULT_SELECTOR = "talend.studio.proxy.disableDefaultSelector";
private static final String PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER = "talend.studio.proxy.disableDefaultSelectorProvider";
/**
* Example: update.talend.com,socket:http,https:http;nexus.talend.com,socket,http;,socket:http
@@ -67,7 +89,20 @@ public class TalendProxySelector extends ProxySelector {
private static final String KEY_DEFAULT = ":default:";
private ProxySelector defaultSelector;
private static Field uriHostField;
private static Method proxyManagerUpdateSystemPropertiesFunc;
private static boolean checkProxy = Boolean.valueOf(System.getProperty(PROP_CHECK_PROXY, Boolean.TRUE.toString()));
/**
* Note: eclipse default selector may be different between TOS and TIS, TOS may use jre one, TIS may use egit one
*/
private ProxySelector eclipseDefaultSelector;
private ProxySelector jreDefaultSelector;
private EProxySelector eProxySelector;
final private Map<Object, Collection<IProxySelectorProvider>> selectorProviders;
@@ -83,15 +118,36 @@ public class TalendProxySelector extends ProxySelector {
private boolean allowProxyRedirect = false;
private boolean disableDefaultSelector = false;
private boolean disableDefaultSelectorProvider = false;
private TalendProxySelector(final ProxySelector defaultSelector) {
this.defaultSelector = defaultSelector;
private boolean validateUri = true;
private boolean executeConnectionFailed = true;
private boolean updateSystemPropertiesForJre = true;
private TalendProxySelector(final ProxySelector eclipseDefaultSelector) {
this.eclipseDefaultSelector = eclipseDefaultSelector;
this.jreDefaultSelector = new DefaultProxySelector();
selectorProviders = Collections.synchronizedMap(new HashMap<>());
allowProxyRedirect = Boolean.valueOf(System.getProperty(PROP_ALLOW_PROXY_REDIRECT, Boolean.FALSE.toString()));
disableDefaultSelector = Boolean.valueOf(System.getProperty(PROP_DISABLE_DEFAULT_SELECTOR, Boolean.FALSE.toString()));
disableDefaultSelectorProvider = Boolean
.valueOf(System.getProperty(PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER, Boolean.FALSE.toString()));
printProxyLog = Boolean.valueOf(System.getProperty(PROP_PRINT_LOGS, Boolean.FALSE.toString()));
validateUri = Boolean.valueOf(System.getProperty(PROP_VALIDATE_URI, Boolean.TRUE.toString()));
executeConnectionFailed = Boolean.valueOf(System.getProperty(PROP_EXECUTE_CONNECTION_FAILED, Boolean.TRUE.toString()));
updateSystemPropertiesForJre = Boolean
.valueOf(System.getProperty(PROP_UPDATE_SYSTEM_PROPERTIES_FOR_JRE, Boolean.TRUE.toString()));
switch (System.getProperty(PROP_PROXY_SELECTOR, PROP_PROXY_SELECTOR_DEFAULT).toLowerCase()) {
case PROP_PROXY_SELECTOR_JRE:
this.eProxySelector = EProxySelector.jre;
break;
default:
this.eProxySelector = EProxySelector.eclipse_default;
break;
}
initHostMap();
initRedirectList();
@@ -176,6 +232,18 @@ public class TalendProxySelector extends ProxySelector {
synchronized (instanceLock) {
if (instance == null) {
instance = new TalendProxySelector(proxySelector);
try {
uriHostField = URI.class.getDeclaredField("host");
uriHostField.setAccessible(true);
} catch (Exception e) {
ExceptionHandler.process(e);
}
try {
proxyManagerUpdateSystemPropertiesFunc = ProxyManager.class.getDeclaredMethod("updateSystemProperties");
proxyManagerUpdateSystemPropertiesFunc.setAccessible(true);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
@@ -188,34 +256,72 @@ public class TalendProxySelector extends ProxySelector {
return null;
}
});
if (instance.getDefaultProxySelector() == null
if (instance.getEclipseDefaultSelector() == null
|| (proxySelector != null && proxySelector.getClass().getName().endsWith(ECLIPSE_PROXY_SELECTOR))) {
instance.setDefaultProxySelector(proxySelector);
instance.setEclipseDefaultSelector(proxySelector);
}
}
return instance;
}
public static void checkProxy() {
if (!checkProxy) {
return;
}
try {
TalendProxySelector.getInstance();
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
@Override
public List<Proxy> select(final URI uri) {
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.select " + uri);
}
if (uri == null) {
return Collections.EMPTY_LIST;
}
URI validatedUri = validateUri(uri);
Set<Proxy> results = new LinkedHashSet<>();
try {
final Set<Proxy> resultFromProviders = getProxysFromProviders(uri);
final Set<Proxy> resultFromProviders = getProxysFromProviders(validatedUri);
if (resultFromProviders != null && !resultFromProviders.isEmpty()) {
results.addAll(resultFromProviders);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.resultFromProviders " + results);
}
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.defaultProxySelector " + defaultProxySelector);
}
if (defaultProxySelector != null) {
URI newUri = getNewUri(uri);
List<Proxy> defaultProxys = defaultProxySelector.select(newUri);
/**
* don't validate uri here, so that we can know whether it is an issue uri
*/
URI newUri = getNewUri(validatedUri, false);
List<Proxy> defaultProxys = null;
if (validateUri && StringUtils.isBlank(newUri.getHost())) {
/**
* If host is blank, force to use jre proxy selector to avoid the eclipse proxy selector bug
*/
defaultProxys = getJreProxySelector().select(newUri);
} else {
defaultProxys = defaultProxySelector.select(newUri);
}
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.defaultProxys " + defaultProxys);
}
try {
results.addAll(filterProxys(uri, defaultProxys));
results.addAll(filterProxys(validatedUri, defaultProxys));
} catch (Exception e) {
results.addAll(defaultProxys);
ExceptionHandler.process(e);
@@ -229,6 +335,54 @@ public class TalendProxySelector extends ProxySelector {
return new LinkedList<Proxy>(results);
}
private URI validateUri(URI uri) {
if (!validateUri) {
return uri;
}
URI validatedUri = null;
try {
/**
* DON'T use URI.create(), MUST use the conductor which requires authority
*/
validatedUri = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment());
/**
* Validate the host, if the host is empty, it will cause the eclipse selector to return dirrect
*/
if (StringUtils.isBlank(validatedUri.getHost())) {
String authority = validatedUri.getAuthority();
if (StringUtils.isNotBlank(authority)) {
// example: https://u:p@www.company.com:8081/path/a?param=b
String host = null;
int userInfoIndex = authority.indexOf('@');
if (0 <= userInfoIndex) {
authority = authority.substring(userInfoIndex + 1);
}
int portIndex = authority.lastIndexOf(':');
if (0 <= portIndex) {
host = authority.substring(0, portIndex);
}
try {
uriHostField.set(validatedUri, host);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
if (validatedUri == null) {
validatedUri = uri;
}
}
if (printProxyLog) {
ExceptionHandler.log("After validate: " + uri + " -> " + validatedUri);
}
return validatedUri;
}
private List<Proxy> filterProxys(final URI uri, List<Proxy> defaultProxys) {
List<Proxy> result = new ArrayList<>();
if (defaultProxys != null && !defaultProxys.isEmpty()) {
@@ -264,38 +418,48 @@ public class TalendProxySelector extends ProxySelector {
return result;
}
private URI getNewUri(URI uri) {
private URI getNewUri(URI uri, boolean validateUri) {
URI newUri = uri;
if (newUri != null) {
String host = newUri.getHost();
Map<String, String> protocolMap = null;
if (StringUtils.isNotBlank(host)) {
protocolMap = hostMap.get(host.toLowerCase());
}
if (protocolMap == null) {
protocolMap = hostMap.get(KEY_DEFAULT);
}
try {
// get host before new URI, because the host may be set manually due to URI issue
String host = newUri.getHost();
newUri = new URI(newUri.getScheme(), newUri.getAuthority(), newUri.getPath(), newUri.getQuery(),
newUri.getFragment());
Map<String, String> protocolMap = null;
if (StringUtils.isNotBlank(host)) {
protocolMap = hostMap.get(host.toLowerCase());
}
if (protocolMap == null) {
protocolMap = hostMap.get(KEY_DEFAULT);
}
if (protocolMap != null) {
String schema = newUri.getScheme();
if (schema != null) {
String lowercasedProtocol = schema.toLowerCase();
String preferedProtocol = protocolMap.get(lowercasedProtocol);
if (StringUtils.isNotBlank(preferedProtocol)) {
try {
newUri = new URI(preferedProtocol, newUri.getUserInfo(), newUri.getHost(), newUri.getPort(),
newUri.getPath(), newUri.getQuery(), newUri.getFragment());
} catch (URISyntaxException e) {
if (printProxyLog) {
ExceptionHandler.process(new Exception(
Messages.getString("TalendProxySelector.exception.proxySelectionError", newUri), e),
Priority.WARN);
}
if (protocolMap != null) {
String schema = newUri.getScheme();
if (schema != null) {
String lowercasedProtocol = schema.toLowerCase();
String preferedProtocol = protocolMap.get(lowercasedProtocol);
if (StringUtils.isNotBlank(preferedProtocol)) {
/**
* Note: MUST use the constructor which requires authority, because some uri may be illegal,
* then host info will be stored in authority field instead of host filed
*/
newUri = new URI(preferedProtocol, newUri.getAuthority(), newUri.getPath(), newUri.getQuery(),
newUri.getFragment());
}
}
}
} catch (URISyntaxException e) {
if (printProxyLog) {
ExceptionHandler.process(
new Exception(Messages.getString("TalendProxySelector.exception.proxySelectionError", uri), e),
Priority.WARN);
}
}
}
if (validateUri) {
newUri = validateUri(newUri);
}
return newUri;
}
@@ -395,11 +559,45 @@ public class TalendProxySelector extends ProxySelector {
}
public ProxySelector getDefaultProxySelector() {
return defaultSelector;
switch (eProxySelector) {
case jre:
return getJreProxySelector();
default:
return eclipseDefaultSelector;
}
}
public void setDefaultProxySelector(final ProxySelector selector) {
defaultSelector = selector;
private ProxySelector getJreProxySelector() {
try {
/**
* for tcompv0, daikon may create an isolated system properties for it, so proxies may be ignored in the new
* system properties; here we try to call the method to add proxies into the isolated system properties
*/
if (updateSystemPropertiesForJre && ClassLoaderIsolatedSystemProperties.getInstance()
.isIsolated(Thread.currentThread().getContextClassLoader())) {
if (printProxyLog) {
ExceptionHandler.log("Before update jre proxy system properties for the isolated classloader, http.proxyHost="
+ System.getProperty("http.proxyHost"));
}
IProxyService proxyService = CommonsPlugin.getProxyService();
proxyManagerUpdateSystemPropertiesFunc.invoke(proxyService);
if (printProxyLog) {
ExceptionHandler.log("After updated jre proxy system properties for the isolated classloader, http.proxyHost="
+ System.getProperty("http.proxyHost"));
}
}
} catch (Throwable e) {
ExceptionHandler.process(e);
}
return this.jreDefaultSelector;
}
public ProxySelector getEclipseDefaultSelector() {
return eclipseDefaultSelector;
}
public void setEclipseDefaultSelector(ProxySelector eclipseDefaultSelector) {
this.eclipseDefaultSelector = eclipseDefaultSelector;
}
@Override
@@ -413,21 +611,26 @@ public class TalendProxySelector extends ProxySelector {
});
}
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (defaultProxySelector != null) {
defaultProxySelector.connectFailed(uri, sa, ioe);
if (executeConnectionFailed) {
/**
* Just try to make the behavior of jre proxy selector same like eclipse proxy selector
*/
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (defaultProxySelector != null) {
defaultProxySelector.connectFailed(uri, sa, ioe);
}
}
}
public IProxySelectorProvider createDefaultProxySelectorProvider() {
if (disableDefaultSelector) {
if (disableDefaultSelectorProvider) {
return null;
}
return new DefaultProxySelectorProvider(Thread.currentThread());
}
public IProxySelectorProvider createDefaultProxySelectorProvider(String host) {
if (disableDefaultSelector) {
if (disableDefaultSelectorProvider) {
return null;
}
return new DefaultProxySelectorProvider(host);
@@ -445,6 +648,11 @@ public class TalendProxySelector extends ProxySelector {
return possibleKeys;
}
private enum EProxySelector {
eclipse_default,
jre
}
private class DefaultProxySelectorProvider extends AbstractProxySelectorProvider {
private Thread currentThread = null;
@@ -475,7 +683,7 @@ public class TalendProxySelector extends ProxySelector {
@Override
public boolean canHandle(URI uri) {
if (disableDefaultSelector) {
if (disableDefaultSelectorProvider) {
return false;
}
if (currentThread != null && Thread.currentThread() == currentThread) {

View File

@@ -215,8 +215,12 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
lockerValue.getLock().lockInterruptibly();
traceStackForDebugging(lockerValue);
}
@@ -239,8 +243,12 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = this.prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
boolean locked = lockerValue.getLock().tryLock();
if (locked) {
traceStackForDebugging(lockerValue);
@@ -283,8 +291,12 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = this.prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
interruptIfStopping();
boolean locked = lockerValue.getLock().tryLock(timeout, unit);
if (locked) {
@@ -322,13 +334,17 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = getLockerValue(key);
boolean returnValue = false;
if (lockerValue != null) {
lockerValue.getLock().unlock();
returnValue = true;
LockerValue<KP> lockerValue = this.getLockerValue(key);
boolean returnValue;
try {
returnValue = false;
if (lockerValue != null) {
lockerValue.getLock().unlock();
returnValue = true;
}
} finally {
this.decrementRunningOperations();
}
decrementRunningOperations();
cleanAccordingOperations();
return returnValue;
}

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.commons.ui</artifactId>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core.repository</artifactId>

View File

@@ -70,6 +70,7 @@ import org.talend.commons.runtime.service.ITaCoKitService;
import org.talend.commons.ui.gmf.util.DisplayUtils;
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
import org.talend.commons.utils.data.container.RootContainer;
import org.talend.commons.utils.network.TalendProxySelector;
import org.talend.commons.utils.time.TimeMeasure;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.AbstractDQModelService;
@@ -872,6 +873,9 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
}
this.repositoryFactoryFromProvider.deleteObjectPhysical(project, object, version, fromEmptyRecycleBin);
if (isFullLogonFinished()) {
fireRepositoryPropertyChange(ERepositoryActionName.AFTER_DELETE.getName(), null, object);
}
// i18n
// log.info("Physical deletion [" + objToDelete + "] by " + getRepositoryContext().getUser() + ".");
String str[] = new String[] { object.toString(), getRepositoryContext().getUser().toString() };
@@ -2034,6 +2038,11 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
TimeMeasure.begin("logOnProject"); //$NON-NLS-1$
try {
/**
* init/check proxy selector, in case default proxy selector is not registed yet
*/
TalendProxySelector.checkProxy();
System.getProperties().put("ReadOnlyUser", Boolean.FALSE.toString()); //$NON-NLS-1$
// remove the auto-build to enhance the build speed and application's use
@@ -2409,9 +2418,14 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
@Override
@SuppressWarnings("unchecked")
public void executeRepositoryWorkUnit(RepositoryWorkUnit workUnit) {
checkProxySettings();
this.repositoryFactoryFromProvider.executeRepositoryWorkUnit(workUnit);
}
private void checkProxySettings() {
TalendProxySelector.checkProxy();
}
@Override
public void unloadResources(Property property) throws PersistenceException {
repositoryFactoryFromProvider.unloadResources(property);

View File

@@ -12,10 +12,14 @@
// ============================================================================
package org.talend.core.repository.model.dnd;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.components.IComponent;
import org.talend.core.model.components.IComponentsService;
import org.talend.core.model.properties.ConnectionItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.SalesforceSchemaConnectionItem;
import org.talend.core.model.repository.ERepositoryObjectType;
@@ -28,6 +32,8 @@ import org.talend.repository.model.RepositoryNode;
*/
public class SalesforceComponentDndFilter extends DefaultRepositoryComponentDndFilter {
public static final String SALSEFORCE = "salesforce"; //$NON-NLS-1$
public static final String COMPONENT_T_SALSEFORCE_CONNECTION = "tSalesforceConnection"; //$NON-NLS-1$
public static final String COMPONENT_T_SALSEFORCE_WAVE_BULK_EXEC = "tSalesforceWaveBulkExec"; //$NON-NLS-1$
@@ -98,7 +104,16 @@ public class SalesforceComponentDndFilter extends DefaultRepositoryComponentDndF
}
}
}
}
if (item instanceof ConnectionItem && SALSEFORCE.equalsIgnoreCase(((ConnectionItem) item).getTypeName())) {
// Special for Javajet components: tSalesforceEinsteinBulkExec/tSalesforceEinsteinOutputBulkExec
IComponentsService service = GlobalServiceRegister.getDefault().getService(IComponentsService.class);
Collection<IComponent> componentAll = service.getComponentsFactory().readComponents();
for (IComponent component : componentAll) {
if (component.getName().startsWith("tSalesforceEinstein") && !components.contains(component)) { //$NON-NLS-1$
components.add(component);
}
}
}
return components;
}

View File

@@ -13,6 +13,8 @@
package org.talend.core.repository.ui.dialog;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -30,12 +32,14 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.GlobalServiceRegister;
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.IRepositoryObject;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.repository.utils.RepositoryNodeSortUtil;
import org.talend.core.ui.ITestContainerProviderService;
import org.talend.repository.model.RepositoryNode;
import org.talend.repository.model.IRepositoryNode.EProperties;
@@ -107,7 +111,8 @@ public class PastSelectorDialog extends Dialog {
modificationTime.setWidth(200);
modificationTime.setText("Modification Time");
for (IRepositoryViewObject object : versions) {
RepositoryNodeSortUtil util = new RepositoryNodeSortUtil();
for (IRepositoryViewObject object : util.getSortVersion(versions)) {
TableItem item = new TableItem(table, SWT.NONE);
item.setData(object);
item.setText(0, object.getVersion());
@@ -187,7 +192,7 @@ public class PastSelectorDialog extends Dialog {
});
return composite;
}
public Set<IRepositoryViewObject> getSelectedVersionItems() {
return this.selectedVersionItems;
}

View File

@@ -0,0 +1,47 @@
// ============================================================================
//
// 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.core.repository.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.talend.commons.utils.Version;
import org.talend.core.model.repository.IRepositoryViewObject;
/**
* @author hwang
*
*/
public class RepositoryNodeSortUtil {
public List<IRepositoryViewObject> getSortVersion(List<IRepositoryViewObject> versions) {
List<IRepositoryViewObject> temp = new ArrayList<IRepositoryViewObject>();
temp.addAll(versions);
Collections.sort(temp, new Comparator<IRepositoryViewObject>() {
@Override
public int compare(IRepositoryViewObject o1, IRepositoryViewObject o2) {
String version1 = o1.getVersion();
String version2 = o2.getVersion();
if(version1 != null && version2 != null) {
return new Version(version1).compareTo(new Version(version2));
}
return 0;
}
});
return temp;
}
}

View File

@@ -28,6 +28,7 @@ Export-Package: org.talend.commons.utils.generation,
org.talend.core.model.business,
org.talend.core.model.components,
org.talend.core.model.context,
org.talend.core.model.context.link,
org.talend.core.model.general,
org.talend.core.model.genhtml,
org.talend.core.model.metadata,

View File

@@ -19,6 +19,7 @@
<extension-point id="hadoopConnectionCreator" name="Hadoop Connection Creator" schema="schema/hadoopConnectionCreator.exsd"/>
<extension-point id="artifact_handler" name="Artifact Repository Handler" schema="schema/artifact_handler.exsd"/>
<extension-point id="actionFilterDelegate" name="Action Filter delegate" schema="schema/actionFilterDelegate.exsd"/>
<extension-point id="saveItemContextLinkService" name="Save Item Context Link Service" schema="schema/saveItemContextLinkService.exsd"/>
<extension
point="org.talend.core.runtime.repositoryComponent_provider">
@@ -53,4 +54,16 @@
name="Talend">
</category>
</extension>
<extension
point="org.talend.core.runtime.service">
<Service
class="org.talend.core.model.update.RepositoryContextUpdateService"
serviceId="IRepositoryContextUpdateService">
</Service>
<Service
class="org.talend.core.model.update.GenericDbContextUpdateService"
serviceId="IRepositoryContextUpdateService">
</Service>
</extension>
</plugin>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core.runtime</artifactId>

View File

@@ -0,0 +1,105 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.talend.core.runtime" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.talend.core.runtime" id="saveItemContextLinkService" name="Save Item Context Link Service"/>
</appinfo>
<documentation>
Save the context link data for item which contain ContextType object
The extension point must implements interface : org.talend.core.model.context.link.IItemContextLinkService
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="creator" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="creator">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.talend.core.model.context.link.IItemContextLinkService"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
7.4.1
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
boolean accept(Item item);
boolean saveItemLink(Item item);
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View File

@@ -254,6 +254,34 @@ public final class ResourceUtils {
}
}
/**
* Comment method "setFileContent".
*
* @param stream
* @param file
* @throws PersistenceException
*/
public static void setFileContent(InputStream stream, IFile file) throws PersistenceException {
try {
if (stream == null) {
String msg = Messages.getString("resources.file.notCreated", file.getName(), //$NON-NLS-1$
Messages.getString("ResourceUtils.streamNull")); //$NON-NLS-1$
throw new PersistenceException(msg);
}
file.setContents(stream, true, false, null);
} catch (CoreException e) {
String msg = Messages.getString("resources.file.notCreated", file.getName(), e.getMessage()); //$NON-NLS-1$
throw new PersistenceException(msg, e);
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {
CommonExceptionHandler.process(e);
}
}
}
/**
* Convenience method to delete a file.<br/>
*

View File

@@ -12,35 +12,49 @@
// ============================================================================
package org.talend.core;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.runtime.services.IGenericDBService;
/**
* created by ldong on Mar 23, 2015 Detailled comment
*
*/
public class AbstractRepositoryContextUpdateService implements IRepositoryContextUpdateService {
@Override
public void updateRelatedContextVariable(Connection con, String oldValue, String newValue) {
}
public abstract class AbstractRepositoryContextUpdateService implements IRepositoryContextUpdateService {
protected IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
protected String updateHadoopProperties(List<Map<String, Object>> hadoopProperties, String oldValue, String newValue) {
String finalProperties = "";
String finalProperties = null;
boolean isModified = false;
if (!hadoopProperties.isEmpty()) {
for (Map<String, Object> propertyMap : hadoopProperties) {
String propertyValue = (String) propertyMap.get("VALUE");
if (propertyValue.equals(oldValue)) {
propertyMap.put("VALUE", newValue);
isModified = true;
}
}
finalProperties = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopProperties);
if (isModified) {
finalProperties = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopProperties);
}
}
return finalProperties;
}
protected boolean updateCompPropertiesContextParameter(Connection conn, String oldValue, String newValue) {
boolean isModified = false;
Map<String, String> oldToNewHM = new HashMap<String, String>();
oldToNewHM.put(oldValue, newValue);
String compProperties = conn.getCompProperties();
if (service != null && StringUtils.isNotBlank(compProperties)) {
service.updateCompPropertiesForContextMode(conn, oldToNewHM);
isModified = true;
}
return isModified;
}
}

View File

@@ -12,7 +12,9 @@
// ============================================================================
package org.talend.core;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
@@ -247,4 +249,29 @@ public class GlobalServiceRegister {
}
return null;
}
public List findAllService(Class klass) {
List serviceList = new ArrayList();
String key = klass.getName();
IConfigurationElement[] configElements = getConfigurationElements();
if (configElements != null) {
for (IConfigurationElement element : configElements) {
if (element.isValid()) {
String id = element.getAttribute("serviceId"); //$NON-NLS-1$
if (!key.endsWith(id)) {
continue;
}
try {
Object service = element.createExecutableExtension("class"); //$NON-NLS-1$
if (klass.isInstance(service)) {
serviceList.add(service);
};
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
}
}
return serviceList;
}
}

View File

@@ -20,5 +20,7 @@ import org.talend.core.model.metadata.builder.connection.Connection;
*/
public interface IRepositoryContextUpdateService extends IService {
public void updateRelatedContextVariable(Connection con, String oldValue, String newValue);
public boolean accept(Connection connection);
public boolean updateContextParameter(Connection conn, String oldValue, String newValue);
}

View File

@@ -166,9 +166,9 @@ public enum EDatabaseVersion4Drivers {
REDSHIFT(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT, "redshift", "REDSHIFT", //$NON-NLS-1$ //$NON-NLS-2$
"redshift-jdbc42-no-awssdk-1.2.37.1061.jar")), //$NON-NLS-1$
REDSHIFT_SSO(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT_SSO, "redshift sso", "REDSHIFT_SSO", //$NON-NLS-1$ //$NON-NLS-2$
new String[] { "redshift-jdbc42-no-awssdk-1.2.37.1061.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.9.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"jackson-databind-2.9.9.jar", "jackson-annotations-2.9.0.jar", "httpcore-4.4.9.jar", "httpclient-4.5.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
"joda-time-2.8.1.jar", "commons-logging-1.1.3.jar", "commons-codec-1.6.jar" })), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new String[] { "redshift-jdbc42-no-awssdk-1.2.37.1061.jar", "aws-java-sdk-1.11.729.jar", "jackson-core-2.10.1.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"jackson-databind-2.10.1.jar", "jackson-annotations-2.10.1.jar", "httpcore-4.4.11.jar", "httpclient-4.5.9.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
"joda-time-2.8.1.jar", "commons-logging-1.2.jar", "commons-codec-1.11.jar" })), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
AMAZON_AURORA(new DbVersion4Drivers(EDatabaseTypeName.AMAZON_AURORA, "mysql-connector-java-5.1.30-bin.jar")); //$NON-NLS-1$

View File

@@ -21,8 +21,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.EList;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
import org.talend.commons.exception.ExceptionHandler;
@@ -30,6 +33,9 @@ import org.talend.commons.exception.PersistenceException;
import org.talend.commons.utils.platform.PluginChecker;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.language.LanguageManager;
import org.talend.core.model.context.link.ContextLinkService;
import org.talend.core.model.context.link.ContextParamLink;
import org.talend.core.model.context.link.ItemContextLink;
import org.talend.core.model.metadata.MetadataTalendType;
import org.talend.core.model.metadata.MetadataToolHelper;
import org.talend.core.model.metadata.types.ContextParameterJavaTypeManager;
@@ -43,6 +49,7 @@ import org.talend.core.model.properties.JobletProcessItem;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.cwm.helper.ResourceHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
@@ -53,6 +60,8 @@ import org.talend.repository.model.IProxyRepositoryFactory;
*/
public class ContextUtils {
private static final Logger LOGGER = Logger.getLogger(ContextUtils.class);
private static final Set<String> JAVA_KEYWORDS = new HashSet<String>(Arrays.asList("abstract", "continue", "for", "new", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"switch", "assert", "default", "goto", "package", "synchronized", "boolean", "do", "if", "private", "this", "break", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
"double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
@@ -82,15 +91,25 @@ public class ContextUtils {
* update the JobContextParameter form repository ContextItem by context name.
*
*/
public static boolean updateParameterFromRepository(ContextItem sourceItem, IContextParameter contextParam, String contextName) {
public static boolean updateParameterFromRepository(Item sourceItem, IContextParameter contextParam, String contextName) {
return updateParameterFromRepository(sourceItem, contextParam, contextName, null);
}
public static boolean updateParameterFromRepository(Item sourceItem, IContextParameter contextParam, String contextName,
Map<String, String> renameMap) {
if (sourceItem == null || contextParam == null) {
return false;
}
// not found, use default.
ContextType contextType = getContextTypeByName(sourceItem, contextName, true);
ContextType contextType = getContextTypeByName(sourceItem, contextName);
if (contextType != null) {
ContextParameterType parameterType = getContextParameterTypeByName(contextType, contextParam.getName());
String paramName = contextParam.getName();
String newName = ContextUtils.getNewNameFromRenameMap(renameMap, paramName);
if (newName != null) {
paramName = newName;
}
ContextParameterType parameterType = getContextParameterTypeByName(contextType, paramName);
// found parameter, update it.
if (parameterType != null) {
contextParam.setComment(parameterType.getComment());
@@ -98,6 +117,9 @@ public class ContextUtils {
contextParam.setPromptNeeded(parameterType.isPromptNeeded());
contextParam.setType(parameterType.getType());
contextParam.setValue(parameterType.getRawValue());
if (!StringUtils.equals(contextParam.getName(), parameterType.getName())) {
contextParam.setName(parameterType.getName());
}
return true;
}
}
@@ -178,6 +200,28 @@ public class ContextUtils {
return parameterType;
}
public static ContextParameterType getContextParameterTypeById(ContextType contextType, final String uuId,
boolean isFromContextItem) {
if (contextType == null || uuId == null) {
return null;
}
ContextParameterType parameterType = null;
for (ContextParameterType param : (List<ContextParameterType>) contextType.getContextParameter()) {
String paramId = null;
if (isFromContextItem) {
paramId = ResourceHelper.getUUID(param);
} else {
paramId = param.getInternalId();
}
if (uuId.equals(paramId)) {
parameterType = param;
break;
}
}
return parameterType;
}
@SuppressWarnings("unchecked")
private static boolean checkObject(Object obj) {
if (obj == null) {
@@ -372,6 +416,7 @@ public class ContextUtils {
targetParam.setValue(sourceParam.getValue());
targetParam.setPromptNeeded(sourceParam.isPromptNeeded());
targetParam.setComment(sourceParam.getComment());
targetParam.setInternalId(sourceParam.getInternalId());
}
/**
@@ -411,7 +456,7 @@ public class ContextUtils {
targetParam.setValue(sourceParam.getRawValue());
targetParam.setPromptNeeded(sourceParam.isPromptNeeded());
targetParam.setComment(sourceParam.getComment());
targetParam.setInternalId(sourceParam.getInternalId());
}
public static Map<String, Item> getRepositoryContextItemIdMapping() {
@@ -538,8 +583,8 @@ public class ContextUtils {
}
// preference name must match TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE
return Boolean.parseBoolean(CoreRuntimePlugin.getInstance().getDesignerCoreService()
.getPreferenceStore("propagateContextVariable")); //$NON-NLS-1$
return Boolean.parseBoolean(
CoreRuntimePlugin.getInstance().getDesignerCoreService().getPreferenceStore("propagateContextVariable")); //$NON-NLS-1$
}
/**
@@ -573,17 +618,17 @@ public class ContextUtils {
boolean modified = false;
for (String varName : set) {
ContextParameterType contextParameterType = ContextUtils.getContextParameterTypeByName(
contextType, varName);
IContextParameter contextParameter = processJobManager.getDefaultContext().getContextParameter(
varName);
ContextParameterType contextParameterType = ContextUtils
.getContextParameterTypeByName(contextType, varName);
IContextParameter contextParameter = processJobManager.getDefaultContext()
.getContextParameter(varName);
if (contextParameter == null) { // added
addContextParameterType(processJobManager, contextItem, contextParameterType);
modified = true;
}
}
if (modified) {
processJobManager.saveToEmf(processType.getContext());
processJobManager.saveToEmf(processType.getContext(), true);
added = true;
}
}
@@ -672,8 +717,328 @@ public class ContextUtils {
contextParam.setPromptNeeded(contextParamType.isPromptNeeded());
contextParam.setComment(contextParamType.getComment());
contextParam.setInternalId(contextParamType.getInternalId());
contextParam.setSource(contextItem.getProperty().getId());
return contextParam;
}
/**
* Get the context type from item (ContextItem/JobletProcessItem/ProcessItem), If the name is null will use default
* context
*
* @param item
* @param contextName
* @return
*/
public static ContextType getContextTypeByName(Item item, String contextName) {
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
if (contextName == null) {
contextName = contextItem.getDefaultContext();
}
return ContextUtils.getContextTypeByName(contextItem, contextName, true);
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
return ContextUtils.getContextTypeByName((List<ContextType>) jobletProcessItem.getJobletProcess().getContext(),
contextName, jobletProcessItem.getJobletProcess().getDefaultContext());
} else if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return ContextUtils.getContextTypeByName((List<ContextType>) processItem.getProcess().getContext(), contextName,
processItem.getProcess().getDefaultContext());
}
return null;
}
public static String getDefaultContextName(Item item) {
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
return contextItem.getDefaultContext();
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
return jobletProcessItem.getJobletProcess().getDefaultContext();
} else if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return processItem.getProcess().getDefaultContext();
}
return null;
}
public static EList getAllContextType(Item item) {
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
return contextItem.getContext();
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
return jobletProcessItem.getJobletProcess().getContext();
} else if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return processItem.getProcess().getContext();
}
return null;
}
public static Map<String, String> getContextParamterRenamedMap(Item item) {
ItemContextLink itemContextLink = null;
try {
itemContextLink = ContextLinkService.getInstance().loadContextLinkFromJson(item);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (itemContextLink != null) {
if (item instanceof ConnectionItem) {
return compareConnectionContextParamName((ConnectionItem) item, itemContextLink);
} else {
return compareContextParamName(item, itemContextLink);
}
}
return Collections.EMPTY_MAP;
}
private static Map<String, String> compareContextParamName(Item processItem, ItemContextLink itemContextLink) {
List<ContextType> contextTypeList = getAllContextType(processItem);
return compareContextParamName(contextTypeList, itemContextLink);
}
public static Map<String, String> compareContextParamName(List<ContextType> contextTypeList,
ItemContextLink itemContextLink) {
Map<String, String> renamedMap = new HashMap<String, String>();
Map<String, Item> tempItemMap = new HashMap<String, Item>();
for (ContextType contextType : contextTypeList) {
for (Object obj : contextType.getContextParameter()) {
if (obj instanceof ContextParameterType) {
ContextParameterType contextParameterType = (ContextParameterType) obj;
ContextParamLink paramLink = itemContextLink.findContextParamLinkByName(
contextParameterType.getRepositoryContextId(), contextType.getName(), contextParameterType.getName());
if (paramLink != null) {
Item item = tempItemMap.get(contextParameterType.getRepositoryContextId());
if (item == null) {
item = ContextUtils.getRepositoryContextItemById(contextParameterType.getRepositoryContextId());
tempItemMap.put(contextParameterType.getRepositoryContextId(), item);
}
if (item != null) {
final ContextType repoContextType = ContextUtils.getContextTypeByName(item, contextType.getName());
ContextParameterType repoContextParam = ContextUtils.getContextParameterTypeById(repoContextType,
paramLink.getId(), item instanceof ContextItem);
if (repoContextParam != null
&& !StringUtils.equals(repoContextParam.getName(), contextParameterType.getName())) {
renamedMap.put(repoContextParam.getName(), contextParameterType.getName());
}
}
}
}
}
}
return renamedMap;
}
private static Map<String, String> compareConnectionContextParamName(ConnectionItem connectionItem,
ItemContextLink itemContextLink) {
Map<String, String> renamedMap = new HashMap<String, String>();
if (connectionItem.getConnection().isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(connectionItem.getConnection().getContextId());
if (contextItem != null) {
ContextType contextType = ContextUtils.getContextTypeByName(contextItem,
connectionItem.getConnection().getContextName(), false);
if (contextType != null) {
for (Object obj : contextType.getContextParameter()) {
if (obj instanceof ContextParameterType) {
ContextParameterType paramType = (ContextParameterType) obj;
ContextParamLink paramLink = itemContextLink.findContextParamLinkById(
connectionItem.getConnection().getContextId(),
connectionItem.getConnection().getContextName(), ResourceHelper.getUUID(paramType));
if (paramLink != null && !StringUtils.equals(paramType.getName(), paramLink.getName())) {
renamedMap.put(paramType.getName(), paramLink.getName());
}
}
}
}
}
}
return renamedMap;
}
/**
*
* @param itemId
* @param contextType
* @return rename map. Key is new name and value is old name.
*/
public static Map<String, String> calculateRenamedMapFromLinkFile(String projectLabel, String itemId, IContext context,
Item repoContextItem) {
Map<String, String> renamedMap = new HashMap<String, String>();
Map<String, Item> idToItemMap = new HashMap<String, Item>();
if (repoContextItem != null) {
idToItemMap.put(repoContextItem.getProperty().getId(), repoContextItem);
}
try {
ItemContextLink itemContextLink = ContextLinkService.getInstance().doLoadContextLinkFromJson(projectLabel, itemId);
if (itemContextLink != null) {
for (Object obj : context.getContextParameterList()) {
if (obj instanceof IContextParameter) {
IContextParameter parameterType = (IContextParameter) obj;
ContextParamLink parameterLink = itemContextLink.findContextParamLinkByName(parameterType.getSource(),
context.getName(), parameterType.getName());
if (parameterLink != null) {
Item item = idToItemMap.get(parameterType.getSource());
if (item == null) {
item = getRepositoryContextItemById(parameterType.getSource());
idToItemMap.put(parameterType.getSource(), item);
}
if (item != null) {
ContextType contextType = ContextUtils.getContextTypeByName(item, context.getName());
ContextParameterType repoParameterType = ContextUtils.getContextParameterTypeById(contextType,
parameterLink.getId(), item instanceof ContextItem);
if (repoParameterType != null
&& !StringUtils.equals(repoParameterType.getName(), parameterType.getName())) {
renamedMap.put(repoParameterType.getName(), parameterType.getName());
}
}
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return renamedMap;
}
/**
*
* DOC hcw ProcessUpdateManager class global comment. Detailled comment
*/
public static class ContextItemParamMap {
private Map<Item, Set<String>> map = new HashMap<Item, Set<String>>();
public void add(Item item, String param) {
Set<String> params = map.get(item);
if (params == null) {
params = new HashSet<String>();
map.put(item, params);
}
params.add(param);
}
@SuppressWarnings("unchecked")
public Set<String> get(Item item) {
Set<String> params = map.get(item);
return (params == null) ? Collections.EMPTY_SET : params;
}
public boolean isEmpty() {
return map.isEmpty();
}
public Set<Item> getContexts() {
return map.keySet();
}
}
public static boolean compareContextParameter(Item contextItem, ContextType contextType, IContextParameter param,
ContextParamLink paramLink, Map<Item, Map<String, String>> repositoryRenamedMap, Map<Item, Set<String>> existedParams,
ContextItemParamMap unsameMap, ContextItemParamMap deleteParams, boolean onlySimpleShow, boolean isDefaultContext) {
boolean builtin = true;
String paramName = param.getName();
if (paramLink != null && paramLink.getId() != null && contextType != null) {// Compare use UUID
String paramId = paramLink.getId();
ContextParameterType contextParameterType = null;
contextParameterType = getContextParameterTypeById(contextType, paramId, contextItem instanceof ContextItem);
if (contextParameterType != null) {
if (!StringUtils.equals(contextParameterType.getName(), paramName)) {
if (isDefaultContext) {
Map<String, String> renameMap = repositoryRenamedMap.get(contextItem);
if (renameMap == null) {
renameMap = new HashMap<String, String>();
repositoryRenamedMap.put(contextItem, renameMap);
}
renameMap.put(contextParameterType.getName(), paramName);
}
} else {
if (isDefaultContext) {
if (existedParams.get(contextItem) == null) {
existedParams.put(contextItem, new HashSet<String>());
}
existedParams.get(contextItem).add(paramName);
}
if (onlySimpleShow || !samePropertiesForContextParameter(param, contextParameterType)) {
unsameMap.add(contextItem, paramName);
}
}
builtin = false;
} else {
// delete context variable
if (isPropagateContextVariable() && isDefaultContext) {
deleteParams.add(contextItem, paramName);
builtin = false;
}
}
} else { // Compare use Name
final ContextParameterType contextParameterType = ContextUtils.getContextParameterTypeByName(contextType, paramName);
if (contextParameterType != null) {
Item repositoryContext = contextItem;
if (isDefaultContext) {
if (existedParams.get(contextItem) == null) {
existedParams.put(repositoryContext, new HashSet<String>());
}
existedParams.get(repositoryContext).add(paramName);
}
if (onlySimpleShow || !ContextUtils.samePropertiesForContextParameter(param, contextParameterType)) {
unsameMap.add(contextItem, paramName);
}
builtin = false;
} else {
// delete context variable
if (ContextUtils.isPropagateContextVariable()) {
deleteParams.add(contextItem, paramName);
builtin = false;
}
}
}
return builtin && isDefaultContext;
}
public static String getParamId(IContextParameter param, ContextParamLink paramLink) {
if (paramLink != null) {
return paramLink.getId();
}
if (param != null) {
return param.getInternalId();
}
return null;
}
public static Item findContextItem(List<ContextItem> allContextItem, String source) {
if (allContextItem != null) {
for (ContextItem contextItem : allContextItem) {
if (StringUtils.equals(contextItem.getProperty().getId(), source)) {
return contextItem;
}
}
}
return getRepositoryContextItemById(source);
}
public static String getNewNameFromRenameMap(Map<String, String> renameMap, String oldName) {
if (renameMap != null) {
for (String key : renameMap.keySet()) {
String value = renameMap.get(key);
if (StringUtils.equals(value, oldName)) {
return key;
}
}
}
return null;
}
public static boolean isBuildInParameter(ContextParameterType paramType) {
if (paramType.getRepositoryContextId() == null || IContextParameter.BUILT_IN.equals(paramType.getRepositoryContextId())) {
return true;
}
return false;
}
}

View File

@@ -19,8 +19,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.talend.core.model.metadata.MetadataTalendType;
import org.talend.core.model.metadata.types.ContextParameterJavaTypeManager;
import org.talend.core.model.process.IContext;
@@ -30,6 +32,7 @@ import org.talend.core.model.process.IContextParameter;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.utils.ContextParameterUtils;
import org.talend.cwm.helper.ResourceHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
@@ -74,7 +77,7 @@ public class JobContextManager implements IContextManager {
*/
private Set<String> originalParamerters = new HashSet<String>();
private Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
private Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
/*
* for context group
@@ -251,73 +254,7 @@ public class JobContextManager implements IContextManager {
*/
@Override
public void saveToEmf(EList contextTypeList) {
if (contextTypeList == null) {
return;
}
if (listContext.isEmpty()) {
retrieveDefaultContext();
}
EList newcontextTypeList = new BasicEList();
for (int i = 0; i < listContext.size(); i++) {
IContext context = listContext.get(i);
String contextGroupName = renameGroupContext.get(context);
if (contextGroupName == null) {
contextGroupName = context.getName();
}
ContextType contextType = findContextType(contextTypeList, contextGroupName);
if (contextType == null) {
contextType = TalendFileFactory.eINSTANCE.createContextType();
}
contextType.setName(context.getName());
contextType.setConfirmationNeeded(context.isConfirmationNeeded());
newcontextTypeList.add(contextType);
EList contextTypeParamList = contextType.getContextParameter();
List<IContextParameter> contextParameterList = context.getContextParameterList();
EList newContextTypeParamList = new BasicEList();
if (contextParameterList != null) {
for (int j = 0; j < contextParameterList.size(); j++) {
IContextParameter contextParam = contextParameterList.get(j);
String contexParameterName = nameMap.get(contextParam.getName());
if (contexParameterName == null) {
contexParameterName = contextParam.getName();
}
ContextParameterType contextParamType = findContextParameterType(contextTypeParamList, contexParameterName);
if (contextParamType == null) {
contextParamType = TalendFileFactory.eINSTANCE.createContextParameterType();
}
newContextTypeParamList.add(contextParamType);
contextParamType.setName(contextParam.getName());
contextParamType.setPrompt(contextParam.getPrompt());
contextParamType.setType(contextParam.getType());
contextParamType.setRawValue(contextParam.getValue());
contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
contextParamType.setComment(contextParam.getComment());
if (!contextParam.isBuiltIn()) {
Item item = ContextUtils.getRepositoryContextItemById(contextParam.getSource());
if (item != null) {
contextParamType.setRepositoryContextId(item.getProperty().getId());
} else {
String contextId = contextParam.getSource();
if (!IContextParameter.BUILT_IN.equals(contextId)) {
contextParamType.setRepositoryContextId(contextId);
}
}
}
}
contextTypeParamList.clear(); // remove old
contextTypeParamList.addAll(newContextTypeParamList);
}
}
contextTypeList.clear(); // clear old
contextTypeList.addAll(newcontextTypeList);
saveToEmf(contextTypeList, false);
}
private ContextType findContextType(EList contextTypeList, String contextName) {
@@ -384,6 +321,7 @@ public class JobContextManager implements IContextManager {
contextParam.setContext(context);
contextParam.setName(contextParamType.getName());
contextParam.setPrompt(contextParamType.getPrompt());
contextParam.setInternalId(contextParamType.getInternalId());
originalParamerters.add(contextParam.getName());
boolean exists = true;
try {
@@ -486,16 +424,6 @@ public class JobContextManager implements IContextManager {
}
/**
*
* ggu Comment method "getLostParameters".
*
* @return
*/
public Set<String> getLostParameters() {
return this.lostParameters;
}
public Map<ContextItem, Map<String, String>> getRepositoryRenamedMap() {
return this.repositoryRenamedMap;
}
@@ -516,6 +444,16 @@ public class JobContextManager implements IContextManager {
}
/**
*
* ggu Comment method "getLostParameters".
*
* @return
*/
public Set<String> getLostParameters() {
return this.lostParameters;
}
public void addNewParameters(String param) {
newParameters.add(param);
}
@@ -540,11 +478,11 @@ public class JobContextManager implements IContextManager {
}
}
public Map<ContextItem, Set<String>> getNewParametersMap() {
public Map<Item, Set<String>> getNewParametersMap() {
return newParametersMap;
}
public void setNewParametersMap(Map<ContextItem, Set<String>> newParametersMap) {
public void setNewParametersMap(Map<Item, Set<String>> newParametersMap) {
this.newParametersMap = newParametersMap;
}
@@ -573,4 +511,98 @@ public class JobContextManager implements IContextManager {
public void setConfigContextGroup(boolean isConfigContextGroup) {
this.isConfigContextGroup = isConfigContextGroup;
}
@Override
public void saveToEmf(EList contextTypeList, boolean useInternalId) {
if (contextTypeList == null) {
return;
}
if (listContext.isEmpty()) {
retrieveDefaultContext();
}
EList newcontextTypeList = new BasicEList();
Map<String, Item> idToItemMap = new HashMap<String, Item>();
for (int i = 0; i < listContext.size(); i++) {
IContext context = listContext.get(i);
String contextGroupName = renameGroupContext.get(context);
if (contextGroupName == null) {
contextGroupName = context.getName();
}
ContextType contextType = findContextType(contextTypeList, contextGroupName);
if (contextType == null) {
contextType = TalendFileFactory.eINSTANCE.createContextType();
}
contextType.setName(context.getName());
contextType.setConfirmationNeeded(context.isConfirmationNeeded());
newcontextTypeList.add(contextType);
EList contextTypeParamList = contextType.getContextParameter();
List<IContextParameter> contextParameterList = context.getContextParameterList();
EList newContextTypeParamList = new BasicEList();
if (contextParameterList != null) {
for (int j = 0; j < contextParameterList.size(); j++) {
IContextParameter contextParam = contextParameterList.get(j);
String contexParameterName = nameMap.get(contextParam.getName());
if (contexParameterName == null) {
contexParameterName = contextParam.getName();
}
ContextParameterType contextParamType = findContextParameterType(contextTypeParamList, contexParameterName);
if (contextParamType == null) {
contextParamType = TalendFileFactory.eINSTANCE.createContextParameterType();
}
newContextTypeParamList.add(contextParamType);
contextParamType.setName(contextParam.getName());
contextParamType.setPrompt(contextParam.getPrompt());
contextParamType.setType(contextParam.getType());
contextParamType.setRawValue(contextParam.getValue());
contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
contextParamType.setComment(contextParam.getComment());
if (!contextParam.isBuiltIn()) {
Item item = idToItemMap.get(contextParam.getSource());
if (item == null) {
item = ContextUtils.getRepositoryContextItemById(contextParam.getSource());
idToItemMap.put(contextParam.getSource(), item);
}
if (item != null) {
contextParamType.setRepositoryContextId(item.getProperty().getId());
if (item instanceof ContextItem) {
ContextType repoContextType = ContextUtils.getContextTypeByName(item, contextType.getName());
if (repoContextType != null) {
ContextParameterType repoContextParam = ContextUtils
.getContextParameterTypeByName(repoContextType, contextParam.getName());
if (repoContextParam != null) {
ResourceHelper.setUUid(contextParamType, ResourceHelper.getUUID(repoContextParam));
}
}
}
} else {
String contextId = contextParam.getSource();
if (!IContextParameter.BUILT_IN.equals(contextId)) {
contextParamType.setRepositoryContextId(contextId);
}
}
} else if (useInternalId) {
String internalId = contextParam.getInternalId();
if (StringUtils.isEmpty(internalId)) {
internalId = EcoreUtil.generateUUID();
contextParamType.setInternalId(internalId);
contextParam.setInternalId(internalId);
} else {
contextParamType.setInternalId(internalId);
}
}
}
contextTypeParamList.clear(); // remove old
contextTypeParamList.addAll(newContextTypeParamList);
}
}
contextTypeList.clear(); // clear old
contextTypeList.addAll(newcontextTypeList);
}
}

View File

@@ -45,13 +45,14 @@ public class JobContextParameter implements IContextParameter, Cloneable {
String[] valueList;
String internalId;
/**
* change to save id always for bug 13184.
*/
String source = ""; //$NON-NLS-1$
public JobContextParameter() {
}
@Override
@@ -310,6 +311,14 @@ public class JobContextParameter implements IContextParameter, Cloneable {
this.promptNeeded = promptNeeded;
}
public String getInternalId() {
return internalId;
}
public void setInternalId(String internalId) {
this.internalId = internalId;
}
@Override
public IContextParameter clone() {
IContextParameter clonedContextParameter = null;

View File

@@ -0,0 +1,85 @@
// ============================================================================
//
// 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.core.model.context.link;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ContextLink {
@JsonProperty("contextName")
private String contextName;
@JsonProperty("repoId")
private String repoId;
@JsonProperty("parameterList")
private List<ContextParamLink> parameterList = new ArrayList<ContextParamLink>();
public String getRepoId() {
return repoId;
}
public void setRepoId(String repoId) {
this.repoId = repoId;
}
public List<ContextParamLink> getParameterList() {
return parameterList;
}
public void setParameterList(List<ContextParamLink> parameterList) {
this.parameterList = parameterList;
}
public String getContextName() {
return contextName;
}
public void setContextName(String contextName) {
this.contextName = contextName;
}
public ContextParamLink getParamLinkByName(String paramName) {
for (ContextParamLink paramLink : parameterList) {
if (StringUtils.equals(paramLink.getName(), paramName)) {
return paramLink;
}
}
return null;
}
public ContextParamLink getParamLinkById(String id) {
for (ContextParamLink paramLink : parameterList) {
if (StringUtils.equals(paramLink.getId(), id)) {
return paramLink;
}
}
return null;
}
public ContextLink cloneObj() {
ContextLink obj = new ContextLink();
obj.setContextName(contextName);
obj.setRepoId(repoId);
for (ContextParamLink p : parameterList) {
obj.getParameterList().add(p.cloneObj());
}
return obj;
}
}

View File

@@ -0,0 +1,392 @@
// ============================================================================
//
// 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.core.model.context.link;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.process.IContextParameter;
import org.talend.core.model.properties.ConnectionItem;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.JobletProcessItem;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Project;
import org.talend.cwm.helper.ResourceHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.repository.ProjectManager;
import org.talend.repository.model.RepositoryConstants;
import com.fasterxml.jackson.databind.ObjectMapper;
public class ContextLinkService {
private static final String CREATOR_EXT_ID = "org.talend.core.runtime.saveItemContextLinkService"; //$NON-NLS-1$
public static final String LINKS_FOLDER_NAME = "links";
public static final String LINK_FILE_POSTFIX = ".link";
private static final List<IItemContextLinkService> registeredService = new ArrayList<IItemContextLinkService>();
private static ContextLinkService instance = new ContextLinkService();
private static final String CURRENT_PROJECT_LABEL = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
private ContextLinkService() {
initService();
}
public static ContextLinkService getInstance() {
return instance;
}
public synchronized boolean saveContextLink(Item item) throws PersistenceException {
for (IItemContextLinkService service : registeredService) {
if (service.accept(item)) {
return service.saveItemLink(item);
}
}
return doSaveContextLink(item);
}
public synchronized boolean doSaveContextLink(Item item) throws PersistenceException {
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return saveContextLink(processItem.getProcess().getContext(), item);
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = (JobletProcessItem) item;
return saveContextLink(jobletItem.getJobletProcess().getContext(), item);
} else if (item instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) item;
return saveContextLink(connectionItem.getConnection(), item);
}
return false;
}
@SuppressWarnings("unchecked")
private synchronized boolean saveContextLink(Connection connection, Item item) throws PersistenceException {
boolean hasLinkFile = false;
ItemContextLink itemContextLink = new ItemContextLink();
itemContextLink.setItemId(item.getProperty().getId());
if (connection.isContextMode()) {
String contextId = connection.getContextId();
if (StringUtils.isEmpty(contextId) || IContextParameter.BUILT_IN.equals(contextId)) {
return hasLinkFile;
}
ContextLink contextLink = new ContextLink();
contextLink.setContextName(connection.getContextName());
contextLink.setRepoId(contextId);
itemContextLink.getContextList().add(contextLink);
ContextItem contextItem = ContextUtils.getContextItemById2(contextId);
if (contextItem != null) {
ContextType contextType = ContextUtils.getContextTypeByName(contextItem.getContext(),
connection.getContextName());
if (contextType != null) {
for (Object o : contextType.getContextParameter()) {
if (o instanceof ContextParameterType) {
ContextParameterType contextParameterType = (ContextParameterType) o;
ContextParamLink contextParamLink = new ContextParamLink();
contextParamLink.setName(contextParameterType.getName());
contextParamLink.setId(ResourceHelper.getUUID(contextParameterType));
contextLink.getParameterList().add(contextParamLink);
}
}
}
}
}
if (itemContextLink.getContextList().size() > 0) {
saveContextLinkToJson(item, itemContextLink);
hasLinkFile = true;
} else {
deleteContextLinkJsonFile(item);
}
return hasLinkFile;
}
public synchronized boolean saveContextLink(List<ContextType> contextTypeList, Item item) throws PersistenceException {
boolean hasLinkFile = false;
String itemId = item.getProperty().getId();
ItemContextLink itemContextLink = new ItemContextLink();
itemContextLink.setItemId(itemId);
Map<String, Item> tempCache = new HashMap<String, Item>();
if (contextTypeList != null && contextTypeList.size() > 0) {
ItemContextLink backupContextLink = this.loadContextLinkFromJson(item);
for (Object object : contextTypeList) {
if (object instanceof ContextType) {
ContextType jobContextType = (ContextType) object;
for (Object o : jobContextType.getContextParameter()) {
if (o instanceof ContextParameterType) {
ContextParameterType contextParameterType = (ContextParameterType) o;
String repositoryContextId = contextParameterType.getRepositoryContextId();
if (StringUtils.isEmpty(repositoryContextId)
|| IContextParameter.BUILT_IN.equals(repositoryContextId)) {
ContextLink contextLink = itemContextLink.findContextLink(item.getProperty().getId(),
jobContextType.getName());
if (contextLink == null) {
contextLink = new ContextLink();
contextLink.setContextName(jobContextType.getName());
contextLink.setRepoId(itemId);
itemContextLink.getContextList().add(contextLink);
}
ContextParamLink contextParamLink = createParamLink(itemId, jobContextType.getName(),
contextParameterType.getName(), contextParameterType.getInternalId(), tempCache,
backupContextLink);
contextLink.getParameterList().add(contextParamLink);
} else {
ContextLink contextLink = itemContextLink
.findContextLink(contextParameterType.getRepositoryContextId(), jobContextType.getName());
if (contextLink == null) {
contextLink = new ContextLink();
contextLink.setContextName(jobContextType.getName());
contextLink.setRepoId(repositoryContextId);
itemContextLink.getContextList().add(contextLink);
}
ContextParamLink contextParamLink = createParamLink(repositoryContextId, jobContextType.getName(),
contextParameterType.getName(), contextParameterType.getInternalId(), tempCache,
backupContextLink);
contextLink.getParameterList().add(contextParamLink);
}
}
}
}
}
}
if (itemContextLink.getContextList().size() > 0) {
saveContextLinkToJson(item, itemContextLink);
hasLinkFile = true;
} else {
deleteContextLinkJsonFile(item);
}
return hasLinkFile;
}
@SuppressWarnings("unchecked")
private ContextParamLink createParamLink(String repositoryContextId, String contextName, String paramName, String internalId,
Map<String, Item> tempCache, ItemContextLink oldContextLink) {
ContextParamLink contextParamLink = new ContextParamLink();
contextParamLink.setName(paramName);
contextParamLink.setId(internalId);
Item contextItem = tempCache.get(repositoryContextId);
if (contextItem == null) {
contextItem = ContextUtils.getRepositoryContextItemById(repositoryContextId);
tempCache.put(repositoryContextId, contextItem);
}
if (contextItem != null) {
ContextType contextType = ContextUtils.getContextTypeByName(contextItem, contextName);
ContextParameterType repoContextParameterType = ContextUtils.getContextParameterTypeByName(contextType, paramName);
String uuID = null;
if(repoContextParameterType != null) {
if (contextItem instanceof ContextItem) {
uuID = ResourceHelper.getUUID(repoContextParameterType);
} else if (repoContextParameterType.getInternalId() != null) {
uuID = repoContextParameterType.getInternalId();
}
}
if (repoContextParameterType == null && oldContextLink != null) {
ContextParamLink oldParamLink = oldContextLink.findContextParamLinkByName(repositoryContextId, contextName,
paramName);
if (oldParamLink != null) {
uuID = oldParamLink.getId();
}
}
contextParamLink.setId(uuID);
}
return contextParamLink;
}
private synchronized void saveContextLinkToJson(Item item, ItemContextLink itemContextLink) throws PersistenceException {
IFolder linksFolder = getLinksFolder(getItemProjectLabel(item));
if (!linksFolder.exists()) {
ResourceUtils.createFolder(linksFolder);
}
IFile linkFile = calContextLinkFile(item);
ObjectMapper objectMapper = new ObjectMapper();
try {
String content = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(itemContextLink);
if (!linkFile.exists()) {
ResourceUtils.createFile(new ByteArrayInputStream(content.getBytes()), linkFile);
} else {
ResourceUtils.setFileContent(new ByteArrayInputStream(content.getBytes()), linkFile);
}
} catch (Exception e) {
throw new PersistenceException(e);
}
}
public synchronized boolean changeRepositoryId(Item item, Map<String, String> old2NewMap) throws PersistenceException {
boolean isModofied = false;
ItemContextLink itemContextLink = loadContextLinkFromJson(item);
if (itemContextLink != null) {
for (ContextLink contextLink : itemContextLink.getContextList()) {
if (old2NewMap.containsKey(contextLink.getRepoId())) {
contextLink.setRepoId(old2NewMap.get(contextLink.getRepoId()));
isModofied = true;
}
}
}
if (isModofied) {
this.saveContextLinkToJson(item, itemContextLink);
}
return isModofied;
}
public synchronized ItemContextLink loadContextLinkFromJson(Item item) throws PersistenceException {
for (IItemContextLinkService service : registeredService) {
if (service.accept(item)) {
return service.loadItemLink(item);
}
}
return doLoadContextLinkFromJson(item);
}
public synchronized ItemContextLink doLoadContextLinkFromJson(Item item) throws PersistenceException {
IFile linkFile = calContextLinkFile(item);
return doLoadContextLinkFromFile(linkFile);
}
public synchronized ItemContextLink doLoadContextLinkFromJson(String projectLabel, String id) throws PersistenceException {
IFile linkFile = calContextLinkFile(projectLabel, id);
return doLoadContextLinkFromFile(linkFile);
}
public synchronized ItemContextLink doLoadContextLinkFromFile(IFile linkFile) throws PersistenceException {
if (linkFile == null || !linkFile.exists()) {
return null;
}
ItemContextLink contextLink = null;
try {
contextLink = new ObjectMapper().readValue(linkFile.getLocation().toFile(), ItemContextLink.class);
} catch (IOException e) {
throw new PersistenceException(e);
}
return contextLink;
}
public synchronized void deleteContextLinkJsonFile(Item item) throws PersistenceException {
IFile linkFile = calContextLinkFile(item);
if (linkFile != null && linkFile.exists()) {
try {
linkFile.delete(true, null);
} catch (CoreException e) {
throw new PersistenceException(e);
}
}
}
public static IFile calContextLinkFile(Item item) throws PersistenceException {
if (item == null) {
return null;
}
IFolder linksFolder = getLinksFolder(getItemProjectLabel(item));
return linksFolder.getFile(calLinkFileName(item.getProperty().getId()));
}
public static IFile calContextLinkFile(String projectLabel, String itemId) throws PersistenceException {
if (projectLabel == null || itemId == null) {
return null;
}
IFolder linksFolder = getLinksFolder(projectLabel);
return linksFolder.getFile(calLinkFileName(itemId));
}
public static String getItemProjectLabel(Item item) {
Project project = ProjectManager.getInstance().getProject(item);
if (project != null) {
return project.getTechnicalLabel();
}
return CURRENT_PROJECT_LABEL;
}
private static String calLinkFileName(String id) {
StringBuilder sb = new StringBuilder();
sb.append(id).append(LINK_FILE_POSTFIX);
return sb.toString();
}
public static IFile calLinksFile(IFolder projectFolder, String id) {
IFolder settingFolder = projectFolder.getFolder(RepositoryConstants.SETTING_DIRECTORY);
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
return linksFolder.getFile(getLinkFileName(id));
}
public static String calLinksFilePath(String projectPath, String id) {
StringBuilder sb = new StringBuilder(projectPath);
sb.append(File.separator).append(RepositoryConstants.SETTING_DIRECTORY);
sb.append(File.separator).append(LINKS_FOLDER_NAME);
sb.append(File.separator).append(getLinkFileName(id));
return sb.toString();
}
public static IFile calLinksFile(IProject project, String id) {
IFolder settingFolder = project.getFolder(RepositoryConstants.SETTING_DIRECTORY);
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
return linksFolder.getFile(getLinkFileName(id));
}
public static String getLinkFileName(String id) {
return id + LINK_FILE_POSTFIX;
}
private static IFolder getLinksFolder(String projectLabel) throws PersistenceException {
IProject iProject = ResourceUtils.getProject(projectLabel);
IFolder settingFolder = iProject.getFolder(RepositoryConstants.SETTING_DIRECTORY);
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
return linksFolder;
}
private static void initService() {
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CREATOR_EXT_ID);
if (extensionPoint != null) {
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
for (IConfigurationElement configurationElement : configurationElements) {
try {
Object creator = configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
if (creator instanceof IItemContextLinkService) {
IItemContextLinkService service = (IItemContextLinkService) creator;
registeredService.add(service);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
}
}
}
}

View File

@@ -0,0 +1,48 @@
// ============================================================================
//
// 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.core.model.context.link;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ContextParamLink {
@JsonProperty("id")
private String id;
@JsonProperty("name")
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ContextParamLink cloneObj() {
ContextParamLink obj = new ContextParamLink();
obj.setId(id);
obj.setName(name);
return obj;
}
}

View File

@@ -0,0 +1,26 @@
// ============================================================================
//
// 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.core.model.context.link;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.model.properties.Item;
public interface IItemContextLinkService {
boolean accept(Item item);
boolean saveItemLink(Item item) throws PersistenceException;
ItemContextLink loadItemLink(Item item) throws PersistenceException;
}

View File

@@ -0,0 +1,80 @@
// ============================================================================
//
// 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.core.model.context.link;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ItemContextLink {
@JsonProperty("itemId")
private String itemId;
@JsonProperty("contextList")
private List<ContextLink> contextList = new ArrayList<ContextLink>();
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public List<ContextLink> getContextList() {
return contextList;
}
public void setContextList(List<ContextLink> contextList) {
this.contextList = contextList;
}
public ContextParamLink findContextParamLinkByName(String repoContextId, String contextName, String paramName) {
ContextLink contextLink = findContextLink(repoContextId, contextName);
if (contextLink != null) {
return contextLink.getParamLinkByName(paramName);
}
return null;
}
public ContextParamLink findContextParamLinkById(String repoContextId, String contextName, String paramId) {
ContextLink contextLink = findContextLink(repoContextId, contextName);
if (contextLink != null) {
return contextLink.getParamLinkById(paramId);
}
return null;
}
public ContextLink findContextLink(String repoContextId, String contextName) {
for (ContextLink contextLink : contextList) {
if ((repoContextId == null || StringUtils.equals(repoContextId, contextLink.getRepoId()))
&& StringUtils.equals(contextName, contextLink.getContextName())) {
return contextLink;
}
}
return null;
}
public ItemContextLink cloneObj() {
ItemContextLink obj = new ItemContextLink();
obj.setItemId(itemId);
for (ContextLink c : contextList) {
obj.getContextList().add(c.cloneObj());
}
return obj;
}
}

View File

@@ -56,6 +56,7 @@ public class ConnectionBean implements Cloneable {
private static final String TOKEN = "token"; //$NON-NLS-1$
private static final String URL = "url"; //$NON-NLS-1$
/**
* DOC smallet ConnectionBean constructor comment.
*/
@@ -396,4 +397,15 @@ public class ConnectionBean implements Cloneable {
}
}
public String getUrl() {
try {
if (conDetails.has(URL)) {
return conDetails.getString(URL);
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
return "";
}
}

View File

@@ -87,6 +87,7 @@ import org.talend.core.model.repository.DragAndDropManager;
import org.talend.core.model.update.UpdatesConstants;
import org.talend.core.model.utils.IDragAndDropServiceHandler;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.services.IGenericWizardService;
import org.talend.core.service.IMetadataManagmentService;
import org.talend.core.service.IMetadataManagmentUiService;
import org.talend.core.utils.KeywordsValidator;
@@ -155,12 +156,12 @@ public class RepositoryToComponentProperty {
return getEDIFACTSchemaValue((EDIFACTConnection) connection, value);
}
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
if (handler.canHandle(connection)) {
return handler.getComponentValue(connection, value, table, targetComponent, contextMap);
}
// Special for Javajet components: tSalesforceEinsteinBulkExec/tSalesforceEinsteinOutputBulkExec
if (targetComponent != null && targetComponent.startsWith("tSalesforceEinstein")) { //$NON-NLS-1$
return getSpecialGenericValue(connection, value, table, targetComponent, contextMap);
}
return null;
return getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
}
@@ -213,8 +214,7 @@ public class RepositoryToComponentProperty {
return;
}
SAPFunctionUnit unit = null;
for (int i = 0; i < conn.getFuntions().size(); i++) {
SAPFunctionUnit tmp = conn.getFuntions().get(i);
for (SAPFunctionUnit tmp : conn.getFuntions()) {
if (tmp.getLabel().equals(functionLabel)) {
unit = tmp;
break;
@@ -230,9 +230,8 @@ public class RepositoryToComponentProperty {
if (isInput) {
mergeColumn(table, table.getChildren(), value2);
} else {
for (int i = 0; i < table.getChildren().size(); i++) {
for (SAPFunctionParameter column : table.getChildren()) {
Map<String, Object> map = new HashMap<String, Object>();
SAPFunctionParameter column = table.getChildren().get(i);
// this part maybe no use , didn't find OUTPUT_PARAMS in sap component
map.put("SAP_PARAMETER_TYPE", column.getType().replace('.', '_')); //$NON-NLS-1$
map.put("SAP_TABLE_NAME", TalendQuoteUtils.addQuotes("")); //$NON-NLS-1$
@@ -298,8 +297,8 @@ public class RepositoryToComponentProperty {
if (conn == null) {
return null;
}
for (int i = 0; i < conn.getFuntions().size(); i++) {
unit = conn.getFuntions().get(i);
for (SAPFunctionUnit element : conn.getFuntions()) {
unit = element;
if (unit.getLabel().equals(functionLabel)) {
break;
}
@@ -626,6 +625,50 @@ public class RepositoryToComponentProperty {
return null;
}
private static Object getSpecialGenericValue(Connection connection, String value, IMetadataTable table,
String targetComponent,
Map<Object, Object> contextMap) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService wizardService = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
if (wizardService != null && wizardService.isGenericConnection(connection)) {
if (value != null) {
if ("ENDPOINT".equals(value)) { //$NON-NLS-1$
value = "connection.endpoint"; //$NON-NLS-1$
} else if ("USER_NAME".equals(value)) { //$NON-NLS-1$
value = "connection.userPassword.userId"; //$NON-NLS-1$
} else if ("PASSWORD".equals(value)) { //$NON-NLS-1$
// salesforce javajet component:pwd = pwd + token
value = "connection.userPassword.password"; //$NON-NLS-1$
Object password = getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
String skValue = "connection.userPassword.securityKey"; //$NON-NLS-1$
Object securityKey = getHandlerComponentValue(connection, skValue, table, targetComponent, contextMap);
if (securityKey != null) {
if (isContextMode(connection, String.valueOf(password))) {
return String.valueOf(password) + "+" + String.valueOf(securityKey); //$NON-NLS-1$
} else {
return TalendQuoteUtils.addQuotes(TalendQuoteUtils.removeQuotesIfExist(String.valueOf(password))
+ TalendQuoteUtils.removeQuotesIfExist(String.valueOf(securityKey)));
}
}
return password;
}
return getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
}
}
}
return null;
}
private static Object getHandlerComponentValue(Connection connection, String value, IMetadataTable table,
String targetComponent, Map<Object, Object> contextMap) {
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
if (handler.canHandle(connection)) {
return handler.getComponentValue(connection, value, table, targetComponent, contextMap);
}
}
return null;
}
private static SalesforceModuleUnit getSaleforceModuleUnitByTable(IMetadataTable table,
EList<SalesforceModuleUnit> moduleList) {
for (SalesforceModuleUnit unit : moduleList) {
@@ -746,9 +789,9 @@ public class RepositoryToComponentProperty {
public static List<Map<String, String>> getOutputWSDLValue(EList list) {
List<Map<String, String>> newList = new ArrayList<Map<String, String>>();
for (int i = 0; i < list.size(); i++) {
for (Object element : list) {
Map<String, String> map = new HashMap<String, String>();
WSDLParameter node = (WSDLParameter) list.get(i);
WSDLParameter node = (WSDLParameter) element;
map.put("EXPRESSION", node.getExpression());
map.put("COLUMN", node.getColumn());
map.put("SOURCE", node.getSource());
@@ -1001,8 +1044,9 @@ public class RepositoryToComponentProperty {
} else {
String version = connection.getDbVersionString();
if (EDatabaseVersion4Drivers.ORACLE_18.name().equals(version)) {
if (StringUtils.equals(CDCTypeMode.LOG_MODE.getName(), connection.getCdcTypeMode()))
if (StringUtils.equals(CDCTypeMode.LOG_MODE.getName(), connection.getCdcTypeMode())) {
return CDCTypeMode.LOG_UNSUPPORTED_MODE.getName();
}
}
return connection.getCdcTypeMode();
}
@@ -1491,7 +1535,7 @@ public class RepositoryToComponentProperty {
String clusterID = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
if (clusterID != null) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
IHadoopClusterService hadoopClusterService = (IHadoopClusterService) GlobalServiceRegister.getDefault()
IHadoopClusterService hadoopClusterService = GlobalServiceRegister.getDefault()
.getService(IHadoopClusterService.class);
Map<String, String> hadoopCustomLibraries = hadoopClusterService.getHadoopCustomLibraries(clusterID);
@@ -1735,7 +1779,7 @@ public class RepositoryToComponentProperty {
private static boolean isContextMode(Connection connection, String value) {
IMetadataManagmentUiService mmService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentUiService.class)) {
mmService = (IMetadataManagmentUiService) GlobalServiceRegister.getDefault()
mmService = GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentUiService.class);
}
if (mmService != null) {
@@ -2022,7 +2066,7 @@ public class RepositoryToComponentProperty {
Path p = new Path(connection.getXmlFilePath());
if ((p.toPortableString()).endsWith("xsd")) { //$NON-NLS-1$
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentUiService.class)) {
IMetadataManagmentUiService mmUIService = (IMetadataManagmentUiService) GlobalServiceRegister.getDefault()
IMetadataManagmentUiService mmUIService = GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentUiService.class);
String newPath = mmUIService.getAndOpenXSDFileDialog(p);
if (newPath != null) {
@@ -2142,9 +2186,9 @@ public class RepositoryToComponentProperty {
public static List<Map<String, String>> getOutputXmlValue(EList list) {
List<Map<String, String>> newList = new ArrayList<Map<String, String>>();
for (int i = 0; i < list.size(); i++) {
for (Object element : list) {
Map<String, String> map = new HashMap<String, String>();
XMLFileNode node = (XMLFileNode) list.get(i);
XMLFileNode node = (XMLFileNode) element;
String defaultValue = node.getDefaultValue();
if (defaultValue == null) {
defaultValue = ""; //$NON-NLS-1$
@@ -2388,7 +2432,7 @@ public class RepositoryToComponentProperty {
} else {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentService.class)) {
IMetadataManagmentService mmService = (IMetadataManagmentService) GlobalServiceRegister.getDefault()
IMetadataManagmentService mmService = GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentService.class);
IMetadataTable convert = mmService.convertMetadataTable(repTable);
String uinqueTableName = node.getProcess()
@@ -2643,8 +2687,7 @@ public class RepositoryToComponentProperty {
boolean foundColumn = false;
Map<String, Object> map = new HashMap<String, Object>();
map.put("QUERY", null); //$NON-NLS-1$
for (int i = 0; i < schemaTargets.size(); i++) {
SchemaTarget sch = schemaTargets.get(i);
for (SchemaTarget sch : schemaTargets) {
if (col.getLabel().equals(sch.getTagName())) {
// map.put("SCHEMA_COLUMN", sch.getTagName());
foundColumn = true;
@@ -2653,8 +2696,7 @@ public class RepositoryToComponentProperty {
}
if (!foundColumn && colRenameMap != null && !colRenameMap.isEmpty()) {
Set<String> newNameSet = colRenameMap.keySet();
for (int i = 0; i < schemaTargets.size(); i++) {
SchemaTarget sch = schemaTargets.get(i);
for (SchemaTarget sch : schemaTargets) {
if (newNameSet.contains(sch.getTagName())) {
String oldColLabel = colRenameMap.get(sch.getTagName());
if (col.getLabel().equals(oldColLabel)) {
@@ -2713,8 +2755,7 @@ public class RepositoryToComponentProperty {
for (IMetadataColumn col : metadataTable.getListColumns()) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("QUERY", null); //$NON-NLS-1$
for (int i = 0; i < conceptTargets.size(); i++) {
ConceptTarget cpt = conceptTargets.get(i);
for (ConceptTarget cpt : conceptTargets) {
if (col.getLabel().equals(cpt.getTargetName())) {
// map.put("SCHEMA_COLUMN", sch.getTagName());
map.put("QUERY", TalendQuoteUtils.addQuotes(cpt.getRelativeLoopExpression())); //$NON-NLS-1$

View File

@@ -44,6 +44,8 @@ public interface IContextManager {
public void saveToEmf(EList contextTypeList);
public void saveToEmf(EList contextTypeList, boolean useInternalId);
public void loadFromEmf(EList contextTypeList, String defaultContextName);
public boolean sameAs(IContextManager contextManager);

View File

@@ -71,4 +71,8 @@ public interface IContextParameter {
public void setSource(final String sourceName);
public boolean isBuiltIn();
public String getInternalId();
public void setInternalId(String internalId);
}

View File

@@ -426,6 +426,11 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
*/
public final static ERepositoryObjectType JOBLET = ERepositoryObjectType.valueOf("JOBLET"); //$NON-NLS-1$
/**
* <font color="red">This value may be <b>null</b> in some products, <b>should add NPE check</b></font>
*/
public final static ERepositoryObjectType SERVICES = ERepositoryObjectType.valueOf("SERVICES"); //$NON-NLS-1$
public final static ERepositoryObjectType JOBLET_DESIGNS = ERepositoryObjectType.valueOf("JOBLET_DESIGNS"); //$NON-NLS-1$
public final static ERepositoryObjectType SPARK_JOBLET = ERepositoryObjectType.valueOf("SPARK_JOBLET"); //$NON-NLS-1$
@@ -438,6 +443,8 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
public final static ERepositoryObjectType ROUTINES = ERepositoryObjectType.valueOf("ROUTINES"); //$NON-NLS-1$
public final static ERepositoryObjectType BEANS = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
public final static ERepositoryObjectType METADATA_HEADER_FOOTER = ERepositoryObjectType.valueOf("METADATA_HEADER_FOOTER"); //$NON-NLS-1$
public final static ERepositoryObjectType JOB_SCRIPT = ERepositoryObjectType.valueOf("JOB_SCRIPT"); //$NON-NLS-1$

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.core.model.update;
import org.talend.core.AbstractRepositoryContextUpdateService;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.runtime.services.IGenericDBService;
public class GenericDbContextUpdateService extends AbstractRepositoryContextUpdateService {
IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
@Override
public boolean accept(Connection connection) {
return connection.getCompProperties() != null;
}
@Override
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
return updateCompPropertiesContextParameter(conn, oldValue, newValue);
}
}

View File

@@ -0,0 +1,424 @@
// ============================================================================
//
// 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.core.model.update;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.talend.core.AbstractRepositoryContextUpdateService;
import org.talend.core.database.conn.ConnParameterKeys;
import org.talend.core.database.conn.template.EDatabaseConnTemplate;
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
import org.talend.core.model.metadata.builder.connection.AdditionalConnectionProperty;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.connection.DelimitedFileConnection;
import org.talend.core.model.metadata.builder.connection.FileExcelConnection;
import org.talend.core.model.metadata.builder.connection.LdifFileConnection;
import org.talend.core.model.metadata.builder.connection.PositionalFileConnection;
import org.talend.core.model.metadata.builder.connection.RegexpFileConnection;
import org.talend.core.model.metadata.builder.connection.SAPConnection;
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
import org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection;
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
import org.talend.core.model.metadata.builder.connection.XmlXPathLoopDescriptor;
public class RepositoryContextUpdateService extends AbstractRepositoryContextUpdateService {
@Override
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.isContextMode()) {
if (conn instanceof DatabaseConnection) {
return updateDatabaseConnectinParam((DatabaseConnection) conn, oldValue, newValue);
}
if (conn instanceof FileExcelConnection) {
return updateFileExcelConnectionParam((FileExcelConnection) conn, oldValue, newValue);
}
if (conn instanceof DelimitedFileConnection) {
return updatDelimitedFileConnectionParam((DelimitedFileConnection) conn, oldValue, newValue);
}
if (conn instanceof RegexpFileConnection) {
return updateRegexpFileConnectionParam((RegexpFileConnection) conn, oldValue, newValue);
}
if (conn instanceof LdifFileConnection) {
return updateLdifFileConnectionParam((LdifFileConnection) conn, oldValue, newValue);
}
if (conn instanceof PositionalFileConnection) {
return updatePositionalFileConnectionParam((PositionalFileConnection) conn, oldValue, newValue);
}
if (conn instanceof XmlFileConnection) {
return updateXmlFileConnectionParam((XmlFileConnection) conn, oldValue, newValue);
}
if (conn instanceof SalesforceSchemaConnection) {
return updateSalesforceSchemaConnectionParam((SalesforceSchemaConnection) conn, oldValue, newValue);
}
if (conn instanceof WSDLSchemaConnection) {
return updateWSDLSchemaConnectionParam((WSDLSchemaConnection) conn, oldValue, newValue);
}
if (conn instanceof SAPConnection) {
return updateSAPConnectionParam((SAPConnection) conn, oldValue, newValue);
}
}
return isModified;
}
private boolean updateParameters(DatabaseConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
EMap<String, String> parameters = dbConn.getParameters();
if (parameters != null && !parameters.isEmpty()) {
for (Entry<String, String> entry : parameters.entrySet()) {
if (entry != null) {
String value = entry.getValue();
if (StringUtils.equals(value, oldValue)) {
entry.setValue(newValue);
isModified = true;
}
}
}
}
boolean hadoopUpdateResult = updateHadoopPropertiesForDbConnection(dbConn, oldValue, newValue);
return isModified || hadoopUpdateResult;
}
private boolean updateHadoopPropertiesForDbConnection(DatabaseConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
EMap<String, String> parameters = dbConn.getParameters();
String databaseType = parameters.get(ConnParameterKeys.CONN_PARA_KEY_DB_TYPE);
String hadoopProperties = "";
if (databaseType != null) {
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES);
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES);
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES);
}
List<Map<String, Object>> hadoopPropertiesList = HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties);
if (!hadoopPropertiesList.isEmpty()) {
for (Map<String, Object> propertyMap : hadoopPropertiesList) {
String propertyValue = (String) propertyMap.get("VALUE");
if (propertyValue.equals(oldValue)) {
propertyMap.put("VALUE", newValue);
isModified = true;
}
}
String hadoopPropertiesJson = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopPropertiesList);
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES, hadoopPropertiesJson);
isModified = true;
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES, hadoopPropertiesJson);
isModified = true;
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES, hadoopPropertiesJson);
isModified = true;
}
}
}
return isModified;
}
private boolean updateDatabaseConnectinParam(DatabaseConnection dbConn, String oldValue, String newValue) {
boolean compPropertiesResult = updateCompPropertiesContextParameter(dbConn, oldValue, newValue);
boolean isModified = false;
if (dbConn.getAdditionalParams() != null && dbConn.getAdditionalParams().equals(oldValue)) {
dbConn.setAdditionalParams(newValue);
isModified = true;
} else if (dbConn.getUsername() != null && dbConn.getUsername().equals(oldValue)) {
dbConn.setUsername(newValue);
isModified = true;
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
dbConn.setPassword(newValue);
isModified = true;
} else if (dbConn.getServerName() != null && dbConn.getServerName().equals(oldValue)) {
dbConn.setServerName(newValue);
isModified = true;
} else if (dbConn.getPort() != null && dbConn.getPort().equals(oldValue)) {
dbConn.setPort(newValue);
isModified = true;
} else if (dbConn.getSID() != null && dbConn.getSID().equals(oldValue)) {
dbConn.setSID(newValue);
isModified = true;
} else if (dbConn.getDbmsId() != null && dbConn.getDbmsId().equals(oldValue)) {
dbConn.setDbmsId(newValue);
isModified = true;
} else if (dbConn.getDriverClass() != null && dbConn.getDriverClass().equals(oldValue)) {
dbConn.setDriverClass(newValue);
isModified = true;
} else if (dbConn.getDriverJarPath() != null && dbConn.getDriverJarPath().equals(oldValue)) {
dbConn.setDriverJarPath(newValue);
isModified = true;
} else if (dbConn.getURL() != null && dbConn.getURL().equals(oldValue)) {
dbConn.setURL(newValue);
isModified = true;
} else if (dbConn.getUiSchema() != null && dbConn.getUiSchema().equals(oldValue)) {
// Added by Marvin Wang on Nov.7, 2012 for bug TDI-12596, because schema can not
// be
// propagated to metadata db.
dbConn.setUiSchema(newValue);
isModified = true;
} else {
isModified = updateParameters(dbConn, oldValue, newValue);
}
return isModified || compPropertiesResult;
}
private boolean updateFileExcelConnectionParam(FileExcelConnection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.getFirstColumn() != null && conn.getFirstColumn().equals(oldValue)) {
conn.setFirstColumn(newValue);
isModified = true;
} else if (conn.getLastColumn() != null && conn.getLastColumn().equals(oldValue)) {
conn.setLastColumn(newValue);
isModified = true;
} else if (conn.getThousandSeparator() != null && conn.getThousandSeparator().equals(oldValue)) {
conn.setThousandSeparator(newValue);
isModified = true;
} else if (conn.getDecimalSeparator() != null && conn.getDecimalSeparator().equals(oldValue)) {
conn.setDecimalSeparator(newValue);
isModified = true;
} else if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
conn.setFilePath(newValue);
isModified = true;
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
conn.setEncoding(newValue);
isModified = true;
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
conn.setLimitValue(newValue);
isModified = true;
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
conn.setHeaderValue(newValue);
isModified = true;
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
conn.setFooterValue(newValue);
isModified = true;
}
return isModified;
}
private boolean updatDelimitedFileConnectionParam(DelimitedFileConnection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
conn.setFilePath(newValue);
isModified = true;
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
conn.setEncoding(newValue);
isModified = true;
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
conn.setLimitValue(newValue);
isModified = true;
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
conn.setHeaderValue(newValue);
isModified = true;
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
conn.setFooterValue(newValue);
isModified = true;
} else if (conn.getRowSeparatorValue() != null && conn.getRowSeparatorValue().equals(oldValue)) {
conn.setRowSeparatorValue(newValue);
isModified = true;
} else if (conn.getFieldSeparatorValue() != null && conn.getFieldSeparatorValue().equals(oldValue)) {
conn.setFieldSeparatorValue(newValue);
isModified = true;
}
return isModified;
}
private boolean updateRegexpFileConnectionParam(RegexpFileConnection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
conn.setFilePath(newValue);
isModified = true;
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
conn.setEncoding(newValue);
isModified = true;
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
conn.setLimitValue(newValue);
isModified = true;
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
conn.setHeaderValue(newValue);
isModified = true;
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
conn.setFooterValue(newValue);
isModified = true;
} else if (conn.getRowSeparatorValue() != null && conn.getRowSeparatorValue().equals(oldValue)) {
conn.setRowSeparatorValue(newValue);
isModified = true;
} else if (conn.getFieldSeparatorValue() != null && conn.getFieldSeparatorValue().equals(oldValue)) {
conn.setFieldSeparatorValue(newValue);
isModified = true;
}
return isModified;
}
private boolean updateLdifFileConnectionParam(LdifFileConnection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
conn.setFilePath(newValue);
isModified = true;
}
return isModified;
}
private boolean updatePositionalFileConnectionParam(PositionalFileConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
dbConn.setFilePath(newValue);
isModified = true;
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
dbConn.setEncoding(newValue);
isModified = true;
} else if (dbConn.getLimitValue() != null && dbConn.getLimitValue().equals(oldValue)) {
dbConn.setLimitValue(newValue);
isModified = true;
} else if (dbConn.getHeaderValue() != null && dbConn.getHeaderValue().equals(oldValue)) {
dbConn.setHeaderValue(newValue);
isModified = true;
} else if (dbConn.getFooterValue() != null && dbConn.getFooterValue().equals(oldValue)) {
dbConn.setFooterValue(newValue);
isModified = true;
} else if (dbConn.getRowSeparatorValue() != null && dbConn.getRowSeparatorValue().equals(oldValue)) {
dbConn.setRowSeparatorValue(newValue);
isModified = true;
} else if (dbConn.getFieldSeparatorValue() != null && dbConn.getFieldSeparatorValue().equals(oldValue)) {
dbConn.setFieldSeparatorValue(newValue);
isModified = true;
}
return isModified;
}
private boolean updateXmlFileConnectionParam(XmlFileConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
if (dbConn.getXmlFilePath() != null && dbConn.getXmlFilePath().equals(oldValue)) {
dbConn.setXmlFilePath(newValue);
isModified = true;
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
dbConn.setEncoding(newValue);
isModified = true;
} else if (dbConn.getOutputFilePath() != null && dbConn.getOutputFilePath().equals(oldValue)) {
dbConn.setOutputFilePath(newValue);
isModified = true;
}
EList schema = dbConn.getSchema();
if (schema != null && schema.size() > 0) {
if (schema.get(0) instanceof XmlXPathLoopDescriptor) {
XmlXPathLoopDescriptor descriptor = (XmlXPathLoopDescriptor) schema.get(0);
if (descriptor.getAbsoluteXPathQuery() != null && descriptor.getAbsoluteXPathQuery().equals(oldValue)) {
descriptor.setAbsoluteXPathQuery(newValue);
isModified = true;
}
}
}
return isModified;
}
private boolean updateSalesforceSchemaConnectionParam(SalesforceSchemaConnection ssConn, String oldValue, String newValue) {
boolean isModified = false;
if (ssConn.getWebServiceUrl() != null && ssConn.getWebServiceUrl().equals(oldValue)) {
ssConn.setWebServiceUrl(newValue);
isModified = true;
} else if (ssConn.getPassword() != null && ssConn.getPassword().equals(oldValue)) {
// in fact, because in context mode. can setPassword directly.
// ssConn.setPassword(ssConn.getValue(newValue,true));
ssConn.setPassword(newValue);
isModified = true;
} else if (ssConn.getUserName() != null && ssConn.getUserName().equals(oldValue)) {
ssConn.setUserName(newValue);
isModified = true;
} else if (ssConn.getTimeOut() != null && ssConn.getTimeOut().equals(oldValue)) {
ssConn.setTimeOut(newValue);
isModified = true;
} else if (ssConn.getBatchSize() != null && ssConn.getBatchSize().equals(oldValue)) {
ssConn.setBatchSize(newValue);
isModified = true;
} else if (ssConn.getQueryCondition() != null && ssConn.getQueryCondition().equals(oldValue)) {
ssConn.setQueryCondition(newValue);
isModified = true;
}
return isModified;
}
private boolean updateWSDLSchemaConnectionParam(WSDLSchemaConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
if (dbConn.getUserName() != null && dbConn.getUserName().equals(oldValue)) {
dbConn.setUserName(newValue);
isModified = true;
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
dbConn.setPassword(newValue);
isModified = true;
} else if (dbConn.getProxyHost() != null && dbConn.getProxyHost().equals(oldValue)) {
dbConn.setProxyHost(newValue);
isModified = true;
} else if (dbConn.getProxyPassword() != null && dbConn.getProxyPassword().equals(oldValue)) {
dbConn.setProxyPassword(newValue);
isModified = true;
} else if (dbConn.getProxyUser() != null && dbConn.getProxyUser().equals(oldValue)) {
dbConn.setProxyUser(newValue);
isModified = true;
} else if (dbConn.getProxyPort() != null && dbConn.getProxyPort().equals(oldValue)) {
dbConn.setProxyPort(newValue);
isModified = true;
}
return isModified;
}
private boolean updateSAPConnectionParam(SAPConnection sapConn, String oldValue, String newValue) {
boolean isModified = false;
if (sapConn.getClient() != null && sapConn.getClient().equals(oldValue)) {
sapConn.setClient(newValue);
isModified = true;
} else if (sapConn.getUsername() != null && sapConn.getUsername().equals(oldValue)) {
sapConn.setUsername(newValue);
isModified = true;
} else if (sapConn.getPassword() != null && sapConn.getPassword().equals(oldValue)) {
sapConn.setPassword(newValue);
isModified = true;
} else if (sapConn.getHost() != null && sapConn.getHost().equals(oldValue)) {
sapConn.setHost(newValue);
isModified = true;
} else if (sapConn.getSystemNumber() != null && sapConn.getSystemNumber().equals(oldValue)) {
sapConn.setSystemNumber(newValue);
isModified = true;
} else if (sapConn.getLanguage() != null && sapConn.getLanguage().equals(oldValue)) {
sapConn.setLanguage(newValue);
isModified = true;
} else {
for (AdditionalConnectionProperty sapProperty : sapConn.getAdditionalProperties()) {
if (sapProperty.getValue() != null && sapProperty.getValue().equals(oldValue)) {
sapProperty.setValue(newValue);
isModified = true;
}
}
}
return isModified;
}
@Override
public boolean accept(Connection connection) {
if (connection instanceof DatabaseConnection || connection instanceof FileExcelConnection
|| connection instanceof DelimitedFileConnection || connection instanceof RegexpFileConnection
|| connection instanceof LdifFileConnection || connection instanceof PositionalFileConnection
|| connection instanceof XmlFileConnection || connection instanceof SalesforceSchemaConnection
|| connection instanceof WSDLSchemaConnection || connection instanceof SAPConnection) {
return true;
}
return false;
}
}

View File

@@ -21,14 +21,12 @@ import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -41,11 +39,8 @@ import org.talend.commons.exception.PersistenceException;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.ICoreService;
import org.talend.core.IRepositoryContextUpdateService;
import org.talend.core.IService;
import org.talend.core.ITDQPatternService;
import org.talend.core.ITDQRepositoryService;
import org.talend.core.database.conn.ConnParameterKeys;
import org.talend.core.database.conn.template.EDatabaseConnTemplate;
import org.talend.core.hadoop.BigDataBasicUtil;
import org.talend.core.hadoop.HadoopConstants;
import org.talend.core.hadoop.IHadoopClusterService;
@@ -54,28 +49,23 @@ import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.context.JobContext;
import org.talend.core.model.context.JobContextManager;
import org.talend.core.model.context.JobContextParameter;
import org.talend.core.model.context.link.ContextLink;
import org.talend.core.model.context.link.ContextLinkService;
import org.talend.core.model.context.link.ContextParamLink;
import org.talend.core.model.context.link.ItemContextLink;
import org.talend.core.model.metadata.IMetadataColumn;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MetadataSchemaType;
import org.talend.core.model.metadata.builder.connection.AdditionalConnectionProperty;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.connection.DelimitedFileConnection;
import org.talend.core.model.metadata.builder.connection.FileExcelConnection;
import org.talend.core.model.metadata.builder.connection.GenericSchemaConnection;
import org.talend.core.model.metadata.builder.connection.LdifFileConnection;
import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.metadata.builder.connection.PositionalFileConnection;
import org.talend.core.model.metadata.builder.connection.QueriesConnection;
import org.talend.core.model.metadata.builder.connection.Query;
import org.talend.core.model.metadata.builder.connection.RegexpFileConnection;
import org.talend.core.model.metadata.builder.connection.SAPConnection;
import org.talend.core.model.metadata.builder.connection.SAPFunctionUnit;
import org.talend.core.model.metadata.builder.connection.SAPIDocUnit;
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
import org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection;
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
import org.talend.core.model.metadata.builder.connection.XmlXPathLoopDescriptor;
import org.talend.core.model.process.IContext;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IContextParameter;
@@ -94,10 +84,12 @@ import org.talend.core.model.relationship.RelationshipItemBuilder;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.update.extension.UpdateManagerProviderDetector;
import org.talend.core.model.utils.ContextParameterUtils;
import org.talend.core.model.utils.UpdateRepositoryHelper;
import org.talend.core.prefs.ITalendCorePrefConstants;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.i18n.Messages;
import org.talend.core.runtime.services.IGenericDBService;
import org.talend.core.service.IMRProcessService;
import org.talend.core.service.IMetadataManagmentService;
import org.talend.core.service.IStormProcessService;
@@ -110,7 +102,6 @@ import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.runprocess.ItemCacheManager;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.model.IProxyRepositoryService;
import org.talend.repository.model.IRepositoryService;
import org.talend.repository.model.RepositoryNode;
@@ -119,6 +110,12 @@ import org.talend.repository.model.RepositoryNode;
*/
public abstract class RepositoryUpdateManager {
private static final Logger LOGGER = Logger.getLogger(RepositoryUpdateManager.class);
private static final IProxyRepositoryFactory FACTORY = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
private static List<IRepositoryContextUpdateService> CONTEXT_UPDATE_SERVICE_LIST = null;
/**
* for repository context rename.
*/
@@ -147,7 +144,7 @@ public abstract class RepositoryUpdateManager {
*/
protected Object parameter;
private Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
private Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
private boolean onlyOpeningJob = false;
@@ -279,7 +276,7 @@ public abstract class RepositoryUpdateManager {
private boolean openRenameCheckedDialog() {
return MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),
Messages.getString("RepositoryUpdateManager.RenameContextTitle"), //$NON-NLS-1$
Messages.getString("RepositoryUpdateManager.RenameContextMessages")); //$NON-NLS-1$
Messages.getString("RepositoryUpdateManager.RenameContextMessagesNoBuiltIn")); //$NON-NLS-1$
}
@@ -288,7 +285,7 @@ public abstract class RepositoryUpdateManager {
}
public boolean needForcePropagation() {
return needForcePropagationForContext() || (getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty());
return getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty();
}
private boolean needForcePropagationForContext() {
@@ -687,469 +684,191 @@ public abstract class RepositoryUpdateManager {
if (valueMap == null) {
return;
}
Set<String> set = valueMap.keySet();
List<String> list = new ArrayList<String>(set);
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
for (String newValue : list) {
String oldValue = valueMap.get(newValue);
oldValue = "context." + oldValue;
newValue = "context." + newValue;
List<IRepositoryViewObject> dbConnList = factory.getAll(ERepositoryObjectType.METADATA_CONNECTIONS, true);
for (IRepositoryViewObject obj : dbConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof DatabaseConnection) {
DatabaseConnection dbConn = (DatabaseConnection) conn;
if (dbConn.getAdditionalParams() != null && dbConn.getAdditionalParams().equals(oldValue)) {
dbConn.setAdditionalParams(newValue);
} else if (dbConn.getUsername() != null && dbConn.getUsername().equals(oldValue)) {
dbConn.setUsername(newValue);
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
dbConn.setPassword(newValue);
} else if (dbConn.getServerName() != null && dbConn.getServerName().equals(oldValue)) {
dbConn.setServerName(newValue);
} else if (dbConn.getPort() != null && dbConn.getPort().equals(oldValue)) {
dbConn.setPort(newValue);
} else if (dbConn.getSID() != null && dbConn.getSID().equals(oldValue)) {
dbConn.setSID(newValue);
} else if (dbConn.getDbmsId() != null && dbConn.getDbmsId().equals(oldValue)) {
dbConn.setDbmsId(newValue);
} else if (dbConn.getDriverClass() != null && dbConn.getDriverClass().equals(oldValue)) {
dbConn.setDriverClass(newValue);
} else if (dbConn.getDriverJarPath() != null && dbConn.getDriverJarPath().equals(oldValue)) {
dbConn.setDriverJarPath(newValue);
} else if (dbConn.getURL() != null && dbConn.getURL().equals(oldValue)) {
dbConn.setURL(newValue);
} else if (dbConn.getUiSchema() != null && dbConn.getUiSchema().equals(oldValue)) {
// Added by Marvin Wang on Nov.7, 2012 for bug TDI-12596, because schema can not be
// propagated to metadata db.
dbConn.setUiSchema(newValue);
} else {
updateParameters(dbConn, oldValue, newValue);
}
factory.save(item);
}
}
}
}
List<IRepositoryViewObject> dbConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_CONNECTIONS, true);
for (IRepositoryViewObject obj : dbConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
List<IRepositoryViewObject> excelConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_EXCEL, true);
for (IRepositoryViewObject obj : excelConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof FileExcelConnection) {
if (((FileExcelConnection) conn).getFirstColumn() != null
&& ((FileExcelConnection) conn).getFirstColumn().equals(oldValue)) {
((FileExcelConnection) conn).setFirstColumn(newValue);
} else if (((FileExcelConnection) conn).getLastColumn() != null
&& ((FileExcelConnection) conn).getLastColumn().equals(oldValue)) {
((FileExcelConnection) conn).setLastColumn(newValue);
} else if (((FileExcelConnection) conn).getThousandSeparator() != null
&& ((FileExcelConnection) conn).getThousandSeparator().equals(oldValue)) {
((FileExcelConnection) conn).setThousandSeparator(newValue);
} else if (((FileExcelConnection) conn).getDecimalSeparator() != null
&& ((FileExcelConnection) conn).getDecimalSeparator().equals(oldValue)) {
((FileExcelConnection) conn).setDecimalSeparator(newValue);
} else if (((FileExcelConnection) conn).getFilePath() != null
&& ((FileExcelConnection) conn).getFilePath().equals(oldValue)) {
((FileExcelConnection) conn).setFilePath(newValue);
} else if (((FileExcelConnection) conn).getEncoding() != null
&& ((FileExcelConnection) conn).getEncoding().equals(oldValue)) {
((FileExcelConnection) conn).setEncoding(newValue);
} else if (((FileExcelConnection) conn).getLimitValue() != null
&& ((FileExcelConnection) conn).getLimitValue().equals(oldValue)) {
((FileExcelConnection) conn).setLimitValue(newValue);
} else if (((FileExcelConnection) conn).getHeaderValue() != null
&& ((FileExcelConnection) conn).getHeaderValue().equals(oldValue)) {
((FileExcelConnection) conn).setHeaderValue(newValue);
} else if (((FileExcelConnection) conn).getFooterValue() != null
&& ((FileExcelConnection) conn).getFooterValue().equals(oldValue)) {
((FileExcelConnection) conn).setFooterValue(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> excelConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_EXCEL, true);
for (IRepositoryViewObject obj : excelConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> deliConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_DELIMITED, true);
for (IRepositoryViewObject obj : deliConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof DelimitedFileConnection) {
if (((DelimitedFileConnection) conn).getFilePath() != null
&& ((DelimitedFileConnection) conn).getFilePath().equals(oldValue)) {
((DelimitedFileConnection) conn).setFilePath(newValue);
} else if (((DelimitedFileConnection) conn).getEncoding() != null
&& ((DelimitedFileConnection) conn).getEncoding().equals(oldValue)) {
((DelimitedFileConnection) conn).setEncoding(newValue);
} else if (((DelimitedFileConnection) conn).getLimitValue() != null
&& ((DelimitedFileConnection) conn).getLimitValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setLimitValue(newValue);
} else if (((DelimitedFileConnection) conn).getHeaderValue() != null
&& ((DelimitedFileConnection) conn).getHeaderValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setHeaderValue(newValue);
} else if (((DelimitedFileConnection) conn).getFooterValue() != null
&& ((DelimitedFileConnection) conn).getFooterValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setFooterValue(newValue);
} else if (((DelimitedFileConnection) conn).getRowSeparatorValue() != null
&& ((DelimitedFileConnection) conn).getRowSeparatorValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setRowSeparatorValue(newValue);
} else if (((DelimitedFileConnection) conn).getFieldSeparatorValue() != null
&& ((DelimitedFileConnection) conn).getFieldSeparatorValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setFieldSeparatorValue(newValue);
}
factory.save(item);
}
List<IRepositoryViewObject> deliConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_DELIMITED, true);
for (IRepositoryViewObject obj : deliConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> regConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_REGEXP, true);
for (IRepositoryViewObject obj : regConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> ldifConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_LDIF, true);
for (IRepositoryViewObject obj : ldifConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> posiConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_POSITIONAL, true);
for (IRepositoryViewObject obj : posiConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> xmlConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_XML, true);
for (IRepositoryViewObject obj : xmlConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> saleConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA, true);
for (IRepositoryViewObject obj : saleConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> wsdlConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_WSDL_SCHEMA, true);
for (IRepositoryViewObject obj : wsdlConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
}
}
}
List<IRepositoryViewObject> sapConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_SAPCONNECTIONS, true);
for (IRepositoryViewObject obj : sapConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
List<IRepositoryViewObject> regConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_REGEXP, true);
for (IRepositoryViewObject obj : regConnList) {
}
for (String updateType : UpdateRepositoryHelper.getAllHadoopConnectionTypes()) {
List<IRepositoryViewObject> hadoopConnList = FACTORY
.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, updateType), true);
for (IRepositoryViewObject obj : hadoopConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof RegexpFileConnection) {
if (((RegexpFileConnection) conn).getFilePath() != null
&& ((RegexpFileConnection) conn).getFilePath().equals(oldValue)) {
((RegexpFileConnection) conn).setFilePath(newValue);
} else if (((RegexpFileConnection) conn).getEncoding() != null
&& ((RegexpFileConnection) conn).getEncoding().equals(oldValue)) {
((RegexpFileConnection) conn).setEncoding(newValue);
} else if (((RegexpFileConnection) conn).getLimitValue() != null
&& ((RegexpFileConnection) conn).getLimitValue().equals(oldValue)) {
((RegexpFileConnection) conn).setLimitValue(newValue);
} else if (((RegexpFileConnection) conn).getHeaderValue() != null
&& ((RegexpFileConnection) conn).getHeaderValue().equals(oldValue)) {
((RegexpFileConnection) conn).setHeaderValue(newValue);
} else if (((RegexpFileConnection) conn).getFooterValue() != null
&& ((RegexpFileConnection) conn).getFooterValue().equals(oldValue)) {
((RegexpFileConnection) conn).setFooterValue(newValue);
} else if (((RegexpFileConnection) conn).getRowSeparatorValue() != null
&& ((RegexpFileConnection) conn).getRowSeparatorValue().equals(oldValue)) {
((RegexpFileConnection) conn).setRowSeparatorValue(newValue);
} else if (((RegexpFileConnection) conn).getFieldSeparatorValue() != null
&& ((RegexpFileConnection) conn).getFieldSeparatorValue().equals(oldValue)) {
((RegexpFileConnection) conn).setFieldSeparatorValue(newValue);
}
factory.save(item);
}
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
}
}
}
}
}
List<IRepositoryViewObject> ldifConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_LDIF, true);
for (IRepositoryViewObject obj : ldifConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof LdifFileConnection) {
LdifFileConnection dbConn = (LdifFileConnection) conn;
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
dbConn.setFilePath(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> posiConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_POSITIONAL, true);
for (IRepositoryViewObject obj : posiConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof PositionalFileConnection) {
PositionalFileConnection dbConn = (PositionalFileConnection) conn;
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
dbConn.setFilePath(newValue);
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
dbConn.setEncoding(newValue);
} else if (dbConn.getLimitValue() != null && dbConn.getLimitValue().equals(oldValue)) {
dbConn.setLimitValue(newValue);
} else if (dbConn.getHeaderValue() != null && dbConn.getHeaderValue().equals(oldValue)) {
dbConn.setHeaderValue(newValue);
} else if (dbConn.getFooterValue() != null && dbConn.getFooterValue().equals(oldValue)) {
dbConn.setFooterValue(newValue);
} else if (dbConn.getRowSeparatorValue() != null
&& dbConn.getRowSeparatorValue().equals(oldValue)) {
dbConn.setRowSeparatorValue(newValue);
} else if (dbConn.getFieldSeparatorValue() != null
&& dbConn.getFieldSeparatorValue().equals(oldValue)) {
dbConn.setFieldSeparatorValue(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> xmlConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_XML, true);
for (IRepositoryViewObject obj : xmlConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof XmlFileConnection) {
XmlFileConnection dbConn = (XmlFileConnection) conn;
if (dbConn.getXmlFilePath() != null && dbConn.getXmlFilePath().equals(oldValue)) {
dbConn.setXmlFilePath(newValue);
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
dbConn.setEncoding(newValue);
} else if (dbConn.getOutputFilePath() != null && dbConn.getOutputFilePath().equals(oldValue)) {
dbConn.setOutputFilePath(newValue);
}
EList schema = dbConn.getSchema();
if (schema != null && schema.size() > 0) {
if (schema.get(0) instanceof XmlXPathLoopDescriptor) {
XmlXPathLoopDescriptor descriptor = (XmlXPathLoopDescriptor) schema.get(0);
if (descriptor.getAbsoluteXPathQuery() != null
&& descriptor.getAbsoluteXPathQuery().equals(oldValue)) {
descriptor.setAbsoluteXPathQuery(newValue);
}
}
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> saleConnList = factory.getAll(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA, true);
for (IRepositoryViewObject obj : saleConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof SalesforceSchemaConnection) {
SalesforceSchemaConnection ssConn = (SalesforceSchemaConnection) conn;
if (ssConn.getWebServiceUrl() != null && ssConn.getWebServiceUrl().equals(oldValue)) {
ssConn.setWebServiceUrl(newValue);
} else if (ssConn.getPassword() != null && ssConn.getPassword().equals(oldValue)) {
// in fact, because in context mode. can setPassword directly.
// ssConn.setPassword(ssConn.getValue(newValue,true));
ssConn.setPassword(newValue);
} else if (ssConn.getUserName() != null && ssConn.getUserName().equals(oldValue)) {
ssConn.setUserName(newValue);
} else if (ssConn.getTimeOut() != null && ssConn.getTimeOut().equals(oldValue)) {
ssConn.setTimeOut(newValue);
} else if (ssConn.getBatchSize() != null && ssConn.getBatchSize().equals(oldValue)) {
ssConn.setBatchSize(newValue);
} else if (ssConn.getQueryCondition() != null && ssConn.getQueryCondition().equals(oldValue)) {
ssConn.setQueryCondition(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> wsdlConnList = factory.getAll(ERepositoryObjectType.METADATA_WSDL_SCHEMA, true);
for (IRepositoryViewObject obj : wsdlConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof WSDLSchemaConnection) {
WSDLSchemaConnection dbConn = (WSDLSchemaConnection) conn;
if (dbConn.getUserName() != null && dbConn.getUserName().equals(oldValue)) {
dbConn.setUserName(newValue);
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
dbConn.setPassword(newValue);
} else if (dbConn.getProxyHost() != null && dbConn.getProxyHost().equals(oldValue)) {
dbConn.setProxyHost(newValue);
} else if (dbConn.getProxyPassword() != null && dbConn.getProxyPassword().equals(oldValue)) {
dbConn.setProxyPassword(newValue);
} else if (dbConn.getProxyUser() != null && dbConn.getProxyUser().equals(oldValue)) {
dbConn.setProxyUser(newValue);
} else if (dbConn.getProxyPort() != null && dbConn.getProxyPort().equals(oldValue)) {
dbConn.setProxyPort(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> sapConnList = factory.getAll(ERepositoryObjectType.METADATA_SAPCONNECTIONS, true);
for (IRepositoryViewObject obj : sapConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof SAPConnection) {
SAPConnection sapConn = (SAPConnection) conn;
if (sapConn.getClient() != null && sapConn.getClient().equals(oldValue)) {
sapConn.setClient(newValue);
} else if (sapConn.getUsername() != null && sapConn.getUsername().equals(oldValue)) {
sapConn.setUsername(newValue);
} else if (sapConn.getPassword() != null && sapConn.getPassword().equals(oldValue)) {
sapConn.setPassword(newValue);
} else if (sapConn.getHost() != null && sapConn.getHost().equals(oldValue)) {
sapConn.setHost(newValue);
} else if (sapConn.getSystemNumber() != null && sapConn.getSystemNumber().equals(oldValue)) {
sapConn.setSystemNumber(newValue);
} else if (sapConn.getLanguage() != null && sapConn.getLanguage().equals(oldValue)) {
sapConn.setLanguage(newValue);
} else {
for (AdditionalConnectionProperty sapProperty : sapConn.getAdditionalProperties()) {
if (sapProperty.getValue() != null && sapProperty.getValue().equals(oldValue)) {
sapProperty.setValue(newValue);
}
}
}
factory.save(item);
}
}
}
}
}
for (String updateType : UpdateRepositoryHelper.getAllHadoopConnectionTypes()) {
List<IRepositoryViewObject> hadoopConnList = factory
.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, updateType), true);
for (IRepositoryViewObject obj : hadoopConnList) {
Item item = obj.getProperty().getItem();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
for (ERepositoryObjectType objectType : service.getAllGenericMetadataDBRepositoryType()) {
List<IRepositoryViewObject> repositoryObjects = FACTORY.getAll(objectType);
for (IRepositoryViewObject object : repositoryObjects) {
Item item = object.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (GlobalServiceRegister.getDefault()
.isServiceRegistered(IRepositoryContextUpdateService.class)) {
IService service = GlobalServiceRegister.getDefault()
.getService(IRepositoryContextUpdateService.class);
IRepositoryContextUpdateService repositoryContextUpdateService = (IRepositoryContextUpdateService) service;
repositoryContextUpdateService.updateRelatedContextVariable(conn, oldValue, newValue);
}
factory.save(item);
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
}
}
}
private static void updateConnectionContextParam(ConnectionItem conntectionItem, ContextItem citem,
Map<String, String> newToOldValueMap) throws PersistenceException {
boolean isModified = false;
if (conntectionItem != null && conntectionItem.getConnection() != null && citem != null
&& citem.getProperty() != null
&& StringUtils.equals(conntectionItem.getConnection().getContextId(), citem.getProperty().getId())) {
for (String newValue : newToOldValueMap.keySet()) {
String oldValue = newToOldValueMap.get(newValue);
boolean result = updateConnectionContextParam(conntectionItem, oldValue, newValue);
isModified = isModified || result;
}
if (isModified) {
FACTORY.save(conntectionItem, false);
}
}
}
private static boolean updateConnectionContextParam(ConnectionItem conntectionItem, String oldValue, String newValue) {
Connection conn = conntectionItem.getConnection();
if (conn.isContextMode()) {
IRepositoryContextUpdateService updater = null;
updater = findContextParameterUpdater(conn);
if (updater != null) {
return updater.updateContextParameter(conn, addContextParamPrefix(oldValue), addContextParamPrefix(newValue));
}
}
return false;
}
public static void updateConnectionContextParam(RepositoryNode connNode) throws PersistenceException {
if (connNode.getObject() == null || connNode.getObject().getProperty() == null
|| connNode.getObject().getProperty().getItem() == null) {
return;
}
ConnectionItem conntectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
updateConnectionContextParam(conntectionItem);
}
public static void updateConnectionContextParam(ConnectionItem conntectionItem)
throws PersistenceException {
Connection conn = conntectionItem.getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
ItemContextLink itemContextLink = null;
try {
itemContextLink = ContextLinkService.getInstance().loadContextLinkFromJson(conntectionItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
ContextLink contextLink = null;
if (itemContextLink != null) {
contextLink = itemContextLink.findContextLink(null, conn.getContextName());
}
if (contextLink != null) {
ContextType contextType = ContextUtils.getContextTypeByName(contextItem, conn.getContextName(), false);
IRepositoryContextUpdateService updateServce = findContextParameterUpdater(conn);
if (updateServce != null) {
boolean isModified = false;
for (ContextParamLink paramLink : contextLink.getParameterList()) {
ContextParameterType paramType = ContextUtils.getContextParameterTypeByName(contextType,
paramLink.getName());
if (paramType == null) {
paramType = ContextUtils.getContextParameterTypeById(contextType, paramLink.getId(), true);
if (paramType != null) {
boolean result = updateServce.updateContextParameter(conn,
addContextParamPrefix(paramLink.getName()), addContextParamPrefix(paramType.getName()));
isModified = isModified || result;
}
}
}
}
}
}
}
private void updateParameters(DatabaseConnection dbConn, String oldValue, String newValue) {
EMap<String, String> parameters = dbConn.getParameters();
if (parameters != null && !parameters.isEmpty()) {
for (Entry<String, String> entry : parameters.entrySet()) {
if (entry != null) {
String value = entry.getValue();
if (StringUtils.equals(value, oldValue)) {
entry.setValue(newValue);
if (isModified) {
FACTORY.save(conntectionItem, false);
}
}
}
}
updateHadoopPropertiesForDbConnection(dbConn, oldValue, newValue);
}
private void updateHadoopPropertiesForDbConnection(DatabaseConnection dbConn, String oldValue, String newValue) {
EMap<String, String> parameters = dbConn.getParameters();
String databaseType = parameters.get(ConnParameterKeys.CONN_PARA_KEY_DB_TYPE);
String hadoopProperties = "";
if (databaseType != null) {
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES);
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES);
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES);
}
List<Map<String, Object>> hadoopPropertiesList = HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties);
if (!hadoopPropertiesList.isEmpty()) {
for (Map<String, Object> propertyMap : hadoopPropertiesList) {
String propertyValue = (String) propertyMap.get("VALUE");
if (propertyValue.equals(oldValue)) {
propertyMap.put("VALUE", newValue);
}
}
String hadoopPropertiesJson = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopPropertiesList);
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES, hadoopPropertiesJson);
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES, hadoopPropertiesJson);
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES, hadoopPropertiesJson);
}
}
private static String addContextParamPrefix(String value) {
if (!value.startsWith(ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX)) {
value = ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + value;
}
return value;
}
public static IEditorReference[] getEditors() {
if (CommonsPlugin.isHeadless() || !getProxyRepositoryFactory().isFullLogonFinished()) {
if (CommonsPlugin.isHeadless() || !FACTORY.isFullLogonFinished()) {
return new IEditorReference[0];
}
final List<IEditorReference> list = new ArrayList<IEditorReference>();
@@ -1245,6 +964,7 @@ public abstract class RepositoryUpdateManager {
jobParam.setSource(repositoryId);
jobParam.setType(repoParam.getType());
jobParam.setValue(repoParam.getValue());
jobParam.setInternalId(repoParam.getInternalId());
jobContext.getContextParameterList().add(jobParam);
}
addContextGroupList.add(jobContext);
@@ -1529,7 +1249,6 @@ public abstract class RepositoryUpdateManager {
*/
public static boolean updateServices(ConnectionItem connectionItem, boolean show, final boolean onlySimpleShow) {
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.SERVICES_RELATION);
@@ -1623,7 +1342,6 @@ public abstract class RepositoryUpdateManager {
* @return
*/
public static boolean updateValidationRuleConnection(ConnectionItem connectionItem, boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.VALIDATION_RULE_RELATION);
@@ -1977,7 +1695,6 @@ public abstract class RepositoryUpdateManager {
public static boolean updateWSDLConnection(ConnectionItem connectionItem, boolean show, final boolean onlySimpleShow) {
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
@@ -2062,7 +1779,6 @@ public abstract class RepositoryUpdateManager {
* @return
*/
public static boolean updateSAPFunction(final SAPFunctionUnit sapFunction, boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(sapFunction.getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
@@ -2091,8 +1807,6 @@ public abstract class RepositoryUpdateManager {
* @return
*/
public static boolean updateSAPIDoc(final SAPIDocUnit sapIDoc, boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(sapIDoc.getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
@@ -2151,8 +1865,6 @@ public abstract class RepositoryUpdateManager {
protected static boolean updateSchema(final Object table, ConnectionItem connItem, Map<String, String> schemaRenamedMap,
boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo((connItem).getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
@@ -2208,8 +1920,6 @@ public abstract class RepositoryUpdateManager {
}
private static boolean updateQueryObject(Object parameter, boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = null;
if (parameter instanceof Query) {
relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(((Query) parameter).getId(),
@@ -2340,7 +2050,7 @@ public abstract class RepositoryUpdateManager {
repositoryUpdateManager.setContextRenamedMap(repositoryRenamedMap);
// newly added parameters
Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
if (!repositoryContextManager.getNewParameters().isEmpty()) {
newParametersMap.put(item, repositoryContextManager.getNewParameters());
}
@@ -2352,16 +2062,14 @@ public abstract class RepositoryUpdateManager {
ExceptionHandler.process(e);
}
return repositoryUpdateManager.doWork(show, onlySimpleShow);
}
public Map<ContextItem, Set<String>> getNewParametersMap() {
public Map<Item, Set<String>> getNewParametersMap() {
return newParametersMap;
}
public void setNewParametersMap(Map<ContextItem, Set<String>> newParametersMap) {
public void setNewParametersMap(Map<Item, Set<String>> newParametersMap) {
this.newParametersMap = newParametersMap;
}
@@ -2464,7 +2172,6 @@ public abstract class RepositoryUpdateManager {
// Added TDQ-11688 20170309 yyin
public static boolean updateDQPattern(Item patternItem) {
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(patternItem.getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PATTERN_RELATION);
@@ -2482,9 +2189,19 @@ public abstract class RepositoryUpdateManager {
return repositoryUpdateManager.doWork(true, false);
}
private static IProxyRepositoryFactory getProxyRepositoryFactory() {
return ((IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class))
.getProxyRepositoryFactory();
}
public static IRepositoryContextUpdateService findContextParameterUpdater(Connection connection) {
if (CONTEXT_UPDATE_SERVICE_LIST == null) {
CONTEXT_UPDATE_SERVICE_LIST = GlobalServiceRegister.getDefault()
.findAllService(IRepositoryContextUpdateService.class);
}
for (IRepositoryContextUpdateService updater : CONTEXT_UPDATE_SERVICE_LIST) {
if (updater.accept(connection)) {
return updater;
}
}
LOGGER.error(
"Can't find any connection context parameter updater for connection type:" + connection.getClass().getName());
return null;
}
}

View File

@@ -187,11 +187,13 @@ public class TalendLibsServerManager {
* Check user library connection with the setting from remote administrator
*
* @return
* @throws PersistenceException
*/
public boolean canConnectUserLibrary() {
public boolean canConnectUserLibrary() throws PersistenceException {
boolean canConnect = false;
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
RepositoryContext repositoryContext = factory.getRepositoryContext();
ArtifactRepositoryBean bean = null;
try {
if (repositoryContext != null && repositoryContext.getFields() != null && !factory.isLocalConnectionProvider()
&& !repositoryContext.isOffline()) {
@@ -208,7 +210,7 @@ public class TalendLibsServerManager {
&& GlobalServiceRegister.getDefault().isServiceRegistered(IRemoteService.class)) {
IRemoteService remoteService = (IRemoteService) GlobalServiceRegister.getDefault()
.getService(IRemoteService.class);
ArtifactRepositoryBean bean = remoteService.getLibNexusServer(userName, password, adminUrl);
bean = remoteService.getLibNexusServer(userName, password, adminUrl);
if (bean != null) {
IRepositoryArtifactHandler handler = RepositoryArtifactHandlerManager.getRepositoryHandler(bean);
if (handler.checkConnection()) {
@@ -223,6 +225,9 @@ public class TalendLibsServerManager {
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (bean == null) {
throw new PersistenceException(Messages.getString("TalendLibsServerManager.cannotGetUserLibraryServer"));
}
return canConnect;
}

View File

@@ -32,8 +32,12 @@ public class LastGenerationInfo {
private HashMap<String, Set<ModuleNeeded>> modulesNeededWithSubjobPerJob;
private HashMap<String, Set<ModuleNeeded>> highPriorityModuleNeededPerJob;
private HashMap<String, Set<ModuleNeeded>> highPriorityModuleNeeded;
private HashMap<String, Set<ModuleNeeded>> testcaseModuleNeeded;
private HashMap<String, Set<String>> routinesNeededWithSubjobPerJob;
private HashMap<String, Set<String>> contextPerJob;
@@ -52,7 +56,9 @@ public class LastGenerationInfo {
modulesNeededPerJob = new HashMap<String, Set<ModuleNeeded>>();
contextPerJob = new HashMap<String, Set<String>>();
modulesNeededWithSubjobPerJob = new HashMap<String, Set<ModuleNeeded>>();
highPriorityModuleNeededPerJob = new HashMap<>();
highPriorityModuleNeeded = new HashMap<>();
testcaseModuleNeeded = new HashMap<>();
lastGeneratedjobs = new HashSet<JobInfo>();
routinesNeededPerJob = new HashMap<String, Set<String>>();
routinesNeededWithSubjobPerJob = new HashMap<String, Set<String>>();
@@ -235,6 +241,22 @@ public class LastGenerationInfo {
return routinesNeededPerJob.get(key);
}
public Set<ModuleNeeded> getHighPriorityModuleNeededPerJob(String jobId, String jobVersion) {
String key = getProcessKey(jobId, jobVersion);
if (!highPriorityModuleNeededPerJob.containsKey(key)) {
highPriorityModuleNeededPerJob.put(key, new LinkedHashSet<>());
}
return highPriorityModuleNeededPerJob.get(key);
}
public void setHighPriorityModuleNeededPerJob(String jobId, String jobVersion, Set<ModuleNeeded> moduleNeeded) {
String key = getProcessKey(jobId, jobVersion);
if (!highPriorityModuleNeededPerJob.containsKey(key)) {
highPriorityModuleNeededPerJob.put(key, new LinkedHashSet<>());
}
highPriorityModuleNeededPerJob.get(key).addAll(moduleNeeded);
}
public Set<ModuleNeeded> getHighPriorityModuleNeeded(String jobId, String jobVersion) {
String key = getProcessKey(jobId, jobVersion);
if (!highPriorityModuleNeeded.containsKey(key)) {
@@ -251,7 +273,20 @@ public class LastGenerationInfo {
highPriorityModuleNeeded.get(key).addAll(moduleNeeded);
}
public Set<ModuleNeeded> getTestcaseModuleNeeded(String jobId, String jobVersion) {
String key = getProcessKey(jobId, jobVersion);
if (!testcaseModuleNeeded.containsKey(key)) {
testcaseModuleNeeded.put(key, new HashSet<>());
}
return testcaseModuleNeeded.get(key);
}
public void setTestcaseModuleNeeded(String jobId, String jobVersion, Set<ModuleNeeded> modulesNeeded) {
testcaseModuleNeeded.put(getProcessKey(jobId, jobVersion), new HashSet<>(modulesNeeded));
}
public void clearHighPriorityModuleNeeded() {
highPriorityModuleNeededPerJob.clear();
highPriorityModuleNeeded.clear();
}
@@ -292,26 +327,19 @@ public class LastGenerationInfo {
routinesNeededWithSubjobPerJob.put(key, new HashSet<String>(modulesNeeded));
}
public void clearModulesNeededWithSubjobPerJob() {
if (!modulesNeededWithSubjobPerJob.isEmpty()) {
modulesNeededWithSubjobPerJob.clear();
}
}
/**
* Clear modules per job cache, not thread safe
*/
public void clearModulesNeededPerJob() {
if (!modulesNeededPerJob.isEmpty()) {
modulesNeededPerJob.clear();
}
public void clearCaches() {
clearHighPriorityModuleNeeded();
modulesNeededPerJob.clear();
modulesNeededWithSubjobPerJob.clear();
testcaseModuleNeeded.clear();
}
public void clean() {
modulesNeededPerJob.clear();
routinesNeededPerJob.clear();
modulesNeededWithSubjobPerJob.clear();
highPriorityModuleNeeded.clear();
clearHighPriorityModuleNeeded();
testcaseModuleNeeded.clear();
routinesNeededWithSubjobPerJob.clear();
contextPerJob.clear();

View File

@@ -64,7 +64,10 @@ public interface TalendProcessOptionConstants {
public static final int MODULES_WITH_INDEPENDENT = 1 << 2;
// include joblet module but without joblet's dependencies
/**
* @Deprecated will get all modules of node inside joblet recursively, use {@link #MODULES_DEFAULT} instead.
*/
@Deprecated
public static final int MODULES_WITH_JOBLET = 1 << 3;
public static final int MODULES_FOR_MR = 1 << 4;

View File

@@ -64,4 +64,8 @@ public interface IGenericDBService extends IService{
public ERepositoryObjectType getExtraDBType(ERepositoryObjectType type);
public void updateCompPropertiesForContextMode(Connection connection, Map<String, String> contextVarMap);
public List<ERepositoryObjectType> getAllGenericMetadataDBRepositoryType();
}

View File

@@ -18,7 +18,6 @@ import java.util.Set;
import org.apache.log4j.Level;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -26,6 +25,7 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.IService;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.language.ICodeProblemsChecker;
@@ -244,4 +244,13 @@ public interface IRunProcessService extends IService {
public IFolder getJavaProjectExternalResourcesFolder(IProcess process);
public boolean isCIMode();
public static IRunProcessService get() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
return GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
}
return null;
}
}

View File

@@ -21,6 +21,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -91,11 +92,14 @@ public final class ProjectManager {
private Set<Object> updatedRemoteHandlerRecords;
private Set<Project> tempProjects;
private ProjectManager() {
beforeLogonRecords = new HashSet<String>();
logonRecords = new HashSet<String>();
migrationRecords = new HashSet<String>();
updatedRemoteHandlerRecords = new HashSet<Object>();
tempProjects = new HashSet<>();
initCurrentProject();
}
@@ -106,6 +110,18 @@ public final class ProjectManager {
return singleton;
}
public void clearTempProjects() {
tempProjects.clear();
}
public boolean removeTempProject(Project project) {
return tempProjects.remove(project);
}
public boolean addTempProject(Project project) {
return tempProjects.add(project);
}
public Project getProjectFromProjectLabel(String label) {
if (currentProject == null) {
initCurrentProject();
@@ -119,6 +135,12 @@ public final class ProjectManager {
return project;
}
}
for (Project project : tempProjects) {
if (StringUtils.equals(project.getLabel(), label)) {
return project;
}
}
return null;
}
@@ -136,6 +158,11 @@ public final class ProjectManager {
return project;
}
}
for (Project project : tempProjects) {
if (StringUtils.equals(project.getTechnicalLabel(), label)) {
return project;
}
}
return null;
}

View File

@@ -30,6 +30,7 @@ public enum ERepositoryActionName {
DELETE_TO_RECYCLE_BIN("delete to recycle bin"), //$NON-NLS-1$
DELETE_FOREVER("delete forever"), //$NON-NLS-1$
AFTER_DELETE("after delete"), //$NON-NLS-1$
// these actions bellow are only for jobs and joblet actually, need to review.

View File

@@ -33,6 +33,8 @@ public class RepositoryConstants {
public static final String PROJECT_BRANCH_ID = "repository.project.branch"; //$NON-NLS-1$
public static final String PROJECT_ID = "repository.project.id";
public static final String IMG_DIRECTORY = "images"; //$NON-NLS-1$
public static final String IMG_DIRECTORY_OF_JOB_OUTLINE = "images/job_outlines"; //$NON-NLS-1$

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core.ui</artifactId>

View File

@@ -12,6 +12,7 @@
// ============================================================================
package org.talend.core.ui.token;
import org.apache.commons.codec.digest.DigestUtils;
import org.eclipse.jface.preference.IPreferenceStore;
import org.talend.commons.utils.VersionUtils;
import org.talend.core.GlobalServiceRegister;
@@ -49,7 +50,11 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
public static String calcUniqueId() {
return TokenGenerator.generateMachineToken((src) -> StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(src));
}
public static String hashUniqueId() {
return TokenGenerator.generateMachineToken((src) -> DigestUtils.sha256Hex(src));
}
/*
* (non-Javadoc)
*
@@ -61,7 +66,7 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
// version
tokenStudioObject.put(VERSION.getKey(), VersionUtils.getInternalVersion());
// uniqueId
tokenStudioObject.put(UNIQUE_ID.getKey(), calcUniqueId());
tokenStudioObject.put(UNIQUE_ID.getKey(), hashUniqueId());
// typeStudio
if (GlobalServiceRegister.getDefault().isServiceRegistered(IBrandingService.class)) {

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<version>7.3.1</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.core</artifactId>

View File

@@ -77,5 +77,7 @@ public interface ICoreTisService extends IService {
Map<String, String> getDropBundleInfo() throws IOException;
Set<String> getComponentBlackList();
public String getLatestInstalledVersion();
}

View File

@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@@ -185,6 +184,8 @@ public class ProcessorUtilities {
private static boolean isDebug = false;
private static boolean isCIMode = false;
private static JobInfo mainJobInfo;
public static void addOpenEditor(IEditorPart editor) {
@@ -564,8 +565,10 @@ public class ProcessorUtilities {
neededLibraries);
// get all job testcases needed modules
neededLibraries.addAll(getAllJobTestcaseModules(selectedProcessItem));
Set<ModuleNeeded> testcaseModules = getAllJobTestcaseModules(selectedProcessItem);
LastGenerationInfo.getInstance().setTestcaseModuleNeeded(jobInfo.getJobId(), jobInfo.getJobVersion(),
testcaseModules);
neededLibraries.addAll(testcaseModules);
// must install the needed libraries before generate codes with poms.
CorePlugin.getDefault().getRunProcessService().updateLibraries(neededLibraries, currentProcess,
retrievedJarsForCurrentBuild);
@@ -1237,7 +1240,7 @@ public class ProcessorUtilities {
Set<ModuleNeeded> neededLibraries =
CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(currentProcess,
false);
isCIMode && BitwiseOptionUtils.containOption(option, GENERATE_MAIN_ONLY));
if (neededLibraries != null) {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(jobInfo.getJobId(),
jobInfo.getJobVersion(), neededLibraries);
@@ -1245,7 +1248,10 @@ public class ProcessorUtilities {
neededLibraries);
// get all job testcases needed modules
neededLibraries.addAll(getAllJobTestcaseModules(selectedProcessItem));
Set<ModuleNeeded> testcaseModules = getAllJobTestcaseModules(selectedProcessItem);
LastGenerationInfo.getInstance().setTestcaseModuleNeeded(jobInfo.getJobId(), jobInfo.getJobVersion(),
testcaseModules);
neededLibraries.addAll(testcaseModules);
// must install the needed libraries before generate codes with poms.
CorePlugin.getDefault().getRunProcessService().updateLibraries(neededLibraries, currentProcess,
@@ -2848,4 +2854,13 @@ public class ProcessorUtilities {
ProcessorUtilities.addFileToJar(configFilePath, jarFilePath);
return jarFilePath;
}
public static boolean isCIMode() {
return isCIMode;
}
public static void setCIMode(boolean isCIMode) {
ProcessorUtilities.isCIMode = isCIMode;
}
}

Some files were not shown because too many files have changed in this diff Show More