Compare commits

...

35 Commits

Author SHA1 Message Date
vyu-talend
5e7fc98dc8 Fix(TDI-32477):Dynamic column includes the part of columns 2019-07-29 17:13:32 +08:00
vyu-talend
ec71042f02 Fix(TDI-32477):Enable when the type is Dynamic 2019-07-24 14:33:04 +08:00
vyu-talend
b3f5b32f71 Fix(TDI-32477):Always lowercase column's name and table in Postgresql 2019-07-24 14:33:03 +08:00
vyu-talend
bc27eb5a90 Fix(TDI-32477):Always lowercase column's name of postgres when create
table
2019-07-24 14:33:01 +08:00
hcyi
c7c9d4bf2d fix(TUP-23898):Create new plugin for junit tests of tacokit studio-integration. (#3740)
* fix(TUP-23898):Create new plugin for junit tests of tacokit
studio-integration.

* fix(TUP-23898):Create new plugin for junit tests of tacokit
studio-integration.

* fix(TUP-23898):Create new plugin for junit tests of tacokit
studio-integration.

* fix(TUP-23898):Create new plugin for junit tests of tacokit
studio-integration.
2019-07-23 18:29:29 +08:00
hcyi
4271923ca3 fix(TUP-23264):Studio can't find dependencies for tacokit components. (#3720)
* fix(TUP-23264):Studio can't find dependencies for tacokit components.

* fix(TUP-23264):add junits for Studio can't find dependencies for tacokit
components.
2019-07-23 12:03:00 +08:00
jiezhang-tlnd
70f0e7a076 fix(TUP-23588)For tCreateTable, the Database Type is always Mysql after dragging and dropping from database Metadata (#3714)
* fix(TUP-23588)For tCreateTable, the Database Type is always Mysql after
dragging and dropping from database Metadata
https://jira.talendforge.org/browse/TUP-23588

* junit(TUP-23588)For tCreateTable, the Database Type is always Mysql
after dragging and dropping from database Metadata

* fix(TUP-23588)For tCreateTable, the Database Type is always Mysql after
dragging and dropping from database Metadata

* fix(TUP-23588)For tCreateTable, the Database Type is always Mysql after
dragging and dropping from database Metadata

* fix(TUP-23588)For tCreateTable, the Database Type is always Mysql after
dragging and dropping from database Metadata

* fix(TUP-23588)For tCreateTable, the Database Type is always Mysql after
dragging and dropping from database Metadata
2019-07-23 11:20:25 +08:00
pyzhou
6e0af4dd99 fix(TDI-42674):Redshift missing jar for SSO (#3731)
* fix(TDI-42674):Redshift missing jar for SSO

* fix(TDI-42674):change mvn path

* fix(TDI-42674):change require to require_if
2019-07-22 17:23:21 +08:00
clesaec
26fbb4e014 TDI-42679 : use new File(rep, file) constructor (#3724) 2019-07-19 13:25:34 +02:00
dmytroshekera
28b472384b bugfix(TDI-42364): When building a Standalone job. (#3734)
Generated Powershell scripts, is wrong.
2019-07-19 12:51:04 +03:00
Zhiwei Xue
c0f93ad66b Revert fix of TUP-23729 (#3732)
* Revert "fix(TUP-23729):Memory issue found when run TUJ (#3705)"

This reverts commit 1d706bc243.

* Revert "fix(TUP-23729):Memory issue found when run TUJ (#3689)"

This reverts commit 5069b086d7.
2019-07-18 18:25:34 +08:00
slushatel
7a53a97ceb fix(TDI-42634): get attachments recursively (#3700)
* fix(TDI-42634): get attachments recursively

* fix(TDI-42634): change indents to 'space'
2019-07-18 10:55:05 +03:00
pyzhou
1c89042c03 fix(TDI-42572):upgrade EXAUtil version (#3719)
* fix(TDI-42572):upgrade EXAUtil version

* Change the mvn path
2019-07-18 10:01:06 +08:00
dmytroshekera
9133ff39d1 bugfix(TDI-42581): tSOAP doesn't support SOAPActions for Soap 1.2 (#3727)
param 'action' should not be empty
2019-07-17 14:40:51 +03:00
Zhiwei Xue
1d706bc243 fix(TUP-23729):Memory issue found when run TUJ (#3705) 2019-07-17 17:01:39 +08:00
dmytroshekera
24031c6bb0 Dshekera/tdi 42581 t soap doesnt support soap actions for soap 1 2 (#3725)
* bugfix(TDI-42581): tSOAP doesn't support SOAPActions for Soap 1.2
2019-07-16 16:44:14 +03:00
Chao MENG
5d7deb4f08 fix(TUP-23508): TOS can't use memory run (#3698)
https://jira.talendforge.org/browse/TUP-23508
2019-07-16 17:44:26 +08:00
kjwang-talend
2f323ea5ec TUP-23841 Build job with 'OSGI Bundle For ESB' get error pop-up (#3711)
https://jira.talendforge.org/browse/TUP-23841
2019-07-16 10:30:48 +08:00
kjwang-talend
0099cf4b7f Fix TUP-23809 [Studio] changes in column order are not saved (no (#3708)
propagate changes dialog)
https://jira.talendforge.org/browse/TUP-23809
2019-07-16 10:04:02 +08:00
vyu-talend
ad8b244f13 Fix(TDI-42572):Improvement for generating correct format to Exasol (#3677)
* Fix(TDI-42572):Improvement for generating correct format to Exasol

* Fix(TDI-42572):Using checkbox
2019-07-16 09:37:04 +08:00
slushatel
b4196f3ade feat(TDI-42570): stop process if parent thread has terminated, add log wrapper for tos studio (#3715) 2019-07-15 14:52:28 +03:00
Hanna Liashchuk
a6cc1fd725 fix(TBD-8951): skeap header for Service Account (#3716) 2019-07-15 14:18:45 +03:00
Hanna Liashchuk
6d2c08fb02 Revert "(feature(TBD-8945): added drop table checkbox to OAuth authentication mode (#3706)" (#3712)
This reverts commit b37f4d2169.
2019-07-15 13:04:28 +03:00
Hanna Liashchuk
b37f4d2169 (feature(TBD-8945): added drop table checkbox to OAuth authentication mode (#3706) 2019-07-15 12:55:50 +03:00
zshen-talend
18a6bd6b9e chor(TDQ-17069): remove unused code (#3617) 2019-07-15 15:53:33 +08:00
hcyi
12025462fd fix(TUP-23743):ERROR when Job in MDM project calling Job in Reference DI project:import routines.DataQuality cannot be resolved. (#3688)
* fix(TUP-23743):ERROR when Job in MDM project calling Job in Reference DI
project:import routines.DataQuality cannot be resolved.

* fix(TUP-23743):ERROR when Job in MDM project calling Job in Reference DI
project:import routines.DataQuality cannot be resolved.
2019-07-15 11:39:36 +08:00
hcyi
8a17273fff fix(TUP-23550):Select query for DBInput component page will list Couchbase. (#3704)
* fix(TUP-23550):Select query for DBInput component page will list
Couchbase.

* fix(TUP-23550):add junits
2019-07-15 10:33:04 +08:00
zshen-talend
4666ad0ba2 feat(TDQ-16777 TDQ-17239): added one migration for added encoding type (#3690)
of combo list.
2019-07-12 16:07:34 +08:00
Hanna Liashchuk
e99e3a88ac task(TBD-8950): Change redundant code appearance in tBigQueryBulkExec (#3703)
* (TBD-8950): code refactoring

* fix(TBD-8950): added postfix
2019-07-11 16:47:06 +03:00
Roman
eef7ee7939 fix(TDI-42436): copy Redshift components to cloud folder (#3702)
* fix(TDI-42436): copy Redshift components to cloud folder
2019-07-11 11:46:36 +03:00
wang wei
323b7fdf86 fix(TDI-42423): fix the tcreatetable for teradata with jdbc parameters(#3680) 2019-07-10 09:50:06 +08:00
slushatel
9e8d8785c2 Tdi 42570 stop process when thread stops (#3676)
* feat(TDI-42570): stop process if parent thread has terminated

* feat(TDI-42570): stop process if parent thread has terminated

* feat(TDI-42570): stop process if parent thread has terminated. improve indentation

* feat(TDI-42570): stop process if parent thread has terminated. improve indentation
2019-07-09 14:54:26 +03:00
hcyi
463d35acb2 fix(TUP-23790):Can't guess schema for metadata (#3691)
item(delimited/positional/regex/excel/ldif/ldap)
2019-07-09 18:21:16 +08:00
Zhiwei Xue
5069b086d7 fix(TUP-23729):Memory issue found when run TUJ (#3689) 2019-07-09 18:11:06 +08:00
Jane Ding
18694afab5 fix(TUP-23663)The connection row between components is getting activated (#3687)
* fix(TUP-23663)The connection row between components is getting activated
unexpectedly when using tMSXMLInput component
https://jira.talendforge.org/browse/TUP-23663

* fix(TUP-23663)The connection row between components is getting activated
unexpectedly when using tMSXMLInput component
https://jira.talendforge.org/browse/TUP-23663

* fix(TUP-23663)The connection row between components is getting activated
unexpectedly when using tMSXMLInput component
https://jira.talendforge.org/browse/TUP-23663

* fix(TUP-23663)The connection row between components is getting activated
unexpectedly when using tMSXMLInput component
https://jira.talendforge.org/browse/TUP-23663

* fix(TUP-23663)The connection row between components is getting activated
unexpectedly when using tMSXMLInput component
https://jira.talendforge.org/browse/TUP-23663
2019-07-09 17:49:22 +08:00
61 changed files with 2033 additions and 383 deletions

View File

@@ -55,5 +55,6 @@
<plugin id="org.talend.testutils" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
<plugin id="org.talend.updates.runtime.test" download-size="0" install-size="0" version="0.0.0" fragment="true" unpack="false"/>
<plugin id="org.talend.utils.test" download-size="0" install-size="0" version="0.0.0" fragment="true" unpack="false"/>
<plugin id="org.talend.sdk.component.studio-integration.test" download-size="0" install-size="0" version="0.0.0" fragment="true" unpack="false"/>
<plugin id="test.all.test.suite" download-size="0" install-size="0" version="0.0.0" unpack="false"/>
</feature>

View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.talend.libraries</groupId>
<artifactId>talend-soap</artifactId>
<version>2.1-20190513</version>
<version>2.1-20190716</version>
<packaging>jar</packaging>
<name>talend-soap</name>

View File

@@ -124,7 +124,9 @@ public class SOAPUtil {
}
SOAPMessage message = messageFactory.createMessage();
MimeHeaders mimeHeaders = message.getMimeHeaders();
mimeHeaders.setHeader("SOAPAction", soapAction);
setSoapAction(version, soapAction, mimeHeaders);
if (basicAuth) {
addBasicAuthHeader(mimeHeaders, username, password);
}
@@ -263,8 +265,8 @@ public class SOAPUtil {
}
SOAPMessage message = messageFactory.createMessage();
MimeHeaders mimeHeaders = message.getMimeHeaders();
mimeHeaders.setHeader("SOAPAction", soapAction);
SOAPPart soapPart = message.getSOAPPart();
setSoapAction(version, soapAction, mimeHeaders);
SOAPPart soapPart = message.getSOAPPart();
String encoding = getEncoding(soapMessage);
@@ -291,8 +293,20 @@ public class SOAPUtil {
return null;
}
}
private String getEncoding(String text) {
/* https://jira.talendforge.org/browse/TDI-42581 skip add SOAPAction directly to header v1.2 */
private void setSoapAction(String version, String soapAction, MimeHeaders mimeHeaders) {
if (SOAP12.equals(version)) {
// in soap version 1.2 param 'action' optional and should not be empty
if( soapAction != null && !soapAction.trim().isEmpty()) {
mimeHeaders.setHeader("Content-Type", "application/soap+xml; charset=utf-8; action=\"" + soapAction + "\"");
}
} else {
mimeHeaders.setHeader("SOAPAction", soapAction);
}
}
private String getEncoding(String text) {
String result = Charset.defaultCharset().name();
if(text == null) {

View File

@@ -7,7 +7,7 @@
<groupId>org.talend.libraries</groupId>
<artifactId>talend-db-exasol</artifactId>
<version>2.1.2</version>
<version>2.1.3</version>
<packaging>jar</packaging>
<name>talend-db-exasol</name>

View File

@@ -94,12 +94,11 @@ public class EXABulkUtil {
private String createNumberFormat(Integer length, Integer precision, boolean hasGroups) {
if (length != null && length.intValue() > 0) {
StringBuilder sb = new StringBuilder();
int numGroups = (length.intValue() / 3) + 1;
for (int i = 0; i < numGroups; i++) {
if (i > 0 && hasGroups) {
sb.append("G");
}
sb.append("999");
for (int i = length - 1; i >= 0; i--) {
if(hasGroups && i < length - 1 && i > 0 && (i % 3 == 2)) {
sb.append("G");
}
sb.append("9");
}
if (precision != null && precision.intValue() > 0) {
sb.append("D");

View File

@@ -7,6 +7,7 @@
<FAMILIES>
<FAMILY>Databases/DB Specifics/Amazon/Redshift</FAMILY>
<FAMILY>Cloud/Amazon/Redshift</FAMILY>
</FAMILIES>
<DOCUMENTATION>

View File

@@ -24,13 +24,14 @@
String dataset = ElementParameterParser.getValue(node, "__DATASET__");
String table = ElementParameterParser.getValue(node, "__TABLE__");
String gsFile = ElementParameterParser.getValue(node, "__GS_FILE__");
boolean setFieldDelimiter = ElementParameterParser.getBooleanValue(node, "__SET_FIELD_DELIMITER__");
String fieldDelimiter = ElementParameterParser.getValue(node, "__FIELD_DELIMITER__");
String actionOnData = ElementParameterParser.getValue(node, "__ACTION_ON_DATA__");
boolean dieOnError = "true".equals(ElementParameterParser.getValue(node, "__DIE_ON_ERROR__"));
boolean dieOnError = ElementParameterParser.getBooleanValue(node, "__DIE_ON_ERROR__");
boolean createTableIfNotExist = ElementParameterParser.getBooleanValue(node, "__CREATE_TABLE_IF_NOT_EXIST__");
String gsFileHeader = ElementParameterParser.getValue(node, "__GS_FILE_HEADER__");
String tokenFile = ElementParameterParser.getValue(node,"__TOKEN_NAME__");
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
boolean isLog4jEnabled = ElementParameterParser.getBooleanValue(node.getProcess(), "__LOG4J_ACTIVATE__");
String passwordFieldName = "";
@@ -201,7 +202,7 @@
} else {
throw new IllegalArgumentException("authentication mode should be either \"SERVICEACCOUNT\" or \"OAUTH\", but it is " + authMode);
}
boolean bulkFileAlreadyExists = "true".equals(ElementParameterParser.getValue(node, "__BULK_FILE_ALREADY_EXIST__"));
boolean bulkFileAlreadyExists = ElementParameterParser.getBooleanValue(node, "__BULK_FILE_ALREADY_EXIST__");
String accessKey = ElementParameterParser.getValue(node, "__GS_ACCESS_KEY__");
String secretKey = ElementParameterParser.getValue(node, "__GS_SECRET_KEY__");
String localFilename = ElementParameterParser.getValue(node, "__GS_LOCAL_FILE__");
@@ -234,6 +235,7 @@
}
%>
gsService_<%=cid%>.putObject(<%=bucketName%>, fileObject_<%=cid%>);
/* ----END-UPLOADING-FILE---- */
<%
if(isLog4jEnabled){
%>
@@ -242,7 +244,6 @@
}
}
%>
/* ----END-UPLOADING-FILE---- */
<%
if (authMode.equals("OAUTH")) {
@@ -259,7 +260,7 @@
com.google.api.services.bigquery.model.JobConfiguration config_<%=cid%> = new com.google.api.services.bigquery.model.JobConfiguration();
com.google.api.services.bigquery.model.JobConfigurationLoad queryLoad_<%=cid%> = new com.google.api.services.bigquery.model.JobConfigurationLoad();
if (<%=ElementParameterParser.getBooleanValue(node, "__CREATE_TABLE_IF_NOT_EXIST__")%>) {
<%if (createTableIfNotExist) { %>
com.google.api.services.bigquery.model.TableSchema schema_<%=cid%> = new com.google.api.services.bigquery.model.TableSchema();
<%
@@ -301,14 +302,7 @@
typeToGenerate = "string";
}
}
%>
<%
String modeType = null;
if (!column.isNullable()) {
modeType = "REQUIRED";
} else {
modeType = "NULLABLE";
}
String modeType = (!column.isNullable()) ? "REQUIRED" : "NULLABLE";
%>
com.google.api.services.bigquery.model.TableFieldSchema <%=columnName%>_<%=cid%> = new com.google.api.services.bigquery.model.TableFieldSchema();
<%=columnName%>_<%=cid%>.setName("<%=columnName%>");
@@ -331,9 +325,10 @@
queryLoad_<%=cid%>.setSchema(schema_<%=cid%>);
}
<%
if("true".equals(ElementParameterParser.getValue(node, "__CREATE_TABLE_IF_NOT_EXIST__"))) {
}
if(createTableIfNotExist) {
%>
queryLoad_<%=cid%>.setCreateDisposition("CREATE_IF_NEEDED");
<%
@@ -342,15 +337,13 @@
queryLoad_<%=cid%>.setCreateDisposition("CREATE_NEVER");
<%
}
if("true".equals(ElementParameterParser.getValue(node, "__SET_FIELD_DELIMITER__"))) {
if(setFieldDelimiter) {
%>
queryLoad_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>);
<%
}
%>
queryLoad_<%=cid%>.setAllowQuotedNewlines(true);
queryLoad_<%=cid%>.setWriteDisposition("WRITE_<%=actionOnData%>");
com.google.api.services.bigquery.model.TableReference destinationTable_<%=cid%> = new com.google.api.services.bigquery.model.TableReference();
destinationTable_<%=cid%>.setProjectId(PROJECT_ID_<%=cid%>);
@@ -358,8 +351,8 @@
destinationTable_<%=cid%>.setTableId(<%=table%>);
queryLoad_<%=cid%>.setDestinationTable(destinationTable_<%=cid%>);
queryLoad_<%=cid%>.setSourceUris(java.util.Arrays.asList(<%=ElementParameterParser.getValue(node, "__GS_FILE__")%>));
queryLoad_<%=cid%>.setSkipLeadingRows(<%=ElementParameterParser.getValue(node, "__GS_FILE_HEADER__")%>);
queryLoad_<%=cid%>.setSourceUris(java.util.Arrays.asList(<%=gsFile%>));
queryLoad_<%=cid%>.setSkipLeadingRows(<%=gsFileHeader%>);
queryLoad_<%=cid%>.setNullMarker("\\N");
config_<%=cid%>.setLoad(queryLoad_<%=cid%>);
@@ -465,7 +458,10 @@
com.google.cloud.bigquery.TableId tableId_<%=cid%> = com.google.cloud.bigquery.TableId.of(<%=projectId%>, <%=dataset%>, <%=table%>);
com.google.cloud.bigquery.Table table_<%=cid%> = bigquery_<%=cid%>.getTable(tableId_<%=cid%>);
com.google.cloud.bigquery.LoadJobConfiguration.Builder loadJobBuilder_<%=cid%> = com.google.cloud.bigquery.LoadJobConfiguration.newBuilder(tableId_<%=cid%>, <%=gsFile%>);
if (<%=ElementParameterParser.getBooleanValue(node, "__DROP__")%> && table_<%=cid%> != null) {
boolean dropTable_<%=cid%> = <%=ElementParameterParser.getBooleanValue(node, "__DROP__")%>;
if ( dropTable_<%=cid%> && table_<%=cid%> != null) {
boolean deleted = bigquery_<%=cid%>.delete(tableId_<%=cid%>);
if (deleted) {
<%
@@ -479,69 +475,66 @@
throw new RuntimeException("Unable to delete table " + tableId_<%=cid%>);
}
}
if (<%=ElementParameterParser.getBooleanValue(node, "__DROP__")%> || <%=ElementParameterParser.getBooleanValue(node, "__CREATE_TABLE_IF_NOT_EXIST__")%>) {
java.util.List<com.google.cloud.bigquery.Field> fields_<%=cid%> = new java.util.ArrayList<>();
<%
List<IMetadataTable> metadatas = node.getMetadataList();
if ((metadatas!=null) && (metadatas.size() > 0)) {
IMetadataTable metadata = metadatas.get(0);
if (metadata != null) {
List<IMetadataColumn> columns = metadata.getListColumns();
int nbColumns = columns.size();
for (int i = 0; i < nbColumns; i++ ) {
IMetadataColumn column = columns.get(i);
String columnName = column.getLabel();
String typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
if("id_String".equals(column.getTalendType()) || "id_Character".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
} else if ("id_Float".equals(column.getTalendType()) || "id_Double".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.FLOAT";
} else if ("id_Short".equals(column.getTalendType()) || "id_Integer".equals(column.getTalendType()) || "id_Long".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.INTEGER";
} else if ("id_BigDecimal".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.NUMERIC";
} else if ("id_Boolean".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.BOOLEAN";
} else if ("id_Date".equals(column.getTalendType())) {
String pattern = column.getPattern();
if(pattern.length() == 12 || pattern.isEmpty() || "\"\"".equals(pattern)) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.DATE";
}else if(pattern.length() > 12){
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.TIMESTAMP";
}else{
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
}
}
String modeType = "NULLABLE";
if (!column.isNullable()) {
modeType = "REQUIRED";
}
<%if(createTableIfNotExist){%>
if(table_<%=cid%> == null){
java.util.List<com.google.cloud.bigquery.Field> fields_<%=cid%> = new java.util.ArrayList<>();
<%
List<IMetadataTable> metadatas = node.getMetadataList();
if ((metadatas!=null) && (metadatas.size() > 0)) {
IMetadataTable metadata = metadatas.get(0);
if (metadata != null) {
List<IMetadataColumn> columns = metadata.getListColumns();
int nbColumns = columns.size();
for (int i = 0; i < nbColumns; i++ ) {
IMetadataColumn column = columns.get(i);
String columnName = column.getLabel();
String typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
if("id_String".equals(column.getTalendType()) || "id_Character".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
} else if ("id_Float".equals(column.getTalendType()) || "id_Double".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.FLOAT";
} else if ("id_Short".equals(column.getTalendType()) || "id_Integer".equals(column.getTalendType()) || "id_Long".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.INTEGER";
} else if ("id_BigDecimal".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.NUMERIC";
} else if ("id_Boolean".equals(column.getTalendType())) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.BOOLEAN";
} else if ("id_Date".equals(column.getTalendType())) {
String pattern = column.getPattern();
if(pattern.length() == 12 || pattern.isEmpty() || "\"\"".equals(pattern)) {
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.DATE";
}else if(pattern.length() > 12){
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.TIMESTAMP";
}else{
typeToGenerate = "com.google.cloud.bigquery.LegacySQLTypeName.STRING";
}
}
String modeType = (!column.isNullable()) ? "REQUIRED" : "NULLABLE";
%>
com.google.cloud.bigquery.Field field_<%=i%> = com.google.cloud.bigquery.Field.newBuilder("<%=columnName%>", <%=typeToGenerate%>)
.setMode(com.google.cloud.bigquery.Field.Mode.valueOf("<%=modeType%>"))
.build();
fields_<%=cid%>.add(field_<%=i%>);
<%
if(isLog4jEnabled){
%>
log.debug("<%=cid%> - Field index[<%=i%>] {\"name\":\"<%=columnName%>\",\"type\":\"<%=typeToGenerate%>\"}");
<%
<%
if(isLog4jEnabled){
%>
log.debug("<%=cid%> - Field index[<%=i%>] {\"name\":\"<%=columnName%>\",\"type\":\"<%=typeToGenerate%>\"}");
<%
}
}
}
}
}
%>
%>
com.google.cloud.bigquery.Schema schema_<%=cid%> = com.google.cloud.bigquery.Schema.of(fields_<%=cid%>);
com.google.cloud.bigquery.TableInfo tableInfo_<%=cid%> = com.google.cloud.bigquery.TableInfo.newBuilder(tableId_<%=cid%>, com.google.cloud.bigquery.StandardTableDefinition.of(schema_<%=cid%>)).build();
table_<%=cid%> = bigquery_<%=cid%>.create(tableInfo_<%=cid%>);
loadJobBuilder_<%=cid%>.setSchema(schema_<%=cid%>);
}
<%
if("true".equals(ElementParameterParser.getValue(node, "__CREATE_TABLE_IF_NOT_EXIST__"))) {
com.google.cloud.bigquery.Schema schema_<%=cid%> = com.google.cloud.bigquery.Schema.of(fields_<%=cid%>);
com.google.cloud.bigquery.TableInfo tableInfo_<%=cid%> = com.google.cloud.bigquery.TableInfo.newBuilder(tableId_<%=cid%>, com.google.cloud.bigquery.StandardTableDefinition.of(schema_<%=cid%>)).build();
table_<%=cid%> = bigquery_<%=cid%>.create(tableInfo_<%=cid%>);
loadJobBuilder_<%=cid%>.setSchema(schema_<%=cid%>);
}
<%}
if(createTableIfNotExist) {
%>
loadJobBuilder_<%=cid%>.setCreateDisposition(com.google.cloud.bigquery.JobInfo.CreateDisposition.CREATE_IF_NEEDED);
<%
@@ -551,51 +544,35 @@
<%
}
%>
<%
if("APPEND".equals(actionOnData)) {
%>
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_APPEND);
<%
} else if("TRUNCATE".equals(actionOnData)) {
%>
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_TRUNCATE);
<%
}
else {
%>
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_EMPTY);
<%
}
%>
loadJobBuilder_<%=cid%>.setDestinationTable(tableId_<%=cid%>);
com.google.cloud.bigquery.CsvOptions.Builder csvOptions_<%=cid%> = com.google.cloud.bigquery.CsvOptions.newBuilder();
csvOptions_<%=cid%>.setAllowQuotedNewLines(true);
loadJobBuilder_<%=cid%>.setWriteDisposition(com.google.cloud.bigquery.JobInfo.WriteDisposition.WRITE_<%=actionOnData%>);
loadJobBuilder_<%=cid%>.setDestinationTable(tableId_<%=cid%>);
com.google.cloud.bigquery.CsvOptions.Builder csvOptions_<%=cid%> = com.google.cloud.bigquery.CsvOptions.newBuilder();
csvOptions_<%=cid%>.setAllowQuotedNewLines(true);
csvOptions_<%=cid%>.setSkipLeadingRows(<%=gsFileHeader%>);
<%if("true".equals(ElementParameterParser.getValue(node, "__SET_FIELD_DELIMITER__"))) {
%>
loadJobBuilder_<%=cid%>.setFormatOptions(csvOptions_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>).build());
<%
}
%>
<%if(setFieldDelimiter) {
%>
loadJobBuilder_<%=cid%>.setFormatOptions(csvOptions_<%=cid%>.setFieldDelimiter(<%=fieldDelimiter%>).build());
<%
}
%>
loadJobBuilder_<%=cid%>.setNullMarker("\\N");
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.of(loadJobBuilder_<%=cid%>.build()));
job_<%=cid%> = job_<%=cid%>.waitFor(com.google.cloud.RetryOption.initialRetryDelay(org.threeten.bp.Duration.ofSeconds(1)));
if (job_<%=cid%> != null && job_<%=cid%>.getStatus().getError() == null) {
<%
if(isLog4jEnabled){
%>
log.info("<%=cid%> - Job execution status: " + job_<%=cid%>.getStatus());
<%
loadJobBuilder_<%=cid%>.setNullMarker("\\N");
com.google.cloud.bigquery.Job job_<%=cid%> = bigquery_<%=cid%>.create(com.google.cloud.bigquery.JobInfo.of(loadJobBuilder_<%=cid%>.build()));
job_<%=cid%> = job_<%=cid%>.waitFor(com.google.cloud.RetryOption.initialRetryDelay(org.threeten.bp.Duration.ofSeconds(1)));
if (job_<%=cid%> != null && job_<%=cid%>.getStatus().getError() == null) {
<%
if(isLog4jEnabled){
%>
log.info("<%=cid%> - Job execution status: " + job_<%=cid%>.getStatus());
<%
}
%>
} else {
List<com.google.cloud.bigquery.BigQueryError> errorList = job_<%=cid%>.getStatus().getExecutionErrors();
throw new RuntimeException("Job failed: " + errorList.get(errorList.size() - 1));
}
%>
} else {
List<com.google.cloud.bigquery.BigQueryError> errorList = job_<%=cid%>.getStatus().getExecutionErrors();
throw new RuntimeException("Job failed: " + errorList.get(errorList.size() - 1));
}
/* ----END-CREATING-JOB (Cloud API)---- */
<%

View File

@@ -53,6 +53,7 @@
<PARAMETER
NAME="DBTYPE"
REPOSITORY_VALUE="DBTYPE"
FIELD="CLOSED_LIST"
NUM_ROW="10"
>

View File

@@ -1564,7 +1564,7 @@ class TeradataManager extends Manager {
private boolean useExistingConnection;
private String connection;
private static final String SEPARATOR = ",";
private static final String SEPARATOR = "/";
protected TeradataManager(String host, String port, String dbName, String tableName,
String userName, String cid, boolean useExistingConnection, String connection, String additionalParams ) {

View File

@@ -36,6 +36,8 @@ skeleton="@{org.talend.designer.components.localprovider}/components/templates/d
String defaultDateFormat = ElementParameterParser.getValue(node, "__DEFAULT_DATE_FORMAT__");
String defaultTimestampFormat = ElementParameterParser.getValue(node, "__DEFAULT_TIMESTAMP_FORMAT__");
String numGroupSep = ElementParameterParser.getValue(node, "__THOUSANDS_SEPARATOR__");
boolean useLenPrecision = "true".equals(ElementParameterParser.getValue(node, "__USE_PRECISION_LENGTH_FROM_SCHEMA__"));
if (numGroupSep == null|| numGroupSep.trim().isEmpty()) {
numGroupSep = "null";
}
@@ -207,12 +209,24 @@ org.talend.database.exasol.imp.EXABulkUtil <%=cid%> = new org.talend.database.ex
String lengthStr = "null";
String precisionStr = "null";
Integer length = column.getLength();
if (length != null) {
lengthStr = String.valueOf(length);
}
if(useLenPrecision) {
if (length != null) {
lengthStr = String.valueOf(length);
}
} else {
if (length != null && hasGroupSep) {
lengthStr = String.valueOf(length);
}
}
Integer precision = column.getPrecision();
if (precision != null) {
precisionStr = String.valueOf(precision);
if(useLenPrecision) {
if (precision != null) {
precisionStr = String.valueOf(precision);
}
} else {
if (precision != null && hasGroupSep) {
precisionStr = String.valueOf(precision);
}
}
String talendType = column.getTalendType();
if ("id_Date".equals(talendType)

View File

@@ -635,14 +635,23 @@
>
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER
NAME="USE_PRECISION_LENGTH_FROM_SCHEMA"
FIELD="CHECK"
NUM_ROW="115"
REQUIRED="true"
>
<DEFAULT>false</DEFAULT>
</PARAMETER>
</ADVANCED_PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="Driver-EXASolution" MODULE="exajdbc-6.0.9302.jar" MVN="mvn:org.talend.libraries/exajdbc-6.0.9302/6.3.0" REQUIRED="true" />
<IMPORT NAME="Talend-DB-Exasol-Util" MODULE="talend-db-exasol-2.1.2.jar" MVN="mvn:org.talend.libraries/talend-db-exasol-2.1.2/6.2.0"
UrlPath="platform:/plugin/org.talend.libraries.jdbc.exasol/lib/talend-db-exasol-2.1.2.jar" REQUIRED="true" />
<IMPORT NAME="Talend-DB-Exasol-Util" MODULE="talend-db-exasol-2.1.3.jar" MVN="mvn:org.talend.libraries/talend-db-exasol/2.1.3"
UrlPath="platform:/plugin/org.talend.libraries.jdbc.exasol/lib/talend-db-exasol-2.1.3.jar" REQUIRED="true" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -108,4 +108,6 @@ NB_LINE_INSERTED.NAME=Rows inserted
NB_LINE_DELETED.NAME=Rows deleted
SOURCE_QUERY.NAME=Source query
TEST_MODE.NAME=Test mode (no statements are executed)
TEST_MODE.NAME=Test mode (no statements are executed)
USE_PRECISION_LENGTH_FROM_SCHEMA.NAME=Use precision and length from schema

View File

@@ -66,25 +66,26 @@
}
}
DecodeString_<%=cid%> decode_<%=cid%> = new DecodeString_<%=cid%>();
try{
fileInput<%=cid%> = new java.io.FileInputStream(<%=filename %>);
javax.mail.Session session_<%=cid %> = javax.mail.Session.getInstance(System.getProperties(), null);
javax.mail.internet.MimeMessage msg_<%=cid %> = new javax.mail.internet.MimeMessage(session_<%=cid %>, fileInput<%=cid%>);
javax.mail.internet.MimeMessage msg_<%=cid %> = new javax.mail.internet.MimeMessage(session_<%=cid %>, fileInput<%=cid%>);
java.util.List<String> list_<%=cid %> = new java.util.ArrayList<String>();
for (int i_<%=cid %> =0;i_<%=cid %> < mailParts_<%=cid %>.length;i_<%=cid %>++) {
String part_<%=cid %> = mailParts_<%=cid %>[i_<%=cid %>];
String sep_<%=cid%>= mailSeparator_<%=cid %>[i_<%=cid %>];
if(part_<%=cid %>.equalsIgnoreCase("body")) {
for (int i_<%=cid %> = 0; i_<%=cid %> < mailParts_<%=cid %>.length; i_<%=cid %>++) {
String part_<%=cid %> = mailParts_<%=cid %>[i_<%=cid %>];
String sep_<%=cid%>= mailSeparator_<%=cid %>[i_<%=cid %>];
if(part_<%=cid %>.equalsIgnoreCase("body")) {
if(msg_<%=cid %>.isMimeType("multipart/*")) {
javax.mail.Multipart mp<%=cid%> = (javax.mail.Multipart) msg_<%=cid %>.getContent();
for (int i = 0; i < mp<%=cid%>.getCount(); i++) {
javax.mail.BodyPart mpart<%=cid%> = mp<%=cid%>.getBodyPart(i);
String disposition<%=cid%> = mpart<%=cid%>.getDisposition();
if (!((disposition<%=cid%> != null) && ((disposition<%=cid%>
.equals(javax.mail.Part.ATTACHMENT)) || (disposition<%=cid%>.equals(javax.mail.Part.INLINE))))) {
// the following extract the body part(text/plain + text/html)
try{
for (int i = 0; i < mp<%=cid%>.getCount(); i++) {
javax.mail.BodyPart mpart<%=cid%> = mp<%=cid%>.getBodyPart(i);
String disposition<%=cid%> = mpart<%=cid%>.getDisposition();
if (!((disposition<%=cid%> != null) && ((disposition<%=cid%>
.equals(javax.mail.Part.ATTACHMENT)) || (disposition<%=cid%>.equals(javax.mail.Part.INLINE))))) {
// the following extract the body part(text/plain + text/html)
try{
Object content_<%=cid %> = mpart<%=cid %>.getContent();
if (content_<%=cid %> instanceof javax.mail.internet.MimeMultipart) {
javax.mail.internet.MimeMultipart mimeMultipart_<%=cid %> = (javax.mail.internet.MimeMultipart) content_<%=cid %>;
@@ -124,105 +125,104 @@
<%}%>
}
<%
//both attachment and message context in the email,bug TDI-19065
//both attachment and message context in the email,bug TDI-19065
%>
}else if(disposition<%=cid%> != null && disposition<%=cid%>.equals(javax.mail.Part.INLINE)){
list_<%=cid %>.add(mpart<%=cid%>.getContent().toString());
}
}
}
} else {
java.io.InputStream in_<%=cid %> = msg_<%=cid %>.getInputStream();
byte[] buffer_<%=cid %> = new byte[1024];
int length_<%=cid %> = 0;
java.io.ByteArrayOutputStream baos_<%=cid %> = new java.io.ByteArrayOutputStream();
while ((length_<%=cid %> = in_<%=cid %>.read(buffer_<%=cid %>, 0, 1024)) != -1) {
baos_<%=cid %>.write(buffer_<%=cid %>, 0, length_<%=cid %>);
}
String contentType_<%=cid%> = msg_<%=cid%>.getContentType();
String charsetName_<%=cid%> = "";
if(contentType_<%=cid%>!=null && contentType_<%=cid%>.trim().length()>0){
javax.mail.internet.ContentType cy_<%=cid%> = new javax.mail.internet.ContentType(contentType_<%=cid%>);
charsetName_<%=cid%> = cy_<%=cid%>.getParameter("charset");
}
if(charsetName_<%=cid%>!=null && charsetName_<%=cid%>.length()>0){
list_<%=cid %>.add(baos_<%=cid %>.toString(charsetName_<%=cid%>));
}else{
list_<%=cid %>.add(baos_<%=cid %>.toString());
}
in_<%=cid %>.close();
baos_<%=cid %>.close();
byte[] buffer_<%=cid %> = new byte[1024];
int length_<%=cid %> = 0;
java.io.ByteArrayOutputStream baos_<%=cid %> = new java.io.ByteArrayOutputStream();
while ((length_<%=cid %> = in_<%=cid %>.read(buffer_<%=cid %>, 0, 1024)) != -1) {
baos_<%=cid %>.write(buffer_<%=cid %>, 0, length_<%=cid %>);
}
String contentType_<%=cid%> = msg_<%=cid%>.getContentType();
String charsetName_<%=cid%> = "";
if(contentType_<%=cid%>!=null && contentType_<%=cid%>.trim().length()>0){
javax.mail.internet.ContentType cy_<%=cid%> = new javax.mail.internet.ContentType(contentType_<%=cid%>);
charsetName_<%=cid%> = cy_<%=cid%>.getParameter("charset");
}
if(charsetName_<%=cid%>!=null && charsetName_<%=cid%>.length()>0){
list_<%=cid %>.add(baos_<%=cid %>.toString(charsetName_<%=cid%>));
}else{
list_<%=cid %>.add(baos_<%=cid %>.toString());
}
in_<%=cid %>.close();
baos_<%=cid %>.close();
}
}else if(part_<%=cid %>.equalsIgnoreCase("header")){
java.util.Enumeration em = msg_<%=cid %>.getAllHeaderLines();
int em_count=0;
String tempStr_<%=cid %>="";
}else if(part_<%=cid %>.equalsIgnoreCase("header")){
java.util.Enumeration em = msg_<%=cid %>.getAllHeaderLines();
int em_count=0;
String tempStr_<%=cid %>="";
while (em.hasMoreElements()) {
tempStr_<%=cid %> = tempStr_<%=cid %> + (String) em.nextElement() + sep_<%=cid%> ;
}
list_<%=cid%>.add(decode_<%=cid%>.decode(tempStr_<%=cid%>));
}else{
if(("true").equals(mailChecked_<%=cid %>[i_<%=cid%>])){
} else {
if(("true").equals(mailChecked_<%=cid %>[i_<%=cid%>])){
String[] sa_<%=cid%> = msg_<%=cid %>.getHeader(part_<%=cid%>);
String tempStr_<%=cid%>="";
for(int i=0;i<sa_<%=cid%>.length;i++){
tempStr_<%=cid%>=tempStr_<%=cid%>+sa_<%=cid%>[i] + sep_<%=cid%>;
}
list_<%=cid%>.add(decode_<%=cid%>.decode(tempStr_<%=cid%>));
}else{
String content_<%=cid %> = msg_<%=cid %>.getHeader(part_<%=cid %>, null);
list_<%=cid %>.add(decode_<%=cid%>.decode(content_<%=cid %>));
}
}
}
//attachment Deal
if(msg_<%=cid %>.isMimeType("multipart/*")){
javax.mail.Multipart mp<%=cid%> = (javax.mail.Multipart) msg_<%=cid %>.getContent();
String attachfileName<%=cid%> = "";
String path<%=cid%> = "";
java.io.BufferedOutputStream out<%=cid%> = null;
java.io.BufferedInputStream in<%=cid%> = null;
for (int i = 0; i < mp<%=cid%>.getCount(); i++) {
javax.mail.BodyPart mpart<%=cid%> = mp<%=cid%>.getBodyPart(i);
String disposition<%=cid%> = mpart<%=cid%>.getDisposition();
<%
// fixed bug TDI-8586,to deal with attachments download
%>
if (mpart<%=cid%>.getFileName()!=null
&& ((disposition<%=cid%> != null && (disposition<%=cid%>.equals(javax.mail.Part.ATTACHMENT) || disposition<%=cid%>.equals(javax.mail.Part.INLINE)))
|| disposition<%=cid%>==null)) { <%// TDI-29179 %>
attachfileName<%=cid%> = mpart<%=cid%>.getFileName();
attachfileName<%=cid%> = javax.mail.internet.MimeUtility.decodeText(attachfileName<%=cid%>);
if(!(<%=directory%>).endsWith("/")){
path<%=cid%> = <%=directory%> + "/";
}else{
path<%=cid%> =<%=directory%>;
}
path<%=cid%> = path<%=cid%> + attachfileName<%=cid%>;
<% if(isLog4jEnabled){ %>
log.info("<%= cid %> - Extracted attachment: '"+attachfileName<%=cid%>+"'.");
<% } %>
java.io.File attachFile = new java.io.File(path<%=cid%>);
out<%=cid%> = new java.io.BufferedOutputStream(new java.io.FileOutputStream(attachFile));
in<%=cid%> = new java.io.BufferedInputStream(mpart<%=cid%>.getInputStream());
int buffer<%=cid%> = 0;
while ((buffer<%=cid%> = in<%=cid%>.read()) != -1) {
out<%=cid%>.write(buffer<%=cid%>);
out<%=cid%>.flush();
}
out<%=cid%>.close();
in<%=cid%>.close();
}
}
}else{
String content_<%=cid %> = msg_<%=cid %>.getHeader(part_<%=cid %>, null);
list_<%=cid %>.add(decode_<%=cid%>.decode(content_<%=cid %>));
}
}
}
//attachment Deal
class MessagePartProcessor {
void saveAttachment(javax.mail.Part mpart) throws IOException, javax.mail.MessagingException {
if (mpart.getFileName() != null && (
mpart.getDisposition() == null ||
(mpart.getDisposition().equals(javax.mail.Part.ATTACHMENT) || mpart.getDisposition().equals(javax.mail.Part.INLINE))
)) {
String attachFileName = javax.mail.internet.MimeUtility.decodeText(mpart.getFileName());
String path = <%=directory%>;
if(!path.endsWith("/")){
path = path + "/";
}
path = path + attachFileName;
<% if(isLog4jEnabled){ %>
log.info("<%= cid %> - Extracted attachment: '" + attachFileName + "'.");
<% } %>
java.io.File attachFile = new java.io.File(path);
java.io.BufferedOutputStream out = new java.io.BufferedOutputStream(new java.io.FileOutputStream(attachFile));
java.io.BufferedInputStream in = new java.io.BufferedInputStream(mpart.getInputStream());
int buffer = 0;
while ((buffer = in.read()) != -1) {
out.write(buffer);
out.flush();
}
out.close();
in.close();
}
}
// recursively process body parts
void processPart(javax.mail.Part part) throws javax.mail.MessagingException, IOException {
if (part.isMimeType("multipart/*")) {
javax.mail.Multipart multipartContent = (javax.mail.Multipart) part.getContent();
for (int i = 0; i < multipartContent.getCount(); i++) {
javax.mail.Part mpart = multipartContent.getBodyPart(i);
saveAttachment(mpart);
processPart(mpart);
}
}
}
}
new MessagePartProcessor().processPart(msg_<%=cid %>);
// for output
<%
List< ? extends IConnection> conns = node.getOutgoingSortedConnections();
@@ -282,10 +282,10 @@
for (int i=1;i<conns.size();i++) {
IConnection conn2 = conns.get(i);
if ((conn2.getName().compareTo(firstConnName)!=0)&&(conn2.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA))) {
for (IMetadataColumn column: metadata.getListColumns()) {%>
<%=conn2.getName() %>.<%=column.getLabel() %> = <%=firstConnName %>.<%=column.getLabel() %>;
<%
}
for (IMetadataColumn column: metadata.getListColumns()) {%>
<%=conn2.getName() %>.<%=column.getLabel() %> = <%=firstConnName %>.<%=column.getLabel() %>;
<%
}
}
}
}

View File

@@ -185,14 +185,14 @@ imports="
%>
for (org.jets3t.service.model.GSObject objectSummary_<%=cid%> : objects_<%=cid%>) {
String objkey_<%=cid%> = objectSummary_<%=cid%>.getKey();
java.io.File file_<%=cid%> = new java.io.File(<%=outputsDir%>+objkey_<%=cid%>);
java.io.File file_<%=cid%> = new java.io.File(<%=outputsDir%>, objkey_<%=cid%>);
org.jets3t.service.model.GSObject obj_<%=cid%> = service_<%=cid%>.getObject(currentBucketName_<%=cid%>, objkey_<%=cid%>);
<%
}else{
%>
for (java.util.Map<String, String> map_<%=cid %>: list_<%=cid%>) {
String currentBucketName_<%=cid%>=map_<%=cid %>.get("BUCKET_NAME");
java.io.File file_<%=cid%> = new java.io.File(<%=outputsDir%>+map_<%=cid %>.get("OBJECT_NEWNAME"));
java.io.File file_<%=cid%> = new java.io.File(<%=outputsDir%>, map_<%=cid %>.get("OBJECT_NEWNAME"));
org.jets3t.service.model.GSObject obj_<%=cid%> =null;
try {
obj_<%=cid%> = service_<%=cid%>.getObject(currentBucketName_<%=cid%>, map_<%=cid %>.get("OBJECT_KEY"));
@@ -275,4 +275,4 @@ imports="
obj_<%=cid%>.closeDataInputStream();
<%
}
%>
%>

View File

@@ -69,6 +69,8 @@ skeleton="../templates/db_output_bulk.skeleton"
boolean savePoint = ("true").equals(ElementParameterParser.getValue(node,"__SAVE_POINT__"));
String dieOnError = ElementParameterParser.getValue(node, "__DIE_ON_ERROR__");
boolean convertToLowercase = ("true").equals(ElementParameterParser.getValue(node, "__CONVERT_COLUMN_TABLE_TO_LOWERCASE__"));
String rejectConnName = null;
List<? extends IConnection> rejectConns = node.getOutgoingConnections("REJECT");
@@ -98,6 +100,18 @@ List<Column> stmtStructure = null;
if(columnList != null && columnList.size() > 0) {
stmtStructure = getManager(dbmsId, cid).createColumnList(columnList, useFieldOptions, fieldOptions, addCols);
isDynamic = isDynamic && !getManager(dbmsId, cid).isDynamicColumnReplaced();
if(convertToLowercase){
for(Column column : stmtStructure) {
if(column.isReplaced()) {
for (Column replacedColumn : column.getReplacement()) {
replacedColumn.setColumnName(replacedColumn.getColumnName().toLowerCase());
}
} else if(!column.isDynamic()){
column.setColumnName(column.getColumnName().toLowerCase());
}
}
}
}
%>
@@ -116,9 +130,9 @@ if(("true").equals(useExistingConn)) {
String tableName_<%=cid%> = null;
if(dbschema_<%=cid%> == null || dbschema_<%=cid%>.trim().length() == 0) {
tableName_<%=cid%> = <%=table%>;
tableName_<%=cid%> = (<%=table%>)<%=convertToLowercase ? ".toLowerCase()" : ""%>;
} else {
tableName_<%=cid%> = dbschema_<%=cid%> + "\".\"" + <%=table%>;
tableName_<%=cid%> = dbschema_<%=cid%> + "\".\"" + (<%=table%>)<%=convertToLowercase ? ".toLowerCase()" : ""%>;
}
<%

View File

@@ -393,6 +393,14 @@
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER
NAME="CONVERT_COLUMN_TABLE_TO_LOWERCASE"
FIELD="CHECK"
NUM_ROW="25"
>
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER
NAME="USE_BATCH_SIZE"
FIELD="CHECK"

View File

@@ -49,6 +49,8 @@ skeleton="../templates/db_output_bulk.skeleton"
boolean useBatchSize = ("true").equals(ElementParameterParser.getValue(node,"__USE_BATCH_SIZE__"));
String batchSize=ElementParameterParser.getValue(node,"__BATCH_SIZE__");
boolean convertToLowercase = ("true").equals(ElementParameterParser.getValue(node, "__CONVERT_COLUMN_TABLE_TO_LOWERCASE__"));
//feature:22704
boolean savePoint = ("true").equals(ElementParameterParser.getValue(node,"__SAVE_POINT__"));
@@ -156,11 +158,16 @@ skeleton="../templates/db_output_bulk.skeleton"
if(conns_dynamic!=null && conns_dynamic.size()>0){
IConnection conn = conns_dynamic.get(0);
if(!("".equals(insertColName.toString()))) {
String insertColNameStr = null;
if(convertToLowercase)
insertColNameStr = insertColName.toString().toLowerCase();
else
insertColNameStr = insertColName.toString();
%>
String insert_<%=cid%> = "INSERT INTO \"" + tableName_<%=cid%> + "\" (<%=insertColName.toString()%>, "+DynamicUtils.getInsertIntoStmtColumnsList(<%=conn.getName()%>.<%=getDynamicColumn()%>, "<%=dbmsId %>")+") VALUES (<%=insertValueStmt.toString()%>, "+DynamicUtils.getInsertIntoStmtValuesList(<%=conn.getName()%>.<%=getDynamicColumn()%>)+")";
String insert_<%=cid%> = "INSERT INTO \"" + tableName_<%=cid%> + "\" (<%=insertColNameStr%>, "+DynamicUtils.getInsertIntoStmtColumnsList(<%=conn.getName()%>.<%=getDynamicColumn()%>, "<%=dbmsId %>")<%if(convertToLowercase){%>.toLowerCase()<%}%>+") VALUES (<%=insertValueStmt.toString()%>, "+DynamicUtils.getInsertIntoStmtValuesList(<%=conn.getName()%>.<%=getDynamicColumn()%>)+")";
<% } else {
%>
String insert_<%=cid%> = "INSERT INTO \"" + tableName_<%=cid%> + "\" ("+DynamicUtils.getInsertIntoStmtColumnsList(<%=conn.getName()%>.<%=getDynamicColumn()%>, "<%=dbmsId %>")+") VALUES ("+DynamicUtils.getInsertIntoStmtValuesList(<%=conn.getName()%>.<%=getDynamicColumn()%>)+")";
String insert_<%=cid%> = "INSERT INTO \"" + tableName_<%=cid%> + "\" ("+DynamicUtils.getInsertIntoStmtColumnsList(<%=conn.getName()%>.<%=getDynamicColumn()%>, "<%=dbmsId %>")<%if(convertToLowercase){%>.toLowerCase()<%}%>+") VALUES ("+DynamicUtils.getInsertIntoStmtValuesList(<%=conn.getName()%>.<%=getDynamicColumn()%>)+")";
<%
}
}

View File

@@ -98,4 +98,6 @@ NB_LINE_REJECTED.NAME=Number Of Rejected Lines
SPECIFY_DATASOURCE_ALIAS.NAME=Specify a data source alias
DATASOURCE.NAME=Data source
DATASOURCE_ALIAS.NAME=Data source alias
PROPERTIES.NAME=Additional JDBC Parameters
PROPERTIES.NAME=Additional JDBC Parameters
CONVERT_COLUMN_TABLE_TO_LOWERCASE.NAME=Convert columns and table to lowercase

View File

@@ -419,7 +419,7 @@
UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar"
REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar"
MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0"
MVN="mvn:commons-codec/commons-codec/1.6"
UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar"
REQUIRED="true" />
</IMPORTS>

View File

@@ -207,6 +207,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -288,6 +288,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -378,6 +378,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -538,7 +538,7 @@
UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-logging-1.1.3.jar"
REQUIRED="true" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar"
MVN="mvn:org.talend.libraries/commons-codec-1.6/6.0.0"
MVN="mvn:commons-codec/commons-codec/1.6"
UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar"
REQUIRED="true" />
</IMPORTS>

View File

@@ -306,6 +306,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>

View File

@@ -7,6 +7,7 @@
<FAMILIES>
<FAMILY>Databases/DB Specifics/Amazon/Redshift</FAMILY>
<FAMILY>Cloud/Amazon/Redshift</FAMILY>
</FAMILIES>
<DOCUMENTATION>
@@ -281,6 +282,7 @@
<IMPORT NAME="httpcore-4.4.9.jar" MODULE="httpcore-4.4.9.jar" MVN="mvn:org.apache.httpcomponents/httpcore/4.4.9" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="httpclient-4.5.5.jar" MODULE="httpclient-4.5.5.jar" MVN="mvn:org.apache.httpcomponents/httpclient/4.5.5" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="joda-time-2.8.1.jar" MODULE="joda-time-2.8.1.jar" MVN="mvn:joda-time/joda-time/2.8.1" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
<IMPORT NAME="commons-codec-1.6.jar" MODULE="commons-codec-1.6.jar" MVN="mvn:commons-codec/commons-codec/1.6" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.6.jar" REQUIRED_IF="(JDBC_URL == 'SSO') AND (USE_EXISTING_CONNECTION == 'false')" />
</IMPORTS>
</CODEGENERATION>
<RETURNS />

View File

@@ -555,66 +555,92 @@ String inputConnName = null;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// use independent process to run subjob
%>
Runtime runtime_<%=cid %> = Runtime.getRuntime();
final Process ps_<%=cid %>;
ps_<%=cid %> = runtime_<%=cid %>.exec((String[])paraList_<%=cid %>.toArray(new String[paraList_<%=cid %>.size()]));
Thread normal_<%=cid %> = new Thread() {
public void run() {
try {
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(ps_<%=cid %>.getInputStream()));
String line = "";
try {
while((line = reader.readLine()) != null) {
System.out.println(line);
}
} finally {
reader.close();
class ConsoleHelper_<%=cid %> {
private Thread getNormalThread(Process process) {
return new Thread() {
public void run() {
try {
java.io.BufferedReader reader = new java.io.BufferedReader(
new java.io.InputStreamReader(
process.getInputStream()));
String line = "";
try {
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} finally {
reader.close();
}
} catch (java.io.IOException ioe) {
<%if(isLog4jEnabled){%>
log.error("<%=cid %> - " + ioe.getMessage());
<%}%>
ioe.printStackTrace();
}
}
};
}
private Thread getErrorThread(Process process, StringBuffer sb) {
return new Thread() {
public void run() {
try {
java.io.BufferedReader reader = new java.io.BufferedReader(
new java.io.InputStreamReader(
process.getErrorStream()));
String line = "";
try {
while ((line = reader.readLine()) != null) {
sb.append(line)
.append("\n");
}
} finally {
reader.close();
}
} catch (java.io.IOException ioe) {
<%if(isLog4jEnabled){%>
log.error("<%=cid %> - " + ioe.getMessage());
<%}%>
ioe.printStackTrace();
}
}
};
}
} catch(java.io.IOException ioe) {
<%if(isLog4jEnabled){%>
log.error("<%=cid %> - " + ioe.getMessage());
<%}%>
ioe.printStackTrace();
}
}
};
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - The child job '<%if(!useDynamicJob){%><%=childJob %><%}else{%>"+<%=dynamicJobName%>+"<%}%>' starts on the version '<%=version%>' with the context '<%=context%>'.");
<%}%>
normal_<%=cid %>.start();
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - The child job '<%if(!useDynamicJob){%><%=childJob %><%}else{%>"+<%=dynamicJobName%>+"<%}%>' is done.");
<%}%>
ConsoleHelper_<%=cid %> consoleHelper_<%=cid %> = new ConsoleHelper_<%=cid %>();
final StringBuffer errorMsg_<%=cid %> = new StringBuffer();
Thread error_<%=cid %> = new Thread() {
public void run() {
try {
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(ps_<%=cid %>.getErrorStream()));
String line = "";
try {
while((line = reader.readLine()) != null) {
errorMsg_<%=cid %>.append(line).append("\n");
}
} finally {
reader.close();
}
} catch(java.io.IOException ioe) {
<%if(isLog4jEnabled){%>
log.error("<%=cid %> - " + ioe.getMessage());
<%}%>
ioe.printStackTrace();
}
}
};
error_<%=cid %>.start();
Runtime runtime_<%=cid %> = Runtime.getRuntime();
Process ps_<%=cid %> = null;
//0 indicates normal termination
int result_<%=cid %>;
StringBuffer errorMsg_<%=cid %> = new StringBuffer();
try {
ps_<%=cid %> = runtime_<%=cid %>.exec((String[])paraList_<%=cid %>.toArray(new String[paraList_<%=cid %>.size()]));
Thread normal_<%=cid %> = consoleHelper_<%=cid %>.getNormalThread(ps_<%=cid %>);
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - The child job '<%if(!useDynamicJob){%><%=childJob %><%}else{%>"+<%=dynamicJobName%>+"<%}%>' starts on the version '<%=version%>' with the context '<%=context%>'.");
<%}%>
normal_<%=cid %>.start();
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - The child job '<%if(!useDynamicJob){%><%=childJob %><%}else{%>"+<%=dynamicJobName%>+"<%}%>' is done.");
<%}%>
Thread error_<%=cid %> = consoleHelper_<%=cid %>.getErrorThread(ps_<%=cid %>, errorMsg_<%=cid %>);
error_<%=cid %>.start();
result_<%=cid %> = ps_<%=cid %>.waitFor();
normal_<%=cid %>.join(10000);
error_<%=cid %>.join(10000);
} catch (ThreadDeath tde) {
<%if(isLog4jEnabled){%>
log.error("<%=cid %> - thread was terminated.");
<%}%>
ps_<%=cid %>.destroy();
throw tde;
}
//0 indicates normal termination
int result_<%=cid %> = ps_<%=cid %>.waitFor();
normal_<%=cid %>.join(10000);
error_<%=cid %>.join(10000);
globalMap.put("<%=cid %>_CHILD_RETURN_CODE",result_<%=cid %>);
if(result_<%=cid %> != 0){
globalMap.put("<%=cid %>_CHILD_EXCEPTION_STACKTRACE",errorMsg_<%=cid %>.toString());

View File

@@ -151,7 +151,7 @@
<IMPORT NAME="saajapi" MODULE="saaj-api-1.3.jar" MVN="mvn:org.talend.libraries/saaj-api-1.3/6.0.0" REQUIRED="true" BundleID="" />
<IMPORT NAME="saajimpl" MODULE="saaj-impl-1.3.2.jar" MVN="mvn:org.talend.libraries/saaj-impl-1.3.2/6.0.0" REQUIRED="true" BundleID="" />
<IMPORT NAME="jdom" MODULE="jdom-1.1.jar" MVN="mvn:org.talend.libraries/jdom-1.1/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jdom/lib/jdom-1.1.jar" REQUIRED="true" BundleID="org.apache.servicemix.bundles.jdom" />
<IMPORT NAME="talendsoap" MODULE="talend-soap-2.1-20190513.jar" MVN="mvn:org.talend.libraries/talend-soap-2.1-20190513/6.0.0" REQUIRED="true" />
<IMPORT NAME="talendsoap" MODULE="talend-soap-2.1-20190716.jar" MVN="mvn:org.talend.libraries/talend-soap-2.1-20190716/6.0.0" REQUIRED="true" />
<IMPORT NAME="Java_xercesImpl" MODULE="xercesImpl.jar" MVN="mvn:org.talend.libraries/xercesImpl/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.xml/lib/xercesImpl.jar" REQUIRED="true" BundleID="" />
<IMPORT NAME="commons-codec" MODULE="commons-codec-1.9.jar" MVN="mvn:org.talend.libraries/commons-codec-1.9/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-codec-1.9.jar" REQUIRED="true" BundleID="" />
</IMPORTS>

View File

@@ -5,6 +5,7 @@
Boolean isParallelize ="true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__PARALLELIZE__"));
String dbms=ElementParameterParser.getValue(node, "__MAPPING__");
boolean convertToUppercase_tableAction = "true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__CONVERT_COLUMN_TABLE_TO_UPPERCASE__"));
boolean convertToLowercase_tableAction = "true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__CONVERT_COLUMN_TABLE_TO_LOWERCASE__"));
if (!isParallelize) {
//end issue 0010346 Parallelization crash with "Drop table if exists and create"
@@ -222,7 +223,7 @@ if (!isParallelize) {
while(rsTable_<%=cid%>.next()) {
String table_<%=cid%> = rsTable_<%=cid%>.getString("TABLE_NAME");
String schema_<%=cid%> = rsTable_<%=cid%>.getString("TABLE_SCHEM");
if(table_<%=cid%>.equals<%if(!tableNameCaseSensitive){%>IgnoreCase<%}%>(<%=table%>)
if(table_<%=cid%>.equals<%if(!tableNameCaseSensitive){%>IgnoreCase<%}%>(<%=table%><%if(convertToLowercase_tableAction){%>.toLowerCase()<%}%>)
&& (schema_<%=cid%>.equals<%if(!tableNameCaseSensitive){%>IgnoreCase<%}%>(dbschema_<%=cid%>) || ((dbschema_<%=cid%> ==null || dbschema_<%=cid%>.trim().length() ==0) && defaultSchema_<%=cid%>.equals<%if(!tableNameCaseSensitive){%>IgnoreCase<%}%>(schema_<%=cid%>)))) {
whetherExist_<%=cid%> = true;
break;
@@ -377,7 +378,7 @@ if (!isParallelize) {
if(conns_dynamic!=null && conns_dynamic.size()>0){
String query=manager.getCreateTableSQL(stmtStructure);
%>
stmtCreate_<%=cid%>.execute((("<%=query%>").replace("{TALEND_DYNAMIC_COLUMN}",DynamicUtils.getCreateTableSQL(<%=conns_dynamic.get(0).getName()%>.<%=getDynamicColumn()%>, "<%=dbms==null?"":dbms.toLowerCase()%>")<%if(convertToUppercase_tableAction){%>.toUpperCase()<%}%>)+")<%=ending%>"));
stmtCreate_<%=cid%>.execute((("<%=query%>").replace("{TALEND_DYNAMIC_COLUMN}",DynamicUtils.getCreateTableSQL(<%=conns_dynamic.get(0).getName()%>.<%=getDynamicColumn()%>, "<%=dbms==null?"":dbms.toLowerCase()%>"))+")<%=ending%>")<%if(convertToUppercase_tableAction){%>.toUpperCase()<%}else if(convertToLowercase_tableAction){%>.toLowerCase()<%}%>);
<%
}
} else {

View File

@@ -95,7 +95,7 @@
<artifactItem>
<groupId>org.talend.libraries</groupId>
<artifactId>talend-soap</artifactId>
<version>2.1-20190513</version>
<version>2.1-20190716</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${soap.dir}</outputDirectory>

View File

@@ -13,7 +13,9 @@
package org.talend.designer.core.ui.editor.cmd;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -411,6 +413,8 @@ public class ChangeActivateStatusElementCommand extends Command {
for (INode node : jobletandnodeList) {
if (node.isActivate()) {
// MiddleNodes Map<IConnection, Node> connection->Node
// if Node deactivate then connection->null
Map<IConnection, Node> outMiddleNodes = getAllOutMiddleNodes(node);
Map<IConnection, Node> inMiddleNodes = getAllInMiddleNodes(node);
@@ -457,7 +461,8 @@ public class ChangeActivateStatusElementCommand extends Command {
}
}
if (!exist) {
middConnMap.put(nodeList, connList);
List<IConnection> exactConnections = getExactConnectionsBetweenNodes(node, nodeList, connList, true);
middConnMap.put(nodeList, exactConnections);
}
}
@@ -504,11 +509,86 @@ public class ChangeActivateStatusElementCommand extends Command {
}
}
if (!exist) {
middConnMap.put(nodeList, connList);
List<IConnection> exactConnections = getExactConnectionsBetweenNodes(node, nodeList, connList, false);
middConnMap.put(nodeList, exactConnections);
}
}
}
}
// middConnMap=> key(BaseNode, Node1, Node2......);
// BaseNode->(0/some deactivate node)->Node1;BaseNode->(0/some deactivate node)->Node2;
// middConnMap=> value(connections between Node1 and Node2).
return middConnMap;
}
public static List<IConnection> getExactConnectionsBetweenNodes(INode node, List<INode> nodeList, List<IConnection> connList,
boolean isOutgoing) {
List<IConnection> exactList = new ArrayList<IConnection>(connList);
List<INode> targetNodeList = new ArrayList<INode>(nodeList);
targetNodeList.remove(node);
Map<INode, Set<INode>> pathhm = new HashMap<INode, Set<INode>>();
for (INode targetNode : targetNodeList) {
Set<INode> pathNodes = new HashSet<INode>();
pathNodes.add(node);
// Got the passby Node between node and tatgetNode
boolean pathFound = getPathsNodes(node, targetNode, pathNodes, isOutgoing);
if (pathFound) {
pathhm.put(targetNode, pathNodes);
}
}
Collection<Set<INode>> pathSets = pathhm.values();
if (!pathSets.isEmpty()) {
Iterator<IConnection> connectionIte = exactList.iterator();
while (connectionIte.hasNext()) {
IConnection connection = (IConnection) connectionIte.next();
boolean rightIn = false;
Iterator<Set<INode>> pathIte = pathSets.iterator();
while (pathIte.hasNext()) {
Set<INode> nodes = (Set<INode>) pathIte.next();
// if sourceNode and targetNode of the connection don't exist in the NodePath then this connection
// doesn't belong to this flow of BaseNode->(0/some deactivate node)->Node1
// maybe belongs to other flow of BaseNode but all flow deactivate.
if (nodes.contains(connection.getSource()) && nodes.contains(connection.getTarget())) {
rightIn = true;
}
}
if (!rightIn) {
connectionIte.remove();
}
}
}
return exactList;
}
private static boolean getPathsNodes(INode node, INode targetNode, Set<INode> nodes, boolean isOutgoing) {
List<? extends IConnection> connections = null;
if (node.equals(targetNode)) {
return true;
}
if (isOutgoing) {
connections = node.getOutgoingConnections();
} else {
connections = node.getIncomingConnections();
}
for (IConnection connection : connections) {
INode deepNode = null;
if (isOutgoing) {
deepNode = connection.getTarget();
} else {
deepNode = connection.getSource();
}
boolean flag = getPathsNodes(deepNode, targetNode, nodes, isOutgoing);
if (flag) {
nodes.add(deepNode);
return true;
}
}
return false;
}
}

View File

@@ -624,8 +624,10 @@ public class ChangeMetadataCommand extends Command {
setTableMAPPING();
if (!internal) {
updateColumnList(oldOutputMetadata, newOutputMetadata);
((Process) node.getProcess()).checkProcess();
if (!oldOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_NONE)) {
updateColumnList(oldOutputMetadata, newOutputMetadata);
((Process) node.getProcess()).checkProcess();
}
}
refreshMetadataChanged();
}

View File

@@ -1383,7 +1383,7 @@ public class Node extends Element implements IGraphicalNode {
// MetadataTool.copyTable(inputTable, targetTable);
// add by wzhang for feature 7611.
String dbmsId = targetTable.getDbms();
MetadataToolHelper.copyTable(inputTable, targetTable, null, false, true);
MetadataToolHelper.copyTable(inputTable, targetTable, null, false);
MetadataToolHelper.setDBType(targetTable, dbmsId);
ChangeMetadataCommand cmc = new ChangeMetadataCommand(this, null,
tmpTableCreated ? targetTable : null, targetTable, inputSchemaParam);
@@ -1436,7 +1436,7 @@ public class Node extends Element implements IGraphicalNode {
}
boolean isJunitInput = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister
ITestContainerProviderService testContainerService = GlobalServiceRegister
.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null
&& testContainerService.isTestCaseComponent(connection.getSource().getComponent())) {
@@ -1888,7 +1888,7 @@ public class Node extends Element implements IGraphicalNode {
connectionToParse = (String) value;
boolean isTestCase = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister
ITestContainerProviderService testContainerService = GlobalServiceRegister
.getDefault().getService(ITestContainerProviderService.class);
isTestCase = getProcess() != null && testContainerService.isTestContainerProcess(getProcess());
}
@@ -3361,7 +3361,7 @@ public class Node extends Element implements IGraphicalNode {
private void checkHasMultiPrejobOrPostJobComponents() {
Map<String, INode> multiNodes = new HashMap<String, INode>();
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault()
IJobletProviderService jobletService = GlobalServiceRegister.getDefault()
.getService(IJobletProviderService.class);
if (jobletService != null) {
// need to check all node from the process
@@ -3414,7 +3414,7 @@ public class Node extends Element implements IGraphicalNode {
public void checkLinks() {
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault()
IJobletProviderService service = GlobalServiceRegister.getDefault()
.getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(this)) {
isJoblet = true;
@@ -3820,7 +3820,7 @@ public class Node extends Element implements IGraphicalNode {
}
ICoreTisService service = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
service = (ICoreTisService) GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
service = GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
}
// test in case several Dynamic type has been set or if Dynamic is not the last type in schema
@@ -4449,16 +4449,16 @@ public class Node extends Element implements IGraphicalNode {
.getLastVersion(value.toString());
if (lastVersion != null) {
if (isMRServiceRegistered) {
if (((IMRProcessService) GlobalServiceRegister.getDefault()
.getService(IMRProcessService.class))
if (GlobalServiceRegister.getDefault()
.getService(IMRProcessService.class)
.isMapReduceItem(lastVersion.getProperty().getItem())) {
targetIsBigdata = true;
bigDataType = "Batch"; //$NON-NLS-1$
}
}
if (isStormServiceRegistered) {
if (((IStormProcessService) GlobalServiceRegister.getDefault()
.getService(IStormProcessService.class))
if (GlobalServiceRegister.getDefault()
.getService(IStormProcessService.class)
.isStormItem(lastVersion.getProperty().getItem())) {
targetIsBigdata = true;
bigDataType = "Streaming"; //$NON-NLS-1$
@@ -4935,7 +4935,7 @@ public class Node extends Element implements IGraphicalNode {
}
boolean isJobletNode = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault()
IJobletProviderService service = GlobalServiceRegister.getDefault()
.getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(this)) {
isJobletNode = true;
@@ -5310,7 +5310,7 @@ public class Node extends Element implements IGraphicalNode {
public boolean isStandardJoblet() {
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault()
IJobletProviderService service = GlobalServiceRegister.getDefault()
.getService(IJobletProviderService.class);
if (service != null && service.isStandardJobletComponent(this)) {
isJoblet = true;
@@ -5322,7 +5322,7 @@ public class Node extends Element implements IGraphicalNode {
public boolean isJoblet() {
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault()
IJobletProviderService service = GlobalServiceRegister.getDefault()
.getService(IJobletProviderService.class);
if (service != null && service.isJobletComponent(this)) {
isJoblet = true;
@@ -5334,7 +5334,7 @@ public class Node extends Element implements IGraphicalNode {
public boolean isSparkJoblet() {
boolean isSparkJoblet = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
ISparkJobletProviderService sparkJobletService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault()
ISparkJobletProviderService sparkJobletService = GlobalServiceRegister.getDefault()
.getService(ISparkJobletProviderService.class);
if (sparkJobletService != null) {
isSparkJoblet = sparkJobletService.isSparkJobletComponent(this);
@@ -5346,7 +5346,7 @@ public class Node extends Element implements IGraphicalNode {
public boolean isSparkStreamingJoblet() {
boolean isSparkStreamingJoblet = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
ISparkStreamingJobletProviderService sparkJobletService = (ISparkStreamingJobletProviderService) GlobalServiceRegister
ISparkStreamingJobletProviderService sparkJobletService = GlobalServiceRegister
.getDefault().getService(ISparkStreamingJobletProviderService.class);
if (sparkJobletService != null) {
isSparkStreamingJoblet = sparkJobletService.isSparkStreamingJobletComponent(this);
@@ -5383,7 +5383,7 @@ public class Node extends Element implements IGraphicalNode {
public boolean isProgressBarNeeded() {
boolean needBar = true;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault()
IMRProcessService mrService = GlobalServiceRegister.getDefault()
.getService(IMRProcessService.class);
needBar = mrService.isProgressBarNeeded(process);
}
@@ -5579,7 +5579,7 @@ public class Node extends Element implements IGraphicalNode {
public void refreshNodeContainer() {
boolean isRunning = false;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService runProcessService = (IRunProcessService) GlobalServiceRegister.getDefault()
IRunProcessService runProcessService = GlobalServiceRegister.getDefault()
.getService(IRunProcessService.class);
if (runProcessService != null) {
isRunning = runProcessService.isJobRunning();

View File

@@ -123,6 +123,7 @@ import org.talend.core.model.update.IUpdateManager;
import org.talend.core.model.utils.TalendTextUtils;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.repository.utils.ConvertJobsUtil;
import org.talend.core.repository.utils.ProjectHelper;
import org.talend.core.repository.utils.XmiResourceManager;
import org.talend.core.runtime.repository.item.ItemProductKeys;
import org.talend.core.runtime.util.ItemDateParser;
@@ -1079,7 +1080,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
ElementParameterType pType;
boolean isJoblet = false;
if (param.getElement() instanceof INode && PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
IJobletProviderService.class);
if (service != null && service.isJobletComponent((INode) param.getElement())) {
isJoblet = true;
@@ -1920,12 +1921,25 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
}
}
for (IRepositoryViewObject object : routines) {
if (routinesToAdd.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
routinesParameterType.setId(object.getId());
routinesParameterType.setName(object.getLabel());
routinesDependencies.add(routinesParameterType);
//
boolean isLimited = false;
org.talend.core.model.properties.Project currProject = getProject().getEmfProject();
org.talend.core.model.properties.Project project = ProjectManager.getInstance().getProject(this.property);
if (currProject != null && project != null && !currProject.equals(project)) {
int currOrdinal = ProjectHelper.getProjectTypeOrdinal(currProject);
int ordinal = ProjectHelper.getProjectTypeOrdinal(project);
if (currOrdinal > ordinal) {
isLimited = true;
}
}
if (!isLimited) {
for (IRepositoryViewObject object : routines) {
if (routinesToAdd.contains(object.getLabel()) && !routinesAlreadySetup.contains(object.getLabel())) {
RoutinesParameterType routinesParameterType = TalendFileFactory.eINSTANCE.createRoutinesParameterType();
routinesParameterType.setId(object.getId());
routinesParameterType.setName(object.getLabel());
routinesDependencies.add(routinesParameterType);
}
}
}
} catch (PersistenceException e) {
@@ -2283,7 +2297,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
if (EParameterName.PROCESS_TYPE_VERSION.name().equals(pType.getName())) {
String jobletVersion = pType.getValue();
if (!RelationshipItemBuilder.LATEST_VERSION.equals(jobletVersion)) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault()
IJobletProviderService service = GlobalServiceRegister.getDefault()
.getService(IJobletProviderService.class);
if (service != null) {
Property jobletProperty = service.getJobletComponentItem(component);
@@ -2453,7 +2467,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
updateAllMappingTypes();
nc.setNeedLoadLib(false);
if (nc.isJoblet()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
IJobletProviderService.class);
if (service != null) {
// reload only for stuido ,because joblet can be changed in the job editor
@@ -2467,7 +2481,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
NodeContainer nodeContainer = null;
if (isJunitContainer) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerGEFService.class)) {
ITestContainerGEFService testContainerService = (ITestContainerGEFService) GlobalServiceRegister.getDefault()
ITestContainerGEFService testContainerService = GlobalServiceRegister.getDefault()
.getService(ITestContainerGEFService.class);
if (testContainerService != null) {
nodeContainer = testContainerService.createJunitContainer(node);
@@ -2669,7 +2683,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IScdComponentService.class)) {
IScdComponentService service = (IScdComponentService) GlobalServiceRegister.getDefault().getService(
IScdComponentService service = GlobalServiceRegister.getDefault().getService(
IScdComponentService.class);
service.updateOutputMetadata(nc, metadataTable);
}
@@ -2796,7 +2810,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
}
} else {
if (PluginChecker.isJobLetPluginLoaded()) { // bug 12764
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
IJobletProviderService.class);
if (service != null && service.isJobletComponent(source)) {
continue;
@@ -4572,7 +4586,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
Item item = ((IProcess2) jobletProcess).getProperty().getItem();
if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = ((JobletProcessItem) item);
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
IJobletProviderService service = GlobalServiceRegister.getDefault().getService(
IJobletProviderService.class);
if (service != null) {
service.saveJobletNode(jobletItem, jobletContainer);
@@ -4621,7 +4635,7 @@ public class Process extends Element implements IProcess2, IGEFProcess, ILastVer
IJobletProviderService jobletService = null;
if (PluginChecker.isJobLetPluginLoaded()) {
jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
jobletService = GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
for (INode node : getGraphicalNodes()) {
if (jobletService.isJobletComponent(node)) {
listRoutines.addAll(getJobletRoutines(jobletService, node));

View File

@@ -50,6 +50,13 @@
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.3</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.0.24</version>
</dependency>
</dependencies>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>

View File

@@ -1,3 +1,3 @@
$fileDir = Split-Path -Parent $MyInvocation.MyCommand.Path
cd $fileDir
java '-Dtalend.component.manager.m2.repository=%cd%/../lib' ${talend.job.jvmargs.ps1} -cp ${talend.job.ps1.classpath} ${talend.job.class} ${talend.job.bat.addition} %*
$fileDir = Split-Path -Parent $MyInvocation.MyCommand.Path
cd $fileDir
java '-Dtalend.component.manager.m2.repository=%cd%/../lib' ${talend.job.jvmargs.ps1} -cp ${talend.job.ps1.classpath} ${talend.job.class} ${talend.job.bat.addition} $args

View File

@@ -95,6 +95,7 @@ import org.talend.commons.exception.SystemException;
import org.talend.commons.ui.runtime.exception.RuntimeExceptionHandler;
import org.talend.commons.utils.generation.JavaUtils;
import org.talend.commons.utils.resource.FileExtensions;
import org.talend.commons.utils.system.EnvironmentUtils;
import org.talend.core.CorePlugin;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.PluginChecker;
@@ -273,7 +274,7 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
}
private boolean isGuessSchemaJob(Property property) {
return "ID".equals(property.getId()) && "Mock_job_for_Guess_schema".equals(property.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
return property != null && "ID".equals(property.getId()) && "Mock_job_for_Guess_schema".equals(property.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
@@ -1182,7 +1183,12 @@ public class JavaProcessor extends AbstractJavaProcessor implements IJavaBreakpo
} else {
List<String> asList = convertArgsToList(cmd2);
if ((!isExternalUse() && isStandardJob()) || isGuessSchemaJob(property)) {
String localM2Path = "-Dtalend.component.manager.m2.repository=\"" + PomUtil.getLocalRepositoryPath() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
String localM2Path = "-Dtalend.component.manager.m2.repository="; //$NON-NLS-1$
if (EnvironmentUtils.isWindowsSystem()) {
localM2Path = localM2Path + "\"" + PomUtil.getLocalRepositoryPath() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
} else {
localM2Path = localM2Path + PomUtil.getLocalRepositoryPath();
}
asList.add(3, localM2Path);
}
return asList.toArray(new String[0]);

View File

@@ -500,8 +500,14 @@ public class MemoryRuntimeComposite extends ScrolledComposite implements IDynami
private boolean acquireJVM() {
long startTime = System.currentTimeMillis();
long endTime;
String remoteHost = processContext.getSelectedTargetExecutionConfig().getHost();
int remotePort = processContext.getSelectedTargetExecutionConfig().getRemotePort();
String remoteHost = null;
int remotePort = -1;
ITargetExecutionConfig targExecConfig = processContext.getSelectedTargetExecutionConfig();
// normally this value is always null in TOS
if (targExecConfig != null) {
remoteHost = targExecConfig.getHost();
remotePort = targExecConfig.getRemotePort();
}
while(true){
if ((processContext != null && !processContext.isRunning()) && !isReadyToStart) {
return false;

View File

@@ -3215,6 +3215,14 @@
name="RenameTCOMPCouchbaseMigrationTask"
version="7.2.1">
</projecttask>
<projecttask
beforeLogon="false"
class="org.talend.repository.model.migration.AddEncodingTypeForDQComponentsTask"
description="Add the encoding type for some dq components"
id="org.talend.repository.model.migration.AddEncodingTypeForDQComponentsTask"
name="AddEncodingTypeForDQComponentsTask"
version="7.3.1">
</projecttask>
</extension>
<extension

View File

@@ -0,0 +1,112 @@
// ============================================================================
//
// 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.migration.AbstractJobMigrationTask;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.core.model.properties.Item;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
/**
* Migration for added the combo list of encoding type
*/
public class AddEncodingTypeForDQComponentsTask extends AbstractJobMigrationTask {
/*
* (non-Javadoc)
*
* @see org.talend.migration.IMigrationTask#getOrder()
*/
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2019, 7, 9, 0, 0, 0);
return gc.getTime();
}
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
try {
IComponentFilter filter = new IComponentFilter() {
final transient List<String> names = new ArrayList<String>() {
private static final long serialVersionUID = 1L;
{
add("tDataMasking"); //$NON-NLS-1$
add("tPatternMasking"); //$NON-NLS-1$
add("tPatternUnmasking"); //$NON-NLS-1$
add("tRuleSurvivorship"); //$NON-NLS-1$
}
};
@Override
public boolean accept(NodeType node) {
return names.contains(node.getComponentName());
}
};
IComponentConversion checkGIDType = new CheckGIDType();
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion> asList(checkGIDType));
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
private class CheckGIDType implements IComponentConversion {
@Override
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "ENCODING") == null) { //$NON-NLS-1$
ElementParameterType encodingContent = TalendFileFactory.eINSTANCE.createElementParameterType();
encodingContent.setName("ENCODING"); //$NON-NLS-1$
encodingContent.setField(EParameterFieldType.ENCODING_TYPE.getName());
encodingContent.setValue("\"\""); //$NON-NLS-1$
node.getElementParameter().add(encodingContent);
}
if (ComponentUtilities.getNodeProperty(node, "ENCODING:ENCODING_TYPE") == null) { //$NON-NLS-1$
ElementParameterType encodingType = TalendFileFactory.eINSTANCE.createElementParameterType();
encodingType.setName("ENCODING:ENCODING_TYPE"); //$NON-NLS-1$
encodingType.setField(EParameterFieldType.TECHNICAL.getName());
encodingType.setValue("CUSTOM"); //$NON-NLS-1$
node.getElementParameter().add(encodingType);
}
}
}
}

View File

@@ -16,7 +16,6 @@ import org.eclipse.jface.viewers.Viewer;
import org.talend.core.model.metadata.MetadataTable;
import org.talend.core.model.metadata.Query;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.repository.model.IRepositoryNode.ENodeType;
import org.talend.repository.model.RepositoryNode;
/**
@@ -57,8 +56,10 @@ public class QueryTypeProcessor extends SingleTypeProcessor {
if (isCDCConnection(node)) {
return false;
}
if (node.getType() == ENodeType.STABLE_SYSTEM_FOLDER) {
return false;
if (node.getObject() == null && node.getParent() != null) {
if (ERepositoryObjectType.METADATA.equals(node.getParent().getContentType())) {
return false;
}
}
return true;
}

View File

@@ -156,6 +156,7 @@
<module>test/plugins/org.talend.designer.webservice.test</module>
<module>test/plugins/org.talend.designer.scd.test</module>
<module>test/plugins/org.talend.designer.unifiedcomponent.test</module>
<module>test/plugins/org.talend.sdk.component.studio-integration.test</module>
</modules>
<build>
<plugins>

View File

@@ -0,0 +1,143 @@
// ============================================================================
//
// 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 core.ui.editor.cmd;
import java.util.ArrayList;
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.INode;
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.ui.editor.cmd.ChangeActivateStatusElementCommand;
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 jding class global comment. Detailled comment
*/
public class ChangeActivateStatusElementCommandTest {
@Test
public void testGetExactConnectionsBetweenNodes() {
String nodestr = "tMysqlInput";
String nodestr1 = "tLogRow";
IComponent tMysqlComponent = ComponentsFactoryProvider.getInstance().get(nodestr,
ComponentCategory.CATEGORY_4_DI.getName());
IComponent tLogRowComponent = ComponentsFactoryProvider.getInstance().get(nodestr1,
ComponentCategory.CATEGORY_4_DI.getName());
Property property = PropertiesFactory.eINSTANCE.createProperty();
Process process = new Process(property);
// Flow1 BaseNode->Node1->Node2
Node baseNode = new Node(tMysqlComponent, process);
Node node1 = new Node(tLogRowComponent, process);
Node node2 = new Node(tLogRowComponent, process);
IConnection conn1 = createConnection(baseNode, node1);
((List<IConnection>) baseNode.getOutgoingConnections()).add(conn1);
((List<IConnection>) node1.getIncomingConnections()).add(conn1);
IConnection conn2 = createConnection(node1, node2);
((List<IConnection>) node1.getOutgoingConnections()).add(conn2);
((List<IConnection>) node2.getIncomingConnections()).add(conn2);
// Flow2 BaseNode->Node3->Node4
Node node3 = new Node(tLogRowComponent, process);
Node node4 = new Node(tLogRowComponent, process);
IConnection conn3 = createConnection(baseNode, node3);
((List<IConnection>) baseNode.getOutgoingConnections()).add(conn3);
((List<IConnection>) node3.getIncomingConnections()).add(conn3);
IConnection conn4 = createConnection(node3, node4);
((List<IConnection>) node3.getOutgoingConnections()).add(conn4);
((List<IConnection>) node4.getIncomingConnections()).add(conn4);
// Flow3 BaseNode->Node5->Node6
Node node5 = new Node(tLogRowComponent, process);
Node node6 = new Node(tLogRowComponent, process);
IConnection conn5 = createConnection(baseNode, node5);
((List<IConnection>) baseNode.getOutgoingConnections()).add(conn5);
((List<IConnection>) node5.getIncomingConnections()).add(conn5);
IConnection conn6 = createConnection(node5, node6);
((List<IConnection>) node5.getOutgoingConnections()).add(conn6);
((List<IConnection>) node6.getIncomingConnections()).add(conn6);
// case1 All activate
List<INode> nodeList = new ArrayList<INode>();
nodeList.add(baseNode);
nodeList.add(node1);
nodeList.add(node3);
nodeList.add(node5);
List<IConnection> connList = new ArrayList<IConnection>();
// connList conn1,conn3,conn5
connList.add(conn1);
connList.add(conn3);
connList.add(conn5);
List<IConnection> exactConnection = ChangeActivateStatusElementCommand.getExactConnectionsBetweenNodes(baseNode, nodeList,
connList, true);
Assert.assertTrue(exactConnection.size() == 3);
Assert.assertTrue(exactConnection.contains(conn1));
Assert.assertTrue(exactConnection.contains(conn3));
Assert.assertTrue(exactConnection.contains(conn5));
// case2 Flow1 Flow3 deactivate
nodeList = new ArrayList<INode>();
nodeList.add(baseNode);
nodeList.add(node3);
// connList conn1,conn2,conn3,conn5,conn6
connList.add(conn2);
connList.add(conn6);
List<IConnection> exactConnection1 = ChangeActivateStatusElementCommand.getExactConnectionsBetweenNodes(baseNode,
nodeList,
connList, true);
Assert.assertTrue(exactConnection1.size() == 1);
Assert.assertTrue(exactConnection1.contains(conn3));
// case3 Flow1 deactivate, Node3 & Node5 deactivate
nodeList = new ArrayList<INode>();
nodeList.add(baseNode);
nodeList.add(node4);
nodeList.add(node6);
// connList conn1,conn2,conn3,conn4,conn5,conn6
connList.add(conn4);
List<IConnection> exactConnection2 = ChangeActivateStatusElementCommand.getExactConnectionsBetweenNodes(baseNode,
nodeList, connList, true);
Assert.assertTrue(exactConnection2.size() == 4);
Assert.assertTrue(exactConnection2.contains(conn3));
Assert.assertTrue(exactConnection2.contains(conn4));
Assert.assertTrue(exactConnection2.contains(conn5));
Assert.assertTrue(exactConnection2.contains(conn6));
// case4 Flow2 inComing, Node3 deactivate
nodeList = new ArrayList<INode>();
nodeList.add(node4);
nodeList.add(baseNode);
List<IConnection> exactConnection3 = ChangeActivateStatusElementCommand.getExactConnectionsBetweenNodes(node4, nodeList,
connList, false);
Assert.assertTrue(exactConnection3.size() == 2);
Assert.assertTrue(exactConnection2.contains(conn3));
Assert.assertTrue(exactConnection2.contains(conn4));
}
private Connection createConnection(Node sourceNode, Node targetNode) {
Connection connection = new Connection(sourceNode, targetNode, EConnectionType.FLOW_MAIN, false);
return connection;
}
}

View File

@@ -1,30 +0,0 @@
// ============================================================================
//
// 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 java;
import org.junit.Test;
/**
* DOC bqian class global comment. Detailled comment <br/>
*
*/
public class JavaProcessorTest {
/**
* Test method for {@link org.talend.designer.runprocess.Processor#replaceSnippet(java.lang.String)}.
*/
@Test
public void testReplaceSnippet() {
}
}

View File

@@ -0,0 +1,136 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.designer.runprocess.java;
import java.util.Arrays;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import org.talend.commons.utils.VersionUtils;
import org.talend.commons.utils.generation.JavaUtils;
import org.talend.commons.utils.system.EnvironmentUtils;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
import org.talend.designer.core.ui.editor.process.Process;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.runprocess.ProcessorException;
import org.talend.designer.runprocess.ProcessorUtilities;
/**
*
* created by hcyi on Jul 22, 2019 Detailled comment
*
*/
public class JavaProcessorTest {
/**
* Test method for {@link org.talend.designer.runprocess.Processor#replaceSnippet(java.lang.String)}.
*
* @throws ProcessorException
*/
@Test
public void testReplaceSnippet() throws ProcessorException {
}
@Test
public void testGetCommandLine4ExportConfig() throws ProcessorException {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setId("_rHnrstwXEeijXfdWFqSaEA"); //$NON-NLS-1$
property.setLabel("test"); //$NON-NLS-1$
property.setVersion(VersionUtils.DEFAULT_VERSION);
Process process = new Process(property);
JavaProcessor processor = new JavaProcessor(process, property, false);
// only for export
ProcessorUtilities.setExportConfig(JavaUtils.JAVA_APP_NAME, null, null);
String[] cmd = processor.getCommandLine();
Assert.assertTrue(cmd.length > 2);
Assert.assertEquals(processor.extractAheadCommandSegments().toString(), Arrays.asList(cmd).subList(0, 2).toString());
}
@Test
public void testGetCommandLine4ExecutionIsNotStandardJob() throws ProcessorException {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setId("_rHnrstwXEeijXfdWFqSaEA"); //$NON-NLS-1$
property.setLabel("test"); //$NON-NLS-1$
property.setVersion(VersionUtils.DEFAULT_VERSION);
Process process = new Process(property);
JavaProcessor processor = new JavaProcessor(process, property, false);
//
ProcessorUtilities.setExportConfig(JavaUtils.JAVA_APP_NAME, null, null, false, new Date());
String[] cmd = processor.getCommandLine();
Assert.assertFalse(Arrays.asList(cmd).contains(getLocalM2Path()));
}
@Test
public void testGetCommandLine4ExecutionIsStandardJob() throws ProcessorException {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setId("_rHnrstwXEeijXfdWFqSaEA"); //$NON-NLS-1$
property.setLabel("test"); //$NON-NLS-1$
property.setVersion(VersionUtils.DEFAULT_VERSION);
ProcessItem processItem = PropertiesFactory.eINSTANCE.createProcessItem();
processItem.setProperty(property);
processItem.setProcess(TalendFileFactory.eINSTANCE.createProcessType());
processItem.setState(PropertiesFactory.eINSTANCE.createItemState());
Process process = new Process(property);
JavaProcessor processor = new JavaProcessor(process, property, false);
//
ProcessorUtilities.setExportConfig(JavaUtils.JAVA_APP_NAME, null, null, false, new Date());
String[] cmd = processor.getCommandLine();
Assert.assertTrue(Arrays.asList(cmd).contains(getLocalM2Path()));
Assert.assertEquals(getLocalM2Path(), Arrays.asList(cmd).get(3));
}
@Test
public void testGetCommandLine4ExecutionIsGuessSchemaJob() throws ProcessorException {
Property property = PropertiesFactory.eINSTANCE.createProperty();
property.setId("ID"); //$NON-NLS-1$
property.setLabel("Mock_job_for_Guess_schema"); //$NON-NLS-1$
property.setVersion(VersionUtils.DEFAULT_VERSION);
Process process = new Process(property);
JavaProcessor processor = new JavaProcessor(process, property, false);
//
ProcessorUtilities.setExportConfig(JavaUtils.JAVA_APP_NAME, null, null, false, new Date());
String[] cmd = processor.getCommandLine();
Assert.assertTrue(Arrays.asList(cmd).contains(getLocalM2Path()));
Assert.assertEquals(getLocalM2Path(), Arrays.asList(cmd).get(3));
}
private String getLocalM2Path() {
String localM2Path = "-Dtalend.component.manager.m2.repository="; //$NON-NLS-1$
if (EnvironmentUtils.isWindowsSystem()) {
localM2Path = localM2Path + "\"" + PomUtil.getLocalRepositoryPath() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
} else {
localM2Path = localM2Path + PomUtil.getLocalRepositoryPath();
}
return localM2Path;
}
}

View File

@@ -0,0 +1,112 @@
package org.talend.repository.ui.processor;
import org.junit.Assert;
import org.junit.Test;
import org.talend.commons.ui.runtime.image.ECoreImage;
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.properties.DatabaseConnectionItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.FakePropertyImpl;
import org.talend.core.model.repository.RepositoryViewObject;
import org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.model.IRepositoryNode.ENodeType;
import org.talend.repository.model.IRepositoryNode.EProperties;
import org.talend.repository.model.RepositoryNode;
import org.talend.repository.model.StableRepositoryNode;
// ============================================================================
//
// 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
//
// ============================================================================
/**
* created by hcyi on Jul 12, 2019
* Detailled comment
*
*/
public class QueryTypeProcessorTest {
@Test
public void testSelectRepositoryNode4SimpleFolder() {
QueryTypeProcessor query = new QueryTypeProcessor(null);
//
RepositoryNode parent = new RepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
parent.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA);
parent.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA);
parent.setType(ENodeType.STABLE_SYSTEM_FOLDER);
// simple folder
Property property1 = new FakePropertyImpl();
Item item1 = PropertiesFactory.eINSTANCE.createFolderItem();
property1.setItem(item1);
RepositoryViewObject object1 = new RepositoryViewObject(property1, true);
RepositoryNode node1 = new RepositoryNode(object1, parent, ENodeType.SIMPLE_FOLDER);
Assert.assertEquals(node1.getObjectType().getType(), ERepositoryObjectType.FOLDER.getType());
Assert.assertTrue(query.selectRepositoryNode(null, parent, node1));
}
@Test
public void testSelectRepositoryNode4MetadataConnections() {
QueryTypeProcessor query = new QueryTypeProcessor(null);
//
RepositoryNode parent = new RepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
parent.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA);
parent.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA);
parent.setType(ENodeType.STABLE_SYSTEM_FOLDER);
// metadata connections
Property property2 = new FakePropertyImpl();
Item item2 = PropertiesFactory.eINSTANCE.createFolderItem();
property2.setItem(item2);
RepositoryNode node2 = new RepositoryNode(null, parent, ENodeType.STABLE_SYSTEM_FOLDER);
node2.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CONNECTIONS);
node2.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CONNECTIONS);
Assert.assertFalse(query.selectRepositoryNode(null, parent, node2));
}
@Test
public void testSelectRepositoryNode4CDC() {
QueryTypeProcessor query = new QueryTypeProcessor(null);
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
// db connection
Property property = new FakePropertyImpl();
DatabaseConnectionItem item = PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
property.setItem(item);
RepositoryViewObject object = new RepositoryViewObject(property, true);
RepositoryNode cdcNode = new RepositoryNode(object, null, ENodeType.STABLE_SYSTEM_FOLDER);
cdcNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CONNECTIONS);
cdcNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CONNECTIONS);
//
StableRepositoryNode connTypeNode = new StableRepositoryNode(cdcNode, "cdc1", ECoreImage.METADATA_CDC_CONN_ICON);
cdcNode.getChildren().add(connTypeNode);
MetadataTable inputTable = ConnectionFactory.eINSTANCE.createMetadataTable();
inputTable.setId(factory.getNextId());
inputTable.setLabel("Input1");//$NON-NLS-1$
MetadataTableRepositoryObject modelObj = new MetadataTableRepositoryObject(cdcNode.getObject(), inputTable);
modelObj.setLabel("testObject1");
RepositoryNode tableNode = new RepositoryNode(modelObj, connTypeNode, ENodeType.REPOSITORY_ELEMENT);
tableNode.setProperties(EProperties.LABEL, "testObject1");
tableNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_CDC);
connTypeNode.getChildren().add(tableNode);
Assert.assertFalse(query.selectRepositoryNode(null, null, tableNode));
Assert.assertTrue(query.selectRepositoryNode(null, null, connTypeNode));
}
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/main/java">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.talend.sdk.component.studio-integration.test</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,23 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: SDK studio-integration test
Bundle-SymbolicName: org.talend.sdk.component.studio-integration.test
Bundle-Version: 7.3.1.qualifier
Fragment-Host: org.talend.sdk.component.studio-integration
Automatic-Module-Name: org.talend.sdk.component.studio-integration.test
Bundle-Vendor: .Talend SA.
Export-Package: org.talend.sdk.component.studio;
uses:="org.talend.sdk.component.studio.debounce,
org.talend.sdk.component.studio.metadata,
org.talend.sdk.component.studio.service,
org.talend.sdk.component.studio.websocket",
org.talend.sdk.component.studio.debounce,
org.talend.sdk.component.studio.lang,
org.talend.sdk.component.studio.model.connector,
org.talend.sdk.component.studio.model.parameter;uses:="org.talend.sdk.component.studio,org.talend.sdk.component.studio.model.parameter.command",
org.talend.sdk.component.studio.model.parameter.listener;uses:="org.talend.sdk.component.studio.model.action,org.talend.sdk.component.studio.model.parameter",
org.talend.sdk.component.studio.service
Require-Bundle: org.junit,
org.junit.jupiter.api,
org.talend.testutils,
org.eclipse.jdt.core

View File

@@ -0,0 +1 @@
jarprocessor.exclude.children=true

View File

@@ -0,0 +1,4 @@
source.. = src/main/java/
output.. = bin/
bin.includes = META-INF/,\
.

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tdi-studio-se</artifactId>
<version>7.3.1-SNAPSHOT</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.sdk.component.studio-integration.test</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View File

@@ -0,0 +1,64 @@
/**
* Copyright (C) 2006-2019 Talend Inc. - www.talend.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.talend.sdk.component.studio.debounce;
import static java.lang.Thread.sleep;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
public class DebounceManagerTest {
@Test
public void debounce() throws InterruptedException {
try (final DebounceManager manager = new DebounceManager()) {
final DebouncedAction action = manager.createAction();
final Collection<Long> timestamps = new ArrayList<>();
action.debounce(() -> timestamps.add(System.nanoTime()), 1000);
sleep(1500);
assertEquals(1, timestamps.size());
// execute only once
sleep(1500);
assertEquals(1, timestamps.size());
// can be reused
timestamps.clear();
action.debounce(() -> timestamps.add(System.nanoTime()), 1000);
sleep(1500);
assertEquals(1, timestamps.size());
// can be updated
timestamps.clear();
final long start = System.nanoTime();
action.debounce(() -> timestamps.add(0L), 1000);
sleep(500);
action.debounce(() -> timestamps.add(System.nanoTime()), 1000);
sleep(1300);
assertEquals(1, timestamps.size());
final long waitDuration = timestamps.iterator().next() - start;
// 1s after the last update which happens after 500ms
assertEquals(TimeUnit.NANOSECONDS.toMillis(waitDuration), 1500, 100);
// ensure we can start an action and close the manager without errors
action.debounce(() -> timestamps.add(System.nanoTime()), 10000);
}
}
}

View File

@@ -0,0 +1,37 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.sdk.component.studio.lang;
import org.junit.jupiter.api.Assertions;
import org.junit.Test;
public class StringsTest {
@Test
public void testRequireNonEmpty() {
final String expected = "some string";
final String actual = Strings.requireNonEmpty(expected);
Assertions.assertEquals(expected, actual);
IllegalArgumentException e = Assertions.assertThrows(IllegalArgumentException.class, () -> Strings.requireNonEmpty(""));
Assertions.assertEquals("String arg should not be empty", e.getMessage());
}
@Test
public void testRemoveQuotes() {
Assertions.assertEquals("some string", Strings.removeQuotes("\"some string\""));
Assertions.assertEquals("some\"inner\" string", Strings.removeQuotes("\"some\"inner\" string\""));
Assertions.assertEquals("\"some string", Strings.removeQuotes("\"some string"));
Assertions.assertEquals("some string\"", Strings.removeQuotes("some string\""));
}
}

View File

@@ -0,0 +1,72 @@
/**
* Copyright (C) 2006-2019 Talend Inc. - www.talend.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.talend.sdk.component.studio.model.connector;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Assertions;
import org.junit.Test;
import org.talend.core.model.process.EConnectionType;
/**
* Unit-tests for {@link AbstractConnectorCreator}
*/
public class AbstractConnectorCreatorTest {
private static final String DEFAULT = "__default__";
@Test
public void testGetTypeDefault() {
EConnectionType expectedType = EConnectionType.FLOW_MAIN;
EConnectionType actualType = AbstractConnectorCreator.getType(DEFAULT);
assertEquals(expectedType, actualType);
}
@Test
public void testGetTypeMain() {
EConnectionType expectedType = EConnectionType.FLOW_MAIN;
EConnectionType actualType = AbstractConnectorCreator.getType("Main");
assertEquals(expectedType, actualType);
}
@Test
public void testGetTypeReject() {
EConnectionType expectedType = EConnectionType.REJECT;
EConnectionType actualType = AbstractConnectorCreator.getType("reject");
assertEquals(expectedType, actualType);
}
@Test
public void testGetTypeRejectUpperCase() {
EConnectionType expectedType = EConnectionType.REJECT;
EConnectionType actualType = AbstractConnectorCreator.getType("REJECT");
assertEquals(expectedType, actualType);
}
@Test
public void testGetNameDefault() {
String expectedName = EConnectionType.FLOW_MAIN.getName();
String actualName = AbstractConnectorCreator.getName(DEFAULT);
assertEquals(expectedName, actualName);
}
@Test
public void testGetNameAny() {
String expectedName = "Any";
String actualName = AbstractConnectorCreator.getName("Any");
assertEquals(expectedName, actualName);
}
}

View File

@@ -0,0 +1,139 @@
package org.talend.sdk.component.studio.model.parameter;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Test;
import org.talend.core.model.metadata.IMetadataColumn;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MetadataColumn;
import org.talend.core.model.metadata.MetadataTable;
import org.talend.designer.core.ui.editor.nodes.Node;
import org.talend.sdk.component.studio.lang.Pair;
import org.talend.sdk.component.studio.model.action.IActionParameter;
public class OutputSchemaParameterTest {
private static final String CONNECTOR_NAME = "FLOW";
@Test
public void testCreateActionParameter() {
final Node nodeMock = mockNode(metadata());
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true);
final IActionParameter actionParameter = parameter.createActionParameter("param");
final Collection<Pair<String, String>> parameters = actionParameter.parameters();
assertEquals(2, parameters.size());
final Iterator<Pair<String, String>> iterator = parameters.iterator();
assertEquals(new Pair<String, String>("param[0]", "c1"), iterator.next());
assertEquals(new Pair<String, String>("param[1]", "c2"), iterator.next());
}
@Test
public void testGetValue() {
final Node nodeMock = mockNode(metadata());
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true);
assertEquals(Arrays.asList("c1", "c2"), parameter.getValue());
}
@Test
public void testGetValueNoMetadata() {
final Node nodeMock = mockNode(null);
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true);
assertEquals(Collections.emptyList(), parameter.getValue());
}
@Test
public void testGetStringValue() {
final Node nodeMock = mockNode(metadata());
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true);
assertEquals("[c1, c2]", parameter.getStringValue());
}
@Test
public void testGetStringValueNoMetadata() {
final Node nodeMock = mockNode(null);
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true);
assertEquals("[]", parameter.getStringValue());
}
@Test
public void testSetValue() {
final IMetadataTable metadata = new MetadataTable();
final Node nodeMock = mockNode(metadata);
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true);
final List<String> schema = Arrays.asList("c1", "c2", "c3");
parameter.setValue(schema);
assertEquals(3, metadata.getListColumns().size());
final List<String> actualLabels = metadata.getListColumns().stream()
.map(IMetadataColumn::getLabel)
.collect(Collectors.toList());
assertEquals(Arrays.asList("c1", "c2", "c3"), actualLabels);
final List<String> actualDbColumnNames = metadata.getListColumns().stream()
.map(IMetadataColumn::getOriginalDbColumnName)
.collect(Collectors.toList());
assertEquals(Arrays.asList("c1", "c2", "c3"), actualDbColumnNames);
final List<String> actualTypes = metadata.getListColumns().stream()
.map(IMetadataColumn::getTalendType)
.collect(Collectors.toList());
assertEquals(Arrays.asList("id_String", "id_String", "id_String"), actualTypes);
}
/**
* Check there is no exception in case of MetadataTable is missed
*/
@Test
public void testSetValueNoMetadata() {
final Node nodeMock = mockNode(null);
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true);
final List<String> schema = Arrays.asList("c1", "c2", "c3");
parameter.setValue(schema);
}
@Test
public void testIsPersisted() {
final OutputSchemaParameter parameter = new OutputSchemaParameter(null, "schema", CONNECTOR_NAME, null, true);
assertFalse(parameter.isPersisted());
}
@Test
public void testGuessButtonName() {
assertEquals("Guess Schema_config.datastore.dataset", OutputSchemaParameter.guessButtonName("config.datastore.dataset"));
}
private Node mockNode(final IMetadataTable metadata) {
final Node nodeMock = mock(Node.class);
when(nodeMock.getMetadataFromConnector(CONNECTOR_NAME)).thenReturn(metadata);
return nodeMock;
}
private IMetadataTable metadata() {
final IMetadataTable metadata = new MetadataTable();
final List<IMetadataColumn> columns = new ArrayList<>();
final IMetadataColumn c1 = new MetadataColumn();
c1.setLabel("c1");
columns.add(c1);
final IMetadataColumn c2 = new MetadataColumn();
c2.setLabel("c2");
columns.add(c2);
metadata.setListColumns(columns);
return metadata;
}
}

View File

@@ -0,0 +1,171 @@
// ============================================================================
//
// 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.sdk.component.studio.model.parameter;
import org.junit.jupiter.api.Assertions;
import org.junit.Test;
import org.talend.core.model.process.EParameterFieldType;
import org.talend.sdk.component.studio.lang.Pair;
import org.talend.sdk.component.studio.model.action.IActionParameter;
import java.util.*;
public class TableElementParameterTest {
@Test
public void testCreateActionParameter() {
final List<Pair<String, String>> expected = new ArrayList<>();
final Pair<String, String> p1 = new Pair("t[0].id", "id value 0");
expected.add(p1);
final Pair<String, String> p2 = new Pair("t[0].name", "name 0");
expected.add(p2);
final Pair<String, String> p3 = new Pair("t[0].number", "number 0");
expected.add(p3);
final Pair<String, String> p4 = new Pair("t[1].id", "id value 1");
expected.add(p4);
final Pair<String, String> p5 = new Pair("t[1].name", "name 1");
expected.add(p5);
final Pair<String, String> p6 = new Pair("t[1].number", "number 1");
expected.add(p6);
final List<Map<String, String>> value = new ArrayList<>();
final Map<String, String> row1 = new LinkedHashMap<>();
row1.put("conf.table[].id", "id value 0");
row1.put("conf.table[].name", "name 0");
row1.put("conf.table[].number", "number 0");
value.add(row1);
final Map<String, String> row2 = new LinkedHashMap<>();
row2.put("conf.table[].id", "id value 1");
row2.put("conf.table[].name", "name 1");
row2.put("conf.table[].number", "number 1");
value.add(row2);
final TableElementParameter parameter = new TableElementParameter(null, Collections.emptyList());
parameter.setName("conf.table");
parameter.setValue(value);
final IActionParameter actionParameter = parameter.createActionParameter("t");
final Collection<Pair<String, String>> parameters = actionParameter.parameters();
Assertions.assertEquals(expected, parameters);
}
@Test
public void testCreateActionParameterNull() {
final List<Pair<String, String>> expected = new ArrayList<>();
final TableElementParameter parameter = new TableElementParameter(null, Collections.emptyList());
parameter.setName("conf.table");
final IActionParameter actionParameter = parameter.createActionParameter("t");
final Collection<Pair<String, String>> parameters = actionParameter.parameters();
Assertions.assertEquals(expected, parameters);
}
@Test
public void testCreateActionParameterEmpty() {
final List<Pair<String, String>> expected = new ArrayList<>();
final TableElementParameter parameter = new TableElementParameter(null, Collections.emptyList());
parameter.setName("conf.table");
parameter.setValue(new ArrayList<>());
final IActionParameter actionParameter = parameter.createActionParameter("t");
final Collection<Pair<String, String>> parameters = actionParameter.parameters();
Assertions.assertEquals(expected, parameters);
}
@Test
public void testSetValueFixClosedList() {
final List<Map<String, Object>> expectedValue = new ArrayList<>();
final Map<String, Object> expectedRow1 = new LinkedHashMap<>();
expectedRow1.put("conf.table[].check", "false");
expectedRow1.put("conf.table[].enum", "GREATER");
expectedValue.add(expectedRow1);
final CheckElementParameter col1 = new CheckElementParameter(null);
col1.setName("conf.table[].check");
col1.setFieldType(EParameterFieldType.CHECK);
final TaCoKitElementParameter col2 = new TaCoKitElementParameter(null);
final Object[] col2PossibleValues = new String[]{"GREATER", "LESS", "EQUALS"};
col2.setName("conf.table[].enum");
col2.setListItemsValue(col2PossibleValues);
col2.setFieldType(EParameterFieldType.CLOSED_LIST);
final TableElementParameter table = new TableElementParameter(null, Collections.emptyList());
final Object[] tableColumns = new Object[]{col1, col2};
table.setListItemsValue(tableColumns);
table.setName("conf.table");
final List<Map<String, Object>> newValue = new ArrayList<>();
final Map<String, Object> newRow1 = new LinkedHashMap<>();
newRow1.put("conf.table[].check", "false");
newRow1.put("conf.table[].enum", 0);
newValue.add(newRow1);
table.setValue(newValue);
Assertions.assertEquals(expectedValue, table.getValue());
}
@Test
public void testSetValueFromAction() {
final List<Map<String, Object>> expectedValue = new ArrayList<Map<String, Object>>();
final Map<String, Object> row1 = new HashMap<>();
row1.put("conf.updatableConfig.table[].check", true);
row1.put("conf.updatableConfig.table[].number", "1");
row1.put("conf.updatableConfig.table[].operator", "GREATER");
row1.put("conf.updatableConfig.table[].strColumn", "Talend");
expectedValue.add(row1);
final Map<String, Object> row2 = new HashMap<>();
row2.put("conf.updatableConfig.table[].check", false);
row2.put("conf.updatableConfig.table[].number", "2");
row2.put("conf.updatableConfig.table[].operator", "LESS");
row2.put("conf.updatableConfig.table[].strColumn", "The best");
expectedValue.add(row2);
final TableElementParameter table = new TableElementParameter(null, Collections.emptyList());
table.setName("conf.updatableConfig.table");
table.setFieldType(EParameterFieldType.TABLE);
final TaCoKitElementParameter column1 = new TaCoKitElementParameter(null);
column1.setFieldType(EParameterFieldType.CHECK);
column1.setName("conf.updatableConfig.table[].check");
final TaCoKitElementParameter column2 = new TaCoKitElementParameter(null);
column2.setFieldType(EParameterFieldType.TEXT);
column2.setName("conf.updatableConfig.table[].number");
final TaCoKitElementParameter column3 = new TaCoKitElementParameter(null);
column3.setFieldType(EParameterFieldType.CLOSED_LIST);
column3.setName("conf.updatableConfig.table[].operator");
final TaCoKitElementParameter column4 = new TaCoKitElementParameter(null);
column4.setFieldType(EParameterFieldType.TEXT);
column4.setName("conf.updatableConfig.table[].strColumn");
table.setListItemsValue(new Object[] {column1, column2, column3, column4});
final List<Object> tableValue = new ArrayList<>();
final Map<String, Object> tableRow1 = new HashMap<>();
tableRow1.put("check", true);
tableRow1.put("number", 1);
tableRow1.put("operator", "GREATER");
tableRow1.put("strColumn", "Talend");
tableValue.add(tableRow1);
final Map<String, Object> tableRow2 = new HashMap<>();
tableRow2.put("check", false);
tableRow2.put("number", 2);
tableRow2.put("operator", "LESS");
tableRow2.put("strColumn", "The best");
tableValue.add(tableRow2);
table.setValueFromAction(tableValue);
Assertions.assertEquals(expectedValue, table.getValue());
}
}

View File

@@ -0,0 +1,62 @@
/**
* Copyright (C) 2006-2019 Talend Inc. - www.talend.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.talend.sdk.component.studio.model.parameter;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
/**
* Unit-tests for {@link ValueConverter}
*/
public class ValueConverterTest {
@Test
public void testToTable() {
Map<String, Object> expected0 = new HashMap<>();
expected0.put("key1", "value11");
expected0.put("key2", "value12");
Map<String, Object> expected1 = new HashMap<>();
expected1.put("key1", "value21");
expected1.put("key2", "value22");
String table = "[{key1=value11, key2=value12}, {key1=value21, key2=value22}]";
List<Map<String, Object>> converted = ValueConverter.toTable(table);
assertEquals(2, converted.size());
assertEquals(expected0, converted.get(0));
assertEquals(expected1, converted.get(1));
}
@Test
public void testToTableNull() {
ArrayList<Map<String, Object>> empty = new ArrayList<>();
List<Map<String, Object>> actual = ValueConverter.toTable(null);
assertEquals(empty, actual);
}
@Test
public void testToTableEmpty() {
ArrayList<Map<String, Object>> empty = new ArrayList<>();
List<Map<String, Object>> actual = ValueConverter.toTable("");
assertEquals(empty, actual);
}
}

View File

@@ -0,0 +1,153 @@
/**
* Copyright (C) 2006-2019 Talend Inc. - www.talend.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.talend.sdk.component.studio.model.parameter.listener;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.beans.PropertyChangeEvent;
import java.util.HashMap;
import org.junit.Test;
import org.talend.sdk.component.studio.model.parameter.PropertyDefinitionDecorator.Condition;
import org.talend.sdk.component.studio.model.parameter.TaCoKitElementParameter;
import org.talend.sdk.component.studio.model.parameter.TextElementParameter;
import org.talend.sdk.component.studio.model.parameter.condition.ConditionGroup;
// todo: check why these tests are correct, seems it happens on the property change
// and not the relational conditions changes
public class ActiveIfListenerTest {
@Test
public void containsNegative() {
final TacokitTestParameter param = new TacokitTestParameter("-");
new ActiveIfListener(singletonList(
new ConditionGroup(
singletonList(new Condition(new String[] { "A" }, "a", false, "contains")), true)),
param, singletonMap("a", new TacokitTestParameter("foo")))
.propertyChange(new PropertyChangeEvent(param, "value", "bar", "foo"));
assertFalse(param.setShowValue);
}
@Test
public void contains() {
final TacokitTestParameter param = new TacokitTestParameter("-");
new ActiveIfListener(singletonList(
new ConditionGroup(
singletonList(new Condition(new String[] { "A" }, "a", false, "contains")), true)),
param, singletonMap("a", new TacokitTestParameter("bAr")))
.propertyChange(new PropertyChangeEvent(param, "value", "foo", "bAr"));
assertTrue(param.setShowValue);
}
@Test
public void containsLowercase() {
final TacokitTestParameter param = new TacokitTestParameter("-");
new ActiveIfListener(singletonList(
new ConditionGroup(
singletonList(new Condition(
new String[] { "a" }, "a", false, "contains(lowercase=true)")), true)),
param, singletonMap("a", new TacokitTestParameter("bAR")))
.propertyChange(new PropertyChangeEvent(param, "value", "foo", "bAr"));
assertTrue(param.setShowValue);
}
@Test
public void notActivatedCondition() {
final TacokitTestParameter param = new TacokitTestParameter("-");
new ActiveIfListener(singletonList(
new ConditionGroup(
singletonList(new Condition(new String[] { "A" }, "a", false, "DEFAULT")), true)),
param, singletonMap("a", new TacokitTestParameter("C")))
.propertyChange(new PropertyChangeEvent(param, "value", "foo", "bar"));
assertFalse(param.setShowValue);
}
@Test
public void singleCondition() {
final TacokitTestParameter param = new TacokitTestParameter("-");
new ActiveIfListener(singletonList(
new ConditionGroup(
singletonList(new Condition(new String[] { "A" }, "a", false, "DEFAULT")), true)),
param, singletonMap("a", new TacokitTestParameter("A")))
.propertyChange(new PropertyChangeEvent(param, "value", "foo", "bar"));
assertTrue(param.setShowValue);
}
@Test
public void andCondition() {
final TacokitTestParameter param = new TacokitTestParameter("-");
new ActiveIfListener(singletonList(
new ConditionGroup(
asList(
new Condition(new String[] { "A" }, "a", false, "DEFAULT"),
new Condition(new String[] { "B" }, "b", false, "DEFAULT")),
true)),
param, new HashMap<String, TaCoKitElementParameter>() {{
put("a", new TacokitTestParameter("A"));
put("b", new TacokitTestParameter("B"));
}}).propertyChange(new PropertyChangeEvent(param, "value", "foo", "bar"));
assertTrue(param.setShowValue);
}
@Test
public void orCondition() {
final TacokitTestParameter param = new TacokitTestParameter("-");
new ActiveIfListener(singletonList(
new ConditionGroup(
asList(
new Condition(new String[] { "A" }, "a", false, "DEFAULT"),
new Condition(new String[] { "B" }, "b", false, "DEFAULT")),
false)),
param, new HashMap<String, TaCoKitElementParameter>() {{
put("a", new TacokitTestParameter("A"));
put("b", new TacokitTestParameter("C"));
}}).propertyChange(new PropertyChangeEvent(param, "value", "foo", "bar"));
assertTrue(param.setShowValue);
}
private static class TacokitTestParameter extends TextElementParameter {
private final String value;
private boolean setShowValue;
private TacokitTestParameter(final String value) {
super(null);
this.value = value;
}
@Override
public String getValue() {
return value;
}
@Override
public void setShow(boolean show) {
this.setShowValue = show;
}
@Override
public void redraw() {
// no-op
}
@Override
public void firePropertyChange(final String name, final Object oldValue, final Object newValue) {
// no-op
}
}
}

View File

@@ -0,0 +1,70 @@
/**
* Copyright (C) 2006-2019 Talend Inc. - www.talend.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.talend.sdk.component.studio.model.parameter.listener;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Collection;
import java.util.stream.Stream;
import org.junit.Test;
import org.talend.sdk.component.studio.model.parameter.ValidationLabel;
public class PatternValidatorTest {
@Test
public void simpleRegex() {
Stream.of(
new RegexCases("\\S+@\\S+\\.\\S+", asList("foo@bar.com", "test.thing@dummy.provider.com"),
asList("wrong", "notgoodgmail.com")),
new RegexCases("^[a-zA-Z ]+$", asList("John Doe", "Some other Name"),
asList("@bsolutely wrong", "Not a Name v3")))
.flatMap(base -> Stream.of(base, new RegexCases("/^" + base.regex + "$/", base.validTexts, base.invalidTexts)))
.forEach(Runnable::run);
}
@Test
public void withFlags() {
new RegexCases("/[a-z]+/i", asList("foo", "FOO", "FoO"), asList("123", "@")).run();
}
private static class RegexCases implements Runnable {
private final PatternValidator regex;
private final Collection<String> validTexts;
private final Collection<String> invalidTexts;
private RegexCases(final String regex, final Collection<String> validTexts, final Collection<String> invalidTexts) {
this.regex = new PatternValidator(new ValidationLabel(null), regex);
this.validTexts = validTexts;
this.invalidTexts = invalidTexts;
}
@Override
public void run() {
validTexts.forEach(v -> validate(v, true));
invalidTexts.forEach(v -> validate(v, false));
}
private void validate(final String value, final boolean state) {
assertEquals(state, regex.validate(value), "Error in validating " + regex + " > " + value);
}
}
}

View File

@@ -0,0 +1,16 @@
package org.talend.sdk.component.studio.service;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
public class AsciidoctorServiceTest {
@Test
public void init() {
final AsciidoctorService instance = new AsciidoctorService();
String result = instance.convert("= Header");
assertEquals("<h1>Header</h1>",result.trim());
}
}

View File

@@ -0,0 +1,101 @@
/**
* Copyright (C) 2006-2019 Talend Inc. - www.talend.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.talend.sdk.component.studio.test;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.json.bind.annotation.JsonbCreator;
import javax.json.bind.annotation.JsonbProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.talend.core.model.process.IElementParameter;
import org.talend.sdk.component.server.front.model.ActionReference;
import org.talend.sdk.component.server.front.model.SimplePropertyDefinition;
import org.talend.sdk.component.studio.model.parameter.PropertyNode;
import org.talend.sdk.component.studio.model.parameter.TaCoKitElementParameter;
public class TestComponent {
public static final Logger LOG = LoggerFactory.getLogger(TestComponent.class);
private List<ActionReference> actions;
private String name;
private List<PropertyNode> nodes;
private List<SimplePropertyDefinition> properties;
private List<TaCoKitElementParameter> settings;
public static TestComponent load(final String resource) throws Exception {
try (final Jsonb jsonb = JsonbBuilder.create();
final InputStream stream =
Thread.currentThread().getContextClassLoader().getResourceAsStream(resource)) {
return jsonb.fromJson(stream, TestComponent.class);
}
}
@JsonbCreator
public TestComponent(@JsonbProperty("actions") final List<ActionReference> actions,
@JsonbProperty("name") final String name,
@JsonbProperty("properties") final List<SimplePropertyDefinition> properties,
@JsonbProperty("nodes") final List<PropertyNode> nodes,
@JsonbProperty("settings") final List<TaCoKitElementParameter> settings) {
this.actions = actions;
this.name = name;
this.properties = properties;
this.nodes = nodes;
this.settings = settings;
}
public String getName() {
return name;
}
public ActionReference getAction(final String name) {
return actions.stream()
.filter(a -> name.equals(a.getName()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("no action with name " + name));
}
public List<ActionReference> getActions() {
return new ArrayList<>(this.actions);
}
public PropertyNode getNode(final String name) {
return nodes.stream()
.filter(p -> name.equals(p.getProperty().getPath()))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("no property with name " + name));
}
public Map<String, IElementParameter> getSettings() {
final Map<String, IElementParameter> result = new HashMap<>();
settings.forEach(p -> {
result.put(p.getName(), p);
});
return result;
}
}