Compare commits
162 Commits
patch/TPS-
...
patch/7.2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e408ee84c5 | ||
|
|
10914b92bd | ||
|
|
1efd7570d3 | ||
|
|
5b8e8a86ba | ||
|
|
816bb48c60 | ||
|
|
f80c5e54ec | ||
|
|
233e2a33fd | ||
|
|
f559f4c5ea | ||
|
|
0667640551 | ||
|
|
5cc003d379 | ||
|
|
da471ce3c4 | ||
|
|
1ca6dda3cf | ||
|
|
89675c4b23 | ||
|
|
0133dd05e8 | ||
|
|
b9e13df05d | ||
|
|
f777b52c4a | ||
|
|
c5e0d7119b | ||
|
|
2819dc3566 | ||
|
|
ad979090a0 | ||
|
|
db0a65fcdb | ||
|
|
7b0ccc6793 | ||
|
|
2637f4f0e4 | ||
|
|
409131fac1 | ||
|
|
636c261cf5 | ||
|
|
0e09d928c1 | ||
|
|
7f2b14e9fe | ||
|
|
67dec82a79 | ||
|
|
7988529bfd | ||
|
|
6e5e614f62 | ||
|
|
9158251a31 | ||
|
|
2193cb5bc6 | ||
|
|
92143bc9d9 | ||
|
|
5886a9ea1e | ||
|
|
8e11d18951 | ||
|
|
18ae07abed | ||
|
|
89a48f51e3 | ||
|
|
6b0ccf8623 | ||
|
|
3df34392cd | ||
|
|
17687cbe3d | ||
|
|
386eec46c3 | ||
|
|
fd72c4d991 | ||
|
|
2f5a499389 | ||
|
|
759eaa73f0 | ||
|
|
d85a5c0e08 | ||
|
|
5c9f99b54e | ||
|
|
e5ce502008 | ||
|
|
ccfbf51dff | ||
|
|
d2b0c87288 | ||
|
|
6cf2cae1b6 | ||
|
|
604fb23a71 | ||
|
|
e3f6f81cde | ||
|
|
26ff46ddeb | ||
|
|
cd955b7ad4 | ||
|
|
dc11694fd1 | ||
|
|
b1598aca9f | ||
|
|
938c1dadb2 | ||
|
|
ba7622b528 | ||
|
|
2cdfb08e18 | ||
|
|
33fb855c55 | ||
|
|
e6458bc956 | ||
|
|
699ac6f1d4 | ||
|
|
eeb99e841b | ||
|
|
5af3d5faa2 | ||
|
|
cd90676406 | ||
|
|
df3e6451d9 | ||
|
|
67c2ee7982 | ||
|
|
44c8adafc5 | ||
|
|
9b05cd445d | ||
|
|
feccc56372 | ||
|
|
4002ebf11c | ||
|
|
ca0734292e | ||
|
|
ade3d8ea9f | ||
|
|
642afd4c61 | ||
|
|
73b0ef1715 | ||
|
|
a88d5d7da6 | ||
|
|
66baf2369a | ||
|
|
a71f6b26b9 | ||
|
|
68f7ea24cc | ||
|
|
c32f6c1097 | ||
|
|
0234a23a9c | ||
|
|
a604485e3a | ||
|
|
1337af08ad | ||
|
|
a0669d27fc | ||
|
|
a62487a9f0 | ||
|
|
51f7668e49 | ||
|
|
5db747c247 | ||
|
|
9a8d085a05 | ||
|
|
39c9616bb5 | ||
|
|
691e5ed912 | ||
|
|
24c60f1920 | ||
|
|
0b047b73b6 | ||
|
|
d1b60e2e3f | ||
|
|
7329a7558e | ||
|
|
956891d18c | ||
|
|
50810ed439 | ||
|
|
9420056b37 | ||
|
|
5957b4993c | ||
|
|
5b664d9852 | ||
|
|
7cbef2f37f | ||
|
|
4cc93be67f | ||
|
|
f120c7c4dd | ||
|
|
564ed2618d | ||
|
|
5d4c8cc9d9 | ||
|
|
c6647a76a8 | ||
|
|
a1fd9f361b | ||
|
|
2ad1c00b63 | ||
|
|
98db49e280 | ||
|
|
6a6be36610 | ||
|
|
ddb69232e5 | ||
|
|
a4ffd73a24 | ||
|
|
6bb63c2a6d | ||
|
|
e7881d1ecd | ||
|
|
8b879dcbbd | ||
|
|
87b860b0b1 | ||
|
|
3f5a74d847 | ||
|
|
dd6501d8c6 | ||
|
|
9b736bf30a | ||
|
|
09b2ad8aa6 | ||
|
|
245f1c42c2 | ||
|
|
03085d1574 | ||
|
|
5fb4589799 | ||
|
|
7a69ed4c4d | ||
|
|
a38fec9792 | ||
|
|
4cef94aff4 | ||
|
|
09169a8664 | ||
|
|
391704ac42 | ||
|
|
9e693e6f89 | ||
|
|
eee97f1977 | ||
|
|
095c79cbf2 | ||
|
|
2884b847d5 | ||
|
|
96d4930a0a | ||
|
|
e8f2adce2d | ||
|
|
34396d7182 | ||
|
|
82d238deff | ||
|
|
4487a6d33e | ||
|
|
70469391d8 | ||
|
|
7ea110dc3c | ||
|
|
fcad4148f5 | ||
|
|
ebe98a4d67 | ||
|
|
cd23062e30 | ||
|
|
5990df09b0 | ||
|
|
4f5b39d2da | ||
|
|
c9c9d4df22 | ||
|
|
9f4d4fc832 | ||
|
|
cc93b9959b | ||
|
|
94e2442e11 | ||
|
|
079ce620ab | ||
|
|
535af6359e | ||
|
|
0544da1147 | ||
|
|
bdb27eaf55 | ||
|
|
c4b9def853 | ||
|
|
9b31f616f7 | ||
|
|
3c8552e58c | ||
|
|
81f603037b | ||
|
|
3c9ff7e553 | ||
|
|
6611515bd6 | ||
|
|
66dfb4f0bf | ||
|
|
75b74d2c17 | ||
|
|
92e5a0801d | ||
|
|
62ce41a0e9 | ||
|
|
aa9c2b08b9 | ||
|
|
37c58a98cd |
@@ -52,7 +52,7 @@ ProcessDebugDialog.errortext=Impossible de d\u00E9bugger le job.\\nV\u00E9rifiez
|
||||
ShadowProcess.notGeneratedOutputException=Sortie non g\u00E9n\u00E9r\u00E9e.
|
||||
ProcessComposite.contextGroup=Contexte
|
||||
prefs.clientConfiguration=Configuration du client Talend
|
||||
ProcessComposite.endPattern=Le Job {0} s'est termin\u00E9 \u00E0 {1,date,HH:mm dd/MM/yyyy}. [code de sortie={2,number}]
|
||||
ProcessComposite.endPattern=Job {0} termin\u00e9 \u00e0 {1,date,HH\:mm dd/MM/yyyy}. [Code sortie\=\{2,number}]
|
||||
ProcessView.title=Ex\u00E9cuter({0})
|
||||
Processor.configurePerl=L'interpr\u00E9teur Perl n'est pas configur\u00E9.
|
||||
JavaProcessor.notFoundedFolderException=Dossier introuvable dans le projet .Java
|
||||
|
||||
@@ -584,7 +584,16 @@
|
||||
} //endIf
|
||||
%>
|
||||
context.setContextType("<%=ctxParam.getName()%>", "<%=ctxParam.getType()%>");
|
||||
if(context.getStringValue("<%=ctxParam.getName()%>") == null) {
|
||||
context.<%=ctxParam.getName()%> = null;
|
||||
} else {
|
||||
<%//}B1 block%>
|
||||
<%
|
||||
String typeToGenerate ="String";
|
||||
if( !(ctxParam.getType().equals("id_File") || ctxParam.getType().equals("id_Directory") ||ctxParam.getType().equals("id_List Of Value"))) {
|
||||
typeToGenerate=JavaTypesManager.getTypeToGenerate(ctxParam.getType(),true);
|
||||
}
|
||||
|
||||
if (ctxParam.getType().equals("id_Password")) {
|
||||
%>
|
||||
String pwd_<%=ctxParam.getName()%>_value = context.getProperty("<%=ctxParam.getName()%>");
|
||||
@@ -602,13 +611,7 @@
|
||||
}
|
||||
}
|
||||
<%
|
||||
continue;
|
||||
}
|
||||
String typeToGenerate ="String";
|
||||
if( !(ctxParam.getType().equals("id_File") || ctxParam.getType().equals("id_Directory") ||ctxParam.getType().equals("id_List Of Value"))) {
|
||||
typeToGenerate=JavaTypesManager.getTypeToGenerate(ctxParam.getType(),true);
|
||||
}
|
||||
if(typeToGenerate.equals("java.util.Date")) {
|
||||
} else if(typeToGenerate.equals("java.util.Date")) {
|
||||
%>
|
||||
try{
|
||||
String context_<%=ctxParam.getName()%>_value = context.getProperty("<%=ctxParam.getName()%>");
|
||||
@@ -667,6 +670,10 @@
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<%//{B1 block%>
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
} <%/*close last method*/%>
|
||||
@@ -1159,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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
<% } %>
|
||||
|
||||
|
||||
@@ -289,6 +289,15 @@ if(isRunInMultiThread){
|
||||
}
|
||||
<% } %>
|
||||
}
|
||||
|
||||
//if the stored or passed value is "<TALEND_NULL>" string, it mean null
|
||||
public String getStringValue(String key) {
|
||||
String origin_value = this.getProperty(key);
|
||||
if(NULL_VALUE_EXPRESSION_IN_COMMAND_STRING_FOR_CHILD_JOB_ONLY.equals(origin_value)) {
|
||||
return null;
|
||||
}
|
||||
return origin_value;
|
||||
}
|
||||
|
||||
<%
|
||||
for (IContextParameter ctxParam :params)
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.talend.designer.codegen.model.CodeGeneratorEmittersPoolFactory;
|
||||
import org.talend.designer.codegen.model.CodeGeneratorInternalTemplatesFactoryProvider;
|
||||
import org.talend.designer.codegen.proxy.JetProxy;
|
||||
import org.talend.designer.core.generic.model.Component;
|
||||
import org.talend.designer.runprocess.ProcessorUtilities;
|
||||
|
||||
/**
|
||||
* CodeGenerator.
|
||||
@@ -353,8 +354,12 @@ public class CodeGenerator implements ICodeGenerator {
|
||||
.getDefault().getService(IResourcesDependenciesService.class);
|
||||
String resourcePathForContext = null;
|
||||
if (process instanceof IProcess2) {
|
||||
resourcePathForContext = resourceService.getResourcePathForContext(process,
|
||||
contextPar.getValue());
|
||||
String value = contextPar.getValue();
|
||||
// for runtime
|
||||
if (!ProcessorUtilities.isExportConfig()) {
|
||||
contextPar.setType(JavaTypesManager.FILE.getId());
|
||||
}
|
||||
resourcePathForContext = resourceService.getResourcePathForContext(process, value);
|
||||
} else {
|
||||
// for PreviewFileInputContentDataProcess run
|
||||
resourcePathForContext = resourceService.getResourceItemFilePath(contextPar.getValue());
|
||||
|
||||
@@ -94,7 +94,7 @@ public class JavaRoutineSynchronizer extends AbstractRoutineSynchronizer {
|
||||
|
||||
private void syncRoutineItems(Collection<RoutineItem> routineObjects, boolean forceUpdate) throws SystemException {
|
||||
for (RoutineItem routineItem : routineObjects) {
|
||||
syncRoutine(routineItem, true, true, forceUpdate);
|
||||
syncRoutine(routineItem, true, forceUpdate);
|
||||
}
|
||||
syncSystemRoutine(ProjectManager.getInstance().getCurrentProject());
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
@@ -70,7 +70,6 @@ import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.ComponentManager;
|
||||
import org.talend.core.model.components.ComponentProviderInfo;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.EComponentType;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.components.IComponentsHandler;
|
||||
@@ -838,23 +837,21 @@ public class ComponentsFactory implements IComponentsFactory {
|
||||
init(false);
|
||||
}
|
||||
|
||||
for (IComponent comp : componentList) {
|
||||
if (comp.getComponentType() != EComponentType.JOBLET) {
|
||||
continue;
|
||||
}
|
||||
String comName = comp.getName();
|
||||
if (comp != null && paletteType.equals(comp.getPaletteType())) {
|
||||
if (comName.equals(name)) {
|
||||
return comp;
|
||||
} else if (new JobletUtil().matchExpression(comName)) {
|
||||
String[] names = comName.split(":"); //$NON-NLS-1$
|
||||
comName = names[1];
|
||||
if (comName.equals(name)) {
|
||||
return comp;
|
||||
}
|
||||
// check if reference joblet component presents
|
||||
JobletUtil jobletUtils = new JobletUtil();
|
||||
Optional<IComponent> result = jobletUtils.findComponentByName(componentList, name, paletteType);
|
||||
if (!result.isPresent()) {
|
||||
// check if any name matching joblet component presents
|
||||
if (jobletUtils.matchExpression(name)) {
|
||||
name = StringUtils.substringAfterLast(name, ":"); //$NON-NLS-1$
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
result = jobletUtils.findComponentByName(componentList, name, paletteType);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.isPresent()) {
|
||||
return result.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 + "");
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.talend.sap;
|
||||
|
||||
public enum SAPParameterType {
|
||||
IMPORT,
|
||||
CHANGING,
|
||||
TABLES,
|
||||
EXPORT
|
||||
}
|
||||
@@ -569,17 +569,18 @@
|
||||
loadJobBuilder_<%=cid%>.setDestinationTable(tableId_<%=cid%>);
|
||||
com.google.cloud.bigquery.CsvOptions.Builder csvOptions_<%=cid%> = com.google.cloud.bigquery.CsvOptions.newBuilder();
|
||||
csvOptions_<%=cid%>.setAllowQuotedNewLines(true);
|
||||
csvOptions_<%=cid%>.setSkipLeadingRows(<%=ElementParameterParser.getValue(node, "__GS_FILE_HEADER__")%>);
|
||||
|
||||
<%if("true".equals(ElementParameterParser.getValue(node, "__SET_FIELD_DELIMITER__"))) {
|
||||
%>
|
||||
loadJobBuilder_<%=cid%>.setFormatOptions(csvOptions_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>).build());
|
||||
csvOptions_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
loadJobBuilder_<%=cid%>.setFormatOptions(csvOptions_<%=cid%>.build());
|
||||
loadJobBuilder_<%=cid%>.setNullMarker("\\N");
|
||||
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.of(loadJobBuilder_<%=cid%>.build()));
|
||||
job_<%=cid%> = job_<%=cid%>.waitFor(com.google.cloud.RetryOption.initialRetryDelay(org.threeten.bp.Duration.ofSeconds(1)), com.google.cloud.RetryOption.totalTimeout(org.threeten.bp.Duration.ofSeconds(30)));
|
||||
job_<%=cid%> = job_<%=cid%>.waitFor(com.google.cloud.RetryOption.initialRetryDelay(org.threeten.bp.Duration.ofSeconds(1)));
|
||||
if (job_<%=cid%> != null && job_<%=cid%>.getStatus().getError() == null) {
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
|
||||
@@ -221,10 +221,9 @@
|
||||
}
|
||||
|
||||
String query_<%=cid%> = <%=query%>;
|
||||
String dataset = query_<%=cid%>.substring(query_<%=cid%>.indexOf("from") + 4, query_<%=cid%>.indexOf(".")).trim();
|
||||
String temp_table = "temp_" + dataset + java.util.UUID.randomUUID().toString().replaceAll("-", "")
|
||||
+ "<%=cid%>".toLowerCase().replaceAll("[^a-z0-9]", "0").replaceAll("^[^a-z]", "a")
|
||||
+ Integer.toHexString(java.util.concurrent.ThreadLocalRandom.current().nextInt());
|
||||
<% if(isLog4jEnabled) { %>
|
||||
log.info("<%=cid%> - query " + <%=query%>);
|
||||
<% } %>
|
||||
|
||||
com.google.cloud.bigquery.BigQuery bigquery_<%=cid%> = com.google.cloud.bigquery.BigQueryOptions.newBuilder()
|
||||
.setCredentials(credentials_<%=cid%>)
|
||||
@@ -233,25 +232,55 @@
|
||||
.getService();
|
||||
|
||||
com.google.cloud.bigquery.QueryJobConfiguration.Builder queryConfiguration_<%=cid%> = com.google.cloud.bigquery.QueryJobConfiguration.newBuilder(<%=query%>).setUseLegacySql(<%=useLegacySql%>);
|
||||
|
||||
<%
|
||||
if (resultSizeType.equals("LARGE") || resultSizeType.equals("AUTO")) {
|
||||
%>
|
||||
queryConfiguration_<%=cid%>.setDestinationTable(com.google.cloud.bigquery.TableId.of(dataset, temp_table)).setAllowLargeResults(true);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
com.google.cloud.bigquery.JobId jobId_<%=cid%> = com.google.cloud.bigquery.JobId.of(java.util.UUID.randomUUID().toString());
|
||||
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.newBuilder(queryConfiguration_<%=cid%>.build()).setJobId(jobId_<%=cid%>).build());
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
<%if (resultSizeType.equals("LARGE") || resultSizeType.equals("AUTO")) {%>
|
||||
|
||||
com.google.cloud.bigquery.QueryJobConfiguration jobConfDryRun_<%=cid%> = queryConfiguration_<%=cid%> .setDryRun(true).build();
|
||||
com.google.cloud.bigquery.Job jobDryRun_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.of(jobConfDryRun_<%=cid%>));
|
||||
|
||||
String queryLocation_<%=cid%> =jobDryRun_<%=cid%>.getJobId().getLocation();
|
||||
String location_<%=cid%> = queryLocation_<%=cid%> == null ? "US" : queryLocation_<%=cid%>;
|
||||
String tempDataset_<%=cid%> = java.util.UUID.randomUUID().toString().replaceAll("-", "")
|
||||
+ Integer.toHexString(java.util.concurrent.ThreadLocalRandom.current().nextInt())
|
||||
+ Integer.toHexString(java.util.concurrent.ThreadLocalRandom.current().nextInt());
|
||||
String tempTable_<%=cid%> = java.util.UUID.randomUUID().toString().replaceAll("-", "")
|
||||
+ Integer.toHexString(java.util.concurrent.ThreadLocalRandom.current().nextInt())
|
||||
+ Integer.toHexString(java.util.concurrent.ThreadLocalRandom.current().nextInt());
|
||||
<% if(isLog4jEnabled){ %>
|
||||
log.info("<%=cid%> - query location :" + queryLocation_<%=cid%>);
|
||||
log.info("<%=cid%> - temporary dataset location :" + location_<%=cid%>);
|
||||
log.info("<%=cid%> - temporary Dataset name : " + tempDataset_<%=cid%>);
|
||||
log.info("<%=cid%> - temporary table name : " + tempTable_<%=cid%>);
|
||||
<% } %>
|
||||
|
||||
com.google.cloud.bigquery.DatasetInfo datasetInfo_<%=cid%> = com.google.cloud.bigquery.DatasetInfo.newBuilder(tempDataset_<%=cid%>).setLocation(location_<%=cid%>).build();
|
||||
com.google.cloud.bigquery.Dataset dataset_<%=cid%> = bigquery_<%=cid%> .create(datasetInfo_<%=cid%>);
|
||||
|
||||
queryConfiguration_<%=cid%>
|
||||
.setDryRun(false)
|
||||
.setAllowLargeResults(true)
|
||||
.setDestinationTable(com.google.cloud.bigquery.TableId.of(tempDataset_<%=cid%>, tempTable_<%=cid%>));
|
||||
|
||||
com.google.cloud.bigquery.JobId jobId_<%=cid%> = com.google.cloud.bigquery.JobId
|
||||
.newBuilder().setProject(<%=projectId%>)
|
||||
.setJob(java.util.UUID.randomUUID().toString())
|
||||
.setLocation(location_<%=cid%>)
|
||||
.build();
|
||||
|
||||
<% if(isLog4jEnabled){ %>
|
||||
log.info("<%=cid%> - job location : " + jobId_<%=cid%>.getLocation());
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
com.google.cloud.bigquery.JobId jobId_<%=cid%> = com.google.cloud.bigquery.JobId.of(<%=projectId%>,java.util.UUID.randomUUID().toString());
|
||||
|
||||
<% } %>
|
||||
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.newBuilder(queryConfiguration_<%=cid%>.build()).setJobId(jobId_<%=cid%>).build());
|
||||
|
||||
|
||||
<% if(isLog4jEnabled) { %>
|
||||
log.info("<%=cid%> - Sending job " + jobId_<%=cid%> + " with query: " + <%=query%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<% } %>
|
||||
|
||||
job_<%=cid%> = job_<%=cid%>.waitFor();
|
||||
|
||||
if (job_<%=cid%> == null) {
|
||||
@@ -260,13 +289,9 @@
|
||||
throw new RuntimeException(job_<%=cid%>.getStatus().getError().toString());
|
||||
}
|
||||
|
||||
<%
|
||||
if(isLog4jEnabled){
|
||||
%>
|
||||
<% if(isLog4jEnabled) { %>
|
||||
log.info("<%=cid%> - Job " + jobId_<%=cid%> + " finished successfully.");
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<% } %>
|
||||
com.google.cloud.bigquery.TableResult result_<%=cid%> = job_<%=cid%>.getQueryResults();
|
||||
long nb_line_<%=cid%> = 0;
|
||||
<%
|
||||
|
||||
@@ -10,7 +10,10 @@ imports="
|
||||
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
String cid = node.getUniqueName();
|
||||
String authMode = ElementParameterParser.getValue(node,"__AUTH_MODE__");
|
||||
String authMode = ElementParameterParser.getValue(node,"__AUTH_MODE__");
|
||||
String projectId = ElementParameterParser.getValue(node,"__PROJECT_ID__");
|
||||
String resultSizeType = ElementParameterParser.getValue(node,"__RESULT_SIZE__");
|
||||
|
||||
if (authMode.equals("OAUTH")) {
|
||||
%>
|
||||
}
|
||||
@@ -24,7 +27,10 @@ imports="
|
||||
} else if (authMode.equals("SERVICEACCOUNT")) {
|
||||
%>
|
||||
}
|
||||
bigquery_<%=cid%>.delete(com.google.cloud.bigquery.TableId.of(dataset, temp_table));
|
||||
<% if (resultSizeType.equals("LARGE") || resultSizeType.equals("AUTO")) { %>
|
||||
com.google.cloud.bigquery.DatasetId datasetId_<%=cid%> = com.google.cloud.bigquery.DatasetId.of(<%=projectId%>, tempDataset_<%=cid%>);
|
||||
bigquery_<%=cid%>.delete(datasetId_<%=cid%>, com.google.cloud.bigquery.BigQuery.DatasetDeleteOption.deleteContents());
|
||||
<% }%>
|
||||
<%
|
||||
} else {
|
||||
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
org.talend.designer.dbmap.language.generation.GenericDbGenerationManager gm = new org.talend.designer.dbmap.language.generation.GenericDbGenerationManager();
|
||||
org.talend.designer.dbmap.language.mssql.MssqlGenerationManager gm = new org.talend.designer.dbmap.language.mssql.MssqlGenerationManager();
|
||||
String uniqueNameComponent = null;
|
||||
IDbLanguage currentLanguage = gm.getLanguage();
|
||||
|
||||
|
||||
@@ -305,48 +305,54 @@ for(Column colStmt:stmtStructure){
|
||||
|
||||
if(("INSERT").equals(dataAction)){
|
||||
%>
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
String insertQuery_<%=cid %> = "INSERT INTO "+tableName_<%=cid%>+"(<%=insertColName.toString()%>) ("+select_query_<%=cid %>+")";
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(insertQuery_<%=cid %>);
|
||||
|
||||
<%
|
||||
}else if (("UPDATE").equals(dataAction)){
|
||||
if(useUpdateStatement){
|
||||
if(useUpdateStatement){
|
||||
%>
|
||||
String updateQuery_<%=cid %> = select_query_<%=cid %>
|
||||
String updateQuery_<%=cid %> = select_query_<%=cid %>;
|
||||
<%
|
||||
}else{
|
||||
}else{
|
||||
%>
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> "
|
||||
String updateQuery_<%=cid %> = "UPDATE "+tableName_<%=cid%>+" SET <%=updateSetStmt.toString()%> ";
|
||||
<%
|
||||
}
|
||||
}
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
if(useUpdateStatement){
|
||||
%>
|
||||
if(select_query_<%=cid %>.indexOf("WHERE")==-1){
|
||||
updateQuery_<%=cid %> +=" WHERE ";
|
||||
}else{
|
||||
updateQuery_<%=cid %> +=" AND ";
|
||||
}
|
||||
updateQuery_<%=cid %>+= <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
<%
|
||||
}else{
|
||||
%>
|
||||
updateQuery_<%=cid %> += " WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>;
|
||||
<%
|
||||
}
|
||||
}
|
||||
%>
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" WHERE " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(updateQuery_<%=cid %>);
|
||||
<%
|
||||
}else if (("DELETE").equals(dataAction)){
|
||||
%>
|
||||
|
||||
String deleteQuery_<%=cid %> = "DELETE FROM "+ tableName_<%=cid%>+" WHERE EXISTS ("+select_query_<%=cid %>+") "
|
||||
<%
|
||||
if(CodeGenerationUtils.hasAlphaNumericCharacter(whereClause)) {
|
||||
%>
|
||||
+" AND " + <%=CodeGenerationUtils.replaceAllCrBySpace(whereClause)%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
;
|
||||
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement(deleteQuery_<%=cid %>);
|
||||
|
||||
<%
|
||||
}
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
int nb_line_updated_<%=cid%> = 0;
|
||||
int nb_line_inserted_<%=cid%> = 0;
|
||||
|
||||
@@ -33,4 +33,4 @@ USE_DIFFERENT_TABLE.NAME=Use different table name
|
||||
DIFFERENT_TABLE_NAME.NAME=Table name
|
||||
IS_TABLE_NAME_VARIABLE.NAME=Table name from connection name is variable
|
||||
|
||||
USE_UPDATE_STATEMENT.NAME=Use update statement
|
||||
USE_UPDATE_STATEMENT.NAME=Use update statement without subqueries
|
||||
@@ -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>
|
||||
|
||||
@@ -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 %>+") "
|
||||
|
||||
@@ -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
|
||||
@@ -13,9 +13,22 @@
|
||||
INode node = (INode)codeGenArgument.getArgument();
|
||||
String cid = node.getUniqueName();
|
||||
String confLib = ElementParameterParser.getValue(node, "__CONF_LIB__");
|
||||
Boolean setHadoopConf = ElementParameterParser.getBooleanValue(node, "__SET_HADOOP_CONF__");
|
||||
String customHadoopConfPath = ElementParameterParser.getValue(node, "__HADOOP_CONF_SPECIFIC_JAR__");
|
||||
if (setHadoopConf == null) {
|
||||
setHadoopConf = Boolean.FALSE;
|
||||
}
|
||||
%>
|
||||
|
||||
<% if(confLib != null && confLib.length() > 0){%>
|
||||
<% if((confLib != null && confLib.length() > 0) || setHadoopConf){%>
|
||||
|
||||
String libPath_<%=cid %> = "";
|
||||
|
||||
<% if (setHadoopConf) { %>
|
||||
|
||||
libPath_<%=cid %> = <%=customHadoopConfPath %>;
|
||||
|
||||
<% } else { %>
|
||||
|
||||
class DealJobLibrary_<%=cid%> {
|
||||
|
||||
@@ -75,14 +88,9 @@ class DealJobLibrary_<%=cid%> {
|
||||
|
||||
}
|
||||
|
||||
java.net.URLClassLoader currentLoader<%=cid %> = (java.net.URLClassLoader) Thread.currentThread().getContextClassLoader();
|
||||
java.lang.reflect.Method method_<%=cid %> = java.net.URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { java.net.URL.class });
|
||||
method_<%=cid %>.setAccessible(true);
|
||||
|
||||
DealJobLibrary_<%=cid%> dealJobLibrary = new DealJobLibrary_<%=cid%>();
|
||||
String confJarName = dealJobLibrary.getConfJarName(<%=confLib %>, this.contextStr);
|
||||
|
||||
String libPath_<%=cid %> = "";
|
||||
<%if (ProcessorUtilities.isExportConfig()) {%>
|
||||
libPath_<%=cid %> = "../lib/" + confJarName;
|
||||
<%} else {
|
||||
@@ -90,6 +98,11 @@ String libPath_<%=cid %> = "";
|
||||
libPath_<%=cid %> = new java.io.File("<%=libFolder %>/" + confJarName).getAbsolutePath();
|
||||
<%}%>
|
||||
libPath_<%=cid %> = dealJobLibrary.replaceJarPathsFromCrcMap(libPath_<%=cid %>);
|
||||
<%}%>
|
||||
|
||||
java.net.URLClassLoader currentLoader<%=cid %> = (java.net.URLClassLoader) Thread.currentThread().getContextClassLoader();
|
||||
java.lang.reflect.Method method_<%=cid %> = java.net.URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { java.net.URL.class });
|
||||
method_<%=cid %>.setAccessible(true);
|
||||
method_<%=cid %>.invoke(currentLoader<%=cid %>, new Object[] { new java.io.File(libPath_<%=cid %>).toURL() });
|
||||
|
||||
<%}%>
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
>
|
||||
<DEFAULT></DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="SET_HADOOP_CONF" FIELD="CHECK" NUM_ROW="2" REPOSITORY_VALUE="SET_HADOOP_CONF" >
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
<PARAMETER NAME="HADOOP_CONF_SPECIFIC_JAR" FIELD="TEXT" NUM_ROW="2" REPOSITORY_VALUE="HADOOP_CONF_SPECIFIC_JAR" >
|
||||
<DEFAULT>"path/to/hadoop_conf.jar"</DEFAULT>
|
||||
</PARAMETER>
|
||||
</PARAMETERS>
|
||||
|
||||
<CODEGENERATION></CODEGENERATION>
|
||||
|
||||
@@ -208,6 +208,8 @@ boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.ge
|
||||
mc_<%=cid%>.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
|
||||
mc_<%=cid%>.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
|
||||
javax.activation.CommandMap.setDefaultCommandMap(mc_<%=cid%>);
|
||||
// add com.sun.mail.handlers to job imports / depenencies (TESB-27110)
|
||||
com.sun.mail.handlers.text_plain text_plain_h_<%=cid%> = null;
|
||||
// -- Send the message --
|
||||
javax.mail.Transport.send(msg_<%=cid %>);
|
||||
} catch(java.lang.Exception e){
|
||||
|
||||
@@ -106,7 +106,12 @@
|
||||
REQUIRED="false" NUM_ROW="11">
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
|
||||
<PARAMETER NAME="IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY" FIELD="CHECK" NUM_ROW="11"
|
||||
SHOW_IF="CREATE_EMPTY_ELEMENT=='false'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="EXPAND_EMPTY_ELM" FIELD="CHECK" NUM_ROW="11"
|
||||
SHOW_IF="CREATE_EMPTY_ELEMENT=='true'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
@@ -173,6 +178,8 @@
|
||||
TARGET="Out.CREATE" />
|
||||
<TEMPLATE_PARAM SOURCE="self.CREATE_EMPTY_ELEMENT"
|
||||
TARGET="Out.CREATE_EMPTY_ELEMENT" />
|
||||
<TEMPLATE_PARAM SOURCE="self.IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY"
|
||||
TARGET="Out.IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY" />
|
||||
<TEMPLATE_PARAM SOURCE="self.EXPAND_EMPTY_ELM"
|
||||
TARGET="Out.EXPAND_EMPTY_ELM" />
|
||||
<TEMPLATE_PARAM SOURCE="self.OUTPUT_AS_XSD"
|
||||
|
||||
@@ -43,4 +43,5 @@ SCHEMA.NAME=Schema
|
||||
THOUSANDS_SEPARATOR.NAME=Thousands separator
|
||||
XMLFIELD.NAME=Output Column
|
||||
XSD_FILE.NAME=XSD file path
|
||||
IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY.NAME = Ignore service attributes for empty elements
|
||||
EXPAND_EMPTY_ELM.NAME = Expand Empty Element if needed(for dom4j)
|
||||
@@ -45,6 +45,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
String removeHeader = ElementParameterParser.getValue(node, "__REMOVE_HEADER__"); // add for feature7788
|
||||
String encoding = ElementParameterParser.getValue(node, "__ENCODING__");
|
||||
boolean isAllowEmpty = ("true").equals(ElementParameterParser.getValue(node, "__CREATE_EMPTY_ELEMENT__"));
|
||||
boolean ignoreServiceAttributes = ("true").equals(ElementParameterParser.getValue(node, "__IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY__"));
|
||||
boolean expandEmptyElm = ("true").equals(ElementParameterParser.getValue(node, "__EXPAND_EMPTY_ELM__"));
|
||||
String mode = ElementParameterParser.getValue(node, "__GENERATION_MODE__");
|
||||
List<Map<String, String>> rootTable =
|
||||
@@ -200,6 +201,18 @@ java.util.Map<String,String> arraysValueMap_<%=cid%> = new java.util.HashMap<Str
|
||||
%>
|
||||
|
||||
class NestXMLTool_<%=cid%>{
|
||||
<%
|
||||
if (!isAllowEmpty && ignoreServiceAttributes) {
|
||||
%>
|
||||
private java.util.Set<String> serviceAttributeNames = new java.util.HashSet<>();
|
||||
{
|
||||
serviceAttributeNames.add("type");
|
||||
serviceAttributeNames.add("class");
|
||||
serviceAttributeNames.add("array");
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
public void parseAndAdd(org.dom4j.Element nestRoot, String value){
|
||||
try {
|
||||
org.dom4j.Document doc4Str = org.dom4j.DocumentHelper.parseText("<root>"+ value + "</root>");
|
||||
@@ -235,16 +248,25 @@ class NestXMLTool_<%=cid%>{
|
||||
for (org.dom4j.Element tmp: (java.util.List<org.dom4j.Element>) root.elements()) {
|
||||
removeEmptyElement(tmp);
|
||||
}
|
||||
if (root.content().size() == 0
|
||||
&& root.attributes().size() == 0
|
||||
&& root.declaredNamespaces().size() == 0) {
|
||||
if(root.getParent()!=null){
|
||||
root.getParent().remove(root);
|
||||
|
||||
boolean noSignificantDataAnnotationsExist = root.attributes().isEmpty() <%if (!isAllowEmpty && ignoreServiceAttributes) {%>|| isOnlyServiceAttributesDeclared(root.attributes()) <% } %>;
|
||||
if (root.content().isEmpty()
|
||||
&& noSignificantDataAnnotationsExist && root.declaredNamespaces().isEmpty()) {
|
||||
if(root.getParent()!=null){
|
||||
root.getParent().remove(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
<%
|
||||
if (!isAllowEmpty && ignoreServiceAttributes) {
|
||||
%>
|
||||
private boolean isOnlyServiceAttributesDeclared(List<org.dom4j.Attribute> attributes) {
|
||||
return attributes.stream().allMatch(a -> serviceAttributeNames.contains(a.getName().toLowerCase()));
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
public String objectToString(Object value){
|
||||
if(value.getClass().isArray()){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@@ -99,6 +99,11 @@
|
||||
<DEFAULT>true</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY" FIELD="CHECK" NUM_ROW="11"
|
||||
SHOW_IF="CREATE_EMPTY_ELEMENT=='false'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="EXPAND_EMPTY_ELM" FIELD="CHECK" NUM_ROW="11"
|
||||
SHOW_IF="CREATE_EMPTY_ELEMENT=='true'">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
|
||||
@@ -44,5 +44,6 @@ THOUSANDS_SEPARATOR.NAME=Thousands separator
|
||||
XMLFIELD.NAME=Output Column
|
||||
XML_FIELD.NAME=XML Field
|
||||
XSD_FILE.NAME=XSD file path
|
||||
IGNORE_SERVICE_ATTRIBUTES_FOR_EMPTY.NAME = Ignore service attributes for empty elements
|
||||
EXPAND_EMPTY_ELM.NAME = Expand Empty Element if needed(for dom4j)
|
||||
COMPACT_FORMAT.NAME = Compact Format
|
||||
@@ -35,6 +35,7 @@ imports="
|
||||
%>
|
||||
String driverClass_<%=cid%> = "<%=this.getDirverClassName(node)%>";
|
||||
java.lang.Class jdbcclazz_<%=cid%> = java.lang.Class.forName(driverClass_<%=cid%>);
|
||||
globalMap.put("driverClass_<%=cid%>", driverClass_<%=cid%>);
|
||||
<%
|
||||
newInstance(node);
|
||||
}
|
||||
|
||||
@@ -165,6 +165,12 @@ imports="
|
||||
close_begin();
|
||||
%>
|
||||
conn_<%=cid%>.close();
|
||||
<% /* TESB-24900 - graceful shutdown for MYSQL connection */ %>
|
||||
if("com.mysql.cj.jdbc.Driver".equals((String)globalMap.get("driverClass_<%=(connection!=null)?connection.replaceAll("'","").trim():""%>"))
|
||||
&& routines.system.BundleUtils.inOSGi()) {
|
||||
Class.forName("com.mysql.cj.jdbc.AbandonedConnectionCleanupThread").
|
||||
getMethod("checkedShutdown").invoke(null, (Object[]) null);
|
||||
}
|
||||
<%
|
||||
close_end();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.beans.PropertyChangeEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.eclipse.swt.SWT;
|
||||
@@ -126,7 +127,9 @@ public class ButtonController extends AbstractElementPropertySectionController {
|
||||
continue;
|
||||
}
|
||||
for(String path : listString){
|
||||
jars.add(GenericTableUtils.getDriverJarPath(path));
|
||||
if (!StringUtils.isBlank(path)) {
|
||||
jars.add(GenericTableUtils.getDriverJarPath(path));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -100,15 +103,20 @@ public class ComponentRefController extends AbstractElementPropertySectionContro
|
||||
for (int j = 0; j < param.getListItemsValue().length; j++) {
|
||||
if (((CCombo) ctrl).getText().equals(param.getListItemsDisplayName()[j])) {
|
||||
value = (String) param.getListItemsValue()[j];
|
||||
if (j == 0 && (boolean) ((ElementParameter) propertyParameter)
|
||||
.getTaggedValue(IGenericConstants.IS_PROPERTY_SHOW)) {
|
||||
if (j == 0) {
|
||||
// The first item in the combo is
|
||||
// this component
|
||||
props.referenceType
|
||||
.setValue(ComponentReferenceProperties.ReferenceType.THIS_COMPONENT);
|
||||
props.componentInstanceId.setValue(null);
|
||||
props.setReference(null);
|
||||
propertyParameter.setShow(true);
|
||||
boolean isPropertyShow = true;
|
||||
Object isPropertyShowObj = ((ElementParameter) propertyParameter)
|
||||
.getTaggedValue(IGenericConstants.IS_PROPERTY_SHOW);
|
||||
if (isPropertyShowObj != null) {
|
||||
isPropertyShow = Boolean.valueOf(isPropertyShowObj.toString());
|
||||
}
|
||||
propertyParameter.setShow(isPropertyShow);
|
||||
} else {
|
||||
props.referenceType
|
||||
.setValue(ComponentReferenceProperties.ReferenceType.COMPONENT_INSTANCE);
|
||||
@@ -277,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)) {
|
||||
@@ -306,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;
|
||||
}
|
||||
@@ -331,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<>();
|
||||
|
||||
@@ -1473,7 +1473,12 @@ public class Component extends AbstractBasicComponent {
|
||||
//as sql type value may have newline and return characters, which make compiler issue in java code,
|
||||
//so have to convert the newline characters to visible "\r", "\n" for pass the compiler issue and can't only convert them to white space as TDI-41898
|
||||
//jdbc drivers, salesforce driver can work like that sql : select * \nfrom Account, so it is ok
|
||||
return NodeUtil.replaceCRLFInMEMO_SQL(value);
|
||||
String replacedString = NodeUtil.replaceCRLFInMEMO_SQL(value).trim();
|
||||
|
||||
// For the case when sql field ends with extra semicolon, it has to be removed to avoid compilation error.
|
||||
return replacedString.endsWith(";")
|
||||
? replacedString.substring(0, replacedString.length() -1)
|
||||
: replacedString;
|
||||
}
|
||||
if (GenericTypeUtils.isSchemaType(property)) {
|
||||
// Handles embedded escaped quotes which might occur
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.designer.core.generic.model;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.ProxySelector;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -30,6 +31,7 @@ import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.ui.gmf.util.DisplayUtils;
|
||||
import org.talend.commons.ui.swt.dialogs.ErrorDialogWidthDetailArea;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.components.api.component.Connector;
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.components.api.service.ComponentService;
|
||||
@@ -498,11 +500,27 @@ public class GenericElementParameter extends ElementParameter implements IGeneri
|
||||
monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
|
||||
try {
|
||||
exceptionResult = null;
|
||||
if (Boolean.getBoolean(TalendProxySelector.PROP_PRINT_LOGS)) {
|
||||
ExceptionHandler.log(
|
||||
"Before tcompv0 service call: ProxySelector.getDefault() -> " + ProxySelector.getDefault());
|
||||
ExceptionHandler.log("http.proxyHost -> " + System.getProperty("http.proxyHost"));
|
||||
}
|
||||
toDo();
|
||||
if (Boolean.getBoolean(TalendProxySelector.PROP_PRINT_LOGS)) {
|
||||
ExceptionHandler.log(
|
||||
"After tcompv0 service call: ProxySelector.getDefault() -> " + ProxySelector.getDefault());
|
||||
ExceptionHandler.log("http.proxyHost -> " + System.getProperty("http.proxyHost"));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
result.set(false);
|
||||
exceptionResult = new InvocationTargetException(e);
|
||||
throw exceptionResult;
|
||||
} finally {
|
||||
if (Boolean.getBoolean(TalendProxySelector.PROP_PRINT_LOGS)) {
|
||||
ExceptionHandler.log(
|
||||
"Finally tcompv0 service call: ProxySelector.getDefault() -> " + ProxySelector.getDefault());
|
||||
ExceptionHandler.log("http.proxyHost -> " + System.getProperty("http.proxyHost"));
|
||||
}
|
||||
}
|
||||
result.set(true);
|
||||
}
|
||||
@@ -568,6 +586,7 @@ public class GenericElementParameter extends ElementParameter implements IGeneri
|
||||
this.drivedByForm = drivedByForm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Property getProperty() {
|
||||
NamedThing content = widget.getContent();
|
||||
if (content instanceof Property) {
|
||||
|
||||
@@ -21,11 +21,13 @@ import java.util.Set;
|
||||
import org.talend.components.api.component.ComponentDefinition;
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.components.api.properties.ComponentReferenceProperties;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
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.runtime.services.IGenericService;
|
||||
import org.talend.daikon.properties.Properties;
|
||||
import org.talend.designer.core.generic.model.Component;
|
||||
import org.talend.designer.core.generic.model.GenericElementParameter;
|
||||
import org.talend.designer.core.generic.utils.ComponentsUtils;
|
||||
|
||||
@@ -109,4 +111,9 @@ public class GenericService implements IGenericService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTcompv0(IComponent component) {
|
||||
return Component.class.isInstance(component);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -736,6 +736,7 @@ PerformancePreferencePage.generateCode=Generate code when opening the job
|
||||
PerformancePreferencePage.checkVersion=Check only the last version when updating jobs or joblets
|
||||
PerformancePreferencePage.addOrDeleteVariable=Propagate add/delete variable changes in repository contexts
|
||||
PerformancePreferencePage.ActivedTimeoutSetting=Activate the timeout for database connection.
|
||||
PerformancePreferencePage.propagateContext=Propagate add context groups in repository contexts
|
||||
PerformancePreferencePage.ConnectionTimeout=Connection timeout (seconds)
|
||||
PerformancePreferencePage.HBaseOrMaprDBScanLimit=HBase/MapR-DB scan limit (for retrieving schema)
|
||||
PerformancePreferencePage.HBaseOrMaprDBScanLimitTip=If set it by zero, will be same as deactiving the limit.
|
||||
|
||||
@@ -99,6 +99,7 @@ import org.talend.designer.core.ui.views.jobsettings.JobSettings;
|
||||
import org.talend.designer.core.ui.views.problems.Problems;
|
||||
import org.talend.designer.core.ui.views.properties.ComponentSettings;
|
||||
import org.talend.designer.core.ui.views.properties.ComponentSettingsView;
|
||||
import org.talend.designer.core.utils.BigDataJobUtil;
|
||||
import org.talend.designer.core.utils.JavaProcessUtil;
|
||||
import org.talend.designer.core.utils.UnifiedComponentUtil;
|
||||
import org.talend.designer.runprocess.ProcessorException;
|
||||
@@ -874,4 +875,9 @@ public class DesignerCoreService implements IDesignerCoreService {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNeedContextInJar(IProcess process) {
|
||||
return new BigDataJobUtil(process).needsToHaveContextInsideJar();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
||||
@@ -16,11 +16,14 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.oro.text.regex.MalformedPatternException;
|
||||
import org.apache.oro.text.regex.Pattern;
|
||||
import org.apache.oro.text.regex.Perl5Compiler;
|
||||
import org.apache.oro.text.regex.Perl5Matcher;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.system.EnvironmentUtils;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.language.LanguageManager;
|
||||
@@ -35,10 +38,10 @@ import org.talend.core.model.process.IConnectionCategory;
|
||||
import org.talend.core.model.process.IElement;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
import org.talend.hadoop.distribution.DistributionFactory;
|
||||
import org.talend.hadoop.distribution.ESparkVersion;
|
||||
import org.talend.hadoop.distribution.spark.SparkVersionUtil;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
|
||||
/**
|
||||
* This class will test an expression in the element parameters. <br>
|
||||
@@ -74,7 +77,36 @@ public final class Expression {
|
||||
|
||||
private static final String LESS_THAN = "<"; //$NON-NLS-1$
|
||||
|
||||
private static final Pattern isShowFuncPattern = Pattern.compile("isShow\\[(\\w+)(\\.\\w+)*\\]"); //$NON-NLS-1$
|
||||
private static final String isShowPrefix = "isShow"; //$NON-NLS-1$
|
||||
|
||||
private static final java.util.regex.Pattern isShowFuncPattern = java.util.regex.Pattern
|
||||
.compile(isShowPrefix + "\\[(\\w+)(\\.\\w+)*\\]"); //$NON-NLS-1$
|
||||
|
||||
private static final String sparkVersionPrefix = "SPARK_"; //$NON-NLS-1$
|
||||
|
||||
private static final java.util.regex.Pattern sparkVersionPattern = java.util.regex.Pattern
|
||||
.compile("(lt|le|gt|ge|eq|ne)\\s*'(" + sparkVersionPrefix + ".*)'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
private static Perl5Matcher conditionMatcher = new Perl5Matcher();
|
||||
|
||||
private static Pattern andPattern;
|
||||
|
||||
private static Pattern orPattern;
|
||||
|
||||
static {
|
||||
Perl5Compiler compiler = new Perl5Compiler();
|
||||
// example for the reg exp: (.*)[')][ ]*or[ ]*[\w(](.*)
|
||||
String prefixReg = "(.*)[') ][ ]*"; //$NON-NLS-1$
|
||||
String suffixReg = "[ ]*[ (](.*)"; //$NON-NLS-1$
|
||||
try {
|
||||
andPattern = compiler.compile(prefixReg + AND + suffixReg);
|
||||
orPattern = compiler.compile(prefixReg + OR + suffixReg);
|
||||
} catch (MalformedPatternException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String CONTAINS = "CONTAINS"; //$NON-NLS-1$
|
||||
|
||||
private Expression(String expressionString) {
|
||||
this.expressionString = expressionString;
|
||||
@@ -145,14 +177,15 @@ public final class Expression {
|
||||
|
||||
}
|
||||
|
||||
public static boolean isThereCondition(String expression, String condition) {
|
||||
// example for the reg exp: (.*)[')][ ]*or[ ]*[\w(](.*)
|
||||
String refixReg = "(.*)[') ][ ]*"; //$NON-NLS-1$
|
||||
String suffixReg = "[ ]*[ (](.*)"; //$NON-NLS-1$
|
||||
if (expression.matches(refixReg + condition + suffixReg)) {
|
||||
protected static boolean isThereCondition(String expression, String condition) {
|
||||
expression = expression.toLowerCase();
|
||||
if (!expression.contains(condition)) {
|
||||
return false;
|
||||
}
|
||||
if (AND.equals(condition) && conditionMatcher.matches(expression, andPattern)) {
|
||||
return true;
|
||||
}
|
||||
if (expression.matches(refixReg + condition.toUpperCase() + suffixReg)) {
|
||||
if (OR.equals(condition) && conditionMatcher.matches(expression, orPattern)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -274,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) {
|
||||
@@ -784,13 +821,15 @@ public final class Expression {
|
||||
// should be private, but need to unitary tested
|
||||
public static boolean evaluateSparkVersion(String simpleExpression, List<? extends IElementParameter> listParam,
|
||||
ElementParameter currentParam) {
|
||||
if (!simpleExpression.contains(sparkVersionPrefix)) {
|
||||
return false;
|
||||
}
|
||||
INode node = retrieveNodeElementFromParameter(currentParam, listParam);
|
||||
ESparkVersion version = SparkVersionUtil.getSparkVersion(node);
|
||||
if (version == null) {
|
||||
return false;
|
||||
}
|
||||
Pattern p = java.util.regex.Pattern.compile("(lt|le|gt|ge|eq|ne)\\s*'(SPARK_.*)'"); //$NON-NLS-1$
|
||||
Matcher m = p.matcher(simpleExpression);
|
||||
Matcher m = sparkVersionPattern.matcher(simpleExpression);
|
||||
if (m.find()) {
|
||||
ESparkVersion versionToTest = ESparkVersion.valueOf(m.group(2));
|
||||
switch (m.group(1)) {
|
||||
@@ -836,7 +875,7 @@ public final class Expression {
|
||||
|
||||
private static List<String> getParaNamesFromIsShowFunc(String expr) {
|
||||
List<String> paraNames = new ArrayList<String>();
|
||||
if (expr == null) {
|
||||
if (expr == null || !expr.contains(isShowPrefix)) {
|
||||
return paraNames;
|
||||
}
|
||||
Matcher matcher = isShowFuncPattern.matcher(expr);
|
||||
@@ -1030,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()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,9 +31,20 @@ public class MultipleComponentConnection implements IMultipleComponentConnection
|
||||
|
||||
String connectionType;
|
||||
|
||||
String connectorName;
|
||||
|
||||
public MultipleComponentConnection(String cType, String targetName) {
|
||||
connectionType = cType;
|
||||
nameTarget = targetName;
|
||||
connectorName = cType;
|
||||
}
|
||||
|
||||
public String getConnectorName() {
|
||||
return connectorName;
|
||||
}
|
||||
|
||||
public void setConnectorName(String connectorName) {
|
||||
this.connectorName = connectorName;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.List;
|
||||
|
||||
import org.talend.core.model.components.IMultipleComponentConnection;
|
||||
import org.talend.core.model.components.IMultipleComponentItem;
|
||||
import org.talend.core.model.process.INode;
|
||||
|
||||
/**
|
||||
* DOC nrousseau class global comment. Detailled comment <br/>
|
||||
@@ -67,4 +68,10 @@ public class MultipleComponentItem implements IMultipleComponentItem {
|
||||
public void setComponent(String component) {
|
||||
this.component = component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNode(INode newNode, INode oldNode) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -77,17 +77,36 @@ public class MultipleComponentManager implements IMultipleComponentManager {
|
||||
return currentItem;
|
||||
}
|
||||
|
||||
public void addItem(IMultipleComponentItem currentItem) {
|
||||
String name = currentItem.getName();
|
||||
if (name.equals(inputName)) {
|
||||
input = currentItem;
|
||||
}
|
||||
if (name.equals(outputName)) {
|
||||
output = currentItem;
|
||||
}
|
||||
itemList.add(currentItem);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.model.components.IMultipleComponentManager#addParam(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void addParam(String source, String target) {
|
||||
paramList.add(new MultipleComponentParameter(source, target));
|
||||
paramList.add(createMultiCompParam(source, target));
|
||||
}
|
||||
|
||||
public void addValue(String target, String value) {
|
||||
paramList.add(new MultipleComponentParameterValue(target, value));
|
||||
paramList.add(createMultiCompParamValue(target, value));
|
||||
}
|
||||
|
||||
protected IMultipleComponentParameter createMultiCompParam(String target, String value) {
|
||||
return new MultipleComponentParameter(target, value, getParamSeperator());
|
||||
}
|
||||
|
||||
protected IMultipleComponentParameter createMultiCompParamValue(String target, String value) {
|
||||
return new MultipleComponentParameterValue(target, value, getParamSeperator());
|
||||
}
|
||||
|
||||
public void validateItems() {
|
||||
@@ -170,4 +189,9 @@ public class MultipleComponentManager implements IMultipleComponentManager {
|
||||
return this.lookupMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParamSeperator() {
|
||||
return ".";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,11 +33,15 @@ public class MultipleComponentParameter implements IMultipleComponentParameter {
|
||||
String targetValue;
|
||||
|
||||
public MultipleComponentParameter(String source, String target) {
|
||||
StringTokenizer token = new StringTokenizer(source, "."); //$NON-NLS-1$
|
||||
this(source, target, ".");
|
||||
}
|
||||
|
||||
public MultipleComponentParameter(String source, String target, String seperator) {
|
||||
StringTokenizer token = new StringTokenizer(source, seperator);
|
||||
sourceComponent = token.nextToken();
|
||||
sourceValue = token.nextToken();
|
||||
|
||||
token = new StringTokenizer(target, "."); //$NON-NLS-1$
|
||||
token = new StringTokenizer(target, seperator);
|
||||
targetComponent = token.nextToken();
|
||||
targetValue = token.nextToken();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,11 @@ public class MultipleComponentParameterValue implements IMultipleComponentParame
|
||||
String targetValue;
|
||||
|
||||
public MultipleComponentParameterValue(String target, String value) {
|
||||
StringTokenizer token = new StringTokenizer(target, "."); //$NON-NLS-1$
|
||||
this(target, value, ".");
|
||||
}
|
||||
|
||||
public MultipleComponentParameterValue(String target, String value, String seperator) {
|
||||
StringTokenizer token = new StringTokenizer(target, seperator);
|
||||
targetComponent = token.nextToken();
|
||||
targetValue = token.nextToken();
|
||||
|
||||
@@ -41,6 +45,7 @@ public class MultipleComponentParameterValue implements IMultipleComponentParame
|
||||
sourceValue = value;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.model.components;
|
||||
|
||||
/**
|
||||
* DOC hzhao class global comment. Detailled comment
|
||||
*/
|
||||
public class MultipleGenricComponentManager extends MultipleComponentManager {
|
||||
|
||||
public MultipleGenricComponentManager(boolean lookupMode) {
|
||||
super(lookupMode);
|
||||
}
|
||||
|
||||
public MultipleGenricComponentManager(String inputName, String outputName, String connector) {
|
||||
super(inputName, outputName, connector);
|
||||
}
|
||||
|
||||
public MultipleGenricComponentManager(String inputName, String outputName) {
|
||||
super(inputName, outputName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParamSeperator() {
|
||||
return "#";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.gef.palette.PaletteEntry;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
@@ -31,6 +32,7 @@ import org.talend.core.model.process.IReplaceNodeInProcess;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryEditorInput;
|
||||
import org.talend.core.model.update.UpdateResult;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
|
||||
@@ -143,7 +145,7 @@ public abstract class AbstractProcessProvider implements IReplaceNodeInProcess {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DOC qzhang Comment method "canDeleteNode".
|
||||
*
|
||||
@@ -257,5 +259,10 @@ public abstract class AbstractProcessProvider implements IReplaceNodeInProcess {
|
||||
public boolean canHandleNode(INode node) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IRepositoryEditorInput createJobletEditorInput(JobletProcessItem processItem, boolean load, Boolean lastVersion, Boolean readonly,
|
||||
Boolean openedInJob) throws PersistenceException{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.collections.BidiMap;
|
||||
@@ -36,6 +37,7 @@ import org.talend.components.api.properties.VirtualComponentProperties;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.hadoop.HadoopConfJarBean;
|
||||
import org.talend.core.hadoop.IHadoopClusterService;
|
||||
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
@@ -512,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());
|
||||
|
||||
@@ -778,7 +781,7 @@ public class DataProcess implements IGeneratingProcess {
|
||||
DataConnection dataConnec = new DataConnection();
|
||||
dataConnec.setActivate(graphicalNode.isActivate());
|
||||
dataConnec.setLineStyle(EConnectionType.getTypeFromName(curConnec.getConnectionType()));
|
||||
dataConnec.setConnectorName(curConnec.getConnectionType());
|
||||
dataConnec.setConnectorName(curConnec.getConnectorName());
|
||||
if (nodeSource.getMetadataList() != null) {
|
||||
dataConnec.setMetadataTable(nodeSource.getMetadataList().get(0));
|
||||
}
|
||||
@@ -1011,6 +1014,7 @@ public class DataProcess implements IGeneratingProcess {
|
||||
curNode.setActivate(false);
|
||||
curNode.setStart(false);
|
||||
}
|
||||
curItem.updateNode(curNode, graphicalNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3249,8 +3253,8 @@ public class DataProcess implements IGeneratingProcess {
|
||||
if (!hadoopClusterService.isUseDynamicConfJar(hadoopClusterItemId)) {
|
||||
return null;
|
||||
}
|
||||
String confsJarName = hadoopClusterService.getCustomConfsJarName(hadoopClusterItemId, false, false);
|
||||
if (confsJarName == null) {
|
||||
Optional<HadoopConfJarBean> confJarBean = hadoopClusterService.getCustomConfsJar(hadoopClusterItemId, false, false);
|
||||
if (!confJarBean.isPresent()) {
|
||||
return null;
|
||||
}
|
||||
IComponent component = ComponentsFactoryProvider.getInstance().get(componentName, componentCategory.getName());
|
||||
@@ -3266,7 +3270,21 @@ public class DataProcess implements IGeneratingProcess {
|
||||
clusterIdParam.setValue(hadoopClusterItemId);
|
||||
}
|
||||
IElementParameter confLibParam = confNode.getElementParameter("CONF_LIB"); //$NON-NLS-1$
|
||||
confLibParam.setValue(TalendTextUtils.addQuotes(confsJarName));
|
||||
confLibParam.setValue(TalendTextUtils.addQuotes(confJarBean.get().getCustomConfJarName()));
|
||||
IElementParameter setConfParam = confNode.getElementParameter("SET_HADOOP_CONF"); //$NON-NLS-1$
|
||||
if (setConfParam != null) {
|
||||
setConfParam.setValue(Boolean.valueOf(confJarBean.get().isOverrideCustomConf()));
|
||||
}
|
||||
IElementParameter confPathParam = confNode.getElementParameter("HADOOP_CONF_SPECIFIC_JAR"); //$NON-NLS-1$
|
||||
if (confPathParam != null) {
|
||||
String jarPath = null;
|
||||
if (confJarBean.get().isContextMode()) {
|
||||
jarPath = confJarBean.get().getOverrideCustomConfPath();
|
||||
} else {
|
||||
jarPath = TalendTextUtils.addQuotes(confJarBean.get().getOriginalOverrideCustomConfPath());
|
||||
}
|
||||
confPathParam.setValue(jarPath);
|
||||
}
|
||||
return confNode;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -15,16 +15,25 @@ package org.talend.designer.core.model.process.jobsettings;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.EComponentType;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IMultipleComponentItem;
|
||||
import org.talend.core.model.components.IMultipleComponentManager;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataToolAvroHelper;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
import org.talend.core.model.param.EConnectionParameterName;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
@@ -33,11 +42,15 @@ import org.talend.core.model.process.INodeConnector;
|
||||
import org.talend.core.model.process.INodeReturn;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.temp.ECodePart;
|
||||
import org.talend.core.runtime.services.IGenericService;
|
||||
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.EmfComponent;
|
||||
import org.talend.designer.core.model.components.MultipleComponentConnection;
|
||||
import org.talend.designer.core.model.components.MultipleComponentItem;
|
||||
import org.talend.designer.core.model.components.MultipleComponentManager;
|
||||
import org.talend.designer.core.model.components.MultipleGenricComponentManager;
|
||||
import org.talend.designer.core.model.process.jobsettings.JobSettingsConstants.ContextLoadInfo;
|
||||
|
||||
/**
|
||||
@@ -65,9 +78,22 @@ public class JobContextLoadComponent implements IComponent {
|
||||
|
||||
private final boolean isFile;
|
||||
|
||||
public JobContextLoadComponent(boolean isFile, String dbComponent) {
|
||||
private IComponent component;
|
||||
|
||||
public JobContextLoadComponent(boolean isFile, String dbComponent, String componentType) {
|
||||
this.isFile = isFile;
|
||||
this.dbComponent = dbComponent;
|
||||
try {
|
||||
String compType = componentType;
|
||||
if (StringUtils.isBlank(componentType)) {
|
||||
ExceptionHandler.log(
|
||||
this.getClass().getName() + ": componentType is empty, will use DI type for component " + dbComponent);
|
||||
compType = ComponentCategory.CATEGORY_4_DI.getName();
|
||||
}
|
||||
component = ComponentsFactoryProvider.getInstance().get(dbComponent, compType);
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
loadMultipleComponentManager();
|
||||
}
|
||||
|
||||
@@ -87,17 +113,46 @@ public class JobContextLoadComponent implements IComponent {
|
||||
if (dbComponent == null) {
|
||||
return;
|
||||
}
|
||||
multipleComponentManager = new MultipleComponentManager(DB_INPUT, CONTEXT_LOAD);
|
||||
|
||||
IMultipleComponentItem currentItem = multipleComponentManager.addItem(DB_INPUT, dbComponent);
|
||||
currentItem.getOutputConnections().add(
|
||||
new MultipleComponentConnection(EConnectionType.FLOW_MAIN.getName(), CONTEXT_LOAD));
|
||||
MultipleComponentConnection multiCompConnection = new MultipleComponentConnection(EConnectionType.FLOW_MAIN.getName(),
|
||||
CONTEXT_LOAD);
|
||||
IMultipleComponentItem currentItem = null;
|
||||
if (isTcompv0(component)) {
|
||||
multipleComponentManager = new MultipleGenricComponentManager(DB_INPUT, CONTEXT_LOAD);
|
||||
multiCompConnection.setConnectorName("MAIN");
|
||||
currentItem = new MultipleComponentItem() {
|
||||
|
||||
public void updateNode(INode newNode, INode oldNode) {
|
||||
super.updateNode(newNode, oldNode);
|
||||
if (newNode != null) {
|
||||
List<IMetadataTable> metadataList = newNode.getMetadataList();
|
||||
if (0 < metadataList.size() && isTcompv0(newNode.getComponent())) {
|
||||
IMetadataTable newMetadata = metadataList.get(0);
|
||||
newMetadata.setAttachedConnector("MAIN");
|
||||
ComponentProperties tcomp_properties = newNode.getComponentProperties();
|
||||
Schema schema = MetadataToolAvroHelper.convertToAvro(ConvertionHelper.convert(newMetadata));
|
||||
tcomp_properties.setValue("main.schema", schema);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
currentItem.setName(DB_INPUT);
|
||||
currentItem.setComponent(dbComponent);
|
||||
|
||||
((MultipleGenricComponentManager) multipleComponentManager).addItem(currentItem);
|
||||
} else {
|
||||
multipleComponentManager = new MultipleComponentManager(DB_INPUT, CONTEXT_LOAD);
|
||||
currentItem = multipleComponentManager.addItem(DB_INPUT, dbComponent);
|
||||
}
|
||||
|
||||
currentItem.getOutputConnections().add(multiCompConnection);
|
||||
|
||||
currentItem = multipleComponentManager.addItem(CONTEXT_LOAD, CONTEXTLOAD_COMPONENT);
|
||||
|
||||
}
|
||||
multipleComponentManager.validateItems();
|
||||
multipleComponentManagers.add(multipleComponentManager);
|
||||
|
||||
createMultipleComponentsParameters();
|
||||
}
|
||||
|
||||
@@ -181,6 +236,11 @@ public class JobContextLoadComponent implements IComponent {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isTcompv0(IComponent comp) {
|
||||
return comp != null
|
||||
&& Optional.ofNullable(IGenericService.getService()).map(s -> s.isTcompv0(comp)).orElse(Boolean.FALSE);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -242,10 +302,10 @@ public class JobContextLoadComponent implements IComponent {
|
||||
}
|
||||
|
||||
protected void createMultipleComponentsParameters() {
|
||||
final String self = "self."; //$NON-NLS-1$
|
||||
// create parameters
|
||||
if ((multipleComponentManagers != null) && (multipleComponentManagers.size() > 0)) {
|
||||
IMultipleComponentManager multipleComponentManager = multipleComponentManagers.get(0);
|
||||
final String self = "self" + multipleComponentManager.getParamSeperator(); //$NON-NLS-1$
|
||||
if (isFile) {
|
||||
String source = self + EParameterName.IMPLICIT_TCONTEXTLOAD_FILE.getName();
|
||||
multipleComponentManager.addParam(source, FILE_INPUT_REGEX + ".FILENAME"); //$NON-NLS-1$
|
||||
@@ -257,84 +317,140 @@ public class JobContextLoadComponent implements IComponent {
|
||||
multipleComponentManager.addParam(source, FILE_INPUT_REGEX + ".IGNORE_ERROR_MESSAGE"); //$NON-NLS-1$
|
||||
|
||||
} else {
|
||||
String source = self + JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".URL");
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DRIVER_JAR");
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_CLASS.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DRIVER_CLASS");
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.HOST.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".HOST"); //$NON-NLS-1$
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".SERVER"); //$NON-NLS-1$
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DSN"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.PORT.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".PORT"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DBNAME"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DB_VERSION"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTIES.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".PROPERTIES"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".SCHEMA_DB"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".USER"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".PASS"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DBTABLE"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DB_TYPE"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.CONNECTION_TYPE.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".CONNECTION_TYPE"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.QUERY;
|
||||
multipleComponentManager.addParam(source, DB_INPUT + "." + JobSettingsConstants.QUERY); //$NON-NLS-1$
|
||||
boolean initDefault = true;
|
||||
if (isTcompv0(component)) {
|
||||
if ("tJDBCInput".equalsIgnoreCase(dbComponent)) {
|
||||
initDefault = false;
|
||||
initTcompv0ParamMapping(self, multipleComponentManager);
|
||||
} else {
|
||||
ExceptionHandler.log(this.getClass().getName()
|
||||
+ ": MultipleComponentsParameters mapping is not prepared for tcompv0 " + dbComponent);
|
||||
}
|
||||
}
|
||||
if (initDefault) {
|
||||
initDefaultParameterMapping(self, multipleComponentManager);
|
||||
}
|
||||
|
||||
}
|
||||
// context parameter
|
||||
final String context = CONTEXT_LOAD + "."; //$NON-NLS-1$
|
||||
|
||||
String source = self + EParameterName.LOAD_NEW_VARIABLE.getName();
|
||||
String target = context + EParameterName.LOAD_NEW_VARIABLE.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.NOT_LOAD_OLD_VARIABLE.getName();
|
||||
target = context + EParameterName.NOT_LOAD_OLD_VARIABLE.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.PRINT_OPERATIONS.getName();
|
||||
target = context + EParameterName.PRINT_OPERATIONS.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.DISABLE_ERROR.getName();
|
||||
target = context + EParameterName.DISABLE_ERROR.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.DISABLE_INFO.getName();
|
||||
target = context + EParameterName.DISABLE_INFO.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.DISABLE_WARNINGS.getName();
|
||||
target = context + EParameterName.DISABLE_WARNINGS.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
initContextParamMapping(self, multipleComponentManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initTcompv0ParamMapping(final String self, IMultipleComponentManager multipleComponentManager) {
|
||||
|
||||
final String seperator = multipleComponentManager.getParamSeperator();
|
||||
String source = self + JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + seperator + EConnectionParameterName.GENERIC_URL.getDisplayName());
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName());
|
||||
multipleComponentManager.addParam(source,
|
||||
DB_INPUT + seperator + EConnectionParameterName.GENERIC_DRIVER_JAR.getDisplayName());
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_CLASS.getName());
|
||||
multipleComponentManager.addParam(source,
|
||||
DB_INPUT + seperator + EConnectionParameterName.GENERIC_DRIVER_CLASS.getDisplayName());
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName());
|
||||
multipleComponentManager.addParam(source,
|
||||
DB_INPUT + seperator + EConnectionParameterName.GENERIC_TABLENAME.getDisplayName()); // $NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName());
|
||||
multipleComponentManager.addParam(source,
|
||||
DB_INPUT + seperator + EConnectionParameterName.GENERIC_USERNAME.getDisplayName()); // $NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName());
|
||||
multipleComponentManager.addParam(source,
|
||||
DB_INPUT + seperator + EConnectionParameterName.GENERIC_PASSWORD.getDisplayName()); // $NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName());
|
||||
multipleComponentManager.addParam(source,
|
||||
DB_INPUT + seperator + EConnectionParameterName.GENERIC_TABLENAME.getDisplayName()); // $NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.QUERY;
|
||||
multipleComponentManager.addParam(source, DB_INPUT + seperator + "sql"); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
private void initContextParamMapping(final String self, IMultipleComponentManager multipleComponentManager) {
|
||||
// context parameter
|
||||
final String context = CONTEXT_LOAD + multipleComponentManager.getParamSeperator();
|
||||
|
||||
String source = self + EParameterName.LOAD_NEW_VARIABLE.getName();
|
||||
String target = context + EParameterName.LOAD_NEW_VARIABLE.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.NOT_LOAD_OLD_VARIABLE.getName();
|
||||
target = context + EParameterName.NOT_LOAD_OLD_VARIABLE.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.PRINT_OPERATIONS.getName();
|
||||
target = context + EParameterName.PRINT_OPERATIONS.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.DISABLE_ERROR.getName();
|
||||
target = context + EParameterName.DISABLE_ERROR.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.DISABLE_INFO.getName();
|
||||
target = context + EParameterName.DISABLE_INFO.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
|
||||
source = self + EParameterName.DISABLE_WARNINGS.getName();
|
||||
target = context + EParameterName.DISABLE_WARNINGS.getName();
|
||||
multipleComponentManager.addParam(source, target);
|
||||
}
|
||||
|
||||
private void initDefaultParameterMapping(final String self, IMultipleComponentManager multipleComponentManager) {
|
||||
String source = self + JobSettingsConstants.getExtraParameterName(EParameterName.URL.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".URL");
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DRIVER_JAR");
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_CLASS.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DRIVER_CLASS");
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.HOST.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".HOST"); //$NON-NLS-1$
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".SERVER"); //$NON-NLS-1$
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DSN"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.PORT.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".PORT"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DBNAME.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DBNAME"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DB_VERSION"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.PROPERTIES.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".PROPERTIES"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".SCHEMA_DB"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.USER.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".USER"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.PASS.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".PASS"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DBTABLE.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DBTABLE"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".DB_TYPE"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.getExtraParameterName(EParameterName.CONNECTION_TYPE.getName());
|
||||
multipleComponentManager.addParam(source, DB_INPUT + ".CONNECTION_TYPE"); //$NON-NLS-1$
|
||||
|
||||
source = self + JobSettingsConstants.QUERY;
|
||||
multipleComponentManager.addParam(source, DB_INPUT + "." + JobSettingsConstants.QUERY); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends IElementParameter> createElementParameters(INode node) {
|
||||
|
||||
@@ -380,8 +496,17 @@ public class JobContextLoadComponent implements IComponent {
|
||||
IElementParameter newParam = new ElementParameter(node);
|
||||
newParam.setName(JobSettingsConstants.getExtraParameterName(EParameterName.DRIVER_JAR.getName()));
|
||||
newParam.setFieldType(EParameterFieldType.TABLE);
|
||||
newParam.setListItemsDisplayName(new String[] { EmfComponent.TEXT_BUILTIN, EmfComponent.TEXT_REPOSITORY });
|
||||
newParam.setListItemsDisplayCodeName(new String[] { EmfComponent.BUILTIN, EmfComponent.REPOSITORY });
|
||||
if (isTcompv0(component)) {
|
||||
/**
|
||||
* seems that tcompv0 will check the list using the display name when generating codes:
|
||||
* GenericTableUtils#setTableValues
|
||||
*/
|
||||
newParam.setListItemsDisplayName(new String[0]);
|
||||
newParam.setListItemsDisplayCodeName(new String[0]);
|
||||
} else {
|
||||
newParam.setListItemsDisplayName(new String[] { EmfComponent.TEXT_BUILTIN, EmfComponent.TEXT_REPOSITORY });
|
||||
newParam.setListItemsDisplayCodeName(new String[] { EmfComponent.BUILTIN, EmfComponent.REPOSITORY });
|
||||
}
|
||||
elemParamList.add(newParam);
|
||||
|
||||
newParam = new ElementParameter(node);
|
||||
|
||||
@@ -928,7 +928,7 @@ public class JobSettingsManager {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
IComponent tContextLoadComponent = new JobContextLoadComponent(fileFlag, dbInput);
|
||||
IComponent tContextLoadComponent = new JobContextLoadComponent(fileFlag, dbInput, process.getComponentsType());
|
||||
|
||||
final String uniqueName = "Implicit_Context"; //$NON-NLS-1$
|
||||
DataNode tContextLoadNode = new DataNode(tContextLoadComponent, uniqueName);
|
||||
@@ -1023,7 +1023,8 @@ public class JobSettingsManager {
|
||||
String dbType = getDatabaseTypeFromParameter(process);
|
||||
if (dbType != null) {
|
||||
// TDI-18161:the SQL script's syntax is not right because of the implicit context of General JDBC.
|
||||
if (dbType.equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())) {
|
||||
if (dbType.equals(EDatabaseTypeName.GENERAL_JDBC.getDisplayName())
|
||||
|| dbType.equals(EDatabaseTypeName.GENERAL_JDBC.getProduct())) {
|
||||
dbType = findRealDbTypeForJDBC(process, dbType);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.talend.commons.exception.SystemException;
|
||||
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.process.ITargetExecutionConfig;
|
||||
import org.talend.core.model.runprocess.IEclipseProcessor;
|
||||
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
|
||||
@@ -44,7 +43,6 @@ import org.talend.core.runtime.process.TalendProcessOptionConstants;
|
||||
import org.talend.designer.codegen.ICodeGenerator;
|
||||
import org.talend.designer.core.ISyntaxCheckableEditor;
|
||||
import org.talend.designer.core.i18n.Messages;
|
||||
import org.talend.designer.maven.model.MavenSystemFolders;
|
||||
import org.talend.designer.runprocess.IProcessMessageManager;
|
||||
import org.talend.designer.runprocess.IProcessor;
|
||||
import org.talend.designer.runprocess.ProcessorException;
|
||||
@@ -361,11 +359,7 @@ public abstract class Processor implements IProcessor, IEclipseProcessor, Talend
|
||||
protected Process exec(String[] cmd, String path) throws ProcessorException {
|
||||
try {
|
||||
if (path == null || !new File(path).exists()) {
|
||||
if (getSpecialWorkingDir() != null) {
|
||||
return Runtime.getRuntime().exec(cmd, null, getSpecialWorkingDir());
|
||||
} else {
|
||||
return Runtime.getRuntime().exec(cmd);
|
||||
}
|
||||
return Runtime.getRuntime().exec(cmd);
|
||||
} else {
|
||||
return Runtime.getRuntime().exec(cmd, null, new File(path));
|
||||
}
|
||||
@@ -374,23 +368,6 @@ public abstract class Processor implements IProcessor, IEclipseProcessor, Talend
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (TUP-20459)For a job which dependencies resources need set the working dir DOC jding
|
||||
* Comment method "getSpecialWorkingDir".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private File getSpecialWorkingDir() {
|
||||
if (!(process instanceof IProcess2)) {
|
||||
return null;
|
||||
}
|
||||
File workingDir = project.getFile(MavenSystemFolders.EXT_RESOURCES.getPath()).getLocation().toFile();
|
||||
if (workingDir.exists()) {
|
||||
return workingDir;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Thread createProdConsThread(final InputStream input, final boolean isError, final int bufferSize,
|
||||
final StringBuffer out, final StringBuffer err) {
|
||||
Thread thread = new Thread() {
|
||||
@@ -452,6 +429,8 @@ public abstract class Processor implements IProcessor, IEclipseProcessor, Talend
|
||||
*/
|
||||
@Override
|
||||
public String getInterpreter() throws ProcessorException {
|
||||
if (this.isLinuxTargetPlatform())
|
||||
return "java";
|
||||
return interpreter;
|
||||
}
|
||||
|
||||
@@ -797,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
|
||||
|
||||
@@ -313,9 +313,11 @@ public class GEFPasteAction extends SelectionAction {
|
||||
(org.talend.designer.core.ui.editor.process.Process) editor.getProcess(), gefPoint);
|
||||
mpc.setSelectedSubjobs(subjobParts);
|
||||
mpc.setSelectedExpandedJoblet(expandedJobletNodes);
|
||||
mpc.setCheckNodeExist(false);
|
||||
execute(mpc);
|
||||
} else if (nodeParts.size() != 0) {
|
||||
NodesPasteCommand cmd = new NodesPasteCommand(nodeParts, editor.getProcess(), gefPoint);
|
||||
cmd.setCheckNodeExist(false);
|
||||
cmd.setSelectedSubjobs(subjobParts);
|
||||
cmd.setSelectedExpandedJoblet(expandedJobletNodes);
|
||||
execute(cmd);
|
||||
|
||||
@@ -607,7 +607,7 @@ public final class TalendEditorPaletteFactory {
|
||||
while (iter.hasNext()) {
|
||||
IComponent xmlComponent = iter.next();
|
||||
|
||||
Matcher matcher = pattern.matcher(xmlComponent.getName().toLowerCase());
|
||||
Matcher matcher = pattern.matcher(xmlComponent.getDisplayName().toLowerCase());
|
||||
if (matcher.find()) {
|
||||
resultByName.add(new ComponentHit(xmlComponent, matcher.start()));
|
||||
continue;
|
||||
@@ -643,7 +643,7 @@ public final class TalendEditorPaletteFactory {
|
||||
private static void addDelegateComponents(IComponentsFactory compFac, Collection<IComponent> componentSet,
|
||||
String lowerCasedKeyword) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUnifiedComponentService.class)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault().getService(
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(
|
||||
IUnifiedComponentService.class);
|
||||
service.filterUnifiedComponentForPalette(compFac, componentSet, lowerCasedKeyword);
|
||||
|
||||
@@ -730,13 +730,12 @@ public final class TalendEditorPaletteFactory {
|
||||
return null;
|
||||
}
|
||||
IComponent delegateComponent = UnifiedComponentUtil.getDelegateComponent(component);
|
||||
String name = component.getName();
|
||||
String filter = null;
|
||||
if (delegateComponent != component) {
|
||||
// emf component name
|
||||
filter = component.getName();
|
||||
name = UnifiedComponentUtil.getComponentDisplayNameForPalette(delegateComponent, filter);
|
||||
}
|
||||
String name = UnifiedComponentUtil.getComponentDisplayNameForPalette(delegateComponent, filter);
|
||||
ImageDescriptor imageSmall = delegateComponent.getIcon16();
|
||||
IPreferenceStore store = DesignerPlugin.getDefault().getPreferenceStore();
|
||||
ImageDescriptor imageLarge;
|
||||
|
||||
@@ -19,15 +19,21 @@ import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.jdt.internal.ui.JavaPlugin;
|
||||
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
|
||||
import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
|
||||
import org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy;
|
||||
import org.eclipse.jdt.internal.ui.text.JavaReconciler;
|
||||
import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
|
||||
import org.eclipse.jdt.ui.text.IJavaPartitions;
|
||||
import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration;
|
||||
import org.eclipse.jdt.ui.text.JavaTextTools;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.Region;
|
||||
import org.eclipse.jface.text.source.IOverviewRuler;
|
||||
import org.eclipse.jface.text.source.ISourceViewer;
|
||||
import org.eclipse.jface.text.source.IVerticalRuler;
|
||||
import org.eclipse.jface.text.source.SourceViewerConfiguration;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.part.FileEditorInput;
|
||||
import org.talend.commons.exception.SystemException;
|
||||
@@ -297,5 +303,41 @@ public class TalendJavaEditor extends CompilationUnitEditor implements ISyntaxCh
|
||||
super.initializeDragAndDrop(viewer);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor#createJavaSourceViewer(org.eclipse.swt.widgets.
|
||||
* Composite, org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean,
|
||||
* int, org.eclipse.jface.preference.IPreferenceStore)
|
||||
*/
|
||||
@Override
|
||||
protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
|
||||
boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
|
||||
return new TalendAdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles, store);
|
||||
}
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
protected class TalendAdaptedSourceViewer extends AdaptedSourceViewer {
|
||||
|
||||
public TalendAdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
|
||||
boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
|
||||
super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(SourceViewerConfiguration configuration) {
|
||||
super.configure(configuration);
|
||||
if (fReconciler == null) {
|
||||
JavaCompositeReconcilingStrategy strategy = new JavaCompositeReconcilingStrategy(this, TalendJavaEditor.this,
|
||||
configuration.getConfiguredDocumentPartitioning(this));
|
||||
JavaReconciler reconciler = new JavaReconciler(TalendJavaEditor.this, strategy, false);
|
||||
reconciler.setIsAllowedToModifyDocument(false);
|
||||
reconciler.setDelay(500);
|
||||
fReconciler = reconciler;
|
||||
fReconciler.install(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,11 +557,12 @@ public class ChangeMetadataCommand extends Command {
|
||||
}
|
||||
}
|
||||
MetadataToolHelper.copyTable(newInputMetadata, currentInputMetadata);
|
||||
currentOutputMetadata.setOriginalColumns(newOutputMetadata.getOriginalColumns());
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_NONE)) {
|
||||
if (!currentOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_IGNORE_USED)) {
|
||||
if (!currentOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_NONE, true)) {
|
||||
if (!currentOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_IGNORE_USED, true)) {
|
||||
String type = (String) node.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
|
||||
if (type != null && type.equals(EmfComponent.REPOSITORY) && !repositoryMode) {
|
||||
// for one node has several schema_type,set mode for the current one
|
||||
@@ -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
|
||||
@@ -624,8 +626,10 @@ public class ChangeMetadataCommand extends Command {
|
||||
setTableMAPPING();
|
||||
|
||||
if (!internal) {
|
||||
updateColumnList(oldOutputMetadata, newOutputMetadata);
|
||||
((Process) node.getProcess()).checkProcess();
|
||||
if (!oldOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_NONE)) {
|
||||
updateColumnList(oldOutputMetadata, newOutputMetadata);
|
||||
((Process) node.getProcess()).checkProcess();
|
||||
}
|
||||
}
|
||||
refreshMetadataChanged();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ public class MultiplePasteCommand extends CompoundCommand {
|
||||
private NodesPasteCommand nodeCmd;
|
||||
|
||||
private NotesPasteCommand noteCmd;
|
||||
|
||||
private boolean isCheckNodeExist = true;
|
||||
|
||||
public MultiplePasteCommand(List<NodePart> nodeParts, List<NoteEditPart> noteParts, Process process, Point cursorLocation) {
|
||||
// List<NodePart> nodePartList = new ArrayList<NodePart>();
|
||||
@@ -67,6 +69,8 @@ public class MultiplePasteCommand extends CompoundCommand {
|
||||
*/
|
||||
@Override
|
||||
public void execute() {
|
||||
nodeCmd.setCheckNodeExist(isCheckNodeExist);
|
||||
|
||||
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
|
||||
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
|
||||
@@ -85,7 +89,7 @@ public class MultiplePasteCommand extends CompoundCommand {
|
||||
for (EditPart editPart : (List<EditPart>) processPart.getChildren()) {
|
||||
if (editPart instanceof NodePart) {
|
||||
Node currentNode = (Node) editPart.getModel();
|
||||
if (nodeCmd.getNodeContainerList().contains(currentNode.getNodeContainer())) {
|
||||
if (nodeCmd.getNodeContainerList().contains(currentNode.getNodeContainer()) || !isCheckNodeExist) {
|
||||
sel.add(editPart);
|
||||
}
|
||||
} else if (editPart instanceof NoteEditPart) {
|
||||
@@ -150,4 +154,13 @@ public class MultiplePasteCommand extends CompoundCommand {
|
||||
nodeCmd.setSelectedExpandedJoblet(selectedExpandedJoblet);
|
||||
}
|
||||
|
||||
|
||||
public boolean isCheckNodeExist() {
|
||||
return isCheckNodeExist;
|
||||
}
|
||||
|
||||
|
||||
public void setCheckNodeExist(boolean isCheckNodeExist) {
|
||||
this.isCheckNodeExist = isCheckNodeExist;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,8 @@ public class NodesPasteCommand extends Command {
|
||||
private boolean isJobletRefactor = false;
|
||||
|
||||
private boolean isJunitCreate = false;
|
||||
|
||||
private boolean isCheckNodeExist = true;
|
||||
|
||||
/**
|
||||
* Getter for isJunitCreate.
|
||||
@@ -385,7 +387,7 @@ public class NodesPasteCommand extends Command {
|
||||
// create the nodes
|
||||
for (NodePart copiedNodePart : nodeParts) {
|
||||
IGraphicalNode copiedNode = (IGraphicalNode) copiedNodePart.getModel();
|
||||
if (!containNodeInProcess(copiedNode)) {
|
||||
if (this.isCheckNodeExist && !containNodeInProcess(copiedNode)) {
|
||||
continue;
|
||||
}
|
||||
IComponent component = ComponentsFactoryProvider.getInstance().get(copiedNode.getComponent().getName(),
|
||||
@@ -1008,4 +1010,16 @@ public class NodesPasteCommand extends Command {
|
||||
public void setSelectedExpandedJoblet(List<NodePart> selectedExpandedJoblet) {
|
||||
this.selectedExpandedJoblet = selectedExpandedJoblet;
|
||||
}
|
||||
|
||||
|
||||
public boolean isCheckNodeExist() {
|
||||
return isCheckNodeExist;
|
||||
}
|
||||
|
||||
|
||||
public void setCheckNodeExist(boolean isCheckNodeExist) {
|
||||
this.isCheckNodeExist = isCheckNodeExist;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -302,12 +302,14 @@ public class PropertyChangeCommand extends Command {
|
||||
List<? extends IConnection> connections = ((Node) elem).getOutgoingConnections();
|
||||
for (IConnection connection : connections) {
|
||||
if (!connection.getName().equals(oldELTValue)) {
|
||||
// do nothing when custom connection name.
|
||||
// Update if use custom connection name.
|
||||
ChangeConnTextCommand command = new ChangeConnTextCommand(connection, newELTValue);
|
||||
command.execute();
|
||||
continue;
|
||||
}
|
||||
INode targetNode = connection.getTarget();
|
||||
String componentName = targetNode.getComponent().getName();
|
||||
if (componentName.matches("tELT.+Map")) { //$NON-NLS-1$
|
||||
if (componentName.matches("tELT.*Map")) { //$NON-NLS-1$
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDbMapDesignerService.class)) {
|
||||
IDbMapDesignerService service = GlobalServiceRegister.getDefault().getService(
|
||||
IDbMapDesignerService.class);
|
||||
|
||||
@@ -480,13 +480,6 @@ public class QueryGuessCommand extends Command {
|
||||
String newQuery = null;
|
||||
// Need update schema if table type as calculation view for SAP Hana Database
|
||||
updateSchema(dbType, newOutputMetadataTable);
|
||||
if (node != null && node instanceof INode) {
|
||||
process = ((INode) node).getProcess();
|
||||
boolean isContextMode = ContextParameterUtils.containContextVariables(schema);
|
||||
if (isContextMode) {
|
||||
schema = JavaProcessUtil.getContextOriginalValue(process, schema);
|
||||
}
|
||||
}
|
||||
realTableName = QueryUtil.getTableName(node, newOutputMetadataTable, schema, dbType, realTableName);
|
||||
|
||||
if (realTableName.startsWith(TalendTextUtils.QUOTATION_MARK) && realTableName.endsWith(TalendTextUtils.QUOTATION_MARK)
|
||||
|
||||
@@ -14,7 +14,6 @@ package org.talend.designer.core.ui.editor.dependencies;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.gef.commands.CommandStack;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
@@ -58,6 +57,7 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.resources.ResourceItem;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.ui.context.CustomDialogCellEditor;
|
||||
import org.talend.core.ui.context.model.table.ContextTableTabChildModel;
|
||||
@@ -256,12 +256,8 @@ public class ManageResourcePanel extends Composite {
|
||||
}
|
||||
JobResourceDependencyModel model = new JobResourceDependencyModel((ResourceItem) item);
|
||||
Property property = process.getProperty();
|
||||
StringBuffer joblabel = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(property.getItem().getState().getPath())) {
|
||||
joblabel.append(property.getItem().getState().getPath() + "/");
|
||||
}
|
||||
joblabel.append(property.getLabel() + "_" + property.getVersion());
|
||||
model.setResourceDepPath(ResourceDependenciesUtil.getResourcePath(model, joblabel.toString(), null));
|
||||
String jobLabel = JavaResourcesHelper.getJobFolderName(property.getLabel(), property.getVersion());
|
||||
model.setResourceDepPath(ResourceDependenciesUtil.getResourcePath(model, jobLabel, null));
|
||||
getInput().add(model);
|
||||
resourcesTV.refresh();
|
||||
resourcesTV.setSelection(new StructuredSelection(model));
|
||||
@@ -362,13 +358,9 @@ public class ManageResourcePanel extends Composite {
|
||||
final JobResourceDependencyModel model = (JobResourceDependencyModel) element;
|
||||
if (!model.getSelectedVersion().equals(value)) {
|
||||
Property property = process.getProperty();
|
||||
StringBuffer joblabel = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(property.getItem().getState().getPath())) {
|
||||
joblabel.append(property.getItem().getState().getPath() + "/");
|
||||
}
|
||||
joblabel.append(property.getLabel() + "_" + property.getVersion());
|
||||
String jobLabel = JavaResourcesHelper.getJobFolderName(property.getLabel(), property.getVersion());
|
||||
model.setSelectedVersion((String) value);
|
||||
model.setResourceDepPath(ResourceDependenciesUtil.getResourcePath(model, joblabel.toString(), (String) value));
|
||||
model.setResourceDepPath(ResourceDependenciesUtil.getResourcePath(model, jobLabel, (String) value));
|
||||
getViewer().update(element, null);
|
||||
try {
|
||||
IRepositoryViewObject repoObject = ProxyRepositoryFactory.getInstance()
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.resources.ResourceItem;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.service.IResourcesDependenciesService;
|
||||
import org.talend.designer.core.ui.AbstractMultiPageTalendEditor;
|
||||
@@ -45,6 +46,7 @@ import org.talend.designer.core.ui.editor.dependencies.dialog.DependenciesResour
|
||||
import org.talend.designer.core.ui.editor.dependencies.model.JobResourceDependencyModel;
|
||||
import org.talend.designer.core.ui.editor.dependencies.util.ResourceDependenciesUtil;
|
||||
import org.talend.designer.maven.tools.BuildCacheManager;
|
||||
import org.talend.designer.runprocess.ProcessorUtilities;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
public class ResourcesDependenciesService implements IResourcesDependenciesService {
|
||||
@@ -89,12 +91,12 @@ public class ResourcesDependenciesService implements IResourcesDependenciesServi
|
||||
if (repoObject != null) {
|
||||
JobResourceDependencyModel model = new JobResourceDependencyModel(
|
||||
(ResourceItem) repoObject.getProperty().getItem());
|
||||
StringBuffer joblabel = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(property.getItem().getState().getPath())) {
|
||||
joblabel.append(property.getItem().getState().getPath() + "/");
|
||||
String jobLabel = JavaResourcesHelper.getJobFolderName(property.getLabel(), property.getVersion());
|
||||
if (ProcessorUtilities.isExportConfig()) {
|
||||
resPath = ResourceDependenciesUtil.getResourcePath(model, jobLabel, parts[1]);
|
||||
}else {
|
||||
resPath = ResourceDependenciesUtil.getJobExecuteResourceFilePath(model, property, jobLabel, parts[1]);
|
||||
}
|
||||
joblabel.append(property.getLabel() + "_" + property.getVersion());
|
||||
resPath = ResourceDependenciesUtil.getResourcePath(model, joblabel.toString(), parts[1]);
|
||||
// to check if file exist, if not copy it
|
||||
ResourceDependenciesUtil.copyToExtResourceFolder(model, property.getId(), property.getVersion(), parts[1],
|
||||
null);
|
||||
|
||||
@@ -22,10 +22,12 @@ import java.util.Map;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.metadata.types.JavaTypesManager;
|
||||
import org.talend.core.model.process.IContext;
|
||||
@@ -35,8 +37,11 @@ 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.model.resources.ResourceItem;
|
||||
import org.talend.core.model.utils.JavaResourcesHelper;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.process.ITalendProcessJavaProject;
|
||||
import org.talend.designer.core.ui.editor.dependencies.model.JobResourceDependencyModel;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
public class ResourceDependenciesUtil {
|
||||
@@ -64,12 +69,8 @@ public class ResourceDependenciesUtil {
|
||||
|
||||
public static Collection<JobResourceDependencyModel> getResourceDependencies(IProcess2 process) {
|
||||
Property property = process.getProperty();
|
||||
StringBuffer joblabel = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(property.getItem().getState().getPath())) {
|
||||
joblabel.append(property.getItem().getState().getPath() + "/");
|
||||
}
|
||||
joblabel.append(property.getLabel() + "_" + property.getVersion());
|
||||
return getResourceDependencies((String) process.getAdditionalProperties().get(RESOURCES_PROP), joblabel.toString(),
|
||||
String jobLabel = JavaResourcesHelper.getJobFolderName(property.getLabel(), property.getVersion());
|
||||
return getResourceDependencies((String) process.getAdditionalProperties().get(RESOURCES_PROP), jobLabel,
|
||||
process);
|
||||
}
|
||||
|
||||
@@ -240,18 +241,14 @@ public class ResourceDependenciesUtil {
|
||||
Path p = new Path(item.getProperty().getLabel());
|
||||
resourcePath.append(p.removeFileExtension().lastSegment());
|
||||
resourcePath.append("_" + version + "." + item.getBindingExtension());
|
||||
// for job testjob_0.2 => testjob_0_2
|
||||
String checkversion = jobLabel.substring(jobLabel.lastIndexOf("_"));
|
||||
if (checkversion.contains(".")) {
|
||||
jobLabel = jobLabel.substring(0, jobLabel.lastIndexOf("_")) + checkversion.replace(".", "_");
|
||||
}
|
||||
// Local_Project/testjob_0_2/resources/test_0.1.txt
|
||||
/*
|
||||
* Local_Project project Label need to lower case avoid the exception of
|
||||
* org.eclipse.core.internal.resources.ResourceException: A resource exists with a different case caused by
|
||||
* ext-resources/local_project/testjob_0_2/contexts
|
||||
*/
|
||||
String newFilePath = currentProject.getLabel().toLowerCase() + SEG_TAG + jobLabel + SEG_TAG + SRC_RESOURCES_FOLDER
|
||||
String newFilePath = JavaResourcesHelper.getProjectFolderName(currentProject.getTechnicalLabel()) + SEG_TAG + jobLabel
|
||||
+ SEG_TAG + SRC_RESOURCES_FOLDER
|
||||
+ SEG_TAG + resourcePath.toString();
|
||||
return newFilePath;
|
||||
}
|
||||
@@ -268,11 +265,7 @@ public class ResourceDependenciesUtil {
|
||||
return;
|
||||
}
|
||||
Property property = jobObject.getProperty();
|
||||
StringBuffer joblabel = new StringBuffer();
|
||||
if (StringUtils.isNotBlank(property.getItem().getState().getPath())) {
|
||||
joblabel.append(property.getItem().getState().getPath() + "/");
|
||||
}
|
||||
joblabel.append(property.getLabel() + "_" + property.getVersion());
|
||||
String jobLabel = JavaResourcesHelper.getJobFolderName(property.getLabel(), property.getVersion());
|
||||
|
||||
ResourceItem item = model.getItem();
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
@@ -294,13 +287,7 @@ public class ResourceDependenciesUtil {
|
||||
String itemResPath = model.getPathUrl() + fileSuffix;
|
||||
File resourceFile = project.getFile(new Path(RESOURCES_FOLDER + SEG_TAG + itemResPath)).getLocation().toFile();
|
||||
if (resourceFile.exists()) {
|
||||
String processJobLabel = joblabel.toString();
|
||||
if (StringUtils.isNotBlank(rootJobLabel)) {
|
||||
processJobLabel = rootJobLabel;
|
||||
}
|
||||
String extResPath = getProcessFolder(jobObject) + processJobLabel.toLowerCase() + SRC_EXTRESOURCE_FOLDER;
|
||||
String newFilePath = getResourcePath(model, joblabel.toString(), newVersion);
|
||||
File targetFile = project.getFile(new Path(extResPath + SEG_TAG + newFilePath)).getLocation().toFile();
|
||||
File targetFile = new File(getJobExecuteResourceFilePath(model, property, jobLabel, newVersion));
|
||||
try {
|
||||
FilesUtils.copyFile(resourceFile, targetFile);
|
||||
} catch (IOException e) {
|
||||
@@ -309,6 +296,21 @@ public class ResourceDependenciesUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static String getJobExecuteResourceFilePath(JobResourceDependencyModel model, Property jobProperty,String jobLabel,String resourceVersion) {
|
||||
String path = null;
|
||||
IRunProcessService service = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
service = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
|
||||
}
|
||||
if (service == null) {
|
||||
return path;
|
||||
}
|
||||
String filePath = getResourcePath(model, jobLabel, resourceVersion);
|
||||
ITalendProcessJavaProject talendJobJavaProject = service.getTalendJobJavaProject(jobProperty);
|
||||
path = talendJobJavaProject.getExternalResourcesFolder().getFile(new Path(filePath)).getLocation().toOSString();
|
||||
return path;
|
||||
}
|
||||
|
||||
public static void deleteFromResourceFolder(JobResourceDependencyModel model, String jobId, String jobVersion) {
|
||||
IRepositoryViewObject jobObject = null;
|
||||
try {
|
||||
@@ -367,7 +369,7 @@ public class ResourceDependenciesUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getProcessFolder(IRepositoryViewObject jobObject) {
|
||||
public static String getProcessFolder(IRepositoryViewObject jobObject) {
|
||||
String folder = jobObject.getRepositoryObjectType().getFolder();
|
||||
return POMS_JOBS_FOLDER + folder + "/";
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -29,6 +30,7 @@ import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.EComponentType;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
@@ -45,6 +47,9 @@ import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.ui.editor.RepositoryEditorInput;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.projectsetting.IProjectSettingPreferenceConstants;
|
||||
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
|
||||
import org.talend.core.services.ISVNProviderService;
|
||||
import org.talend.core.ui.IJobletProviderService;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
@@ -97,6 +102,15 @@ public class JobletUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isStrictJoblet() {
|
||||
ProjectPreferenceManager projectPreferenceManager = CoreRuntimePlugin.getInstance()
|
||||
.getProjectPreferenceManager();
|
||||
if(projectPreferenceManager == null) {
|
||||
return false;
|
||||
}
|
||||
return projectPreferenceManager.getBoolean(IProjectSettingPreferenceConstants.USE_STRICT_REFERENCE_JOBLET);
|
||||
}
|
||||
|
||||
public List<INodeConnector> createConnectors(INode node, IProcess2 process) {
|
||||
List<INodeConnector> listConnector = new ArrayList<INodeConnector>();
|
||||
@@ -750,4 +764,25 @@ public class JobletUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Optional<IComponent> findComponentByName(Set<IComponent> components, String searchName, String paletteType) {
|
||||
return components.stream().filter(p -> p.getComponentType() == EComponentType.JOBLET
|
||||
&& paletteType.equals(p.getPaletteType()) && matchesName(p.getName(), searchName)).findFirst();
|
||||
}
|
||||
|
||||
private boolean matchesName(String exist, String search) {
|
||||
if (exist == null) {
|
||||
return false;
|
||||
}
|
||||
if (exist.equals(search)) {
|
||||
return true;
|
||||
}
|
||||
if (matchExpression(exist)) {
|
||||
exist = StringUtils.substringAfterLast(exist, ":"); //$NON-NLS-1$
|
||||
if (exist.equals(search)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -516,7 +519,7 @@ public class Node extends Element implements IGraphicalNode {
|
||||
|
||||
private void init(IComponent newComponent) {
|
||||
this.component = UnifiedComponentUtil.getEmfComponent(this, newComponent);
|
||||
this.label = component.getName();
|
||||
this.label = component.getDisplayName();
|
||||
updateComponentStatusIfNeeded(true);
|
||||
IPreferenceStore store = DesignerPlugin.getDefault().getPreferenceStore();
|
||||
|
||||
@@ -1179,6 +1182,12 @@ public class Node extends Element implements IGraphicalNode {
|
||||
if (useConn != null) {
|
||||
connParam = this.getElementParameter("CONNECTION"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
boolean isGeneric = this.getComponent().getComponentType() == EComponentType.GENERIC;
|
||||
if(isGeneric && labelToParse != null) {
|
||||
labelToParse = labelToParse.replaceAll("__TABLE__", "__tableSelection.tablename__"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
if (useConn != null && connParam != null && Boolean.TRUE.equals(useConn.getValue())) {
|
||||
|
||||
String connName = (String) connParam.getValue();
|
||||
@@ -5624,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
@@ -123,7 +124,9 @@ import org.talend.core.model.update.IUpdateManager;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.utils.ConvertJobsUtil;
|
||||
import org.talend.core.repository.utils.ProjectHelper;
|
||||
import org.talend.core.repository.utils.XmiResourceManager;
|
||||
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
|
||||
import org.talend.core.runtime.repository.item.ItemProductKeys;
|
||||
import org.talend.core.runtime.util.ItemDateParser;
|
||||
import org.talend.core.service.IScdComponentService;
|
||||
@@ -184,7 +187,6 @@ import org.talend.designer.core.utils.DetectContextVarsUtils;
|
||||
import org.talend.designer.core.utils.JavaProcessUtil;
|
||||
import org.talend.designer.core.utils.JobSettingVersionUtil;
|
||||
import org.talend.designer.core.utils.UnifiedComponentUtil;
|
||||
import org.talend.designer.core.utils.UpdateParameterUtils;
|
||||
import org.talend.designer.core.utils.ValidationRulesUtil;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.designer.runprocess.ItemCacheManager;
|
||||
@@ -1079,7 +1081,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
ElementParameterType pType;
|
||||
boolean isJoblet = false;
|
||||
if (param.getElement() instanceof INode && PluginChecker.isJobLetPluginLoaded()) {
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService.class);
|
||||
if (service != null && service.isJobletComponent((INode) param.getElement())) {
|
||||
isJoblet = true;
|
||||
@@ -1370,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) {
|
||||
@@ -1399,11 +1402,6 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IElementParameter param : elemParam.getElementParameters()) {
|
||||
UpdateParameterUtils.setDefaultValues(param, elemParam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected boolean noNeedSetValue(IElementParameter param, String paraValue) {
|
||||
@@ -1819,23 +1817,36 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
routinesDependencies = new ArrayList<RoutinesParameterType>();
|
||||
}
|
||||
try {
|
||||
Project targetProject = new Project(ProjectManager.getInstance().getProject(getProperty()));
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
Set<IRepositoryViewObject> routines = new HashSet<>();
|
||||
routines.addAll(factory.getAll(targetProject, ERepositoryObjectType.ROUTINES));
|
||||
List<Project> referenceProjects = ProjectManager.getInstance().getAllReferencedProjects(targetProject, false);
|
||||
referenceProjects.stream().forEach(p -> {
|
||||
try {
|
||||
routines.addAll(factory.getAll(p, ERepositoryObjectType.ROUTINES));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
});
|
||||
Map<String, String> allRoutinesMap = routines.stream()
|
||||
.collect(Collectors.toMap(IRepositoryViewObject::getId, IRepositoryViewObject::getLabel));
|
||||
Iterator<RoutinesParameterType> iterator = routinesDependencies.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
RoutinesParameterType routine = iterator.next();
|
||||
if (!allRoutinesMap.containsKey(routine.getId())) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
List<String> possibleRoutines = new ArrayList<String>();
|
||||
List<String> routinesToAdd = new ArrayList<String>();
|
||||
String additionalString = LanguageManager.getCurrentLanguage() == ECodeLanguage.JAVA ? "." : "";
|
||||
|
||||
List<String> routinesAlreadySetup = new ArrayList<String>();
|
||||
|
||||
for (RoutinesParameterType routine : routinesDependencies) {
|
||||
routinesAlreadySetup.add(routine.getName());
|
||||
}
|
||||
|
||||
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
List<IRepositoryViewObject> routines = factory.getAll(ProjectManager.getInstance().getCurrentProject(),
|
||||
ERepositoryObjectType.ROUTINES);
|
||||
routines.addAll(factory.getAll(ProjectManager.getInstance().getCurrentProject(), ERepositoryObjectType.PIG_UDF));
|
||||
for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
|
||||
for (Project project : referenceProjects) {
|
||||
List<IRepositoryViewObject> refRoutines = factory.getAll(project, ERepositoryObjectType.ROUTINES);
|
||||
refRoutines.addAll(factory.getAll(project, ERepositoryObjectType.PIG_UDF));
|
||||
for (IRepositoryViewObject object : refRoutines) {
|
||||
if (!((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
|
||||
if (!possibleRoutines.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
@@ -1860,9 +1871,8 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
possibleRoutines.add(object.getLabel());
|
||||
}
|
||||
}
|
||||
for (Project project : ProjectManager.getInstance().getAllReferencedProjects()) {
|
||||
for (Project project : referenceProjects) {
|
||||
List<IRepositoryViewObject> refRoutines = factory.getAll(project, ERepositoryObjectType.ROUTINES);
|
||||
refRoutines.addAll(factory.getAll(project, ERepositoryObjectType.PIG_UDF));
|
||||
for (IRepositoryViewObject object : refRoutines) {
|
||||
if (!((RoutineItem) object.getProperty().getItem()).isBuiltIn()) {
|
||||
if (!possibleRoutines.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
@@ -1920,12 +1930,25 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
}
|
||||
|
||||
for (IRepositoryViewObject object : routines) {
|
||||
if (routinesToAdd.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
|
||||
routinesParameterType.setId(object.getId());
|
||||
routinesParameterType.setName(object.getLabel());
|
||||
routinesDependencies.add(routinesParameterType);
|
||||
//
|
||||
boolean isLimited = false;
|
||||
org.talend.core.model.properties.Project currProject = getProject().getEmfProject();
|
||||
org.talend.core.model.properties.Project project = ProjectManager.getInstance().getProject(this.property);
|
||||
if (currProject != null && project != null && !currProject.equals(project)) {
|
||||
int currOrdinal = ProjectHelper.getProjectTypeOrdinal(currProject);
|
||||
int ordinal = ProjectHelper.getProjectTypeOrdinal(project);
|
||||
if (currOrdinal > ordinal) {
|
||||
isLimited = true;
|
||||
}
|
||||
}
|
||||
if (!isLimited) {
|
||||
for (IRepositoryViewObject object : routines) {
|
||||
if (routinesToAdd.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
|
||||
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
|
||||
routinesParameterType.setId(object.getId());
|
||||
routinesParameterType.setName(object.getLabel());
|
||||
routinesDependencies.add(routinesParameterType);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
@@ -2283,7 +2306,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
if (EParameterName.PROCESS_TYPE_VERSION.name().equals(pType.getName())) {
|
||||
String jobletVersion = pType.getValue();
|
||||
if (!RelationshipItemBuilder.LATEST_VERSION.equals(jobletVersion)) {
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault()
|
||||
IJobletProviderService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IJobletProviderService.class);
|
||||
if (service != null) {
|
||||
Property jobletProperty = service.getJobletComponentItem(component);
|
||||
@@ -2321,12 +2344,12 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
String componentName = unNode.getComponentName();
|
||||
if (!isCurrentProject && !componentName.contains(":")) {
|
||||
componentName = ProjectManager.getInstance().getProject(this.getProperty()).getLabel() + ":" + componentName; //$NON-NLS-1$
|
||||
} else if (jobletUtil.matchExpression(componentName)) {
|
||||
} else if (jobletUtil.matchExpression(componentName) && !jobletUtil.isStrictJoblet()) {
|
||||
String[] names = componentName.split(":"); //$NON-NLS-1$
|
||||
componentName = names[1];
|
||||
}
|
||||
IComponent component = ComponentsFactoryProvider.getInstance().get(componentName, componentsType);
|
||||
if (component == null && jobletUtil.isJoblet(unNode)) {
|
||||
if (component == null && jobletUtil.isJoblet(unNode) && !jobletUtil.isStrictJoblet()) {
|
||||
component = ComponentsFactoryProvider.getInstance().getJobletComponent(componentName, componentsType);
|
||||
}
|
||||
if (component != null) {
|
||||
@@ -2453,7 +2476,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
updateAllMappingTypes();
|
||||
nc.setNeedLoadLib(false);
|
||||
if (nc.isJoblet()) {
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService.class);
|
||||
if (service != null) {
|
||||
// reload only for stuido ,because joblet can be changed in the job editor
|
||||
@@ -2467,7 +2490,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
NodeContainer nodeContainer = null;
|
||||
if (isJunitContainer) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
|
||||
ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault()
|
||||
ITestContainerGEFService testContainerService = GlobalServiceRegister.getDefault()
|
||||
.getService(ITestContainerGEFService.class);
|
||||
if (testContainerService != null) {
|
||||
nodeContainer = testContainerService.createJunitContainer(node);
|
||||
@@ -2669,7 +2692,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IScdComponentService.class)) {
|
||||
IScdComponentService service = (IScdComponentService) GlobalServiceRegister.getDefault().getService(
|
||||
IScdComponentService service = GlobalServiceRegister.getDefault().getService(
|
||||
IScdComponentService.class);
|
||||
service.updateOutputMetadata(nc, metadataTable);
|
||||
}
|
||||
@@ -2796,7 +2819,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
} else {
|
||||
if (PluginChecker.isJobLetPluginLoaded()) { // bug 12764
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService.class);
|
||||
if (service != null && service.isJobletComponent(source)) {
|
||||
continue;
|
||||
@@ -3323,6 +3346,9 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
component = ((Node) node).getDelegateComponent();
|
||||
}
|
||||
String baseName = component.getOriginalName();
|
||||
if (EComponentType.GENERIC.equals(component.getComponentType())) {
|
||||
baseName = component.getDisplayName();
|
||||
}
|
||||
return UniqueNodeNameGenerator.generateUniqueNodeName(baseName, uniqueNodeNameList);
|
||||
}
|
||||
|
||||
@@ -4432,6 +4458,18 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
private void loadAdditionalProperties() {
|
||||
if (additionalProperties == null) {
|
||||
additionalProperties = new HashMap<Object, Object>();
|
||||
try {
|
||||
if (property.getItem() != null && ERepositoryObjectType.getType(property) != null) {
|
||||
boolean isRouteProcess = ERepositoryObjectType.getType(property).equals(ERepositoryObjectType.PROCESS_ROUTE);
|
||||
if (!isRouteProcess && "ROUTE"
|
||||
.equals(this.property.getAdditionalProperties().get(TalendProcessArgumentConstant.ARG_BUILD_TYPE))) {
|
||||
this.property.getAdditionalProperties().remove(TalendProcessArgumentConstant.ARG_BUILD_TYPE);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
for (Object key : this.property.getAdditionalProperties().keySet()) {
|
||||
additionalProperties.put(key, this.property.getAdditionalProperties().get(key));
|
||||
}
|
||||
@@ -4563,6 +4601,9 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
}
|
||||
|
||||
private void saveJobletNode(AbstractJobletContainer jobletContainer) {
|
||||
if (CommonsPlugin.isHeadless()) {
|
||||
return;
|
||||
}
|
||||
INode jobletNode = jobletContainer.getNode();
|
||||
IProcess jobletProcess = jobletNode.getComponent().getProcess();
|
||||
if (jobletProcess == null) {
|
||||
@@ -4572,7 +4613,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
Item item = ((IProcess2) jobletProcess).getProperty().getItem();
|
||||
if (item instanceof JobletProcessItem) {
|
||||
JobletProcessItem jobletItem = ((JobletProcessItem) item);
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService.class);
|
||||
if (service != null) {
|
||||
service.saveJobletNode(jobletItem, jobletContainer);
|
||||
@@ -4621,7 +4662,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
|
||||
|
||||
IJobletProviderService jobletService = null;
|
||||
if (PluginChecker.isJobLetPluginLoaded()) {
|
||||
jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
|
||||
jobletService = GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
|
||||
for (INode node : getGraphicalNodes()) {
|
||||
if (jobletService.isJobletComponent(node)) {
|
||||
listRoutines.addAll(getJobletRoutines(jobletService, node));
|
||||
|
||||
@@ -115,6 +115,7 @@ import org.talend.core.ui.ICDCProviderService;
|
||||
import org.talend.core.ui.IJobletProviderService;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.cwm.helper.SAPBWTableHelper;
|
||||
import org.talend.designer.core.DesignerPlugin;
|
||||
import org.talend.designer.core.i18n.Messages;
|
||||
import org.talend.designer.core.model.components.EParameterName;
|
||||
import org.talend.designer.core.model.components.ElementParameter;
|
||||
@@ -126,6 +127,7 @@ import org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl;
|
||||
import org.talend.designer.core.ui.editor.nodes.Node;
|
||||
import org.talend.designer.core.ui.editor.update.UpdateCheckResult;
|
||||
import org.talend.designer.core.ui.editor.update.UpdateManagerUtils;
|
||||
import org.talend.designer.core.ui.preferences.TalendDesignerPrefConstants;
|
||||
import org.talend.designer.core.utils.ConnectionUtil;
|
||||
import org.talend.designer.core.utils.SAPParametersUtils;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
@@ -308,6 +310,10 @@ public class ProcessUpdateManager extends AbstractUpdateManager {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Boolean propagate = DesignerPlugin.getDefault().getPreferenceStore().getBoolean(TalendDesignerPrefConstants.PROPAGATE_CONTEXT);
|
||||
if(!propagate) {
|
||||
return contextResults;
|
||||
}
|
||||
// only handle added groups
|
||||
Set<String> contextSourceChecked = new HashSet<String>();
|
||||
Set<String> processContextGroups = new HashSet<String>();
|
||||
@@ -415,8 +421,6 @@ public class ProcessUpdateManager extends AbstractUpdateManager {
|
||||
|
||||
Map<ContextItem, Set<String>> existedParams = new HashMap<ContextItem, Set<String>>();
|
||||
|
||||
List<String> contextItemGroupNames = new ArrayList<String>();
|
||||
|
||||
for (IContext context : contextManager.getListContext()) {
|
||||
for (IContextParameter param : context.getContextParameterList()) {
|
||||
if (!param.isBuiltIn()) {
|
||||
@@ -440,14 +444,6 @@ public class ProcessUpdateManager extends AbstractUpdateManager {
|
||||
boolean builtin = true;
|
||||
if (contextItem != null) {
|
||||
if (contextItem instanceof ContextItem) {
|
||||
contextItemGroupNames.clear();
|
||||
EList<?> contextGroups = ((ContextItem) contextItem).getContext();
|
||||
for (Object contextGroup : contextGroups) {
|
||||
if (contextGroup instanceof ContextTypeImpl) {
|
||||
String name = ((ContextTypeImpl) contextGroup).getName();
|
||||
contextItemGroupNames.add(name);
|
||||
}
|
||||
}
|
||||
final ContextType contextType = ContextUtils.getContextTypeByName((ContextItem) contextItem,
|
||||
context.getName(), true);
|
||||
if (contextType != null) {
|
||||
@@ -459,10 +455,8 @@ public class ProcessUpdateManager extends AbstractUpdateManager {
|
||||
existedParams.put(repositoryContext, new HashSet<String>());
|
||||
}
|
||||
existedParams.get(repositoryContext).add(paramName);
|
||||
String jobContextGroupName = context.getName();
|
||||
boolean contains = contextItemGroupNames.contains(jobContextGroupName);
|
||||
if (contains && (onlySimpleShow || !ContextUtils.samePropertiesForContextParameter(param,
|
||||
contextParameterType))) {
|
||||
if (onlySimpleShow || !ContextUtils.samePropertiesForContextParameter(param,
|
||||
contextParameterType)) {
|
||||
unsameMap.add(contextItem, paramName);
|
||||
}
|
||||
builtin = false;
|
||||
@@ -596,10 +590,14 @@ public class ProcessUpdateManager extends AbstractUpdateManager {
|
||||
if (newParametersMap.get(contextItem) == null) {
|
||||
newParametersMap.put(contextItem, new HashSet<String>());
|
||||
}
|
||||
newParametersMap.get(contextItem).add(parameterType.getName());
|
||||
// To avoid the case: serval contexts contain more than one same name parameters, but we only can add
|
||||
// one of them
|
||||
IContext processContext = ((JobContextManager) contextManager).getDefaultContext();
|
||||
if (processContext.getContextParameter(parameterType.getName()) == null) {
|
||||
newParametersMap.get(contextItem).add(parameterType.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1535,9 +1533,9 @@ public class ProcessUpdateManager extends AbstractUpdateManager {
|
||||
|
||||
if (onlySimpleShow
|
||||
|| !metadataTable.sameMetadataAs(copyOfrepositoryMetadata,
|
||||
IMetadataColumn.OPTIONS_IGNORE_DBTYPE)
|
||||
IMetadataColumn.OPTIONS_IGNORE_DBTYPE, true)
|
||||
|| connectionItem instanceof GenericSchemaConnectionItem && !metadataTable
|
||||
.sameMetadataAs(copyOfrepositoryMetadata, IMetadataColumn.OPTIONS_NONE)) {
|
||||
.sameMetadataAs(copyOfrepositoryMetadata, IMetadataColumn.OPTIONS_NONE, true)) {
|
||||
result = new UpdateCheckResult(node);
|
||||
result.setResult(EUpdateItemType.NODE_SCHEMA, EUpdateResult.UPDATE,
|
||||
copyOfrepositoryMetadata, source);
|
||||
|
||||
@@ -247,7 +247,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
if (obj instanceof RepositoryNode) {
|
||||
RepositoryNode sourceNode = (RepositoryNode) obj;
|
||||
if (PluginChecker.isCDCPluginLoaded()) {
|
||||
ICDCProviderService service = (ICDCProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
ICDCProviderService service = GlobalServiceRegister.getDefault().getService(
|
||||
ICDCProviderService.class);
|
||||
|
||||
if (service != null && (service.isSubscriberTableNode(sourceNode) || service.isSystemSubscriberTable(sourceNode))) {
|
||||
@@ -260,7 +260,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
}
|
||||
IOozieService oozieService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IOozieService.class)) {
|
||||
oozieService = (IOozieService) GlobalServiceRegister.getDefault().getService(IOozieService.class);
|
||||
oozieService = GlobalServiceRegister.getDefault().getService(IOozieService.class);
|
||||
}
|
||||
if (oozieService != null && oozieService.isOozieNode(sourceNode)) {
|
||||
return false;
|
||||
@@ -268,7 +268,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
|
||||
ISAPProviderService sapService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISAPProviderService.class)) {
|
||||
sapService = (ISAPProviderService) GlobalServiceRegister.getDefault().getService(ISAPProviderService.class);
|
||||
sapService = GlobalServiceRegister.getDefault().getService(ISAPProviderService.class);
|
||||
}
|
||||
if (sapService != null && sapService.isSAPNode(sourceNode)) {
|
||||
return false;
|
||||
@@ -1051,7 +1051,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
Item item = sourceNode.getObject().getProperty().getItem();
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
|
||||
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister
|
||||
ITestContainerProviderService testContainerService = GlobalServiceRegister
|
||||
.getDefault().getService(ITestContainerProviderService.class);
|
||||
if (testContainerService != null && testContainerService.isTestContainerItem(item)) {
|
||||
continue;
|
||||
@@ -1971,7 +1971,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
// special handle hbase to support tpigLoad
|
||||
String hbaseName = EDatabaseTypeName.HBASE.getDisplayName().toUpperCase();
|
||||
if (rcSetting != null && (hbaseName).equals(rcSetting.toString())) {
|
||||
IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(
|
||||
IComponentsService service = GlobalServiceRegister.getDefault().getService(
|
||||
IComponentsService.class);
|
||||
String componentProductname = null;
|
||||
Collection<IComponent> components = service.getComponentsFactory().readComponents();
|
||||
@@ -2125,7 +2125,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
|
||||
EConnectionType connectionType = EConnectionType.FLOW_MAIN;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
|
||||
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault()
|
||||
ICamelDesignerCoreService camelService = GlobalServiceRegister.getDefault()
|
||||
.getService(ICamelDesignerCoreService.class);
|
||||
if (camelService.isRouteBuilderNode(node)) {
|
||||
connectionType = camelService.getTargetConnectionType(node);
|
||||
@@ -2143,7 +2143,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
// FIXME perhaps, this is not good fix, need check it later
|
||||
// bug 21411
|
||||
if (PluginChecker.isJobLetPluginLoaded()) {
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService.class);
|
||||
if (service != null && service.isJobletComponent(targetConnection.getTarget())) {
|
||||
if (targetConnection.getTarget() instanceof Node) {
|
||||
@@ -2277,7 +2277,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
private boolean isLock(JobletContainerPart part) {
|
||||
INode jobletNode = ((JobletContainer) part.getModel()).getNode();
|
||||
if (PluginChecker.isJobLetPluginLoaded()) {
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService.class);
|
||||
if (service != null) {
|
||||
return service.isLock(jobletNode);
|
||||
@@ -2292,7 +2292,7 @@ public class TalendEditorDropTargetListener extends TemplateTransferDropTargetLi
|
||||
Node jobletNode = ((JobletContainer) part.getModel()).getNode();
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
if (PluginChecker.isJobLetPluginLoaded()) {
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService.class);
|
||||
if (service != null) {
|
||||
openEditor = (AbstractMultiPageTalendEditor) service.openJobletEditor(jobletNode, page);
|
||||
@@ -2332,7 +2332,7 @@ class ComponentChooseDialog extends ListDialog {
|
||||
if (UnifiedComponentUtil.isDelegateComponent(component) && typeName != null) {
|
||||
return component.getName() + "(" + typeName + ")";
|
||||
}
|
||||
return component.getName();
|
||||
return component.getDisplayName();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.gef.commands.Command;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
@@ -36,6 +37,7 @@ import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.update.EUpdateItemType;
|
||||
import org.talend.core.model.update.EUpdateResult;
|
||||
import org.talend.core.model.update.UpdateResult;
|
||||
@@ -86,15 +88,16 @@ public class UpdateContextParameterCommand extends Command {
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
List<String> contextItemGroupNames = new ArrayList<String>();
|
||||
Map<String, ContextType> repoContextMap = new HashMap<String, ContextType>();
|
||||
String repoDefaultContextName = null;
|
||||
if (result.getParameter() != null) {
|
||||
if (result.getParameter() instanceof ContextItem) {
|
||||
contextItemGroupNames.clear();
|
||||
EList<?> contextGroups = ((ContextItem) result.getParameter()).getContext();
|
||||
for (Object contextGroup : contextGroups) {
|
||||
repoDefaultContextName = ((ContextItem) result.getParameter()).getDefaultContext();
|
||||
for (Object contextGroup : contextGroups) {
|
||||
if (contextGroup instanceof ContextTypeImpl) {
|
||||
String name = ((ContextTypeImpl) contextGroup).getName();
|
||||
contextItemGroupNames.add(name);
|
||||
repoContextMap.put(name, ((ContextTypeImpl) contextGroup));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,13 +140,19 @@ public class UpdateContextParameterCommand extends Command {
|
||||
}
|
||||
break;
|
||||
case UPDATE:
|
||||
if (contextItemGroupNames.contains(context.getName())) {
|
||||
String sourceContextName = null;
|
||||
if (repoContextMap.containsKey(context.getName())) {
|
||||
sourceContextName = context.getName();
|
||||
} else {
|
||||
sourceContextName = repoDefaultContextName;
|
||||
}
|
||||
if (sourceContextName != null) {
|
||||
item = (ContextItem) result.getParameter();
|
||||
|
||||
if (item != null && item.getProperty().getId().equals(param.getSource())
|
||||
&& result.isChecked()) {
|
||||
|
||||
ContextUtils.updateParameterFromRepository(item, param, context.getName());
|
||||
ContextUtils.updateParameterFromRepository(item, param, sourceContextName);
|
||||
} else {
|
||||
param.setSource(IContextParameter.BUILT_IN);
|
||||
}
|
||||
@@ -201,6 +210,30 @@ public class UpdateContextParameterCommand extends Command {
|
||||
continue;
|
||||
}
|
||||
param = (JobContextParameter) contextParam.clone();
|
||||
final Item contextItem = ContextUtils.getRepositoryContextItemById(param.getSource());
|
||||
if (contextItem != null) {
|
||||
if (contextItem instanceof ContextItem) {
|
||||
String defaultContextName = ((ContextItem) contextItem).getDefaultContext();
|
||||
ContextTypeImpl defaultContext = null;
|
||||
EList<?> contextGroups = ((ContextItem) contextItem).getContext();
|
||||
for (Object contextGroup : contextGroups) {
|
||||
if (contextGroup instanceof ContextTypeImpl) {
|
||||
String conName = ((ContextTypeImpl) contextGroup).getName();
|
||||
if (StringUtils.equals(defaultContextName, conName)) {
|
||||
defaultContext = ((ContextTypeImpl) contextGroup);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (defaultContext != null) {
|
||||
final ContextParameterType conParamType = ContextUtils
|
||||
.getContextParameterTypeByName(defaultContext, param.getName());
|
||||
if (conParamType != null) {
|
||||
ContextUtils.updateParameter(conParamType, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
param.setContext(newContext);
|
||||
newParamList.add(param);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ public class DesignerPreferencePage extends FieldEditorPreferencePage implements
|
||||
Messages.getString("DesignerPreferencePage.duplicateTestCases"), getFieldEditorParent()); //$NON-NLS-1$
|
||||
addField(duplicateTestCases);
|
||||
}
|
||||
|
||||
|
||||
DirectoryFieldEditor compDefaultFileDir = new DirectoryFieldEditor(TalendDesignerPrefConstants.COMP_DEFAULT_FILE_DIR,
|
||||
Messages.getString("DesignerPreferencePage.defaultFilePathDirectory"), getFieldEditorParent()) {
|
||||
|
||||
|
||||
@@ -65,6 +65,9 @@ public class PerformancePreferencePage extends FieldEditorPreferencePage impleme
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.CHECK_ONLY_LAST_VERSION,
|
||||
Messages.getString("PerformancePreferencePage.checkVersion"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT,
|
||||
Messages.getString("PerformancePreferencePage.propagateContext"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE,
|
||||
Messages.getString("PerformancePreferencePage.addOrDeleteVariable"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
@@ -101,6 +104,9 @@ public class PerformancePreferencePage extends FieldEditorPreferencePage impleme
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.CHECK_ONLY_LAST_VERSION,
|
||||
Messages.getString("PerformancePreferencePage.checkVersion"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT,
|
||||
Messages.getString("PerformancePreferencePage.propagateContext"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
addField(new BooleanFieldEditor(TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE,
|
||||
Messages.getString("PerformancePreferencePage.addOrDeleteVariable"), //$NON-NLS-1$
|
||||
getFieldEditorParent()));
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -67,6 +67,8 @@ public class TalendDesignerPrefConstants {
|
||||
public static final String EDITOR_LINESTYLE = "editorLineStyle "; //$NON-NLS-1$
|
||||
|
||||
public static final String DUPLICATE_TESTCASE = "duplicateTestCases "; //$NON-NLS-1$
|
||||
|
||||
public static final String PROPAGATE_CONTEXT = "propagateContext"; //$NON-NLS-1$
|
||||
|
||||
public static final String SCHEMA_OPTIONS = "schemaOptions"; //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -151,7 +151,12 @@ public class BigDataJobUtil {
|
||||
|
||||
for (IElementParameter pt : parameters) {
|
||||
if (pt.getName().equals("DISTRIBUTION")) { //$NON-NLS-1$
|
||||
return true;
|
||||
String value = String.valueOf(pt.getValue());
|
||||
if ("MICROSOFT_HD_INSIGHT".equals(value) //$NON-NLS-1$
|
||||
|| "GOOGLE_CLOUD_DATAPROC".equals(value) //$NON-NLS-1$
|
||||
|| "CLOUDERA_ALTUS".equals(value) || "DATABRICKS".equals(value) || "QUBOLE".equals(value)) { //$NON-NLS-1$
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isSparkWithYarnClusterMode()) {
|
||||
|
||||
@@ -436,7 +436,9 @@ public class JavaProcessUtil {
|
||||
if (var.equals(contextPara.getName())) {
|
||||
String value =
|
||||
context.getContextParameter(contextPara.getName()).getValue();
|
||||
|
||||
if (StringUtils.isBlank(value)) {
|
||||
continue;
|
||||
}
|
||||
if (curParam.getName().equals(EParameterName.DRIVER_JAR.getName())
|
||||
&& value.contains(";")) { //$NON-NLS-1$
|
||||
String[] jars = value.split(";"); //$NON-NLS-1$
|
||||
@@ -488,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");
|
||||
|
||||
@@ -49,8 +49,7 @@ public class UnifiedComponentUtil {
|
||||
if (elementParameter != null && elementParameter.getValue() != null) {
|
||||
String emfCompName = String.valueOf(elementParameter.getValue());
|
||||
String paletteType = component.getPaletteType();
|
||||
IComponentsService compService = (IComponentsService) GlobalServiceRegister.getDefault()
|
||||
.getService(IComponentsService.class);
|
||||
IComponentsService compService = GlobalServiceRegister.getDefault().getService(IComponentsService.class);
|
||||
IComponent emfComponent = compService.getComponentsFactory().get(emfCompName, paletteType);
|
||||
if (emfComponent != null) {
|
||||
return emfComponent;
|
||||
@@ -64,8 +63,7 @@ public class UnifiedComponentUtil {
|
||||
|
||||
public static boolean isDelegateComponent(IComponent component) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUnifiedComponentService.class)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
if (service.isDelegateComponent(component)) {
|
||||
return true;
|
||||
}
|
||||
@@ -75,8 +73,7 @@ public class UnifiedComponentUtil {
|
||||
|
||||
public static IComponent getDelegateComponent(IComponent component) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUnifiedComponentService.class)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
return service.getDelegateComponent(component);
|
||||
}
|
||||
return component;
|
||||
@@ -84,8 +81,7 @@ public class UnifiedComponentUtil {
|
||||
|
||||
public static IComponent getDelegateComponent(String componentName, String paletteType) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUnifiedComponentService.class)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
return service.getDelegateComponent(componentName, paletteType);
|
||||
}
|
||||
return null;
|
||||
@@ -94,8 +90,7 @@ public class UnifiedComponentUtil {
|
||||
public static void createParameters(INode node, List<IElementParameter> listParams, IComponent delegateComp,
|
||||
IComponent emfComp) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUnifiedComponentService.class)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
service.createParameters(node, listParams, delegateComp, emfComp);
|
||||
}
|
||||
}
|
||||
@@ -104,8 +99,7 @@ public class UnifiedComponentUtil {
|
||||
List<? extends IElementParameter> oldParms, List<IMetadataTable> oldMetadataTables,
|
||||
List<INodeConnector> oldConnectors) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUnifiedComponentService.class)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
service.switchComponent(node, delegateComponent, oldEmfComponent, oldParms, oldMetadataTables, oldConnectors);
|
||||
}
|
||||
|
||||
@@ -114,8 +108,7 @@ public class UnifiedComponentUtil {
|
||||
public static List<IComponent> filterUnifiedComponent(RepositoryComponentSetting setting, List<IComponent> componentList) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUnifiedComponentService.class)) {
|
||||
List<IComponent> filtedList = new ArrayList<IComponent>();
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
IComponentsHandler componentsHandler = ComponentsFactoryProvider.getInstance().getComponentsHandler();
|
||||
filtedList.addAll(componentList);
|
||||
for (IComponent component : componentList) {
|
||||
@@ -149,12 +142,10 @@ public class UnifiedComponentUtil {
|
||||
|
||||
public static IComponent getEmfComponent(IComponentName setting, IComponent selectedComponent) {
|
||||
if (isDelegateComponent(selectedComponent)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
String paletteType = selectedComponent.getPaletteType();
|
||||
String emfCompName = service.getUnifiedComponetName4DndFromRepository(setting, selectedComponent);
|
||||
IComponentsService compService = (IComponentsService) GlobalServiceRegister.getDefault()
|
||||
.getService(IComponentsService.class);
|
||||
IComponentsService compService = GlobalServiceRegister.getDefault().getService(IComponentsService.class);
|
||||
IComponent emfComponent = compService.getComponentsFactory().get(emfCompName, paletteType);
|
||||
if (emfComponent != null) {
|
||||
return emfComponent;
|
||||
@@ -167,8 +158,7 @@ public class UnifiedComponentUtil {
|
||||
|
||||
public static String getUnifiedComponentDisplayName(IComponent delegateComponent, String emfComponent) {
|
||||
if (isDelegateComponent(delegateComponent)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
return service.getUnifiedCompDisplayName(delegateComponent, emfComponent);
|
||||
}
|
||||
return delegateComponent.getName();
|
||||
@@ -194,17 +184,15 @@ public class UnifiedComponentUtil {
|
||||
|
||||
public static String getComponentDisplayNameForPalette(IComponent delegateComponent, String keyWord) {
|
||||
if (isDelegateComponent(delegateComponent)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
return service.getComponentDisplayNameForPalette(delegateComponent, keyWord);
|
||||
}
|
||||
return delegateComponent.getName();
|
||||
return delegateComponent.getDisplayName();
|
||||
}
|
||||
|
||||
public static IComponent getUnifiedComponentByFilter(IComponent delegateComponent, String filter) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUnifiedComponentService.class)) {
|
||||
IUnifiedComponentService service = (IUnifiedComponentService) GlobalServiceRegister.getDefault()
|
||||
.getService(IUnifiedComponentService.class);
|
||||
IUnifiedComponentService service = GlobalServiceRegister.getDefault().getService(IUnifiedComponentService.class);
|
||||
return service.getUnifiedComponentByFilter(delegateComponent, filter);
|
||||
}
|
||||
return null;
|
||||
|
||||
BIN
main/plugins/org.talend.designer.dbmap/icons/property.png
Normal file
BIN
main/plugins/org.talend.designer.dbmap/icons/property.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
@@ -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
|
||||
|
||||
@@ -54,6 +54,7 @@ import org.talend.designer.dbmap.i18n.Messages;
|
||||
import org.talend.designer.dbmap.language.generation.DbGenerationManager;
|
||||
import org.talend.designer.dbmap.language.generation.GenericDbGenerationManager;
|
||||
import org.talend.designer.dbmap.language.hive.HiveGenerationManager;
|
||||
import org.talend.designer.dbmap.language.mssql.MssqlGenerationManager;
|
||||
import org.talend.designer.dbmap.language.mysql.MysqlGenerationManager;
|
||||
import org.talend.designer.dbmap.language.oracle.OracleGenerationManager;
|
||||
import org.talend.designer.dbmap.language.postgres.PostgresGenerationManager;
|
||||
@@ -180,6 +181,29 @@ public class DbMapComponent extends AbstractMapComponent {
|
||||
elemParams.add(activeDelimitedIdentifiersEP);
|
||||
}
|
||||
activeDelimitedIdentifiersEP.setValue(getGenerationManager().isUseDelimitedIdentifiers());
|
||||
|
||||
//
|
||||
IElementParameter useAliasInOutputTableEP = origNode
|
||||
.getElementParameter(EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName());
|
||||
if (useAliasInOutputTableEP == null) {
|
||||
useAliasInOutputTableEP = new ElementParameter(origNode);
|
||||
useAliasInOutputTableEP.setShow(false);
|
||||
useAliasInOutputTableEP.setFieldType(EParameterFieldType.CHECK);
|
||||
useAliasInOutputTableEP.setName(EParameterName.USE_ALIAS_IN_OUTPUT_TABLE.getName());
|
||||
useAliasInOutputTableEP.setCategory(EComponentCategory.TECHNICAL);
|
||||
useAliasInOutputTableEP.setNumRow(99);
|
||||
useAliasInOutputTableEP.setReadOnly(false);
|
||||
if (getGenerationManager() instanceof OracleGenerationManager) {
|
||||
boolean disableAlias = Boolean
|
||||
.valueOf(System.getProperty("elt.oracle.disableColumnAlias", Boolean.FALSE.toString())); //$NON-NLS-1$
|
||||
if (!disableAlias) {
|
||||
getGenerationManager().setUseAliasInOutputTable(true);
|
||||
}
|
||||
}
|
||||
List<IElementParameter> elemParams = (List<IElementParameter>) origNode.getElementParameters();
|
||||
elemParams.add(useAliasInOutputTableEP);
|
||||
}
|
||||
useAliasInOutputTableEP.setValue(getGenerationManager().isUseAliasInOutputTable());
|
||||
}
|
||||
mapperMain.loadModelFromInternalData();
|
||||
metadataListOut = mapperMain.getMetadataListOut();
|
||||
@@ -465,7 +489,9 @@ public class DbMapComponent extends AbstractMapComponent {
|
||||
}
|
||||
if (externalData != null) {
|
||||
// rename metadata column name
|
||||
List<ExternalDbMapTable> tables = new ArrayList<ExternalDbMapTable>(externalData.getInputTables());
|
||||
List<ExternalDbMapTable> tables = new ArrayList<ExternalDbMapTable>();
|
||||
List<ExternalDbMapTable> inputTables = new ArrayList<ExternalDbMapTable>(externalData.getInputTables());
|
||||
tables.addAll(inputTables);
|
||||
tables.addAll(externalData.getOutputTables());
|
||||
ExternalDbMapTable tableFound = null;
|
||||
for (ExternalDbMapTable table : tables) {
|
||||
@@ -482,11 +508,23 @@ public class DbMapComponent extends AbstractMapComponent {
|
||||
}
|
||||
}
|
||||
|
||||
List<String> alias = new ArrayList<String>();
|
||||
alias.add(conectionName);
|
||||
for(ExternalDbMapTable table : inputTables) {
|
||||
if (table.getTableName().equals(conectionName)) {
|
||||
if(table.getAlias() != null) {
|
||||
alias.add(table.getAlias());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// it is necessary to update expressions only if renamed column come from input table
|
||||
if (tableFound != null && externalData.getInputTables().indexOf(tableFound) != -1) {
|
||||
TableEntryLocation oldLocation = new TableEntryLocation(conectionName, oldColumnName);
|
||||
TableEntryLocation newLocation = new TableEntryLocation(conectionName, newColumnName);
|
||||
replaceLocationsInAllExpressions(oldLocation, newLocation, false);
|
||||
for(String connName : alias) {
|
||||
if (tableFound != null && externalData.getInputTables().indexOf(tableFound) != -1) {
|
||||
TableEntryLocation oldLocation = new TableEntryLocation(connName, oldColumnName);
|
||||
TableEntryLocation newLocation = new TableEntryLocation(connName, newColumnName);
|
||||
replaceLocationsInAllExpressions(oldLocation, newLocation, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -588,6 +626,8 @@ public class DbMapComponent extends AbstractMapComponent {
|
||||
generationManager = new PostgresGenerationManager();
|
||||
} else if (value.contains("tELTHiveMap")) { //$NON-NLS-1$
|
||||
generationManager = new HiveGenerationManager();
|
||||
} else if (value.contains("tELTMSSqlMap")) {
|
||||
generationManager = new MssqlGenerationManager();
|
||||
} else if (value.startsWith("tELT") && value.endsWith("Map")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
{
|
||||
generationManager = new GenericDbGenerationManager();
|
||||
@@ -595,6 +635,7 @@ public class DbMapComponent extends AbstractMapComponent {
|
||||
throw new IllegalArgumentException(Messages.getString("DbMapComponent.unknowValue") + value); //$NON-NLS-1$
|
||||
}
|
||||
updateUseDelimitedIdentifiersStatus();
|
||||
updateUseAliasInOutputTableStatus();
|
||||
}
|
||||
|
||||
return generationManager;
|
||||
@@ -604,6 +645,7 @@ public class DbMapComponent extends AbstractMapComponent {
|
||||
public void setOriginalNode(INode originalNode) {
|
||||
super.setOriginalNode(originalNode);
|
||||
updateUseDelimitedIdentifiersStatus();
|
||||
updateUseAliasInOutputTableStatus();
|
||||
}
|
||||
|
||||
private void updateUseDelimitedIdentifiersStatus() {
|
||||
@@ -625,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)
|
||||
*
|
||||
|
||||
@@ -12,7 +12,11 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.dbmap.language.generation;
|
||||
|
||||
import static java.util.Optional.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -79,6 +83,8 @@ public abstract class DbGenerationManager {
|
||||
|
||||
protected String tabSpaceString = DEFAULT_TAB_SPACE_STRING;
|
||||
|
||||
private final String DOT_STR = "."; //$NON-NLS-1$
|
||||
|
||||
protected static final String DEFAULT_TAB_SPACE_STRING = ""; //$NON-NLS-1$
|
||||
|
||||
protected List<String> queryColumnsSegments = new ArrayList<String>();
|
||||
@@ -89,10 +95,14 @@ public abstract class DbGenerationManager {
|
||||
|
||||
private Boolean useDelimitedIdentifiers;
|
||||
|
||||
private Boolean useAliasInOutputTable;
|
||||
|
||||
protected Set<String> subQueryTable = new HashSet<String>();
|
||||
|
||||
protected INode source;
|
||||
|
||||
protected Set<String> inputSchemaContextSet = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* DOC amaumont GenerationManager constructor comment.
|
||||
*
|
||||
@@ -268,6 +278,9 @@ public abstract class DbGenerationManager {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
protected String addQuotes(String name) {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* ggu Comment method "buildSqlSelect".
|
||||
@@ -283,6 +296,7 @@ public abstract class DbGenerationManager {
|
||||
queryColumnsSegments.clear();
|
||||
querySegments.clear();
|
||||
subQueryTable.clear();
|
||||
inputSchemaContextSet.clear();
|
||||
|
||||
this.tabSpaceString = tabString;
|
||||
DbMapComponent component = getDbMapComponent(dbMapComponent);
|
||||
@@ -295,7 +309,9 @@ public abstract class DbGenerationManager {
|
||||
}
|
||||
|
||||
ExternalDbMapData data = component.getExternalData();
|
||||
|
||||
List<ExternalDbMapTable> inputTables = data.getInputTables();
|
||||
List<String> contextList = getContextList(component);
|
||||
collectSchemaContextParam(dbMapComponent, inputTables, contextList);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<ExternalDbMapTable> outputTables = data.getOutputTables();
|
||||
@@ -368,8 +384,6 @@ public abstract class DbGenerationManager {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.FROM);
|
||||
List<ExternalDbMapTable> inputTables = data.getInputTables();
|
||||
|
||||
// load input table in hash
|
||||
boolean explicitJoin = false;
|
||||
int lstSizeInputTables = inputTables.size();
|
||||
@@ -558,6 +572,40 @@ public abstract class DbGenerationManager {
|
||||
return sqlQuery;
|
||||
}
|
||||
|
||||
protected void collectSchemaContextParam(DbMapComponent dbMapComponent, List<ExternalDbMapTable> inputTables,
|
||||
List<String> contextList) {
|
||||
List<IConnection> incomingConnections = (List<IConnection>) dbMapComponent.getIncomingConnections();
|
||||
if (incomingConnections != null) {
|
||||
for (IConnection connection : incomingConnections) {
|
||||
INode input = connection.getSource();
|
||||
if (input != null) {
|
||||
IElementParameter eltSchemaNameParam = input.getElementParameter("ELT_SCHEMA_NAME"); //$NON-NLS-1$
|
||||
if (eltSchemaNameParam != null && eltSchemaNameParam.getValue() != null) {
|
||||
String schema = String.valueOf(eltSchemaNameParam.getValue());
|
||||
if (schema != null && !inputSchemaContextSet.contains(schema) && contextList.contains(schema)) {
|
||||
inputSchemaContextSet.add(schema);
|
||||
}
|
||||
}
|
||||
IElementParameter eltTableNameParam = input.getElementParameter("ELT_TABLE_NAME"); //$NON-NLS-1$
|
||||
if (eltTableNameParam != null && eltTableNameParam.getValue() != null) {
|
||||
String table = String.valueOf(eltTableNameParam.getValue());
|
||||
if (table != null && !inputSchemaContextSet.contains(table) && contextList.contains(table)) {
|
||||
inputSchemaContextSet.add(table);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inputTables != null) {
|
||||
for (ExternalDbMapTable table : inputTables) {
|
||||
if (table.getAlias() != null && !inputSchemaContextSet.contains(table.getAlias())
|
||||
&& contextList.contains(table.getAlias())) {
|
||||
inputSchemaContextSet.add(table.getAlias());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String buildSqlSelect(DbMapComponent dbMapComponent, String outputTableName, String tabString,
|
||||
boolean checkUseUpdateStatement) {
|
||||
queryColumnsName = "\""; //$NON-NLS-1$
|
||||
@@ -565,6 +613,7 @@ public abstract class DbGenerationManager {
|
||||
queryColumnsSegments.clear();
|
||||
querySegments.clear();
|
||||
subQueryTable.clear();
|
||||
inputSchemaContextSet.clear();
|
||||
|
||||
this.tabSpaceString = tabString;
|
||||
DbMapComponent component = getDbMapComponent(dbMapComponent);
|
||||
@@ -601,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -627,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);
|
||||
@@ -674,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
|
||||
@@ -699,35 +744,17 @@ public abstract class DbGenerationManager {
|
||||
|
||||
for (int i = 0; i < lstSizeInputTables; i++) {
|
||||
ExternalDbMapTable inputTable = inputTables.get(i);
|
||||
IJoinType joinType = null;
|
||||
if (i == 0) {
|
||||
joinType = AbstractDbLanguage.JOIN.NO_JOIN;
|
||||
} else {
|
||||
joinType = language.getJoin(inputTable.getJoinType());
|
||||
}
|
||||
if (language.unuseWithExplicitJoin().contains(joinType) && !explicitJoin) {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, inputTable.getTableName());
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, inputTable.getAlias());
|
||||
}
|
||||
boolean commaCouldBeAdded = i > 0;
|
||||
buildTableDeclaration(component, sb, inputTable, commaCouldBeAdded, false, false);
|
||||
}
|
||||
|
||||
// On
|
||||
if (org.apache.commons.lang.StringUtils.isNotEmpty(keyColumn)) {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.ON);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, keyColumn);
|
||||
}
|
||||
// where
|
||||
StringBuilder sbWhere = new StringBuilder();
|
||||
this.tabSpaceString = DEFAULT_TAB_SPACE_STRING;
|
||||
boolean isFirstClause = true;
|
||||
for (int i = 0; i < lstSizeInputTables; i++) {
|
||||
ExternalDbMapTable inputTable = inputTables.get(i);
|
||||
if (buildConditions(component, sbWhere, inputTable, false, isFirstClause, false)) {
|
||||
if (buildConditions4WhereClause(isFirstClause, component, sbWhere, inputTable, false)) {
|
||||
isFirstClause = false;
|
||||
}
|
||||
}
|
||||
@@ -836,7 +863,7 @@ public abstract class DbGenerationManager {
|
||||
}
|
||||
|
||||
protected void checkParameters(DbMapComponent component) {
|
||||
checkUseDelimitedIdentifiers(component);
|
||||
checkSpecialParameters(component);
|
||||
}
|
||||
|
||||
protected boolean checkUseUpdateStatement(DbMapComponent dbMapComponent, String outputTableName) {
|
||||
@@ -855,7 +882,68 @@ public abstract class DbGenerationManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void checkUseDelimitedIdentifiers(DbMapComponent component) {
|
||||
protected String getDifferentTable(DbMapComponent dbMapComponent, String outputTableName) {
|
||||
if (!"Snowflake".equalsIgnoreCase(getDbType(dbMapComponent))) {//$NON-NLS-1$
|
||||
return null;
|
||||
}
|
||||
List<IConnection> outputConnections = (List<IConnection>) dbMapComponent.getOutgoingConnections();
|
||||
if (outputConnections != null) {
|
||||
IConnection iconn = this.getConnectonByMetadataName(outputConnections, outputTableName);
|
||||
if (iconn != null && iconn.getTarget() != null) {
|
||||
source = iconn.getTarget();
|
||||
IElementParameter useDifferentTable = source.getElementParameter("USE_DIFFERENT_TABLE"); //$NON-NLS-1$
|
||||
if (useDifferentTable != null && useDifferentTable.isShow(source.getElementParameters())
|
||||
&& useDifferentTable.getValue() != null) {
|
||||
if (Boolean.valueOf(useDifferentTable.getValue().toString())) {
|
||||
IElementParameter differentTable = source.getElementParameter("DIFFERENT_TABLE_NAME"); //$NON-NLS-1$
|
||||
if (differentTable != null && differentTable.getValue() != null) {
|
||||
String table = TalendTextUtils.removeQuotes(String.valueOf(differentTable.getValue()));
|
||||
if (org.apache.commons.lang.StringUtils.isNotBlank(table)) {
|
||||
return table;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getDbType(DbMapComponent component) {
|
||||
IElementParameter mappingPara = component.getElementParameter(EParameterName.MAPPING.getName());
|
||||
if (mappingPara == null) {
|
||||
return null;
|
||||
}
|
||||
String mapping = (String) mappingPara.getValue();
|
||||
if (mapping == null) {
|
||||
return null;
|
||||
}
|
||||
MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(mapping);
|
||||
if (mappingTypeRetriever == null) {
|
||||
return null;
|
||||
}
|
||||
Dbms dbms = mappingTypeRetriever.getDbms();
|
||||
if (dbms == null) {
|
||||
return null;
|
||||
}
|
||||
return dbms.getProduct();
|
||||
}
|
||||
|
||||
/**
|
||||
* This piece regulates which columns are going to be skipped in UPDATE QUERY generation in SET section if
|
||||
* <b>SET_COLUMN</b> property exists. This enhancement is needed for tELTOutput component in case of
|
||||
* <b>USE_UPDATE_STATEMENT</b>
|
||||
*
|
||||
* @return List of columns that going to be skipped, if no <b>SET_COLUMN</b> specified then return empty list.
|
||||
*/
|
||||
protected List<Boolean> getSetColumnsForUpdateQuery() {
|
||||
return ofNullable(source.getElementParameter("SET_COLUMN")).filter(iep -> iep.isShow(source.getElementParameters()))
|
||||
.flatMap(iep -> ofNullable((List<Map<String, ? extends Object>>) iep.getValue()))
|
||||
.orElseGet(Collections::emptyList).stream().map(m -> !Boolean.valueOf(m.get("UPDATE_COLUMN").toString()))
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
protected void checkSpecialParameters(DbMapComponent component) {
|
||||
/**
|
||||
* in elt related component javajets(like tELTMSSqlMap_main.javajet), they don't get DbGenerationManager by
|
||||
* DbMapComponent#getGenerationManager() while they construct a new manager manually, so some parameters may not
|
||||
@@ -872,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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -885,30 +985,35 @@ public abstract class DbGenerationManager {
|
||||
if (expression == null) {
|
||||
return null;
|
||||
}
|
||||
if (DEFAULT_TAB_SPACE_STRING.equals(tabSpaceString)) {
|
||||
List<String> contextList = getContextList(component);
|
||||
boolean haveReplace = false;
|
||||
for (String context : contextList) {
|
||||
List<String> contextList = getContextList(component);
|
||||
boolean haveReplace = false;
|
||||
for (String context : contextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\" +" + context + "+ \""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
haveReplace = true;
|
||||
}
|
||||
}
|
||||
if (!haveReplace) {
|
||||
List<String> connContextList = getConnectionContextList(component);
|
||||
for (String context : connContextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\" +" + context + "+ \""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
haveReplace = true;
|
||||
}
|
||||
}
|
||||
if (!haveReplace) {
|
||||
List<String> connContextList = getConnectionContextList(component);
|
||||
for (String context : connContextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\" +" + context + "+ \""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<String> globalMapList = getGlobalMapList(component, 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$
|
||||
}
|
||||
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$
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
@@ -935,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);
|
||||
}
|
||||
@@ -964,7 +1073,11 @@ public abstract class DbGenerationManager {
|
||||
query = query + " \""; //$NON-NLS-1$
|
||||
} else {
|
||||
if (query.trim().endsWith("+ \"")) { //$NON-NLS-1$
|
||||
query = query.substring(0, query.lastIndexOf("+ \"")); //$NON-NLS-1$
|
||||
if (DEFAULT_TAB_SPACE_STRING.equals(this.tabSpaceString)) {
|
||||
query = query.substring(0, query.lastIndexOf("+ \"")); //$NON-NLS-1$
|
||||
} else {
|
||||
query = query + "\""; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -999,7 +1112,7 @@ public abstract class DbGenerationManager {
|
||||
|
||||
return contextList;
|
||||
}
|
||||
|
||||
|
||||
protected Set<String> getGlobalMapList(DbMapComponent component, String sqlQuery) {
|
||||
return parser.getGlobalMapSet(sqlQuery);
|
||||
}
|
||||
@@ -1014,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1046,6 +1159,35 @@ public abstract class DbGenerationManager {
|
||||
return atLeastOneConditionWritten;
|
||||
}
|
||||
|
||||
/**
|
||||
* build conditions for update case only DOC hzhao Comment method "buildConditions".
|
||||
*
|
||||
* @param isFirstClause
|
||||
* @param component
|
||||
* @param sb
|
||||
* @param inputTable
|
||||
* @param isSqlQuert
|
||||
* @return
|
||||
*/
|
||||
protected boolean buildConditions4WhereClause(boolean isFirstClause, DbMapComponent component, StringBuilder sb,
|
||||
ExternalDbMapTable inputTable,
|
||||
boolean isSqlQuert) {
|
||||
List<ExternalDbMapEntry> inputEntries = inputTable.getMetadataTableEntries();
|
||||
int lstSizeEntries = inputEntries.size();
|
||||
boolean atLeastOneConditionWritten = false;
|
||||
for (int j = 0; j < lstSizeEntries; j++) {
|
||||
ExternalDbMapEntry dbMapEntry = inputEntries.get(j);
|
||||
boolean conditionWritten = buildCondition(component, sb, inputTable, isFirstClause, dbMapEntry, true, isSqlQuert);
|
||||
if (conditionWritten) {
|
||||
atLeastOneConditionWritten = true;
|
||||
}
|
||||
if (isFirstClause && conditionWritten) {
|
||||
isFirstClause = false;
|
||||
}
|
||||
}
|
||||
return atLeastOneConditionWritten;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC amaumont Comment method "buildCondition".
|
||||
*
|
||||
@@ -1071,8 +1213,7 @@ public abstract class DbGenerationManager {
|
||||
*/
|
||||
private boolean buildCondition(DbMapComponent component, StringBuilder sbWhere, ExternalDbMapTable table,
|
||||
boolean isFirstClause, ExternalDbMapEntry dbMapEntry, boolean writeCr, boolean isSqlQuery) {
|
||||
String expression = dbMapEntry.getExpression();
|
||||
expression = initExpression(component, dbMapEntry);
|
||||
String expression = initExpression(component, dbMapEntry);
|
||||
IDbOperator dbOperator = getOperatorsManager().getOperatorFromValue(dbMapEntry.getOperator());
|
||||
boolean operatorIsSet = dbOperator != null;
|
||||
boolean expressionIsSet = expression != null && expression.trim().length() > 0;
|
||||
@@ -1324,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;
|
||||
@@ -1434,8 +1575,8 @@ public abstract class DbGenerationManager {
|
||||
oriName = oriName.replaceAll("\\$", "\\\\\\$"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
expression = expression.replaceFirst(tableValue + "\\." + co.getLabel(), //$NON-NLS-1$
|
||||
tableValue + "\\." + oriName); //$NON-NLS-1$
|
||||
expression = replaceAuotes(expression, quto_markParser, quto_mark);
|
||||
tableValue + "\\." + oriName); //$NON-NLS-1$
|
||||
expression = replaceAuotes(component, expression, quto_markParser, quto_mark);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1450,11 +1591,14 @@ public abstract class DbGenerationManager {
|
||||
return expression;
|
||||
}
|
||||
|
||||
protected String replaceAuotes(String expression, String quoParser, String quote){
|
||||
if(!expression.contains("'")){
|
||||
return expression.replaceAll(quoParser,"\\\\" +quote); //$NON-NLS-1$
|
||||
protected String replaceAuotes(DbMapComponent component, String expression, String quoParser, String quote) {
|
||||
if (isComplexExpression(component, expression)) {
|
||||
return expression;
|
||||
}
|
||||
|
||||
if(!expression.contains("'")){
|
||||
return expression.replaceAll(quoParser,"\\\\" +quote); //$NON-NLS-1$;
|
||||
}
|
||||
|
||||
List<Integer> indexs = new ArrayList<>();
|
||||
for(int i=0;i<expression.length();i++){
|
||||
if("'".equals(String.valueOf(expression.charAt(i)))){
|
||||
@@ -1486,25 +1630,32 @@ public abstract class DbGenerationManager {
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
protected boolean isComplexExpression(DbMapComponent component, String expression) {
|
||||
if (parser.isContainsGlobalMapExpression(expression)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -1661,4 +1812,337 @@ public abstract class DbGenerationManager {
|
||||
this.useDelimitedIdentifiers = useDelimitedIdentifiers;
|
||||
}
|
||||
|
||||
public boolean isUseAliasInOutputTable() {
|
||||
return Boolean.TRUE.equals(this.useAliasInOutputTable);
|
||||
}
|
||||
|
||||
public void setUseAliasInOutputTable(boolean useAliasInOutputTable) {
|
||||
this.useAliasInOutputTable = useAliasInOutputTable;
|
||||
}
|
||||
|
||||
public boolean isConditionChecked(DbMapComponent component, ExternalDbMapTable inputTable) {
|
||||
List<ExternalDbMapEntry> inputEntries = inputTable.getMetadataTableEntries();
|
||||
boolean atLeastOneConditionIsChecked = false;
|
||||
for (ExternalDbMapEntry dbMapEntry : inputEntries) {
|
||||
if (dbMapEntry.isJoin()) {
|
||||
if (org.apache.commons.lang.StringUtils.isNotEmpty(dbMapEntry.getExpression())
|
||||
&& org.apache.commons.lang.StringUtils.isNotEmpty(dbMapEntry.getOperator())) {
|
||||
atLeastOneConditionIsChecked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return atLeastOneConditionIsChecked;
|
||||
}
|
||||
|
||||
public String buildSqlUpdate(DbMapComponent dbMapComponent, String outputTableName, String tabString) {
|
||||
queryColumnsName = "\""; //$NON-NLS-1$
|
||||
aliasAlreadyDeclared.clear();
|
||||
queryColumnsSegments.clear();
|
||||
querySegments.clear();
|
||||
subQueryTable.clear();
|
||||
inputSchemaContextSet.clear();
|
||||
|
||||
this.tabSpaceString = tabString;
|
||||
DbMapComponent component = getDbMapComponent(dbMapComponent);
|
||||
|
||||
List<IConnection> outputConnections = (List<IConnection>) component.getOutgoingConnections();
|
||||
|
||||
Map<String, IConnection> nameToOutputConnection = new HashMap<String, IConnection>();
|
||||
for (IConnection connection : outputConnections) {
|
||||
nameToOutputConnection.put(connection.getUniqueName(), connection);
|
||||
}
|
||||
|
||||
ExternalDbMapData data = component.getExternalData();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
List<ExternalDbMapTable> outputTables = data.getOutputTables();
|
||||
int lstOutputTablesSize = outputTables.size();
|
||||
ExternalDbMapTable outputTable = null;
|
||||
for (int i = 0; i < lstOutputTablesSize; i++) {
|
||||
ExternalDbMapTable temp = outputTables.get(i);
|
||||
if (outputTableName.equals(temp.getName())) {
|
||||
outputTable = temp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (outputTable != null) {
|
||||
String outTableName = outputTable.getTableName();
|
||||
IConnection connection = nameToOutputConnection.get(outputTable.getName());
|
||||
List<IMetadataColumn> columns = new ArrayList<IMetadataColumn>();
|
||||
if (connection != null) {
|
||||
IMetadataTable metadataTable = connection.getMetadataTable();
|
||||
if (metadataTable != null) {
|
||||
columns.addAll(metadataTable.getListColumns());
|
||||
}
|
||||
}
|
||||
// Update
|
||||
String targetSchemaTable = outTableName;
|
||||
IElementParameter eltSchemaNameParam = source.getElementParameter("ELT_SCHEMA_NAME"); //$NON-NLS-1$
|
||||
if (eltSchemaNameParam != null && eltSchemaNameParam.getValue() != null) {
|
||||
String schema = TalendQuoteUtils.removeQuotesIfExist(String.valueOf(eltSchemaNameParam.getValue()));
|
||||
if (org.apache.commons.lang.StringUtils.isNotEmpty(schema)) {
|
||||
targetSchemaTable = addQuotes(schema) + DbMapSqlConstants.DOT + addQuotes(outTableName);
|
||||
}
|
||||
}
|
||||
|
||||
appendSqlQuery(sb, "\"", false); //$NON-NLS-1$
|
||||
appendSqlQuery(sb, DbMapSqlConstants.UPDATE);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, targetSchemaTable);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
|
||||
// Set
|
||||
String keyColumn = DbMapSqlConstants.EMPTY;
|
||||
List<ExternalDbMapEntry> metadataTableEntries = outputTable.getMetadataTableEntries();
|
||||
if (metadataTableEntries != null) {
|
||||
appendSqlQuery(sb, "SET"); //$NON-NLS-1$
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
boolean isKey = false;
|
||||
int lstSizeOutTableEntries = metadataTableEntries.size();
|
||||
List<Boolean> setColumns = getSetColumnsForUpdateQuery();
|
||||
final boolean hasDeactivatedColumns = !setColumns.isEmpty();
|
||||
boolean isFirstColumn = true;
|
||||
for (int i = 0; i < lstSizeOutTableEntries; i++) {
|
||||
if (hasDeactivatedColumns && setColumns.get(i)) {
|
||||
continue;
|
||||
}
|
||||
ExternalDbMapEntry dbMapEntry = metadataTableEntries.get(i);
|
||||
String columnEntry = dbMapEntry.getName();
|
||||
String expression = dbMapEntry.getExpression();
|
||||
expression = initExpression(component, dbMapEntry);
|
||||
expression = addQuoteForSpecialChar(expression, component);
|
||||
//
|
||||
if (!DEFAULT_TAB_SPACE_STRING.equals(this.tabSpaceString)) {
|
||||
expression += DbMapSqlConstants.SPACE + DbMapSqlConstants.AS + DbMapSqlConstants.SPACE
|
||||
+ getAliasOf(dbMapEntry.getName());
|
||||
}
|
||||
String exp = replaceVariablesForExpression(component, expression);
|
||||
String columnSegment = exp;
|
||||
// Added isFirstColumn to conform old behaior if first column is skipped
|
||||
if (i > 0 && !isFirstColumn) {
|
||||
queryColumnsName += DbMapSqlConstants.COMMA + DbMapSqlConstants.SPACE;
|
||||
columnSegment = DbMapSqlConstants.COMMA + DbMapSqlConstants.SPACE + columnSegment;
|
||||
}
|
||||
if (expression != null && expression.trim().length() > 0) {
|
||||
queryColumnsName += exp;
|
||||
queryColumnsSegments.add(columnSegment);
|
||||
}
|
||||
//
|
||||
if (!isKey) {
|
||||
for (IMetadataColumn column : columns) {
|
||||
String columnName = column.getLabel();
|
||||
if (columnName.equals(dbMapEntry.getName()) && column.isKey()) {
|
||||
isKey = column.isKey();
|
||||
keyColumn = addQuotes(columnEntry) + " = " + expression;//$NON-NLS-1$
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isKey) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (expression != null && expression.trim().length() > 0) {
|
||||
// Append COMMA and NEW_LINE for all columns except FIRST.
|
||||
if (!isFirstColumn) {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.COMMA);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
} else {
|
||||
isFirstColumn = false;
|
||||
}
|
||||
appendSqlQuery(sb, addQuotes(columnEntry) + " = " + expression); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
if ("\"".equals(queryColumnsName)) {
|
||||
throw new IllegalArgumentException("Specify at least 1 column for UPDATE QUERY in SET section");
|
||||
}
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
|
||||
// From
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.FROM);
|
||||
// load input table in hash
|
||||
List<ExternalDbMapTable> inputTables = data.getInputTables();
|
||||
// load input table in hash
|
||||
boolean explicitJoin = false;
|
||||
int lstSizeInputTables = inputTables.size();
|
||||
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
IJoinType previousJoinType = null;
|
||||
|
||||
for (int i = 0; i < lstSizeInputTables; i++) {
|
||||
ExternalDbMapTable inputTable = inputTables.get(i);
|
||||
IJoinType joinType = language.getJoin(inputTable.getJoinType());
|
||||
if (!language.unuseWithExplicitJoin().contains(joinType) && i > 0) {
|
||||
explicitJoin = true;
|
||||
} else {
|
||||
explicitJoin = false;
|
||||
}
|
||||
if (i == 0) {
|
||||
joinType = AbstractDbLanguage.JOIN.NO_JOIN;
|
||||
previousJoinType = joinType;
|
||||
} else {
|
||||
joinType = language.getJoin(inputTable.getJoinType());
|
||||
}
|
||||
boolean commaCouldBeAdded = !explicitJoin && i > 0;
|
||||
boolean crCouldBeAdded = false;
|
||||
if (language.unuseWithExplicitJoin().contains(joinType) && !explicitJoin) {
|
||||
buildTableDeclaration(component, sb, inputTable, commaCouldBeAdded, crCouldBeAdded, false);
|
||||
|
||||
} else if (!language.unuseWithExplicitJoin().contains(joinType) && explicitJoin) {
|
||||
if (i > 0) {
|
||||
if (previousJoinType == null) {
|
||||
buildTableDeclaration(component, sb, inputTables.get(i - 1), commaCouldBeAdded, crCouldBeAdded, true);
|
||||
previousJoinType = joinType;
|
||||
} else {
|
||||
// appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
}
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
}
|
||||
String labelJoinType = joinType.getLabel();
|
||||
if (joinType == AbstractDbLanguage.JOIN.CROSS_JOIN) {
|
||||
ExternalDbMapTable nextTable = null;
|
||||
if (i < lstSizeInputTables) {
|
||||
nextTable = inputTables.get(i);
|
||||
appendSqlQuery(sb, labelJoinType);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
buildTableDeclaration(component, sb, nextTable, false, true, true);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (isConditionChecked(component, inputTable)) {
|
||||
appendSqlQuery(sb, labelJoinType);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
buildTableDeclaration(component, sb, inputTable, false, false, true);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.ON);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.LEFT_BRACKET);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
buildConditions(component, sb, inputTable, true, true, true);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.RIGHT_BRACKET);
|
||||
} else {
|
||||
commaCouldBeAdded = true;
|
||||
buildTableDeclaration(component, sb, inputTable, commaCouldBeAdded, crCouldBeAdded, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// where
|
||||
StringBuilder sbWhere = new StringBuilder();
|
||||
this.tabSpaceString = DEFAULT_TAB_SPACE_STRING;
|
||||
boolean isFirstClause = true;
|
||||
for (int i = 0; i < lstSizeInputTables; i++) {
|
||||
ExternalDbMapTable inputTable = inputTables.get(i);
|
||||
IJoinType joinType = language.getJoin(inputTable.getJoinType());
|
||||
if (joinType == AbstractDbLanguage.JOIN.CROSS_JOIN) {
|
||||
// if join type is CROSS JOIN the condition will only in where clause no matter explicit join
|
||||
// checked or not
|
||||
if (buildConditions4WhereClause(isFirstClause, component, sbWhere, inputTable, false)) {
|
||||
isFirstClause = false;
|
||||
}
|
||||
} else {
|
||||
if (buildConditions(component, sbWhere, inputTable, false, isFirstClause, false)) {
|
||||
isFirstClause = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* for addition conditions
|
||||
*/
|
||||
// like as input.newcolumn1>100
|
||||
List<String> whereAddition = new ArrayList<String>();
|
||||
// olny pure start with group or order, like as order/group by input.newcolumn1
|
||||
// List<String> byAddition = new ArrayList<String>();
|
||||
// like as input.newcolumn1>100 group/oder by input.newcolumn1
|
||||
// List<String> containWhereAddition = new ArrayList<String>();
|
||||
// like as "OR/AND input.newcolumn1", will keep original
|
||||
List<String> originalWhereAddition = new ArrayList<String>();
|
||||
List<String> otherAddition = new ArrayList<String>();
|
||||
|
||||
if (outputTable != null) {
|
||||
List<ExternalDbMapEntry> customWhereConditionsEntries = outputTable.getCustomWhereConditionsEntries();
|
||||
if (customWhereConditionsEntries != null) {
|
||||
for (ExternalDbMapEntry entry : customWhereConditionsEntries) {
|
||||
String exp = initExpression(component, entry);
|
||||
if (exp != null && !DbMapSqlConstants.EMPTY.equals(exp.trim())) {
|
||||
if (containWith(exp, DbMapSqlConstants.OR, true) || containWith(exp, DbMapSqlConstants.AND, true)) {
|
||||
exp = replaceVariablesForExpression(component, exp);
|
||||
originalWhereAddition.add(exp);
|
||||
} else {
|
||||
exp = replaceVariablesForExpression(component, exp);
|
||||
whereAddition.add(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<ExternalDbMapEntry> customOtherConditionsEntries = outputTable.getCustomOtherConditionsEntries();
|
||||
if (customOtherConditionsEntries != null) {
|
||||
for (ExternalDbMapEntry entry : customOtherConditionsEntries) {
|
||||
String exp = initExpression(component, entry);
|
||||
if (exp != null && !DbMapSqlConstants.EMPTY.equals(exp.trim())) {
|
||||
exp = replaceVariablesForExpression(component, exp);
|
||||
otherAddition.add(exp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.tabSpaceString = tabString;
|
||||
|
||||
String whereClauses = sbWhere.toString();
|
||||
boolean whereFlag = whereClauses.trim().length() > 0;
|
||||
boolean whereAddFlag = !whereAddition.isEmpty();
|
||||
boolean whereOriginalFlag = !originalWhereAddition.isEmpty();
|
||||
if (whereFlag || whereAddFlag || whereOriginalFlag) {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.WHERE);
|
||||
}
|
||||
if (whereFlag) {
|
||||
appendSqlQuery(sb, whereClauses);
|
||||
}
|
||||
if (whereAddFlag) {
|
||||
for (int i = 0; i < whereAddition.size(); i++) {
|
||||
if (i == 0 && whereFlag || i > 0) {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.AND);
|
||||
}
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, whereAddition.get(i));
|
||||
}
|
||||
}
|
||||
if (whereOriginalFlag) {
|
||||
for (String s : originalWhereAddition) {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.SPACE);
|
||||
appendSqlQuery(sb, s);
|
||||
}
|
||||
}
|
||||
if (!otherAddition.isEmpty()) {
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
for (String s : otherAddition) {
|
||||
appendSqlQuery(sb, s);
|
||||
appendSqlQuery(sb, DbMapSqlConstants.NEW_LINE);
|
||||
appendSqlQuery(sb, tabSpaceString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String sqlQuery = sb.toString();
|
||||
sqlQuery = handleQuery(sqlQuery);
|
||||
queryColumnsName = handleQuery(queryColumnsName);
|
||||
return sqlQuery;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,12 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.dbmap.language.generation;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.designer.dbmap.DbMapComponent;
|
||||
import org.talend.designer.dbmap.language.GenericDbLanguage;
|
||||
import org.talend.designer.dbmap.language.mssql.MssqlGenerationManager;
|
||||
|
||||
/**
|
||||
* wzhang class global comment. Detailled comment
|
||||
@@ -26,6 +30,17 @@ public class GenericDbGenerationManager extends DbGenerationManager {
|
||||
|
||||
@Override
|
||||
public String buildSqlSelect(DbMapComponent component, String outputTableName) {
|
||||
try {
|
||||
if (Optional.ofNullable(component).map(c -> c.getComponent()).map(c -> "tELTMSSqlMap".equals(c.getName()))
|
||||
.orElse(false)) {
|
||||
MssqlGenerationManager genManager = new MssqlGenerationManager();
|
||||
String result = genManager.buildSqlSelect(component, outputTableName);
|
||||
this.queryColumnsName = genManager.getQueryColumnsName();
|
||||
return result;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return super.buildSqlSelect(component, outputTableName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.dbmap.language.mssql;
|
||||
|
||||
import org.talend.designer.dbmap.DbMapComponent;
|
||||
import org.talend.designer.dbmap.language.GenericDbLanguage;
|
||||
import org.talend.designer.dbmap.language.generation.DbGenerationManager;
|
||||
|
||||
public class MssqlGenerationManager extends DbGenerationManager {
|
||||
|
||||
public MssqlGenerationManager() {
|
||||
super(new GenericDbLanguage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String buildSqlSelect(DbMapComponent component, String outputTableName) {
|
||||
boolean checkUseUpdateStatement = checkUseUpdateStatement(component, outputTableName);
|
||||
if (checkUseUpdateStatement) {
|
||||
return buildSqlUpdate(component, outputTableName, DEFAULT_TAB_SPACE_STRING);
|
||||
} else {
|
||||
return super.buildSqlSelect(component, outputTableName, DEFAULT_TAB_SPACE_STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,8 +236,8 @@ public class PostgresGenerationManager extends DbGenerationManager {
|
||||
}
|
||||
tableAndSchema = tableAndSchema + getHandledField(tableNoQuote);
|
||||
|
||||
if (isVariable(schemaNoQuote) || isVariable(tableNoQuote)) {
|
||||
tableAndSchema = replaceVariablesForExpression(component, tableAndSchema);
|
||||
if (isVariable(schemaNoQuote) || isVariable(tableNoQuote)) {
|
||||
tableAndSchema = replaceVariablesForExpression(component, tableAndSchema);
|
||||
}
|
||||
sb.append(tableAndSchema);
|
||||
} else {
|
||||
@@ -290,32 +290,39 @@ public class PostgresGenerationManager extends DbGenerationManager {
|
||||
if (expression == null) {
|
||||
return null;
|
||||
}
|
||||
if (DEFAULT_TAB_SPACE_STRING.equals(tabSpaceString)) {
|
||||
List<String> contextList = getContextList(component);
|
||||
boolean haveReplace = false;
|
||||
for (String context : contextList) {
|
||||
List<String> contextList = getContextList(component);
|
||||
boolean haveReplace = false;
|
||||
for (String context : contextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = replaceContextValue(expression, context);
|
||||
haveReplace = true;
|
||||
}
|
||||
}
|
||||
if (!haveReplace) {
|
||||
List<String> connContextList = getConnectionContextList(component);
|
||||
for (String context : connContextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\\\\\"\"+" + context + "+\"\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
haveReplace = true;
|
||||
expression = replaceContextValue(expression, context);
|
||||
}
|
||||
}
|
||||
if (!haveReplace) {
|
||||
List<String> connContextList = getConnectionContextList(component);
|
||||
for (String context : connContextList) {
|
||||
if (expression.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\\\\\"\"+" + context + "+\"\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<String> globalMapList = getGlobalMapList(component, expression);
|
||||
for (String globalMapStr : globalMapList) {
|
||||
String replacement = globalMapStr;
|
||||
if (globalMapStr.contains("\\\\")) {
|
||||
replacement = globalMapStr.replaceAll("\\\\", "\\\\\\\\");
|
||||
}
|
||||
String regex = parser.getGlobalMapExpressionRegex(globalMapStr);
|
||||
expression = expression.replaceAll(regex, "\\\\\"\"+" + replacement + "+\"\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
Set<String> globalMapList = getGlobalMapList(component, expression);
|
||||
for (String globalMapStr : globalMapList) {
|
||||
String replacement = globalMapStr;
|
||||
if (globalMapStr.contains("\\\\")) {
|
||||
replacement = globalMapStr.replaceAll("\\\\", "\\\\\\\\");
|
||||
}
|
||||
String regex = parser.getGlobalMapExpressionRegex(globalMapStr);
|
||||
expression = expression.replaceAll(regex, "\\\\\"\"+" + replacement + "+\"\\\\\""); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
private String replaceContextValue(String expression, String context) {
|
||||
if (inputSchemaContextSet.contains(context)) {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\\\\\"\"+" + context + "+\"\\\\\"");
|
||||
} else {
|
||||
expression = expression.replaceAll("\\b" + context + "\\b", "\" +" + context + "+ \"");
|
||||
}
|
||||
return expression;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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".
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.dbmap.model.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -101,7 +100,6 @@ public class InputTable extends AbstractInOutTable {
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<IMetadataColumn> columnsToRemove = new ArrayList<IMetadataColumn>();
|
||||
for (IMetadataColumn column : columns) {
|
||||
InputColumnTableEntry inputEntry = (InputColumnTableEntry) getNewTableEntry(column);
|
||||
ExternalDbMapEntry externalMapperTableEntry = nameToPerTabEntry.get(inputEntry.getMetadataColumn().getLabel());
|
||||
@@ -110,13 +108,8 @@ public class InputTable extends AbstractInOutTable {
|
||||
fillInputEntry(inputEntry, externalMapperTableEntry);
|
||||
nameToPerTabEntry.remove(externalMapperTableEntry.getName());
|
||||
}
|
||||
if (externalMapperTableEntry != null || !isAliasTable) {
|
||||
dataMapTableEntries.add(inputEntry);
|
||||
} else {
|
||||
columnsToRemove.add(column);
|
||||
}
|
||||
dataMapTableEntries.add(inputEntry);
|
||||
}
|
||||
columns.removeAll(columnsToRemove);
|
||||
|
||||
// create unmatching entries
|
||||
for (ExternalDbMapEntry perTableEntry : nameToPerTabEntry.values()) {
|
||||
|
||||
@@ -45,6 +45,7 @@ import org.talend.commons.ui.runtime.ws.WindowSystem;
|
||||
import org.talend.commons.ui.swt.drawing.background.BackgroundRefresher;
|
||||
import org.talend.commons.ui.swt.linking.BgDrawableComposite;
|
||||
import org.talend.commons.utils.threading.ExecutionLimiter;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
import org.talend.designer.abstractmap.model.table.IDataMapTable;
|
||||
import org.talend.designer.abstractmap.ui.dnd.DraggingInfosPopup;
|
||||
import org.talend.designer.abstractmap.ui.listener.DropTargetOperationListener;
|
||||
@@ -230,6 +231,20 @@ public class MapperUI {
|
||||
dbmsId = input.getMetadataTable().getDbms();
|
||||
}
|
||||
}
|
||||
if(dbmsId == null && mapperModel.getOutputDataMapTables() != null && !mapperModel.getOutputDataMapTables().isEmpty()) {
|
||||
OutputTable output = mapperModel.getOutputDataMapTables().get(0);
|
||||
if (output.getMetadataTable() != null) {
|
||||
dbmsId = output.getMetadataTable().getDbms();
|
||||
}
|
||||
}
|
||||
if(dbmsId == null && mapperManager.getAbstractMapComponent() != null
|
||||
&& !mapperManager.getAbstractMapComponent().getIncomingConnections().isEmpty()){
|
||||
IConnection conn = mapperManager.getAbstractMapComponent().getIncomingConnections().get(0);
|
||||
if(conn.getMetadataTable() != null) {
|
||||
dbmsId = conn.getMetadataTable().getDbms();
|
||||
}
|
||||
}
|
||||
|
||||
tabFolderEditors = new TabFolderEditors(mainSashForm, SWT.BORDER, mapperManager, dbmsId);
|
||||
|
||||
createInputZoneWithTables(mapperModel, uiManager, display);
|
||||
@@ -300,6 +315,10 @@ public class MapperUI {
|
||||
if (outputsTablesView.size() > 0) {
|
||||
uiManager.selectDataMapTableView(outputsTablesView.get(0), true, false);
|
||||
}
|
||||
|
||||
for (DataMapTableView view : outputsTablesView) {
|
||||
view.getTableViewerCreatorForColumns().getTableViewer().refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void resizeNotMinimizedTablesAtExpandedSize(final Display display) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.dbmap.ui.tabs;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.gef.commands.CommandStack;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.swt.SWT;
|
||||
@@ -23,12 +25,19 @@ import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Event;
|
||||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.talend.commons.ui.swt.advanced.dataeditor.control.ExtendedPushButton;
|
||||
import org.talend.commons.ui.swt.colorstyledtext.UnnotifiableColorStyledText;
|
||||
import org.talend.commons.ui.swt.extended.table.ExtendedButtonEvent;
|
||||
import org.talend.commons.ui.swt.extended.table.IExtendedButtonListener;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.ui.metadata.editor.MetadataTableEditorView;
|
||||
import org.talend.core.ui.metadata.editor.MetadataToolbarEditorView;
|
||||
import org.talend.designer.dbmap.MapperMain;
|
||||
import org.talend.designer.dbmap.i18n.Messages;
|
||||
import org.talend.designer.dbmap.managers.MapperManager;
|
||||
import org.talend.designer.dbmap.model.table.InputTable;
|
||||
import org.talend.designer.dbmap.model.table.OutputTable;
|
||||
import org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView;
|
||||
|
||||
/**
|
||||
* DOC amaumont class global comment. Detailled comment <br/>
|
||||
@@ -58,6 +67,10 @@ public class TabFolderEditors extends CTabFolder {
|
||||
|
||||
private String dbmsId;
|
||||
|
||||
private List<ExtendedPushButton> inputToolBarButtons;
|
||||
|
||||
private List<ExtendedPushButton> outputToolBarButtons;
|
||||
|
||||
public TabFolderEditors(Composite parent, int style, MapperManager mapperManager, String dbmsId) {
|
||||
super(parent, style);
|
||||
tabFolderEditors = this;
|
||||
@@ -144,6 +157,8 @@ public class TabFolderEditors extends CTabFolder {
|
||||
inputMetaEditor.initGraphicComponents();
|
||||
inputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
|
||||
|
||||
addListenersToInputButtons();
|
||||
|
||||
outputMetaEditor = new MetadataTableEditorView(inOutMetaEditorContainer, SWT.BORDER);
|
||||
outputMetaEditor.setCurrentDbms(dbmsId);
|
||||
outputMetaEditor.setShowDbTypeColumn(true, false, true);
|
||||
@@ -152,6 +167,46 @@ public class TabFolderEditors extends CTabFolder {
|
||||
outputMetaEditor.setShowPatternColumn(false);
|
||||
outputMetaEditor.initGraphicComponents();
|
||||
outputMetaEditor.getExtendedTableViewer().setCommandStack(commandStack);
|
||||
|
||||
addListenersToOutputButtons();
|
||||
}
|
||||
|
||||
private void addListenersToInputButtons() {
|
||||
MetadataToolbarEditorView toolBar = inputMetaEditor.getToolBar();
|
||||
inputToolBarButtons = toolBar.getButtons();
|
||||
IExtendedButtonListener afterCommandListener = new IExtendedButtonListener() {
|
||||
|
||||
public void handleEvent(ExtendedButtonEvent event) {
|
||||
List<InputTable> inputTablesList = mapperManager.getInputTables();
|
||||
for (InputTable inputTable : inputTablesList) {
|
||||
DataMapTableView view = mapperManager.retrieveIDataMapTableView(inputTable);
|
||||
view.getTableViewerCreatorForColumns().getTableViewer().refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (ExtendedPushButton extendedPushButton : inputToolBarButtons) {
|
||||
extendedPushButton.addListener(afterCommandListener, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void addListenersToOutputButtons() {
|
||||
MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar();
|
||||
outputToolBarButtons = toolBar.getButtons();
|
||||
IExtendedButtonListener afterCommandListener = new IExtendedButtonListener() {
|
||||
|
||||
public void handleEvent(ExtendedButtonEvent event) {
|
||||
List<OutputTable> outputTablesList = mapperManager.getOutputTables();
|
||||
for (OutputTable outputTable : outputTablesList) {
|
||||
DataMapTableView view = mapperManager.retrieveIDataMapTableView(outputTable);
|
||||
view.getTableViewerCreatorForColumns().getTableViewer().refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
for (ExtendedPushButton extendedPushButton : outputToolBarButtons) {
|
||||
extendedPushButton.addListener(afterCommandListener, false);
|
||||
}
|
||||
}
|
||||
|
||||
private StyledText createStyledText(CTabItem item) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -47,6 +47,10 @@ public class DataMapExpressionParser {
|
||||
|
||||
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 + ")|("
|
||||
+ TABLE_PATTERN + GLOBALMAP_PATTERN + ")|(" + GLOBALMAP_PATTERN + COLUMN_PATTERN + ")|" + GLOBALMAP_PATTERN;;
|
||||
|
||||
@@ -147,7 +151,7 @@ public class DataMapExpressionParser {
|
||||
location = new TableEntryLocation(matchResult.group(36), matchResult.group(38));
|
||||
}else if (matchResult.group(39) != null) {
|
||||
// table.\"column\"
|
||||
// Case NVL(Keys.\"ORG_SCD_ID\",-99) When -99 Then 'N' Else 'Y' End
|
||||
// Case NVL(Keys.\"ORG_SCD_ID\",-99) When -99 Then 'N' Else 'Y' End
|
||||
location = new TableEntryLocation(matchResult.group(40), matchResult.group(41));
|
||||
}
|
||||
if (location != null) {
|
||||
@@ -215,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) {
|
||||
@@ -226,6 +230,20 @@ public class DataMapExpressionParser {
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public boolean isContainsGlobalMapExpression(String sqlQuery) {
|
||||
if (sqlQuery != null) {
|
||||
recompilePatternIfNecessary(GLOBALMAP_PATTERN_ALL);
|
||||
while (matcher.contains(sqlQuery, pattern)) {
|
||||
return true;
|
||||
}
|
||||
recompilePatternIfNecessary(GLOBALMAP_PATTERN);
|
||||
while (matcher.contains(sqlQuery, pattern)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getGlobalMapExpressionRegex(String expression) {
|
||||
String[] specialChars = new String[] { "\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|" };
|
||||
|
||||
@@ -165,7 +165,7 @@ public class FOXUI {
|
||||
xmlToSchemaSash = new SashForm(mainComposite, SWT.HORIZONTAL | SWT.SMOOTH);
|
||||
xmlToSchemaSash.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
xmlToSchemaSash.setBackgroundMode(SWT.INHERIT_FORCE);
|
||||
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
|
||||
if (Platform.OS_MACOSX.equals(Platform.getOS()) || Platform.OS_LINUX.equals(Platform.getOS())) {
|
||||
xmlToSchemaSash.setSashWidth((mainComposite.getShell().getBounds().width) / 5);
|
||||
}
|
||||
canModify = externalNode.getProcess().isReadOnly();
|
||||
@@ -190,7 +190,7 @@ public class FOXUI {
|
||||
footerComp = new FooterComposite(mainComposite, SWT.NONE, foxManager);
|
||||
xmlViewer.expandToLevel(3);
|
||||
linker.createLinks();
|
||||
if (Platform.OS_MACOSX.equals(Platform.getOS())) {
|
||||
if (Platform.OS_MACOSX.equals(Platform.getOS()) || Platform.OS_LINUX.equals(Platform.getOS())) {
|
||||
mainComposite.getShell().addControlListener(new ControlListener() {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user