Compare commits
20 Commits
release/6.
...
xwen/(prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f774b05a9 | ||
|
|
8e3b894b40 | ||
|
|
ba09021891 | ||
|
|
54a65f277e | ||
|
|
fad19c1798 | ||
|
|
51023d952a | ||
|
|
c660e00a20 | ||
|
|
e19c349c0b | ||
|
|
2a36e4734b | ||
|
|
56be6a81ba | ||
|
|
1e39b0ae89 | ||
|
|
0d8a6cf4da | ||
|
|
4c35a9795b | ||
|
|
e77b75b74e | ||
|
|
62b792fa49 | ||
|
|
091ff2c3e2 | ||
|
|
06ba1e58db | ||
|
|
98bc21712c | ||
|
|
8fad24c729 | ||
|
|
175b875f5d |
@@ -113,6 +113,10 @@ public abstract class AbstractUIManager {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
public void openAutoMappingDialog() {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
public abstract AbstractMapperManager getAbstractMapperManager();
|
||||
|
||||
public abstract void refreshBackground(boolean forceRecalculate, boolean firstExecutionAfterTime);
|
||||
|
||||
@@ -31,6 +31,8 @@ public interface ITableEntry {
|
||||
|
||||
public String getParentName();
|
||||
|
||||
public String getTableName();
|
||||
|
||||
public IDataMapTable getParent();
|
||||
|
||||
public String getExpression();
|
||||
|
||||
@@ -291,7 +291,8 @@
|
||||
}
|
||||
%>
|
||||
} catch(java.lang.Exception ex_<%=cid%>) {
|
||||
rowstate_<%=cid%>.setException(ex_<%=cid%>);
|
||||
rowstate_<%=cid%>.setException(new RuntimeException(String.format("Couldn't parse value for column '%s' in '%s', value is '%s'. Details: %s",
|
||||
"<%= column.getLabel() %>", "<%=targetConnName %>", temp, ex_<%=cid%>), ex_<%=cid%>));
|
||||
}
|
||||
<%
|
||||
}
|
||||
@@ -306,7 +307,22 @@
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=defaultValue %>;
|
||||
<%
|
||||
if (!JavaTypesManager.NULL.equals(defaultValue)) {
|
||||
%>
|
||||
try {
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=defaultValue %>;
|
||||
} catch(java.lang.Exception ex_<%=cid%>) {
|
||||
rowstate_<%=cid%>.setException(new RuntimeException(String.format("Couldn't set default value for column '%s' in '%s'. Details: %s",
|
||||
"<%= column.getLabel() %>", "<%=targetConnName %>", ex_<%=cid%>), ex_<%=cid%>));
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=defaultValue %>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
@@ -800,7 +816,8 @@
|
||||
%>
|
||||
|
||||
} catch(java.lang.Exception ex_<%=cid%>) {
|
||||
rowstate_<%=cid%>.setException(ex_<%=cid%>);
|
||||
rowstate_<%=cid%>.setException(new RuntimeException(String.format("Couldn't parse value for column '%s' in '%s', value is '%s'. Details: %s",
|
||||
"<%= column.getLabel() %>", "<%=targetConnName %>", <%=sourceValueName%>[columnIndexWithD_<%=cid%>], ex_<%=cid%>), ex_<%=cid%>));
|
||||
}
|
||||
}else{
|
||||
<%
|
||||
@@ -812,7 +829,22 @@
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=defaultValue %>;
|
||||
<%
|
||||
if (!JavaTypesManager.NULL.equals(defaultValue)) {
|
||||
%>
|
||||
try {
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=defaultValue %>;
|
||||
} catch(java.lang.Exception ex_<%=cid%>) {
|
||||
rowstate_<%=cid%>.setException(new RuntimeException(String.format("Couldn't set default value for column '%s' in '%s'. Details: %s",
|
||||
"<%= column.getLabel() %>", "<%=targetConnName %>", ex_<%=cid%>), ex_<%=cid%>));
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=defaultValue %>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
@@ -843,7 +875,34 @@
|
||||
|
||||
<%if(!"id_Dynamic".equals(column.getTalendType())) {%>
|
||||
}else{
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=JavaTypesManager.getDefaultValueFromJavaType(typeToGenerate, column.getDefault()) %>;
|
||||
<%
|
||||
String defaultValue = JavaTypesManager.getDefaultValueFromJavaType(typeToGenerate, column.getDefault());
|
||||
boolean isJavaPrimitiveType = JavaTypesManager.isJavaPrimitiveType(javaType,column.isNullable());
|
||||
if((isJavaPrimitiveType && (column.getDefault()==null || column.getDefault().length() == 0))) {
|
||||
%>
|
||||
rowstate_<%=cid%>.setException(new RuntimeException("Value is empty for column : '<%= column.getLabel() %>' in '<%=targetConnName %>' connection, value is invalid or this column should be nullable or have a default value."));
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<%
|
||||
if (!JavaTypesManager.NULL.equals(defaultValue)) {
|
||||
%>
|
||||
try {
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=defaultValue %>;
|
||||
} catch(java.lang.Exception ex_<%=cid%>) {
|
||||
rowstate_<%=cid%>.setException(new RuntimeException(String.format("Couldn't set default value for column '%s' in '%s'. %s",
|
||||
"<%= column.getLabel() %>", "<%=targetConnName %>", ex_<%=cid%>), ex_<%=cid%>));
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
<%=targetConnName %>.<%=column.getLabel() %> = <%=defaultValue %>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
}
|
||||
<%}%>
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ String accessToken = helper.getStringParam("__ACCESS_TOKEN__");
|
||||
String folderName = helper.getStringParam("__FOLDER_NAME__");
|
||||
boolean useProxy = helper.getBoolParam("__USE_PROXY__");
|
||||
boolean useSSL = helper.getBoolParam("__USE_SSL__");
|
||||
boolean withTrashFiles = helper.getBoolParam("__INCLUDTRASHFILES__");
|
||||
|
||||
|
||||
String connection = ElementParameterParser.getValue(node,"__CONNECTION__");
|
||||
String connectionKey = "\"conn_" + connection+"\"";
|
||||
@@ -89,6 +91,8 @@ String proxyPort = helper.getStringParam("__PROXY_PORT__");
|
||||
java.util.List<com.google.api.services.drive.model.File> <%=cid%>_result = new java.util.ArrayList<com.google.api.services.drive.model.File>();
|
||||
com.google.api.services.drive.Drive.Files.List <%=cid%>_request = <%=cid%>_client.files().list();
|
||||
String <%=cid%>_folderName = <%=folderName%>;
|
||||
String <%=cid%>_qTrash = <% if (!withTrashFiles) {%>" and trashed=false"<% } else {%> "" <% } %>;
|
||||
|
||||
if (<%=cid%>_folderName == null || <%=cid%>_folderName.isEmpty())
|
||||
{
|
||||
throw new Exception("Folder name can not be empty");
|
||||
@@ -104,15 +108,15 @@ String proxyPort = helper.getStringParam("__PROXY_PORT__");
|
||||
do {
|
||||
|
||||
if(!<%=cid%>_folderName.equals("root")) {
|
||||
<%=cid%>_request.setQ("title = '" + <%=cid%>_folderName + "' and mimeType = 'application/vnd.google-apps.folder'");
|
||||
<%=cid%>_request.setQ("title = '" + <%=cid%>_folderName + "'"+<%=cid%>_qTrash+" and mimeType = 'application/vnd.google-apps.folder'");
|
||||
} else {
|
||||
|
||||
<%if ("BOTH".equals(helper.getStringParam("__LIST_MODE__"))) {%>
|
||||
<%=cid%>_request.setQ("'" + <%=cid%>_folderName + "' in parents");
|
||||
<%=cid%>_request.setQ("'" + <%=cid%>_folderName + "' in parents"+<%=cid%>_qTrash;
|
||||
<%} else if ("FILES".equals(helper.getStringParam("__LIST_MODE__"))) {%>
|
||||
<%=cid%>_request.setQ("'" + <%=cid%>_folderName + "' in parents and mimeType != 'application/vnd.google-apps.folder'");
|
||||
<%=cid%>_request.setQ("'" + <%=cid%>_folderName + "' in parents"+<%=cid%>_qTrash+" and mimeType != 'application/vnd.google-apps.folder'");
|
||||
<%} else {%>
|
||||
<%=cid%>_request.setQ("'" + <%=cid%>_folderName + "' in parents and mimeType = 'application/vnd.google-apps.folder'");
|
||||
<%=cid%>_request.setQ("'" + <%=cid%>_folderName + "' in parents"+<%=cid%>_qTrash+" and mimeType = 'application/vnd.google-apps.folder'");
|
||||
<%}%>
|
||||
}
|
||||
com.google.api.services.drive.model.FileList files = <%=cid%>_request.execute();
|
||||
@@ -124,11 +128,11 @@ String proxyPort = helper.getStringParam("__PROXY_PORT__");
|
||||
} else {
|
||||
<%=cid%>_request = <%=cid%>_client.files().list();
|
||||
<%if ("BOTH".equals(helper.getStringParam("__LIST_MODE__"))) {%>
|
||||
<%=cid%>_request.setQ("'" + files.getItems().get(0).getId() + "' in parents");
|
||||
<%=cid%>_request.setQ("'" + files.getItems().get(0).getId() + "' in parents"+<%=cid%>_qTrash);
|
||||
<%} else if ("FILES".equals(helper.getStringParam("__LIST_MODE__"))) {%>
|
||||
<%=cid%>_request.setQ("'" + files.getItems().get(0).getId() + "' in parents and mimeType != 'application/vnd.google-apps.folder'");
|
||||
<%=cid%>_request.setQ("'" + files.getItems().get(0).getId() + "' in parents"+<%=cid%>_qTrash+" and mimeType != 'application/vnd.google-apps.folder'");
|
||||
<%} else {%>
|
||||
<%=cid%>_request.setQ("'" + files.getItems().get(0).getId() + "' in parents and mimeType = 'application/vnd.google-apps.folder'");
|
||||
<%=cid%>_request.setQ("'" + files.getItems().get(0).getId() + "' in parents"+<%=cid%>_qTrash+" and mimeType = 'application/vnd.google-apps.folder'");
|
||||
<%}%>
|
||||
files = <%=cid%>_request.execute();
|
||||
}
|
||||
@@ -140,7 +144,7 @@ String proxyPort = helper.getStringParam("__PROXY_PORT__");
|
||||
<%} else {%>
|
||||
java.util.List<String> subfolders_<%=cid %> = new java.util.ArrayList<String>();
|
||||
if(!<%=cid%>_folderName.equals("root")) {
|
||||
<%=cid%>_request.setQ("title = '" + <%=cid%>_folderName + "' and mimeType = 'application/vnd.google-apps.folder'");
|
||||
<%=cid%>_request.setQ("title = '" + <%=cid%>_folderName + "'"+<%=cid%>_qTrash+" and mimeType = 'application/vnd.google-apps.folder'");
|
||||
com.google.api.services.drive.model.FileList <%=cid%>_files = <%=cid%>_request.execute();
|
||||
if (<%=cid%>_files.getItems().size() > 1) {
|
||||
throw new Exception("More than one folder with name " + "\"" + <%=cid%>_folderName + "\" found!");
|
||||
@@ -156,9 +160,9 @@ String proxyPort = helper.getStringParam("__PROXY_PORT__");
|
||||
while (subfolders_<%=cid %>.size()>0) {
|
||||
do {
|
||||
<%if ("DIRECTORIES".equals(helper.getStringParam("__LIST_MODE__"))) {%>
|
||||
<%=cid%>_request.setQ("'"+subfolders_<%=cid %>.get(0)+"' in parents and mimeType = 'application/vnd.google-apps.folder'");
|
||||
<%=cid%>_request.setQ("'"+subfolders_<%=cid %>.get(0)+"' in parents"+<%=cid%>_qTrash+" and mimeType = 'application/vnd.google-apps.folder'");
|
||||
<%} else {%>
|
||||
<%=cid%>_request.setQ("'"+subfolders_<%=cid %>.get(0)+"' in parents"); // check all files and folders
|
||||
<%=cid%>_request.setQ("'"+subfolders_<%=cid %>.get(0)+"' in parents"+<%=cid%>_qTrash); // check all files and folders
|
||||
<%}%>
|
||||
com.google.api.services.drive.model.FileList files = <%=cid%>_request.execute();
|
||||
|
||||
|
||||
@@ -93,6 +93,9 @@
|
||||
</PARAMETERS>
|
||||
|
||||
<ADVANCED_PARAMETERS>
|
||||
<PARAMETER NAME="INCLUDTRASHFILES" FIELD="CHECK" NUM_ROW="90">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION>
|
||||
|
||||
@@ -30,4 +30,6 @@ LIST_MODE.ITEM.DIRECTORIES=Directories
|
||||
LIST_MODE.ITEM.FILES=Files
|
||||
LIST_MODE.NAME=FileList Type
|
||||
FOLDER_NAME.NAME=Folder Name
|
||||
INCLUDSUBDIR.NAME=Includes subdirectories
|
||||
INCLUDSUBDIR.NAME=Includes subdirectories
|
||||
|
||||
INCLUDTRASHFILES.NAME=Include trash files
|
||||
@@ -1 +1,5 @@
|
||||
<%@ include file="../templates/DB/Close/AbstractDBClose.javajet"%>
|
||||
<%@ include file="../templates/DB/Close/AbstractDBClose.javajet"%>
|
||||
|
||||
if (null != java.sql.DriverManager.getLogWriter()) {
|
||||
java.sql.DriverManager.getLogWriter().close();
|
||||
}
|
||||
@@ -11,16 +11,28 @@ imports="
|
||||
|
||||
public void createURL(INode node) {
|
||||
super.createURL(node);
|
||||
|
||||
if(dbproperties == null || ("\"\"").equals(dbproperties) || ("").equals(dbproperties)) {
|
||||
%>
|
||||
String url_<%=cid %> = "jdbc:redshift://"+<%=dbhost%>+":"+<%=dbport%>+"/"+<%=dbname%>;
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
String url_<%=cid%> = "jdbc:redshift://" + <%=dbhost%> + ":" + <%=dbport%> + "/" + <%=dbname%> + "?" + <%=dbproperties%>;
|
||||
<%
|
||||
}
|
||||
|
||||
String logLevel= ElementParameterParser.getValue(node, "__LOG_LEVEL__");
|
||||
String logFile= ElementParameterParser.getValue(node, "__LOG_FILE__");
|
||||
|
||||
if (!logLevel.equals("0")) {
|
||||
%>
|
||||
java.io.Writer output_<%=cid %> = new java.io.FileWriter(<%= logFile %>, true);
|
||||
java.sql.DriverManager.setLogWriter(new java.io.PrintWriter(output_<%=cid %>,true));
|
||||
<%
|
||||
}
|
||||
%>
|
||||
StringBuilder sbuilder_<%=cid%> = new StringBuilder();
|
||||
sbuilder_<%=cid%>.append("jdbc:redshift://").append(<%=dbhost%>).append(":").append(<%=dbport%>).append("/").append(<%=dbname%>).append("?loglevel=").append(<%= logLevel %>);
|
||||
<%
|
||||
if(dbproperties != null && !"\"\"".equals(dbproperties) && !"".equals(dbproperties)) {
|
||||
%>
|
||||
sbuilder_<%=cid%>.append("&").append(<%=dbproperties%>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
String url_<%=cid%> = sbuilder_<%=cid%>.toString();
|
||||
<%
|
||||
}
|
||||
|
||||
public String getDirverClassName(INode node){
|
||||
@@ -33,7 +45,6 @@ imports="
|
||||
<%//----------------------------component codes-----------------------------------------%>
|
||||
|
||||
<%@ include file="../templates/DB/AbstractDBConnection.javajet"%>
|
||||
|
||||
globalMap.put("schema_" + "<%=cid%>",<%=dbschema%>);
|
||||
|
||||
globalMap.put("conn_" + "<%=cid%>",conn_<%=cid%>);
|
||||
|
||||
@@ -152,6 +152,23 @@
|
||||
</PARAMETERS>
|
||||
|
||||
<ADVANCED_PARAMETERS>
|
||||
<PARAMETER
|
||||
NAME="LOG_FILE"
|
||||
FIELD="FILE"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
>
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/redshift-jdbc.log"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="LOG_LEVEL" FIELD="CLOSED_LIST" NUM_ROW="12">
|
||||
<ITEMS DEFAULT="INFO">
|
||||
<ITEM NAME="NONE" VALUE="0" />
|
||||
<ITEM NAME="INFO" VALUE="1" />
|
||||
<ITEM NAME="DEBUG" VALUE="2" />
|
||||
</ITEMS>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="AUTO_COMMIT" FIELD="CHECK" NUM_ROW="10">
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
@@ -16,4 +16,9 @@ AUTO_COMMIT.NAME = Auto Commit
|
||||
TYPE.NAME=Database Driver
|
||||
PROPERTY.NAME=Property Type
|
||||
|
||||
LOG_FILE.NAME=Log file
|
||||
LOG_LEVEL.NAME=Logging level
|
||||
LOG_LEVEL.ITEM.NONE=None
|
||||
LOG_LEVEL.ITEM.INFO=Info
|
||||
LOG_LEVEL.ITEM.DEBUG=Debug
|
||||
PROPERTIES.NAME=Additional JDBC Parameters
|
||||
@@ -21,11 +21,13 @@ imports="
|
||||
|
||||
String logLevel= ElementParameterParser.getValue(node, "__LOG_LEVEL__");
|
||||
String logFile= ElementParameterParser.getValue(node, "__LOG_FILE__");
|
||||
if (!logLevel.equals("0")) {
|
||||
%>
|
||||
if (<%= logLevel %> > 0) {
|
||||
java.io.Writer output_<%=cid %> = new java.io.FileWriter(<%= logFile %>, true);
|
||||
java.sql.DriverManager.setLogWriter(new java.io.PrintWriter(output_<%=cid %>,true));
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
StringBuilder sbuilder_<%=cid%> = new StringBuilder();
|
||||
sbuilder_<%=cid%>.append("jdbc:redshift://").append(<%=dbhost%>).append(":").append(<%=dbport%>).append("/").append(<%=dbname%>).append("?loglevel=").append(<%= logLevel %>);
|
||||
|
||||
@@ -1 +1,11 @@
|
||||
<%@ include file="../templates/DB/Input/AbstractDBInputEnd.javajet"%>
|
||||
<%@ include file="../templates/DB/Input/AbstractDBInputEnd.javajet"%>
|
||||
|
||||
<%
|
||||
if ("false".equalsIgnoreCase(ElementParameterParser.getValue(node, "__USE_EXISTING_CONNECTION__"))) {
|
||||
%>
|
||||
if (null != java.sql.DriverManager.getLogWriter()) {
|
||||
java.sql.DriverManager.getLogWriter().close();
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
@@ -203,11 +203,12 @@
|
||||
FIELD="FILE"
|
||||
NUM_ROW="10"
|
||||
REQUIRED="true"
|
||||
SHOW_IF="USE_EXISTING_CONNECTION == 'false'"
|
||||
>
|
||||
<DEFAULT>"__COMP_DEFAULT_FILE_DIR__/redshift-jdbc.log"</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
<PARAMETER NAME="LOG_LEVEL" FIELD="CLOSED_LIST" NUM_ROW="12">
|
||||
<PARAMETER NAME="LOG_LEVEL" FIELD="CLOSED_LIST" NUM_ROW="12" SHOW_IF="USE_EXISTING_CONNECTION == 'false'">
|
||||
<ITEMS DEFAULT="INFO">
|
||||
<ITEM NAME="NONE" VALUE="0" />
|
||||
<ITEM NAME="INFO" VALUE="1" />
|
||||
|
||||
@@ -133,6 +133,8 @@ if(tableNameWithSchema){
|
||||
if(dbschema_<%=cid%> != null && dbschema_<%=cid%>.trim().length() > 0) {
|
||||
tableName_<%=cid%> = dbschema_<%=cid%> + "\".\"" + tableName_<%=cid%>;
|
||||
}
|
||||
|
||||
schemaForSearch_<%=cid %> = dbschema_<%=cid%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -94,7 +94,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
|
||||
} else if((javaType == JavaTypesManager.BIGDECIMAL) && changeHashAndEqualsForBigDecimal) {
|
||||
%>
|
||||
result = prime * result + ((this.<%=column.getLabel() %> == null) ? 0 : new Double(this.<%=column.getLabel() %>.doubleValue()).hashCode());
|
||||
result = prime * result + ((this.<%=column.getLabel() %> == null) ? 0 : this.<%=column.getLabel() %>.stripTrailingZeros().hashCode());
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
@@ -142,7 +142,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
if (other.<%=column.getLabel() %> != null)
|
||||
return false;
|
||||
<%if((javaType == JavaTypesManager.BIGDECIMAL) && changeHashAndEqualsForBigDecimal) {%>
|
||||
} else if ((other.<%=column.getLabel() %> == null) || (this.<%=column.getLabel() %>.compareTo(other.<%=column.getLabel() %>)!=0))
|
||||
} else if ((other.<%=column.getLabel() %> == null) || (this.<%=column.getLabel() %>.stripTrailingZeros().compareTo(other.<%=column.getLabel() %>.stripTrailingZeros())!=0))
|
||||
<%} else {%>
|
||||
} else if (!this.<%=column.getLabel() %>.equals(other.<%=column.getLabel() %>))
|
||||
<%}%>
|
||||
|
||||
@@ -147,6 +147,8 @@
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.ONLY_ONCE_EACH_DUPLICATED_KEY" TARGET="UniqIn.ONLY_ONCE_EACH_DUPLICATED_KEY"/>
|
||||
|
||||
<TEMPLATE_PARAM SOURCE="self.CHANGE_HASH_AND_EQUALS_FOR_BIGDECIMAL" TARGET="UniqOut.IGNORE_TRAILING_ZEROS_FOR_BIGDECIMAL"/>
|
||||
|
||||
</TEMPLATES>
|
||||
</CODEGENERATION>
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ if (("").equals(directory)) {
|
||||
directory=ElementParameterParser.getValue(node.getProcess(), "__COMP_DEFAULT_FILE_DIR__") + "/temp";
|
||||
}
|
||||
String cid = ElementParameterParser.getValue(node, "__CID__");
|
||||
boolean ignoreTrailingZerosForBigDecimal = "true".equalsIgnoreCase(ElementParameterParser.getValue(node, "__IGNORE_TRAILING_ZEROS_FOR_BIGDECIMAL__"));
|
||||
|
||||
String connName = "";
|
||||
if (node.getIncomingConnections().size()==1) {
|
||||
@@ -234,9 +235,21 @@ class rowStruct_<%=cid %> extends <%=connName %>Struct {
|
||||
if (other.<%=keyColumn.getLabel() %> == null) {
|
||||
return false;
|
||||
} else {
|
||||
<%
|
||||
if (ignoreTrailingZerosForBigDecimal) {
|
||||
%>
|
||||
if (!this.<%=keyColumn.getLabel() %>.stripTrailingZeros().equals(other.<%=keyColumn.getLabel() %>.stripTrailingZeros())) {
|
||||
return false;
|
||||
}
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
if (!this.<%=keyColumn.getLabel() %>.equals(other.<%=keyColumn.getLabel() %>)) {
|
||||
return false;
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
}
|
||||
}
|
||||
<%
|
||||
@@ -453,7 +466,17 @@ class Comparator_1_<%=cid %> implements Comparator<rowStruct_<%=cid %>> {
|
||||
if (arg1.<%=keyColumn.getLabel() %> == null) {
|
||||
return 1;
|
||||
} else {
|
||||
<%
|
||||
if (ignoreTrailingZerosForBigDecimal) {
|
||||
%>
|
||||
compare = arg0.<%=keyColumn.getLabel() %>.stripTrailingZeros().compareTo(arg1.<%=keyColumn.getLabel() %>.stripTrailingZeros());
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
compare = arg0.<%=keyColumn.getLabel() %>.compareTo(arg1.<%=keyColumn.getLabel() %>);
|
||||
<%
|
||||
}
|
||||
%>
|
||||
if (compare != 0) {
|
||||
return compare;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,17 @@
|
||||
|
||||
</PARAMETERS>
|
||||
|
||||
<ADVANCED_PARAMETERS/>
|
||||
<ADVANCED_PARAMETERS>
|
||||
|
||||
<PARAMETER
|
||||
NAME="IGNORE_TRAILING_ZEROS_FOR_BIGDECIMAL"
|
||||
FIELD="CHECK"
|
||||
NUM_ROW="3"
|
||||
>
|
||||
<DEFAULT>false</DEFAULT>
|
||||
</PARAMETER>
|
||||
|
||||
</ADVANCED_PARAMETERS>
|
||||
|
||||
<CODEGENERATION/>
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
String outputRowStructName = conns.get(0).getName()+"Struct";//row2
|
||||
%>
|
||||
int nb_line_<%=cid%> = 0;
|
||||
net.sf.json.xml.XMLSerializer xmlSerializer_<%=cid%> = new net.sf.json.xml.XMLSerializer();
|
||||
xmlSerializer_<%=cid%>.clearNamespaces();
|
||||
xmlSerializer_<%=cid%>.setSkipNamespaces(true);
|
||||
xmlSerializer_<%=cid%>.setForceTopLevelObject(<%=(removeRoot?false:true)%>);
|
||||
<%
|
||||
INode sourceNode = node.getIncomingConnections(EConnectionType.ON_COMPONENT_OK).get(0).getSource();
|
||||
String virtualSourceCid = sourceNode.getUniqueName();
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<IMPORT NAME="commons_lang" MODULE="commons-lang-2.6.jar" MVN="mvn:org.talend.libraries/commons-lang-2.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.apache.common/lib/commons-lang-2.6.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="commons_logging" MODULE="commons-logging-1.1.1.jar" MVN="mvn:org.talend.libraries/commons-logging-1.1.1/6.0.0" UrlPath="platform:/base/plugins/org.apache.commons.logging_1.1.1.v201101211721.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="ezmorph" MODULE="ezmorph-1.0.6.jar" MVN="mvn:org.talend.libraries/ezmorph-1.0.6/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jackson/lib/ezmorph-1.0.6.jar" REQUIRED="true" />
|
||||
<IMPORT NAME="json" MODULE="org.json.jar" MVN="mvn:org.talend.libraries/org.json/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jackson/lib/org.json.jar" REQUIRED="true"/>
|
||||
<IMPORT NAME="json-lib" MODULE="json-lib-2.4-jdk15.jar" MVN="mvn:org.talend.libraries/json-lib-2.4-jdk15/6.0.0" UrlPath="platform:/plugin/org.talend.libraries.jackson/lib/json-lib-2.4-jdk15.jar" REQUIRED="true" />
|
||||
</IMPORTS>
|
||||
</CODEGENERATION>
|
||||
|
||||
|
||||
@@ -102,7 +102,8 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
}
|
||||
%>
|
||||
//Convert XML to JSON
|
||||
<%=conn.getName()%>.<%=jsonField %> = org.json.XML.toJSONObject(str_<%=cid %>).toString();
|
||||
net.sf.json.JSON json_<%=cid%> = xmlSerializer_<%=cid%>.read(str_<%=cid %>);
|
||||
<%=conn.getName()%>.<%=jsonField %> = json_<%=cid%>.toString();
|
||||
|
||||
nb_line_<%=cid%>++;
|
||||
<%
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -756,6 +756,12 @@ public class CLASS {
|
||||
}
|
||||
public List<Column> getSearchingColumnList(SCDConfiger scdConfiger) {
|
||||
List<Column> columnList = new ArrayList<Column>();
|
||||
if(scdConfiger.isEnableType0()) {
|
||||
List<Column> type0Attributes = scdConfiger.getDimensionType0Configer().getDimensionAttributes();
|
||||
for(Column type0Attribute : type0Attributes) {
|
||||
columnList.add(type0Attribute);
|
||||
}
|
||||
}
|
||||
if(scdConfiger.isEnableType1()) {
|
||||
List<Column> type1Attributes = scdConfiger.getDimensionType1Configer().getDimensionAttributes();
|
||||
for(Column type1Attribute : type1Attributes) {
|
||||
@@ -853,6 +859,17 @@ public class CLASS {
|
||||
}
|
||||
searchingSQL.append(getLProtectedChar() + sourceKey.getColumnName() + getRProtectedChar());
|
||||
}
|
||||
if(scdConfiger.isEnableType0()) {
|
||||
List<Column> type0Attributes = scdConfiger.getDimensionType0Configer().getDimensionAttributes();
|
||||
for(Column type0Attribute : type0Attributes) {
|
||||
if(firstColumn) {
|
||||
firstColumn = false;
|
||||
} else {
|
||||
searchingSQL.append(separator);
|
||||
}
|
||||
searchingSQL.append(getLProtectedChar() + type0Attribute.getColumnName() + getRProtectedChar());
|
||||
}
|
||||
}
|
||||
if(scdConfiger.isEnableType1()) {
|
||||
List<Column> type1Attributes = scdConfiger.getDimensionType1Configer().getDimensionAttributes();
|
||||
for(Column type1Attribute : type1Attributes) {
|
||||
|
||||
@@ -90,6 +90,7 @@ import org.talend.core.ui.component.settings.ComponentsSettingsHelper;
|
||||
import org.talend.core.ui.services.IComponentsLocalProviderService;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.daikon.NamedThing;
|
||||
import org.talend.daikon.exception.TalendRuntimeException;
|
||||
import org.talend.daikon.properties.Properties;
|
||||
import org.talend.daikon.properties.presentation.Form;
|
||||
import org.talend.daikon.properties.property.Property;
|
||||
@@ -1149,6 +1150,9 @@ public class Component extends AbstractBasicComponent {
|
||||
} catch (Exception e) {
|
||||
if (node == null) {
|
||||
// not handled, must because the runtime info must have a node configuration (properties are null)
|
||||
} else if (e instanceof TalendRuntimeException) {
|
||||
// no need to check talend runtime exception in design time.
|
||||
e.printStackTrace(); // only for debug.
|
||||
} else {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,6 @@ import org.talend.designer.core.model.components.EParameterName;
|
||||
import org.talend.designer.core.model.components.ElementParameter;
|
||||
import org.talend.designer.core.model.process.jobsettings.JobSettingsManager;
|
||||
import org.talend.designer.core.model.process.statsandlogs.StatsAndLogsManager;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.AbstractExternalData;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType;
|
||||
import org.talend.designer.core.ui.AbstractMultiPageTalendEditor;
|
||||
import org.talend.designer.core.ui.editor.connections.Connection;
|
||||
@@ -270,17 +269,18 @@ public class DataProcess implements IGeneratingProcess {
|
||||
if (graphicalNode.getExternalNode() == null) {
|
||||
dataNode = new DataNode();
|
||||
} else {
|
||||
// mapper
|
||||
dataNode = (AbstractNode) ExternalNodesFactory.getInstance(graphicalNode.getComponent().getPluginExtension());
|
||||
IExternalData externalData = graphicalNode.getExternalData();
|
||||
IExternalNode externalNode = graphicalNode.getExternalNode();
|
||||
// mapper
|
||||
if (externalData != null) {
|
||||
((IExternalNode) dataNode).setExternalData(externalData);
|
||||
}
|
||||
// xmlmap
|
||||
if (externalNode != null) {
|
||||
((IExternalNode) dataNode).setExternalEmfData(externalNode.getExternalEmfData());
|
||||
}
|
||||
((IExternalNode) dataNode).setExternalEmfData(externalNode.getExternalEmfData());
|
||||
// sap eltmap
|
||||
((IExternalNode) dataNode).setInternalMapperModel(externalNode.getInternalMapperModel());
|
||||
|
||||
}
|
||||
dataNode.setActivate(graphicalNode.isActivate());
|
||||
dataNode.setStart(graphicalNode.isStart());
|
||||
@@ -831,17 +831,20 @@ public class DataProcess implements IGeneratingProcess {
|
||||
if (component.getPluginExtension() == null) {
|
||||
curNode = new DataNode(component, uniqueName);
|
||||
} else {
|
||||
// mapper
|
||||
curNode = (AbstractNode) ExternalNodesFactory.getInstance(component.getPluginExtension());
|
||||
IExternalData externalData = graphicalNode.getExternalData();
|
||||
IExternalNode externalNode = graphicalNode.getExternalNode();
|
||||
if (externalData != null) {
|
||||
((IExternalNode) curNode).setExternalData(externalData);
|
||||
}
|
||||
// xmlmap
|
||||
if (externalNode != null) {
|
||||
if (curNode instanceof IExternalNode) {
|
||||
// mapper
|
||||
if (externalData != null) {
|
||||
((IExternalNode) curNode).setExternalData(externalData);
|
||||
}
|
||||
// xmlmap
|
||||
((IExternalNode) curNode).setExternalEmfData(externalNode.getExternalEmfData());
|
||||
// sap eltmap
|
||||
((IExternalNode) curNode).setInternalMapperModel(externalNode.getInternalMapperModel());
|
||||
}
|
||||
|
||||
curNode.setStart(graphicalNode.isStart());
|
||||
curNode.setElementParameters(graphicalNode.getComponent().createElementParameters(curNode));
|
||||
curNode.setListConnector(graphicalNode.getListConnector());
|
||||
@@ -3119,18 +3122,16 @@ public class DataProcess implements IGeneratingProcess {
|
||||
// IExternalData externalData = graphicalNode.getExternalData();
|
||||
|
||||
IExternalNode externalNode = graphicalNode.getExternalNode();
|
||||
if (externalNode != null) {
|
||||
AbstractExternalData externalEmfData = externalNode.getExternalEmfData();
|
||||
newGraphicalNode.getExternalNode().setExternalEmfData(externalEmfData);
|
||||
}
|
||||
// fwang fixed bug TDI-8027
|
||||
IExternalData externalData = graphicalNode.getExternalData();
|
||||
if (externalData != null) {
|
||||
try {
|
||||
newGraphicalNode.setExternalData(externalData.clone());
|
||||
} catch (CloneNotSupportedException e) {
|
||||
newGraphicalNode.setExternalData(externalData);
|
||||
if (externalNode != null) {
|
||||
// mapper
|
||||
if (externalData != null) {
|
||||
newGraphicalNode.getExternalNode().setExternalData(externalData);
|
||||
}
|
||||
// xmlmap
|
||||
newGraphicalNode.getExternalNode().setExternalEmfData(externalNode.getExternalEmfData());
|
||||
// sap eltmap
|
||||
newGraphicalNode.getExternalNode().setInternalMapperModel(externalNode.getInternalMapperModel());
|
||||
}
|
||||
|
||||
copyElementParametersValue(graphicalNode, newGraphicalNode);
|
||||
|
||||
@@ -284,6 +284,7 @@ public abstract class AbstractMultiPageTalendEditor extends MultiPageEditorPart
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changePaletteComponentHandler() {
|
||||
ComponentsFactoryProvider.getInstance().setComponentsHandler(designerEditor.getComponenentsHandler());
|
||||
}
|
||||
@@ -1780,6 +1781,7 @@ public abstract class AbstractMultiPageTalendEditor extends MultiPageEditorPart
|
||||
*/
|
||||
@Override
|
||||
public void dispose() {
|
||||
boolean isDirty = isDirty();
|
||||
getSite().setSelectionProvider(null);
|
||||
getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
|
||||
/* after the release of eclipse3.6,this parameter can't be null */
|
||||
@@ -1809,11 +1811,17 @@ public abstract class AbstractMultiPageTalendEditor extends MultiPageEditorPart
|
||||
|
||||
JobletUtil jUtil = new JobletUtil();
|
||||
jUtil.makeSureUnlockJoblet(getProcess());
|
||||
if (isDirty) {
|
||||
// fix for TUP-17936
|
||||
jUtil.reloadJobletInCurrentProcess(getProcess());
|
||||
}
|
||||
|
||||
Item item = getProcess().getProperty().getItem();
|
||||
boolean keep = jUtil.keepLockJoblet(item);
|
||||
if (keep) {
|
||||
repFactory.unlock(property.getItem());
|
||||
}
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
} catch (LoginException e) {
|
||||
|
||||
@@ -62,6 +62,7 @@ import org.talend.commons.ui.runtime.image.ECoreImage;
|
||||
import org.talend.commons.ui.runtime.image.ImageProvider;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.EComponentType;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.components.IComponentsHandler;
|
||||
@@ -197,7 +198,7 @@ public final class TalendEditorPaletteFactory {
|
||||
String[] strings = family.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
|
||||
String[] oraStrings = oraFamily.split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX);
|
||||
for (int j = 0; j < strings.length; j++) {
|
||||
if (displayedFamilies.contains(oraStrings[j])) {
|
||||
if (displayedFamilies.contains(oraStrings[j]) || xmlComponent.getComponentType() == EComponentType.JOBLET) {
|
||||
families.add(strings[j]);
|
||||
familyMap.put(strings[j], oraStrings[j]);
|
||||
}
|
||||
@@ -296,8 +297,8 @@ public final class TalendEditorPaletteFactory {
|
||||
if (favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName())) {
|
||||
componentsDrawer = ht.get(FAVORITES);
|
||||
if (componentsDrawer != null) {
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class,
|
||||
xmlComponent, imageSmall, imageLarge);
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class, xmlComponent, imageSmall,
|
||||
imageLarge);
|
||||
|
||||
component.setDescription(longName);
|
||||
component.setParent(componentsDrawer);
|
||||
@@ -316,8 +317,8 @@ public final class TalendEditorPaletteFactory {
|
||||
continue;
|
||||
}
|
||||
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class,
|
||||
xmlComponent, imageSmall, imageLarge);
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class, xmlComponent, imageSmall,
|
||||
imageLarge);
|
||||
|
||||
component.setDescription(longName);
|
||||
|
||||
@@ -423,8 +424,8 @@ public final class TalendEditorPaletteFactory {
|
||||
// 2.1 search from local palette
|
||||
addComponentsByNameFilter(compFac, componentSet, lowerCasedKeyword);
|
||||
if (!componentSet.isEmpty()) {
|
||||
componentSet = new LinkedHashSet<IComponent>(
|
||||
sortResultsBasedOnRecentlyUsed(new ArrayList<IComponent>(componentSet)));
|
||||
componentSet = new LinkedHashSet<IComponent>(sortResultsBasedOnRecentlyUsed(new ArrayList<IComponent>(
|
||||
componentSet)));
|
||||
needSort = false;
|
||||
}
|
||||
|
||||
@@ -663,8 +664,8 @@ public final class TalendEditorPaletteFactory {
|
||||
} else {
|
||||
imageLarge = recentlyUsedComponent.getIcon32();
|
||||
}
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class,
|
||||
recentlyUsedComponent, imageSmall, imageLarge);
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class, recentlyUsedComponent, imageSmall,
|
||||
imageLarge);
|
||||
|
||||
component.setDescription(longName);
|
||||
component.setParent(componentsDrawer);
|
||||
@@ -678,8 +679,8 @@ public final class TalendEditorPaletteFactory {
|
||||
String name = entry.getLabel();
|
||||
IComponent component = ((PaletteComponentFactory) entry.getToolProperty(CreationTool.PROPERTY_CREATION_FACTORY))
|
||||
.getComponent();
|
||||
TalendCombinedTemplateCreationEntry newEntry = new TalendCombinedTemplateCreationEntry(name, name, Node.class,
|
||||
component, entry.getSmallIcon(), entry.getLargeIcon());
|
||||
TalendCombinedTemplateCreationEntry newEntry = new TalendCombinedTemplateCreationEntry(name, name, Node.class, component,
|
||||
entry.getSmallIcon(), entry.getLargeIcon());
|
||||
|
||||
newEntry.setDescription(entry.getDescription());
|
||||
return newEntry;
|
||||
@@ -699,8 +700,8 @@ public final class TalendEditorPaletteFactory {
|
||||
} else {
|
||||
imageLarge = component.getIcon32();
|
||||
}
|
||||
TalendCombinedTemplateCreationEntry newEntry = new TalendCombinedTemplateCreationEntry(name, name, Node.class,
|
||||
component, imageSmall, imageLarge);
|
||||
TalendCombinedTemplateCreationEntry newEntry = new TalendCombinedTemplateCreationEntry(name, name, Node.class, component,
|
||||
imageSmall, imageLarge);
|
||||
|
||||
newEntry.setDescription(component.getLongName());
|
||||
return newEntry;
|
||||
@@ -902,8 +903,8 @@ public final class TalendEditorPaletteFactory {
|
||||
if (favoriteComponentNames != null && favoriteComponentNames.contains(xmlComponent.getName())) {
|
||||
componentsDrawer = ht.get(FAVORITES);
|
||||
if (componentsDrawer != null) {
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class,
|
||||
xmlComponent, imageSmall, imageLarge);
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class, xmlComponent, imageSmall,
|
||||
imageLarge);
|
||||
|
||||
component.setDescription(longName);
|
||||
component.setParent(componentsDrawer);
|
||||
@@ -928,14 +929,14 @@ public final class TalendEditorPaletteFactory {
|
||||
// String key = null;
|
||||
// key = xmlComponent.getName() + "#" + oraStrings[j];//$NON-NLS-1$
|
||||
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class,
|
||||
xmlComponent, imageSmall, imageLarge);
|
||||
component = new TalendCombinedTemplateCreationEntry(name, name, Node.class, xmlComponent, imageSmall,
|
||||
imageLarge);
|
||||
|
||||
component.setDescription(longName);
|
||||
if (a == 0) {
|
||||
componentsDrawer = ht.get(strings[j]);
|
||||
component.setParent(componentsDrawer);
|
||||
componentsDrawer.add(component);
|
||||
component.setParent(componentsDrawer);
|
||||
componentsDrawer.add(component);
|
||||
} else if (a == 1) {
|
||||
boolean canAdd = true;
|
||||
// listName = paGroup.getChildren();
|
||||
@@ -1333,13 +1334,13 @@ public final class TalendEditorPaletteFactory {
|
||||
return toolGroup;
|
||||
}
|
||||
|
||||
private static ERepositoryObjectType getJobletObjectType(IComponentsHandler handler){
|
||||
if(handler == null){
|
||||
private static ERepositoryObjectType getJobletObjectType(IComponentsHandler handler) {
|
||||
if (handler == null) {
|
||||
return null;
|
||||
}
|
||||
ComponentCategory category = handler.extractComponentsCategory();
|
||||
ERepositoryObjectType type = ERepositoryObjectType.JOBLET;
|
||||
if(category == null){
|
||||
if (category == null) {
|
||||
return type;
|
||||
}
|
||||
switch (category) {
|
||||
@@ -1354,7 +1355,7 @@ public final class TalendEditorPaletteFactory {
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
/** Utility class. */
|
||||
private TalendEditorPaletteFactory() {
|
||||
// Utility class
|
||||
|
||||
@@ -2,11 +2,17 @@ package org.talend.designer.core.ui.editor.jobletcontainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.draw2d.geometry.Dimension;
|
||||
import org.eclipse.draw2d.geometry.Point;
|
||||
import org.eclipse.draw2d.geometry.Rectangle;
|
||||
@@ -454,6 +460,39 @@ public class JobletUtil {
|
||||
|
||||
}
|
||||
|
||||
public void reloadJobletInCurrentProcessInBackground(final IProcess2 process) {
|
||||
Job reloadJob = new Job("Reload joblet process...") {
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
reloadJobletInCurrentProcess(process);
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
};
|
||||
reloadJob.setPriority(Job.INTERACTIVE);
|
||||
reloadJob.setSystem(true);
|
||||
reloadJob.schedule();
|
||||
|
||||
}
|
||||
|
||||
public void reloadJobletInCurrentProcess(IProcess2 process) {
|
||||
List<? extends INode> nodeList = process.getGraphicalNodes();
|
||||
Set<String> components = new HashSet<String>();
|
||||
for (INode node : nodeList) {
|
||||
if (!components.contains(node.getComponent().getName() + node.getComponent().getVersion())
|
||||
&& ((Node) node).isJoblet()) {
|
||||
components.add(node.getComponent().getName() + node.getComponent().getVersion());
|
||||
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(
|
||||
IJobletProviderService.class);
|
||||
if (service != null) {
|
||||
service.reloadJobletProcess(node, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean needReadOnlyJoblet(JobletProcessItem jobletItem) {
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
IEditorPart[] editors = page.getEditors();
|
||||
|
||||
@@ -12,12 +12,16 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.utils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IElement;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.designer.core.model.components.ElementParameter;
|
||||
import org.talend.designer.core.model.components.Expression;
|
||||
|
||||
/**
|
||||
@@ -96,4 +100,37 @@ public final class UpdateParameterUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deepCopy(IElementParameter from, IElementParameter to) {
|
||||
Set<IElementParameter> copiedList = new HashSet<IElementParameter>();
|
||||
deepCopy(from, to, copiedList);
|
||||
}
|
||||
|
||||
public static void deepCopy(IElementParameter from, IElementParameter to, Set<IElementParameter> copiedList) {
|
||||
if (copiedList.contains(from)) {
|
||||
return;
|
||||
} else {
|
||||
copiedList.add(from);
|
||||
}
|
||||
to.setValue(from.getValue());
|
||||
Map<String, IElementParameter> fromChildParamMap = from.getChildParameters();
|
||||
if (fromChildParamMap != null && !fromChildParamMap.isEmpty()) {
|
||||
Map<String, IElementParameter> toChildParamMap = to.getChildParameters();
|
||||
for (Map.Entry<String, IElementParameter> fromEntry : fromChildParamMap.entrySet()) {
|
||||
String key = fromEntry.getKey();
|
||||
IElementParameter fromValue = fromEntry.getValue();
|
||||
if (fromValue == null) {
|
||||
toChildParamMap.put(key, null);
|
||||
} else {
|
||||
IElementParameter toValue = toChildParamMap.get(key);
|
||||
if (toValue == null) {
|
||||
toValue = new ElementParameter(to.getElement());
|
||||
toChildParamMap.put(key, toValue);
|
||||
}
|
||||
deepCopy(fromValue, toValue, copiedList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="class"/>
|
||||
</classpath>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="output" path="class"/>
|
||||
</classpath>
|
||||
|
||||
@@ -45,3 +45,4 @@ Export-Package: org.talend.designer.mapper,
|
||||
org.talend.designer.mapper.model.tableentry,
|
||||
org.talend.designer.mapper.utils,
|
||||
org.talend.designer.mapper.utils.problems
|
||||
Import-Package: org.eclipse.jface.preference
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 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.mapper.managers;
|
||||
|
||||
|
||||
/**
|
||||
* DOC xwen class global comment. Detailled comment
|
||||
*/
|
||||
public class MapperAutoMappingManager {
|
||||
|
||||
private static MapperAutoMappingManager instance = null;
|
||||
|
||||
private MapperManager manager;
|
||||
|
||||
/**
|
||||
* DOC xwen MapperAutoMappingManager constructor comment.
|
||||
*
|
||||
* @param manager
|
||||
*/
|
||||
public MapperAutoMappingManager(MapperManager manager) {
|
||||
this.manager = manager;
|
||||
initModelSettings();
|
||||
}
|
||||
|
||||
|
||||
public static synchronized MapperAutoMappingManager getInstance(MapperManager manager) {
|
||||
if (instance == null) {
|
||||
instance = new MapperAutoMappingManager(manager);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xwen Comment method "initModelSettings".
|
||||
*/
|
||||
private void initModelSettings() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1035,9 +1035,9 @@ public class MapperManager extends AbstractMapperManager {
|
||||
/**
|
||||
* DOC amaumont Comment method "mapAutomaticallly".
|
||||
*/
|
||||
public void mapAutomaticallly() {
|
||||
public void mapAutomaticallly(int levenshteinWeight, int jaccardWeight) {
|
||||
AutoMapper autoMapper = new AutoMapper(this);
|
||||
autoMapper.map();
|
||||
autoMapper.map(levenshteinWeight, jaccardWeight);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -117,6 +117,7 @@ import org.talend.designer.mapper.model.tableentry.TableEntryLocation;
|
||||
import org.talend.designer.mapper.model.tableentry.VarTableEntry;
|
||||
import org.talend.designer.mapper.ui.MapperUI;
|
||||
import org.talend.designer.mapper.ui.commands.DataMapTableViewSelectedCommand;
|
||||
import org.talend.designer.mapper.ui.dialog.AutoMappingDialog;
|
||||
import org.talend.designer.mapper.ui.dialog.MapReducePropertySetDialog;
|
||||
import org.talend.designer.mapper.ui.dialog.OutputAddDialog;
|
||||
import org.talend.designer.mapper.ui.dialog.PropertySetDialog;
|
||||
@@ -2017,6 +2018,16 @@ public class UIManager extends AbstractUIManager {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.designer.abstractmap.managers.AbstractUIManager#openAutoMapDialog()
|
||||
*/
|
||||
@Override
|
||||
public void openAutoMappingDialog() {
|
||||
new AutoMappingDialog(getShell(), mapperManager).open();
|
||||
}
|
||||
|
||||
public boolean isTableViewMoveable(Zone zone, boolean moveUp) {
|
||||
if (zone == Zone.INPUTS) {
|
||||
if (currentSelectedInputTableView == null) {
|
||||
|
||||
@@ -30,6 +30,7 @@ public class MapperSettingModel implements Cloneable {
|
||||
|
||||
private String rowBufferSize;
|
||||
|
||||
|
||||
/**
|
||||
* @return the MapReduce lookup tables should be precalculated and distributed across nodes in the cluster.
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,13 @@ public class AbstractInOutTableEntry extends DataMapTableEntry implements IColum
|
||||
|
||||
private IMetadataColumn metadataColumn;
|
||||
|
||||
private String parentName;
|
||||
|
||||
public AbstractInOutTableEntry(IMetadataColumn metadataColumn) {
|
||||
|
||||
this.metadataColumn = metadataColumn;
|
||||
}
|
||||
|
||||
public AbstractInOutTableEntry(IDataMapTable abstractDataMapTable, IMetadataColumn metadataColumn, String expression) {
|
||||
super(abstractDataMapTable, expression);
|
||||
this.metadataColumn = metadataColumn;
|
||||
@@ -70,4 +77,24 @@ public class AbstractInOutTableEntry extends DataMapTableEntry implements IColum
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for parentName.
|
||||
*
|
||||
* @return the parentName
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Sets the parentName.
|
||||
*
|
||||
* @param parentName the parentName to set
|
||||
*/
|
||||
public void setParentName(String parentName) {
|
||||
this.parentName = parentName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return this.parentName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ public abstract class DataMapTableEntry implements ITableEntry {
|
||||
|
||||
private List<Problem> problems;
|
||||
|
||||
public DataMapTableEntry() {
|
||||
|
||||
}
|
||||
|
||||
public DataMapTableEntry(IDataMapTable abstractDataMapTable, String expression) {
|
||||
super();
|
||||
this.parent = abstractDataMapTable;
|
||||
@@ -97,6 +101,10 @@ public abstract class DataMapTableEntry implements ITableEntry {
|
||||
}
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Problem> getProblems() {
|
||||
return this.problems;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public class InputColumnTableEntry extends AbstractInOutTableEntry {
|
||||
|
||||
private String operator;
|
||||
|
||||
|
||||
public InputColumnTableEntry(IDataMapTable abstractDataMapTable, IMetadataColumn metadataColumn, String expression) {
|
||||
super(abstractDataMapTable, metadataColumn, expression);
|
||||
}
|
||||
@@ -33,6 +34,13 @@ public class InputColumnTableEntry extends AbstractInOutTableEntry {
|
||||
super(abstractDataMapTable, metadataColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xwen InputColumnTableEntry constructor comment.
|
||||
*/
|
||||
public InputColumnTableEntry(IMetadataColumn metadataColumn) {
|
||||
super(metadataColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for operator.
|
||||
*
|
||||
@@ -51,4 +59,6 @@ public class InputColumnTableEntry extends AbstractInOutTableEntry {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -31,4 +31,11 @@ public class OutputColumnTableEntry extends AbstractInOutTableEntry {
|
||||
super(abstractDataMapTable, metadataColumn);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xwen OutputColumnTableEntry constructor comment.
|
||||
*/
|
||||
public OutputColumnTableEntry(IMetadataColumn metadataColumn) {
|
||||
super(metadataColumn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.talend.designer.mapper.ui.automap;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.talend.designer.abstractmap.model.tableentry.IColumnEntry;
|
||||
import org.talend.designer.mapper.language.ILanguage;
|
||||
@@ -22,6 +23,9 @@ import org.talend.designer.mapper.managers.MapperManager;
|
||||
import org.talend.designer.mapper.model.table.InputTable;
|
||||
import org.talend.designer.mapper.model.table.OutputTable;
|
||||
import org.talend.designer.mapper.ui.visualmap.table.DataMapTableView;
|
||||
import org.talend.utils.string.Jaccard;
|
||||
import org.talend.utils.string.Levenshtein;
|
||||
|
||||
|
||||
/**
|
||||
* DOC amaumont class global comment. Detailled comment <br/>
|
||||
@@ -45,7 +49,10 @@ public class AutoMapper {
|
||||
/**
|
||||
* DOC amaumont Comment method "map".
|
||||
*/
|
||||
public void map() {
|
||||
public void map(int levenshteinWeight, int jaccardWeight) {
|
||||
int paramL = levenshteinWeight;
|
||||
int paramJ = jaccardWeight;
|
||||
|
||||
List<InputTable> inputTables = mapperManager.getInputTables();
|
||||
List<OutputTable> outputTables = mapperManager.getOutputTables();
|
||||
|
||||
@@ -61,30 +68,41 @@ public class AutoMapper {
|
||||
for (OutputTable outputTable : outputTables) {
|
||||
|
||||
List<IColumnEntry> outputEntries = outputTable.getColumnEntries();
|
||||
boolean mapFound = false;
|
||||
for (IColumnEntry outputEntry : outputEntries) {
|
||||
|
||||
mapFound = false;
|
||||
|
||||
if (mapperManager.checkEntryHasEmptyExpression(outputEntry)) {
|
||||
|
||||
String outputColumnName = outputEntry.getName();
|
||||
String outputColumnName = outputEntry.getName().toLowerCase();
|
||||
String jaccardOutput = Jaccard.tokenize(outputEntry.getName());
|
||||
|
||||
HashMap<IColumnEntry, Double> finalMap = new HashMap<IColumnEntry, Double>();
|
||||
for (InputTable inputTable : inputTables) {
|
||||
|
||||
List<IColumnEntry> inputColumnEntries = inputTable.getColumnEntries();
|
||||
for (IColumnEntry inputEntry : inputColumnEntries) {
|
||||
if (inputEntry.getName().equalsIgnoreCase(outputColumnName)) {
|
||||
outputEntry.setExpression(currentLanguage.getLocation(inputTable.getName(), inputEntry
|
||||
.getName()));
|
||||
mapFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mapFound) {
|
||||
break;
|
||||
}
|
||||
// Levenshtein
|
||||
String inputStr = inputEntry.getName().toLowerCase();
|
||||
double LevenshteinScore = Levenshtein.getLevenshteinScore(inputStr, outputColumnName);
|
||||
|
||||
// Jaccard
|
||||
String jaccardIutput = Jaccard.tokenize(inputEntry.getName());
|
||||
double JaccardScore = Jaccard.JaccardCompare(jaccardIutput, jaccardOutput);
|
||||
double finalScore = LevenshteinScore * paramL + JaccardScore * paramJ;
|
||||
|
||||
finalMap.put(inputEntry, finalScore);
|
||||
inputEntry.getParent();
|
||||
|
||||
}
|
||||
}
|
||||
IColumnEntry bestEntry = getMaxStr(finalMap);
|
||||
if (bestEntry == null) {
|
||||
continue;
|
||||
}
|
||||
if (finalMap.get(bestEntry) < 30) {
|
||||
continue;
|
||||
} else {
|
||||
outputEntry
|
||||
.setExpression(currentLanguage.getLocation(bestEntry.getParent().getName(), bestEntry.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -106,4 +124,22 @@ public class AutoMapper {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static IColumnEntry getMaxStr(HashMap<IColumnEntry, Double> map) {
|
||||
Double max = 0.0;
|
||||
IColumnEntry result = null;
|
||||
|
||||
for (Entry<IColumnEntry, Double> entry : map.entrySet()) {
|
||||
if (entry.getValue() > max) {
|
||||
result = entry.getKey();
|
||||
if (result != null)
|
||||
max = entry.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,650 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 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.mapper.ui.dialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.custom.ScrolledComposite;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.FormAttachment;
|
||||
import org.eclipse.swt.layout.FormData;
|
||||
import org.eclipse.swt.layout.FormLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Slider;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.MetadataColumn;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.core.ui.CoreUIPlugin;
|
||||
import org.talend.designer.abstractmap.model.table.IDataMapTable;
|
||||
import org.talend.designer.abstractmap.model.tableentry.IColumnEntry;
|
||||
import org.talend.designer.mapper.language.ILanguage;
|
||||
import org.talend.designer.mapper.language.LanguageProvider;
|
||||
import org.talend.designer.mapper.managers.MapperManager;
|
||||
import org.talend.designer.mapper.model.MapperModel;
|
||||
import org.talend.designer.mapper.model.table.AbstractDataMapTable;
|
||||
import org.talend.designer.mapper.model.table.InputTable;
|
||||
import org.talend.designer.mapper.model.table.OutputTable;
|
||||
import org.talend.designer.mapper.model.tableentry.InputColumnTableEntry;
|
||||
import org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry;
|
||||
import org.talend.designer.mapper.ui.visualmap.zone.scrollable.InputTablesZoneView;
|
||||
import org.talend.designer.mapper.ui.visualmap.zone.scrollable.OutputTablesZoneView;
|
||||
import org.talend.utils.string.Jaccard;
|
||||
import org.talend.utils.string.Levenshtein;
|
||||
|
||||
/**
|
||||
* DOC xwen class global comment. Detailled comment
|
||||
*/
|
||||
public class AutoMappingDialog extends Dialog {
|
||||
|
||||
private IPreferenceStore weightStore;
|
||||
|
||||
private MapperManager mapperManager;
|
||||
|
||||
private MapperModel mapperModel;
|
||||
|
||||
private Slider levenshteinSlider;
|
||||
|
||||
private Slider jaccardSlider;
|
||||
|
||||
private int levenshteinWeight = 0;
|
||||
|
||||
private Integer jaccardWeight = 0;
|
||||
|
||||
private Label levenshteinWeightLabel;
|
||||
|
||||
private Label jaccardWeightLabel;
|
||||
|
||||
private Group autoMapGroup;
|
||||
|
||||
private Button previewButton;
|
||||
|
||||
private Button resetButton;
|
||||
|
||||
private SashForm datasFlowViewSashForm;
|
||||
|
||||
private Composite inputsZone;
|
||||
|
||||
private Composite outputZone;
|
||||
|
||||
private Composite container;
|
||||
|
||||
private SashForm mainSash;
|
||||
|
||||
|
||||
private ScrolledComposite sc2;
|
||||
|
||||
private InputTablesZoneView inputTablesZoneView;
|
||||
|
||||
private OutputTablesZoneView outputTablesZoneView;
|
||||
|
||||
private List<InputTable> inputTables;
|
||||
|
||||
private List<List<IColumnEntry>> cacheInputTables = new ArrayList<List<IColumnEntry>>();
|
||||
|
||||
private List<List<IColumnEntry>> cacheOutputTables = new ArrayList<List<IColumnEntry>>();
|
||||
|
||||
private List<List<IColumnEntry>> resetOutTables = new ArrayList<List<IColumnEntry>>();
|
||||
|
||||
private List<List<IColumnEntry>> resetInTables = new ArrayList<List<IColumnEntry>>();
|
||||
|
||||
private List<IColumnEntry> currentInputList = new ArrayList<IColumnEntry>();
|
||||
|
||||
private List<OutputTable> outputTables;
|
||||
|
||||
private List<IColumnEntry> currentOutputList = new ArrayList<IColumnEntry>();
|
||||
|
||||
private static final boolean SHOW_BORDERS = false;
|
||||
|
||||
private TableViewer tableViewerOut;
|
||||
|
||||
private TableViewer tableViewerIn;
|
||||
|
||||
private Combo inCombo;
|
||||
|
||||
private Combo outCombo;
|
||||
|
||||
/**
|
||||
* DOC xwen AutoMappingDialog constructor comment.
|
||||
*
|
||||
* @param parentShell
|
||||
*/
|
||||
public AutoMappingDialog(Shell parentShell, MapperManager mapperManager) {
|
||||
super(parentShell);
|
||||
|
||||
this.mapperManager = mapperManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getShellStyle() {
|
||||
|
||||
return super.getShellStyle() | SWT.RESIZE | SWT.MAX;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
||||
*/
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
container = new Composite(parent, SWT.RESIZE);
|
||||
// container = (Composite) super.createDialogArea(parent);
|
||||
final GridLayout gridLayout = new GridLayout(1, false);
|
||||
gridLayout.marginLeft = 10;
|
||||
gridLayout.marginTop = 10;
|
||||
gridLayout.marginHeight = 10;
|
||||
container.setLayout(gridLayout);
|
||||
|
||||
autoMapGroup = new Group(container, SWT.NONE);
|
||||
autoMapGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
autoMapGroup.setText("Auto Map");
|
||||
|
||||
GridLayout AutogridLayout = new GridLayout(3, false);
|
||||
AutogridLayout.horizontalSpacing = 10;
|
||||
AutogridLayout.marginRight = 100;
|
||||
|
||||
autoMapGroup.setLayout(AutogridLayout);
|
||||
Label levenshteinLabel = new Label(autoMapGroup, SWT.NONE);
|
||||
levenshteinLabel.setText("Levenshtein");
|
||||
levenshteinSlider = new Slider(autoMapGroup, SWT.HORIZONTAL);
|
||||
levenshteinSlider.setSize(200, 25);
|
||||
levenshteinSlider.setMaximum(101);
|
||||
levenshteinSlider.setMinimum(0);
|
||||
levenshteinSlider.setThumb(1);
|
||||
levenshteinWeightLabel = new Label(autoMapGroup, SWT.NONE);
|
||||
|
||||
Label jaccardLabel = new Label(autoMapGroup, SWT.NONE);
|
||||
jaccardLabel.setText("Jaccard");
|
||||
jaccardSlider = new Slider(autoMapGroup, SWT.HORIZONTAL);
|
||||
jaccardSlider.setSize(200, 25);
|
||||
jaccardSlider.setMaximum(101);
|
||||
jaccardSlider.setMinimum(0);
|
||||
jaccardSlider.setThumb(1);
|
||||
jaccardWeightLabel = new Label(autoMapGroup, SWT.NONE);
|
||||
|
||||
Composite buttonComposite = new Composite(container, SWT.NONE);
|
||||
FormLayout layout = new FormLayout();
|
||||
FormData data = new FormData();
|
||||
data.left = new FormAttachment(90, 20);
|
||||
|
||||
previewButton = new Button(buttonComposite, SWT.NONE);
|
||||
previewButton.setText("Preview");
|
||||
resetButton = new Button(buttonComposite, SWT.NONE);
|
||||
resetButton.setText(" Reset ");
|
||||
resetButton.setLayoutData(data);
|
||||
|
||||
buttonComposite.setLayout(layout);
|
||||
|
||||
mainSash = new SashForm(container, SWT.SMOOTH | SWT.HORIZONTAL | SWT.BORDER);
|
||||
|
||||
|
||||
init();
|
||||
initTables();
|
||||
addListener();
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DOC xwen Comment method "initTables".
|
||||
*/
|
||||
private void initTables() {
|
||||
createInputZone();
|
||||
createOutputZone();
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xwen Comment method "createOutputZone".
|
||||
*/
|
||||
private void createOutputZone() {
|
||||
outputZone = new Composite(mainSash, SWT.NONE);
|
||||
GridLayout grid = new GridLayout(1, true);
|
||||
outputZone.setLayout(grid);
|
||||
|
||||
Composite comboComp = new Composite(outputZone, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(2, true);
|
||||
Label outLabel = new Label(comboComp, SWT.NONE);
|
||||
outLabel.setText("Output Tables");
|
||||
comboComp.setLayout(layout);
|
||||
|
||||
outCombo = new Combo(comboComp, SWT.READ_ONLY);
|
||||
|
||||
sc2 = new ScrolledComposite(outputZone, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
GridData sc2GridData = new GridData(GridData.FILL_BOTH);
|
||||
sc2.setLayoutData(sc2GridData);
|
||||
sc2.setBackgroundMode(SWT.INHERIT_DEFAULT);
|
||||
sc2.setLayout(new GridLayout(1, false));
|
||||
|
||||
outputTablesZoneView = new OutputTablesZoneView(sc2, getBorder(), mapperManager);
|
||||
outputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
|
||||
sc2.setContent(outputTablesZoneView);
|
||||
GridLayout grid1 = new GridLayout();
|
||||
outputZone.setLayout(grid1);
|
||||
outputTablesZoneView.setLayout(grid1);
|
||||
sc2.setExpandHorizontal(true);
|
||||
outputTablesZoneView.setSize(200, 200);
|
||||
sc2.layout();
|
||||
|
||||
tableViewerOut = new TableViewer(outputTablesZoneView, SWT.BORDER | SWT.FULL_SELECTION);
|
||||
Table table = tableViewerOut.getTable();
|
||||
table.setHeaderVisible(true);
|
||||
table.setLinesVisible(true);
|
||||
|
||||
TableColumn col1 = new TableColumn(table, SWT.NONE);
|
||||
col1.setText("Expression");
|
||||
col1.setWidth(150);
|
||||
TableColumn col2 = new TableColumn(table, SWT.NONE);
|
||||
col2.setText("Column");
|
||||
col2.setWidth(150);
|
||||
|
||||
TableViewerContentProvider provider = new TableViewerContentProvider();
|
||||
OutTableViewerLabelProvider labelProvider = new OutTableViewerLabelProvider();
|
||||
|
||||
tableViewerOut.setContentProvider(provider);
|
||||
tableViewerOut.setLabelProvider(labelProvider);
|
||||
|
||||
// Object data = null;
|
||||
OutputTable firstTable = null;
|
||||
if (!outputTables.isEmpty()) {
|
||||
firstTable = outputTables.get(0);
|
||||
}
|
||||
if (firstTable != null) {
|
||||
List<IColumnEntry> outputColumnEntries = firstTable.getColumnEntries();
|
||||
// data = outputColumnEntries;
|
||||
|
||||
for (IColumnEntry outputEntry : outputColumnEntries) {
|
||||
IMetadataColumn metadataColumn = new MetadataColumn();
|
||||
OutputColumnTableEntry entry = new OutputColumnTableEntry(metadataColumn);
|
||||
entry.setName(outputEntry.getName());
|
||||
entry.setExpression(outputEntry.getExpression());
|
||||
entry.setParentName(outputEntry.getParent().getName());
|
||||
currentOutputList.add(entry);
|
||||
}
|
||||
}
|
||||
tableViewerOut.setUseHashlookup(true);
|
||||
|
||||
// cache all output tables
|
||||
initOutputTables();
|
||||
outCombo.select(0);
|
||||
tableViewerOut.setInput(cacheOutputTables.get(0));
|
||||
outputTablesZoneView.setSize(outputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xwen Comment method "createInputZone".
|
||||
*/
|
||||
private void createInputZone() {
|
||||
inputsZone = new Composite(mainSash, SWT.NONE);
|
||||
GridLayout grid = new GridLayout(1, true);
|
||||
inputsZone.setLayout(grid);
|
||||
|
||||
Composite comboComp = new Composite(inputsZone, SWT.NONE);
|
||||
GridLayout layout = new GridLayout(2, true);
|
||||
Label inLabel = new Label(comboComp, SWT.NONE);
|
||||
inLabel.setText("Intput Tables");
|
||||
comboComp.setLayout(layout);
|
||||
|
||||
inCombo = new Combo(comboComp, SWT.READ_ONLY);
|
||||
|
||||
ScrolledComposite sc1 = new ScrolledComposite(inputsZone, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
GridData sc1GridData = new GridData(GridData.FILL_BOTH);
|
||||
sc1.setLayoutData(sc1GridData);
|
||||
// sc1.setLayout(new GridLayout(1, false));
|
||||
sc1.setBackgroundMode(SWT.INHERIT_DEFAULT);
|
||||
|
||||
inputTablesZoneView = new InputTablesZoneView(sc1, getBorder(), mapperManager);
|
||||
inputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
|
||||
inputTablesZoneView.setSize(100, 100);
|
||||
|
||||
sc1.setExpandHorizontal(true);
|
||||
sc1.setExpandVertical(true);
|
||||
sc1.setMinWidth(100);
|
||||
sc1.setMinHeight(100);
|
||||
sc1.setBounds(50, 50, 300, 300);
|
||||
sc1.setContent(inputTablesZoneView);
|
||||
// sc1.setSize(100, 100);
|
||||
|
||||
tableViewerIn = new TableViewer(inputTablesZoneView, SWT.BORDER | SWT.FULL_SELECTION);
|
||||
Table table = tableViewerIn.getTable();
|
||||
table.setHeaderVisible(true);
|
||||
table.setLinesVisible(true);
|
||||
|
||||
TableColumn col = new TableColumn(table, SWT.NONE);
|
||||
col.setText("Column");
|
||||
col.setWidth(150);
|
||||
|
||||
TableViewerContentProvider provider = new TableViewerContentProvider();
|
||||
InTableViewerLabelProvider labelProvider = new InTableViewerLabelProvider();
|
||||
|
||||
tableViewerIn.setContentProvider(provider);
|
||||
tableViewerIn.setLabelProvider(labelProvider);
|
||||
|
||||
|
||||
tableViewerIn.setUseHashlookup(true);
|
||||
|
||||
//cache all input tables
|
||||
initInputTables();
|
||||
inCombo.select(0);
|
||||
|
||||
tableViewerIn.setInput(cacheInputTables.get(0));
|
||||
|
||||
inputTablesZoneView.setSize(inputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
|
||||
}
|
||||
|
||||
private void initInputTables() {
|
||||
if (cacheInputTables.isEmpty()) {
|
||||
for (InputTable inputTable : inputTables) {
|
||||
|
||||
List<IColumnEntry> inputColumnEntries = inputTable.getColumnEntries();
|
||||
List<IColumnEntry> cacheInputTable = new ArrayList<IColumnEntry>();
|
||||
|
||||
for (IColumnEntry inputEntry : inputColumnEntries) {
|
||||
IMetadataColumn metadataColumn = new MetadataColumn();
|
||||
InputColumnTableEntry entry = new InputColumnTableEntry(metadataColumn);
|
||||
entry.setName(inputEntry.getName());
|
||||
entry.setParentName(inputEntry.getParent().getName());
|
||||
cacheInputTable.add(entry);// put entry into table
|
||||
}
|
||||
|
||||
cacheInputTables.add(cacheInputTable);
|
||||
inCombo.add(inputTable.getName());
|
||||
}
|
||||
} else {
|
||||
cacheInputTables = new ArrayList<List<IColumnEntry>>();
|
||||
for (InputTable inputTable : inputTables) {
|
||||
|
||||
List<IColumnEntry> inputColumnEntries = inputTable.getColumnEntries();
|
||||
List<IColumnEntry> cacheInputTable = new ArrayList<IColumnEntry>();
|
||||
|
||||
for (IColumnEntry inputEntry : inputColumnEntries) {
|
||||
IMetadataColumn metadataColumn = new MetadataColumn();
|
||||
InputColumnTableEntry entry = new InputColumnTableEntry(metadataColumn);
|
||||
entry.setName(inputEntry.getName());
|
||||
entry.setParentName(inputEntry.getParent().getName());
|
||||
cacheInputTable.add(entry);// put entry into table
|
||||
}
|
||||
|
||||
cacheInputTables.add(cacheInputTable);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initOutputTables() {
|
||||
if (cacheOutputTables.isEmpty()) {
|
||||
for (OutputTable outputTable : outputTables) {
|
||||
|
||||
List<IColumnEntry> outputColumnEntries = outputTable.getColumnEntries();
|
||||
List<IColumnEntry> cacheOutputTable = new ArrayList<IColumnEntry>();
|
||||
|
||||
for (IColumnEntry outputEntry : outputColumnEntries) {
|
||||
IMetadataColumn metadataColumn = new MetadataColumn();
|
||||
OutputColumnTableEntry entry = new OutputColumnTableEntry(metadataColumn);
|
||||
entry.setName(outputEntry.getName());
|
||||
entry.setExpression(outputEntry.getExpression());
|
||||
entry.setParentName(outputEntry.getParent().getName());
|
||||
cacheOutputTable.add(entry);// put entry into table
|
||||
}
|
||||
cacheOutputTables.add(cacheOutputTable);
|
||||
outCombo.add(outputTable.getName());
|
||||
}
|
||||
} else {
|
||||
cacheOutputTables = new ArrayList<List<IColumnEntry>>();
|
||||
for (OutputTable outputTable : outputTables) {
|
||||
|
||||
List<IColumnEntry> outputColumnEntries = outputTable.getColumnEntries();
|
||||
List<IColumnEntry> cacheOutputTable = new ArrayList<IColumnEntry>();
|
||||
|
||||
for (IColumnEntry outputEntry : outputColumnEntries) {
|
||||
IMetadataColumn metadataColumn = new MetadataColumn();
|
||||
OutputColumnTableEntry entry = new OutputColumnTableEntry(metadataColumn);
|
||||
entry.setName(outputEntry.getName());
|
||||
entry.setExpression(outputEntry.getExpression());
|
||||
entry.setParentName(outputEntry.getParent().getName());
|
||||
cacheOutputTable.add(entry);// put entry into table
|
||||
}
|
||||
cacheOutputTables.add(cacheOutputTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xwen Comment method "getMinimizedButtonState".
|
||||
*
|
||||
* @param tables
|
||||
* @return
|
||||
*/
|
||||
private Boolean getMinimizedButtonState(List<? extends AbstractDataMapTable> tables) {
|
||||
boolean allTablesAreMinimized = true;
|
||||
boolean allTablesAreNotMinimized = true;
|
||||
|
||||
for (IDataMapTable table : tables) {
|
||||
if (table.isMinimized()) {
|
||||
allTablesAreNotMinimized = false;
|
||||
} else {
|
||||
allTablesAreMinimized = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (allTablesAreMinimized) {
|
||||
return new Boolean(true);
|
||||
} else if (allTablesAreNotMinimized) {
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC xwen Comment method "init".
|
||||
*/
|
||||
private void init() {
|
||||
weightStore = CoreUIPlugin.getDefault().getPreferenceStore();
|
||||
levenshteinWeightLabel.setText(String.valueOf(weightStore.getInt(ITalendCorePrefConstants.LEVENSHTEIN_WEIGHT)));
|
||||
levenshteinSlider.setSelection(weightStore.getInt(ITalendCorePrefConstants.LEVENSHTEIN_WEIGHT));
|
||||
jaccardWeightLabel.setText(String.valueOf(weightStore.getInt(ITalendCorePrefConstants.JACCARD_WEIGHT)));
|
||||
jaccardSlider.setSelection(weightStore.getInt(ITalendCorePrefConstants.JACCARD_WEIGHT));
|
||||
|
||||
this.mapperModel = new MapperModel(mapperManager.getInputTables(), mapperManager.getOutputTables(),
|
||||
mapperManager.getVarsTables());
|
||||
|
||||
inputTables = mapperManager.getInputTables();
|
||||
outputTables = mapperManager.getOutputTables();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addListener() {
|
||||
levenshteinSlider.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateAutoMap();
|
||||
}
|
||||
});
|
||||
|
||||
jaccardSlider.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateAutoMap();
|
||||
}
|
||||
});
|
||||
|
||||
previewButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
|
||||
// IPreferenceStore weightStore = CoreUIPlugin.getDefault().getPreferenceStore();
|
||||
int levenshteinWeight = levenshteinSlider.getSelection();
|
||||
int jaccardWeight = jaccardSlider.getSelection();
|
||||
map(levenshteinWeight, jaccardWeight);
|
||||
}
|
||||
});
|
||||
|
||||
resetButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
initInputTables();
|
||||
initOutputTables();
|
||||
|
||||
tableViewerIn.setInput(cacheInputTables.get(inCombo.getSelectionIndex()));
|
||||
tableViewerOut.setInput(cacheOutputTables.get(outCombo.getSelectionIndex()));
|
||||
}
|
||||
});
|
||||
|
||||
inCombo.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
tableViewerIn.setInput(cacheInputTables.get(inCombo.getSelectionIndex()));
|
||||
};
|
||||
});
|
||||
|
||||
outCombo.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
tableViewerOut.setInput(cacheOutputTables.get(outCombo.getSelectionIndex()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void map(int levenshteinWeight, int jaccardWeight) {
|
||||
int paramL = levenshteinWeight;
|
||||
int paramJ = jaccardWeight;
|
||||
|
||||
ILanguage currentLanguage = LanguageProvider.getCurrentLanguage();
|
||||
|
||||
for (List<IColumnEntry> OutputList : cacheOutputTables) {
|
||||
for (IColumnEntry outputEntry : OutputList) {
|
||||
|
||||
if (outputEntry.getExpression() == null || outputEntry.getExpression().trim().length() == 0) {
|
||||
String outputColumnName = outputEntry.getName().toLowerCase();
|
||||
String jaccardOutput = Jaccard.tokenize(outputEntry.getName());
|
||||
HashMap<IColumnEntry, Double> finalMap = new HashMap<IColumnEntry, Double>();
|
||||
|
||||
for (List<IColumnEntry> InputList : cacheInputTables) {
|
||||
for (IColumnEntry inputEntry : InputList) {
|
||||
String inputStr = inputEntry.getName().toLowerCase();
|
||||
double LevenshteinScore = Levenshtein.getLevenshteinScore(inputStr, outputColumnName);
|
||||
// Jaccard
|
||||
String jaccardIutput = Jaccard.tokenize(inputEntry.getName());
|
||||
double JaccardScore = Jaccard.JaccardCompare(jaccardIutput, jaccardOutput);
|
||||
double finalScore = LevenshteinScore * paramL + JaccardScore * paramJ;
|
||||
|
||||
finalMap.put(inputEntry, finalScore);
|
||||
}
|
||||
}
|
||||
IColumnEntry bestEntry = getMaxStr(finalMap);
|
||||
if (bestEntry == null) {
|
||||
continue;
|
||||
}
|
||||
if (finalMap.get(bestEntry) < 30) {
|
||||
continue;
|
||||
} else {
|
||||
outputEntry.setExpression(currentLanguage.getLocation(bestEntry.getTableName(), bestEntry.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int index = outCombo.getSelectionIndex();
|
||||
tableViewerOut.setInput(cacheOutputTables.get(index));
|
||||
}
|
||||
|
||||
public static IColumnEntry getMaxStr(HashMap<IColumnEntry, Double> map) {
|
||||
Double max = 0.0;
|
||||
IColumnEntry result = null;
|
||||
|
||||
for (Entry<IColumnEntry, Double> entry : map.entrySet()) {
|
||||
if (entry.getValue() > max) {
|
||||
result = entry.getKey();
|
||||
if (result != null)
|
||||
max = entry.getValue();
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void updateAutoMap() {
|
||||
levenshteinWeight = levenshteinSlider.getSelection();
|
||||
jaccardWeight = jaccardSlider.getSelection();
|
||||
levenshteinWeightLabel.setText(String.valueOf(levenshteinWeight));
|
||||
jaccardWeightLabel.setText(String.valueOf(jaccardWeight));
|
||||
autoMapGroup.layout();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
||||
*/
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
IPreferenceStore weightStore = CoreUIPlugin.getDefault().getPreferenceStore();
|
||||
levenshteinWeight = levenshteinSlider.getSelection();
|
||||
jaccardWeight = jaccardSlider.getSelection();
|
||||
weightStore.setValue(ITalendCorePrefConstants.LEVENSHTEIN_WEIGHT, levenshteinWeight);
|
||||
weightStore.setValue(ITalendCorePrefConstants.JACCARD_WEIGHT, jaccardWeight);
|
||||
|
||||
// List<DataMapTableView> dataMapTableViews = mapperManager.getUiManager().getInputsTablesView();
|
||||
// for (DataMapTableView dataMapTableView : dataMapTableViews) {
|
||||
// dataMapTableView.setParent(oldParent);
|
||||
// }
|
||||
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
|
||||
*/
|
||||
@Override
|
||||
protected void cancelPressed() {
|
||||
// List<DataMapTableView> dataMapTableViews = mapperManager.getUiManager().getInputsTablesView();
|
||||
// for (DataMapTableView dataMapTableView : dataMapTableViews) {
|
||||
// dataMapTableView.setParent(oldParent);
|
||||
// }
|
||||
super.cancelPressed();
|
||||
}
|
||||
|
||||
|
||||
private int getBorder() {
|
||||
return SHOW_BORDERS ? SWT.BORDER : SWT.NONE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 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.mapper.ui.dialog;
|
||||
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.talend.designer.abstractmap.model.tableentry.IColumnEntry;
|
||||
import org.talend.designer.mapper.model.tableentry.InputColumnTableEntry;
|
||||
|
||||
/**
|
||||
* DOC xwen class global comment. Detailled comment
|
||||
*/
|
||||
public class InTableViewerLabelProvider implements ITableLabelProvider {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public boolean isLabelProperty(Object element, String property) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
|
||||
*/
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||
*/
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
IColumnEntry entry = (InputColumnTableEntry) element;
|
||||
String columnName = entry.getName();
|
||||
return columnName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 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.mapper.ui.dialog;
|
||||
|
||||
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry;
|
||||
|
||||
/**
|
||||
* DOC xwen class global comment. Detailled comment
|
||||
*/
|
||||
public class OutTableViewerLabelProvider implements ITableLabelProvider {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
|
||||
*/
|
||||
public boolean isLabelProperty(Object element, String property) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
|
||||
*/
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
|
||||
*/
|
||||
public Image getColumnImage(Object element, int columnIndex) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
|
||||
*/
|
||||
public String getColumnText(Object element, int columnIndex) {
|
||||
OutputColumnTableEntry entry = (OutputColumnTableEntry) element;
|
||||
String columnName = entry.getName();
|
||||
if (columnIndex == 0) {
|
||||
return entry.getExpression();
|
||||
}
|
||||
if (columnIndex == 1) {
|
||||
return columnName;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ package org.talend.designer.mapper.ui.dialog;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
@@ -31,11 +32,14 @@ import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Slider;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledDirectoryField;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledText;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.core.ui.CoreUIPlugin;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.mapper.i18n.Messages;
|
||||
@@ -63,10 +67,25 @@ public class PropertySetDialog extends Dialog {
|
||||
|
||||
private LabelledText sizeField;
|
||||
|
||||
private Slider levenshteinSlider;
|
||||
|
||||
private Slider jaccardSlider;
|
||||
|
||||
private int levenshteinWeight = 0;
|
||||
|
||||
private Integer jaccardWeight = 0;
|
||||
|
||||
private Label levenshteinWeightLabel;
|
||||
|
||||
private Label jaccardWeightLabel;
|
||||
|
||||
public static final String QUOTATION_MARK = "\""; //$NON-NLS-1$
|
||||
|
||||
private Group autoMapGroup;
|
||||
|
||||
private final Color color = new Color(Display.getDefault(), 238, 238, 0);
|
||||
|
||||
|
||||
/**
|
||||
* Create the dialog
|
||||
*
|
||||
@@ -119,6 +138,33 @@ public class PropertySetDialog extends Dialog {
|
||||
label.setText("*");
|
||||
label.setToolTipText("Required filed.");
|
||||
|
||||
autoMapGroup = new Group(container, SWT.NONE);
|
||||
autoMapGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
|
||||
autoMapGroup.setText("Auto Map");
|
||||
|
||||
GridLayout AutogridLayout = new GridLayout(3, false);
|
||||
AutogridLayout.horizontalSpacing = 10;
|
||||
AutogridLayout.marginRight = 100;
|
||||
|
||||
autoMapGroup.setLayout(AutogridLayout);
|
||||
Label levenshteinLabel = new Label(autoMapGroup, SWT.NONE);
|
||||
levenshteinLabel.setText("Levenshtein");
|
||||
levenshteinSlider = new Slider(autoMapGroup, SWT.HORIZONTAL);
|
||||
levenshteinSlider.setSize(200, 25);
|
||||
levenshteinSlider.setMaximum(101);
|
||||
levenshteinSlider.setMinimum(0);
|
||||
levenshteinSlider.setThumb(1);
|
||||
levenshteinWeightLabel = new Label(autoMapGroup, SWT.NONE);
|
||||
|
||||
Label jaccardLabel = new Label(autoMapGroup, SWT.NONE);
|
||||
jaccardLabel.setText("Jaccard");
|
||||
jaccardSlider = new Slider(autoMapGroup, SWT.HORIZONTAL);
|
||||
jaccardSlider.setSize(200, 25);
|
||||
jaccardSlider.setMaximum(101);
|
||||
jaccardSlider.setMinimum(0);
|
||||
jaccardSlider.setThumb(1);
|
||||
jaccardWeightLabel = new Label(autoMapGroup, SWT.NONE);
|
||||
|
||||
init();
|
||||
addListener();
|
||||
updateStatus();
|
||||
@@ -133,6 +179,12 @@ public class PropertySetDialog extends Dialog {
|
||||
enableAutoConvertTypeBtn.setSelection(currnentModel.isEnableAutoConvertType());
|
||||
directoryField.setText(StringUtils.trimToEmpty(currnentModel.getTempDataDir()));
|
||||
sizeField.setText(StringUtils.trimToEmpty(currnentModel.getRowBufferSize()));
|
||||
|
||||
IPreferenceStore weightStore = CoreUIPlugin.getDefault().getPreferenceStore();
|
||||
levenshteinWeightLabel.setText(String.valueOf(weightStore.getInt(ITalendCorePrefConstants.LEVENSHTEIN_WEIGHT)));
|
||||
levenshteinSlider.setSelection(weightStore.getInt(ITalendCorePrefConstants.LEVENSHTEIN_WEIGHT));
|
||||
jaccardWeightLabel.setText(String.valueOf(weightStore.getInt(ITalendCorePrefConstants.JACCARD_WEIGHT)));
|
||||
jaccardSlider.setSelection(weightStore.getInt(ITalendCorePrefConstants.JACCARD_WEIGHT));
|
||||
}
|
||||
|
||||
private void addListener() {
|
||||
@@ -168,6 +220,22 @@ public class PropertySetDialog extends Dialog {
|
||||
}
|
||||
});
|
||||
|
||||
levenshteinSlider.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateAutoMap();
|
||||
}
|
||||
});
|
||||
|
||||
jaccardSlider.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
updateAutoMap();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void updateStatus() {
|
||||
@@ -207,6 +275,14 @@ public class PropertySetDialog extends Dialog {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAutoMap() {
|
||||
levenshteinWeight = levenshteinSlider.getSelection();
|
||||
jaccardWeight = jaccardSlider.getSelection();
|
||||
levenshteinWeightLabel.setText(String.valueOf(levenshteinWeight));
|
||||
jaccardWeightLabel.setText(String.valueOf(jaccardWeight));
|
||||
autoMapGroup.layout();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contents of the button bar
|
||||
*
|
||||
@@ -256,6 +332,12 @@ public class PropertySetDialog extends Dialog {
|
||||
mapperManager.addRejectOutput();
|
||||
}
|
||||
}
|
||||
IPreferenceStore weightStore = CoreUIPlugin.getDefault().getPreferenceStore();
|
||||
levenshteinWeight = levenshteinSlider.getSelection();
|
||||
jaccardWeight = jaccardSlider.getSelection();
|
||||
weightStore.setValue(ITalendCorePrefConstants.LEVENSHTEIN_WEIGHT, levenshteinWeight);
|
||||
weightStore.setValue(ITalendCorePrefConstants.JACCARD_WEIGHT, jaccardWeight);
|
||||
|
||||
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 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.mapper.ui.dialog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
/**
|
||||
* DOC xwen class global comment. Detailled comment
|
||||
*/
|
||||
public class TableViewerContentProvider implements IStructuredContentProvider {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object,
|
||||
* java.lang.Object)
|
||||
*/
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
|
||||
*/
|
||||
public Object[] getElements(Object inputElement) {
|
||||
if (inputElement instanceof List) {
|
||||
Object[] o = ((List) inputElement).toArray();
|
||||
return o;
|
||||
} else {
|
||||
return new Object[0];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import org.eclipse.swt.widgets.ToolItem;
|
||||
import org.talend.commons.ui.runtime.image.EImage;
|
||||
import org.talend.designer.mapper.i18n.Messages;
|
||||
import org.talend.designer.mapper.managers.MapperManager;
|
||||
import org.talend.designer.mapper.managers.UIManager;
|
||||
import org.talend.designer.mapper.ui.visualmap.table.DataMapTableView;
|
||||
import org.talend.designer.mapper.ui.visualmap.zone.Zone;
|
||||
|
||||
@@ -109,7 +110,7 @@ public class ToolbarOutputZone extends ToolbarZone {
|
||||
* DOC amaumont Comment method "addListeners".
|
||||
*/
|
||||
private void addListeners() {
|
||||
// final UIManager uiManager = getMapperManager().getUiManager();
|
||||
final UIManager uiManager = getMapperManager().getUiManager();
|
||||
addOutputItem.addListener(SWT.Selection, new Listener() {
|
||||
|
||||
public void handleEvent(Event event) {
|
||||
@@ -133,7 +134,12 @@ public class ToolbarOutputZone extends ToolbarZone {
|
||||
for (DataMapTableView dataMapTableView : outputsTablesView) {
|
||||
dataMapTableView.notifyFocusLost();
|
||||
}
|
||||
getMapperManager().mapAutomaticallly();
|
||||
|
||||
uiManager.openAutoMappingDialog();
|
||||
|
||||
// IPreferenceStore weightStore = CoreUIPlugin.getDefault().getPreferenceStore();
|
||||
// getMapperManager().mapAutomaticallly(weightStore.getInt(ITalendCorePrefConstants.LEVENSHTEIN_WEIGHT),
|
||||
// weightStore.getInt(ITalendCorePrefConstants.JACCARD_WEIGHT));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -122,6 +122,8 @@ public class MetadataTableEditorViewExt extends MetadataTableEditorView {
|
||||
|
||||
mainComposite.setLayoutData(gridData);
|
||||
|
||||
tableComposite = mainComposite;
|
||||
|
||||
createHeaderTable();
|
||||
|
||||
initTable();
|
||||
|
||||
@@ -2932,6 +2932,14 @@
|
||||
name="reset the 'COLUMN_DELIMITER' parameter"
|
||||
version="6.5.0">
|
||||
</projecttask>
|
||||
<projecttask
|
||||
beforeLogon="false"
|
||||
breaks="6.5.0"
|
||||
class="org.talend.repository.model.migration.AddIncludTrashFilesOnGoogleDriveListTask"
|
||||
id="org.talend.repository.model.migration.AddIncludTrashFilesOnGoogleDriveListTask"
|
||||
name="Configure the new INCLUDTRASHFILES property to 'true' in order to keep the same behavior as before"
|
||||
version="6.5.1">
|
||||
</projecttask>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2007 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.repository.model.migration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.model.components.ComponentUtilities;
|
||||
import org.talend.core.model.components.ModifyComponentsAction;
|
||||
import org.talend.core.model.components.conversions.IComponentConversion;
|
||||
import org.talend.core.model.components.filters.IComponentFilter;
|
||||
import org.talend.core.model.components.filters.NameComponentFilter;
|
||||
import org.talend.core.model.migration.AbstractJobMigrationTask;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.migration.IMigrationTask.ExecutionResult;
|
||||
|
||||
|
||||
/**
|
||||
* Configure the new __INCLUDTRASHFILES__ property to 'true' in order to keep the same behavior as before.
|
||||
*
|
||||
* @author ypiel
|
||||
* @since 6.5.1
|
||||
*/
|
||||
public class AddIncludTrashFilesOnGoogleDriveListTask extends AbstractJobMigrationTask {
|
||||
|
||||
/**
|
||||
* The component to update.
|
||||
*/
|
||||
private final static String GOOGLE_DRIVE_LIST_NAME = "tGoogleDriveList";
|
||||
|
||||
/**
|
||||
* The name of the new property.
|
||||
*/
|
||||
private final static String INCLUDTRASHFILES_PROPERTY_NAME = "INCLUDTRASHFILES";
|
||||
|
||||
/**
|
||||
* Type of the new property.
|
||||
*/
|
||||
private final static String INCLUDTRASHFILES_PROPERTY_TYPE = "CHECK";
|
||||
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
return new GregorianCalendar(2017, 07, 07, 12, 0, 0).getTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExecutionResult execute(Item item) {
|
||||
ProcessType processType = getProcessType(item);
|
||||
|
||||
if (processType == null) {
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
IComponentConversion addIncludTrashProperty = new IComponentConversion() {
|
||||
|
||||
@Override
|
||||
public void transform(NodeType node) {
|
||||
ElementParameterType includeTrashFiles = ComponentUtilities.getNodeProperty(node, INCLUDTRASHFILES_PROPERTY_NAME);
|
||||
|
||||
// If INCLUDTRASHFILES_PROPERTY_NAME property doesn't exist, create with true to keep the same behavior as before
|
||||
if(includeTrashFiles == null) {
|
||||
ComponentUtilities.addNodeProperty(node, INCLUDTRASHFILES_PROPERTY_NAME, INCLUDTRASHFILES_PROPERTY_TYPE);
|
||||
ComponentUtilities.getNodeProperty(node, INCLUDTRASHFILES_PROPERTY_NAME).setValue("true");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
IComponentFilter filter = new NameComponentFilter(GOOGLE_DRIVE_LIST_NAME);
|
||||
|
||||
try {
|
||||
ModifyComponentsAction.searchAndModify(item,
|
||||
processType,
|
||||
filter,
|
||||
Arrays.<IComponentConversion> asList(addIncludTrashProperty));
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
|
||||
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.sqlbuilder.actions;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,8 +21,10 @@ import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.core.model.metadata.builder.database.DriverShim;
|
||||
import org.talend.core.sqlbuilder.util.TextUtil;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
import org.talend.metadata.managment.utils.MetadataConnectionUtils;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.sqlbuilder.IConstants;
|
||||
import org.talend.sqlbuilder.Messages;
|
||||
@@ -174,11 +177,13 @@ public class ExecSQLAction extends AbstractEditorAction {
|
||||
queryStrings.add(querySql);
|
||||
}
|
||||
}
|
||||
boolean executed = false;
|
||||
try {
|
||||
// Diaplay data in sqlResult Composites
|
||||
while (!queryStrings.isEmpty()) {
|
||||
String querySql = queryStrings.remove(0);
|
||||
if (querySql != null) {
|
||||
executed = true;
|
||||
SQLExecution sqlExe = new SQLExecution(querySql, maxRows, runNode);
|
||||
resultViewer.addSQLExecution(sqlExe);
|
||||
// editor.setSQLRunTime(sqlExe.getSQLResult().getExecutionTimeMillis());
|
||||
@@ -188,6 +193,19 @@ public class ExecSQLAction extends AbstractEditorAction {
|
||||
// e.printStackTrace();
|
||||
ExceptionHandler.process(e);
|
||||
SqlBuilderPlugin.log(Messages.getString("ExecSQLAction.logMessageErrorCreatingSqlTab"), e); //$NON-NLS-1$
|
||||
} finally {
|
||||
if (runNode != null && !executed) {
|
||||
DriverShim wapperDriver = runNode.getWapperDriver();
|
||||
String dbType = runNode.getDatabaseConnection().getDatabaseType();
|
||||
String driverClassName = runNode.getDatabaseConnection().getDriverClass();
|
||||
if (wapperDriver != null && MetadataConnectionUtils.isDerbyRelatedDb(driverClassName, dbType)) {
|
||||
try {
|
||||
wapperDriver.connect("jdbc:derby:;shutdown=true", null); //$NON-NLS-1$
|
||||
} catch (SQLException e) {
|
||||
// exception of shutdown success. no need to catch.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.metadata.managment.utils.MetadataConnectionUtils;
|
||||
import org.talend.repository.model.IRepositoryNode;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.sqlbuilder.IConstants;
|
||||
@@ -250,6 +251,8 @@ public final class EMFRepositoryNodeManager {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SqlBuilderPlugin.log(Messages.getString("EMFRepositoryNodeManager.logMessage"), e); //$NON-NLS-1$
|
||||
} finally {
|
||||
MetadataConnectionUtils.closeDerbyDriver();
|
||||
}
|
||||
}
|
||||
if (!relations.isEmpty()) {
|
||||
|
||||
@@ -81,6 +81,7 @@ import org.talend.sqlbuilder.editors.MultiPageSqlBuilderEditor;
|
||||
import org.talend.sqlbuilder.ui.AbstractSQLEditorComposite;
|
||||
import org.talend.sqlbuilder.ui.SQLBuilderDialog;
|
||||
import org.talend.utils.sql.ConnectionUtils;
|
||||
|
||||
import orgomg.cwm.resource.relational.Catalog;
|
||||
import orgomg.cwm.resource.relational.Schema;
|
||||
|
||||
@@ -864,11 +865,22 @@ public class SQLBuilderRepositoryNodeManager {
|
||||
public DatabaseMetaData getDatabaseMetaData(IMetadataConnection iMetadataConnection) throws ClassNotFoundException,
|
||||
InstantiationException, IllegalAccessException, SQLException {
|
||||
ExtractMetaDataUtils extractMeta = ExtractMetaDataUtils.getInstance();
|
||||
extractMeta.getConnection(iMetadataConnection.getDbType(), iMetadataConnection.getUrl(),
|
||||
List list = extractMeta.getConnection(iMetadataConnection.getDbType(), iMetadataConnection.getUrl(),
|
||||
iMetadataConnection.getUsername(), iMetadataConnection.getPassword(), iMetadataConnection.getDatabase(),
|
||||
iMetadataConnection.getSchema(), iMetadataConnection.getDriverClass(), iMetadataConnection.getDriverJarPath(),
|
||||
iMetadataConnection.getDbVersionString(), iMetadataConnection.getAdditionalParams());
|
||||
String dbType = iMetadataConnection.getDbType();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i) instanceof Driver) {
|
||||
String driverClass = iMetadataConnection.getDriverClass();
|
||||
if (MetadataConnectionUtils.isDerbyRelatedDb(driverClass, dbType)) {
|
||||
MetadataConnectionUtils.setDerbyDriver((Driver) list.get(i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DatabaseMetaData dbMetaData = null;
|
||||
// Added by Marvin Wang on Mar. 13, 2013 for loading hive jars dynamically, refer to TDI-25072.
|
||||
if (EDatabaseTypeName.HIVE.getXmlName().equalsIgnoreCase(dbType)) {
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2014 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.ui.editor.jobletcontainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.image.ImageUtils;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.model.properties.ByteArray;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.FakePropertyImpl;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.repository.RepositoryObject;
|
||||
import org.talend.core.model.routines.RoutinesUtil;
|
||||
import org.talend.core.repository.ui.view.RepositoryLabelProvider;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.designer.core.model.process.AbstractProcessProvider;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ParametersType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
import org.talend.designer.core.ui.editor.nodecontainer.NodeContainer;
|
||||
import org.talend.designer.core.ui.editor.nodes.Node;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
import org.talend.designer.joblet.model.JobletFactory;
|
||||
import org.talend.designer.joblet.model.JobletProcess;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
/**
|
||||
* created by wchen on Jul 27, 2017 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class JobletUtilTest {
|
||||
|
||||
IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
|
||||
|
||||
IComponentsFactory components = ComponentsFactoryProvider.getInstance();
|
||||
|
||||
List<IRepositoryViewObject> repositoryObjects;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
repositoryObjects = new ArrayList<IRepositoryViewObject>();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
for (IRepositoryViewObject repositoryObject : repositoryObjects) {
|
||||
factory.deleteObjectPhysical(repositoryObject);
|
||||
IComponent jobletComponent = components.get(repositoryObject.getLabel(), ComponentCategory.CATEGORY_4_DI.getName());
|
||||
components.getComponents().remove(jobletComponent);
|
||||
}
|
||||
AbstractProcessProvider.loadComponentsFromProviders();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReloadJobletInCurrentProcess() throws PersistenceException {
|
||||
String label = "testReloadJobletInCurrentProcess";
|
||||
String id = factory.getNextId();
|
||||
createRepositoryObject(label, id, VersionUtils.DEFAULT_VERSION);
|
||||
AbstractProcessProvider.loadComponentsFromProviders();
|
||||
IComponent jobleComponent = components.get(label, ComponentCategory.CATEGORY_4_DI.getName());
|
||||
IComponent tMsgComponent = components.get("tMsgBox", ComponentCategory.CATEGORY_4_DI.getName());
|
||||
|
||||
Property porperty = new FakePropertyImpl();
|
||||
Process currentProcess = new Process(porperty);
|
||||
Node jobletNode = new Node(jobleComponent, currentProcess);
|
||||
currentProcess.addNodeContainer(new NodeContainer(jobletNode));
|
||||
|
||||
Process jobletProcess = (Process) jobletNode.getComponent().getProcess();
|
||||
Node node = new Node(tMsgComponent, jobletProcess);
|
||||
jobletProcess.addNodeContainer(new NodeContainer(node));
|
||||
|
||||
Assert.assertEquals(jobletProcess.getGraphicalNodes().size(), 1);
|
||||
|
||||
JobletUtil jUtil = new JobletUtil();
|
||||
jUtil.reloadJobletInCurrentProcess(currentProcess);
|
||||
|
||||
Process jobletProcessAfterReload = (Process) jobletNode.getComponent().getProcess();
|
||||
Assert.assertFalse(jobletProcessAfterReload == jobletProcess);
|
||||
Assert.assertEquals(jobletProcessAfterReload.getGraphicalNodes().size(), 0);
|
||||
|
||||
}
|
||||
|
||||
private IRepositoryViewObject createRepositoryObject(String label, String id, String version) throws PersistenceException {
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
|
||||
property.setVersion(version);
|
||||
property.setStatusCode(""); //$NON-NLS-1$
|
||||
|
||||
JobletProcessItem processItem = PropertiesFactory.eINSTANCE.createJobletProcessItem();
|
||||
ByteArray ba = PropertiesFactory.eINSTANCE.createByteArray();
|
||||
processItem.setIcon(ba);
|
||||
processItem.getIcon().setInnerContent(
|
||||
ImageUtils.saveImageToData(RepositoryLabelProvider.getDefaultJobletImage(processItem)));
|
||||
|
||||
processItem.setProperty(property);
|
||||
property.setId(id);
|
||||
property.setLabel(label);
|
||||
property.setDisplayName(property.getLabel());
|
||||
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
|
||||
// add depended routines.
|
||||
List<RoutinesParameterType> dependenciesInPreference;
|
||||
dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
|
||||
|
||||
parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
|
||||
JobletProcess process = JobletFactory.eINSTANCE.createJobletProcess();
|
||||
process.setParameters(parameterType);
|
||||
processItem.setJobletProcess(process);
|
||||
factory.create(processItem, new Path(""));
|
||||
return new RepositoryObject(property);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2016 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.utils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.designer.core.model.components.ElementParameter;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public class UpdateParameterUtilsTest {
|
||||
|
||||
@SuppressWarnings("nls")
|
||||
@Test
|
||||
public void deepCopyTest() {
|
||||
ElementParameter from = new ElementParameter(null);
|
||||
String P1 = "P1";
|
||||
from.setValue(P1); // $NON-NLS-1$
|
||||
|
||||
Map<String, IElementParameter> fromChildren = from.getChildParameters();
|
||||
|
||||
ElementParameter child = new ElementParameter(null);
|
||||
String CK1 = "CK1";
|
||||
String CV1 = "CV1";
|
||||
child.setValue(CV1);
|
||||
fromChildren.put(CK1, child);
|
||||
|
||||
child = new ElementParameter(null);
|
||||
String CK2 = "CK2";
|
||||
String CV2 = "CV2";
|
||||
child.setValue(CV2);
|
||||
fromChildren.put(CK2, child);
|
||||
|
||||
child = new ElementParameter(null);
|
||||
String CK3 = "CK3";
|
||||
String CV3 = "CV3";
|
||||
child.setValue(CV3);
|
||||
fromChildren.put(CK3, child);
|
||||
|
||||
Map<String, IElementParameter> fromChidlren2 = child.getChildParameters();
|
||||
child = new ElementParameter(null);
|
||||
String CCK1 = "CCK1";
|
||||
String CCV1 = "CCV1";
|
||||
child.setValue(CCV1);
|
||||
fromChidlren2.put(CCK1, child);
|
||||
|
||||
child = new ElementParameter(null);
|
||||
String CCK2 = "CCK2";
|
||||
String CCV2 = "CCV2";
|
||||
child.setValue(CCV2);
|
||||
fromChidlren2.put(CCK2, child);
|
||||
|
||||
child = new ElementParameter(null);
|
||||
String CCK3 = "CCK3";
|
||||
String CCV3 = "CCV3";
|
||||
child.setValue(CCV3);
|
||||
fromChidlren2.put(CCK3, child);
|
||||
|
||||
ElementParameter to = new ElementParameter(null);
|
||||
|
||||
UpdateParameterUtils.deepCopy(from, to);
|
||||
|
||||
assertResult(from, to);
|
||||
}
|
||||
|
||||
private void assertResult(IElementParameter left, IElementParameter right) {
|
||||
|
||||
if (left == null && right == null) {
|
||||
assertTrue(true);
|
||||
return;
|
||||
} else if (left == null || right == null) {
|
||||
assertTrue(false);
|
||||
return;
|
||||
}
|
||||
|
||||
assertEquals(left.getValue(), right.getValue());
|
||||
|
||||
Map<String, IElementParameter> leftChildren = left.getChildParameters();
|
||||
Map<String, IElementParameter> rightChildren = right.getChildParameters();
|
||||
|
||||
assertEquals(leftChildren.size(), rightChildren.size());
|
||||
|
||||
for (Map.Entry<String, IElementParameter> leftEntry : leftChildren.entrySet()) {
|
||||
String key = leftEntry.getKey();
|
||||
IElementParameter leftParameter = leftEntry.getValue();
|
||||
IElementParameter rightParameter = rightChildren.get(key);
|
||||
assertResult(leftParameter, rightParameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user