Compare commits
14 Commits
patch/8.0.
...
patch/7.3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68c9322695 | ||
|
|
5b25e32ed1 | ||
|
|
6524cb203d | ||
|
|
738ba8f372 | ||
|
|
cf5f86d862 | ||
|
|
02f668b24d | ||
|
|
35d710ca54 | ||
|
|
c78507196c | ||
|
|
7a60d7fdbb | ||
|
|
e05ae031de | ||
|
|
3028e357b1 | ||
|
|
7dab8ce963 | ||
|
|
35b20bb39e | ||
|
|
25d58e1fd2 |
@@ -514,17 +514,35 @@
|
||||
}
|
||||
org.apache.logging.log4j.core.config.Configurator.setLevel(org.apache.logging.log4j.LogManager.getRootLogger().getName(), log.getLevel());
|
||||
<%}%>
|
||||
}
|
||||
log.info("TalendJob: '<%=codeGenArgument.getJobName()%>' - Start.");
|
||||
<%}%>
|
||||
|
||||
<%
|
||||
INode jobCatcherNode = null;
|
||||
}
|
||||
log.info("TalendJob: '<%=codeGenArgument.getJobName()%>' - Start.");
|
||||
<%}%>
|
||||
|
||||
<%
|
||||
INode jobCatcherNode = null;
|
||||
|
||||
int threadPoolSize = 0;
|
||||
boolean tRESTRequestLoopExists = false;
|
||||
for (INode nodeInProcess : process.getGeneratingNodes()) {
|
||||
String componentName = nodeInProcess.getComponent().getName();
|
||||
if("tJobStructureCatcher".equals(componentName)) {
|
||||
|
||||
if(jobCatcherNode==null && "tJobStructureCatcher".equals(componentName)) {
|
||||
jobCatcherNode = nodeInProcess;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!nodeInProcess.isActivate()) continue;
|
||||
|
||||
if("tRESTRequestLoop".equals(componentName)) {
|
||||
tRESTRequestLoopExists = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if("tWriteXMLFieldOut".equals(componentName)) {
|
||||
IConnection nextMergeConn = NodeUtil.getNextMergeConnection(nodeInProcess);
|
||||
if(nextMergeConn == null || nextMergeConn.getInputId()==1){
|
||||
threadPoolSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1199,6 +1217,26 @@ this.globalResumeTicket = true;//to run tPostJob
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
//tRESTRequest may appear in microservice, the code may be called before call submit(task) method, so can't shutdown it here
|
||||
if(!tRESTRequestLoopExists && threadPoolSize>0) {
|
||||
%>
|
||||
es.shutdown();
|
||||
<%//shutdownNow should never be executed, only for safe%>
|
||||
try {
|
||||
if(!es.awaitTermination(60, java.util.concurrent.TimeUnit.SECONDS)) {
|
||||
es.shutdownNow();
|
||||
if(!es.awaitTermination(60, java.util.concurrent.TimeUnit.SECONDS)) {
|
||||
|
||||
}
|
||||
}
|
||||
} catch (java.lang.InterruptedException ie) {
|
||||
es.shutdownNow();
|
||||
} catch (java.lang.Exception e) {
|
||||
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -385,11 +385,101 @@ public <%=JavaTypesManager.getTypeToGenerate(ctxParam.getType(),true)%> get<%=Ch
|
||||
|
||||
<%
|
||||
INode jobCatcherNode = null;
|
||||
|
||||
//one matched component or part, one thread
|
||||
//why not computed by cpu or resource : please image this case :
|
||||
//loop==>(input==>(twritexmlfield A)==>(twritexmlfield B)==>(twritexmlfield C)==>output), dead lock as cycle dependency and only one thead in thread pool
|
||||
//maybe newCachedThreadPool is a better idea, but that have risk for creating more threads, then more memory for TDI-47230
|
||||
//why not generate thread pool object in subprocess scope :
|
||||
// 1: major reason : difficult to control the var scope, somewhere can't access it, then compiler issue
|
||||
// 2: we may need this thread pool for bigger scope, not only for twritexmlfield/twritejsonfield in future
|
||||
// 3: we don't suppose this thread pool cost big resource after all tasks done, so we can shutdown it more later,
|
||||
// for example, most time, user will use less than 3 twritexmlfield in one job, then 3 threads thread pool, we can close them in job finish code part,
|
||||
// not a big cost to keep that. And of course, we best to start&clean it in subprocess finish, but that's risk of 1 above.
|
||||
int threadPoolSize = 0;
|
||||
boolean tHMapExists = false;
|
||||
boolean tHMapOutExists = false;
|
||||
boolean tRESTRequestLoopExists = false;
|
||||
for (INode nodeInProcess : processNodes) {
|
||||
String componentName = nodeInProcess.getComponent().getName();
|
||||
if("tJobStructureCatcher".equals(componentName)) {
|
||||
|
||||
if(jobCatcherNode==null && "tJobStructureCatcher".equals(componentName)) {
|
||||
jobCatcherNode = nodeInProcess;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!nodeInProcess.isActivate()) continue;
|
||||
|
||||
if("tHMap".equals(componentName)) {
|
||||
tHMapExists = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if("tHMapOut".equals(componentName)) {
|
||||
tHMapOutExists = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if("tRESTRequestLoop".equals(componentName)) {
|
||||
tRESTRequestLoopExists = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if("tWriteXMLFieldOut".equals(componentName)) {
|
||||
IConnection nextMergeConn = NodeUtil.getNextMergeConnection(nodeInProcess);
|
||||
if(nextMergeConn == null || nextMergeConn.getInputId()==1){
|
||||
threadPoolSize++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(threadPoolSize>0) {
|
||||
if(tRESTRequestLoopExists) {//miscroservice
|
||||
%>
|
||||
private class DaemonThreadFactory implements java.util.concurrent.ThreadFactory {
|
||||
java.util.concurrent.ThreadFactory factory = java.util.concurrent.Executors.defaultThreadFactory();
|
||||
|
||||
public java.lang.Thread newThread(java.lang.Runnable r) {
|
||||
java.lang.Thread t = factory.newThread(r);
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
<%
|
||||
}
|
||||
|
||||
if(tHMapExists || tHMapOutExists) {
|
||||
%>
|
||||
private final java.util.concurrent.ExecutorService es = java.util.concurrent.Executors.newFixedThreadPool(<%=threadPoolSize%> <%if(tRESTRequestLoopExists) {%>,new DaemonThreadFactory()<%}%>);
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
private final java.util.concurrent.ExecutorService es = java.util.concurrent.Executors.newCachedThreadPool(<%if(tRESTRequestLoopExists) {%>new DaemonThreadFactory()<%}%>);
|
||||
<%
|
||||
}
|
||||
|
||||
if(tRESTRequestLoopExists) {//miscroservice
|
||||
%>
|
||||
{
|
||||
java.lang.Runtime.getRuntime().addShutdownHook(new java.lang.Thread() {
|
||||
public void run() {
|
||||
es.shutdown();
|
||||
try {
|
||||
if(!es.awaitTermination(60, java.util.concurrent.TimeUnit.SECONDS)) {
|
||||
es.shutdownNow();
|
||||
if(!es.awaitTermination(60, java.util.concurrent.TimeUnit.SECONDS)) {
|
||||
|
||||
}
|
||||
}
|
||||
} catch (java.lang.InterruptedException ie) {
|
||||
es.shutdownNow();
|
||||
} catch (java.lang.Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
<%
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -280,10 +280,16 @@ if(columnList != null && columnList.size()>0) {
|
||||
java.lang.StringBuilder primaryKeysSB = new java.lang.StringBuilder();
|
||||
java.lang.StringBuilder updateColumnSB = new java.lang.StringBuilder();
|
||||
for(Column column : stmtStructure) {
|
||||
String columnName = column.getColumnName();
|
||||
if (column.isReplaced()) {
|
||||
for (Column replacedColumn : column.getReplacement()) {
|
||||
columnName = replacedColumn.getColumnName();
|
||||
}
|
||||
}
|
||||
if (column.isKey()) {
|
||||
primaryKeysSB.append("\\\"").append(column.getColumnName()).append("\\\"").append(",");
|
||||
primaryKeysSB.append("\\\"").append(columnName).append("\\\"").append(",");
|
||||
} else {
|
||||
updateColumnSB.append("\\\"").append(column.getColumnName()).append("\\\"").append(" = EXCLUDED.").append("\\\"").append(column.getColumnName()).append("\\\"").append(",");
|
||||
updateColumnSB.append("\\\"").append(columnName).append("\\\"").append(" = EXCLUDED.").append("\\\"").append(columnName).append("\\\"").append(",");
|
||||
}
|
||||
}
|
||||
String primaryKeys = primaryKeysSB.toString();
|
||||
|
||||
@@ -189,6 +189,22 @@ skeleton="../templates/db_output_bulk.skeleton"
|
||||
if (("UPSERT").equals(dataAction)) {%>
|
||||
java.lang.StringBuilder dynamicPrimaryKeysSB_<%=cid%> = new java.lang.StringBuilder();
|
||||
java.lang.StringBuilder dynamicUpdateColumnSB_<%=cid%> = new java.lang.StringBuilder();
|
||||
<%for(Column column : stmtStructure) {
|
||||
if (!column.isDynamic()) {
|
||||
String columnName = column.getColumnName();
|
||||
if (column.isReplaced()) {
|
||||
for (Column replacedColumn : column.getReplacement()) {
|
||||
columnName = replacedColumn.getColumnName();
|
||||
}
|
||||
}
|
||||
if(column.isKey()) {%>
|
||||
dynamicPrimaryKeysSB_<%=cid%>.append("\"").append("<%=columnName%>").append("\"").append(",");
|
||||
<%} else {%>
|
||||
dynamicUpdateColumnSB_<%=cid%>.append("\"").append("<%=columnName%>").append("\"").append(" = EXCLUDED.").append("\"")
|
||||
.append("<%=columnName%>").append("\"").append(",");
|
||||
<%}
|
||||
}
|
||||
}%>
|
||||
for (int x_<%=cid%> = 0; x_<%=cid%> < dynamic_<%=cid%>.getColumnCount(); x_<%=cid%>++) {
|
||||
routines.system.DynamicMetadata column_<%=cid%> = dynamic_<%=cid%>.getColumnMetadata(x_<%=cid%>);
|
||||
if(column_<%=cid%>.isKey()) {
|
||||
|
||||
@@ -209,4 +209,8 @@ globalMap.put("<%=cid%>_ERROR_MESSAGE",e_<%=cid%>.getMessage());
|
||||
globalMap.put("<%=cid %>_NB_FILE",nb_file_<%=cid%>);
|
||||
globalMap.put("<%=cid %>_ERROR_MESSAGE",e_<%=cid%>.getMessage());
|
||||
throw e_<%=cid%>;
|
||||
}finally {
|
||||
if(session_<%=cid%> != null) {
|
||||
session_<%=cid%>.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
}
|
||||
IConnection nextMergeConn = NodeUtil.getNextMergeConnection(node);
|
||||
if(nextMergeConn != null && nextMergeConn.getInputId()>1 && startNodeCid != null){
|
||||
%>
|
||||
%>
|
||||
txf_<%=cid%>.join();
|
||||
|
||||
if(txf_<%=cid%>.getLastException()!=null) {
|
||||
|
||||
@@ -100,7 +100,7 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
}
|
||||
%>
|
||||
|
||||
class ThreadXMLField_<%=cid%> extends Thread {
|
||||
class ThreadXMLField_<%=cid%> implements java.lang.Runnable {
|
||||
<%
|
||||
if(destination.indexOf("tCouchbaseOutput_")==0 || destination.indexOf("tCouchDBOutput_")==0){
|
||||
%>
|
||||
@@ -167,7 +167,9 @@ globalMap.put("<%=cid%>_ERROR_MESSAGE",te.getMessage());
|
||||
<%} else {%>
|
||||
ThreadXMLField_<%=cid%> txf_<%=cid%> = new ThreadXMLField_<%=cid%>(listGroupby_<%=cid%>, flows_<%=cid%>);
|
||||
<%}%>
|
||||
txf_<%=cid%>.start();
|
||||
|
||||
java.util.concurrent.Future<?> future_<%=cid%> = es.submit(txf_<%=cid%>);
|
||||
globalMap.put("wrtXMLFieldIn_<%=cid%>", future_<%=cid%>);
|
||||
<%
|
||||
}else{
|
||||
if(destination.indexOf("tCouchbaseOutput_")==0 || destination.indexOf("tCouchDBOutput_")==0){
|
||||
|
||||
@@ -352,7 +352,7 @@ globalMap.put("<%=virtualTargetCid%>_FINISH" + (listGroupby_<%=cid%>==null?"":li
|
||||
IConnection nextMergeConn = NodeUtil.getNextMergeConnection(node);
|
||||
if(nextMergeConn == null || nextMergeConn.getInputId()==1){
|
||||
%>
|
||||
txf_<%=cid%>.join();
|
||||
future_<%=cid%>.get();
|
||||
|
||||
if(txf_<%=cid%>.getLastException()!=null) {
|
||||
currentComponent = txf_<%=cid%>.getCurrentComponent();
|
||||
|
||||
@@ -38,6 +38,12 @@ if ((metadatas!=null)&&(metadatas.size()>0)) {
|
||||
if (listGroupby_<%=cid%> != null) {
|
||||
globalMap.put("<%=virtualTargetCid%>_FINISH" + (listGroupby_<%=cid%>==null?"":listGroupby_<%=cid%>.hashCode()), "true");
|
||||
}
|
||||
// workaround for 37349 - in case of normal execution it will pass normally
|
||||
// in case it fails and handle by catch - it will wait for child thread finish
|
||||
java.util.concurrent.Future<?> future_<%=cid%> = (java.util.concurrent.Future) globalMap.get("wrtXMLFieldIn_<%=cid%>");
|
||||
if (future_<%=cid%> != null) {
|
||||
future_<%=cid%>.get();
|
||||
}
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%@ jet
|
||||
%>
|
||||
<%
|
||||
if(("INSERT").equals(dataAction) || ("INSERT_IGNORE").equals(dataAction)) {
|
||||
if(("INSERT").equals(dataAction) || ("INSERT_IGNORE").equals(dataAction) || ("UPSERT").equals(dataAction)) {
|
||||
%>
|
||||
String[] insertSQLSplits_<%=cid%> = insert_<%=cid%>.split("\\?");
|
||||
<%
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%@ jet
|
||||
%>
|
||||
<%
|
||||
if(("INSERT").equals(dataAction) || ("INSERT_IGNORE").equals(dataAction)) {
|
||||
if(("INSERT").equals(dataAction) || ("INSERT_IGNORE").equals(dataAction) || ("UPSERT").equals(dataAction)) {
|
||||
%>
|
||||
String[] insertSQLSplits_<%=cid%> = null;
|
||||
<%
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%@ jet
|
||||
%>
|
||||
<%
|
||||
if(("INSERT").equals(dataAction) || ("INSERT_IGNORE").equals(dataAction)) {
|
||||
if(("INSERT").equals(dataAction) || ("INSERT_IGNORE").equals(dataAction) || ("UPSERT").equals(dataAction)) {
|
||||
%>
|
||||
insertSQLSplits_<%=cid%> = insert_<%=cid%>.split("\\?");
|
||||
<%
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.avro.Schema;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.INode;
|
||||
@@ -23,6 +24,7 @@ import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.runtime.evaluator.AbstractPropertyValueEvaluator;
|
||||
import org.talend.core.runtime.util.GenericTypeUtils;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.daikon.properties.property.Property;
|
||||
|
||||
/**
|
||||
@@ -85,10 +87,24 @@ public class ComponentContextPropertyValueEvaluator extends AbstractPropertyValu
|
||||
} else {
|
||||
stringStoredValue = simpleConvertResult;
|
||||
}
|
||||
if (GenericTypeUtils.isStringType(property)) {
|
||||
String val = String.valueOf(stringStoredValue);
|
||||
if (property.isFlag(Property.Flags.ENCRYPT)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (storedValue instanceof List) {
|
||||
return storedValue;
|
||||
}
|
||||
if (GenericTypeUtils.isStringType(property)) {
|
||||
|
||||
String val = String.valueOf(stringStoredValue);
|
||||
|
||||
if (property.isFlag(Property.Flags.ENCRYPT)) {
|
||||
return TalendQuoteUtils.removeQuotes(StringEscapeUtils.unescapeJava(val));
|
||||
}
|
||||
}
|
||||
return getTypedValue(property, storedValue, stringStoredValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.talend.core.model.components.IODataComponentContainer;
|
||||
import org.talend.core.model.metadata.ColumnNameChanged;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataToolHelper;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
@@ -157,8 +158,7 @@ public class ExternalNodeChangeCommand extends Command {
|
||||
repositoryMetadata = repositoryMetadata.clone();
|
||||
repositoryMetadata.setTableName(connection.getSource().getUniqueName());
|
||||
((org.talend.core.model.metadata.MetadataTable) repositoryMetadata).setRepository(true);
|
||||
if (!repositoryMetadata
|
||||
.sameMetadataAs(connection.getMetadataTable(), IMetadataColumn.OPTIONS_IGNORE_USED)) {
|
||||
if (needChangeSchemaType(connection, repositoryMetadata)) {
|
||||
connection.getSource().setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
|
||||
}
|
||||
}
|
||||
@@ -169,6 +169,43 @@ public class ExternalNodeChangeCommand extends Command {
|
||||
setLabel(Messages.getString("ExternalNodeChangeCommand.modifaicationFrom") + node.getUniqueName()); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
protected boolean needChangeSchemaType(IConnection connection, IMetadataTable repositoryMetadata) {
|
||||
EConnectionType lineStyle = connection.getLineStyle();
|
||||
String connectorName = connection.getConnectorName();
|
||||
IMetadataTable metadataTable = connection.getMetadataTable();
|
||||
if (EConnectionType.REJECT == lineStyle || "REJECT".equals(connectorName)) {
|
||||
IElementParameter inputSchemaParam = null;
|
||||
for (IElementParameter param : connection.getSource().getElementParameters()) {
|
||||
if ((EParameterFieldType.SCHEMA_TYPE.equals(param.getFieldType())
|
||||
|| EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType()))
|
||||
&& (param.getContext().equals(connectorName))) {
|
||||
inputSchemaParam = param;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (inputSchemaParam != null) {
|
||||
Object value = inputSchemaParam.getValue();
|
||||
if (value instanceof MetadataTable) {
|
||||
MetadataTable table = (MetadataTable) value;
|
||||
List<IMetadataColumn> columns = table.getListColumns();
|
||||
|
||||
List<IMetadataColumn> inputColumnListWithUnselected = new ArrayList<IMetadataColumn>(
|
||||
metadataTable.getListColumns(true));
|
||||
// errorCode,errorFields,errorMessage
|
||||
for (int i = 0; i < columns.size(); i++) {
|
||||
IMetadataColumn inputColumn = columns.get(i);
|
||||
IMetadataColumn myColumn = metadataTable.getColumn(inputColumn.getLabel());
|
||||
inputColumnListWithUnselected.remove(myColumn);
|
||||
}
|
||||
return !repositoryMetadata.sameMetadataAs(inputColumnListWithUnselected, IMetadataColumn.OPTIONS_IGNORE_USED);
|
||||
}
|
||||
}
|
||||
}
|
||||
return !repositoryMetadata
|
||||
.sameMetadataAs(metadataTable, IMetadataColumn.OPTIONS_IGNORE_USED);
|
||||
}
|
||||
|
||||
private void refreshCodeView() {
|
||||
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
IViewPart view = page.findView(CodeView.ID);
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.talend.core.model.process.Element;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.process.JobInfo;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
@@ -306,6 +307,8 @@ public abstract class BigDataJavaProcessor extends MavenJavaProcessor implements
|
||||
if (isExport) {
|
||||
// In an export mode, we add the job jar which is located in the current working directory
|
||||
libJars.append("./" + makeupJobJarName()); //$NON-NLS-1$
|
||||
// to fix TBD-13419, need to add the subjob jar name to the -libjars parameter
|
||||
libJars.append(makeupSubjobJarNameStr4Export()); //$NON-NLS-1$
|
||||
if (!needAllLibJars) {
|
||||
// to avoid issue TPSVC-4826
|
||||
libJars.append(","); //$NON-NLS-1$
|
||||
@@ -333,12 +336,61 @@ public abstract class BigDataJavaProcessor extends MavenJavaProcessor implements
|
||||
|
||||
// ... and add the jar of the job itself also located in the target directory/
|
||||
libJars.append(getTalendJavaProject().getTargetFolder().getLocation().toPortableString() + "/" + makeupJobJarName()); //$NON-NLS-1$
|
||||
// to fix TBD-13419, need to add the subjob jar name to the -libjars parameter
|
||||
libJars.append(makeupSubjobJarNameStr4Local());
|
||||
}
|
||||
list.add(libJars.toString());
|
||||
return list;
|
||||
}
|
||||
|
||||
protected String makeUpClassPathString() {
|
||||
/**
|
||||
* Makes up the subjob(s) jar name string for local, that should be like:
|
||||
* 1) "" (no subjobs)
|
||||
* 2) ",<project_folder>/poms/jobs/process/<subjob_name_versiono>/target/<subjob_name_versiono>.jar" (standard subjob)
|
||||
* 3) ",<project_folder>/poms/jobs/process_mr/<subjob_name_version>/target/<subjob_name_versiono>.jar" (spark subjob)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String makeupSubjobJarNameStr4Local() {
|
||||
String subjobJarNameStr = ""; //$NON-NLS-1$
|
||||
Set<JobInfo> jobInfos = getBuildChildrenJobs();
|
||||
if (!jobInfos.isEmpty()) {
|
||||
Iterator<JobInfo> it = jobInfos.iterator();
|
||||
while (it.hasNext()) {
|
||||
JobInfo jobInfo = it.next();
|
||||
subjobJarNameStr += "," //$NON-NLS-1$
|
||||
+ TalendJavaProjectManager.getTalendJobJavaProject(jobInfo.getProcessItem().getProperty())
|
||||
.getTargetFolder()
|
||||
.getLocation()
|
||||
.toPortableString()
|
||||
+ "/" + jobInfo.getJobName().toLowerCase() + "_" + jobInfo.getJobVersion().replace(".", "_") //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
+ ".jar"; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return subjobJarNameStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes up the subjob(s) jar name string for export, that should be like:
|
||||
* 1) "" (no subjobs)
|
||||
* 2) ",./subjob1_0_1.jar" (with subjobs)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected String makeupSubjobJarNameStr4Export() {
|
||||
String subjobJarNameStr = ""; //$NON-NLS-1$
|
||||
Set<JobInfo> jobInfos = getBuildChildrenJobs();
|
||||
if (!jobInfos.isEmpty()) {
|
||||
Iterator<JobInfo> it = jobInfos.iterator();
|
||||
while (it.hasNext()) {
|
||||
JobInfo jobInfo = it.next();
|
||||
subjobJarNameStr += ",./" + jobInfo.getJobName().toLowerCase() + "_" + jobInfo.getJobVersion().replace(".", "_") + ".jar"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
||||
}
|
||||
}
|
||||
return subjobJarNameStr;
|
||||
}
|
||||
|
||||
protected String makeUpClassPathString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try {
|
||||
sb.append(getLibsClasspath());
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.components.api.component.ComponentDefinition;
|
||||
@@ -91,7 +92,7 @@ public class GenericDragAndDropHandler extends AbstractDragAndDropServiceHandler
|
||||
Map<Object, Object> contextMap) {
|
||||
if (value != null && canHandle(connection)) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault()
|
||||
IGenericWizardService wizardService = GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
if (wizardService != null && wizardService.isGenericConnection(connection)) {
|
||||
List<ComponentProperties> componentPropertiesList = wizardService.getAllComponentProperties(connection,
|
||||
@@ -149,12 +150,12 @@ public class GenericDragAndDropHandler extends AbstractDragAndDropServiceHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getPassword(Connection connection, String value) {
|
||||
public static String getPassword(Connection connection, String value) {
|
||||
String pass = connection.getValue(value, false);
|
||||
if (ContextParameterUtils.isContextMode(connection, value)) {
|
||||
return pass;
|
||||
}
|
||||
return TalendQuoteUtils.addQuotesIfNotExist(pass);
|
||||
return TalendQuoteUtils.addQuotes(pass);
|
||||
}
|
||||
|
||||
private Object getPropertiesValue(Connection connection, Properties properties, String value) {
|
||||
@@ -258,7 +259,7 @@ public class GenericDragAndDropHandler extends AbstractDragAndDropServiceHandler
|
||||
if (((ConnectionItem) item).getConnection().getCompProperties() == null) {
|
||||
return neededComponents;
|
||||
}
|
||||
IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class);
|
||||
IComponentsService service = GlobalServiceRegister.getDefault().getService(IComponentsService.class);
|
||||
Collection<IComponent> components = service.getComponentsFactory().readComponents();
|
||||
for (IComponent component : components) {
|
||||
if (EComponentType.GENERIC.equals(component.getComponentType())) {
|
||||
@@ -284,7 +285,7 @@ public class GenericDragAndDropHandler extends AbstractDragAndDropServiceHandler
|
||||
}
|
||||
IGenericDBService dbService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
dbService = (IGenericDBService) GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
|
||||
dbService = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
|
||||
}
|
||||
if (dbService != null && dbService.getExtraTypes().contains(parent.getObjectType())) {
|
||||
return true;
|
||||
|
||||
@@ -346,7 +346,9 @@ public class GenericContextUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} else if (property.isFlag(Property.Flags.ENCRYPT)) {
|
||||
property.setValue(valueFromContext);
|
||||
} else {
|
||||
property.setValue(TalendQuoteUtils.removeQuotes(valueFromContext));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.talend.sdk.component.studio.metadata.tableeditor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -52,13 +53,15 @@ public class TaCoKitPropertiesTableEditorView<B> extends PropertiesTableEditorVi
|
||||
CCombo combo = (CCombo) cbc.getControl();
|
||||
String val = null;
|
||||
|
||||
boolean needUpdateListItem = false;
|
||||
if (combo.getEditable() && !StringUtils.isBlank(combo.getText())) {
|
||||
val = String.valueOf(combo.getText());
|
||||
needUpdateListItem = true;
|
||||
}
|
||||
|
||||
int rowNumber = ((Table) combo.getParent()).getSelectionIndex();
|
||||
|
||||
Map<String, String> svs = new HashMap<String, String>();
|
||||
Map<String, String> svs = new LinkedHashMap<String, String>();
|
||||
|
||||
if (currentParam.getListItemsValue() != null && currentParam.getListItemsValue().length > 0) {
|
||||
for (Object o : currentParam.getListItemsValue()) {
|
||||
@@ -70,7 +73,7 @@ public class TaCoKitPropertiesTableEditorView<B> extends PropertiesTableEditorVi
|
||||
svs.put(val, val);
|
||||
}
|
||||
|
||||
if (!svs.isEmpty()) {
|
||||
if (!svs.isEmpty() && needUpdateListItem) {
|
||||
TaCoKitUtil.updateElementParameter(currentParam, svs);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2022 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.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
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.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataTable;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IConnection;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.designer.core.ui.editor.connections.Connection;
|
||||
import org.talend.designer.core.ui.editor.nodes.Node;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
|
||||
public class ExternalNodeChangeCommandTest {
|
||||
|
||||
@Test
|
||||
public void testNeedChangeSchemaType() throws Exception {
|
||||
Process process = new Process(createProperty());
|
||||
|
||||
IElementParameter param = null;
|
||||
|
||||
|
||||
String componentName = "tSalesforceOutput";
|
||||
IComponent salesforceOutputComponent = ComponentsFactoryProvider.getInstance().get(componentName,
|
||||
ComponentCategory.CATEGORY_4_DI.getName());
|
||||
Node salesforceOutputNode = new Node(salesforceOutputComponent, process);
|
||||
IMetadataTable metadataFromConnector = salesforceOutputNode.getMetadataFromConnector("REJECT");
|
||||
List<IMetadataColumn> mockMetadataColumns = mockMetadataColumns(
|
||||
new String[] { "errorCode", "errorFields", "errorMessage" });
|
||||
metadataFromConnector.setListColumns(mockMetadataColumns);
|
||||
|
||||
for (IElementParameter param1 : salesforceOutputNode.getElementParameters()) {
|
||||
if ((EParameterFieldType.SCHEMA_TYPE.equals(param1.getFieldType())
|
||||
|| EParameterFieldType.SCHEMA_REFERENCE.equals(param1.getFieldType()))
|
||||
&& (param1.getContext().equals("REJECT"))) {
|
||||
param = param1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MetadataTable mockRepoMetadata = Mockito.mock(MetadataTable.class);
|
||||
param.setValue(mockRepoMetadata);
|
||||
|
||||
componentName = "tLogRow";
|
||||
IComponent logRowComponent = ComponentsFactoryProvider.getInstance().get(componentName,
|
||||
ComponentCategory.CATEGORY_4_DI.getName());
|
||||
Node logRowNode = new Node(logRowComponent, process);
|
||||
|
||||
// connectorName:REJECT
|
||||
IConnection connection = new Connection(salesforceOutputNode, logRowNode, EConnectionType.FLOW_MAIN, "REJECT", "reject",
|
||||
"row1", true);
|
||||
|
||||
mockMetadataColumns = mockMetadataColumns(
|
||||
new String[] { "errorCode", "errorFields", "errorMessage" });
|
||||
Mockito.when(mockRepoMetadata.getListColumns()).thenReturn(mockMetadataColumns);
|
||||
|
||||
ExternalNodeChangeCommand mockCmd = Mockito.mock(ExternalNodeChangeCommand.class);
|
||||
Mockito.when(mockCmd.needChangeSchemaType(connection, mockRepoMetadata)).thenCallRealMethod();
|
||||
|
||||
boolean needChange = mockCmd.needChangeSchemaType(connection, mockRepoMetadata);
|
||||
Mockito.verify(mockRepoMetadata, Mockito.times(1)).sameMetadataAs(Mockito.anyList(),
|
||||
Mockito.eq(IMetadataColumn.OPTIONS_IGNORE_USED));
|
||||
|
||||
// lineStyle:EConnectionType.REJECT
|
||||
connection = new Connection(salesforceOutputNode, logRowNode, EConnectionType.REJECT, "REJECT", "reject", "row1", true);
|
||||
Mockito.when(mockCmd.needChangeSchemaType(connection, mockRepoMetadata)).thenCallRealMethod();
|
||||
mockCmd.needChangeSchemaType(connection, mockRepoMetadata);
|
||||
Mockito.verify(mockRepoMetadata, Mockito.times(2)).sameMetadataAs(Mockito.anyList(),
|
||||
Mockito.eq(IMetadataColumn.OPTIONS_IGNORE_USED));
|
||||
|
||||
// lineStyle != EConnectionType.REJECT AND connectorName != REJECT
|
||||
connection = new Connection(salesforceOutputNode, logRowNode, EConnectionType.FLOW_MAIN, "MAIN", "main", "row1", true);
|
||||
Mockito.when(mockCmd.needChangeSchemaType(connection, mockRepoMetadata)).thenCallRealMethod();
|
||||
mockCmd.needChangeSchemaType(connection, mockRepoMetadata);
|
||||
Mockito.verify(mockRepoMetadata, Mockito.times(1)).sameMetadataAs(Mockito.eq(connection.getMetadataTable()),
|
||||
Mockito.eq(IMetadataColumn.OPTIONS_IGNORE_USED));
|
||||
|
||||
}
|
||||
|
||||
private List<IMetadataColumn> mockMetadataColumns(String[] labels) {
|
||||
List<IMetadataColumn> columns = new ArrayList<IMetadataColumn>();
|
||||
if (labels != null) {
|
||||
for (String label : labels) {
|
||||
IMetadataColumn mockerrorMessageColumn = Mockito.mock(IMetadataColumn.class);
|
||||
Mockito.when(mockerrorMessageColumn.getLabel()).thenReturn(label);
|
||||
columns.add(mockerrorMessageColumn);
|
||||
}
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
private static Property createProperty() {
|
||||
Property property = PropertiesFactory.eINSTANCE.createProperty();
|
||||
property.setAuthor(((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
|
||||
property.setVersion(VersionUtils.DEFAULT_VERSION);
|
||||
return property;
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,12 @@ import static org.mockito.Mockito.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
import org.talend.core.model.utils.AbstractDragAndDropServiceHandler;
|
||||
import org.talend.repository.generic.model.genericMetadata.GenericConnection;
|
||||
|
||||
@@ -31,8 +33,16 @@ import org.talend.repository.generic.model.genericMetadata.GenericConnection;
|
||||
*/
|
||||
public class GenericDragAndDropHandlerTest {
|
||||
|
||||
private Connection conn = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
conn = ConnectionFactory.eINSTANCE.createConnection();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
conn = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -60,4 +70,42 @@ public class GenericDragAndDropHandlerTest {
|
||||
// isGenericRepositoryValue = genericDragAndDropHandler.isGenericRepositoryValue(connection, "QueryMode");//$NON-NLS-1$
|
||||
// assertEquals(true, isGenericRepositoryValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPassword1() {
|
||||
String pwd = GenericDragAndDropHandler.getPassword(conn, "TestPassword");
|
||||
assertEquals("\"TestPassword\"", pwd); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPassword2() {
|
||||
String pwd = GenericDragAndDropHandler.getPassword(conn, "\"TestPassword\"");
|
||||
assertEquals("\"\\\"TestPassword\\\"\"", pwd); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPassword3() {
|
||||
String pwd = GenericDragAndDropHandler.getPassword(conn, "\"\"TestPassword\"\"");
|
||||
assertEquals("\"\\\"\\\"TestPassword\\\"\\\"\"", pwd); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPassword4() {
|
||||
String pwd = GenericDragAndDropHandler.getPassword(conn, "\"TestPassword");
|
||||
assertEquals("\"\\\"TestPassword\"", pwd); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPassword5() {
|
||||
String pwd = GenericDragAndDropHandler.getPassword(conn, "TestPassword\"");
|
||||
assertEquals("\"TestPassword\\\"\"", pwd); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPassword6() {
|
||||
conn.setContextMode(true);
|
||||
String pwd = GenericDragAndDropHandler.getPassword(conn, "context.pwd");
|
||||
conn.setContextMode(false);
|
||||
assertEquals("context.pwd", pwd); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user