Compare commits

...

48 Commits

Author SHA1 Message Date
zshen-talend
e408ee84c5 fix(TDQ-20754): revert code to keep project is lowercase (#7778) 2022-07-20 10:11:25 +08:00
zshen-talend
10914b92bd fix(TDQ-19623): make sure project name never force lowercase (#7657) 2022-06-16 17:49:59 +08:00
zshen-talend
1efd7570d3 fix(TDQ-19623): make sure tdqReportRun can support reference project out (#7621)
of stdio
2022-06-13 18:31:35 +08:00
Xilai Dai
5b8e8a86ba fix(APPINT-34526) backport the fixes from APPINT-31563 (#7443) 2022-04-18 16:51:43 +08:00
Chao MENG
816bb48c60 fix(TUP-30599): tMap drag and drop does not work seamlessly in Linux GUI (#7268)
as it does in Windows
https://jira.talendforge.org/browse/TUP-30599
2022-03-04 16:13:17 +08:00
Liu Xinquan
f80c5e54ec fix(TBD-13419) Class not found happen in spark job calling a standard… (#7163) 2022-02-24 15:51:39 +08:00
Wei Hua
233e2a33fd APPINT-34077 RuntimeException: java.lang.NoClassDefFoundError: org/apache/cxf/databinding/DataBinding (#7062) 2021-12-29 14:49:04 +08:00
hcyi
f559f4c5ea fix(TUP-34187):DbGenerationManagerTest 3 junits fail on patch 7.2.1 (#7050)
* fix(TUP-34187):DbGenerationManagerTest 3 junits fail on patch 7.2.1

* fix(TUP-34187):DbGenerationManagerTest 3 junits fail on patch 7.2.1

* fix(TUP-34187):DbGenerationManagerTest 3 junits fail on patch 7.2.1
2021-12-22 12:02:02 +08:00
Jill Yan
0667640551 APPINT-34174 (#6995)
Co-authored-by: jillyan <yan955599@gmail.com>
2021-12-13 10:52:43 +08:00
Abdulhamid Rashankar
5cc003d379 APPINT-33792:Grand child jobs are not built when generated with CI 7.2.1 P2-Cmdline (#6880) 2021-11-23 11:34:41 +01:00
wang wei
da471ce3c4 fix(TDI-39084): fail to get sap table parameter for tsapbapi and throw NPE (#5019) 2021-11-08 11:07:21 +08:00
Chao MENG
1ca6dda3cf Cmeng/patch/7.3/tup 28063 improve start (#5092) (#6813)
* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063

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

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

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

* fix(TUP-28659): backport

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

* fix(TUP-30438):add junits

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

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

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

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

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

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

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

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

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

* TUP-30333 add comments

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

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

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

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

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

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

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

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

* fix(TUP-27374): add back default vm arguments
2020-08-07 10:24:58 +08:00
Mike Yan
e5ce502008 fix(TESB-29210): Build type not updated for consumer job (#5015) 2020-08-03 16:14:57 +08:00
apoltavtsev
ccfbf51dff TESB-29071 Bean in route gives wrong output on running in studio 2020-07-31 12:09:37 +02:00
nrousseau
d2b0c87288 Revert "fix(TDI-42522): avoid 65535 issue (#3636) (#3893) (#4895)" (#5020)
This reverts commit 6cf2cae1b6.
2020-07-31 17:46:47 +08:00
77 changed files with 3470 additions and 1539 deletions

View File

@@ -59,76 +59,88 @@ if((codePart.equals(ECodePart.END))&&(stat || logstashCurrent)){
List<String> needToEndConnNames = new ArrayList<String>();
INode nextNode = node.getOutgoingConnections(EConnectionType.ITERATE).get(0).getTarget();
NodeUtil.fillConnectionsForStat(needToEndConnNames, nextNode);
if(!needToEndConnNames.isEmpty()) {
if(stat && logstashCurrent) {
%>
runStat.updateStatAndLog(execStat,enableLogStash,iterateId,2,0<%for(String connName : needToEndConnNames){%>,"<%=connName%>"<%}%>);
%>
<%if(stat) {%>
if(execStat){
<%
for(String connName : needToEndConnNames){
%>
runStat.updateStatOnConnection("<%=connName%>"+iterateId,2, 0);
<%
} else {
if(stat) {%>
if(execStat){
runStat.updateStatOnConnection(iterateId,2,0<%for(String connName : needToEndConnNames){%>,"<%=connName%>"<%}%>);
}
<%}%>
<%if(logstashCurrent) {//now only finish the log, not send, TODO%>
if(enableLogStash){
runStat.log(iterateId,2,0<%for(String connName : needToEndConnNames){%>,"<%=connName%>"<%}%>);
}
<%
}
}
%>
}
}
if(connSet.size()>0) {
if(stat && logstashCurrent && (connSet.size()==1)) {//the most common case, write this ugly logic for 65535 issue
for(IConnection con:connSet){
INode source = con.getSource();
String sourceNodeId = source.getUniqueName();
String sourceNodeComponent = source.getComponent().getName();
for (INode jobStructureCatcher : jobCatcherNodes) {
%>
if(runStat.updateStatAndLog(execStat,enableLogStash,resourceMap,iterateId,"<%=con.getUniqueName()%>",2,0,
<%=jobStructureCatcher.getUniqueName()%>,"<%=sourceNodeId%>","<%=sourceNodeComponent%>","<%=node.getUniqueName()%>","<%=node.getComponent().getName()%>","<%="REJECT".equals(con.getConnectorName()) ? "reject" : "output"%>")) {
<%=jobStructureCatcher.getDesignSubjobStartNode().getUniqueName() %>Process(globalMap);
}
<%
break;
}
}
} else {
if(stat){
%>
if(execStat){
runStat.updateStat(resourceMap,iterateId,2,0<%for(IConnection con : connSet){%>,"<%=con.getUniqueName()%>"<%}%>);
}
<%
<%}%>
<%if(logstashCurrent) {//now only finish the log, not send, TODO%>
if(enableLogStash){
<%
for(String connName : needToEndConnNames){
%>
runStat.logStatOnConnection("<%=connName%>"+iterateId,2, 0);
<%
}
%>
}
<%
}
%>
<%
}
if(connSet.size()>0){
for(IConnection con:connSet){
INode source = con.getSource();
String sourceNodeId = source.getUniqueName();
String sourceNodeComponent = source.getComponent().getName();
%>
<%if(stat) {%>
if(execStat){
if(resourceMap.get("inIterateVComp") == null || !((Boolean)resourceMap.get("inIterateVComp"))){
runStat.updateStatOnConnection("<%=con.getUniqueName()%>"+iterateId,2, 0);
}
}
<%}%>
if(logstashCurrent){
%>
if(enableLogStash) {
<%
for(IConnection con:connSet){
INode source = con.getSource();
String sourceNodeId = source.getUniqueName();
String sourceNodeComponent = source.getComponent().getName();
<%if(logstashCurrent) {%>
if(enableLogStash){
if(resourceMap.get("inIterateVComp") == null || !((Boolean)resourceMap.get("inIterateVComp"))){
<%
for (INode jobStructureCatcher : jobCatcherNodes) {
%>
if(runStat.log(resourceMap,iterateId,"<%=con.getUniqueName()%>",2,0,
<%=jobStructureCatcher.getUniqueName()%>,"<%=sourceNodeId%>","<%=sourceNodeComponent%>","<%=node.getUniqueName()%>","<%=node.getComponent().getName()%>","<%="REJECT".equals(con.getConnectorName()) ? "reject" : "output"%>")) {
<%=jobStructureCatcher.getDesignSubjobStartNode().getUniqueName() %>Process(globalMap);
}
RunStat.StatBean talend_statebean = runStat.logStatOnConnection("<%=con.getUniqueName()%>"+iterateId,2, 0);
<%=jobStructureCatcher.getUniqueName() %>.addConnectionMessage(
"<%=sourceNodeId%>",
"<%=sourceNodeComponent%>",
false,
"<%="REJECT".equals(con.getConnectorName()) ? "reject" : "output"%>",
"<%=con.getUniqueName()%>",
talend_statebean.getNbLine(),
talend_statebean.getStartTime(),
talend_statebean.getEndTime()
);
<%=jobStructureCatcher.getUniqueName() %>.addConnectionMessage(
"<%=node.getUniqueName()%>",
"<%=node.getComponent().getName()%>",
true,
"input",
"<%=con.getUniqueName()%>",
talend_statebean.getNbLine(),
talend_statebean.getStartTime(),
talend_statebean.getEndTime()
);
<%=jobStructureCatcher.getDesignSubjobStartNode().getUniqueName() %>Process(globalMap);
<%
break;
}
}
%>
}
<%
%>
}
}
}
<%}%>
<%
}
}
}
%>

View File

@@ -146,82 +146,83 @@
boolean logstashCurrent = !cid.startsWith("tJobStructureCatcher") && !cid.startsWith("talend") && enableLogStash;
if ((codePart.equals(ECodePart.BEGIN))&&(stat || logstashCurrent)&&connSet.size()>0) {
if(containsTPartitioner) {
%>
if(<%if(stat){%>execStat<%}%><%if(stat && logstashCurrent){%> || <%}%><%if(logstashCurrent){%>enableLogStash<%}%>) {
runStat.updateStatOnConnectionAndLog(resourceMap,globalMap,iterateLoop,iterateId,<%if(stat){%>execStat<%} else {%>false<%}%>,enableLogStash,0<%for(IConnection con : connSet){%>,"<%=con.getUniqueName()%>"<%}%>);
}
<%
} else {
if(stat && logstashCurrent) {
%>
runStat.updateStatAndLog(execStat,enableLogStash,resourceMap,iterateId,0,0<%for(IConnection con : connSet){%>,"<%=con.getUniqueName()%>"<%}%>);
<%
} else {
if(stat) {
%>
if(execStat) {
runStat.updateStatOnConnection(resourceMap,iterateId,0,0<%for(IConnection con : connSet){%>,"<%=con.getUniqueName()%>"<%}%>);
}
<%
for(IConnection con:connSet){
%>
if (<%if(stat){%>execStat<%}%><%if(stat && logstashCurrent){%> || <%}%><%if(logstashCurrent){%>enableLogStash<%}%>) {
if(resourceMap.get("inIterateVComp") == null){
<%if(containsTPartitioner){%>
java.util.concurrent.ConcurrentHashMap<Object, Object> concurrentHashMap_<%=con.getUniqueName() %> = (java.util.concurrent.ConcurrentHashMap) globalMap.get("concurrentHashMap");
concurrentHashMap_<%=con.getUniqueName() %>.putIfAbsent("<%=con.getUniqueName() %>" + iterateLoop,new java.util.concurrent.atomic.AtomicInteger(0));
java.util.concurrent.atomic.AtomicInteger stats_<%=con.getUniqueName() %> = (java.util.concurrent.atomic.AtomicInteger) concurrentHashMap_<%=con.getUniqueName() %>.get("<%=con.getUniqueName() %>" + iterateLoop);
int step_<%=con.getUniqueName() %> = stats_<%=con.getUniqueName() %>.incrementAndGet()<=1?0:1;
<%if(stat) {%>
if(execStat) {
runStat.updateStatOnConnection("<%=con.getUniqueName() %>"+iterateId, step_<%=con.getUniqueName()%>, 0);
}
<%}%>
<%if(logstashCurrent) {%>
if(enableLogStash) {
runStat.logStatOnConnection("<%=con.getUniqueName()%>"+iterateId, step_<%=con.getUniqueName()%>, 0);
}
<%}%>
<%}else{%>
<%if(stat) {%>
if(execStat) {
runStat.updateStatOnConnection("<%=con.getUniqueName() %>"+iterateId, 0, 0);
}
<%}%>
<%if(logstashCurrent) {%>
if(enableLogStash) {
runStat.logStatOnConnection("<%=con.getUniqueName()%>"+iterateId, 0, 0);
}
<%}%>
<%}%>
}
if(logstashCurrent) {
%>
if(enableLogStash) {
runStat.log(resourceMap,iterateId,0,0<%for(IConnection con : connSet){%>,"<%=con.getUniqueName()%>"<%}%>);
}
<%
}
}
}
<%
}
}
if((codePart.equals(ECodePart.MAIN))&&(stat || logstashCurrent)&&connSet.size()>0){
if(!node.getComponent().useMerge()) {
if(stat && logstashCurrent) {
%>
runStat.updateStatAndLog(execStat,enableLogStash,iterateId,1,1<%for(IConnection con : connSet){%>,"<%=con.getUniqueName()%>"<%}%>);
<%
} else {
if(stat) {
%>
if(execStat){
runStat.updateStatOnConnection(iterateId,1,1<%for(IConnection con : connSet){%>,"<%=con.getUniqueName()%>"<%}%>);
}
<%
for(IConnection con:connSet){
%>
//<%=con.getUniqueName()%>
//<%=(String)codeGenArgument.getIncomingName()%>
<%if (!node.getComponent().useMerge()) {%>
<%if(stat) {%>
if(execStat){
runStat.updateStatOnConnection("<%=con.getUniqueName() %>"+iterateId,1, 1);
}
<%}%>
if(logstashCurrent) {
%>
if(enableLogStash) {
runStat.log(iterateId,1,1<%for(IConnection con : connSet){%>,"<%=con.getUniqueName()%>"<%}%>);
}
<%
<%if(logstashCurrent) {%>
if(enableLogStash) {
runStat.logStatOnConnection("<%=con.getUniqueName() %>"+iterateId,1, 1);
}
}
} else {
for(IConnection connection:connSet){
if(connection.getUniqueName().equals((String)codeGenArgument.getIncomingName())){
if(stat && logstashCurrent) {
%>
runStat.updateStatAndLog(execStat,enableLogStash,iterateId,1,1<%for(IConnection con : connSet){if(con.getUniqueName().equals((String)codeGenArgument.getIncomingName())){%>,"<%=con.getUniqueName()%>"<%}}%>);
<%
} else {
if(stat) {%>
if(execStat){
runStat.updateStatOnConnection(iterateId,1,1<%for(IConnection con : connSet){if(con.getUniqueName().equals((String)codeGenArgument.getIncomingName())){%>,"<%=con.getUniqueName()%>"<%}}%>);
}
<%}
if(logstashCurrent) {%>
if(enableLogStash) {
runStat.log(iterateId,1,1<%for(IConnection con : connSet){if(con.getUniqueName().equals((String)codeGenArgument.getIncomingName())){%>,"<%=con.getUniqueName()%>"<%}}%>);
}
<%}
}
<%}%>
<%
} else if(con.getUniqueName().equals((String)codeGenArgument.getIncomingName())){
%>
<%if(stat) {%>
if(execStat){
runStat.updateStatOnConnection("<%=con.getUniqueName() %>"+iterateId,1, 1);
}
}
<%}%>
<%if(logstashCurrent) {%>
if(enableLogStash) {
runStat.logStatOnConnection("<%=con.getUniqueName() %>"+iterateId,1, 1);
}
<%}%>
<%}%>
<%
}
}
@@ -250,7 +251,7 @@
for (INode jobStructureCatcher : jobCatcherNodes) {
%>
if(enableLogStash) {
<%=jobStructureCatcher.getUniqueName() %>.addCM("<%=node.getUniqueName()%>", "<%=node.getComponent().getName()%>");
<%=jobStructureCatcher.getUniqueName() %>.addComponentMessage("<%=node.getUniqueName()%>", "<%=node.getComponent().getName()%>");
<%=jobStructureCatcher.getDesignSubjobStartNode().getUniqueName() %>Process(globalMap);
}
<%
@@ -265,37 +266,46 @@
List<String> needToStartConnNames = new ArrayList<String>();
INode nextNode = node.getOutgoingConnections(EConnectionType.ITERATE).get(0).getTarget();
NodeUtil.fillConnectionsForStat(needToStartConnNames, nextNode);
if(needToStartConnNames.isEmpty()) {
//do nothing
} else if(containsTPartitioner){
%>
if(<%if(stat){%>execStat<%}%><%if(stat && logstashCurrent){%> || <%}%><%if(logstashCurrent){%>enableLogStash<%}%>){
runStat.updateStatOnConnectionAndLog(globalMap,iterateLoop,iterateId,<%if(stat){%>execStat<%} else {%>false<%}%>,enableLogStash,0<%for(String connName : needToStartConnNames){%>,"<%=connName%>"<%}%>);
}
<%
} else {
if(stat && logstashCurrent) {
%>
runStat.updateStatAndLog(execStat,enableLogStash,iterateId,0,0<%for(String connName : needToStartConnNames){%>,"<%=connName%>"<%}%>);
<%
} else {
if(stat){
%>
if(execStat){
runStat.updateStatOnConnection(iterateId,0,0<%for(String connName : needToStartConnNames){%>,"<%=connName%>"<%}%>);
}
<%
}
%>
<%if(logstashCurrent) {%>
if(enableLogStash){
runStat.log(iterateId,0,0<%for(String connName : needToStartConnNames){%>,"<%=connName%>"<%}%>);
}
<%
}
for(String connName : needToStartConnNames){
%>
<%if(containsTPartitioner){%>
java.util.concurrent.ConcurrentHashMap<Object, Object> concurrentHashMap_<%=connName%> = (java.util.concurrent.ConcurrentHashMap) globalMap.get("concurrentHashMap");
concurrentHashMap_<%=connName%>.putIfAbsent("<%=connName%>" + iterateLoop,new java.util.concurrent.atomic.AtomicInteger(0));
java.util.concurrent.atomic.AtomicInteger stats_<%=connName%> = (java.util.concurrent.atomic.AtomicInteger) concurrentHashMap_<%=connName%>.get("<%=connName%>" + iterateLoop);
int step_<%=connName %> = stats_<%=connName%>.incrementAndGet()<=1?0:1;
<%if(stat) {%>
if(execStat) {
runStat.updateStatOnConnection("<%=connName%>"+iterateId, step_<%=connName%>, 0);
}
<%}%>
<%if(logstashCurrent) {%>
if(enableLogStash) {
runStat.logStatOnConnection("<%=connName%>"+iterateId, step_<%=connName%>, 0);
}
<%}%>
<%}else{%>
<%if(stat) {%>
if(execStat) {
runStat.updateStatOnConnection("<%=connName%>"+iterateId, 0, 0);
}
<%}%>
<%if(logstashCurrent) {%>
if(enableLogStash) {
runStat.logStatOnConnection("<%=connName%>"+iterateId, 0, 0);
}
<%}%>
<%}%>
<%
}
%>
}
<%
}else if(codePart.equals(ECodePart.MAIN)){
%>
resourceMap.put("inIterateVComp", true);

View File

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

View File

@@ -1,10 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.talend.libraries</groupId>
<groupId>org.talend.components.lib</groupId>
<artifactId>talendsap</artifactId>
<name>talendsap</name>
<version>1.0.1</version>
<version>1.0.2</version>
<properties>
<talend.nexus.url>https://artifacts-oss.talend.com</talend.nexus.url>

View File

@@ -90,6 +90,7 @@ public class DocumentExtractor {
List<Element> tablesAndChangingElements = new ArrayList<Element>(3);
tablesAndChangingElements.add(functionElement.element("TABLES"));
tablesAndChangingElements.add(functionElement.element("CHANGING"));
tablesAndChangingElements.add(functionElement.element("OUTPUT"));
for(Element tablesOrChangingElement : tablesAndChangingElements) {
if (tablesOrChangingElement == null) {
@@ -121,6 +122,10 @@ public class DocumentExtractor {
}
result.add(row);
}
if(!result.isEmpty()) {
return result;
}
}
return result;

View File

@@ -49,11 +49,11 @@ public class DocumentHelper {
}
}
public void addSingleParameter(String name, String value, boolean isChanging) {
public void addSingleParameter(String name, String value, SAPParameterType parameter_type) {
if(value == null) {
value = "";
}
if (isChanging) {
if (parameter_type == SAPParameterType.CHANGING) {
correctChanging();
changing.addElement(name).setText(value);
} else {
@@ -62,8 +62,8 @@ public class DocumentHelper {
}
}
public void addStructParameter(String name, boolean isChanging) {
if (isChanging) {
public void addStructParameter(String name, SAPParameterType parameter_type) {
if (parameter_type == SAPParameterType.CHANGING) {
correctChanging();
currentStruct = changing.addElement(name);
} else {
@@ -79,13 +79,16 @@ public class DocumentHelper {
currentStruct.addElement(name).setText(value);
}
public void addTableParameter(String name, boolean isChanging) {
if (isChanging) {
public void addTableParameter(String name, SAPParameterType parameter_type) {
if (parameter_type == SAPParameterType.CHANGING) {
correctChanging();
currentTable = changing.addElement(name);
} else {
} else if(parameter_type == SAPParameterType.TABLES) {
correctTables();
currentTable = tables.addElement(name);
} else {
correctInput();
currentTable = input.addElement(name);
}
}
@@ -108,18 +111,18 @@ public class DocumentHelper {
DocumentHelper helper = new DocumentHelper();
helper.setFunctionName("READ_TABLE_FUNCTION");
helper.addSingleParameter("ID", "1", true);
helper.addSingleParameter("NAME", "gaoyan", false);
helper.addSingleParameter("ID", "1", SAPParameterType.CHANGING);
helper.addSingleParameter("NAME", "gaoyan", SAPParameterType.IMPORT);
helper.addStructParameter("INFO", true);
helper.addStructParameter("INFO", SAPParameterType.CHANGING);
helper.addStructChildParameter("ID", "2");
helper.addStructChildParameter("NAME", "wangwei");
helper.addStructParameter("INFO1", false);
helper.addStructParameter("INFO1", SAPParameterType.IMPORT);
helper.addStructChildParameter("ID1", "4");
helper.addStructChildParameter("NAME1", "momo");
helper.addTableParameter("TABLE1", false);
helper.addTableParameter("TABLE1", SAPParameterType.TABLES);
for (int i = 0; i < 200000; i++) {
helper.addTableRow();
helper.addTableRowChildParameter("c1", i + "");
@@ -132,7 +135,7 @@ public class DocumentHelper {
helper.addTableRowChildParameter("c8", "wangwei" + i);
}
helper.addTableParameter("TABLE2", false);
helper.addTableParameter("TABLE2", SAPParameterType.TABLES);
for (int i = 0; i < 2; i++) {
helper.addTableRow();
helper.addTableRowChildParameter("ID4", i + "");

View File

@@ -0,0 +1,8 @@
package org.talend.sap;
public enum SAPParameterType {
IMPORT,
CHANGING,
TABLES,
EXPORT
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,144 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.designer.dbmap.ui.dialog;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.talend.core.model.components.IComponent;
import org.talend.designer.dbmap.i18n.Messages;
import org.talend.designer.dbmap.language.generation.DbGenerationManager;
import org.talend.designer.dbmap.managers.MapperManager;
/**
*
* created by hcyi on Nov 24, 2020 Detailled comment
*
*/
public class PropertySetDialog extends Dialog {
private MapperManager mapperManager;
private DbGenerationManager generationManager;
private Button delimitedIdentifiersButton;
private Button useAliasButton;
private final Color color = new Color(Display.getDefault(), 238, 238, 0);
public PropertySetDialog(Shell parentShell, MapperManager mapperManager) {
super(parentShell);
this.mapperManager = mapperManager;
generationManager = mapperManager.getComponent().getGenerationManager();
}
@Override
protected Control createDialogArea(Composite parent) {
Composite container = (Composite) super.createDialogArea(parent);
final GridLayout gridLayout = new GridLayout();
gridLayout.marginLeft = 10;
gridLayout.marginTop = 20;
gridLayout.marginHeight = 0;
container.setLayout(gridLayout);
delimitedIdentifiersButton = new Button(container, SWT.CHECK);
delimitedIdentifiersButton.setText(Messages.getString("PropertySetDialog.delimitedIdentifiers.title")); //$NON-NLS-1$
useAliasButton = new Button(container, SWT.CHECK);
useAliasButton.setText(Messages.getString("PropertySetDialog.useAlias.oracle.title")); //$NON-NLS-1$
init();
addListener();
updateStatus();
return container;
}
private void init() {
delimitedIdentifiersButton.setSelection(generationManager.isUseDelimitedIdentifiers());
useAliasButton.setSelection(generationManager.isUseAliasInOutputTable());
// Implement the column alias only for tELTOracleMap now.
boolean enabled = false;
IComponent component = mapperManager.getComponent().getComponent();
if (component != null && "tELTOracleMap".equals(component.getName())) { //$NON-NLS-1$
enabled = true;
}
useAliasButton.setVisible(enabled);
}
private void addListener() {
delimitedIdentifiersButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
mapperManager.useDelimitedIdentifiers(delimitedIdentifiersButton.getSelection());
updateStatus();
}
});
useAliasButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
mapperManager.useAliasInOutputTable(useAliasButton.getSelection());
updateStatus();
}
});
}
private void updateStatus() {
if (generationManager.isUseDelimitedIdentifiers() == delimitedIdentifiersButton.getSelection()) {
delimitedIdentifiersButton.setBackground(null);
} else {
delimitedIdentifiersButton.setBackground(color);
}
if (generationManager.isUseAliasInOutputTable() == useAliasButton.getSelection()) {
useAliasButton.setBackground(null);
} else {
useAliasButton.setBackground(color);
}
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
}
@Override
protected Point getInitialSize() {
return new Point(500, 300);
}
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(Messages.getString("PropertySetDialog.title")); //$NON-NLS-1$
}
@Override
protected void okPressed() {
mapperManager.useDelimitedIdentifiers(delimitedIdentifiersButton.getSelection());
mapperManager.useAliasInOutputTable(useAliasButton.getSelection());
super.okPressed();
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -210,4 +210,11 @@ public class DragNDrop {
dropTarget.addDropListener(targetListener);
}
public static DropTarget addDropListener(Control listenerControl, TransferDropTargetListener listener) {
DropTarget dropTarget = new DropTarget(listenerControl, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
dropTarget.setTransfer(new Transfer[] { TableEntriesTransfer.getInstance() });
dropTarget.addDropListener(listener);
return dropTarget;
}
}

View File

@@ -23,6 +23,7 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable;
import org.talend.commons.ui.runtime.ws.WindowSystem;
import org.talend.commons.ui.swt.tableviewer.TableViewerCreator;
@@ -46,6 +47,8 @@ import org.talend.designer.mapper.ui.visualmap.zone.Zone;
*/
public class DropContextAnalyzer {
public static final String PROP_DND_OPERATE_CONTROL = "PROP_DND_OPERATE_CONTROL";
private DropTargetEvent event;
private DraggedData draggedData;
@@ -105,14 +108,21 @@ public class DropContextAnalyzer {
DropTarget dropTarget = (DropTarget) event.widget;
Control controlTarget = dropTarget.getControl();
dataMapTableViewTarget = mapperManager.retrieveDataMapTableView(controlTarget);
if (controlTarget instanceof Table) {
currentTableTarget = (Table) dropTarget.getControl();
} else if (controlTarget instanceof StyledText) {
currentStyledTextTarget = (StyledText) dropTarget.getControl();
} else {
} else if (controlTarget instanceof Text) {
Object storedData = controlTarget.getData(DropContextAnalyzer.PROP_DND_OPERATE_CONTROL);
if (storedData instanceof Table) {
currentTableTarget = (Table) storedData;
controlTarget = currentTableTarget;
}
}
if (currentTableTarget == null && currentStyledTextTarget == null) {
throw new IllegalArgumentException(Messages.getString("DropContextAnalyzer.0", controlTarget.toString())); //$NON-NLS-1$
}
dataMapTableViewTarget = mapperManager.retrieveDataMapTableView(controlTarget);
zoneTarget = dataMapTableViewTarget.getZone();
draggedData = TableEntriesTransfer.getInstance().getDraggedData();
dataMapTableViewSource = (DataMapTableView) draggedData.getDataMapTableViewSource();

View File

@@ -27,6 +27,7 @@ import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalListener;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.TransferDropTargetListener;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
import org.eclipse.jface.viewers.DialogCellEditor;
@@ -170,7 +171,9 @@ import org.talend.designer.mapper.model.tableentry.VarTableEntry;
import org.talend.designer.mapper.ui.color.ColorInfo;
import org.talend.designer.mapper.ui.color.ColorProviderMapper;
import org.talend.designer.mapper.ui.dialog.ListStringValueDialog;
import org.talend.designer.mapper.ui.dnd.CompleteDropTargetTableListener;
import org.talend.designer.mapper.ui.dnd.DragNDrop;
import org.talend.designer.mapper.ui.dnd.DropContextAnalyzer;
import org.talend.designer.mapper.ui.event.MousePositionAnalyser;
import org.talend.designer.mapper.ui.event.ResizeHelper;
import org.talend.designer.mapper.ui.event.ResizeHelper.RESIZE_MODE;
@@ -2045,6 +2048,11 @@ public abstract class DataMapTableView extends Composite implements IDataMapTabl
final Text expressionTextEditor = cellEditor.getTextControl();
expressionTextEditor.setData(DropContextAnalyzer.PROP_DND_OPERATE_CONTROL, tableViewerCreator.getTable());
TransferDropTargetListener completeDropTargetListener = new CompleteDropTargetTableListener(mapperManager,
tableViewerCreator.getTable());
DragNDrop.addDropListener(expressionTextEditor, completeDropTargetListener);
if (isConstraintExpressionCellEditor) {
constraintExpressionTextEditor = expressionTextEditor;
} else {
@@ -2427,7 +2435,9 @@ public abstract class DataMapTableView extends Composite implements IDataMapTabl
private void parseExpression(ModifiedBeanEvent event, TableViewerCreator tableViewerCreator, ITableEntry tableEntry) {
if (event.column == tableViewerCreator.getColumn(DataMapTableView.ID_EXPRESSION_COLUMN)) {
mapperManager.getUiManager().parseExpression(tableEntry.getExpression(), tableEntry, false, false, false);
mapperManager.getUiManager().refreshBackground(false, false);
if (headerComposite != null && !headerComposite.isDisposed()) {
mapperManager.getUiManager().refreshBackground(false, false);
}
}
}

View File

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

View File

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

View File

@@ -296,7 +296,7 @@ public class DefaultRunProcessService implements IRunProcessService {
return new MavenJavaProcessor(process, property, filenameFromLabel);
} else {
if (property != null) {
if (!ProcessorUtilities.isGeneratePomOnly()) {
// if (!ProcessorUtilities.isGeneratePomOnly()) {
// for esb type only
boolean servicePart = false;
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(property.getId(),
@@ -338,7 +338,7 @@ public class DefaultRunProcessService implements IRunProcessService {
return soapService.createOSGIJavaProcessor(process, property, filenameFromLabel);
}
}
}
// }
return new MavenJavaProcessor(process, property, filenameFromLabel);
} else {
return new MavenJavaProcessor(process, property, filenameFromLabel);

View File

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

View File

@@ -32,6 +32,7 @@ import org.talend.commons.utils.resource.FileExtensions;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.process.JobInfo;
import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
@@ -245,6 +246,8 @@ public abstract class BigDataJavaProcessor extends MavenJavaProcessor implements
if (isExport) {
// In an export mode, we add the job jar which is located in the current working directory
libJars.append("./" + makeupJobJarName()); //$NON-NLS-1$
// to fix TBD-13419, need to add the subjob jar name to the -libjars parameter
libJars.append(makeupSubjobJarNameStr4Export()); //$NON-NLS-1$
if (!needAllLibJars) {
// to avoid issue TPSVC-4826
libJars.append(","); //$NON-NLS-1$
@@ -278,12 +281,61 @@ public abstract class BigDataJavaProcessor extends MavenJavaProcessor implements
// ... and add the jar of the job itself also located in the target directory/
libJars.append(getTalendJavaProject().getTargetFolder().getLocation().toPortableString() + "/" + makeupJobJarName()); //$NON-NLS-1$
// to fix TBD-13419, need to add the subjob jar name to the -libjars parameter
libJars.append(makeupSubjobJarNameStr4Local());
}
list.add(libJars.toString());
return list;
}
protected String makeUpClassPathString() {
/**
* Makes up the subjob(s) jar name string for local, that should be like:
* 1) "" (no subjobs)
* 2) ",<project_folder>/poms/jobs/process/<subjob_name_versiono>/target/<subjob_name_versiono>.jar" (standard subjob)
* 3) ",<project_folder>/poms/jobs/process_mr/<subjob_name_version>/target/<subjob_name_versiono>.jar" (spark subjob)
*
* @return
*/
protected String makeupSubjobJarNameStr4Local() {
String subjobJarNameStr = ""; //$NON-NLS-1$
Set<JobInfo> jobInfos = getBuildChildrenJobs();
if (!jobInfos.isEmpty()) {
Iterator<JobInfo> it = jobInfos.iterator();
while (it.hasNext()) {
JobInfo jobInfo = it.next();
subjobJarNameStr += "," //$NON-NLS-1$
+ TalendJavaProjectManager.getTalendJobJavaProject(jobInfo.getProcessItem().getProperty())
.getTargetFolder()
.getLocation()
.toPortableString()
+ "/" + jobInfo.getJobName().toLowerCase() + "_" + jobInfo.getJobVersion().replace(".", "_") //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ ".jar"; //$NON-NLS-1$
}
}
return subjobJarNameStr;
}
/**
* Makes up the subjob(s) jar name string for export, that should be like:
* 1) "" (no subjobs)
* 2) ",./subjob1_0_1.jar" (with subjobs)
*
* @return
*/
protected String makeupSubjobJarNameStr4Export() {
String subjobJarNameStr = ""; //$NON-NLS-1$
Set<JobInfo> jobInfos = getBuildChildrenJobs();
if (!jobInfos.isEmpty()) {
Iterator<JobInfo> it = jobInfos.iterator();
while (it.hasNext()) {
JobInfo jobInfo = it.next();
subjobJarNameStr += ",./" + jobInfo.getJobName().toLowerCase() + "_" + jobInfo.getJobVersion().replace(".", "_") + ".jar"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
}
return subjobJarNameStr;
}
protected String makeUpClassPathString() {
StringBuffer sb = new StringBuffer();
try {
sb.append(getLibsClasspath());

View File

@@ -41,6 +41,7 @@ import java.util.zip.ZipInputStream;
import org.apache.commons.codec.binary.Base64InputStream;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IMarker;
@@ -216,6 +217,8 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
private String jobVersion;
private static final Logger LOGGER = Logger.getLogger(JavaProcessor.class);
/**
* Set current status.
*
@@ -1326,6 +1329,7 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
final String rootWorkingDir = getRootWorkingDir(false);
StringBuffer basePath = new StringBuffer(50);
if (isExportConfig() || isRunAsExport()) {
// current path.
basePath.append('.');
@@ -1485,7 +1489,9 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
}
StringBuffer libPath = new StringBuffer();
if (isExportConfig() || isRunAsExport()) {
boolean hasLibPrefix = libPrefixPath.length() > 0;
for (ModuleNeeded neededModule : neededModules) {
if (hasLibPrefix) {
@@ -1577,7 +1583,7 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
Set<JobInfo> infos = getBuildChildrenJobs();
for (JobInfo jobInfo : infos) {
String childJarName = JavaResourcesHelper.getJobFolderName(jobInfo.getJobName(), jobInfo.getJobVersion());
String childJarName = JavaResourcesHelper.getJobFolderName(jobInfo);
exportJar += classPathSeparator + rootWorkingDir + childJarName + FileExtensions.JAR_FILE_SUFFIX;
}
return exportJar;
@@ -1674,13 +1680,21 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
}
}
}
// if not check or the value is empty, should use preference
if (string == null || "".equals(string)) { //$NON-NLS-1$
string = RunProcessPlugin.getDefault().getPreferenceStore().getString(RunProcessPrefsConstants.VMARGUMENTS);
// https://jira.talendforge.org/browse/TUP-27374
String[] vmargs = null;
try {
// if not check or the value is empty, should use preference
if (string == null || "".equals(string)) { //$NON-NLS-1$
string = RunProcessPlugin.getDefault().getPreferenceStore().getString(RunProcessPrefsConstants.VMARGUMENTS);
}
String replaceAll = string.trim();
List<String> vmList = new JobVMArgumentsUtil().readString(replaceAll);
vmargs = vmList.toArray(new String[0]);
} catch (Exception e) {
LOGGER.debug(e.getMessage(), e);
// UI can not be loaded, use default jvm args
vmargs = JobVMArgumentsUtil.DEFAULT_JVM_ARGS;
}
String replaceAll = string.trim();
List<String> vmList = new JobVMArgumentsUtil().readString(replaceAll);
String[] vmargs = vmList.toArray(new String[0]);
return vmargs;
}
@@ -1980,13 +1994,17 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
IFolder extResourcePath = externalResourcesFolder.getFolder(jobContextFolderPath);
IFolder resourcesPath = resourcesFolder.getFolder(jobContextFolderPath);
if(!resourcesPath.exists()) {
tProcessJvaProject.createSubFolder(null, resourcesFolder, jobContextFolderPath.toString());
}
resourcesPath.refreshLocal(IResource.DEPTH_INFINITE, null);
if (!extResourcePath.exists()) {
tProcessJvaProject.createSubFolder(null, externalResourcesFolder, jobContextFolderPath.toString());
}
resourcesPath.refreshLocal(IResource.DEPTH_INFINITE, null);
extResourcePath.refreshLocal(IResource.DEPTH_INFINITE, null);
for (IResource resource : extResourcePath.members()) {
IFile context = resourcesPath.getFile(resource.getName());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,93 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.model.migration;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.logging.Logger;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2e.core.MavenPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.general.Project;
import org.talend.core.model.migration.AbstractProjectMigrationTask;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.designer.maven.tools.AggregatorPomsHelper;
/*
* Created by bhe on Sep 29, 2020
*/
public class RemoveSnapshotJarMigrationTask extends AbstractProjectMigrationTask {
private static final Logger LOGGER = Logger.getLogger(RemoveSnapshotJarMigrationTask.class.getCanonicalName());
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2020, 9, 30, 12, 00, 00);
return gc.getTime();
}
@Override
public ExecutionResult execute(Project project) {
AggregatorPomsHelper pomHelper = new AggregatorPomsHelper();
IFile rootPomFile = pomHelper.getProjectRootPom();
if (rootPomFile.exists()) {
try {
boolean isRegeneratePoms = false;
Model model = MavenPlugin.getMaven().readModel(rootPomFile.getLocation().toFile());
if (model.getModules() != null) {
for (String module : model.getModules()) {
Path modPath = Paths.get(rootPomFile.getLocation().toFile().getParent(), module, "pom.xml");
Model modModel = MavenPlugin.getMaven().readModel(modPath.toFile());
isRegeneratePoms = doMigration(modModel.getDependencies());
if (isRegeneratePoms) {
break;
}
}
}
LOGGER.info("modules: " + model.getModules() + ", isRegeneratePoms: " + isRegeneratePoms);
if (isRegeneratePoms) {
pomHelper.syncAllPomsWithoutProgress(new NullProgressMonitor());
return ExecutionResult.SUCCESS_NO_ALERT;
}
return ExecutionResult.NOTHING_TO_DO;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
private static boolean doMigration(List<Dependency> deps) {
if (deps == null || deps.isEmpty()) {
return false;
}
for (Dependency dep : deps) {
if (StringUtils.equals("org.talend.libraries", dep.getGroupId())
&& StringUtils.equals("6.0.0-SNAPSHOT", dep.getVersion())) {
if (StringUtils.equals("crypto-utils", dep.getArtifactId())) {
return true;
}
}
}
return false;
}
}

View File

@@ -0,0 +1,109 @@
// ============================================================================
//
// 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.repository.model.migration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.components.ComponentUtilities;
import org.talend.core.model.components.ModifyComponentsAction;
import org.talend.core.model.components.conversions.IComponentConversion;
import org.talend.core.model.components.filters.IComponentFilter;
import org.talend.core.model.components.filters.NameComponentFilter;
import org.talend.core.model.migration.AbstractJobMigrationTask;
import org.talend.core.model.properties.Item;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ElementValueType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
public class SAPBAPIParameterTypeMigrationTask extends AbstractJobMigrationTask {
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
String[] componentsName = new String[] { "tSAPBapi" };
try {
for (String element : componentsName) {
IComponentFilter filter = new NameComponentFilter(element);
ModifyComponentsAction.searchAndModify(item, processType, filter,
Arrays.<IComponentConversion>asList(new IComponentConversion() {
@SuppressWarnings("unchecked")
@Override
public void transform(NodeType node) {
ElementParameterType mapping_input = ComponentUtilities.getNodeProperty(node,
"MAPPING_INPUT");
TalendFileFactory fileFact = TalendFileFactory.eINSTANCE;
if (mapping_input != null) {
List<ElementValueType> newElementValues = new ArrayList<ElementValueType>();
List<ElementValueType> elementValues = mapping_input.getElementValue();
boolean tableType = false;
for (ElementValueType elementValue : elementValues) {
if ("TYPE".equals(elementValue.getElementRef())
&& "TABLE".equals(elementValue.getValue())) {
tableType = true;
}
if ("CHANGING".equals(elementValue.getElementRef())) {
ElementValueType value = fileFact.createElementValueType();
value.setElementRef("PARAMETER_TYPE");
boolean is_changing_parameter = "true".equalsIgnoreCase(elementValue.getValue());
if (tableType) {
value.setValue(is_changing_parameter ? "CHANGING" : "TABLES");
} else {
value.setValue(is_changing_parameter ? "CHANGING" : "IMPORT");
}
newElementValues.add(value);
tableType = false;
continue;
}
newElementValues.add(elementValue);
}
elementValues.clear();
elementValues.addAll(newElementValues);
}
}
}));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2021, 10, 2, 18, 0, 0);
return gc.getTime();
}
}

View File

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

View File

@@ -0,0 +1,80 @@
// ============================================================================
//
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.model.migration;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.model.components.ComponentUtilities;
import org.talend.core.model.components.ModifyComponentsAction;
import org.talend.core.model.components.conversions.IComponentConversion;
import org.talend.core.model.components.filters.IComponentFilter;
import org.talend.core.model.components.filters.NameComponentFilter;
import org.talend.core.model.migration.AbstractAllJobMigrationTask;
import org.talend.core.model.properties.Item;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
/**
* created by hcyi on Feb 24, 2021
* Detailled comment
*
*/
public class SpecialUpdateELTEnableColumnAliasMigrationTask extends AbstractAllJobMigrationTask {
private static final String ELT_ORACLE_DISABLE_COLUMN_ALIAS = "elt.oracle.disableColumnAlias"; //$NON-NLS-1$
private static final String USE_ALIAS_IN_OUTPUT_TABLE = "USE_ALIAS_IN_OUTPUT_TABLE"; //$NON-NLS-1$
private String field = "CHECK"; //$NON-NLS-1$
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
boolean disableOracleAlias = Boolean
.valueOf(System.getProperty(ELT_ORACLE_DISABLE_COLUMN_ALIAS, Boolean.FALSE.toString()));
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null || disableOracleAlias) {
return ExecutionResult.NOTHING_TO_DO;
}
IComponentFilter filter = new NameComponentFilter("tELTOracleMap"); //$NON-NLS-1$
try {
ModifyComponentsAction.searchAndModify(item, processType, filter,
Arrays.<IComponentConversion> asList(new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType use_alias = ComponentUtilities.getNodeProperty(node, USE_ALIAS_IN_OUTPUT_TABLE);
if (use_alias == null) {
ComponentUtilities.addNodeProperty(node, USE_ALIAS_IN_OUTPUT_TABLE, field);
}
ComponentUtilities.setNodeValue(node, USE_ALIAS_IN_OUTPUT_TABLE, String.valueOf(!disableOracleAlias));
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2021, 01, 07, 12, 0, 0);
return gc.getTime();
}
}

View File

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

View File

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

View File

@@ -13,6 +13,7 @@
package org.talend.repository.ui.wizards.exportjob.handler;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
@@ -58,11 +59,13 @@ import org.talend.core.runtime.process.TalendProcessArgumentConstant;
import org.talend.core.runtime.repository.build.BuildExportManager;
import org.talend.core.service.ITransformService;
import org.talend.core.ui.ITestContainerProviderService;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.tools.BuildCacheManager;
import org.talend.designer.runprocess.IProcessor;
import org.talend.designer.runprocess.ProcessorUtilities;
import org.talend.model.bridge.ReponsitoryContextBridge;
import org.talend.repository.ProjectManager;
import org.talend.repository.documentation.ExportFileResource;
import org.talend.repository.local.ExportItemUtil;
import org.talend.repository.model.RepositoryConstants;
@@ -79,7 +82,6 @@ public class BuildJobHandler extends AbstractBuildJobHandler {
public BuildJobHandler(ProcessItem processItem, String version, String contextName, Map<ExportChoice, Object> exportChoiceMap) {
super(processItem, version, contextName, exportChoiceMap);
setProjectNameLowerCase(true);
ProcessorUtilities.setExportConfig(JavaUtils.JAVA_APP_NAME, null, null);
}
@@ -182,6 +184,8 @@ public class BuildJobHandler extends AbstractBuildJobHandler {
generationOption = generationOption | ProcessorUtilities.GENERATE_WITHOUT_COMPILING;
}
argumentsMap.put(TalendProcessArgumentConstant.ARG_GENERATE_OPTION, generationOption);
argumentsMap.put(TalendProcessArgumentConstant.ARG_NEED_JETTY_SERVER,
ProcessUtils.hasJettyEndpoint((ProcessType)processItem.getProcess()));
BuildCacheManager.getInstance().clearCurrentCache();
@@ -200,7 +204,7 @@ public class BuildJobHandler extends AbstractBuildJobHandler {
return;
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister
ITestContainerProviderService testContainerService = GlobalServiceRegister
.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
List<IFile> reports = new ArrayList<IFile>();
@@ -268,7 +272,7 @@ public class BuildJobHandler extends AbstractBuildJobHandler {
private void addTDMDependencies(IFolder itemsFolder, List<Item> items) {
ITransformService tdmService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITransformService.class)) {
tdmService = (ITransformService) GlobalServiceRegister.getDefault().getService(ITransformService.class);
tdmService = GlobalServiceRegister.getDefault().getService(ITransformService.class);
}
if (tdmService == null) {
return;
@@ -354,62 +358,88 @@ public class BuildJobHandler extends AbstractBuildJobHandler {
private void addDQDependencies(IFolder parentFolder, List<Item> items) throws Exception {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQItemService.class)) {
ITDQItemService tdqItemService = (ITDQItemService) GlobalServiceRegister.getDefault().getService(
ITDQItemService tdqItemService = GlobalServiceRegister.getDefault().getService(
ITDQItemService.class);
List<Project> initProList = new ArrayList<>();
for (Item item : items) {
if (tdqItemService != null && tdqItemService.hasProcessItemDependencies(Arrays.asList(new Item[] { item }))) {
setNeedItemDependencies(true);
// add .Talend.definition file
String defIdxFolderName = "TDQ_Libraries"; //$NON-NLS-1$
String defIdxFileName = ".Talend.definition"; //$NON-NLS-1$
Project pro = getProject(processItem);
IFolder itemsProjectFolder = parentFolder.getFolder(pro.getTechnicalLabel().toLowerCase());
File itemsFolderDir = new File(parentFolder.getLocation().toFile().getAbsolutePath());
IProject project = ReponsitoryContextBridge.getRootProject();
String defIdxRelativePath = defIdxFolderName + PATH_SEPARATOR + defIdxFileName;
IFile defIdxFile = project.getFile(defIdxRelativePath);
if (defIdxFile.exists()) {
File defIdxFileSource = new File(project.getLocation().makeAbsolute().append(defIdxFolderName)
.append(defIdxFileName).toFile().toURI());
File defIdxFileTarget = new File(itemsProjectFolder.getFile(defIdxRelativePath).getLocation().toFile()
.getAbsolutePath());
FilesUtils.copyFile(defIdxFileSource, defIdxFileTarget);
}
// add report header image & template files
String reportingBundlePath = PluginChecker.getBundlePath("org.talend.dataquality.reporting"); //$NON-NLS-1$
File imageFolder = new File(reportingBundlePath + PATH_SEPARATOR + "images"); //$NON-NLS-1$
if (imageFolder.exists()) {
FilesUtils.copyDirectory(imageFolder, itemsFolderDir);
}
File templateFolder = new File(reportingBundlePath + PATH_SEPARATOR + "reports"); //$NON-NLS-1$
if (templateFolder.exists() && templateFolder.isDirectory()) {
FilesUtils.copyDirectory(templateFolder, itemsFolderDir);
}
// TDQ-10842 msjian: consider user defined report template files
String reportTemplateFolderName = "JRXML Template"; //$NON-NLS-1$
String reportTemplateFolderPath = defIdxFolderName + PATH_SEPARATOR + reportTemplateFolderName;
IFolder reportFolder = project.getFolder(reportTemplateFolderPath);
if (reportFolder.exists()) {
File reportFileSource = new File(project
.getLocation()
.makeAbsolute()
.append(defIdxFolderName)
.append(reportTemplateFolderName)
.toFile()
.toURI());
File reportFileTarget = new File(itemsProjectFolder
.getFile(defIdxFolderName)
.getLocation()
.toFile()
.getAbsolutePath());
FilesUtils.copyDirectory(reportFileSource, reportFileTarget);
}
// TDQ-10842~
if (PluginChecker.isRefProjectLoaded()
&& ProjectManager.getInstance().getAllReferencedProjects().size() > 0) {
handleMulitProjectCase(parentFolder, initProList, item);
} else {
handleSingleProjectCase(parentFolder, tdqItemService, item);
}
}
}
}
private void handleMulitProjectCase(IFolder parentFolder, List<Project> initProList, Item item) throws IOException {
Project pro = ProjectManager.getInstance().getProject(item);
if (!initProList.contains(pro)) {
initProList.add(pro);
copyDQSystemFile(parentFolder, pro);
}
}
protected void copyDQSystemFile(IFolder parentFolder, Project pro) throws IOException {
setNeedItemDependencies(true);
// add .Talend.definition file
String defIdxFolderName = "TDQ_Libraries"; //$NON-NLS-1$
String defIdxFileName = ".Talend.definition"; //$NON-NLS-1$
IFolder itemsProjectFolder = parentFolder.getFolder(pro.getTechnicalLabel().toLowerCase());
File itemsFolderDir = new File(parentFolder.getLocation().toFile().getAbsolutePath());
IProject project = ReponsitoryContextBridge.findProject(pro.getTechnicalLabel());
String defIdxRelativePath = defIdxFolderName + PATH_SEPARATOR + defIdxFileName;
IFile defIdxFile = project.getFile(defIdxRelativePath);
if (defIdxFile.exists()) {
File defIdxFileSource = new File(project
.getLocation()
.makeAbsolute()
.append(defIdxFolderName)
.append(defIdxFileName)
.toFile()
.toURI());
File defIdxFileTarget =
new File(itemsProjectFolder.getFile(defIdxRelativePath).getLocation().toFile().getAbsolutePath());
FilesUtils.copyFile(defIdxFileSource, defIdxFileTarget);
}
// add report header image & template files
String reportingBundlePath = PluginChecker.getBundlePath("org.talend.dataquality.reporting"); //$NON-NLS-1$
File imageFolder = new File(reportingBundlePath + PATH_SEPARATOR + "images"); //$NON-NLS-1$
if (imageFolder.exists()) {
FilesUtils.copyDirectory(imageFolder, itemsFolderDir);
}
File templateFolder = new File(reportingBundlePath + PATH_SEPARATOR + "reports"); //$NON-NLS-1$
if (templateFolder.exists() && templateFolder.isDirectory()) {
FilesUtils.copyDirectory(templateFolder, itemsFolderDir);
}
// TDQ-10842 msjian: consider user defined report template files
String reportTemplateFolderName = "JRXML Template"; //$NON-NLS-1$
String reportTemplateFolderPath = defIdxFolderName + PATH_SEPARATOR + reportTemplateFolderName;
IFolder reportFolder = project.getFolder(reportTemplateFolderPath);
if (reportFolder.exists()) {
File reportFileSource = new File(project
.getLocation()
.makeAbsolute()
.append(defIdxFolderName)
.append(reportTemplateFolderName)
.toFile()
.toURI());
File reportFileTarget =
new File(itemsProjectFolder.getFile(defIdxFolderName).getLocation().toFile().getAbsolutePath());
FilesUtils.copyDirectory(reportFileSource, reportFileTarget);
}
// TDQ-10842~
}
private void handleSingleProjectCase(IFolder parentFolder, ITDQItemService tdqItemService, Item item)
throws IOException {
Project pro = getProject(processItem);
if (tdqItemService != null && tdqItemService.hasProcessItemDependencies(Arrays.asList(new Item[] { item }))) {
copyDQSystemFile(parentFolder, pro);
}
}
@Override
public void build(IProgressMonitor monitor) throws Exception {
final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {

View File

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

View File

@@ -24,6 +24,7 @@ import aQute.service.reporter.Reporter;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -100,6 +101,7 @@ import org.talend.repository.documentation.ExportFileResource;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JarBuilder;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsManager;
import org.talend.repository.utils.EmfModelUtils;
import org.talend.repository.utils.EsbConfigUtils;
import org.talend.repository.utils.TemplateProcessor;
/**
@@ -169,8 +171,22 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
}
complianceParameter = " -" + complianceLevel + " -maxProblems 100000 -nowarn";
try (InputStream is = RepositoryPlugin.getDefault().getBundle().getEntry("/resources/osgi-exclude.properties") //$NON-NLS-1$
.openStream()) {
try {
File propFile = null;
File esbConfigurationLocation = EsbConfigUtils.getEclipseEsbFolder();
if (esbConfigurationLocation != null && esbConfigurationLocation.exists() && esbConfigurationLocation.isDirectory()) {
propFile = new File(esbConfigurationLocation.getAbsolutePath(), OSGI_EXCLUDE_PROP_FILENAME);
}
InputStream is = null;
if (propFile != null && propFile.exists() && propFile.isFile()) {
is = new FileInputStream(propFile);
} else {
is = RepositoryPlugin.getDefault().getBundle().getEntry("/resources/" + OSGI_EXCLUDE_PROP_FILENAME)
.openStream();
}
final Properties p = new Properties();
p.load(is);
for (Enumeration<?> e = p.propertyNames(); e.hasMoreElements();) {
@@ -929,10 +945,11 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
Set<URL> resources = libResource.getResourcesByRelativePath(path);
for (URL url : resources) {
// TESB-21804:Fail to deploy cMessagingEndpoint with quartz component in runtime for ClassCastException
if (url.getPath().matches("(.*)camel-(.*)-alldep-(.*)$")
|| url.getPath().matches("(.*)activemq-all-[\\d\\.]*.jar$")
|| url.getPath().matches("(.*)jms[\\d\\.-]*.jar$")
|| url.getPath().matches("(.*)tdm-lib-di-[\\d\\.-]*.jar$")) {
String urlStr = url.getPath().replace("\\", "/");
if (urlStr.matches("(.*)camel-(.*)-alldep-(.*)$")
|| urlStr.matches("(.*)activemq-all-[\\d\\.]*.jar$")
|| urlStr.matches("(.*)/jms[\\d\\.-]*.jar$")
|| urlStr.matches("(.*)tdm-lib-di-[\\d\\.-]*.jar$")) {
continue;
}
File dependencyFile = new File(FilesUtils.getFileRealPath(url.getPath()));
@@ -998,6 +1015,17 @@ public class JobJavaScriptOSGIForESBManager extends JobJavaScriptsManager {
requireBundle = "tesb-xacml-rt"; //$NON-NLS-1$
}
}
// https://jira.talendforge.org/browse/APPINT-34077
if (ERepositoryObjectType.getType(processItem.getProperty()).equals(ERepositoryObjectType.PROCESS)) {
for (JobInfo subjobInfo : ProcessorUtilities.getChildrenJobInfo(processItem)) {
if (EmfModelUtils.getComponentByName(subjobInfo.getProcessItem(), "tESBConsumer") != null) { //$NON-NLS-1$
importPackages.add("org.apache.cxf.databinding"); //$NON-NLS-1$
break;
}
}
}
if (ERepositoryObjectType.PROCESS_MR == ERepositoryObjectType.getItemType(processItem)) {
importPackages.add("org.talend.cloud"); //$NON-NLS-1$
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,387 +1,384 @@
package org.talend.repository.handler;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.CorePlugin;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Project;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.designer.runprocess.IRunProcessService;
import org.talend.model.bridge.ReponsitoryContextBridge;
import org.talend.repository.ProjectManager;
import org.talend.repository.items.importexport.handlers.ImportExportHandlersManager;
import org.talend.repository.items.importexport.handlers.model.ImportItem;
import org.talend.repository.items.importexport.manager.ResourcesManager;
import org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager;
import org.talend.repository.items.importexport.ui.managers.ResourcesManagerFactory;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.BuildJobManager;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice;
import org.talend.repository.ui.wizards.exportjob.util.ExportJobUtil;
public class BuildJobHandlerTest {
private ProcessItem jobWithTdqItem;
private ProcessItem jobWithTdmItem;
private ProcessItem jobWithChildrenItem;
private ProcessItem jobWithJobletItem;
private ProcessItem jobWithTestcaseItem;
private ProcessItem childJobItem;
private Item jobletItem;
private List<Item> testItems;
private List<String> destinationPaths;
private Project bridgeProject;
private Map<ExportChoice, Object> exportChoiceMap;
private IRunProcessService runProcessService;
private static final String JOB_WITH_TDQ_ID = "_3TtbgD7OEeiHhJsSj16U_A";
private static final String JOB_WITH_TDM_ID = "_bWyBUAYbEeapTZ0aKwL_YA";
private static final String JOB_WITH_CHILDREN_ID = "_HGAFAD7OEeiNfpYj4K_XrA";
private static final String JOB_WITH_JOBLET_ID = "_FKbJID7OEeiNfpYj4K_XrA";
private static final String JOB_WITH_TESTCASE_ID = "_YmcxoHniEeiA8rKAx4YxMw";
private static final String JOB_CHILD_ID = "_JJsbED7OEeiNfpYj4K_XrA";
private static final String JOBLET_ID = "_V92qED7OEeiNfpYj4K_XrA";
@Before
public void setUp() throws Exception {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
runProcessService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
}
assertNotNull(runProcessService);
// Fix the NPE for org.talend.designer.core.ui.editor.process.Process.createMainParameters(Process.java:401)
bridgeProject = ReponsitoryContextBridge.getProject();
ReponsitoryContextBridge.setProject(ProjectManager.getInstance().getCurrentProject().getEmfProject());
ImportExportHandlersManager importManager = new ImportExportHandlersManager();
URL testJobURL = FileLocator.find(Platform.getBundle("org.talend.repository.test"),
new Path("/resources/testBuildJob.zip"), null);
if (testJobURL != null) {
testJobURL = FileLocator.toFileURL(testJobURL);
}
File srcFile = new File(testJobURL.getFile());
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
ResourcesManager resManager = fileUnityManager.doUnify();
List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, new NullProgressMonitor());
assertTrue(projectRecords.size() > 0);
importManager.importItemRecords(new NullProgressMonitor(), resManager, projectRecords, true,
projectRecords.toArray(new ImportItem[0]), null);
jobWithTdqItem = (ProcessItem) getItemById(JOB_WITH_TDQ_ID);
jobWithTdmItem = (ProcessItem) getItemById(JOB_WITH_TDM_ID);
jobWithChildrenItem = (ProcessItem) getItemById(JOB_WITH_CHILDREN_ID);
jobWithJobletItem = (ProcessItem) getItemById(JOB_WITH_JOBLET_ID);
jobWithTestcaseItem = (ProcessItem) getItemById(JOB_WITH_TESTCASE_ID);
childJobItem = (ProcessItem) getItemById(JOB_CHILD_ID);
jobletItem = getItemById(JOBLET_ID);
testItems = new ArrayList<>();
testItems.add(jobWithTdqItem);
testItems.add(jobWithTdmItem);
testItems.add(jobWithChildrenItem);
testItems.add(jobWithJobletItem);
testItems.add(jobWithTestcaseItem);
testItems.add(childJobItem);
testItems.add(jobletItem);
initExportChoice();
destinationPaths = new ArrayList<>();
}
@Test
public void testBuildJobWithTDQ() throws Exception {
String destinationPath = getDestinationPath(jobWithTdqItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithTdqItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithTdqItem, destinationPath);
}
@Test
public void testBuildJobWithTDM() throws Exception {
String destinationPath = getDestinationPath(jobWithTdmItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithTdmItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithTdmItem, destinationPath);
}
@Test
public void testBuildJobWithChildren() throws Exception {
String destinationPath = getDestinationPath(jobWithChildrenItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithChildrenItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithChildrenItem, destinationPath);
}
@Test
public void testBuildJobWithJoblet() throws Exception {
String destinationPath = getDestinationPath(jobWithJobletItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithJobletItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithJobletItem, destinationPath);
}
@Test
public void testBuildJobWithTestcase() throws Exception {
String destinationPath = getDestinationPath(jobWithTestcaseItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithTestcaseItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithTestcaseItem, destinationPath);
}
private Map<ExportChoice, Object> initExportChoice() {
exportChoiceMap = new HashMap<ExportChoice, Object>();
exportChoiceMap.put(ExportChoice.needLauncher, true);
exportChoiceMap.put(ExportChoice.needSystemRoutine, true);
exportChoiceMap.put(ExportChoice.needUserRoutine, true);
exportChoiceMap.put(ExportChoice.needTalendLibraries, true);
exportChoiceMap.put(ExportChoice.needJobItem, false);
exportChoiceMap.put(ExportChoice.needJobScript, true);
exportChoiceMap.put(ExportChoice.needSourceCode, true);
exportChoiceMap.put(ExportChoice.includeLibs, true);
exportChoiceMap.put(ExportChoice.includeTestSource, false);
exportChoiceMap.put(ExportChoice.executeTests, false);
exportChoiceMap.put(ExportChoice.binaries, true);
exportChoiceMap.put(ExportChoice.needContext, true);
exportChoiceMap.put(ExportChoice.contextName, "Default");
exportChoiceMap.put(ExportChoice.applyToChildren, false);
exportChoiceMap.put(ExportChoice.needLog4jLevel, false);
exportChoiceMap.put(ExportChoice.log4jLevel, null);
exportChoiceMap.put(ExportChoice.needDependencies, true);
exportChoiceMap.put(ExportChoice.needParameterValues, false);
return exportChoiceMap;
}
private Item getItemById(String jobId) throws PersistenceException {
IRepositoryViewObject obj = ProxyRepositoryFactory.getInstance().getLastVersion(jobId);
return obj.getProperty().getItem();
}
private String getDestinationPath(Item item) {
return ExportJobUtil.getTmpFolderPath() + "/" + item.getProperty().getLabel() + ".zip";
}
private void validateBuildResult(ProcessItem jobItem, String destinationPath) throws Exception {
assertTrue(new File(destinationPath).exists());
ZipFile zip = null;
try {
zip = new ZipFile(destinationPath);
// jobInfo
ZipEntry jobInfoEntry = zip.getEntry("jobInfo.properties");
assertNotNull("Can't find the jobInfo.properties", jobInfoEntry);
final InputStream jobInfoStream = zip.getInputStream(jobInfoEntry);
Property property = jobItem.getProperty();
String jobName = property.getLabel();
String jobVersion = property.getVersion();
Properties jobInfoProp = new Properties();
jobInfoProp.load(jobInfoStream);
jobInfoStream.close();
assertEquals(property.getId(), jobInfoProp.getProperty("jobId"));
assertEquals(jobName, jobInfoProp.getProperty("job"));
assertEquals(jobVersion, jobInfoProp.getProperty("jobVersion"));
assertEquals(jobItem.getProcess().getJobType(), jobInfoProp.getProperty("jobType"));
assertEquals(jobItem.getProcess().getDefaultContext(), jobInfoProp.getProperty("contextName"));
final String technicalLabel = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
assertEquals(technicalLabel, jobInfoProp.getProperty("project"));
ZipEntry libEntry = zip.getEntry("lib");
assertNotNull("No lib folder", libEntry);
if (jobItem == jobWithChildrenItem) {
String dependencyFromParent = "commons-lang-2.5.jar";
ZipEntry dependencyEntry = zip.getEntry("lib/" + dependencyFromParent);
assertNotNull("No parent job dependency in lib folder", dependencyEntry);
String dependencyFromChild = "commons-lang-2.6.jar";
dependencyEntry = zip.getEntry("lib/" + dependencyFromChild);
assertNotNull("No child job dependency in lib folder", dependencyEntry);
}
if (jobItem == jobWithJobletItem) {
String dependencyFromJoblet = "commons-beanutils-1.9.2.jar";
ZipEntry dependencyEntry = zip.getEntry("lib/" + dependencyFromJoblet);
assertNotNull("No joblet dependency in lib folder", dependencyEntry);
}
if (jobItem == jobWithTestcaseItem) {
String dependencyFromTestcase = "c3p0-0.9.1.2.jar";
ZipEntry dependencyEntry = zip.getEntry("lib/" + dependencyFromTestcase);
assertNull("Should not have testcase dependency in lib folder", dependencyEntry);
String dependencyFromJobAndTestcase = "commons-io-2.4.jar";
dependencyEntry = zip.getEntry("lib/" + dependencyFromJobAndTestcase);
assertNotNull("No job dependency in lib folder", dependencyEntry);
}
// log4j
ZipEntry log4jXmlEntry = zip.getEntry(jobName + "/log4j.xml");
assertNotNull("No log4j.xml", log4jXmlEntry);
// shell, ps1, bat
ZipEntry batEntry = zip.getEntry(jobName + "/" + jobName + "_run.bat");
assertNotNull("No bat file", batEntry);
ZipEntry ps1Entry = zip.getEntry(jobName + "/" + jobName + "_run.ps1");
assertNotNull("No ps1 file", ps1Entry);
ZipEntry shEntry = zip.getEntry(jobName + "/" + jobName + "_run.sh");
assertNotNull("No shell file", shEntry);
String jobJarName = JavaResourcesHelper.getJobJarName(jobName, jobVersion);
ZipEntry jarEntry = zip.getEntry(jobName + "/" + jobJarName + ".jar");
assertNotNull("No job jar file", jarEntry);
if (jobItem == jobWithChildrenItem) {
String subJobJarName = JavaResourcesHelper.getJobJarName(childJobItem.getProperty().getLabel(),
childJobItem.getProperty().getVersion());
ZipEntry subjobJarEntry = zip.getEntry(jobName + "/" + subJobJarName + ".jar");
assertNotNull("No sub job jar file", subjobJarEntry);
}
// src
String jobFolderName = JavaResourcesHelper.getJobFolderName(jobName, jobVersion);
ZipEntry javaEntry = zip.getEntry(
jobName + "/src/main/java/" + technicalLabel.toLowerCase() + "/" + jobFolderName + "/" + jobName + ".java");
assertNotNull("No job source code file", javaEntry);
ZipEntry contextEntry = zip.getEntry(jobName + "/src/main/resources/" + technicalLabel.toLowerCase()
+ "/" + jobFolderName + "/contexts/Default.properties");
assertNotNull("No context file", contextEntry);
if (jobItem == jobWithTdqItem) {
// dq
ZipEntry tdq = zip.getEntry(jobName + "/items/reports/");
assertNotNull("Can't find the dq reports items", tdq);
assertTrue(tdq.isDirectory());
}
if (jobItem == jobWithTdmItem) {
// if the tdm is load
boolean isTDM = false;
IDesignerCoreService coreService = CorePlugin.getDefault().getDesignerCoreService();
if (coreService != null) {
IProcess process = coreService.getProcessFromProcessItem(jobItem);
for (INode node : process.getGeneratingNodes()) {
IElementParameter param = node.getElementParameter("COMPONENT_NAME");
if ("tHMap".equals(param.getValue())) {
isTDM = true;
break;
}
}
}
assertTrue("Not TDM item", isTDM);
ZipEntry tdmSettingEntry = zip.getEntry(
jobName + "/items/" + technicalLabel.toLowerCase() + "/.settings/com.oaklandsw.base.projectProps");
assertNotNull("Can't export tdm rightly", tdmSettingEntry);
// the __tdm has been moved into job jar. so need test it in jar.
// testbuildWithXXX_0_1.jar!/__tdm/...
JarInputStream jarStream = null;
try {
jarStream = new JarInputStream(zip.getInputStream(jarEntry));
boolean found = false;
JarEntry entry;
while ((entry = jarStream.getNextJarEntry()) != null) {
if (entry.getName().equals("__tdm/") && entry.isDirectory()) {
found = true;
break;
}
}
assertTrue("Can't find __tdm folder in job jar after build", found);
} finally {
if (jarStream != null) {
jarStream.close();
}
}
}
} finally {
if (zip != null) {
zip.close();
}
}
}
@After
public void tearDown() throws Exception {
ReponsitoryContextBridge.setProject(bridgeProject);
if (!testItems.isEmpty()) {
for (Item item : testItems) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
IRepositoryViewObject repObj = factory.getLastVersion(item.getProperty().getId());
if (repObj != null) {
factory.deleteObjectPhysical(repObj);
}
}
testItems.clear();
}
ExportJobUtil.deleteTempFiles();
if (!destinationPaths.isEmpty()) {
for (String destinationPath : destinationPaths) {
File file = new File(destinationPath);
if (file.exists()) {
file.delete();
}
}
destinationPaths.clear();
}
}
}
package org.talend.repository.handler;
import static org.junit.Assert.*;
import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.CorePlugin;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Project;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.designer.runprocess.IRunProcessService;
import org.talend.model.bridge.ReponsitoryContextBridge;
import org.talend.repository.ProjectManager;
import org.talend.repository.items.importexport.handlers.ImportExportHandlersManager;
import org.talend.repository.items.importexport.handlers.model.ImportItem;
import org.talend.repository.items.importexport.manager.ResourcesManager;
import org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager;
import org.talend.repository.items.importexport.ui.managers.ResourcesManagerFactory;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.ui.wizards.exportjob.JavaJobScriptsExportWSWizardPage.JobExportType;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.BuildJobManager;
import org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice;
import org.talend.repository.ui.wizards.exportjob.util.ExportJobUtil;
public class BuildJobHandlerTest {
private ProcessItem jobWithTdqItem;
private ProcessItem jobWithTdmItem;
private ProcessItem jobWithChildrenItem;
private ProcessItem jobWithJobletItem;
private ProcessItem jobWithTestcaseItem;
private ProcessItem childJobItem;
private Item jobletItem;
private List<Item> testItems;
private List<String> destinationPaths;
private Project bridgeProject;
private Map<ExportChoice, Object> exportChoiceMap;
private IRunProcessService runProcessService;
private static final String JOB_WITH_TDQ_ID = "_3TtbgD7OEeiHhJsSj16U_A";
private static final String JOB_WITH_TDM_ID = "_bWyBUAYbEeapTZ0aKwL_YA";
private static final String JOB_WITH_CHILDREN_ID = "_HGAFAD7OEeiNfpYj4K_XrA";
private static final String JOB_WITH_JOBLET_ID = "_FKbJID7OEeiNfpYj4K_XrA";
private static final String JOB_WITH_TESTCASE_ID = "_YmcxoHniEeiA8rKAx4YxMw";
private static final String JOB_CHILD_ID = "_JJsbED7OEeiNfpYj4K_XrA";
private static final String JOBLET_ID = "_V92qED7OEeiNfpYj4K_XrA";
@Before
public void setUp() throws Exception {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
runProcessService = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
}
assertNotNull(runProcessService);
// Fix the NPE for org.talend.designer.core.ui.editor.process.Process.createMainParameters(Process.java:401)
bridgeProject = ReponsitoryContextBridge.getProject();
ReponsitoryContextBridge.setProject(ProjectManager.getInstance().getCurrentProject().getEmfProject());
ImportExportHandlersManager importManager = new ImportExportHandlersManager();
URL testJobURL = FileLocator.find(Platform.getBundle("org.talend.repository.test"),
new Path("/resources/testBuildJob.zip"), null);
if (testJobURL != null) {
testJobURL = FileLocator.toFileURL(testJobURL);
}
File srcFile = new File(testJobURL.getFile());
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
ResourcesManager resManager = fileUnityManager.doUnify();
List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, new NullProgressMonitor());
assertTrue(projectRecords.size() > 0);
importManager.importItemRecords(new NullProgressMonitor(), resManager, projectRecords, true,
projectRecords.toArray(new ImportItem[0]), null);
jobWithTdqItem = (ProcessItem) getItemById(JOB_WITH_TDQ_ID);
jobWithTdmItem = (ProcessItem) getItemById(JOB_WITH_TDM_ID);
jobWithChildrenItem = (ProcessItem) getItemById(JOB_WITH_CHILDREN_ID);
jobWithJobletItem = (ProcessItem) getItemById(JOB_WITH_JOBLET_ID);
jobWithTestcaseItem = (ProcessItem) getItemById(JOB_WITH_TESTCASE_ID);
childJobItem = (ProcessItem) getItemById(JOB_CHILD_ID);
jobletItem = getItemById(JOBLET_ID);
testItems = new ArrayList<>();
testItems.add(jobWithTdqItem);
testItems.add(jobWithTdmItem);
testItems.add(jobWithChildrenItem);
testItems.add(jobWithJobletItem);
testItems.add(jobWithTestcaseItem);
testItems.add(childJobItem);
testItems.add(jobletItem);
initExportChoice();
destinationPaths = new ArrayList<>();
}
@Test
public void testBuildJobWithTDQ() throws Exception {
String destinationPath = getDestinationPath(jobWithTdqItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithTdqItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithTdqItem, destinationPath);
}
@Test
public void testBuildJobWithTDM() throws Exception {
String destinationPath = getDestinationPath(jobWithTdmItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithTdmItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithTdmItem, destinationPath);
}
@Test
public void testBuildJobWithChildren() throws Exception {
String destinationPath = getDestinationPath(jobWithChildrenItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithChildrenItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithChildrenItem, destinationPath);
}
@Test
public void testBuildJobWithJoblet() throws Exception {
String destinationPath = getDestinationPath(jobWithJobletItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithJobletItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithJobletItem, destinationPath);
}
@Test
public void testBuildJobWithTestcase() throws Exception {
String destinationPath = getDestinationPath(jobWithTestcaseItem);
destinationPaths.add(destinationPath);
BuildJobManager.getInstance().buildJob(destinationPath, jobWithTestcaseItem, "0.1", "Default", exportChoiceMap,
JobExportType.POJO, new NullProgressMonitor());
validateBuildResult(jobWithTestcaseItem, destinationPath);
}
private Map<ExportChoice, Object> initExportChoice() {
exportChoiceMap = new HashMap<ExportChoice, Object>();
exportChoiceMap.put(ExportChoice.needLauncher, true);
exportChoiceMap.put(ExportChoice.needSystemRoutine, true);
exportChoiceMap.put(ExportChoice.needUserRoutine, true);
exportChoiceMap.put(ExportChoice.needTalendLibraries, true);
exportChoiceMap.put(ExportChoice.needJobItem, false);
exportChoiceMap.put(ExportChoice.needJobScript, true);
exportChoiceMap.put(ExportChoice.needSourceCode, true);
exportChoiceMap.put(ExportChoice.includeLibs, true);
exportChoiceMap.put(ExportChoice.includeTestSource, false);
exportChoiceMap.put(ExportChoice.executeTests, false);
exportChoiceMap.put(ExportChoice.binaries, true);
exportChoiceMap.put(ExportChoice.needContext, true);
exportChoiceMap.put(ExportChoice.contextName, "Default");
exportChoiceMap.put(ExportChoice.applyToChildren, false);
exportChoiceMap.put(ExportChoice.needLog4jLevel, false);
exportChoiceMap.put(ExportChoice.log4jLevel, null);
exportChoiceMap.put(ExportChoice.needDependencies, true);
exportChoiceMap.put(ExportChoice.needParameterValues, false);
return exportChoiceMap;
}
private Item getItemById(String jobId) throws PersistenceException {
IRepositoryViewObject obj = ProxyRepositoryFactory.getInstance().getLastVersion(jobId);
return obj.getProperty().getItem();
}
private String getDestinationPath(Item item) {
return ExportJobUtil.getTmpFolderPath() + "/" + item.getProperty().getLabel() + ".zip";
}
private void validateBuildResult(ProcessItem jobItem, String destinationPath) throws Exception {
assertTrue(new File(destinationPath).exists());
ZipFile zip = null;
try {
zip = new ZipFile(destinationPath);
// jobInfo
ZipEntry jobInfoEntry = zip.getEntry("jobInfo.properties");
assertNotNull("Can't find the jobInfo.properties", jobInfoEntry);
final InputStream jobInfoStream = zip.getInputStream(jobInfoEntry);
Property property = jobItem.getProperty();
String jobName = property.getLabel();
String jobVersion = property.getVersion();
Properties jobInfoProp = new Properties();
jobInfoProp.load(jobInfoStream);
jobInfoStream.close();
assertEquals(property.getId(), jobInfoProp.getProperty("jobId"));
assertEquals(jobName, jobInfoProp.getProperty("job"));
assertEquals(jobVersion, jobInfoProp.getProperty("jobVersion"));
assertEquals(jobItem.getProcess().getJobType(), jobInfoProp.getProperty("jobType"));
assertEquals(jobItem.getProcess().getDefaultContext(), jobInfoProp.getProperty("contextName"));
final String technicalLabel = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
assertEquals(technicalLabel, jobInfoProp.getProperty("project"));
ZipEntry libEntry = zip.getEntry("lib");
assertNotNull("No lib folder", libEntry);
if (jobItem == jobWithChildrenItem) {
String dependencyFromParent = "commons-lang-2.5.jar";
ZipEntry dependencyEntry = zip.getEntry("lib/" + dependencyFromParent);
assertNotNull("No parent job dependency in lib folder", dependencyEntry);
String dependencyFromChild = "commons-lang-2.6.jar";
dependencyEntry = zip.getEntry("lib/" + dependencyFromChild);
assertNotNull("No child job dependency in lib folder", dependencyEntry);
}
if (jobItem == jobWithJobletItem) {
String dependencyFromJoblet = "commons-beanutils-1.9.2.jar";
ZipEntry dependencyEntry = zip.getEntry("lib/" + dependencyFromJoblet);
assertNotNull("No joblet dependency in lib folder", dependencyEntry);
}
if (jobItem == jobWithTestcaseItem) {
String dependencyFromTestcase = "c3p0-0.9.1.2.jar";
ZipEntry dependencyEntry = zip.getEntry("lib/" + dependencyFromTestcase);
assertNull("Should not have testcase dependency in lib folder", dependencyEntry);
String dependencyFromJobAndTestcase = "commons-io-2.4.jar";
dependencyEntry = zip.getEntry("lib/" + dependencyFromJobAndTestcase);
assertNotNull("No job dependency in lib folder", dependencyEntry);
}
// log4j
ZipEntry log4jXmlEntry = zip.getEntry(jobName + "/log4j.xml");
assertNotNull("No log4j.xml", log4jXmlEntry);
// shell, ps1, bat
ZipEntry batEntry = zip.getEntry(jobName + "/" + jobName + "_run.bat");
assertNotNull("No bat file", batEntry);
ZipEntry ps1Entry = zip.getEntry(jobName + "/" + jobName + "_run.ps1");
assertNotNull("No ps1 file", ps1Entry);
ZipEntry shEntry = zip.getEntry(jobName + "/" + jobName + "_run.sh");
assertNotNull("No shell file", shEntry);
String jobJarName = JavaResourcesHelper.getJobJarName(jobName, jobVersion);
ZipEntry jarEntry = zip.getEntry(jobName + "/" + jobJarName + ".jar");
assertNotNull("No job jar file", jarEntry);
if (jobItem == jobWithChildrenItem) {
String subJobJarName = JavaResourcesHelper.getJobJarName(childJobItem.getProperty().getLabel(),
childJobItem.getProperty().getVersion());
ZipEntry subjobJarEntry = zip.getEntry(jobName + "/" + subJobJarName + ".jar");
assertNotNull("No sub job jar file", subjobJarEntry);
}
// src
String jobFolderName = JavaResourcesHelper.getJobFolderName(jobName, jobVersion);
ZipEntry javaEntry = zip.getEntry(
jobName + "/src/main/java/" + technicalLabel.toLowerCase() + "/" + jobFolderName + "/" + jobName + ".java");
assertNotNull("No job source code file", javaEntry);
ZipEntry contextEntry = zip.getEntry(jobName + "/src/main/resources/" + technicalLabel.toLowerCase()
+ "/" + jobFolderName + "/contexts/Default.properties");
assertNotNull("No context file", contextEntry);
if (jobItem == jobWithTdqItem) {
// dq
ZipEntry tdq = zip.getEntry(jobName + "/items/reports/");
assertNotNull("Can't find the dq reports items", tdq);
assertTrue(tdq.isDirectory());
}
if (jobItem == jobWithTdmItem) {
// if the tdm is load
boolean isTDM = false;
IDesignerCoreService coreService = CorePlugin.getDefault().getDesignerCoreService();
if (coreService != null) {
IProcess process = coreService.getProcessFromProcessItem(jobItem);
for (INode node : process.getGeneratingNodes()) {
IElementParameter param = node.getElementParameter("COMPONENT_NAME");
if ("tHMap".equals(param.getValue())) {
isTDM = true;
break;
}
}
}
assertTrue("Not TDM item", isTDM);
ZipEntry tdmSettingEntry = zip.getEntry(
jobName + "/items/" + technicalLabel.toLowerCase() + "/.settings/com.oaklandsw.base.projectProps");
assertNotNull("Can't export tdm rightly", tdmSettingEntry);
// the __tdm has been moved into job jar. so need test it in jar.
// testbuildWithXXX_0_1.jar!/__tdm/...
JarInputStream jarStream = null;
try {
jarStream = new JarInputStream(zip.getInputStream(jarEntry));
boolean found = false;
JarEntry entry;
while ((entry = jarStream.getNextJarEntry()) != null) {
if (entry.getName().equals("__tdm/") && entry.isDirectory()) {
found = true;
break;
}
}
assertTrue("Can't find __tdm folder in job jar after build", found);
} finally {
if (jarStream != null) {
jarStream.close();
}
}
}
} finally {
if (zip != null) {
zip.close();
}
}
}
@After
public void tearDown() throws Exception {
ReponsitoryContextBridge.setProject(bridgeProject);
if (!testItems.isEmpty()) {
for (Item item : testItems) {
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
IRepositoryViewObject repObj = factory.getLastVersion(item.getProperty().getId());
if (repObj != null) {
factory.deleteObjectPhysical(repObj);
}
}
testItems.clear();
}
ExportJobUtil.deleteTempFiles();
if (!destinationPaths.isEmpty()) {
for (String destinationPath : destinationPaths) {
File file = new File(destinationPath);
if (file.exists()) {
file.delete();
}
}
destinationPaths.clear();
}
}
}