Compare commits

...

28 Commits

Author SHA1 Message Date
Jane Ding
25a0126919 fix(TUP-21425)Job built in 7.0.1 not working in 7.1.1 (#3106) (#3115) (#6142)
https://jira.talendforge.org/browse/TUP-21425
2021-04-30 12:22:24 +08:00
apoltavtsev
8b08fdc713 bugfix(APPINT-32306) Wrong artifact version of the job called by a route 2021-04-09 11:21:04 +02:00
bhe-talendbj
bb0ee2a746 fix(TUP-25820): backport (#5920) 2021-03-09 10:43:55 +08:00
bhe-talendbj
9478ce6a0b fix(TUP-25109): backport TUP-25109 (#5882)
* fix(TUP-25109): backport TUP-25109

* fix(TUP-25109): fix guess schema warning
2021-03-08 14:13:53 +08:00
apoltavtsev
ba425ca2b8 fix(TESB-32028) Remove supported ref Code Projects (#5910) 2021-03-05 23:14:02 +08:00
hcyi
d2983c5c19 fix(TDI-39084): fail to get sap table parameter for tsapbapi and throw NPE. (#5853)
* fix(TDI-39084): fail to get sap table parameter for tsapbapi and throw
NPE.

* TPS-4677:[7.1.1] "Z_TALEND_READ_TABLE" in tSAPBapi give null output
field

Co-authored-by: wang wei <wwang@talend.com>
2021-02-23 16:24:52 +08:00
Jane Ding
afec35bce4 fix(TUP-21055)Migration check executed at each start of studio (#2884) (#2916) (#5832)
* fix(TUP-21055)Migration check executed at each start of studio
https://jira.talendforge.org/browse/TUP-21055

* fix(TUP-21055)Migration check executed at each start of studio
https://jira.talendforge.org/browse/TUP-21055

* fix(TUP-21055)Migration check executed at each start of studio
https://jira.talendforge.org/browse/TUP-21055
Sort the ConfigTypeNode collection

* fix(TUP-21055)Migration check executed at each start of studio
https://jira.talendforge.org/browse/TUP-21055

* fix(TUP-21055)Migration check executed at each start of studio
https://jira.talendforge.org/browse/TUP-21055
2021-02-07 20:08:52 +08:00
bhe-talendbj
5ab73d73a2 fix(TUP-30360): add an option to disable sharing libraries (#5814)
* fix(TUP-30360): add an option to disable sharing libraries

* fix(TUP-30360): add an option to disable sharing libraries, default to true
2021-02-07 10:04:34 +08:00
Chao MENG
7a2837b9d4 fix(TUP-28576):Reference projects routine POM file is modified and can't (#5181) (#5761)
be committed to GIT

Co-authored-by: Zhiwei Xue <zwxue@talend.com>
2021-01-26 12:03:45 +08:00
hzhao-talendbj
e18491a014 fix(TUP-30179): sync context from ext-resource to resource (#5757)
* TUP-30179   remove context from resource and copy context from
ext-resource to resource

* tup-30179  add condition !isSynchronized
2021-01-25 11:15:12 +08:00
hzhao-talendbj
7577d3a038 TUP-30133 add directory resource in route template (#5738) 2021-01-18 09:50:33 +08:00
sbliu
747fe520be fix(TUP-29550) fix problem that "rename" Job in property sheet page duplicates item in Pom file (#5701) 2021-01-05 15:34:06 +08:00
kjwang
c8bbb07688 Kjwang/fix tps 4585 (#5696)
Fix TUP-25777 Integer values are read as string after applying
TPS-3637
https://jira.talendforge.org/browse/TUP-25777
2021-01-05 14:59:44 +08:00
Jane Ding
9a0fd741ce fix(TUP-25649):ERROR when Job in MDM project calling Job in Reference DI (#4331) (#4355) (#5682)
project:import routines.DataQuality cannot be resolved.

Co-authored-by: hcyi <hcyi@talend.com>
2020-12-30 13:02:25 +08:00
mbasiuk-talend
ff71365a17 fix(TDI-45260): save patched version changes on github (#5679) 2020-12-29 15:01:21 +02:00
Jane Ding
8b6daa73e2 Jding/72/tup 22361 elt map bug in column expression while using context (#5595)
variable as a parameter (#3990) (#4209)

* fix(TUP-22361)ELTMap bug in column expression while using context
(#3938)

* fix(TUP-22361)ELTMap bug in column expression while using context
variable as a parameter
https://jira.talendforge.org/browse/TUP-22361

* fix(TUP-22361)ELTMap bug in column expression while using context
variable as a parameter
https://jira.talendforge.org/browse/TUP-22361

* fix(TUP-22361)ELTMap bug in column expression while using context
variable as a parameter
https://jira.talendforge.org/browse/TUP-22361

* fix(TUP-22361)ELTMap bug in column expression while using context
variable as a parameter
https://jira.talendforge.org/browse/TUP-22361

* fix(TUP-22361)ELTMap bug in column expression while using context
variable as a parameter
https://jira.talendforge.org/browse/TUP-22361

Conflicts:
	main/plugins/org.talend.designer.dbmap/src/main/java/org/talend/designer/dbmap/language/generation/DbGenerationManager.java
	main/plugins/org.talend.designer.dbmap/src/main/java/org/talend/designer/dbmap/language/postgres/PostgresGenerationManager.java
	test/plugins/org.talend.designer.dbmap.test/src/org/talend/designer/dbmap/language/generation/DbGenerationManagerTest.java
2020-12-07 10:03:37 +08:00
Zhiwei Xue
eeca56b820 fix(TUP-24623):Compilation error on the job with project references (#5464)
* fix(TUP-24623):Compilation error on the job with project references (#4010)

* fix(TUP-24623):fix regression.
2020-11-06 11:34:24 +08:00
wang wei
9446ce6bad fix(TDI-43619): Null Value Treated as <TALEND_NULL> in Subjob (#4488) (#5449)
Conflicts:
	main/plugins/org.talend.designer.codegen/jet_stub/footer.javajet
2020-11-06 10:09:15 +08:00
vdrokov
a35024deb3 TESB-30572:[7.1] Job build error (#5316)
Avoid build error by removing property from job design if it's value is "ROUTE".
2020-11-03 16:05:56 +01:00
hzhao-talendbj
f53601fb12 tup-27447 backport to patch721 (#4822) (#5238)
* tup-27447  backport to patch721 (#4822)

* fix Could not find the context
2020-10-12 10:04:08 +08:00
Zhiwei Xue
2d3e975d22 fix(TUP-26233):[7.0.1] Sometimes , the ZIP file created by a commandline (#4569) (#4985)
PublishJob is not correct, missing item files.
2020-07-24 18:20:15 +08:00
Dmytro Sylaiev
68aa2a03d5 patch(TPS-4071): Make cumulative patch (#4847)
* patch(TPS-4071): Make cumulative patch

* patch(TPS-4071): Make localprovider buildable

* patch(TPS-4071): Remove localprovider from cumulative patch

* patch(TPS-4071): Remove extra files

* patch(TPS-4071): Fix codegen to avoid compile errors

* patch(TPS-4071): tftpconnection ftps compile error

Co-authored-by: jzhao <jzhao@talend.com>
2020-06-29 20:08:39 +08:00
Jane Ding
5c1725b749 fix(TUP-27179):Studio freezes on job importing/loading (#4682) (#4865)
* fix(TUP-27179):Studio freezes on job importing/loading
https://jira.talendforge.org/browse/TUP-27179

* fix(TUP-27179):Studio freezes on job importing/loading
https://jira.talendforge.org/browse/TUP-27179

* fix(TUP-27179):Studio freezes on job importing/loading
https://jira.talendforge.org/browse/TUP-27179
2020-06-29 10:57:35 +08:00
Jane Ding
7f2c60fff4 feat(TUP-16546)Prompt users for new password in Studio Connection when AD or LDAP credentials change in TAC (#4787)
* feat(TUP-16546)Prompt users for new password in Studio Connection when
(#4508)

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

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

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

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

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

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

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

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

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

Conflicts:
	main/plugins/org.talend.repository/src/main/java/messages.properties
	main/plugins/org.talend.repository/src/main/java/org/talend/repository/ui/login/LoginHelper.java
	main/plugins/org.talend.repository/src/main/java/org/talend/repository/ui/login/LoginProjectPage.java

* feat(TUP-16546):Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546
2020-06-09 16:47:12 +08:00
Laurent BOURGEOIS
2db98b7aa5 fix(TBD-10285):Add contains predicate to expressions (#4758) 2020-05-30 10:06:45 +02:00
Chao MENG
a9e3f1f4e9 fix(TUP-26683): Inputs label in documentation not the same as (#4641)
(#4751)

FlowDiagram
2020-05-29 22:15:54 +08:00
kjwang
bc69ecf45a fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy failure
(#4505)

fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy failure
https://jira.talendforge.org/browse/TUP-26189

Conflicts:
	main/plugins/org.talend.designer.core.generic/src/main/java/org/talend/designer/core/generic/model/GenericElementParameter.java
2020-05-29 17:57:31 +08:00
hcyi
0013d26860 fix(TUP-26683): Inputs label in documentation not the same as (#4641) (#4751)
FlowDiagram
2020-05-29 17:31:16 +08:00
47 changed files with 2211 additions and 307 deletions

View File

@@ -530,9 +530,19 @@
String warningMessageFormat = "Null value will be used for context parameter %s: %s";
for (IContextParameter ctxParam :params)
{
%>
context.setContextType("<%=ctxParam.getName()%>", "<%=ctxParam.getType()%>");
<%
%>
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()%>");
@@ -550,14 +560,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"))
{
%>
@@ -621,6 +624,10 @@
}
<%
}
%>
<%//{B1 block%>
}
<%
}
%>
} catch (java.io.IOException ie) {
@@ -1171,13 +1178,27 @@ if (execStat) {
} else {
type = "ftp";
}
if ("ftp".equals(type)) { %>
((com.enterprisedt.net.ftp.FTPClient) obj_conn).quit();
<%} else if ("sftp".equals(type)) { %>
if ("sftp".equals(type)) { %>
((com.jcraft.jsch.ChannelSftp) obj_conn).quit();
<%} else { %>
((org.apache.commons.net.ftp.FTPSClient) obj_conn).disconnect();
<%}%>
<%} else {
String libImplementation = ElementParameterParser.getValue(ftpNode, "__LIB_IMPLEMENTATION__");
if ("Apache".equalsIgnoreCase(libImplementation)) {
%>
((org.apache.commons.net.ftp.FTPClient) obj_conn).disconnect();
<%
} else {
if ("ftp".equals(type)) {
%>
((com.enterprisedt.net.ftp.FTPClient) obj_conn).quit();
<%
}else{
%>
((org.apache.commons.net.ftp.FTPSClient) obj_conn).disconnect();
<%
}
}
}
%>
}
<% } %>
} catch (java.lang.Exception e) {

View File

@@ -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)

View File

@@ -92,7 +92,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());
}

View File

@@ -0,0 +1,57 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.talend.components.lib</groupId>
<artifactId>talend_file_enhanced</artifactId>
<name>talend_file_enhanced</name>
<version>1.1-patch</version>
<properties>
<talend.nexus.url>https://artifacts-oss.talend.com</talend.nexus.url>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<type>jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>talend_nexus_deployment</id>
<url>${talend.nexus.url}/nexus/content/repositories/TalendOpenSourceSnapshot/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>false</enabled></releases>
</snapshotRepository>
<repository>
<id>talend_nexus_deployment</id>
<url>${talend.nexus.url}/nexus/content/repositories/TalendOpenSourceRelease/</url>
<snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</build>
</project>

View File

@@ -0,0 +1,235 @@
// ============================================================================
//
// Talend Community Edition
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.talend.fileprocess.delimited.patched;
import java.io.BufferedReader;
import java.io.IOException;
/**
* DelimitedDataReader is a stream based API for reading any size of delimited data whith any type of field and record
* delimiters. If you want to get an instance of this type please use the DelimitedDataReaderFactory<br/>
*
* @author gke
*/
public abstract class DelimitedDataReader {
protected BufferedReader inputStream = null;
protected ColumnBuffer columnBuffer = new ColumnBuffer();
protected boolean startedRow = false;
protected int columnsCount = 0;
protected boolean hasReadRecord = false;
protected String[] values = new String[StaticSettings.INITIAL_COLUMN_COUNT];
protected boolean initialized = false;
protected boolean closed = false;
protected boolean skipEmptyRecord = true;
protected long currentRecord = 0;
protected boolean safetySwitch = true;
public DelimitedDataReader(BufferedReader inputStream, boolean skipEmptyRecord) {
if (inputStream == null) {
throw new IllegalArgumentException("Parameter inputStream can not be null.");
}
this.inputStream = inputStream;
this.skipEmptyRecord = skipEmptyRecord;
initialized = true;
}
/**
* DOC ke Comment method "checkClosed". This will be call before read new record or get content of the column
*
* @throws IOException Thrown if this object has already been closed.
*/
protected void checkClosed() throws IOException {
if (closed) {
throw new IOException("This instance of the DelimitedFileReader class has already been closed.");
}
}
/**
* Reads another record. If this returns true, a new row data will be available using get(columnIndex)
*
* @return Whether another record was successfully read or not.
* @throws IOException Thrown if an error occurs while reading data from the source stream.
*/
public abstract boolean readRecord() throws IOException;
/**
* Returns the current columns value for a given column index.
*
* @param columnIndex The index of the column.
* @return The current column value.
* @throws IOException Thrown if this object has already been closed.
*/
public String get(int columnIndex) throws IOException {
checkClosed();
if (columnIndex > -1 && columnIndex < columnsCount) {
return values[columnIndex];
} else {
return "";
}
}
/**
* Gets the count of the records that have been read.
*
* @throws the count of the records that have been read.
*/
public long getProcessedRecordCount() {
return currentRecord;
}
/**
* Closes and releases all related resources.
*/
public void close() {
if (!closed) {
close(true);
closed = true;
}
}
/**
* If closing is true, close and release all related resources.
*
* @param closing
*/
protected abstract void close(boolean closing);
/**
* DOC ke Comment method "getAvailableRowCount".
*
* @param footer the record count that will not used, just as footer for the delimited data. It will also be skipped
* @return the count of Available row count
* @throws IOException
*/
public long getAvailableRowCount(int footer) throws IOException {
checkClosed();
boolean flag = true;
do {
flag = readRecord();
} while (flag);
return currentRecord - footer;
}
public int getAvailableColumnsCount() throws IOException {
return columnsCount;
}
/**
* DOC ke Comment method "skipHeaders". This is used to skip headers in the delimited data
*
* @param header rows count that will be skipped as header
* @throws IOException
*/
public void skipHeaders(int header) throws IOException {
checkClosed();
if (header <= 0) {
return;
}
for (int i = 0; i < header; i++) {
readRecord();
}
currentRecord = 0;
}
/**
* DOC ke Comment method "isSafetySwitch".
*
* @return the state of the safetySwitch
*/
public boolean isSafetySwitch() {
return safetySwitch;
}
/**
* DOC ke Comment method "setSafetySwitch". When reading a delmited text, if safetySwitch is true, and if a column's
* content length is larger than 100,000 or a row's column count is larger than 100,000, an Exception will be
* thrown, and the process of reading delimited data will be terminated.
*
* @param safetySwitch
*/
public void setSafetySwitch(boolean safetySwitch) {
this.safetySwitch = safetySwitch;
}
/**
* @exception IOException Thrown if an error occurs while reading data from the source stream.
*/
protected void endRecord() throws IOException {
// this flag is used as a loop exit condition
// during parsing
hasReadRecord = true;
currentRecord++;
}
@Override
protected void finalize() {
close(false);
}
/**
* StaticSettings for the DelimitedDataReader. they can be changed in unit test.
*/
class StaticSettings {
public static final int MAX_BUFFER_SIZE = 1024;
public static final int INITIAL_COLUMN_COUNT = 10;
public static final int INITIAL_COLUMN_BUFFER_SIZE = 50;
public static final int MAX_SIZE_FOR_SAFTY = 100000;
}
/**
* This is data buffer for storing the contents of a column. this is used in case that the size of a column's
* content is bigger than MAX_BUFFER_SIZE
*
* @author Administrator
*
*/
class ColumnBuffer {
char[] buffer;
int position;
public ColumnBuffer() {
buffer = new char[StaticSettings.INITIAL_COLUMN_BUFFER_SIZE];
position = 0;
}
}
}

View File

@@ -0,0 +1,482 @@
// ============================================================================
//
// Talend Community Edition
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.talend.fileprocess.delimited.patched;
import java.io.BufferedReader;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.function.Predicate;
/**
* DOC ibmuser class global comment. Detailled comment <br/>
*
*/
public class RowParser extends DelimitedDataReader {
private char[] rowSeparator;
private StreamBuffer streamBuffer = null;
private ColumnBuffer rowBuffer = null;
private String rowRecord;
private int mode = 1;
private int rowLength = -1;
private char[] buffer;
private static final int BUFFER_SIZE = 8192;
boolean requireAdditionalReadFromSource = true;
private int separatorIndex;
private boolean foundCR = false;
private int extendedArrayStartIndex = 0;
private int readSymbols = 0;
private int length;
private Predicate<Character> characterVerifier;
/**
* DOC ibmuser RowParser constructor comment.
*
* @param inputStream
* @param rowSeparator
* @param skipEmptyRecords
* @throws IOException
*/
public RowParser(BufferedReader inputStream, String rowSeparator, boolean skipEmptyRecords) throws IOException {
super(inputStream, skipEmptyRecords);
columnBuffer = null;
values = null;
if ("\n".equals(rowSeparator) || "\r\n".equals(rowSeparator)) {
this.buffer = new char[BUFFER_SIZE];
this.mode = 0;
characterVerifier = "\n".equals(rowSeparator) ? c -> c == Character.LETTER_NUMBER : this::testCRLF;
} else if(rowSeparator!=null) {
streamBuffer = new StreamBuffer();
this.rowSeparator = rowSeparator.toCharArray();
rowBuffer = new ColumnBuffer();
try {
streamBuffer.count = inputStream.read(streamBuffer.buffer, 0, streamBuffer.buffer.length);
} catch (IOException ex) {
close();
throw ex;
}
streamBuffer.currentPosition = 0;
streamBuffer.rowStart = 0;
streamBuffer.delimiterLength = rowSeparator.length();
streamBuffer.lastIndexToRead = streamBuffer.count - streamBuffer.delimiterLength;
streamBuffer.streamEndMeet = (streamBuffer.count < streamBuffer.buffer.length);
}
}
/**
* DOC ibmuser RowParser constructor comment.
*
* @param inputStream
* @param rowLength
* @throws IOException
*/
public RowParser(BufferedReader inputStream, int rowLength) throws IOException {
super(inputStream, true);
columnBuffer = null;
values = null;
mode = 2;
this.rowLength = rowLength;
buffer = new char[rowLength];
}
@Override
protected void close(boolean closing) {
if (!closed) {
if (closing && mode == 1) {
streamBuffer.buffer = null;
rowBuffer.buffer = null;
}
try {
if(initialized && inputStream != null) {
inputStream.close();
}
} catch (Exception e) {
// just eat the exception
}
inputStream = null;
closed = true;
}
}
/*
* (non-Javadoc)
*
* @see org.talend.fileprocess.delimited.DelimitedDataReader#readRecord()
*/
public boolean readRecord() throws IOException {
checkClosed();
if (mode == 0) {
return hasNext();
} else if (mode == 1) {
hasReadRecord = false;
if (streamBuffer.hasMoreData()) {
while (streamBuffer.hasMoreData() && !hasReadRecord) {
if (streamBuffer.noDataForDelimter()) {
checkDataLength();
} else {
if (isStartRecordDelimited()) {
if (!skipEmptyRecord) {
endRecord();
}
streamBuffer.skipDelimiter();
} else {
startedRow = true;
streamBuffer.rowStart = streamBuffer.currentPosition;
boolean firstLoop = true;
while (streamBuffer.hasMoreData() && startedRow) {
if (!firstLoop && streamBuffer.noDataForDelimter()) {
checkDataLength();
} else {
if (!firstLoop) {
if (isStartRecordDelimited()) {
endRecord();
streamBuffer.skipDelimiter();
}
} else {
firstLoop = false;
}
if (startedRow) {
streamBuffer.currentPosition++;
if (safetySwitch
&& streamBuffer.currentPosition - streamBuffer.rowStart
+ rowBuffer.position > StaticSettings.MAX_SIZE_FOR_SAFTY) {
close();
throw new IOException(
"Maximum row record length of 100,000 exceeded in row in record "
+ NumberFormat.getIntegerInstance().format(currentRecord)
+ ". Set the safetySwitch property to false"
+ " if you're expecting row record lengths greater than 100,000 characters to"
+ " avoid this error.");
}
}
} // end else
}
}
} // end else
}
}
if (!hasReadRecord) {
if (!streamBuffer.noData()) {
if (!startedRow) {
startedRow = true;
streamBuffer.rowStart = streamBuffer.currentPosition;
streamBuffer.currentPosition = streamBuffer.count;
endRecord();
return true;
}
if (startedRow) {
streamBuffer.currentPosition = streamBuffer.count;
endRecord();
return true;
}
} else {
// if (columnsCount > 0) {
// endRecord();
// return true;
// } else {
return false;
// }
}
}
return hasReadRecord;
} else {
int readNumber = inputStream.read(buffer, 0, rowLength);
if (readNumber == -1) {
return false;
} else {
this.rowRecord = new String(buffer, 0, readNumber);
currentRecord++;
return true;
}
}
}
/**
* Find available record from the source with specified separators.
*
* @return true if reader has a value, otherwise false.
*/
private boolean hasNext() throws IOException {
while (hasMoreData()) {
requireAdditionalReadFromSource = false;
length = readSymbols + extendedArrayStartIndex;
for (int j = Math.max(separatorIndex, extendedArrayStartIndex); j < length; j++){
if (characterVerifier.test(buffer[j])) {
rowRecord = new String(buffer, separatorIndex, j - separatorIndex);
if (j == (length - 1)) {
separatorIndex = 0;
extendedArrayStartIndex = 0;
buffer = new char[BUFFER_SIZE];
if (!skipEmptyRecord || !"".equals(rowRecord)) {
requireAdditionalReadFromSource = true;
currentRecord++;
return true;
} else {
// Reached the end of the buffer and the record is skipped.
break;
}
} else {
separatorIndex = j + 1;
if (!skipEmptyRecord || !"".equals(rowRecord)) {
currentRecord++;
return true;
}
// Skipped, find the next record in the buffer.
}
}
if (j == buffer.length - 1) {
//The end of the buffer is reached, copy unprocessed characters to a new buffer.
ensureBufferCapacity();
}
}
//Reached the last buffer character.
requireAdditionalReadFromSource = true;
if (readSymbols < BUFFER_SIZE) {
break;
}
}
//Last record in the end of the file is reached.
if (readSymbols > 0 || separatorIndex != 0) {
rowRecord = new String(buffer, separatorIndex, length - separatorIndex);
separatorIndex = 0;
if (!skipEmptyRecord || !"".equals(rowRecord)) {
currentRecord++;
return true;
}
}
buffer = null;
return false;
}
/**
* Perform read from source if <b>requireAdditionalReadFromSource</b> is true, otherwise proceed with current read characters.
*
* @return true if buffer contain values to be processed, otherwise source is exhausted.
* @throws IOException exception from input stream read.
*/
private boolean hasMoreData() throws IOException {
return requireAdditionalReadFromSource ? (readSymbols = inputStream.read(buffer, extendedArrayStartIndex, BUFFER_SIZE)) != -1 : true;
}
private boolean testCRLF(Character c) {
if (foundCR && c == Character.LETTER_NUMBER) {
return true;
}
foundCR = c == Character.LINE_SEPARATOR;
return false;
}
/**
* The unprocessed characters has to be copied to a new extended buffer.<br>
* Separator index is reset to 0 to include the unprocessed characters to the next record.
*/
private void ensureBufferCapacity() {
char[] tempChars = buffer;
extendedArrayStartIndex = tempChars.length - separatorIndex;
buffer = new char[extendedArrayStartIndex + BUFFER_SIZE];
System.arraycopy(tempChars, separatorIndex, buffer, 0, extendedArrayStartIndex);
separatorIndex = 0;
}
/**
* @exception IOException Thrown if an error occurs while reading data from the source stream.
*/
private void checkDataLength() throws IOException {
updateCurrentValue();
streamBuffer.moveTailToHead();
int count = 0;
try {
count = inputStream.read(streamBuffer.buffer, streamBuffer.count, streamBuffer.buffer.length
- streamBuffer.count);
} catch (IOException ex) {
close();
throw ex;
}
streamBuffer.count += count;
streamBuffer.lastIndexToRead = streamBuffer.count - streamBuffer.delimiterLength;
if (streamBuffer.count < streamBuffer.buffer.length) {
streamBuffer.streamEndMeet = true;
}
}
private void updateCurrentValue() {
if (startedRow && streamBuffer.rowStart < streamBuffer.currentPosition) {
if (rowBuffer.buffer.length - rowBuffer.position < streamBuffer.currentPosition - streamBuffer.rowStart) {
int newLength = rowBuffer.buffer.length
+ Math.max(streamBuffer.currentPosition - streamBuffer.rowStart, rowBuffer.buffer.length);
char[] holder = new char[newLength];
System.arraycopy(rowBuffer.buffer, 0, holder, 0, rowBuffer.position);
rowBuffer.buffer = holder;
}
System.arraycopy(streamBuffer.buffer, streamBuffer.rowStart, rowBuffer.buffer, rowBuffer.position,
streamBuffer.currentPosition - streamBuffer.rowStart);
rowBuffer.position += streamBuffer.currentPosition - streamBuffer.rowStart;
}
}
private boolean isStartRecordDelimited() {
for (int i = 0; i < rowSeparator.length; i++) {
if (streamBuffer.buffer[streamBuffer.currentPosition + i] != rowSeparator[i]) {
return false;
}
}
return true;
}
@Override
protected void endRecord() throws IOException {
String currentValue = "";
// must be called before setting startedColumn = false
if (startedRow) {
if (rowBuffer.position == 0) {
if (streamBuffer.rowStart < streamBuffer.currentPosition) {
currentValue = new String(streamBuffer.buffer, streamBuffer.rowStart, streamBuffer.currentPosition
- streamBuffer.rowStart);
}
} else {
updateCurrentValue();
currentValue = new String(rowBuffer.buffer, 0, rowBuffer.position);
}
}
rowBuffer.position = 0;
if (startedRow) {
startedRow = false;
}
rowRecord = currentValue;
super.endRecord();
}
/**
* A buffer structure that used to load data from stream for processing.
*
* @author gke
*/
private class StreamBuffer {
char[] buffer;
int currentPosition;
// lastIndexToRead is the last index of letter in the buffer for
// processing, this will be equal to count - delimiterLegnth. This
// is needed because evertime we process a letter, when we need to read
// the proceeding letters in order to make sure if currentPosition is
// the begin of field or record delmiter
int lastIndexToRead;
int delimiterLength;
// count indicates how much usable data has been read into the stream,
// which will not always be as long as Buffer.Length.
int count;
// columnStart is the position in the buffer when the
// current column was started or the last time data
// was moved out to the column buffer.
int rowStart;
// streamEndMeet is also very important, when we loag data from stream,
// if the count is smaller than buffer.length, it indcates that there
// must be no more data in the stream, the stream end is meet.
boolean streamEndMeet = false;
public StreamBuffer() {
buffer = new char[StaticSettings.MAX_BUFFER_SIZE];
currentPosition = 0;
count = 0;
rowStart = 0;
}
public void moveTailToHead() {
count = count - currentPosition;
for (int i = 0; i < count; i++) {
buffer[i] = buffer[currentPosition + i];
}
lastIndexToRead = count - delimiterLength;
currentPosition = 0;
rowStart = 0;
}
public void skipDelimiter() {
currentPosition += delimiterLength;
}
public boolean noDataForDelimter() {
return currentPosition > lastIndexToRead;
}
public boolean hasMoreData() {
return (currentPosition <= lastIndexToRead) || (currentPosition > lastIndexToRead && !streamEndMeet);
}
public boolean noData() {
return currentPosition >= count;
}
}
public String getRowRecord() {
return rowRecord;
}
}

View File

@@ -0,0 +1,168 @@
package org.talend.fileprocess.delimited.patched;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.zip.ZipInputStream;
public class RowParserByByte {
private byte[] buffer;
private int row_length;
private BufferedInputStream in = null;
private boolean safetySwitch = false;
public final int MAX_SIZE_FOR_SAFTY = 100000;
private boolean closed = false;
private long currentRecord = 0;
private int header = 0;
public RowParserByByte(String filename, int row_length) throws FileNotFoundException {
this.row_length = row_length;
File f = new File(filename);
if (!f.exists()) {
throw new FileNotFoundException(filename);
}
in = new BufferedInputStream(new FileInputStream(f));
}
public RowParserByByte(ZipInputStream zis, int row_length) throws FileNotFoundException {
this.row_length = row_length;
in = new BufferedInputStream(zis);
}
public boolean readRecord() throws Exception {
return toByteArray();
}
/**
* DOC ke Comment method "isSafetySwitch".
*
* @return the state of the safetySwitch
*/
public boolean isSafetySwitch() {
return safetySwitch;
}
/**
* DOC ke Comment method "setSafetySwitch". When reading a delmited text, if
* safetySwitch is true, and if a column's content length is larger than
* 100,000 or a row's column count is larger than 100,000, an Exception will
* be thrown, and the process of reading delimited data will be terminated.
*
* @param safetySwitch
*/
public void setSafetySwitch(boolean safetySwitch) {
this.safetySwitch = safetySwitch;
}
/**
* DOC ke Comment method "checkClosed". This will be call before read new
* record or get content of the column
*
* @throws IOException
* Thrown if this object has already been closed.
*/
protected void checkClosed() throws IOException {
if (closed) {
throw new IOException("This instance of the RowRaeserByByte class has already been closed.");
}
}
/**
* DOC ke Comment method "skipHeaders". This is used to skip headers in the
* delimited data
*
* @param header
* rows count that will be skipped as header
* @throws IOException
*/
public void skipHeaders(int header) throws Exception {
checkClosed();
if (header <= 0) {
return;
}
this.header = header;
for (int i = 0; i < header; i++) {
readRecord();
}
currentRecord = 0;
}
public byte[] getBuffer() {
return buffer;
}
public String getRowRecord() {
return new String(buffer);
}
public boolean toByteArray() throws IOException {
this.buffer = new byte[row_length];
if (-1 != in.read(buffer, 0, row_length)) {
if (safetySwitch && currentRecord - header > this.MAX_SIZE_FOR_SAFTY) {
close();
throw new IOException("Maximum row record length of 100,000 exceeded in row in record "
+ NumberFormat.getIntegerInstance().format(currentRecord)
+ ". Set the safetySwitch property to false"
+ " if you're expecting row record lengths greater than 100,000 characters to"
+ " avoid this error.");
}
currentRecord++;
return true;
} else {
return false;
}
}
/**
* DOC ke Comment method "getAvailableRowCount".
*
* @param footer
* the record count that will not used, just as footer for the
* delimited data. It will also be skipped
* @return the count of Available row count
* @throws Exception
*/
public long getAvailableRowCount(int footer) throws Exception {
checkClosed();
boolean flag = true;
do {
flag = readRecord();
} while (flag);
return currentRecord - footer;
}
/**
* Closes and releases all related resources.
*/
public void close() {
try {
in.close();
} catch (IOException e) {
// just eat the exception
}
closed = true;
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -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;
@@ -28,9 +29,9 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.ui.gmf.util.DisplayUtils;
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.properties.ComponentReferenceProperties;
import org.talend.components.api.service.ComponentService;
import org.talend.core.model.components.EComponentType;
import org.talend.core.model.components.IComponent;
@@ -488,10 +489,26 @@ public class GenericElementParameter extends ElementParameter implements IGeneri
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
try {
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);
throw new InvocationTargetException(e);
} 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);
}

View File

@@ -398,6 +398,7 @@ GuessSchemaController.connectionFailed=Database connection is failed.
GuessSchemaController.connError=Connection error
GuessSchemaController.setParameter=Please set connection parameters
GuessSchemaController.waitOpenDatabase=Waiting for opening Database ...
GuessSchemaController.emptyQuery=Empty query
I18nPreferencePage.allTranslation=Import all translations
I18nPreferencePage.completeInfo=Translations loaded from Babili, these translations will be only displayed to test, on next restart of the application, these texts for translations will be lost.
I18nPreferencePage.importBabili=Import Translation from Babili

View File

@@ -342,6 +342,9 @@ public enum EParameterName {
REPARTITIONER(Messages.getString("Connection.paral_repartitioner")), //$NON-NLS-1$
NONE(Messages.getString("Connection.paral_none")), //$NON-NLS-1$
QUEUE_SIZE(Messages.getString("Connection.paral_queuesize")), //$NON-NLS-1$
NUM_PARTITIONS("NUM_PARTITIONS"), //$NON-NLS-1$
DEPART_QUEUE_SIZE("DEPART_QUEUE_SIZE"), //$NON-NLS-1$
PART_QUEUE_SIZE("PART_QUEUE_SIZE"), //$NON-NLS-1$
SUBTREE_START("SUBTREE_START"), //$NON-NLS-1$
END_OF_FLOW("END_OF_FLOW"), //$NON-NLS-1$

View File

@@ -76,6 +76,8 @@ public final class Expression {
private static final Pattern isShowFuncPattern = Pattern.compile("isShow\\[(\\w+)(\\.\\w+)*\\]"); //$NON-NLS-1$
private static final String CONTAINS = "CONTAINS"; //$NON-NLS-1$
private Expression(String expressionString) {
this.expressionString = expressionString;
}
@@ -274,6 +276,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) {
@@ -1030,5 +1036,28 @@ public final class Expression {
}
return false;
}
public static boolean evaluateContains(String simpleExpression, List<? extends IElementParameter> listParam) {
//Split to get param name and param value to look after
String[] splitted = simpleExpression.split(CONTAINS);
if (splitted.length != 2) {
return false;
}
String paramName = splitted[0].trim();
String paramValue = splitted[1].trim();
//Look for the param name in list
IElementParameter param = listParam.stream()
.filter(p -> paramName.equals(p.getName()))
.findAny()
.orElse(null);
if (param == null || ! EParameterFieldType.TABLE.equals(param.getFieldType())) {
return false;
}
// Check if we can find paraValue among table lines
return ((List<Map<String, Object>>) param.getValue()).stream()
.anyMatch(line -> paramValue.equals(line.toString()));
}
}

View File

@@ -3443,15 +3443,26 @@ public class DataProcess implements IGeneratingProcess {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IJobletProviderService.class)) {
jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
}
boolean needReplaceForJoblet = false;
for (INode node : orginalList) {
if (ProcessorUtilities.isGeneratePomOnly() && jobletService != null && jobletService.isJobletComponent(node)) {
if (jobletService != null && jobletService.isJobletComponent(node)) {
if (ProcessorUtilities.isGeneratePomOnly()) {
// skip any joblet contained during the pom generation
continue;
}
needReplaceForJoblet = true;
}
for (IReplaceNodeInProcess replaceProvider : ReplaceNodesInProcessProvider.findReplaceNodesProvider()) {
replaceProvider.rebuildGraphicProcessFromNode(node, graphicalNodeList);
}
}
// All replace for Parallelization done by the start node, but joblet node maybe existed after
// for the new nodes that Joblet added to graphicalNodeList, also need to consider replace node
// such as ReplaceParallelization for Partition row in Joblet
if (needReplaceForJoblet) {
replaceNodeFromProviders(graphicalNodeList);
}
}
private INode addDataNode(INode dataNode) {

View File

@@ -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;
@@ -124,6 +125,7 @@ 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;
@@ -1814,23 +1816,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).stream()
.filter(o -> !((RoutineItem) o.getProperty().getItem()).isBuiltIn()).collect(Collectors.toList()));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
});
Set<String> allRoutinesSet = routines.stream().map(o -> o.getProperty().getLabel()).collect(Collectors.toSet());
Iterator<RoutinesParameterType> iterator = routinesDependencies.iterator();
while (iterator.hasNext()) {
RoutinesParameterType routine = iterator.next();
if (!allRoutinesSet.contains(routine.getName())) {
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())) {
@@ -1855,9 +1870,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())) {
@@ -4421,6 +4435,19 @@ 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));
}

View File

@@ -86,6 +86,7 @@ import org.talend.core.ui.properties.tab.IDynamicProperty;
import org.talend.core.ui.services.ISQLBuilderService;
import org.talend.core.utils.CsvArray;
import org.talend.core.utils.KeywordsValidator;
import org.talend.core.utils.TalendQuoteUtils;
import org.talend.designer.core.i18n.Messages;
import org.talend.designer.core.model.components.EParameterName;
import org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand;
@@ -214,6 +215,11 @@ public class GuessSchemaController extends AbstractElementPropertySectionControl
IElementParameter elementParameterFromField = elem.getElementParameterFromField(EParameterFieldType.MEMO_SQL);
memoSQL = (String) elementParameterFromField.getValue();
if (memoSQL == null || TalendQuoteUtils.removeQuotes(memoSQL).trim().isEmpty()) {
MessageDialog.open(MessageDialog.INFORMATION, this.btn.getShell(), "",
Messages.getString("GuessSchemaController.emptyQuery"), SWT.NONE);
return null;
}
initConnectionParameters();
if (this.connParameters != null && memoSQL != null) {
initConnectionParametersWithContext(elem, manager.getDefaultContext());

View File

@@ -200,6 +200,12 @@ public class GuessSchemaProcess extends AbstractGuessSchemaProcess {
|| EDatabaseTypeName.SAPHana.getXmlName().equals(info.getDbType())) {
createStatament = "conn.createStatement()";
}
if (EDatabaseTypeName.REDSHIFT.getXmlName().equals(info.getDbType())
|| EDatabaseTypeName.REDSHIFT_SSO.getXmlName().equals(info.getDbType())) {
createStatament = "conn.createStatement()";
}
codeStart = systemProperty + getCodeStart(connectionNode, createStatament, fetchSize);
codeMain = "String[] dataOneRow = new String[numbOfColumn];\r\n" + "for (int i = 1; i <= numbOfColumn; i++) {\r\n" //$NON-NLS-1$ //$NON-NLS-2$
@@ -207,13 +213,8 @@ public class GuessSchemaProcess extends AbstractGuessSchemaProcess {
+ "csvWriter.writeNext(dataOneRow);"; //$NON-NLS-1$
if(EDatabaseTypeName.REDSHIFT.getXmlName().equals(info.getDbType())||EDatabaseTypeName.REDSHIFT_SSO.getXmlName().equals(info.getDbType())){
codeEnd = "nbRows++;\r\n" + " if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "conn.close();\r\n" + "csvWriter.close();\r\n"; //$NON-NLS-1$ //$NON-NLS-2$
}else{
codeEnd = "nbRows++;\r\n" + " if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "conn.close();\r\n" + "csvWriter.close();\r\n"; //$NON-NLS-1$ //$NON-NLS-2$
}
codeEnd = "nbRows++;\r\n" + " if (nbRows > " + maximumRowsToPreview + ") break;\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "conn.close();\r\n" + "csvWriter.close();\r\n"; //$NON-NLS-1$ //$NON-NLS-2$
IComponent component = null;
switch (LanguageManager.getCurrentLanguage()) {
@@ -237,99 +238,34 @@ public class GuessSchemaProcess extends AbstractGuessSchemaProcess {
private String getCodeStart(INode connectionNode, String createStatament, int fetchSize){
IPath temppath = getTemppath();
String codeStart = null;
if(EDatabaseTypeName.REDSHIFT.getXmlName().equals(info.getDbType())||EDatabaseTypeName.REDSHIFT_SSO.getXmlName().equals(info.getDbType())){
INode node = getNode();
String tableName = (String) node.getElementParameter("TABLE").getValue();
String dbName = null;
String schema = null;
if(connectionNode!=null){
if(connectionNode.getElementParameter("DBNAME")!=null){
dbName = (String) connectionNode.getElementParameter("DBNAME").getValue();
}
if(connectionNode.getElementParameter("SCHEMA_DB")!=null){
schema = (String) connectionNode.getElementParameter("SCHEMA_DB").getValue();
}
}else{
if(node.getElementParameter("DBNAME")!=null){
dbName = (String) node.getElementParameter("DBNAME").getValue();
}
if(node.getElementParameter("SCHEMA_DB")!=null){
schema = (String) node.getElementParameter("SCHEMA_DB").getValue();
}
}
String codeStart = "java.lang.Class.forName(\"" + info.getDriverClassName() + "\");\r\n" + "String url = \"" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ info.getUrl() + "\";\r\n" + "java.sql.Connection conn = java.sql.DriverManager.getConnection(url, \"" //$NON-NLS-1$ //$NON-NLS-2$
+ info.getUsername() + "\", \"" + info.getPwd() + "\");\r\n" + "java.sql.Statement stm = " + createStatament + ";\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "try {\r\nstm.setFetchSize(" + fetchSize //$NON-NLS-1$
+ ");\r\n} catch (Exception e) {\r\n// Exception is thrown if db don't support, no need to catch exception here\r\n} \r\n" //$NON-NLS-1$
+ "java.sql.ResultSet rs = stm.executeQuery(" + memoSQL + ");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "java.sql.ResultSetMetaData rsmd = rs.getMetaData();\r\n" + "int numbOfColumn = rsmd.getColumnCount();\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "\r\n" + "String fileName = (new java.io.File(\r\n" + " \"" + temppath //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "\")).getAbsolutePath().replace(\r\n" + " \"\\\\\", \"/\");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "com.talend.csv.CSVWriter csvWriter = new com.talend.csv.CSVWriter(\r\n" //$NON-NLS-1$
+ " new java.io.BufferedWriter(new java.io.OutputStreamWriter(\r\n" //$NON-NLS-1$
+ " new java.io.FileOutputStream(\r\n" //$NON-NLS-1$
+ " fileName, false),\r\n" //$NON-NLS-1$
+ " \"GBK\")));\r\n" + " \r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.setSeparator(';');\r\n" + "csvWriter.setQuoteStatus(com.talend.csv.CSVWriter.QuoteStatus.FORCE);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "int nbRows = 0;\r\n" //$NON-NLS-1$
+ "String[] columnNames = new String[numbOfColumn];\r\n" + "String[] nullables = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "String[] lengths = new String[numbOfColumn];\r\n" + "String[] precisions = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "String[] dbtypes = new String[numbOfColumn];\r\n" //$NON-NLS-1$
+ "for(int i = 1;i<=numbOfColumn;i++){\r\n" + "columnNames[i-1] = rsmd.getColumnName(i);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "nullables[i-1] = rsmd.isNullable(i) == 0? \"false\" : \"true\";\r\n" //$NON-NLS-1$
+ "lengths[i-1] = Integer.toString(rsmd.getScale(i));\r\n" //$NON-NLS-1$
+ "precisions[i-1] = Integer.toString(rsmd.getPrecision(i));" //$NON-NLS-1$
+ "dbtypes[i-1] = rsmd.getColumnTypeName(i);\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$
codeStart = "java.lang.Class.forName(\"" + info.getDriverClassName() + "\");\r\n" + "String url = \"" + info.getUrl() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "\";\r\n" + "java.sql.Connection conn = java.sql.DriverManager.getConnection(url, \"" + info.getUsername() //$NON-NLS-1$ //$NON-NLS-2$
+ "\", \"" + info.getPwd() + "\");\r\n" + "java.sql.DatabaseMetaData metaData = conn.getMetaData();\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "java.sql.ResultSet rs = metaData.getColumns(" + dbName + "," + schema + "," + tableName + ",null);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "\r\n" + "String fileName = (new java.io.File(\r\n" + " \"" + temppath //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "\")).getAbsolutePath().replace(\r\n" + " \"\\\\\", \"/\");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "com.talend.csv.CSVWriter csvWriter = new com.talend.csv.CSVWriter(\r\n" //$NON-NLS-1$
+ " new java.io.BufferedWriter(new java.io.OutputStreamWriter(\r\n" //$NON-NLS-1$
+ " new java.io.FileOutputStream(\r\n" //$NON-NLS-1$
+ " fileName, false),\r\n" //$NON-NLS-1$
+ " \"GBK\")));\r\n" + " \r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.setSeparator(';');\r\n" + "csvWriter.setQuoteStatus(com.talend.csv.CSVWriter.QuoteStatus.FORCE);\r\n" + "int nbRows = 0;\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "java.util.List<String> columnNameList= new java.util.ArrayList<String>();\r\n" + "java.util.List<String> nullableList= new java.util.ArrayList<String>();\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "java.util.List<String> lengthList= new java.util.ArrayList<String>();\r\n" + "java.util.List<String> precisionList= new java.util.ArrayList<String>();\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "java.util.List<String> dbtypeList= new java.util.ArrayList<String>();\r\n" //$NON-NLS-1$
+"while (rs.next()) {\r\n" //$NON-NLS-1$
+"columnNameList.add(rs.getString(\"COLUMN_NAME\"));\r\n" //$NON-NLS-1$
+"nullableList.add(rs.getBoolean(\"NULLABLE\") ? \"true\" : \"false\");\r\n" //$NON-NLS-1$
+"lengthList.add(Integer.toString(rs.getInt(\"COLUMN_SIZE\")));\r\n" //$NON-NLS-1$
+"precisionList.add(Integer.toString(rs.getInt(\"NUM_PREC_RADIX\")));\r\n" //$NON-NLS-1$
+"dbtypeList.add(rs.getString(\"TYPE_NAME\"));\r\n" //$NON-NLS-1$
+"}\r\n" //$NON-NLS-1$
+"int numbOfColumn = columnNameList.size();" //$NON-NLS-1$
+ "String[] columnNames = new String[numbOfColumn];\r\n" + "String[] nullables = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "String[] lengths = new String[numbOfColumn];\r\n" + "String[] precisions = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "String[] dbtypes = new String[numbOfColumn];\r\n" //$NON-NLS-1$
+ "for(int i = 0;i<=numbOfColumn-1;i++){\r\n" + "columnNames[i] = columnNameList.get(i);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "nullables[i] = nullableList.get(i);\r\n" //$NON-NLS-1$
+ "lengths[i] = lengthList.get(i);\r\n" //$NON-NLS-1$
+ "precisions[i] = precisionList.get(i);" //$NON-NLS-1$
+ "dbtypes[i] = dbtypeList.get(i);\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.writeNext(columnNames);\r\n" + "csvWriter.writeNext(nullables);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.writeNext(lengths);\r\n" + "csvWriter.writeNext(precisions);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.writeNext(dbtypes);\r\n" + "while (rs.next()) {"; //$NON-NLS-1$ //$NON-NLS-2$
}else{
codeStart = "java.lang.Class.forName(\"" + info.getDriverClassName() + "\");\r\n" + "String url = \"" + info.getUrl() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "\";\r\n" + "java.sql.Connection conn = java.sql.DriverManager.getConnection(url, \"" + info.getUsername() //$NON-NLS-1$ //$NON-NLS-2$
+ "\", \"" + info.getPwd() + "\");\r\n" + "java.sql.Statement stm = " + createStatament + ";\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "try {\r\nstm.setFetchSize(" + fetchSize + ");\r\n} catch (Exception e) {\r\n// Exception is thrown if db don't support, no need to catch exception here\r\n} \r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "java.sql.ResultSet rs = stm.executeQuery(" + memoSQL + ");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "java.sql.ResultSetMetaData rsmd = rs.getMetaData();\r\n" + "int numbOfColumn = rsmd.getColumnCount();\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "\r\n" + "String fileName = (new java.io.File(\r\n" + " \"" + temppath //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "\")).getAbsolutePath().replace(\r\n" + " \"\\\\\", \"/\");\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "com.talend.csv.CSVWriter csvWriter = new com.talend.csv.CSVWriter(\r\n" //$NON-NLS-1$
+ " new java.io.BufferedWriter(new java.io.OutputStreamWriter(\r\n" //$NON-NLS-1$
+ " new java.io.FileOutputStream(\r\n" //$NON-NLS-1$
+ " fileName, false),\r\n" //$NON-NLS-1$
+ " \"GBK\")));\r\n" + " \r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.setSeparator(';');\r\n" + "csvWriter.setQuoteStatus(com.talend.csv.CSVWriter.QuoteStatus.FORCE);\r\n" + "int nbRows = 0;\r\n" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "String[] columnNames = new String[numbOfColumn];\r\n" + "String[] nullables = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "String[] lengths = new String[numbOfColumn];\r\n" + "String[] precisions = new String[numbOfColumn];\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "String[] dbtypes = new String[numbOfColumn];\r\n" //$NON-NLS-1$
+ "for(int i = 1;i<=numbOfColumn;i++){\r\n" + "columnNames[i-1] = rsmd.getColumnName(i);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "nullables[i-1] = rsmd.isNullable(i) == 0? \"false\" : \"true\";\r\n" //$NON-NLS-1$
+ "lengths[i-1] = Integer.toString(rsmd.getScale(i));\r\n" //$NON-NLS-1$
+ "precisions[i-1] = Integer.toString(rsmd.getPrecision(i));" //$NON-NLS-1$
+ "dbtypes[i-1] = rsmd.getColumnTypeName(i);\r\n" + "}\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.writeNext(columnNames);\r\n" + "csvWriter.writeNext(nullables);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.writeNext(lengths);\r\n" + "csvWriter.writeNext(precisions);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.writeNext(dbtypes);\r\n" + "while (rs.next()) {"; //$NON-NLS-1$ //$NON-NLS-2$
}
+ "csvWriter.writeNext(columnNames);\r\n" + "csvWriter.writeNext(nullables);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.writeNext(lengths);\r\n" + "csvWriter.writeNext(precisions);\r\n" //$NON-NLS-1$ //$NON-NLS-2$
+ "csvWriter.writeNext(dbtypes);\r\n" + "while (rs.next()) {"; //$NON-NLS-1$ //$NON-NLS-2$
return codeStart;
}

View File

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

View File

@@ -115,6 +115,8 @@ public class DeploymentComposite extends AbstractTabComposite {
private boolean isDataServiceJob; // Is ESB SOAP Service Job
private boolean isChildJob;
public DeploymentComposite(Composite parent, int style, TabbedPropertySheetWidgetFactory widgetFactory,
IRepositoryViewObject repositoryViewObject) {
super(parent, style, widgetFactory, 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;

View File

@@ -784,7 +784,7 @@ public class MainComposite extends AbstractTabComposite {
RelationshipItemBuilder.getInstance().addOrUpdateItem(repositoryObject.getProperty().getItem());
}
proxyRepositoryFactory.save(ProjectManager.getInstance().getCurrentProject(),
repositoryObject.getProperty().getItem(), false);
repositoryObject.getProperty(), oldName, oldVersion);
if (needjobletRelateUpdate && GlobalServiceRegister.getDefault()
.isServiceRegistered(IJobletProviderService.class)) {
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister

View File

@@ -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()) {

View File

@@ -2,8 +2,10 @@ package org.talend.designer.core.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.talend.core.model.metadata.IMetadataColumn;
import org.talend.core.model.metadata.IMetadataTable;
@@ -386,7 +388,18 @@ public class ParallelExecutionUtils {
}
public static boolean isExistPreviousParCon(Node previousNode) {
Set<String> checkedNodeSet = new HashSet<String>();
boolean existPreviousParCon = isExistPreviousParCon(previousNode, checkedNodeSet);
return existPreviousParCon;
}
private static boolean isExistPreviousParCon(Node previousNode, Set<String> checkedSet) {
boolean hasParInPreviousCon = false;
if (previousNode == null || checkedSet.contains(previousNode.getUniqueName())) {
// already checked, return
return hasParInPreviousCon;
}
checkedSet.add(previousNode.getUniqueName());
if (previousNode.getIncomingConnections().size() > 0) {
for (IConnection con : previousNode.getIncomingConnections()) {
if (con.getElementParameter(EParameterName.PARTITIONER.getName()) != null
@@ -396,7 +409,10 @@ public class ParallelExecutionUtils {
hasParInPreviousCon = true;
break;
} else {
hasParInPreviousCon = isExistPreviousParCon((Node) con.getSource());
hasParInPreviousCon = isExistPreviousParCon((Node) con.getSource(), checkedSet);
if (hasParInPreviousCon) {
break;
}
}
}
}

View File

@@ -79,6 +79,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>();
@@ -91,6 +93,8 @@ public abstract class DbGenerationManager {
protected Set<String> subQueryTable = new HashSet<String>();
protected Set<String> inputSchemaContextSet = new HashSet<String>();
/**
* DOC amaumont GenerationManager constructor comment.
*
@@ -276,6 +280,7 @@ public abstract class DbGenerationManager {
queryColumnsSegments.clear();
querySegments.clear();
subQueryTable.clear();
inputSchemaContextSet.clear();
this.tabSpaceString = tabString;
DbMapComponent component = getDbMapComponent(dbMapComponent);
@@ -288,7 +293,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();
@@ -361,8 +368,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();
@@ -551,6 +556,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());
}
}
}
}
protected DbMapComponent getDbMapComponent(DbMapComponent dbMapComponent) {
DbMapComponent component = dbMapComponent;
INode realGraphicalNode = dbMapComponent.getRealGraphicalNode();
@@ -598,29 +637,27 @@ 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);
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;
}
@@ -716,7 +753,7 @@ public abstract class DbGenerationManager {
return contextList;
}
protected Set<String> getGlobalMapList(DbMapComponent component, String sqlQuery) {
return parser.getGlobalMapSet(sqlQuery);
}
@@ -788,8 +825,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;

View File

@@ -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;
}

View File

@@ -591,8 +591,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
attri.setValue(IHTMLDocConstants.PICTUREFOLDERPATH + "pdf_" + jobName + IHTMLDocConstants.JOB_PREVIEW_PIC_SUFFIX); //$NON-NLS-1$
List attributeList = document.selectNodes("/project/job/externalNodeComponents/component/@preview"); //$NON-NLS-1$
for (int i = 0; i < attributeList.size(); i++) {
Attribute at = (Attribute) attributeList.get(i);
for (Object element : attributeList) {
Attribute at = (Attribute) element;
String externalValue = at.getValue().substring(at.getValue().indexOf("/") + 1); //$NON-NLS-1$
String value = IHTMLDocConstants.PICTUREFOLDERPATH + "pdf_" + externalValue; //$NON-NLS-1$
at.setValue(value);
@@ -665,8 +665,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
// Check if generate Job Extra / Stats&Logs Setting Info
if (item instanceof ProcessItem) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(
IMRProcessService.class);
IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault()
.getService(IMRProcessService.class);
generateExtraSetting = !mrProcessService.isMapReduceItem(item);
generateStatsLogsSetting = generateExtraSetting;
} else if (isRouteProcess(item)) {
@@ -847,8 +847,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
Map<String, String> nameValueMap = new HashMap<String, String>();
for (int i = 0; i < params.size(); i++) {
ElementParameterType param = (ElementParameterType) params.get(i);
for (Object param2 : params) {
ElementParameterType param = (ElementParameterType) param2;
nameValueMap.put(param.getName(), ParameterValueUtil.getValue4Doc(param));
}
// Main settinparam info
@@ -1022,10 +1022,10 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
Element contextListElement = DocumentHelper.createElement("contextList"); // Context root //$NON-NLS-1$
for (int i = 0, n = contexts.size(); i < n; i++) {
for (Object context2 : contexts) {
// export single context infomation
Element contextElement = DocumentHelper.createElement("context"); //$NON-NLS-1$
ContextType context = (ContextType) contexts.get(i);
ContextType context = (ContextType) context2;
// Attributes
contextElement.addAttribute("name", HTMLDocUtils.checkString(context.getName())); //$NON-NLS-1$
@@ -1034,13 +1034,13 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
// Context parameters as children
EList params = context.getContextParameter();
if (params != null && !params.isEmpty()) {
for (int j = 0, k = params.size(); j < k; j++) {
for (Object param2 : params) {
/*
* <contextParameter comment="Give server name" name="server" prompt="Default Server "
* promptNeeded="false" repositoryContextId="_crJMkCCQEd2Oweh7yRMWjQ" type=""
* value="'192.168.0.109'"/>
*/
ContextParameterType param = (ContextParameterType) params.get(j);
ContextParameterType param = (ContextParameterType) param2;
Element contextParamElement = DocumentHelper.createElement("contextParameter"); //$NON-NLS-1$
contextParamElement.addAttribute("name", HTMLDocUtils.checkString(param.getName())); //$NON-NLS-1$
contextParamElement.addAttribute("prompt", HTMLDocUtils.checkString(param.getPrompt())); //$NON-NLS-1$
@@ -1212,8 +1212,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
*/
private void generateConnectionsInfo(Element jobElement, EList connectionList) {
Element connectionsElement = jobElement.addElement("connections"); //$NON-NLS-1$
for (int j = 0; j < connectionList.size(); j++) {
ConnectionType type = (ConnectionType) connectionList.get(j);
for (Object element : connectionList) {
ConnectionType type = (ConnectionType) element;
Element connectionElement = connectionsElement.addElement("connection"); //$NON-NLS-1$
connectionElement.addAttribute("label", HTMLDocUtils.checkString(type.getLabel())); //$NON-NLS-1$
connectionElement.addAttribute("lineStyle", HTMLDocUtils.checkString(type.getLineStyle() + "")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -1251,8 +1251,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
}
if (isRouteProcess(item)) {
jobElement.addAttribute("type", "route");//$NON-NLS-1$//$NON-NLS-2$
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(
ICamelDesignerCoreService.class);
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault()
.getService(ICamelDesignerCoreService.class);
camelService.appendRouteInfo2Doc(item, jobElement);
}
if (generateExtraSetting) {
@@ -1330,8 +1330,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
*/
protected boolean isRouteProcess(Item item) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(
ICamelDesignerCoreService.class);
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault()
.getService(ICamelDesignerCoreService.class);
return camelService.isInstanceofCamel(item);
}
return false;
@@ -1498,8 +1498,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
protected void handleSourceAndTargetConnection(EList connectionList) {
List<String> targetList = new ArrayList<String>();
List<String> sourceList = new ArrayList<String>();
for (int j = 0; j < connectionList.size(); j++) {
ConnectionType type = (ConnectionType) connectionList.get(j);
for (Object element : connectionList) {
ConnectionType type = (ConnectionType) element;
if (!targetConnectionMap.containsKey(type.getSource())) {
targetList = new ArrayList<String>();
}
@@ -1509,10 +1509,13 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
targetConnectionMap.put(type.getSource(), targetList);
if (!sourceConnectionMap.containsKey(type.getTarget())) {
sourceList = new ArrayList<String>();
sourceList = new ArrayList<String>();
if (sourceConnectionMap.containsKey(type.getTarget())) {
sourceList = sourceConnectionMap.get(type.getTarget());
}
if (!sourceList.contains(type.getSource())) {
sourceList.add(type.getSource());
}
sourceList.add(type.getSource());
sourceConnectionMap.put(type.getTarget(), sourceList);
}
@@ -1556,15 +1559,15 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
* @return
*/
private String getFullProductName() {
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
IBrandingService.class);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
.getService(IBrandingService.class);
return brandingService.getFullProductName();
}
private String getProductVersionName() {
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
IBrandingService.class);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
.getService(IBrandingService.class);
return brandingService.getShortProductName() + IHTMLDocConstants.VERSION;
}
@@ -1597,8 +1600,8 @@ public class HTMLDocGenerator implements IDocumentationGenerator {
}
// if (result == null) {
result = new ByteArrayOutputStream(3072);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
IBrandingService.class);
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault()
.getService(IBrandingService.class);
ImageData imageData = brandingService.getLoginHImage().getImageData();
new ByteArrayOutputStream();

View File

@@ -52,6 +52,14 @@
<include>${talend.job.path}/**</include>
</includes>
</fileSet>
<fileSet><!-- add context resources -->
<directory>${current.int-resources.dir}</directory>
<outputDirectory>${file.separator}</outputDirectory>
<includes>
<include>${talend.job.path}/**</include>
</includes>
</fileSet>
<fileSet> <!-- add provided-lib -->
<directory>${current.bundle.resources.dir}/provided-lib</directory>

View File

@@ -44,6 +44,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.osgi.framework.Bundle;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.CorePlugin;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.IESBService;
@@ -732,6 +733,11 @@ public class DefaultRunProcessService implements IRunProcessService {
return TalendJavaProjectManager.getTalendJobJavaProject(property);
}
@Override
public IFolder getCodeSrcFolder(ERepositoryObjectType type, String projectTechName) {
return new AggregatorPomsHelper(projectTechName).getCodeSrcFolder(type);
}
@Override
public ITalendProcessJavaProject getTempJavaProject() {
return TalendJavaProjectManager.getTempJavaProject();
@@ -825,9 +831,8 @@ public class DefaultRunProcessService implements IRunProcessService {
if (ProcessUtils.isRequiredBeans(null, refProject)) {
installRefCodeProject(ERepositoryObjectType.valueOf("BEANS"), refHelper, monitor); //$NON-NLS-1$
}
deleteRefProjects(refProject, refHelper);
deleteRefProjects(refProject, refHelper);
}
private void installRefCodeProject(ERepositoryObjectType codeType, AggregatorPomsHelper refHelper, IProgressMonitor monitor)
@@ -849,15 +854,10 @@ public class DefaultRunProcessService implements IRunProcessService {
private void deleteRefProjects(Project refProject, AggregatorPomsHelper refHelper) throws Exception {
IProgressMonitor monitor = new NullProgressMonitor();
deleteRefProject(ERepositoryObjectType.ROUTINES, refHelper, monitor);
if (ProcessUtils.isRequiredPigUDFs(null, refProject)) {
deleteRefProject(ERepositoryObjectType.PIG_UDF, refHelper, monitor);
}
if (ProcessUtils.isRequiredBeans(null, refProject)) {
deleteRefProject(ERepositoryObjectType.valueOf("BEANS"), refHelper, monitor); //$NON-NLS-1$
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
// use getAllTypesOfCodes to avoid NPE
// the ERepositoryObjectType may not load on current license
deleteRefProject(codeType, refHelper, monitor);
}
}
@@ -916,7 +916,7 @@ public class DefaultRunProcessService implements IRunProcessService {
IPath refPath = codeFile.getProjectRelativePath();
IFolder targetFolder = mainProject.getFolder(refPath.removeLastSegments(1));
if (!targetFolder.exists()) {
targetFolder.create(true, false, progressMonitor);
ResourceUtils.createFolder(targetFolder);
}
FilesUtils.copyDirectory(new File(codeFile.getLocation().toPortableString()),
new File(targetFolder.getLocation().toPortableString()));

View File

@@ -427,6 +427,11 @@ public class RunProcessService implements IRunProcessService {
return delegateService.getTalendJobJavaProject(property);
}
@Override
public IFolder getCodeSrcFolder(ERepositoryObjectType type, String projectTechName) {
return delegateService.getCodeSrcFolder(type, projectTechName);
}
@Override
public ITalendProcessJavaProject getTempJavaProject() {
return delegateService.getTempJavaProject();

View File

@@ -150,6 +150,7 @@ import org.talend.designer.runprocess.i18n.Messages;
import org.talend.designer.runprocess.prefs.RunProcessPrefsConstants;
import org.talend.designer.runprocess.utils.JobVMArgumentsUtil;
import org.talend.repository.ProjectManager;
import org.talend.repository.utils.EmfModelUtils;
import org.talend.repository.utils.EsbConfigUtils;
import org.talend.utils.io.FilesUtils;
@@ -353,16 +354,39 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
outputFolder = tProcessJavaProject.getTestOutputFolder();
} else {
srcFolder = tProcessJavaProject.getSrcFolder();
boolean needsToHaveContextInsideJar = true;
if (property != null && property.getItem() instanceof ProcessItem) {
needsToHaveContextInsideJar = !new BigDataJobUtil(process).needsToHaveContextInsideJar();
boolean needContextInJar = false;
if (process != null) {
needContextInJar = new BigDataJobUtil(process).needsToHaveContextInsideJar();
if (ProcessorUtilities.getMainJobInfo() != null) {
if (ProcessorUtilities.getMainJobInfo().getProcess() != null) {
if (ProcessorUtilities.isEsbJob(ProcessorUtilities.getMainJobInfo().getProcess(), true)
|| "CAMEL".equals(ProcessorUtilities.getMainJobInfo().getProcess().getComponentsType())) {
if (property.getItem() instanceof ProcessItem) {
if (!needContextInJar) {
if (null != EmfModelUtils.getComponentByName((ProcessItem) property.getItem(), "tRunJob",
"cTalendJob")) {
needContextInJar = false;
} else {
if (ProcessorUtilities.isEsbJob(process, true)) {
needContextInJar = false;
} else {
needContextInJar = true;
}
}
}
} else if (property.getItem().eClass().getClassifierID() == 4) {
// CamelPropertiesPackage Line 516 int ROUTELET_PROCESS_ITEM = 4;
needContextInJar = true;
}
}
}
}
}
if (ProcessorUtilities.isExportConfig() && property != null && needsToHaveContextInsideJar) {
resourcesFolder = tProcessJavaProject.getExternalResourcesFolder();
} else {
if (needContextInJar) {
resourcesFolder = tProcessJavaProject.getResourcesFolder();
} else {
resourcesFolder = tProcessJavaProject.getExternalResourcesFolder();
}
outputFolder = tProcessJavaProject.getOutputFolder();
}
@@ -1850,6 +1874,58 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
copyEsbConfigFile(esbConfigsSourceFolder, esbConfigsTargetFolder, "oidc.properties"); //$NON-NLS-1$
}
}
try {
ITalendProcessJavaProject tProcessJvaProject = this.getTalendJavaProject();
if (tProcessJvaProject == null) {
return;
}
Item item = property.getItem();
if (item == null) {
// may be a guess schema process
return;
}
IFolder externalResourcesFolder = tProcessJvaProject.getExternalResourcesFolder();
IFolder resourcesFolder = tProcessJvaProject.getResourcesFolder();
String jobClassPackageFolder = JavaResourcesHelper.getJobClassPackageFolder(item, false);
IPath jobContextFolderPath = new Path(jobClassPackageFolder).append(JavaUtils.JAVA_CONTEXTS_DIRECTORY);
IFolder extResourcePath = externalResourcesFolder.getFolder(jobContextFolderPath);
IFolder resourcesPath = resourcesFolder.getFolder(jobContextFolderPath);
if (!extResourcePath.exists()) {
tProcessJvaProject.createSubFolder(null, externalResourcesFolder, jobContextFolderPath.toString());
}
if (!extResourcePath.isSynchronized(IResource.DEPTH_INFINITE)) {
extResourcePath.refreshLocal(IResource.DEPTH_INFINITE, null);
}
if (!resourcesPath.exists()) {
tProcessJvaProject.createSubFolder(null, resourcesFolder, jobContextFolderPath.toString());
}
if (!resourcesPath.isSynchronized(IResource.DEPTH_INFINITE)) {
resourcesPath.refreshLocal(IResource.DEPTH_INFINITE, null);
}
for (IResource resource : extResourcePath.members()) {
IFile context = resourcesPath.getFile(resource.getName());
if (context.exists()) {
context.delete(true, null);
}
resource.copy(context.getFullPath(), true, null);
}
if (!resourcesPath.isSynchronized(IResource.DEPTH_INFINITE)) {
resourcesPath.refreshLocal(IResource.DEPTH_INFINITE, null);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**

View File

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

View File

@@ -3138,6 +3138,15 @@
name="changeDBVersionForMapROJAIOutputMigrationTask"
version="7.0.1">
</projecttask>
<projecttask
beforeLogon="false"
breaks="7.1.0"
class="org.talend.repository.model.migration.SAPBAPIParameterTypeMigrationTask"
description="adjust the tsapbapi ui"
id="org.talend.repository.model.migration.SAPBAPIParameterTypeMigrationTask"
name="SAPBAPIParameterTypeMigrationTask"
version="7.1.1">
</projecttask>
</extension>
<extension

View File

@@ -1027,4 +1027,8 @@ ArtifactRepositoryShareSettingPage.checkLabel=Check connection
ArtifactRepositoryShareSettingPage.showWarnDialogWhenInstallingFeatures=Show warn dialog when installing component
ArtifactRepositoryShareSettingPage.autoCheckUpdate=Check update automatically
ArtifactRepositoryShareSettingPage.checkUpdatePerDays=Check update frequency(days)
ArtifactRepositoryShareSettingPage.checkUpdatePerDays.error=Please input an interger between {0} and {1} for [{2}]
ArtifactRepositoryShareSettingPage.checkUpdatePerDays.error=Please input an interger between {0} and {1} for [{2}]
ConnectionsDialog.usernameOrPasswordInvalid=Check your username or password or contact your administrator.
LoginProjectPage.authorizationErrorMessage=Invalid username or password for the remote connection. Do you want to fix it now?
LoginProjectPage.errorMessageTitle=Error

View File

@@ -0,0 +1,109 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.model.migration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.components.ComponentUtilities;
import org.talend.core.model.components.ModifyComponentsAction;
import org.talend.core.model.components.conversions.IComponentConversion;
import org.talend.core.model.components.filters.IComponentFilter;
import org.talend.core.model.components.filters.NameComponentFilter;
import org.talend.core.model.migration.AbstractJobMigrationTask;
import org.talend.core.model.properties.Item;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ElementValueType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
public class SAPBAPIParameterTypeMigrationTask extends AbstractJobMigrationTask {
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
String[] componentsName = new String[] { "tSAPBapi" };
try {
for (String element : componentsName) {
IComponentFilter filter = new NameComponentFilter(element);
ModifyComponentsAction.searchAndModify(item, processType, filter,
Arrays.<IComponentConversion>asList(new IComponentConversion() {
@SuppressWarnings("unchecked")
@Override
public void transform(NodeType node) {
ElementParameterType mapping_input = ComponentUtilities.getNodeProperty(node,
"MAPPING_INPUT");
TalendFileFactory fileFact = TalendFileFactory.eINSTANCE;
if (mapping_input != null) {
List<ElementValueType> newElementValues = new ArrayList<ElementValueType>();
List<ElementValueType> elementValues = mapping_input.getElementValue();
boolean tableType = false;
for (ElementValueType elementValue : elementValues) {
if ("TYPE".equals(elementValue.getElementRef())
&& "TABLE".equals(elementValue.getValue())) {
tableType = true;
}
if ("CHANGING".equals(elementValue.getElementRef())) {
ElementValueType value = fileFact.createElementValueType();
value.setElementRef("PARAMETER_TYPE");
boolean is_changing_parameter = "true".equalsIgnoreCase(elementValue.getValue());
if (tableType) {
value.setValue(is_changing_parameter ? "CHANGING" : "TABLES");
} else {
value.setValue(is_changing_parameter ? "CHANGING" : "IMPORT");
}
newElementValues.add(value);
tableType = false;
continue;
}
newElementValues.add(elementValue);
}
elementValues.clear();
elementValues.addAll(newElementValues);
}
}
}));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2021, 1, 22, 18, 0, 0);
return gc.getTime();
}
}

View File

@@ -267,6 +267,10 @@ public abstract class AbstractLoginActionPage extends AbstractActionPage {
protected List<StyleRange> errStyleRange;
protected Throwable authException;
protected boolean hasAuthException = false;
public void clearAllMessages() {
errMessage = null;
warnMessage = null;
@@ -275,6 +279,8 @@ public abstract class AbstractLoginActionPage extends AbstractActionPage {
warnStyleRange = null;
infoStyleRange = null;
loginDialog.clearErrorMessage();
authException = null;
hasAuthException = false;
}
public void hideAllMessages() {
@@ -345,5 +351,21 @@ public abstract class AbstractLoginActionPage extends AbstractActionPage {
return hasError;
}
public Throwable getAuthException() {
return authException;
}
public void setAuthException(Throwable authException) {
this.authException = authException;
}
public boolean isHasAuthException() {
return hasAuthException;
}
public void setHasAuthException(boolean hasAuthException) {
this.hasAuthException = hasAuthException;
}
}
}

View File

@@ -38,6 +38,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.exception.BusinessException;
import org.talend.commons.exception.ClientException;
import org.talend.commons.exception.CommonExceptionHandler;
import org.talend.commons.exception.LoginException;
import org.talend.commons.exception.OperationCancelException;
@@ -470,6 +471,10 @@ public class LoginHelper {
}
public boolean logIn(ConnectionBean connBean, final Project project) {
return logIn(connBean, project, null);
}
public boolean logIn(ConnectionBean connBean, final Project project, ErrorManager errorManager) {
final ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
final boolean needRestartForLocal = needRestartForLocal(connBean);
if (connBean == null || project == null || project.getLabel() == null) {
@@ -555,6 +560,11 @@ public class LoginHelper {
}
});
} else if (isAuthorizationException(e.getTargetException()) && errorManager != null) {
errorManager.setHasAuthException(true);
errorManager.setAuthException(e.getTargetException());
errorManager.setErrMessage(
Messages.getString("LoginComposite.errorMessages1") + ":\n" + e.getTargetException().getMessage());//$NON-NLS-1$ //$NON-NLS-2$
} else {
MessageBoxExceptionHandler.process(e.getTargetException(), getUsableShell());
}
@@ -576,6 +586,17 @@ public class LoginHelper {
return true;
}
public static boolean isAuthorizationException(Throwable exception) {
boolean flag = false;
if (exception instanceof ClientException) {
ClientException e = (ClientException) exception;
if (e.getHttpCode() != null && e.getHttpCode() == 401) {
flag = true;
}
}
return flag;
}
public void saveUpdateStatus(Project project) throws JSONException {
Context ctx = CoreRuntimePlugin.getInstance().getContext();
RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
@@ -705,6 +726,10 @@ public class LoginHelper {
initialized = true;
} catch (Throwable e) {
if (isAuthorizationException(e)) {
errorManager.setHasAuthException(true);
errorManager.setAuthException(e);
}
projects = new Project[0];
if (errorManager != null) {
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());//$NON-NLS-1$

View File

@@ -51,6 +51,8 @@ import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
@@ -691,12 +693,15 @@ public class LoginProjectPage extends AbstractLoginActionPage {
}
checkErrors();
validateUpdate();
if (errorManager.isHasAuthException()) {
handleOpenConnectionsDialog(true);
}
} catch (PersistenceException e) {
CommonExceptionHandler.process(e);
} catch (JSONException e) {
CommonExceptionHandler.process(e);
} finally {
TalendProxySelector.getInstance();
TalendProxySelector.checkProxy();
}
}
@@ -871,40 +876,18 @@ public class LoginProjectPage extends AbstractLoginActionPage {
@Override
public void widgetSelected(SelectionEvent e) {
try {
ConnectionsDialog connectionsDialog = new ConnectionsDialog(getShell());
int open = connectionsDialog.open();
if (open == Window.OK) {
List<ConnectionBean> storedConnections = connectionsDialog.getConnections();
loginHelper.setStoredConnections(storedConnections);
loginHelper.saveConnections();
fillUIContentsWithBusyCursor();
final ConnectionBean connection = getConnection();
if (connection == null) {
checkErrors();
return;
}
// beforeConnBean = connection;
handleOpenConnectionsDialog(false);
}
});
updateServerFields();
finishButton.addPaintListener(new PaintListener() {
// Validate data
if (validateFields()) {
fillUIProjectListWithBusyCursor();
validateProject();
}
checkErrors();
validateUpdate();
} else if (!LoginHelper.isRemotesConnection(getConnection())) {
fillUIProjectListWithBusyCursor();
validateProject();
checkErrors();
}
// setStatusArea();
} catch (PersistenceException e1) {
CommonExceptionHandler.process(e1);
} catch (JSONException e2) {
CommonExceptionHandler.process(e2);
@Override
public void paintControl(PaintEvent e) {
finishButton.removePaintListener(this);
// for start, page showed complete
if (errorManager.isHasAuthException()) {
handleOpenConnectionsDialog(true);
}
}
});
@@ -913,6 +896,9 @@ public class LoginProjectPage extends AbstractLoginActionPage {
@Override
public void widgetSelected(SelectionEvent e) {
// reset flag to connect again
errorManager.setAuthException(null);
errorManager.setHasAuthException(false);
cancelAndClearFetchJobs();
LoginProjectPage.this.selectedProjectBeforeRefresh = getProject() == null ? null : getProject().getLabel();
// Validate data
@@ -930,6 +916,9 @@ public class LoginProjectPage extends AbstractLoginActionPage {
}
setRepositoryContextInContext();
LoginProjectPage.this.selectedProjectBeforeRefresh = null;
if (errorManager.isHasAuthException()) {
handleOpenConnectionsDialog(true);
}
}
});
@@ -1033,7 +1022,7 @@ public class LoginProjectPage extends AbstractLoginActionPage {
}
// should save before login, since svn related codes will read them
saveLastUsedProjectAndBranch();
boolean isLogInOk = loginHelper.logIn(getConnection(), getProject());
boolean isLogInOk = loginHelper.logIn(getConnection(), getProject(), errorManager);
if (isLogInOk) {
LoginHelper.setAlwaysAskAtStartup(alwaysAsk.getSelection());
loginDialog.okPressed();
@@ -1042,6 +1031,9 @@ public class LoginProjectPage extends AbstractLoginActionPage {
} else {
fillUIProjectListWithBusyCursor();
revertUpdateStatus();
if (errorManager.isHasAuthException()) {
handleOpenConnectionsDialog(true);
}
}
}
}
@@ -1121,6 +1113,61 @@ public class LoginProjectPage extends AbstractLoginActionPage {
return true;
}
public void handleOpenConnectionsDialog(boolean showError) {
try {
if (showError && errorManager.isHasAuthException()) {
String[] dialogButtonLabels = new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL };
MessageDialog dialog = new ExceptionMessageDialog(getShell(),
Messages.getString("LoginProjectPage.errorMessageTitle"), null, //$NON-NLS-1$
Messages.getString("LoginProjectPage.authorizationErrorMessage"), MessageDialog.ERROR, //$NON-NLS-1$
dialogButtonLabels, 0, errorManager.getAuthException());
if (dialog.open() == Window.CANCEL) {
return;
}
}
ConnectionsDialog connectionsDialog = new ConnectionsDialog(getShell(), getConnection(),
errorManager.isHasAuthException());
int open = connectionsDialog.open();
if (open == Window.OK) {
List<ConnectionBean> storedConnections = connectionsDialog.getConnections();
loginHelper.setStoredConnections(storedConnections);
loginHelper.saveConnections();
// reset flag to connect again
errorManager.setAuthException(null);
errorManager.setHasAuthException(false);
fillUIContentsWithBusyCursor();
final ConnectionBean connection = getConnection();
if (connection == null) {
checkErrors();
return;
}
// beforeConnBean = connection;
updateServerFields();
// Validate data
if (validateFields()) {
fillUIProjectListWithBusyCursor();
validateProject();
}
checkErrors();
validateUpdate();
if (errorManager.isHasAuthException()) {
handleOpenConnectionsDialog(true);
}
} else if (!LoginHelper.isRemotesConnection(getConnection())) {
fillUIProjectListWithBusyCursor();
validateProject();
checkErrors();
}
// setStatusArea();
} catch (PersistenceException e1) {
CommonExceptionHandler.process(e1);
} catch (JSONException e2) {
CommonExceptionHandler.process(e2);
}
}
private void revertUpdateStatus() {
Context ctx = CoreRuntimePlugin.getInstance().getContext();
RepositoryContext repositoryContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
@@ -1305,7 +1352,12 @@ public class LoginProjectPage extends AbstractLoginActionPage {
protected void refreshNecessaryVisible(boolean isRemote) {
boolean isSVNPluginLoaded = PluginChecker.isSVNProviderPluginLoaded();
refreshCreateSandboxProjectVisible(isNeedSandboxProject());
boolean needSandboxProject = isRemote;
if (!errorManager.isHasAuthException()) {
// connect administrator exist error, avoid check isNeedSandboxProject from remote
needSandboxProject = isNeedSandboxProject();
}
refreshCreateSandboxProjectVisible(needSandboxProject);
refreshImportLocalProjectVisible(!isRemote);
refreshImportDemoProjectVisible(!isRemote);
refreshCreateNewProjectVisible(!isRemote);
@@ -1314,7 +1366,7 @@ public class LoginProjectPage extends AbstractLoginActionPage {
Control projectListAreaBottomControl = null;
if (isSVNPluginLoaded) {
if (isRemote) {
if (isNeedSandboxProject()) {
if (needSandboxProject) {
projectListAreaBottomControl = createSandBoxProject;
} else {
projectListAreaBottomControl = navigateArea;
@@ -1513,6 +1565,10 @@ public class LoginProjectPage extends AbstractLoginActionPage {
}
protected void validateUpdate() throws JSONException {
if (errorManager.isHasAuthException()) {
// can't connect to remote
return;
}
final ConnectionBean currentBean = getConnection();
String repositoryId = null;
// at 1st time open the studio there are no bean at all,so need avoid NPE
@@ -1815,7 +1871,10 @@ public class LoginProjectPage extends AbstractLoginActionPage {
*/
protected void fillUIProjectList() {
Project[] projects = loginHelper.getProjects(getConnection(), errorManager);
Project[] projects = null;
if (!errorManager.isHasAuthException()) {
projects = loginHelper.getProjects(getConnection(), errorManager);
}
if (projects == null) {
projects = new Project[0];
}

View File

@@ -62,6 +62,10 @@ public class ConnectionsDialog extends TitleAreaDialog {
public static final int HSPACE = 5;
private ConnectionBean defaultConnectionSelected;
private boolean hasAuthorizationError = false;
public ConnectionsDialog(Shell parentShell) {
super(parentShell);
setShellStyle(getShellStyle() | SWT.RESIZE);
@@ -71,6 +75,15 @@ public class ConnectionsDialog extends TitleAreaDialog {
setTitleAreaColor(new RGB(255, 255, 255));
}
public ConnectionsDialog(Shell parentShell, ConnectionBean defaultConnectionSelected, boolean hasAuthorizationError) {
super(parentShell);
setShellStyle(getShellStyle() | SWT.RESIZE);
setTitleImage();
setTitleAreaColor(new RGB(255, 255, 255));
this.defaultConnectionSelected = defaultConnectionSelected;
this.hasAuthorizationError = hasAuthorizationError;
}
protected void setTitleImage() {
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(
IBrandingService.class);
@@ -121,7 +134,7 @@ public class ConnectionsDialog extends TitleAreaDialog {
layout.verticalSpacing = 0;
container.setLayout(layout);
listComposite = new ConnectionsListComposite(container, SWT.NONE);
listComposite = new ConnectionsListComposite(container, SWT.NONE, this);
GridDataFactory.fillDefaults().hint(LIST_COMPOSITE_WIDTH, SWT.DEFAULT).grab(false, true).applyTo(listComposite);
formComposite = new ConnectionFormComposite(container, SWT.NONE, listComposite, this);
@@ -130,6 +143,10 @@ public class ConnectionsDialog extends TitleAreaDialog {
Label titleBarSeparator = new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
titleBarSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (defaultConnectionSelected != null && hasAuthorizationError) {
setErrorMessage(Messages.getString("ConnectionsDialog.usernameOrPasswordInvalid"));
}
return composite;
}
@@ -137,4 +154,8 @@ public class ConnectionsDialog extends TitleAreaDialog {
return listComposite.getList();
}
public ConnectionBean getDefaultConnectionSelected() {
return defaultConnectionSelected;
}
}

View File

@@ -19,6 +19,7 @@ import java.util.List;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TextCellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
@@ -60,6 +61,8 @@ import org.talend.repository.ui.login.LoginHelper;
*/
public class ConnectionsListComposite extends Composite {
private ConnectionsDialog dialog;
private FormToolkit toolkit;
private AbstractDataTableEditorView<ConnectionBean> table;
@@ -79,9 +82,10 @@ public class ConnectionsListComposite extends Composite {
* @param parent
* @param style
*/
public ConnectionsListComposite(Composite parent, int style) {
public ConnectionsListComposite(Composite parent, int style, ConnectionsDialog dialog) {
super(parent, style);
this.dialog = dialog;
// PreferenceManipulator prefManipulator = new
// PreferenceManipulator(CorePlugin.getDefault().getPreferenceStore());
// list = prefManipulator.readConnections();
@@ -236,13 +240,39 @@ public class ConnectionsListComposite extends Composite {
});
if (!list.isEmpty()) {
ConnectionBean selectConnection = null;
ConnectionBean defaultConnectionSelected = dialog.getDefaultConnectionSelected();
for (int i = 0; i < list.size(); i++) {
setSelectedConnection(list.get(i));
ConnectionBean connectionBean = list.get(i);
setSelectedConnection(connectionBean);
if (isTheSameConnection(connectionBean, defaultConnectionSelected)) {
selectConnection = connectionBean;
}
}
if (selectConnection != null) {
table.getTableViewerCreator().getTableViewer()
.setSelection(new StructuredSelection(new Object[] { selectConnection }));
} else {
table.getTableViewerCreator().getTableViewer()
.setSelection(new StructuredSelection(new Object[] { list.get(0) }));
}
setSelectedConnection(list.get(0));
}
}
private boolean isTheSameConnection(ConnectionBean baseConnection, ConnectionBean refConnection) {
boolean flag = false;
if (baseConnection == null || refConnection == null) {
return flag;
}
if (baseConnection.getName().equals(refConnection.getName())
&& baseConnection.getUrl().equals(refConnection.getUrl())
&& baseConnection.getRepositoryId().equals(refConnection.getRepositoryId())
&& baseConnection.getUser().equals(refConnection.getUser())) {
flag = true;
}
return flag;
}
private void setSelectedConnection(ConnectionBean selected) {
connectionsFormComposite.setConnection(selected);
}

View File

@@ -13,11 +13,7 @@
package org.talend.repository.ui.wizards.exportjob.handler;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.BooleanUtils;
@@ -33,11 +29,9 @@ import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.CorePlugin;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.PluginChecker;
import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Project;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.runtime.process.IBuildJobHandler;
import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.runtime.process.LastGenerationInfo;
@@ -48,6 +42,7 @@ import org.talend.core.runtime.repository.build.IBuildResourcesProvider;
import org.talend.core.runtime.util.ParametersUtil;
import org.talend.core.services.ICoreTisService;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.runprocess.IProcessor;
import org.talend.designer.runprocess.IRunProcessService;
import org.talend.designer.runprocess.ProcessorUtilities;
import org.talend.repository.ProjectManager;
@@ -389,19 +384,9 @@ public abstract class AbstractBuildJobHandler implements IBuildJobHandler, IBuil
parameters.put(VERSION, version);
parameters.put(OBJ_PROCESS_JAVA_PROJECT, talendProcessJavaProject);
//
List<Item> dependenciesItems = new ArrayList<Item>();
Collection<IRepositoryViewObject> allProcessDependencies = ProcessUtils
.getAllProcessDependencies(Arrays.asList(processItem));
if (!allProcessDependencies.isEmpty()) {
for (IRepositoryViewObject repositoryObject : allProcessDependencies) {
dependenciesItems.add(repositoryObject.getProperty().getItem());
}
parameters.put(OBJ_ITEM_DEPENDENCIES, dependenciesItems);
}
// generate sources
generateJobFiles(monitor);
IProcessor processor = generateJobFiles(monitor);
parameters.put(OBJ_ITEM_DEPENDENCIES, processor.getBuildChildrenJobs());
// export items
if (ParametersUtil.hasBoolFlag(parameters, OPTION_ITEMS)) {

View File

@@ -14,12 +14,12 @@ package org.talend.sdk.component.studio.metadata.migration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IResourceRuleFactory;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -29,7 +29,6 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.LoginException;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.model.general.Project;
import org.talend.core.model.properties.ConnectionItem;
@@ -42,6 +41,8 @@ import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.update.RepositoryUpdateManager;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.repository.model.VersionList;
import org.talend.core.repository.utils.ComponentsJsonModel;
import org.talend.core.repository.utils.ProjectDataJsonProvider;
import org.talend.designer.core.model.utils.emf.talendfile.impl.NodeTypeImpl;
import org.talend.designer.core.model.utils.emf.talendfile.impl.ProcessTypeImpl;
import org.talend.repository.ProjectManager;
@@ -91,11 +92,36 @@ public class TaCoKitMigrationManager {
ExceptionHandler.process(e);
}
}
// as for it will do migration for all project, need to cache config component to component.index file
// under .setting folder from all project
List<ComponentsJsonModel> adaptComponentIndexJson = adaptComponentIndexJson(nodes.values());
for (final Project project : getAllProjects()) {
ProjectDataJsonProvider.saveConfigComponent(project.getTechnicalLabel(), adaptComponentIndexJson);
}
}
}
checkJobsMigration(monitor);
}
public static List<ComponentsJsonModel> adaptComponentIndexJson(Collection<ConfigTypeNode> ConfigTypeNodes) {
List<ComponentsJsonModel> modelList = new LinkedList<ComponentsJsonModel>();
for (ConfigTypeNode configTypeNode : ConfigTypeNodes) {
ComponentsJsonModel model = new ComponentsJsonModel();
model.setId(configTypeNode.getId());
model.setVersion(String.valueOf(configTypeNode.getVersion()));
model.setName(configTypeNode.getName());
model.setDisplayName(configTypeNode.getDisplayName());
model.setParentId(configTypeNode.getParentId());
model.setEdges(configTypeNode.getEdges());
model.setConfigurationType(configTypeNode.getConfigurationType());
model.setActions(configTypeNode.getActions());
model.setProperties(configTypeNode.getProperties());
modelList.add(model);
}
return modelList;
}
private void checkJobsMigration(final IProgressMonitor monitor) throws UserCancelledException {
monitor.subTask(Messages.getString("migration.check.process.checking")); //$NON-NLS-1$
final ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();

View File

@@ -13,10 +13,18 @@
package org.talend.sdk.component.studio.service;
import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.talend.commons.runtime.service.ITaCoKitService;
import org.talend.core.repository.utils.ComponentsJsonModel;
import org.talend.core.repository.utils.ProjectDataJsonProvider;
import org.talend.sdk.component.server.front.model.ConfigTypeNode;
import org.talend.sdk.component.studio.Lookups;
import org.talend.sdk.component.studio.metadata.TaCoKitCache;
import org.talend.sdk.component.studio.metadata.migration.TaCoKitMigrationManager;
import org.talend.sdk.component.studio.toolbar.ReloadAction;
import org.talend.updates.runtime.service.ITaCoKitUpdateService;
@@ -38,4 +46,35 @@ public class TaCoKitService implements ITaCoKitService {
return ITaCoKitUpdateService.getInstance().isCar(file, monitor);
}
@Override
public boolean isNeedMigration(String projectLabel) throws Exception {
boolean isNeed = false;
TaCoKitCache currentCach = Lookups.taCoKitCache();
Collection<ConfigTypeNode> configTypeNodes = currentCach.getConfigTypeNodes().getNodes().values();
Map<String, String[]> lastConfigComponent = ProjectDataJsonProvider.getLastConfigComponent(projectLabel);
if (lastConfigComponent != null && lastConfigComponent.size() > 0) {
for (String id : lastConfigComponent.keySet()) {
// content{name,version,displayName}
String[] content = lastConfigComponent.get(id);
try {
ConfigTypeNode configTypeNode = currentCach.getConfigTypeNode(id);
if (configTypeNode.getVersion() != Integer.parseInt(content[1])) {
isNeed = true;
break;
}
} catch (IllegalArgumentException e) {
// means Config type not found for the id, nothing to do here
}
}
}
// if installed new component, need update
if (configTypeNodes.size() > lastConfigComponent.values().size()) {
List<ComponentsJsonModel> componentIndexJsons = TaCoKitMigrationManager.adaptComponentIndexJson(configTypeNodes);
ProjectDataJsonProvider.saveConfigComponent(projectLabel, componentIndexJsons);
}
return isNeed;
}
}

View File

@@ -18,9 +18,14 @@ import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.Test;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.process.IElement;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.process.INode;
@@ -143,6 +148,15 @@ public class ExpressionTest {
}
}
private ElementParameter createMockParameterWithLineInTable(String paramName, Map<String, Object> line) {
ElementParameter param = mock(ElementParameter.class);
when(param.getFieldType()).thenReturn(EParameterFieldType.TABLE);
when(param.getName()).thenReturn(paramName);
List<Map<String, Object>> list = Stream.of(line).collect(Collectors.toList());
when(param.getValue()).thenReturn(list);
return param;
}
@Test
public void testEvaluateDistrib_simplecase() {
List<IElementParameter> params = new ArrayList<>();
@@ -234,4 +248,16 @@ public class ExpressionTest {
"!DISTRIB[#LINK@NODE.CONNECTION.DISTRIBUTION, #LINK@NODE.CONNECTION.HIVE_VERSION].doSupportUseDatanodeHostname[]",
params, paramNode));
}
@Test
public void testEvaluateContains() {
List<IElementParameter> params = new ArrayList<>();
Map<String, Object> line = new LinkedHashMap<String, Object>() {{
put("ADDITIONAL_ARGUMENT", "'hive.import'");
put("ADDITIONAL_VALUE", "'true'");
}};
ElementParameter param1 = createMockParameterWithLineInTable("ADDITIONAL_JAVA", line);
params.add(param1);
assertTrue(Expression.evaluateContains("ADDITIONAL_JAVA CONTAINS {ADDITIONAL_ARGUMENT='hive.import', ADDITIONAL_VALUE='true'}", params));
}
}

View File

@@ -0,0 +1,100 @@
// ============================================================================
//
// 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.core.utils;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.talend.core.model.components.ComponentCategory;
import org.talend.core.model.components.IComponent;
import org.talend.core.model.process.EConnectionType;
import org.talend.core.model.process.IConnection;
import org.talend.core.model.process.IElementParameter;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
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.ui.editor.connections.Connection;
import org.talend.designer.core.ui.editor.nodes.Node;
import org.talend.designer.core.ui.editor.process.Process;
/**
* DOC class global comment. Detailled comment
*/
public class ParallelExecutionUtilsTest {
@Test
public void testIsExistPreviousParCo() {
IComponent tFixedFlowInputComponent = ComponentsFactoryProvider.getInstance().get("tFixedFlowInput",
ComponentCategory.CATEGORY_4_DI.getName());
IComponent tMysqlComponent = ComponentsFactoryProvider.getInstance().get("tMysqlInput",
ComponentCategory.CATEGORY_4_DI.getName());
IComponent tLogRowComponent = ComponentsFactoryProvider.getInstance().get("tLogRow",
ComponentCategory.CATEGORY_4_DI.getName());
IComponent tJavaComponent = ComponentsFactoryProvider.getInstance().get("tJava",
ComponentCategory.CATEGORY_4_DI.getName());
Property property = PropertiesFactory.eINSTANCE.createProperty();
Process process = new Process(property);
// case1 tJava->tFixedFlowInput->tLogRow
Node c1_Node = new Node(tJavaComponent, process);
Node c1_Node1 = new Node(tFixedFlowInputComponent, process);
Node c1_Node2 = new Node(tLogRowComponent, process);
Connection c1_conn = createConnection(c1_Node, c1_Node1, EConnectionType.FLOW_MAIN);
Connection c1_conn1 = createConnection(c1_Node1, c1_Node2, EConnectionType.FLOW_MAIN);
((List<IConnection>) c1_Node1.getIncomingConnections()).add(c1_conn);
((List<IConnection>) c1_Node2.getIncomingConnections()).add(c1_conn1);
Assert.assertFalse(ParallelExecutionUtils.isExistPreviousParCon(c1_Node2));
IElementParameter elementParameter = new ElementParameter(null);
elementParameter.setName(EParameterName.PARTITIONER.getName());
elementParameter.setValue(true);
((List<IElementParameter>) c1_conn1.getElementParameters()).add(elementParameter);
Assert.assertTrue(ParallelExecutionUtils.isExistPreviousParCon(c1_Node2));
// case2 assume tJava-(runIf)->tFixedFlowInput tJava-(onSubjobok)->tMysqlInput
// tMysqlInput-(onComponentOK)->tFixedFlowInput
// tMysqlInput-(main)->tLogRowComponent
// tLogRowComponent-(onComponentOk)->tJava
Node c2_Node = new Node(tJavaComponent, process);
Node c2_Node1 = new Node(tFixedFlowInputComponent, process);
Node c2_Node2 = new Node(tMysqlComponent, process);
Node c2_Node3 = new Node(tLogRowComponent, process);
Connection c2_conn = createConnection(c2_Node, c2_Node1, EConnectionType.RUN_IF);
Connection c2_conn1 = createConnection(c2_Node, c2_Node2, EConnectionType.ON_SUBJOB_OK);
Connection c2_conn2 = createConnection(c2_Node2, c2_Node1, EConnectionType.ON_COMPONENT_OK);
Connection c2_conn3 = createConnection(c2_Node2, c2_Node3, EConnectionType.FLOW_MAIN);
Connection c2_conn4 = createConnection(c2_Node3, c2_Node, EConnectionType.ON_COMPONENT_OK);
((List<IConnection>) c2_Node1.getIncomingConnections()).add(c2_conn);
((List<IConnection>) c2_Node2.getIncomingConnections()).add(c2_conn1);
((List<IConnection>) c2_Node1.getIncomingConnections()).add(c2_conn2);
((List<IConnection>) c2_Node3.getIncomingConnections()).add(c2_conn3);
((List<IConnection>) c2_Node.getIncomingConnections()).add(c2_conn4);
Assert.assertFalse(ParallelExecutionUtils.isExistPreviousParCon(c2_Node1));
((List<IElementParameter>) c2_conn3.getElementParameters()).add(elementParameter);
Assert.assertTrue(ParallelExecutionUtils.isExistPreviousParCon(c2_Node1));
}
private Connection createConnection(Node sourceNode, Node targetNode, EConnectionType connType) {
Connection connection = new Connection(sourceNode, targetNode, connType, false);
return connection;
}
}

View File

@@ -528,7 +528,6 @@ public class DbGenerationManagerTest extends DbGenerationManagerTestHelper {
contextManger.setDefaultContext(newContext);
when(process.getContextManager()).thenReturn(contextManger);
dbMapComponent.setProcess(process);
ExternalDbMapData externalData2 = new ExternalDbMapData();
DbMapComponent dbMapComponent2 = new DbMapComponent();
dbMapComponent2.setExternalData(externalData2);
@@ -770,4 +769,252 @@ public class DbGenerationManagerTest extends DbGenerationManagerTestHelper {
}
@Test
public void testSubQueryBuildSqlSelect() {
String schema = "";
String table1 = "table1";
String table2 = "table2";
String table3 = "table3";
List<IConnection> incomingConnections = new ArrayList<IConnection>();
String[] mainTableEntities = new String[] { "id", "column1", "column2" };
incomingConnections.add(mockConnection(schema, table1, mainTableEntities));
dbMapComponent.setIncomingConnections(incomingConnections);
ExternalDbMapData externalData = new ExternalDbMapData();
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
// main table
ExternalDbMapTable inputTable = new ExternalDbMapTable();
String mainTableName = "".equals(schema) ? table1 : schema + "." + table1;
// quote will be removed in the ui for connections ,so we do the same for test
String mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
inputTable.setTableName(mainTableNameNoQuote);
inputTable.setName(mainTableName);
List<ExternalDbMapEntry> entities = getMetadataEntities(mainTableEntities, new String[3]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
ExternalDbMapTable outputTable = new ExternalDbMapTable();
mainTableName = "".equals(schema) ? table2 : schema + "." + table2;
// quote will be removed in the ui for connections ,so we do the same for test
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
outputTable.setTableName(mainTableNameNoQuote);
outputTable.setName("table2");
String[] names = new String[] { "id", "column1", "column2" };
String mainTable = mainTableName;
String[] expressions = new String[] { "table1.id",
"CASE WHEN table1.column1 IS NULL THEN context.param1 ELSE table1.column1 END", "table1.column2" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
String[] whereNames = new String[] { "whereFilter" };
String[] whereExps = new String[] { "t.column2 = 'context.param2'" };
outputTable.setCustomWhereConditionsEntries(getMetadataEntities(whereNames, whereExps));
outputs.add(outputTable);
externalData.setInputTables(inputs);
externalData.setOutputTables(outputs);
dbMapComponent.setExternalData(externalData);
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
MetadataTable metadataTable = getMetadataTable(names);
metadataTable.setLabel("table2");
metadataList.add(metadataTable);
dbMapComponent.setMetadataList(metadataList);
JobContext newContext = new JobContext("Default");
List<IContextParameter> newParamList = new ArrayList<IContextParameter>();
newContext.setContextParameterList(newParamList);
JobContextParameter param = new JobContextParameter();
param.setName("schema");
newParamList.add(param);
process = mock(Process.class);
JobContextManager contextManger = new JobContextManager();
contextManger.setDefaultContext(newContext);
when(process.getContextManager()).thenReturn(contextManger);
dbMapComponent.setProcess(process);
ExternalDbMapData externalData2 = new ExternalDbMapData();
DbMapComponent dbMapComponent2 = new DbMapComponent();
dbMapComponent2.setExternalData(externalData2);
mainTableEntities = new String[] { "id", "column1", "column2" };
List<IConnection> outgoingConnections = new ArrayList<IConnection>();
Node map1 = mockNode(dbMapComponent);
outgoingConnections.add(mockConnection(map1, schema, table2, mainTableEntities));
dbMapComponent.setOutgoingConnections(outgoingConnections);
dbMapComponent2.setIncomingConnections(outgoingConnections);
inputs = new ArrayList<ExternalDbMapTable>();
outputs = new ArrayList<ExternalDbMapTable>();
// main table
inputTable = new ExternalDbMapTable();
mainTableName = "".equals(schema) ? table2 : schema + "." + table2;
// quote will be removed in the ui for connections ,so we do the same for test
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
inputTable.setTableName(mainTableNameNoQuote);
inputTable.setName("table2");
entities = getMetadataEntities(mainTableEntities, new String[3]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
outputTable = new ExternalDbMapTable();
mainTableName = "".equals(schema) ? table3 : schema + "." + table3;
// quote will be removed in the ui for connections ,so we do the same for test
mainTableNameNoQuote = TalendTextUtils.removeQuotes(mainTableName);
outputTable.setTableName(mainTableNameNoQuote);
outputTable.setName("table3");
names = new String[] { "id", "column1", "column2" };
mainTable = mainTableName;
expressions = new String[] { "table2.id", "table2.column1", "table2.column2" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
outputs.add(outputTable);
externalData2.setInputTables(inputs);
externalData2.setOutputTables(outputs);
dbMapComponent2.setExternalData(externalData2);
metadataList = new ArrayList<IMetadataTable>();
metadataTable = getMetadataTable(names);
metadataTable.setLabel("table3");
metadataList.add(metadataTable);
dbMapComponent2.setMetadataList(metadataList);
if (dbMapComponent2.getElementParameters() == null) {
dbMapComponent2.setElementParameters(Collections.EMPTY_LIST);
}
JobContextParameter param1 = new JobContextParameter();
param1.setName("param1");
newParamList.add(param1);
JobContextParameter param2 = new JobContextParameter();
param2.setName("param2");
newParamList.add(param2);
dbMapComponent2.setProcess(process);
outgoingConnections = new ArrayList<IConnection>();
outgoingConnections.add(mockConnection(schema, table3, mainTableEntities));
dbMapComponent2.setOutgoingConnections(outgoingConnections);
ElementParameter comName = new ElementParameter(dbMapComponent);
comName.setName("COMPONENT_NAME");
comName.setValue("tELTMap");
List<ElementParameter> list = new ArrayList<>();
list.add(comName);
dbMapComponent.setElementParameters(list);
dbManager = new GenericDbGenerationManager();
// should be:
// "SELECT
// table2.id, table2.column1, table2.column2
// FROM
// (
// SELECT
// table1.id AS id, CASE WHEN table1.column1 IS NULL THEN " +context.param1+ " ELSE table1.column1 END AS
// column1, table1.column2 AS column2
// FROM
// table1
// WHERE t.column2 = '" +context.param2+ "'
// ) table2"
String query = dbManager.buildSqlSelect(dbMapComponent2, "table3").replaceAll("\n", "");
String exceptQuery = "\"SELECT\n" + "table2.id, table2.column1, table2.column2\n" + "FROM\n" + " (\n" + " SELECT\n"
+ " table1.id AS id, CASE WHEN table1.column1 IS NULL THEN \" +context.param1+ \" ELSE table1.column1 END AS column1, table1.column2 AS column2\n"
+ " FROM\n" + " table1\n" + " WHERE t.column2 = '\" +context.param2+ \"'\n" + " ) table2\"";
assertEquals(exceptQuery.replaceAll("\n", "").trim(), query.trim());
}
@Test
/**
* Related Tuj task: TDI40720_tELTMap_InJoin
*/
public void testELTMapInJoin() {
String schema = "context.saphana_schema";
String inputTable1 = "TDI40745";
String inputTable2 = "TDI40745Out";
String outTable1 = "outrow";
dbMapComponent = new DbMapComponent();
List<IMetadataTable> metadataList = new ArrayList<IMetadataTable>();
MetadataTable metadataTable = getMetadataTable(new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" });
metadataTable.setLabel(schema + "." + outTable1);
metadataList.add(metadataTable);
dbMapComponent.setMetadataList(metadataList);
// main table
ExternalDbMapData externalData = new ExternalDbMapData();
List<ExternalDbMapTable> inputs = new ArrayList<ExternalDbMapTable>();
List<ExternalDbMapTable> outputs = new ArrayList<ExternalDbMapTable>();
// main table
ExternalDbMapTable inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + inputTable1);
inputTable.setName(schema + "." + inputTable1);
inputTable.setAlias("inrow");
List<ExternalDbMapEntry> entities = getMetadataEntities(new String[] { "newColumn", "newColumn1" }, new String[2]);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// lookup table
inputTable = new ExternalDbMapTable();
inputTable.setTableName(schema + "." + inputTable2);
inputTable.setName(schema + "." + inputTable2);
inputTable.setAlias("inrow1");
entities = getMetadataEntities(new String[] { "newColumn", "newColumn1" }, new String[2]);
ExternalDbMapEntry newColumn = entities.get(0);
newColumn.setExpression("inrow.newColumn");
newColumn.setOperator("=");
inputTable.setJoinType("INNER_JOIN");
newColumn.setJoin(true);
inputTable.setMetadataTableEntries(entities);
inputs.add(inputTable);
// output
ExternalDbMapTable outputTable = new ExternalDbMapTable();
outputTable.setName(schema + "." + outTable1);
String[] names = new String[] { "newColumn", "newColumn1" };
String[] expressions = new String[] { "inrow.newColumn", "inrow.newColumn1" };
outputTable.setMetadataTableEntries(getMetadataEntities(names, expressions));
outputs.add(outputTable);
externalData.setInputTables(inputs);
externalData.setOutputTables(outputs);
dbMapComponent.setExternalData(externalData);
List<IConnection> incomingConnections = new ArrayList<IConnection>();
incomingConnections.add(
mockConnection(schema, inputTable1, new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" }));
incomingConnections.add(
mockConnection(schema, inputTable2, new String[] { "newColumn", "newColumn1" }, new String[] { "id", "name" }));
dbMapComponent.setIncomingConnections(incomingConnections);
List<IConnection> outputConnections = new ArrayList<IConnection>();
Node map1 = mockNode(dbMapComponent);
IConnection connection = mockConnection(map1, schema, inputTable1, new String[] { "id", "name" });
connection.getMetadataTable().getColumn("id").setLabel("newColumn");
connection.getMetadataTable().getColumn("name").setLabel("newColumn1");
outputConnections.add(connection);
dbMapComponent.setOutgoingConnections(outputConnections);
Process process = mock(Process.class);
when(process.getContextManager()).thenReturn(new JobContextManager());
dbMapComponent.setProcess(process);
JobContext context = new JobContext("Default");
IContextParameter schemaContext = new JobContextParameter();
schemaContext.setName("saphana_schema");
schemaContext.setValue("saphana_schema");
schemaContext.setType("String");
context.getContextParameterList().add(schemaContext);
IContextParameter lookupTableContext = new JobContextParameter();
lookupTableContext.setName("lookup");
lookupTableContext.setValue("lookupTable");
lookupTableContext.setType("String");
context.getContextParameterList().add(lookupTableContext);
dbMapComponent.getProcess().getContextManager().setDefaultContext(context);
String query = dbManager.buildSqlSelect(dbMapComponent, schema + "." + outTable1);
String expectedQuery = "\"SELECT\n" + "inrow.id, inrow.name\n" + "FROM\n"
+ " \" +context.saphana_schema+\".\"+TDI40745+ \" inrow INNER JOIN \" +context.saphana_schema+\".\"+TDI40745Out+ \" inrow1 ON( inrow1.id = inrow.id )\"";
assertEquals(expectedQuery, query);
}
}

View File

@@ -284,6 +284,7 @@ public class PostgresGenerationManagerTest extends DbGenerationManagerTestHelper
String[] columns = new String[] { "_String", "_void" };
String[] dbColumns = new String[] { "String", "void", "age" };
String[] expressions = new String[] { schema + "." + tableName + "._String", schema + "." + tableName + "._void" };
init(schema, tableName, tableName);
initForExpression(schema, tableName, columns, dbColumns, "grade", columns, dbColumns, expressions);
ExternalDbMapTable externalData = dbMapComponent.getExternalData().getOutputTables().get(0);
ExternalDbMapEntry whereEntity = new ExternalDbMapEntry();
@@ -322,6 +323,7 @@ public class PostgresGenerationManagerTest extends DbGenerationManagerTestHelper
String[] outputColumns = new String[] { "name", "name_uppercase", "register" };
String[] expressions = new String[] { "context.schema.bugtdi32594_src.name",
"UPPER(context.schema.bugtdi32594_src.name)", "to_date(context.schema.bugtdi32594_src.register, 'yyyy-MM-dd')" };
init(schema, tableName, tableName);
initForExpression(schema, tableName, inputColumns, inputColumns, outputTable, outputColumns, outputColumns, expressions);
ExternalDbMapTable externalData = dbMapComponent.getExternalData().getOutputTables().get(0);
ExternalDbMapEntry whereEntity = new ExternalDbMapEntry();