Compare commits

..

24 Commits

Author SHA1 Message Date
glzhou
e5b6610abb TPS-1914 [5.5.1] tMDMBulkload can't update the record after install the patch(TMDM-10810)
- update bulkloadclient.jar
2017-04-25 12:05:33 +08:00
zfkang-talend
9d4155314f TMDM-9123 : tMDMBulkload component usage causes high volume of select sqls to mdm db (add "insertOnly" parameter to control server side SELECT operation) (#1184) 2017-04-24 22:55:50 -05:00
Pingwen Lin
d03f803d06 TPS-1462 [5.5.1]tMDMInput with one filter return different records size by different batch size(TMDM-9703) (#571)
TMDM-9703 tMDMInput with one filter return different records size by different batch size (#537)
2016-08-09 14:03:21 +08:00
wchen-talend
c92187aac1 TPS-1175:[5.5.1] Routines don't saves sometime in 5.4.2 Version
(TDI-32401)
2015-12-04 19:04:03 +08:00
pbabin
b54878022c TMDM-8949: Fix Job compilation when multiple tMDMBulkload components are involved in
(cherry picked from commit 4d71f78286)
2015-11-25 18:03:56 +01:00
sbliu
e15fae7537 TMDM-8949: update the bulkloadclient.jar for components. 2015-10-12 16:22:50 +08:00
sbliu
3f0be852c5 Remove unnecessary categories and file 2015-10-10 12:44:23 +08:00
sbliu
c6aa41b4b1 Merge pull request #142 from bguillon-td/master(because the category path diff from patch 5.5.1 to other branch like maintanence/5.5, re-commit commit this file). 2015-10-09 17:41:11 +08:00
sbliu
00f7756d2a Merge pull request #142 from bguillon-td/master
TMDM-8949 add a finally part to tMDMBulkLoad, to clean InputStreamMerger
2015-10-09 16:38:40 +08:00
wchen-talend
15942688cf TPS-986:[5.5.1]Repository Manager - Rule Execution failed for
joblets(TUP-2548)
2015-06-29 14:58:49 +08:00
CHEN Bin
1960c9fcec TPS-952: [5.5.1]Duplicate variable names when enabling parallel
execution on iterations within the same subjob(TDI-30996)
2015-06-10 17:49:04 +08:00
cmeng-talend
82e2af536b TPS-931 fix bug: [5.5.1] tRunJob component does not always show context
parameters (TDI-31474)
https://jira.talendforge.org/browse/TPS-931
2015-05-20 09:56:53 +08:00
sizhaoliu
ec60f556f5 Merge pull request #75 from qiongli/patch/5.5.1
TDQ-10039 make copy tMatchGroup work well.
2015-03-12 14:27:44 +08:00
qiongli
96aafbd48f TDQ-10039 make copy tMatchGroup work well. 2015-03-12 14:16:49 +08:00
Sizhao Liu
85a1808676 add .gitignore config 2015-03-12 13:59:37 +08:00
wchen-talend
985409e0d1 TPS-837:[5.5.1] Patch requested for TDI-31799
java.lang.NullPointerException when opening an joblet imported from
5.2.2 to 5.5.1 or 5.6.1
2015-02-10 14:09:08 +08:00
cmeng-talend
30b5fe0da7 TDI-29234 fix bug: #LINK@NODE doesn't work well as the condition when
TABLE IF in the schema
https://jira.talendforge.org/browse/TDI-29234
2015-01-16 13:08:25 +08:00
hwang
e022cf20f6 TDI-31336:Broken trigger link ‘OnComponentOk’ to joblet 2015-01-04 16:04:29 +08:00
cmeng-talend
a014635905 TDI-31531 fix bug: Bug with txmlmap used in a joblet
https://jira.talendforge.org/browse/TDI-31531
2014-12-26 18:08:50 +08:00
hcyi
c3bd080912 TPS-765:[5.5.1]Shared components not in sync with SVN(TDI-31099) 2014-12-18 18:49:36 +08:00
hcyi
3fa50a4f21 TPS-754:[5.5.1] HL7 - Optional elements are not parsed in the wizard
(TDI-29999)
2014-11-10 18:26:21 +08:00
ycbai
8bfdf93db1 Fix classpath problems. 2014-11-04 17:35:15 +08:00
hwang
fa2d16e5f9 TPS-740:[5.5.1]context value of db password in stats&logs become invalid
after migrate from v5.3.1 to v5.5.1(TDI-30853)
2014-10-27 14:47:11 +08:00
cmeng-talend
97d5f1a66b TPS-725 : [5.5.1] Unable to retrieve salesforce modules from Salesforce
metadata connection(TDI-30366)
https://jira.talendforge.org/browse/TPS-725
2014-10-08 18:48:37 +08:00
19915 changed files with 13994 additions and 19078 deletions

11
.gitignore vendored
View File

@@ -1,5 +1,6 @@
*.class
bin/
target/
class/
classes/
/*/target
/*/bin
/*/class
/*/classes
/*/.settings
/**/dev_con

View File

@@ -1,57 +0,0 @@
# Talend Open Studio for Data Integration
http://www.talend.com
![alt text](http://www.talend.com/sites/default/files/logo-talend.jpg "Talend")
> Contents
This repository contains the source files for Talend Open Studio for Data Integration. These files must be used together with the common code contained in [tcommon-studio-se](https://github.com/Talend/tcommon-studio-se).
## Repository Structure
All Talend Studio repositories follow the same file structure:
```
|_ main Main Eclipse plugins and features
|_ features
|_ plugins
|_ test Eclipse plugins and features for unit tests.
|_ features
|_ plugins
|_ i18n Internationalization plugins and features.
|_ features
|_ plugins
```
## Download
You can download this product from the [Talend website](http://www.talend.com/download/data-integration).
## Usage and Documentation
Documentation is available on [Talend Help Center](http://help.talend.com/).
## Support
You can ask for help on our [Forum](http://www.talend.com/services/global-technical-support).
## Contributing
We welcome contributions of all kinds from anyone.
Using the bug tracker [Talend bugtracker](http://jira.talendforge.org/) is the best channel for bug reports, feature requests and submitting pull requests.
Feel free to share your Talend components on [Talend Exchange](http://www.talendforge.org/exchange).
## License
Copyright (c) 2006-2014 Talend
Licensed under the LPGLv3 License

View File

@@ -1,214 +0,0 @@
// ============================================================================
//
// 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.salesforceBulk;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.SocketAddress;
import com.sforce.async.BulkConnection;
import com.sforce.soap.partner.PartnerConnection;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;
/**
* created by bchen on Jul 11, 2014 Detailled comment
*
*/
public class SforceBasicBulkConnection extends SforceBulkConnection {
private final String login_endpoint;
private final String username;
private final String password;
private final String apiVersion;
private boolean needCompression;
private boolean needTraceMessage;
private boolean useProxy;
private String proxyHost;
private int proxyPort;
private String proxyUsername;
private String proxyPassword;
private SforceBasicBulkConnection() throws Exception {
throw new Exception("should use builder to init"); //$NON-NLS-1$
}
private SforceBasicBulkConnection(Builder builder) throws Exception {
this.login_endpoint = builder.login_endpoint;
this.username = builder.username;
this.password = builder.password;
this.apiVersion = builder.apiVersion;
this.needCompression = builder.needCompression;
this.needTraceMessage = builder.needTraceMessage;
init();
}
@Override
protected void renewSession() throws ConnectionException {
ConnectorConfig partnerConfig = new ConnectorConfig();
partnerConfig.setAuthEndpoint(login_endpoint);
partnerConfig.setUsername(username);
partnerConfig.setPassword(password);
setProxyToConnection(partnerConfig);
// Creating the connection automatically handles login and stores
// the session in partnerConfig
new PartnerConnection(partnerConfig);
// The endpoint for the Bulk API service is the same as for the normal
// SOAP uri until the /Soap/ part. From here it's '/async/versionNumber'
String soapEndpoint = partnerConfig.getServiceEndpoint();
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + apiVersion;
// When PartnerConnection is instantiated, a login is implicitly
// executed and, if successful,
// a valid session is stored in the ConnectorConfig instance.
// Use this key to initialize a BulkConnection:
config.setSessionId(partnerConfig.getSessionId());
config.setRestEndpoint(restEndpoint);
}
private void init() throws Exception {
config = new ConnectorConfig();
setProxyToConnection(config);
// This should only be false when doing debugging.
config.setCompression(needCompression);
// Set this to true to see HTTP requests and responses on stdout
config.setTraceMessage(needTraceMessage);
renewSession();
connection = new BulkConnection(config);
}
private void setProxyToConnection(ConnectorConfig conn) {
Proxy socketProxy = null;
if (!useProxy) {
proxyHost = System.getProperty("https.proxyHost");
if (proxyHost != null && System.getProperty("https.proxyPort") != null) {
proxyPort = Integer.parseInt(System.getProperty("https.proxyPort"));
proxyUsername = System.getProperty("https.proxyUser");
proxyPassword = System.getProperty("https.proxyPassword");
useProxy = true;
} else {
proxyHost = System.getProperty("http.proxyHost");
if (proxyHost != null && System.getProperty("http.proxyPort") != null) {
proxyPort = Integer.parseInt(System.getProperty("http.proxyPort"));
proxyUsername = System.getProperty("http.proxyUser");
proxyPassword = System.getProperty("http.proxyPassword");
useProxy = true;
} else {
proxyHost = System.getProperty("socksProxyHost");
if (proxyHost != null && System.getProperty("socksProxyPort") != null) {
proxyPort = Integer.parseInt(System.getProperty("socksProxyPort"));
proxyUsername = System.getProperty("java.net.socks.username");
proxyPassword = System.getProperty("java.net.socks.password");
useProxy = true;
SocketAddress addr = new InetSocketAddress(proxyHost, proxyPort);
socketProxy = new Proxy(Proxy.Type.SOCKS, addr);
}
}
}
}
if (useProxy) {
if (socketProxy != null) {
conn.setProxy(socketProxy);
} else {
conn.setProxy(proxyHost, proxyPort);
}
if (proxyUsername != null && !"".equals(proxyUsername)) {
conn.setProxyUsername(proxyUsername);
if (proxyPassword != null && !"".equals(proxyPassword)) {
conn.setProxyPassword(proxyPassword);
Authenticator.setDefault(new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
if (getRequestorType() == Authenticator.RequestorType.PROXY) {
return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray());
} else {
return super.getPasswordAuthentication();
}
}
});
}
}
}
}
public static class Builder {
private final String login_endpoint;
private final String username;
private final String password;
private final String apiVersion;
private boolean needCompression = true;
private boolean needTraceMessage = false;
private boolean useProxy = false;
private String proxyHost;
private int proxyPort;
private String proxyUsername;
private String proxyPassword;
public Builder(String login_endpoint, String username, String password, String apiVersion) {
this.login_endpoint = login_endpoint;
this.username = username;
this.password = password;
this.apiVersion = apiVersion;
}
public Builder needCompression(boolean needCompression) {
this.needCompression = needCompression;
return this;
}
public Builder needTraceMessage(boolean needTraceMessage) {
this.needTraceMessage = needTraceMessage;
return this;
}
public Builder setProxy(boolean useProxy, String host, int port, String username, String password) {
this.proxyHost = host;
this.proxyPort = port;
this.proxyUsername = username;
this.proxyPassword = password;
this.useProxy = useProxy;
return this;
}
public SforceBasicBulkConnection build() throws Exception {
return new SforceBasicBulkConnection(this);
}
}
}

View File

@@ -1,166 +0,0 @@
// ============================================================================
//
// 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.salesforceBulk;
import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import com.sforce.async.AsyncApiException;
import com.sforce.async.AsyncExceptionCode;
import com.sforce.async.BatchInfo;
import com.sforce.async.BatchInfoList;
import com.sforce.async.BulkConnection;
import com.sforce.async.JobInfo;
import com.sforce.async.QueryResultList;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;
/**
* created by bchen on Jul 11, 2014 Detailled comment
*
*/
public abstract class SforceBulkConnection {
protected BulkConnection connection;
protected ConnectorConfig config;
protected void renewSession() throws ConnectionException {
throw new ConnectionException("Session expire, need to renew session");
}
protected JobInfo createJob(JobInfo job) throws AsyncApiException, ConnectionException {
try {
return connection.createJob(job);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return createJob(job);
}
throw sfException;
}
}
protected BatchInfo createBatchFromStream(JobInfo job, FileInputStream inputStream) throws AsyncApiException,
ConnectionException {
try {
return connection.createBatchFromStream(job, inputStream);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return createBatchFromStream(job, inputStream);
}
throw sfException;
}
}
protected JobInfo updateJob(JobInfo job) throws AsyncApiException, ConnectionException {
try {
return connection.updateJob(job);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return updateJob(job);
}
throw sfException;
}
}
protected BatchInfoList getBatchInfoList(String jobID) throws AsyncApiException, ConnectionException {
try {
return connection.getBatchInfoList(jobID);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return getBatchInfoList(jobID);
}
throw sfException;
}
}
protected InputStream getBatchResultStream(String jobID, String batchID) throws AsyncApiException, ConnectionException {
try {
return connection.getBatchResultStream(jobID, batchID);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return getBatchResultStream(jobID, batchID);
}
throw sfException;
}
}
protected JobInfo getJobStatus(String jobID) throws AsyncApiException, ConnectionException {
try {
return connection.getJobStatus(jobID);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return getJobStatus(jobID);
}
throw sfException;
}
}
protected BatchInfo createBatchFromStream(JobInfo job, ByteArrayInputStream byteArrayInputStream) throws AsyncApiException,
ConnectionException {
try {
return connection.createBatchFromStream(job, byteArrayInputStream);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return createBatchFromStream(job, byteArrayInputStream);
}
throw sfException;
}
}
protected BatchInfo getBatchInfo(String jobID, String batchID) throws AsyncApiException, ConnectionException {
try {
return connection.getBatchInfo(jobID, batchID);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return getBatchInfo(jobID, batchID);
}
throw sfException;
}
}
protected QueryResultList getQueryResultList(String jobID, String batchID) throws AsyncApiException, ConnectionException {
try {
return connection.getQueryResultList(jobID, batchID);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return getQueryResultList(jobID, batchID);
}
throw sfException;
}
}
protected InputStream getQueryResultStream(String jobID, String batchID, String resultID) throws AsyncApiException,
ConnectionException {
try {
return connection.getQueryResultStream(jobID, batchID, resultID);
} catch (AsyncApiException sfException) {
if (AsyncExceptionCode.InvalidSessionId.equals(sfException.getExceptionCode())) {
renewSession();
return getQueryResultStream(jobID, batchID, resultID);
}
throw sfException;
}
}
}

View File

@@ -1,184 +0,0 @@
// ============================================================================
//
// 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.salesforceBulk;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
import org.talend.salesforce.oauth.OAuthClient;
import org.talend.salesforce.oauth.Token;
import com.sforce.async.BulkConnection;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;
/**
* created by bchen on Jul 11, 2014 Detailled comment
*
*/
public class SforceOAuthBulkConnection extends SforceBulkConnection {
private static final String REFRESHTOKEN_KEY = "refreshtoken";
private final String login_endpoint;
private final String oauth_clientID;
private final String oauth_clientSecret;
private String tokenFilePath;
private final String apiVersion;
private final String callbackHost;
private final int callbackPort;
private boolean needCompression;
private boolean needTraceMessage;
private SforceOAuthBulkConnection() throws Exception {
throw new Exception("should use builder to init"); //$NON-NLS-1$
}
private SforceOAuthBulkConnection(Builder builder) throws Exception {
this.login_endpoint = builder.login_endpoint;
this.oauth_clientID = builder.oauth_clientID;
this.oauth_clientSecret = builder.oauth_clientSecret;
this.apiVersion = builder.apiVersion;
this.tokenFilePath = builder.tokenFilePath;
this.callbackHost = builder.callbackHost;
this.callbackPort = builder.callbackPort;
this.needCompression = builder.needCompression;
this.needTraceMessage = builder.needTraceMessage;
init();
}
private Token loginWithOAuth() throws Exception {
String session_id = null;
OAuthClient oauthClient = new OAuthClient();
oauthClient.setBaseOAuthURL(login_endpoint);
oauthClient.setClientID(oauth_clientID);
oauthClient.setClientSecret(oauth_clientSecret);
Token token = null;
String refreshToken = null;
// 1. if tokenFile exist, try refresh token
if (tokenFilePath != null) {
Properties prop = new Properties();
FileInputStream inputStream = new FileInputStream(tokenFilePath);
prop.load(inputStream);
inputStream.close();
String storedRefreshToken = (String) prop.get(REFRESHTOKEN_KEY);
if (storedRefreshToken != null) {
token = oauthClient.refreshToken(storedRefreshToken);
session_id = token.getAccess_token();
refreshToken = token.getRefresh_token();
}
}
// 2. try to auth if session_id can't be retrieved
if (session_id == null) {
oauthClient.setCallbackHost(callbackHost);
oauthClient.setCallbackPort(callbackPort);
token = oauthClient.getToken();
refreshToken = token.getRefresh_token();
}
// 3.if refresh token & tokenFile exist, store
if (refreshToken != null && tokenFilePath != null) {
Properties prop = new Properties();
prop.setProperty(REFRESHTOKEN_KEY, refreshToken);
FileOutputStream outputStream = new FileOutputStream(tokenFilePath);
prop.store(outputStream, null);
if (outputStream != null) {
outputStream.close();
}
}
return token;
}
private void init() throws Exception {
config = new ConnectorConfig();
// This should only be false when doing debugging.
config.setCompression(needCompression);
// Set this to true to see HTTP requests and responses on stdout
config.setTraceMessage(needTraceMessage);
renewSession();
connection = new BulkConnection(config);
}
@Override
protected void renewSession() throws ConnectionException {
Token token;
try {
token = loginWithOAuth();
} catch (Exception e) {
throw new ConnectionException(e.getMessage());
}
String session_id = token.getAccess_token();
String endpoint = OAuthClient.getBulkEndpoint(token, apiVersion);
config.setSessionId(session_id);
config.setRestEndpoint(endpoint);
}
public static class Builder {
private final String login_endpoint;
private final String oauth_clientID;
private final String oauth_clientSecret;
private final String apiVersion;
private String tokenFilePath = null;
private final String callbackHost;
private final int callbackPort;
private boolean needCompression = true;
private boolean needTraceMessage = false;
public Builder(String login_endpoint, String oauth_clientID, String oauth_clientSecret, String apiVersion,
String callbackHost, int callbackPort) {
this.login_endpoint = login_endpoint;
this.oauth_clientID = oauth_clientID;
this.oauth_clientSecret = oauth_clientSecret;
this.apiVersion = apiVersion;
this.callbackHost = callbackHost;
this.callbackPort = callbackPort;
}
public Builder setTokenFilePath(String tokenFilePath) {
this.tokenFilePath = tokenFilePath;
return this;
}
public Builder needCompression(boolean needCompression) {
this.needCompression = needCompression;
return this;
}
public Builder needTraceMessage(boolean needTraceMessage) {
this.needTraceMessage = needTraceMessage;
return this;
}
public SforceOAuthBulkConnection build() throws Exception {
return new SforceOAuthBulkConnection(this);
}
}
}

View File

@@ -1,124 +0,0 @@
// ============================================================================
//
// 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.salesforce;
import com.salesforce.soap.partner.CallOptions;
import com.salesforce.soap.partner.Login;
import com.salesforce.soap.partner.LoginResult;
import com.salesforce.soap.partner.SessionHeader;
import com.salesforce.soap.partner.SforceServiceStub;
/**
* created by bchen on Jul 9, 2014 Detailled comment
*
*/
public class SforceBasicConnection extends SforceConnection {
private final String login_endpoint;
private final Login userInfo;
private boolean needCompression;
private int timeout;
private String clientID;
private SforceBasicConnection() throws Exception {
throw new Exception("should use builder to init"); //$NON-NLS-1$
}
private SforceBasicConnection(Builder builder) throws Exception {
this.login_endpoint = builder.login_endpoint;
this.userInfo = builder.userInfo;
this.needCompression = builder.needCompression;
this.timeout = builder.timeout;
this.clientID = builder.clientID;
check();
init();
}
private void check() throws Exception {
if (login_endpoint == null || login_endpoint.trim().length() == 0 || userInfo.getUsername() == null
|| userInfo.getUsername().trim().length() == 0 || userInfo.getPassword() == null
|| userInfo.getPassword().trim().length() == 0) {
throw new RuntimeException("Login failed! Please check the username,password and endpoint");
}
}
private void init() throws Exception {
if (clientID != null) {
co = new CallOptions();
co.setClient(clientID);
}
stub = new SforceServiceStub();
SforceManagementUtil.needCompression(stub, needCompression);
SforceManagementUtil.setTimeout(stub, timeout);
SforceManagementUtil.setHttpProxy(stub);
sh = new SessionHeader();
renewSession();
}
@Override
protected void renewSession() throws Exception {
SforceManagementUtil.setEndpoint(stub, login_endpoint);// login_endpoint for login operation
LoginResult loginResult = stub.login(userInfo, null, co).getResult();
sh.setSessionId(loginResult.getSessionId());
SforceManagementUtil.setEndpoint(stub, loginResult.getServerUrl());// server url for CRUD operation
}
public static class Builder {
private final String login_endpoint;
private final Login userInfo;
private boolean needCompression = false;
private int timeout = 60000;
private String clientID = null;
public Builder(String login_endpoint, String username, String password) {
this.login_endpoint = login_endpoint;
this.userInfo = new Login();
this.userInfo.setUsername(username);
this.userInfo.setPassword(password);
}
public Builder needCompression(boolean needCompression) {
this.needCompression = needCompression;
return this;
}
public Builder setTimeout(int timeout) {
this.timeout = timeout;
return this;
}
public Builder setTimeout(String timeout) {
this.timeout = Integer.valueOf(timeout);
return this;
}
public Builder setClientID(String clientID) {
this.clientID = clientID;
return this;
}
public SforceBasicConnection build() throws Exception {
return new SforceBasicConnection(this);
}
}
}

View File

@@ -1,248 +0,0 @@
// ============================================================================
//
// 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.salesforce;
import com.salesforce.soap.partner.CallOptions;
import com.salesforce.soap.partner.Create;
import com.salesforce.soap.partner.CreateResponse;
import com.salesforce.soap.partner.Delete;
import com.salesforce.soap.partner.DeleteResponse;
import com.salesforce.soap.partner.DescribeGlobal;
import com.salesforce.soap.partner.DescribeGlobalResponse;
import com.salesforce.soap.partner.DescribeSObject;
import com.salesforce.soap.partner.DescribeSObjectResponse;
import com.salesforce.soap.partner.DescribeSObjects;
import com.salesforce.soap.partner.DescribeSObjectsResponse;
import com.salesforce.soap.partner.GetDeleted;
import com.salesforce.soap.partner.GetDeletedResponse;
import com.salesforce.soap.partner.GetServerTimestamp;
import com.salesforce.soap.partner.GetServerTimestampResponse;
import com.salesforce.soap.partner.GetUpdated;
import com.salesforce.soap.partner.GetUpdatedResponse;
import com.salesforce.soap.partner.Query;
import com.salesforce.soap.partner.QueryAll;
import com.salesforce.soap.partner.QueryAllResponse;
import com.salesforce.soap.partner.QueryMore;
import com.salesforce.soap.partner.QueryMoreResponse;
import com.salesforce.soap.partner.QueryOptions;
import com.salesforce.soap.partner.QueryResponse;
import com.salesforce.soap.partner.Retrieve;
import com.salesforce.soap.partner.RetrieveResponse;
import com.salesforce.soap.partner.SessionHeader;
import com.salesforce.soap.partner.SforceServiceStub;
import com.salesforce.soap.partner.Update;
import com.salesforce.soap.partner.UpdateResponse;
import com.salesforce.soap.partner.Upsert;
import com.salesforce.soap.partner.UpsertResponse;
import com.salesforce.soap.partner.fault.ExceptionCode;
/**
* created by bchen on Jul 9, 2014 Detailled comment
*
*/
public abstract class SforceConnection {
protected SforceServiceStub stub;
protected SessionHeader sh;
protected CallOptions co;
protected void renewSession() throws Exception {
throw new Exception("Session expire, need to renew session");
}
protected DeleteResponse delete(Delete delete) throws Exception {
try {
return stub.delete(delete, sh, co, null, null, null, null, null, null, null, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return delete(delete);
}
throw sfException;
}
}
protected CreateResponse create(Create create) throws Exception {
try {
return stub.create(create, sh, co, null, null, null, null, null, null, null, null, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return create(create);
}
throw sfException;
}
}
protected UpdateResponse update(Update update) throws Exception {
try {
return stub.update(update, sh, co, null, null, null, null, null, null, null, null, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return update(update);
}
throw sfException;
}
}
protected UpsertResponse upsert(Upsert upsert) throws Exception {
try {
return stub.upsert(upsert, sh, co, null, null, null, null, null, null, null, null, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return upsert(upsert);
}
throw sfException;
}
}
protected GetServerTimestampResponse getServerTimestamp(GetServerTimestamp getServerTimestamp) throws Exception {
try {
return stub.getServerTimestamp(getServerTimestamp, sh, co);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return getServerTimestamp(getServerTimestamp);
}
throw sfException;
}
}
protected GetUpdatedResponse getUpdated(GetUpdated getUpdated) throws Exception {
try {
return stub.getUpdated(getUpdated, sh, co);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return getUpdated(getUpdated);
}
throw sfException;
}
}
protected RetrieveResponse retrieve(Retrieve retrieve) throws Exception {
try {
return stub.retrieve(retrieve, sh, co, null, null, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return retrieve(retrieve);
}
throw sfException;
}
}
protected GetDeletedResponse getDeleted(GetDeleted getDeleted) throws Exception {
try {
return stub.getDeleted(getDeleted, sh, co);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return getDeleted(getDeleted);
}
throw sfException;
}
}
protected QueryAllResponse queryAll(QueryAll queryAll, QueryOptions queryOptions) throws Exception {
try {
return stub.queryAll(queryAll, sh, co, queryOptions);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return queryAll(queryAll, queryOptions);
}
throw sfException;
}
}
protected QueryMoreResponse queryMore(QueryMore queryMore, QueryOptions queryOptions) throws Exception {
try {
return stub.queryMore(queryMore, sh, co, queryOptions);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return queryMore(queryMore, queryOptions);
}
throw sfException;
}
}
protected QueryResponse query(Query query, QueryOptions queryOptions) throws Exception {
try {
return stub.query(query, sh, co, queryOptions, null, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return query(query, queryOptions);
}
throw sfException;
}
}
protected DescribeSObjectResponse describeSObject(DescribeSObject describeSObject) throws Exception {
try {
return stub.describeSObject(describeSObject, sh, co, null, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return describeSObject(describeSObject);
}
throw sfException;
}
}
protected DescribeSObjectsResponse describeSObjects(DescribeSObjects describeSObjects) throws Exception {
try {
return stub.describeSObjects(describeSObjects, sh, co, null, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return describeSObjects(describeSObjects);
}
throw sfException;
}
}
protected DescribeGlobalResponse describeGlobal(DescribeGlobal describeGlobal) throws Exception {
try {
return stub.describeGlobal(describeGlobal, sh, co, null);
} catch (com.salesforce.soap.partner.UnexpectedErrorFault sfException) {
if (ExceptionCode.INVALID_SESSION_ID.equals(sfException.getFaultMessage().getUnexpectedErrorFault()
.getExceptionCode())) {
renewSession();
return describeGlobal(describeGlobal);
}
throw sfException;
}
}
}

View File

@@ -1,117 +0,0 @@
// ============================================================================
//
// 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.salesforce;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axis2.client.Options;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.HttpTransportProperties.ProxyProperties;
import com.salesforce.soap.partner.SforceServiceStub;
/**
* created by bchen on Jul 8, 2014 Detailled comment
*
*/
public class SforceManagementUtil {
public static OMElement newOMElement(String name, String value) throws Exception {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMElement ome = fac.createOMElement(name, null);
ome.addChild(fac.createOMText(ome, value));
return ome;
}
public static void setEndpoint(SforceServiceStub stub, String endpoint) {
stub._getServiceClient().getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(endpoint));
}
public static void needCompression(SforceServiceStub stub, boolean needCompression) {
if (!needCompression) {
return;
}
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
options.setProperty(HTTPConstants.MC_GZIP_REQUEST, Boolean.TRUE);
}
public static void setTimeout(SforceServiceStub stub, int timeout) {
Options options = stub._getServiceClient().getOptions();
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, timeout);
options.setProperty(HTTPConstants.SO_TIMEOUT, timeout);
}
public static void setHttpProxy(SforceServiceStub stub) {
Options options = stub._getServiceClient().getOptions();
String httpsHost = System.getProperty("https.proxyHost");
String httpsPort = System.getProperty("https.proxyPort");
String httpsUser = System.getProperty("https.proxyUser");
String httpsPwd = System.getProperty("https.proxyPassword");
if (httpsHost != null) {
ProxyProperties proxyProperties = new ProxyProperties();
proxyProperties.setProxyName(httpsHost);
if (httpsPort != null) {
proxyProperties.setProxyPort(Integer.parseInt(httpsPort));
}
if (httpsUser != null && !"".equals(httpsUser)) {
proxyProperties.setUserName(httpsUser);
}
if (httpsPwd != null && !"".equals(httpsPwd)) {
proxyProperties.setPassWord(httpsPwd);
}
options.setProperty(HTTPConstants.PROXY, proxyProperties);
} else {
String host = System.getProperty("http.proxyHost");
String port = System.getProperty("http.proxyPort");
String user = System.getProperty("http.proxyUser");
String pwd = System.getProperty("http.proxyPassword");
if (host != null) {
ProxyProperties proxyProperties = new ProxyProperties();
proxyProperties.setProxyName(host);
if (port != null) {
proxyProperties.setProxyPort(Integer.parseInt(port));
}
if (user != null && !"".equals(user)) {
proxyProperties.setUserName(user);
}
if (pwd != null && !"".equals(pwd)) {
proxyProperties.setPassWord(pwd);
}
options.setProperty(HTTPConstants.PROXY, proxyProperties);
} else {
String socksHost = System.getProperty("socksProxyHost");
String socksPort = System.getProperty("socksProxyPort");
String socksUser = System.getProperty("java.net.socks.username");
String socksPwd = System.getProperty("java.net.socks.password");
if (socksHost != null) {
ProxyProperties proxyProperties = new ProxyProperties();
proxyProperties.setProxyName(socksHost);
if (socksPort != null) {
proxyProperties.setProxyPort(Integer.parseInt(socksPort));
}
if (socksUser != null && !"".equals(socksUser)) {
proxyProperties.setUserName(socksUser);
}
if (socksPwd != null && !"".equals(socksPwd)) {
proxyProperties.setPassWord(socksPwd);
}
options.setProperty(HTTPConstants.PROXY, proxyProperties);
}
}
}
// options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION,
// HTTPConstants.HEADER_PROTOCOL_10);
}
}

View File

@@ -1,198 +0,0 @@
// ============================================================================
//
// 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.salesforce;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
import org.talend.salesforce.oauth.OAuthClient;
import org.talend.salesforce.oauth.Token;
import com.salesforce.soap.partner.CallOptions;
import com.salesforce.soap.partner.SessionHeader;
import com.salesforce.soap.partner.SforceServiceStub;
/**
* created by bchen on Jul 10, 2014 Detailled comment
*
*/
public class SforceOAuthConnection extends SforceConnection {
private static final String REFRESHTOKEN_KEY = "refreshtoken";
private final String login_endpoint;
private final String oauth_clientID;
private final String oauth_clientSecret;
private String tokenFilePath;
private final String apiVersion;
private final String callbackHost;
private final int callbackPort;
private boolean needCompression;
private int timeout;
private String clientID;
private SforceOAuthConnection() throws Exception {
throw new Exception("should use builder to init"); //$NON-NLS-1$
}
private SforceOAuthConnection(Builder builder) throws Exception {
this.login_endpoint = builder.login_endpoint;
this.oauth_clientID = builder.oauth_clientID;
this.oauth_clientSecret = builder.oauth_clientSecret;
this.apiVersion = builder.apiVersion;
this.tokenFilePath = builder.tokenFilePath;
this.callbackHost = builder.callbackHost;
this.callbackPort = builder.callbackPort;
this.needCompression = builder.needCompression;
this.timeout = builder.timeout;
this.clientID = builder.clientID;
init();
}
private Token loginWithOAuth() throws Exception {
String session_id = null;
OAuthClient oauthClient = new OAuthClient();
oauthClient.setBaseOAuthURL(login_endpoint);
oauthClient.setClientID(oauth_clientID);
oauthClient.setClientSecret(oauth_clientSecret);
Token token = null;
String refreshToken = null;
// 1. if tokenFile exist, try refresh token
if (tokenFilePath != null) {
Properties prop = new Properties();
FileInputStream inputStream = new FileInputStream(tokenFilePath);
prop.load(inputStream);
inputStream.close();
String storedRefreshToken = (String) prop.get(REFRESHTOKEN_KEY);
if (storedRefreshToken != null) {
token = oauthClient.refreshToken(storedRefreshToken);
session_id = token.getAccess_token();
refreshToken = token.getRefresh_token();
}
}
// 2. try to auth if session_id can't be retrieved
if (session_id == null) {
oauthClient.setCallbackHost(callbackHost);
oauthClient.setCallbackPort(callbackPort);
token = oauthClient.getToken();
refreshToken = token.getRefresh_token();
}
// 3.if refresh token & tokenFile exist, store
if (refreshToken != null && tokenFilePath != null) {
Properties prop = new Properties();
prop.setProperty(REFRESHTOKEN_KEY, refreshToken);
FileOutputStream outputStream = new FileOutputStream(tokenFilePath);
prop.store(outputStream, null);
if (outputStream != null) {
outputStream.close();
}
}
return token;
}
private void init() throws Exception {
if (clientID != null) {
co = new CallOptions();
co.setClient(clientID);
}
stub = new SforceServiceStub();
SforceManagementUtil.needCompression(stub, needCompression);
SforceManagementUtil.setTimeout(stub, timeout);
// SforceManagementUtil.setHttpProxy(stub);//don't support proxy for OAuth
sh = new SessionHeader();
renewSession();
}
@Override
protected void renewSession() throws Exception {
Token token = loginWithOAuth();
String session_id = token.getAccess_token();
String endpoint = OAuthClient.getSOAPEndpoint(token, apiVersion);
SforceManagementUtil.setEndpoint(stub, endpoint);
sh.setSessionId(session_id);
}
public static class Builder {
private final String login_endpoint;
private final String oauth_clientID;
private final String oauth_clientSecret;
private final String apiVersion;
private String tokenFilePath = null;
private final String callbackHost;
private final int callbackPort;
private boolean needCompression = false;
private int timeout = 60000;
private String clientID = null;
public Builder(String login_endpoint, String oauth_clientID, String oauth_clientSecret, String apiVersion,
String callbackHost, int callbackPort) {
this.login_endpoint = login_endpoint;
this.oauth_clientID = oauth_clientID;
this.oauth_clientSecret = oauth_clientSecret;
this.apiVersion = apiVersion;
this.callbackHost = callbackHost;
this.callbackPort = callbackPort;
}
public Builder setTokenFilePath(String tokenFilePath) {
this.tokenFilePath = tokenFilePath;
return this;
}
public Builder needCompression(boolean needCompression) {
this.needCompression = needCompression;
return this;
}
public Builder setTimeout(int timeout) {
this.timeout = timeout;
return this;
}
public Builder setTimeout(String timeout) {
this.timeout = Integer.valueOf(timeout);
return this;
}
public Builder setClientID(String clientID) {
this.clientID = clientID;
return this;
}
public SforceOAuthConnection build() throws Exception {
return new SforceOAuthConnection(this);
}
}
}

View File

@@ -1,114 +0,0 @@
// ============================================================================
//
// 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.salesforce;
import com.salesforce.soap.partner.CallOptions;
import com.salesforce.soap.partner.SessionHeader;
import com.salesforce.soap.partner.SforceServiceStub;
/**
* created by bchen on Jul 9, 2014 Detailled comment
*
*/
public class SforceSessionConnection extends SforceConnection {
private final String endpoint;
private final String session_id;
private boolean needCompression;
private int timeout;
private String clientID;
private SforceSessionConnection() throws Exception {
throw new Exception("should use builder to init"); //$NON-NLS-1$
}
private SforceSessionConnection(Builder builder) throws Exception {
this.endpoint = builder.endpoint;
this.session_id = builder.session_id;
check();
init();
}
private void check() throws Exception {
if (endpoint == null || endpoint.trim().length() == 0 || session_id == null || session_id.trim().length() == 0) {
throw new RuntimeException("Login failed!");
}
}
private void init() throws Exception {
if (clientID != null) {
co = new CallOptions();
co.setClient(clientID);
}
stub = new SforceServiceStub();
SforceManagementUtil.needCompression(stub, needCompression);
SforceManagementUtil.setTimeout(stub, timeout);
// SforceManagementUtil.setHttpProxy(stub);//don't support proxy for OAuth
sh = new SessionHeader();
// renewSession();
SforceManagementUtil.setEndpoint(stub, endpoint);
sh.setSessionId(session_id);
}
@Override
protected void renewSession() throws Exception {
throw new Exception("Session expire, need to renew session");
}
public static class Builder {
private final String endpoint;
private final String session_id;
private boolean needCompression = false;
private int timeout = 60000;
private String clientID = null;
public Builder(String endpoint, String session_id) {
this.endpoint = endpoint;
this.session_id = session_id;
}
public Builder needCompression(boolean needCompression) {
this.needCompression = needCompression;
return this;
}
public Builder setTimeout(int timeout) {
this.timeout = timeout;
return this;
}
public Builder setTimeout(String timeout) {
this.timeout = Integer.valueOf(timeout);
return this;
}
public Builder setClientID(String clientID) {
this.clientID = clientID;
return this;
}
public SforceSessionConnection build() throws Exception {
return new SforceSessionConnection(this);
}
}
}

View File

@@ -1,56 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.talend</groupId>
<artifactId>talendMQConnectionUtil</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>talendMQConnectionUtil</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.10.0</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.mq</artifactId>
<version>x</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.mqjms</artifactId>
<version>x</version>
</dependency>
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.talend</groupId>
<artifactId>talendMQRFH2</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
</build>
</project>

View File

@@ -1,7 +0,0 @@
Note:
About the jar we can't find in http://mvnrepository.com/ .
we need add it to the local repository manually.
For example:
mvn install:install-file -Dfile=D:\workspace\talend_540\.Java\lib\talendMQRFH2.jar -DgroupId=org.talend -DartifactId=talendMQRFH2 -Dversion=1.0.0 -Dpackaging=jar
mvn install:install-file -Dfile=D:\workspace\talend_540\.Java\lib\com.ibm.mq.jar -DgroupId=com.ibm -DartifactId=com.ibm.mq -Dversion=x -Dpackaging=jar
mvn install:install-file -Dfile=D:\workspace\talend_540\.Java\lib\com.ibm.mqjms.jar -DgroupId=com.ibm -DartifactId=com.ibm.mqjms -Dversion=x -Dpackaging=jar

View File

@@ -1,128 +0,0 @@
// ============================================================================
//
// 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.mq;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.jms.JMSException;
import org.apache.activemq.ConnectionClosedException;
/**
* A buffer to keep all the MQ connections, make it reusable between the
* different jobs.
*/
public class SharedActiveMQConnection {
private static boolean DEBUG = false;
private static SharedActiveMQConnection instance = null;
private Map<String, javax.jms.Connection> sharedConnections = new HashMap<String, javax.jms.Connection>();
private SharedActiveMQConnection() {
}
private static synchronized SharedActiveMQConnection getInstance() {
if (instance == null) {
instance = new SharedActiveMQConnection();
}
return instance;
}
private synchronized javax.jms.Connection getConnection(String url,
String userName, String password, String mqConnectionName)
throws JMSException {
if (DEBUG) {
Set<String> keySet = sharedConnections.keySet();
System.out
.print("SharedMQConnection, current shared connections list is:"); //$NON-NLS-1$
for (String key : keySet) {
System.out.print(" " + key); //$NON-NLS-1$
}
System.out.println();
}
javax.jms.Connection connection = sharedConnections
.get(mqConnectionName);
if (connection == null) {
if (DEBUG) {
System.out
.println("SharedMQConnection, can't find the key:" + mqConnectionName + " " //$NON-NLS-1$ //$NON-NLS-2$
+ "so create a new one and share it."); //$NON-NLS-1$
}
org.apache.activemq.ActiveMQConnectionFactory factory = new org.apache.activemq.ActiveMQConnectionFactory(
url);
if (userName == null || ("").equals(userName)) {
connection = factory.createConnection();
} else {
connection = factory.createConnection(userName, password);
}
connection.start();
sharedConnections.put(mqConnectionName, connection);
} else {
try{
connection.start();
if (DEBUG) {
System.out
.println("SharedMQConnection, find the key: " + mqConnectionName + " " + "it is OK."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}catch(ConnectionClosedException e){
if (DEBUG) {
System.out.println("SharedMQConnection, find the key: " + mqConnectionName + " " //$NON-NLS-1$ //$NON-NLS-2$
+ "But it is closed. So create a new one and share it."); //$NON-NLS-1$
}
org.apache.activemq.ActiveMQConnectionFactory factory = new org.apache.activemq.ActiveMQConnectionFactory(
url);
if (userName == null || ("").equals(userName)) {
connection = factory.createConnection();
} else {
connection = factory.createConnection(userName, password);
}
connection.start();
sharedConnections.put(mqConnectionName, connection);
}
}
return connection;
}
/**
* If there don't exist the connection or it is closed, create and store it.
*
* @param url
* @param mqConnectionName
* @return
* @throws JMSException
*/
public static javax.jms.Connection getMQConnection(String url,
String userName, String password, String mqConnectionName)
throws JMSException {
SharedActiveMQConnection instanceLocal = getInstance();
javax.jms.Connection connection = instanceLocal.getConnection(url,
userName, password, mqConnectionName);
return connection;
}
/**
* Set the buffer as null, make it recyclable.
*/
public static void clear() {
instance = null;
}
public static void setDebugMode(boolean debug) {
DEBUG = debug;
}
}

View File

@@ -1,113 +0,0 @@
// ============================================================================
//
// 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.mq;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.ibm.mq.MQException;
/**
* A buffer to keep all the MQ connections, make it reusable between the
* different jobs.
*/
public class SharedWebSphereMQConnection {
private static boolean DEBUG = false;
private static SharedWebSphereMQConnection instance = null;
private Map<String, com.ibm.mq.MQQueueManager> sharedConnections = new HashMap<String, com.ibm.mq.MQQueueManager>();
private SharedWebSphereMQConnection() {
}
private static synchronized SharedWebSphereMQConnection getInstance() {
if (instance == null) {
instance = new SharedWebSphereMQConnection();
}
return instance;
}
private synchronized com.ibm.mq.MQQueueManager getConnection(
String queueManager,
java.util.Hashtable<String, Object> properties,
String mqConnectionName) throws MQException {
if (DEBUG) {
Set<String> keySet = sharedConnections.keySet();
System.out
.print("SharedMQConnection, current shared connections list is:"); //$NON-NLS-1$
for (String key : keySet) {
System.out.print(" " + key); //$NON-NLS-1$
}
System.out.println();
}
com.ibm.mq.MQQueueManager connection = sharedConnections
.get(mqConnectionName);
if (connection == null) {
if (DEBUG) {
System.out
.println("SharedMQConnection, can't find the key:" + mqConnectionName + " " //$NON-NLS-1$ //$NON-NLS-2$
+ "so create a new one and share it."); //$NON-NLS-1$
}
connection = new com.ibm.mq.MQQueueManager(queueManager, properties);
sharedConnections.put(mqConnectionName, connection);
} else if (!connection.isConnected()) {
if (DEBUG) {
System.out
.println("SharedMQConnection, find the key: " + mqConnectionName + " " //$NON-NLS-1$ //$NON-NLS-2$
+ "But it is closed. So create a new one and share it."); //$NON-NLS-1$
}
connection = new com.ibm.mq.MQQueueManager(queueManager, properties);
sharedConnections.put(mqConnectionName, connection);
} else {
if (DEBUG) {
System.out
.println("SharedMQConnection, find the key: " + mqConnectionName + " " + "it is OK."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
return connection;
}
/**
* If there don't exist the connection or it is closed, create and store it.
*
* @param queueManager
* @param properties
* @param mqConnectionName
* @return
* @throws MQException
*/
public static com.ibm.mq.MQQueueManager getMQConnection(
String queueManager,
java.util.Hashtable<String, Object> properties,
String mqConnectionName) throws MQException {
SharedWebSphereMQConnection instanceLocal = getInstance();
com.ibm.mq.MQQueueManager connection = instanceLocal.getConnection(
queueManager, properties, mqConnectionName);
return connection;
}
/**
* Set the buffer as null, make it recyclable.
*/
public static void clear() {
instance = null;
}
public static void setDebugMode(boolean debug) {
DEBUG = debug;
}
}

View File

@@ -1,22 +0,0 @@
package org.talend.mq;
import javax.jms.JMSException;
import junit.framework.TestCase;
import org.junit.Test;
public class TestSharedActiveMQConn extends TestCase {
@Test
public void testSameConnNAme() throws JMSException {
assertTrue(SharedActiveMQConnection.getMQConnection("tcp://localhost:61616", "", "", "conn")==SharedActiveMQConnection.getMQConnection("tcp://localhost:61616", "", "", "conn"));
}
@Test
public void testDiffConnNAme() throws JMSException {
assertFalse(SharedActiveMQConnection.getMQConnection("tcp://localhost:61616", "", "", "conn1")==SharedActiveMQConnection.getMQConnection("tcp://localhost:61616", "", "", "conn2"));
}
}

View File

@@ -1,33 +0,0 @@
package org.talend.mq;
import java.util.Hashtable;
import javax.jms.JMSException;
import junit.framework.TestCase;
import org.junit.Test;
import com.ibm.mq.MQException;
public class TestSharedWebShpereMQConn extends TestCase {
private static Hashtable<String,Object> properties = new java.util.Hashtable<String,Object>();
static{
properties.put("hostname", "localhost");
properties.put("port", Integer.valueOf("1414"));
properties.put("channel", "TALEND.CH");
properties.put("CCSID", new Integer(1208));
properties.put("transport", "MQSeries");
}
@Test
public void testSameConnNAme() throws JMSException, MQException {
assertTrue(SharedWebSphereMQConnection.getMQConnection("TALEND", properties, "conn")==SharedWebSphereMQConnection.getMQConnection("TALEND", properties, "conn"));
}
@Test
public void testDiffConnNAme() throws JMSException, MQException {
assertTrue(SharedWebSphereMQConnection.getMQConnection("TALEND", properties, "conn1")!=SharedWebSphereMQConnection.getMQConnection("TALEND", properties, "conn2"));
}
}

View File

@@ -1,45 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.talend</groupId>
<artifactId>xpathutil</artifactId>
<name>xpathutil</name>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<type>jar</type>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
</testResource>
</testResources>
</build>
</project>

View File

@@ -1,187 +0,0 @@
package org.talend.xpath;
import java.util.List;
import java.util.ArrayList;
public class XPathUtil {
private List<String> defualtNSPath = new ArrayList<String>();
public void setDefaultNSPath(List<String> defualtNSPath) {
this.defualtNSPath = defualtNSPath;
}
private final String LITERAL = "TALEND_LITERAL";
private java.util.regex.Pattern literalPattern = null;
private java.util.Map<String,String> resultCache;
private String removeLiterals(String path, List<String> literals) {
if(path == null || "".equals(path)) {
return path;
}
if(literalPattern == null) {
literalPattern = java.util.regex.Pattern.compile("'([^']*)'|\"([^\"]*)\"");
}
java.util.regex.Matcher matcher = literalPattern.matcher(path);
StringBuffer sb = new StringBuffer();
while(matcher.find()) {
literals.add(path.substring(matcher.start()+1,matcher.end()-1));
if(matcher.group(1)!=null) {
matcher.appendReplacement(sb, "'" + LITERAL + "'");
} else {
matcher.appendReplacement(sb, "\"" + LITERAL + "\"");
}
}
return matcher.appendTail(sb).toString();
}
private String resetLiterals(String xpathExpression,List<String> literals) {
if(literals.isEmpty()) {
return xpathExpression;
}
int start = 0;
int end = xpathExpression.indexOf(LITERAL, start);
if (end == -1) {
return xpathExpression;
}
StringBuilder sb = new StringBuilder();
java.util.Iterator<String> iterator = literals.iterator();
while (end != -1 && iterator.hasNext()) {
sb.append(xpathExpression.substring(start, end)).append(iterator.next());
start = end + LITERAL.length();
end = xpathExpression.indexOf(LITERAL, start);
}
sb.append(xpathExpression.substring(start));
return sb.toString();
}
public String addDefaultNSPrefix(String basePath) {
return addDefaultNSPrefix(basePath,"/");
}
public String addDefaultNSPrefix(String xpathExpression, String basePath) {
if(".".equals(basePath.trim())) {//addDefaultNSPrefix(path,".")==>process the special loop path
basePath = "/";
}
if (defualtNSPath.size() < 1) {
return xpathExpression;
}
if(resultCache == null) {
resultCache = new java.util.HashMap<String,String>();
}
String resultXpathExpression = resultCache.get(xpathExpression);
if(resultXpathExpression!=null) {
return resultXpathExpression;
}
List<String> literals = new java.util.ArrayList<String>();
resultXpathExpression = removeLiterals(xpathExpression,literals);
resultXpathExpression = addDefaultNSPrefixForLocationXPathExpression(resultXpathExpression,basePath);
resultXpathExpression = resetLiterals(resultXpathExpression, literals);
resultCache.put(xpathExpression,resultXpathExpression);
return resultXpathExpression;
}
private String addDefaultNSPrefixForLocationXPathExpression(String path, String absolutePath) {
StringBuilder newPath = new StringBuilder();
String[] pathStrs = path.split("/");
String currentAbsolutePath = absolutePath;
for (int i = 0; i < pathStrs.length; i++) {
String step = pathStrs[i];
currentAbsolutePath = getCurrentAbsolutePath(step, currentAbsolutePath);
if (newPath.length() > 0) {
newPath.append("/");
}
if (step.length() > 0 && step.indexOf(":") == -1 && step.indexOf(".") == -1 /*&& tmp.indexOf("@") == -1*/) {
int index = getDefaultNamespaceIndex(currentAbsolutePath);
if (index >= 0) {
//==== add by wliu to support both filter and functions==
if(step.indexOf("[")>0 && step.indexOf("]")>step.indexOf("[")){//include filter
String tmpStr=replaceElementWithNS(step,"pre"+index+":");
newPath.append(tmpStr);
}else{
if(step.indexOf("@") != -1 || step.indexOf("(")<step.indexOf(")")){ // include attribute
newPath.append(step);
}else{
//==add end=======
newPath.append("pre").append(index).append(":").append(step);
}
}
} else {
newPath.append(step);
}
} else {
newPath.append(step);
}
}
if(newPath.length() == 0) {
return "/";
}
return newPath.toString();
}
private String getCurrentAbsolutePath(String step, String absolutePath) {
String currentAbsolutePath = absolutePath;
if ("..".equals(step)) {
currentAbsolutePath = currentAbsolutePath.substring(0, currentAbsolutePath.lastIndexOf("/"));
} else if(".".equals(step)) {
//do nothing
} else if("/".equals(currentAbsolutePath)) {
currentAbsolutePath += step;
} else {
currentAbsolutePath += "/" + step;
}
return currentAbsolutePath;
}
private int getDefaultNamespaceIndex(String currentAbsolutePath) {
int result = -1;
for (int i = 0,length = 0; i < defualtNSPath.size(); i++) {
if (defualtNSPath.get(i).length() > length && currentAbsolutePath.startsWith(defualtNSPath.get(i))) {
result = i;
length = defualtNSPath.get(i).length();
}
}
return result;
}
private String matches = "@*\\b[a-z|A-Z|_]+[[-]*\\w]*\\b[^'\"|^\\(]";
private java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(matches);
private String replaceElementWithNS(String global, String pre){
java.util.regex.Matcher match = pattern.matcher(global);
StringBuffer sb = new StringBuffer();
match.reset();
while (match.find()) {
String group = match.group();
String tmp = "";
if (group.toLowerCase().matches("\\b(div|mod|and|or)\\b.*") || group.matches("@.*")) {
tmp = group;
} else {
tmp = tmp + pre + group;
}
match.appendReplacement(sb, tmp);
}
match.appendTail(sb);
return sb.toString();
}
}

View File

@@ -1,214 +0,0 @@
package org.talend.xpath;
import junit.framework.TestCase;
import org.junit.Test;
import java.util.List;
import java.util.ArrayList;
public class XPathUtilTest extends TestCase {
private static List<String> defualtNSPath = new ArrayList<String>();
static {
defualtNSPath.add("/root");
defualtNSPath.add("/root/loop/a/b");
}
@Test
public void testWithoutDefaultNamespace1() {
XPathUtil util = new XPathUtil();
assertEquals("/root/loop",util.addDefaultNSPrefix("/root/loop"));
}
@Test
public void testWithoutDefaultNamespace2() {
XPathUtil util = new XPathUtil();
assertEquals("id",util.addDefaultNSPrefix("id","/root/loop"));
}
@Test
public void testWithoutDefaultNamespace3() {
XPathUtil util = new XPathUtil();
assertEquals("@id",util.addDefaultNSPrefix("@id","/root/loop"));
}
@Test
public void testWithoutDefaultNamespace4() {
XPathUtil util = new XPathUtil();
assertEquals("u_id",util.addDefaultNSPrefix("u_id","/root/loop"));
}
@Test
public void testWithoutDefaultNamespace5() {
XPathUtil util = new XPathUtil();
assertEquals(".",util.addDefaultNSPrefix(".","/a/b/c/d"));
}
@Test
public void testWithoutDefaultNamespace6() {
XPathUtil util = new XPathUtil();
assertEquals("..",util.addDefaultNSPrefix("..","/a/b/c/d"));
}
@Test
public void testWithoutDefaultNamespace7() {
XPathUtil util = new XPathUtil();
assertEquals("../e/@_f",util.addDefaultNSPrefix("../e/@_f","/a/b/c/d"));
}
@Test
public void testWithoutDefaultNamespace8() {
XPathUtil util = new XPathUtil();
assertEquals("../../e",util.addDefaultNSPrefix("../../e","/a/b/c/d"));
}
@Test
public void testWithoutDefaultNamespace9() {
XPathUtil util = new XPathUtil();
assertEquals("/a/b/c/d/*[name()]",util.addDefaultNSPrefix("/a/b/c/d/*[name()]"));
}
@Test
public void testWithoutDefaultNamespace10() {
XPathUtil util = new XPathUtil();
assertEquals(".",util.addDefaultNSPrefix(".","/a/b/c/d/*[name()]"));
}
@Test
public void testWithoutDefaultNamespace11() {
XPathUtil util = new XPathUtil();
assertEquals(".",util.addDefaultNSPrefix(".","."));
}
@Test
public void testWithoutDefaultNamespace12() {
XPathUtil util = new XPathUtil();
assertEquals("/",util.addDefaultNSPrefix("/"));
}
@Test
public void testWithoutDefaultNamespace14() {
XPathUtil util = new XPathUtil();
assertEquals(".",util.addDefaultNSPrefix(".","/"));
}
@Test
public void test1() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:root/pre0:loop",util.addDefaultNSPrefix("/root/loop"));
}
@Test
public void test2() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:id",util.addDefaultNSPrefix("id","/root/loop"));
}
@Test
public void test3() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:person[@name='wangwei']/pre0:Value",util.addDefaultNSPrefix("person[@name='wangwei']/Value","/root/loop"));
}
@Test
public void test4() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:person[@name='wangwei']/pre0:Value",util.addDefaultNSPrefix("person[@name='wangwei']/Value","/root/loop"));
}
@Test
public void test5() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:person[@name=\"wangwei\"]/pre0:Value",util.addDefaultNSPrefix("person[@name=\"wangwei\"]/Value","/root/loop"));
}
@Test
public void test6() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:person[@name=\"wangwei\"]/pre0:Value",util.addDefaultNSPrefix("person[@name=\"wangwei\"]/Value","/root/loop"));
}
@Test
public void test7() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:person[@name='{wang.wei}']/pre0:Value",util.addDefaultNSPrefix("person[@name='{wang.wei}']/Value","/root/loop"));
}
@Test
public void test8() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:person/pre0:id/..",util.addDefaultNSPrefix("person/id/..","/root"));
}
@Test
public void test9() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:a/pre1:b/pre1:c/pre1:d",util.addDefaultNSPrefix("a/b/c/d","/root/loop"));
}
@Test
public void test10() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:root/pre0:loop/pre0:a/pre1:b/pre1:c",util.addDefaultNSPrefix("/root/loop/a/b/c"));
}
@Test
public void test11() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:root/pre0:loop/pre0:a/pre1:b[@name='{wang.wei}']/pre1:c",util.addDefaultNSPrefix("/root/loop/a/b[@name='{wang.wei}']/c"));
}
@Test
public void test12() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:root/pre0:loop/pre0:a/pre1:b/pre1:c",util.addDefaultNSPrefix("root/loop/a/b/c","."));
}
@Test
public void test14() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:root/pre0:loop/pre0:a/pre1:b/pre1:c",util.addDefaultNSPrefix("root/loop/a/b/c","/"));
}
@Test
public void test15() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("/",util.addDefaultNSPrefix("/"));
}
@Test
public void test16() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals(".",util.addDefaultNSPrefix(".","/"));
}
@Test
public void test17() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:root//pre0:loop",util.addDefaultNSPrefix("/root//loop"));
}
@Test
public void test18() {
XPathUtil util = new XPathUtil();
util.setDefaultNSPath(defualtNSPath);
assertEquals("pre0:a//pre0:b",util.addDefaultNSPrefix("/a//b","/root/loop"));
}
}

View File

@@ -1,40 +0,0 @@
<%
class MappingTouchXMLNode extends TouchXMLNode {
void getXMLNode(String currEleName) {
%>
nameToElement_<%=cid%>.get("<%=currEleName%>")
<%
}
void getXMLElement(String currEleName) {
%>
((org.dom4j.Element)(nameToElement_<%=cid%>.get("<%=currEleName%>")))
<%
}
void putCurrentComplexTypeElement(String currEleName) {
%>
nameToElement_<%=cid%>.put("<%=currEleName%>_c",<%getXMLNode(currEleName);%>.addElement("xsd:complexType"));
<%
}
void putCurrentSequenceElement(String currEleName) {
%>
nameToElement_<%=cid%>.put("<%=currEleName%>_s",<%getXMLNode(currEleName + "_c");%>.addElement("xsd:sequence"));
<%
}
void putCurrentElement(String currEleName,String parent) {
%>
nameToElement_<%=cid%>.put("<%=currEleName%>",<%getXMLNode(parent);%>.addElement("xsd:element"));
<%
}
void putRootElement() {
%>
nameToElement_<%=cid%>.put("root_xsd",root_xsd_<%=cid%>);
<%
}
}
%>

View File

@@ -1,46 +0,0 @@
<%
//get mean reference
//put mean declare,assign action
class ReferenceTouchXMLNode extends TouchXMLNode {
void getXMLNode(String currEleName) {
%>
<%=currEleName%>_<%=cid%>
<%
}
void getXMLElement(String currEleName) {
getXMLNode(currEleName);
}
void putCurrentComplexTypeElement(String currEleName) {
%>
org.dom4j.Element <%=currEleName%>_c_<%=cid%> = <%getXMLNode(currEleName);%>.addElement("xsd:complexType");
<%
}
void putCurrentSequenceElement(String currEleName) {
%>
org.dom4j.Element <%=currEleName%>_s_<%=cid%> = <%getXMLNode(currEleName + "_c");%>.addElement("xsd:sequence");
<%
}
void putCurrentElement(String currEleName,String parent) {
%>
org.dom4j.Element <%=currEleName%>_<%=cid%> = <%getXMLNode(parent);%>.addElement("xsd:element");
<%
}
void putRootElement() {
//do nothing
}
}
%>

View File

@@ -1,17 +0,0 @@
<%
abstract class TouchXMLNode {
protected String cid = null;
abstract void getXMLNode(String currEleName);
abstract void getXMLElement(String currEleName);
abstract void putCurrentComplexTypeElement(String currEleName);
abstract void putCurrentSequenceElement(String currEleName);
abstract void putCurrentElement(String currEleName,String parent);
abstract void putRootElement();
}
%>

View File

@@ -1,82 +0,0 @@
<%
// ------------------- *** Dom4j generation mode start *** ------------------- //
class XSDToolByDom4j{
String cid = null;
//opt for big xml config tree
BigMethodHelper bigMethodHelper = null;
TouchXMLNode touchXMLNode = null;
public XSDToolByDom4j() {
bigMethodHelper = new BigMethodHelper();
touchXMLNode = bigMethodHelper.getTouchXMLNode();
}
public void generateXSD(String parent, String currEleName, XMLNode root){
if(!("ELEMENT").equals(root.type)){
return;
}
bigMethodHelper.setGenerateId(currEleName);
//start the class
bigMethodHelper.generateClassNameWithRBlock();
bigMethodHelper.resetIndex();
generateMainCode(parent,currEleName,root);
//end the last method
bigMethodHelper.generateLeftBlock();
//end the class
bigMethodHelper.generateLeftBlock();
bigMethodHelper.generateMethodCall();
}
public void generateMainCode(String parent, String currEleName, XMLNode root){
if(("ELEMENT").equals(root.type)){
bigMethodHelper.generateMethod();
createElement(parent,currEleName,root);
if(root.elements!=null && root.elements.size()>0
|| root.attributes!=null && root.attributes.size()>0){
touchXMLNode.putCurrentComplexTypeElement(currEleName);
touchXMLNode.putCurrentSequenceElement(currEleName);
int index = 0;
for(XMLNode child:root.elements){
generateMainCode(currEleName+"_s", currEleName+"_"+index++, child);
}
for(XMLNode attri:root.attributes){
createAttribute(currEleName+"_c",attri);
}
}
}
}
private void createElement(String parent, String currEleName, XMLNode node){
touchXMLNode.putCurrentElement(currEleName,parent);
%>
<%touchXMLNode.getXMLElement(currEleName);%>.addAttribute("name","<%=node.name%>");
<%touchXMLNode.getXMLElement(currEleName);%>.addAttribute("nillable","true");
<%
if(node.parent != null){
%>
<%touchXMLNode.getXMLElement(currEleName);%>.addAttribute("minOccurs","0");
<%touchXMLNode.getXMLElement(currEleName);%>.addAttribute("maxOccurs","unbounded");
<%
}
}
private void createAttribute(String parent, XMLNode node){
%>
<%touchXMLNode.getXMLNode(parent);%>.addElement("xsd:attribute").addAttribute("name","<%=node.name%>");
<%
}
}
// ------------------- *** Dom4j generation mode end *** ------------------- //
%>

View File

@@ -1,69 +0,0 @@
<%
// ------------------- *** Null generation mode start *** ------------------- //
class XSDToolByNull{
String cid = null;
public void generateXSD(String emptyspace, XMLNode root){
if(("ELEMENT").equals(root.type)){
createElement(emptyspace, root);
if(root.elements!=null && root.elements.size()>0
|| root.attributes!=null && root.attributes.size()>0){
%>
out_xsd_<%=cid%>.write("<%=emptyspace%> <xsd:complexType>");
out_xsd_<%=cid%>.newLine();
out_xsd_<%=cid%>.write("<%=emptyspace%> <xsd:sequence>");
out_xsd_<%=cid%>.newLine();
<%
XMLNode mainNode = null;
for(XMLNode child:root.elements){
if( 1==(child.special & 4)){
mainNode = child;
}else{
generateXSD(emptyspace+" ", child);
}
}
if(mainNode!= null){
generateXSD(emptyspace+" ", mainNode);
}
%>
out_xsd_<%=cid%>.write("<%=emptyspace%> </xsd:sequence>");
out_xsd_<%=cid%>.newLine();
<%
for(XMLNode attri:root.attributes){
createAttribute(emptyspace+" ",attri);
}
%>
out_xsd_<%=cid%>.write("<%=emptyspace%> </xsd:complexType>");
out_xsd_<%=cid%>.newLine();
<%
}
%>
out_xsd_<%=cid%>.write("<%=emptyspace%></xsd:element>");
out_xsd_<%=cid%>.newLine();
<%
}
}
private void createElement(String emptyspace, XMLNode node){
%>
out_xsd_<%=cid%>.write("<%=emptyspace%><xsd:element name=\"<%=node.name%>\" nillable=\"true\" "+
<%
if(node.parent != null){
%>
"minOccurs=\"0\" maxOccurs=\"unbounded\""+
<%
}
%>
">");
out_xsd_<%=cid%>.newLine();
<%
}
private void createAttribute(String emptyspace, XMLNode node){
%>
out_xsd_<%=cid%>.write("<%=emptyspace%><xsd:attribute name= \"<%=node.name%>\"/>");
out_xsd_<%=cid%>.newLine();
<%
}
}
%>

View File

@@ -1,57 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.IConnection
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.List
org.talend.core.model.process.EConnectionType
org.talend.core.model.process.IDataConnection
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
boolean includeParallelComps = false;
if (connections != null && connections.size() > 0) {
for (IConnection connection : connections) {
String connectionName = connection.getName();
INode validTarget = ((IDataConnection) connection).getLinkNodeForHash();
INode partitionNode = null;
if(validTarget != null) {
partitionNode = validTarget.getDesignSubjobStartNode();
if ("tCollector".equals(partitionNode.getComponent().getName())) {
includeParallelComps = true;
partitionNode = partitionNode.getIncomingConnections(EConnectionType.STARTS).get(0).getSource();
}
}
if (includeParallelComps && partitionNode!=null) {
%>
synchronized (this) {
if (globalMap.get("tHash_<%=connectionName%>") == null) {
java.util.Map<<%=connectionName%>Struct, <%=connectionName%>Struct> tHash_<%=connectionName%> = null;
boolean isMultiThreaded_<%=cid%> = false;
if (!(globalMap.get("MULTI_THREADED_JOB_<%=partitionNode.getUniqueName()%>_"+jobName) == null || !((Boolean)globalMap.get("MULTI_THREADED_JOB_<%=partitionNode.getUniqueName()%>_"+jobName)))) {
tHash_<%=connectionName%> = new java.util.concurrent.ConcurrentHashMap<<%=connectionName%>Struct,<%=connectionName%>Struct>();
isMultiThreaded_<%=cid%> = true;
} else {
tHash_<%=connectionName%> = new java.util.LinkedHashMap<<%=connectionName%>Struct, <%=connectionName%>Struct>();
}
globalMap.put("tHash_<%=connectionName%>", tHash_<%=connectionName%>);
<%
} else {
%>
java.util.Map<<%=connectionName%>Struct, <%=connectionName%>Struct> tHash_<%=connectionName%> = new java.util.LinkedHashMap<<%=connectionName%>Struct, <%=connectionName%>Struct>();
globalMap.put("tHash_<%=connectionName%>", tHash_<%=connectionName%>);
<%
}
}
}
%>

View File

@@ -1,50 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.IConnection
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.List
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.process.EConnectionType
org.talend.core.model.process.IDataConnection
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
List<IConnection> connections = (List<IConnection>) node.getIncomingConnections();
boolean includeParallelComps = false;
if (connections != null && connections.size() > 0) {
for (IConnection connection : connections) {
String connectionName = connection.getName();
IMetadataTable metadataTable = connection.getMetadataTable();
INode validTarget = ((IDataConnection) connection).getLinkNodeForHash();
if(validTarget != null) {
INode partitionNode = validTarget.getDesignSubjobStartNode();
if ("tCollector".equals(partitionNode.getComponent().getName())) {
includeParallelComps = true;
partitionNode = partitionNode.getIncomingConnections(EConnectionType.STARTS).get(0).getSource();
}
if (includeParallelComps) {
%>
if (isMultiThreaded_<%=cid%>) {
java.util.List<java.util.Map<String,Object>> mapsList_<%=cid%> =
(java.util.List<java.util.Map<String,Object>>)globalMap.get("THREAD_MAPS_<%=partitionNode.getUniqueName()%>_"+jobName);
if (mapsList_<%=cid%> != null) {
for (java.util.Map<String,Object> map : mapsList_<%=cid%>) {
if (globalMap != map) {
map.put("tHash_<%=connectionName%>",tHash_<%=connectionName%>);
} //gm
}//for
}//null
}//is threaded
}
}
<% }
}
}
}
%>

View File

@@ -1,10 +0,0 @@
MDMURL.NAME=URL
USERNAME.NAME=Username
PASSWORD.NAME=Password
UNIVERSE.NAME=Version
HELP=org.talend.help.tMDMConnection
LONG_NAME=Creates a connection to a MDM Server
AUTO_COMMIT.NAME=Auto Commit
GEN_TRANSACTION_ID.NAME=Use client side transaction id

View File

@@ -1,145 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.List
java.util.Map
"
class="MomConnection"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String host=ElementParameterParser.getValue(node, "__SERVERADDRESS__");
String port=ElementParameterParser.getValue(node, "__SERVERPORT__");
String dbuser= ElementParameterParser.getValue(node, "__USER__");
String serverType=ElementParameterParser.getValue(node, "__SERVER__");
boolean isUseSharedConnection = ("true").equals(ElementParameterParser.getValue(node, "__USE_SHARED_CONNECTION__"));
String sharedConnectionName = ElementParameterParser.getValue(node, "__SHARED_CONNECTION_NAME__");
if(("ActiveMQ").equals(serverType)){/***ActiveMQ*****/
boolean transacted = "true".equals(ElementParameterParser.getValue(node, "__IS_TRANSACTED__"));
String acknowledgmentMode = ElementParameterParser.getValue(node, "__ACKNOWLEDGMENT_MODE__");
boolean failover = ("true").equals(ElementParameterParser.getValue(node, "__FAILOVER__"));
List<Map<String,String>> servers = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__SERVERS__");
List<Map<String,String>> additionalOpts = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__ADDITIONAL_OPTIONS__");
String strHost = null;
String strPort = null;
%>
/*---------------------------------------1.initial jms connection factry---------------------------------*/
String url_<%=cid%> ="";
<%if(failover){%>
url_<%=cid %> = "failover:(";
<%
int i=0;
for(Map<String, String> serversMap : servers) {
strHost = serversMap.get("SERVERS_HOST");
strPort = serversMap.get("SERVERS_PORT");
if(i>0) {
%>
url_<%=cid %> = url_<%=cid %> +",";
<%
}
%>
url_<%=cid %> = url_<%=cid %> +"tcp://";
url_<%=cid %> = url_<%=cid %> +<%=strHost%>;
url_<%=cid %> = url_<%=cid %> +":";
url_<%=cid %> = url_<%=cid %> +<%=strPort%>;
<%
i++;
}
%>
url_<%=cid %> = url_<%=cid %> +")?randomize=false";
<%
for(Map<String, String> optrion : additionalOpts) {
%>
url_<%=cid %> = url_<%=cid %> +"&"+<%=optrion.get("OPTION_NAME")%>+"="+<%=optrion.get("OPTION_VALUE")%>;
<%
}
}else{%>
url_<%=cid %> = "tcp://"+<%=host%>+":"+<%=port%>;
<%}%>
<%
String passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
<%
if(isUseSharedConnection){
%>
javax.jms.Connection connection_<%=cid %> = org.talend.mq.SharedActiveMQConnection.getMQConnection(url_<%=cid %>,<%=dbuser%>,decryptedPassword_<%=cid%>,<%=sharedConnectionName%>);
<%
}else{
%>
System.out.println("Connecting to URL: " + url_<%=cid %>);
org.apache.activemq.ActiveMQConnectionFactory factory_<%=cid %> =
new org.apache.activemq.ActiveMQConnectionFactory(url_<%=cid %>);
<%
/*---------------------------------------2.create Queue Or Topic from connection ---------------------------------*/
%>
<% if(dbuser == null || ("\"\"").equals(dbuser) || ("").equals(dbuser)) { %>
javax.jms.Connection connection_<%=cid %> = factory_<%=cid %>.createConnection();
<% } else { %>
javax.jms.Connection connection_<%=cid %> = factory_<%=cid %>.createConnection(<%=dbuser%>,decryptedPassword_<%=cid%>);
<% } %>
connection_<%=cid %>.start();
<%
}
%>
globalMap.put("connection_<%=cid%>", connection_<%=cid %>);
javax.jms.Session session_<%=cid %> = connection_<%=cid %>.createSession(<%=transacted%>, javax.jms.Session.<%=acknowledgmentMode%>);
globalMap.put("session_<%=cid %>", session_<%=cid %>);
<%
}else{ /***WebSphere MQ*****/
String channel=ElementParameterParser.getValue(node, "__CHANNEL__");
String qm=ElementParameterParser.getValue(node, "__QM__");
%>
java.util.Hashtable properties<%=cid%>=new java.util.Hashtable();
properties<%=cid%>.put("hostname", <%=host%>);
properties<%=cid%>.put("port", Integer.valueOf(<%=port%>));
properties<%=cid%>.put("channel", <%=channel%>);
properties<%=cid%>.put("CCSID", new Integer(1208));
properties<%=cid%>.put("transport","MQSeries");
<%
if(!(dbuser == null) && !("\"\"").equals(dbuser) && !("").equals(dbuser)) {
%>
properties<%=cid%>.put("userID",<%=dbuser%>);
<%
String passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
properties<%=cid%>.put("password",decryptedPassword_<%=cid%>);
<%
}
if(isUseSharedConnection){
%>
com.ibm.mq.MQQueueManager qMgr_<%=cid%> = org.talend.mq.SharedWebSphereMQConnection.getMQConnection(<%=qm%>,properties<%=cid%>,<%=sharedConnectionName%>);
<%
}else{
%>
com.ibm.mq.MQQueueManager qMgr_<%=cid%> = new com.ibm.mq.MQQueueManager(<%=qm%>,properties<%=cid%>);
<%
}
%>
globalMap.put("qMgr_<%=cid%>", qMgr_<%=cid%> );
<%
}
%>

View File

@@ -1,602 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.List
java.util.Map
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
cid = cid.replaceAll("_Loop", "");
boolean isUseExistConnection = ("true").equals(ElementParameterParser.getValue(node, "__USE_CONNECTION__"));
String connectionComponentName = ElementParameterParser.getValue(node, "__CONNECTION__");
String serverType=ElementParameterParser.getValue(node, "__SERVER__");
String host=ElementParameterParser.getValue(node, "__SERVERADDRESS__");
String port=ElementParameterParser.getValue(node, "__SERVERPORT__");
String kListen=ElementParameterParser.getValue(node, "__KEEPLISTENING__");
String msgBobyType = ElementParameterParser.getValue(node, "__MESSAGE_BODY_TYPE__");
String msgId=ElementParameterParser.getValue(node, "__MSG_ID__");
String useMsgId=ElementParameterParser.getValue(node, "__IS_USE_MESSAGE_ID__");
String from=ElementParameterParser.getValue(node, "__FROM__");
String msgType = ElementParameterParser.getValue(node, "__MSGTYPE__");
boolean transacted = "true".equals(ElementParameterParser.getValue(node, "__IS_TRANSACTED__"));
String acknowledgmentMode = ElementParameterParser.getValue(node, "__ACKNOWLEDGMENT_MODE__");
boolean failover = ("true").equals(ElementParameterParser.getValue(node, "__FAILOVER__"));
List<Map<String,String>> servers = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__SERVERS__");
List<Map<String,String>> additionalOpts = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__ADDITIONAL_OPTIONS__");
String dbuser= ElementParameterParser.getValue(node, "__USER__");
String strHost = null;
String strPort = null;
boolean useMqHeader = "true".equals(ElementParameterParser.getValue(node, "__USE_MQ_HEADER__"));
List<? extends INode> commitNodes=node.getProcess().getNodesOfType("tMomCommit");
List<? extends INode> rollBackNodes=node.getProcess().getNodesOfType("tMomRollback");
boolean isCommitRollback = false;
for(INode cNode:commitNodes){
String cNodeName = ElementParameterParser.getValue(cNode,"__CONNECTION__");
if(cid.equals(cNodeName)){
isCommitRollback = true;
break;
}
}
if(!isCommitRollback){
for(INode rNode:rollBackNodes){
String rNodeName = ElementParameterParser.getValue(rNode,"__CONNECTION__");
if(cid.equals(rNodeName)){
isCommitRollback = true;
break;
}
}
}
if (isUseExistConnection) {
for (INode pNode : node.getProcess().getNodesOfType("tMomConnection")) {
if (pNode.getUniqueName().equals(connectionComponentName)) {
transacted = "true".equals(ElementParameterParser.getValue(pNode, "__IS_TRANSACTED__"));
serverType = ElementParameterParser.getValue(pNode, "__SERVER__");
failover = ("true").equals(ElementParameterParser.getValue(pNode, "__FAILOVER__"));
}
}
}
IMetadataTable metadata=null;
List<IMetadataColumn> columns = null;
List<IMetadataTable> metadatas = node.getMetadataList();
if ((metadatas!=null)&&(metadatas.size()>0)) {
metadata = metadatas.get(0);
columns = metadata.getListColumns();
} %>
int nb_line_<%=cid%> = 0;
javax.jms.Connection connection_<%=cid %> = null;
try {
<% if (isUseExistConnection && ("ActiveMQ").equals(serverType)) { %>
connection_<%=cid %> = null;
javax.jms.Session session_<%=cid %> = null;
try {
connection_<%=cid %> = (javax.jms.Connection) globalMap.get("connection_<%=connectionComponentName%>");
connection_<%=cid %>.start();
session_<%=cid %> = (javax.jms.Session) globalMap.get("session_<%=connectionComponentName%>");
} catch (NullPointerException npe) {
throw new RuntimeException("<%=connectionComponentName%> still not initialized. Try to redesign job.");
}
javax.jms.Destination des_<%=cid %> = null;
<%
if (("Queue").equals(msgType)) {
%>
des_<%=cid %> = session_<%=cid %>.createQueue(<%=from %>);
<%
} else {
%>
des_<%=cid %> = session_<%=cid %>.createTopic(<%=from %>);
<%
}
%>
javax.jms.MessageProducer replyProducer_<%=cid %> = session_<%=cid %>.createProducer(null);
replyProducer_<%=cid %>.setDeliveryMode(javax.jms.DeliveryMode.NON_PERSISTENT);
javax.jms.MessageConsumer consumer_<%=cid %> = session_<%=cid %>.createConsumer(des_<%=cid %>);
globalMap.put("session_<%=cid %>",session_<%=cid %>);
globalMap.put("connection_<%=cid %>",connection_<%=cid %>);
// Receive message
<% boolean useMax = ("true").equals(ElementParameterParser.getValue(node,"__USEMAX__"));
String maxiumMessages = ElementParameterParser.getValue(node,"__MAXMSG__");
String receiveTimeOut = ElementParameterParser.getValue(node,"__TIMEOUT__");
if(("true").equals(kListen)){
%>
System.out.println("We will consume messages while they continue to be delivered ");
javax.jms.Message message_<%=cid%>;
while ((message_<%=cid%> = consumer_<%=cid %>.receive()) != null) {
<%if(("ActiveMQ").equals(serverType) && !isCommitRollback && transacted){%>
try { // For rollback
<%
}
%>
<%
}else if (useMax) {
%>
int maxMsg_<%=cid %> = <%=maxiumMessages %>;
System.out.println("We are about to wait until we consume: " + maxMsg_<%=cid %> + " message(s) then we will shutdown");
for (int i_<%=cid %> = 0; i_<%=cid %> < maxMsg_<%=cid %> ;) {
<%if(("ActiveMQ").equals(serverType) && !isCommitRollback && transacted){%>
try { // For rollback
<%
}
%>
javax.jms.Message message_<%=cid%> = consumer_<%=cid %>.receive();
if (message_<%=cid%> != null) {
i_<%=cid %>++;
<%
}else {
%>
System.out.println("We will wait for messages within: " + <%=receiveTimeOut%>*1000 + " ms, and then we will shutdown");
javax.jms.Message message_<%=cid%>;
while ((message_<%=cid%> = consumer_<%=cid %>.receive(<%=receiveTimeOut%>*1000)) != null) {
<%if(("ActiveMQ").equals(serverType) /*&& !isUseExistConnection*/ && !isCommitRollback && transacted){%>
try { // For rollback
<%
}
%>
<%
} %>
/*-----------------------------------------------------------4.judge message body type---------------------------------------*/
<%
if(("true").equals(useMsgId) && !"Map".equals(msgBobyType)){
%>
if (message_<%=cid%> instanceof javax.jms.MapMessage) {
javax.jms.MapMessage txtMsg_<%=cid%> = (javax.jms.MapMessage) message_<%=cid%>;
String msg_<%=cid %> = txtMsg_<%=cid%>.getString(<%=msgId%>);
if(msg_<%=cid %> !=null){
<%
}else{
if ("Text".equals(msgBobyType)) {
%>
javax.jms.TextMessage txtMsg_<%=cid%> = (javax.jms.TextMessage) message_<%=cid%>;
String msg_<%=cid %> = txtMsg_<%=cid%>.getText();
<%
} else if ("Bytes".equals(msgBobyType)) {
%>
javax.jms.BytesMessage bytesMsg_<%=cid%> = (javax.jms.BytesMessage) message_<%=cid%>;
byte[] bytesMsgBody_<%=cid%> = new byte[(int)bytesMsg_<%=cid%>.getBodyLength()];
bytesMsg_<%=cid%>.readBytes(bytesMsgBody_<%=cid%>);
<%
if(!"id_byte[]".equals(metadata.getColumn("message").getTalendType())){
%>
String msg_<%=cid %> = new String(bytesMsgBody_<%=cid%>);
<%
}
} else if ("Map".equals(msgBobyType)) {
%>
javax.jms.MapMessage msg_<%=cid %> = (javax.jms.MapMessage) message_<%=cid%>;
<%
}
}
%>
<%} else if (("JBoss").equals(serverType)||(!isUseExistConnection && ("ActiveMQ").equals(serverType))) {
/*---------------------------------------1.initial jms connection factry---------------------------------*/
if(("JBoss").equals(serverType) ){ // server judgement
%>
java.util.Hashtable props_<%=cid%>=new java.util.Hashtable();
props_<%=cid%>.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props_<%=cid%>.put(javax.naming.Context.PROVIDER_URL, <%=host%>+":"+<%=port%>);
props_<%=cid%>.put("java.naming.rmi.security.manager", "yes");
props_<%=cid%>.put(javax.naming.Context.URL_PKG_PREFIXES, "org.jboss.naming");
props_<%=cid%>.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
javax.naming.Context context_<%=cid%>=new javax.naming.InitialContext(props_<%=cid%>);
javax.jms.ConnectionFactory factory_<%=cid%>=(javax.jms.ConnectionFactory)context_<%=cid%>.lookup("ConnectionFactory");
<%
}else if(("ActiveMQ").equals(serverType)){
boolean startServer = ("true").equals(ElementParameterParser.getValue(node, "__STARTSERVER__"));
%>
String url_<%=cid %> ="";
<%if(failover){%>
url_<%=cid %> = "failover:(";
<%
int i=0;
for(Map<String, String> serversMap : servers) {
strHost = serversMap.get("SERVERS_HOST");
strPort = serversMap.get("SERVERS_PORT");
if(i>0) {
%>
url_<%=cid %> = url_<%=cid %> +",";
<%
}
%>
url_<%=cid %> = url_<%=cid %> +"tcp://";
url_<%=cid %> = url_<%=cid %> +<%=strHost%>;
url_<%=cid %> = url_<%=cid %> +":";
url_<%=cid %> = url_<%=cid %> +<%=strPort%>;
<%
i++;
}
%>
url_<%=cid %> = url_<%=cid %> +")?randomize=false";
<%
for(Map<String, String> optrion : additionalOpts) {
%>
url_<%=cid %> = url_<%=cid %> +"&"+<%=optrion.get("OPTION_NAME")%>+"="+<%=optrion.get("OPTION_VALUE")%>;
<%
}
}else{%>
url_<%=cid %> = "tcp://"+<%=host%>+":"+<%=port%>;
<%}%>
<%
if(startServer){
%>
org.apache.activemq.broker.BrokerService broker_<%=cid %> = new org.apache.activemq.broker.BrokerService();
broker_<%=cid %>.setUseJmx(true);
broker_<%=cid %>.addConnector(url_<%=cid %>);
broker_<%=cid %>.start();
<%
}
%>
System.out.println("Connecting to URL: " + url_<%=cid %>);
System.out.println("Consuming " + (<%="Topic".equals(msgType)%> ? "topic" : "queue") + ": " + <%=from%>);
org.apache.activemq.ActiveMQConnectionFactory factory_<%=cid %> = new org.apache.activemq.ActiveMQConnectionFactory(url_<%=cid %>);
<%
}
/*---------------------------------------2.create Queue Or Topic from connection ---------------------------------*/
if(dbuser == null || ("\"\"").equals(dbuser) || ("").equals(dbuser)) {
%>
connection_<%=cid %> = factory_<%=cid %>.createConnection();
<%
} else {
%>
<%
String passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
connection_<%=cid %> = factory_<%=cid %>.createConnection(<%=dbuser%>,decryptedPassword_<%=cid%>);
<%
}
%>
connection_<%=cid %>.start();
javax.jms.Session session_<%=cid %> = connection_<%=cid %>.createSession(<%=transacted%>, javax.jms.Session.<%=acknowledgmentMode%>);
javax.jms.Destination des_<%=cid %> = null;
<%
if (("Queue").equals(msgType)) {
%>
des_<%=cid %> = session_<%=cid %>.createQueue(<%=from %>);
<%
} else {
%>
des_<%=cid %> = session_<%=cid %>.createTopic(<%=from %>);
<%
}
%>
javax.jms.MessageProducer replyProducer_<%=cid %> = session_<%=cid %>.createProducer(null);
replyProducer_<%=cid %>.setDeliveryMode(javax.jms.DeliveryMode.NON_PERSISTENT);
javax.jms.MessageConsumer consumer_<%=cid %> = session_<%=cid %>.createConsumer(des_<%=cid %>);
<% //put session to global map
if( ("ActiveMQ").equals(serverType)) {
%>
globalMap.put("session_<%=cid %>",session_<%=cid %>);
globalMap.put("connection_<%=cid %>",connection_<%=cid %>);
<%
}
%>
<%
/*---------------------------------------3.recevice message form server ---------------------------------*/
if(("JBoss").equals(serverType) ){
%>
System.out.println("Ready to receive message");
System.out.println("Waiting...");
javax.jms.Message message_<%=cid%>;
while((message_<%=cid%>=consumer_<%=cid %>.receive())!=null){
<%
}else if(("ActiveMQ").equals(serverType)){
boolean useMax = ("true").equals(ElementParameterParser.getValue(node,"__USEMAX__"));
String maxiumMessages = ElementParameterParser.getValue(node,"__MAXMSG__");
String receiveTimeOut = ElementParameterParser.getValue(node,"__TIMEOUT__");
if(("true").equals(kListen)){
%>
System.out.println("We will consume messages while they continue to be delivered ");
javax.jms.Message message_<%=cid%>;
while ((message_<%=cid%> = consumer_<%=cid %>.receive()) != null) {
<%if(("ActiveMQ").equals(serverType) /*&& !isUseExistConnection*/ && !isCommitRollback && transacted){%>
try { // For rollback
<%
}
%>
<%
}else if (useMax) {
%>
int maxMsg_<%=cid %> = <%=maxiumMessages %>;
System.out.println("We are about to wait until we consume: " + maxMsg_<%=cid %> + " message(s) then we will shutdown");
for (int i_<%=cid %> = 0; i_<%=cid %> < maxMsg_<%=cid %> ;) {
<%if(("ActiveMQ").equals(serverType) && !isCommitRollback && transacted){%>
try { // For rollback
<%
}
%>
javax.jms.Message message_<%=cid%> = consumer_<%=cid %>.receive();
if (message_<%=cid%> != null) {
i_<%=cid %>++;
<%
}else {
%>
System.out.println("We will wait for messages within: " + <%=receiveTimeOut%>*1000 + " ms, and then we will shutdown");
javax.jms.Message message_<%=cid%>;
while ((message_<%=cid%> = consumer_<%=cid %>.receive(<%=receiveTimeOut%>*1000)) != null) {
<%if(("ActiveMQ").equals(serverType) /*&& !isUseExistConnection*/ && !isCommitRollback && transacted){%>
try { // For rollback
<%
}
%>
<%
}
}
/*-----------------------------------------------------------4.judge message body type---------------------------------------*/
if(("true").equals(useMsgId) && !"Map".equals(msgBobyType)){
%>
if (message_<%=cid%> instanceof javax.jms.MapMessage) {
javax.jms.MapMessage txtMsg_<%=cid%> = (javax.jms.MapMessage) message_<%=cid%>;
String msg_<%=cid %> = txtMsg_<%=cid%>.getString(<%=msgId%>);
if(msg_<%=cid %> !=null){
<%
}else{
if ("Text".equals(msgBobyType)) {
%>
javax.jms.TextMessage txtMsg_<%=cid%> = (javax.jms.TextMessage) message_<%=cid%>;
String msg_<%=cid %> = txtMsg_<%=cid%>.getText();
<%
} else if ("Bytes".equals(msgBobyType)) {
%>
javax.jms.BytesMessage bytesMsg_<%=cid%> = (javax.jms.BytesMessage) message_<%=cid%>;
byte[] bytesMsgBody_<%=cid%> = new byte[(int)bytesMsg_<%=cid%>.getBodyLength()];
bytesMsg_<%=cid%>.readBytes(bytesMsgBody_<%=cid%>);
<%
if(!"id_byte[]".equals(metadata.getColumn("message").getTalendType())){
%>
String msg_<%=cid %> = new String(bytesMsgBody_<%=cid%>);
<%
}
} else if ("Map".equals(msgBobyType)) {
%>
javax.jms.MapMessage msg_<%=cid %> = (javax.jms.MapMessage) message_<%=cid%>;
<%
}
}
%>
<%
} else if(("WebSphere").equals(serverType)){ //server judgement /***WebSphere MQ*****/
%>
com.ibm.mq.MQQueueManager qMgr_<%=cid%>=null;
<%
if(isUseExistConnection){
String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
%>
qMgr_<%=cid%> = (com.ibm.mq.MQQueueManager)globalMap.get("qMgr_<%=connection%>");
globalMap.put("qMgr_<%=cid%>",qMgr_<%=cid%>);
<%
}else{
String channel=ElementParameterParser.getValue(node, "__CHANNEL__");
String qm=ElementParameterParser.getValue(node, "__QM__");
%>
java.util.Hashtable properties<%=cid%>=new java.util.Hashtable();
properties<%=cid%>.put("hostname", <%=host%>);
properties<%=cid%>.put("port", Integer.valueOf(<%=port%>));
properties<%=cid%>.put("channel", <%=channel%>);
properties<%=cid%>.put("CCSID", new Integer(1208));
properties<%=cid%>.put("transport","MQSeries");
<%
if(!(dbuser == null) && !("\"\"").equals(dbuser) && !("").equals(dbuser)) {
%>
properties<%=cid%>.put("userID",<%=dbuser%>);
<%
String passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
properties<%=cid%>.put("password",decryptedPassword_<%=cid%>);
<%
}
%>
qMgr_<%=cid%>=new com.ibm.mq.MQQueueManager(<%=qm%>,properties<%=cid%>);
globalMap.put("qMgr_<%=cid%>",qMgr_<%=cid%>);
<%
}
String queue = ElementParameterParser.getValue(node, "__QUEUE__");
boolean isRollback = ("true").equals(ElementParameterParser.getValue(node, "__ROLLBACK__"));
boolean isCommit = ("true").equals(ElementParameterParser.getValue(node, "__COMMIT__"));
boolean isBrowse = ("true").equals(ElementParameterParser.getValue(node,"__BROWSE__"));
boolean needSSLCipher = ("true").equals(ElementParameterParser.getValue(node,"__SET_MQ_SSL_CIPHER__"));
String sslCipher = ElementParameterParser.getValue(node, "__MQ_SSL_CIPHER__");
isCommit = isCommit && !isBrowse;
isBrowse = isBrowse && !isRollback && !isCommit;
%>
com.ibm.mq.MQQueue remoteQ_<%=cid%>=null;
<%
if(needSSLCipher){
%>
com.ibm.mq.MQEnvironment.sslCipherSuite = "<%=sslCipher%>";
<%
}
if(("true").equals(useMsgId)){
%>
String msgId_<%=cid%> = <%=msgId%>;
if (msgId_<%=cid%> != null & !("").equals(msgId_<%=cid%>)) {
String padding_<%=cid%> = new String();
int padlen_<%=cid%> = 24;
int len_<%=cid%> = Math.abs(padlen_<%=cid%>) - msgId_<%=cid%>.toString().length();
if (len_<%=cid%> > 0) {
for (int i = 0 ; i < len_<%=cid%> ; i++) {
padding_<%=cid%> = padding_<%=cid%> + " ";
}
msgId_<%=cid%> = msgId_<%=cid%> + padding_<%=cid%>;
}
}
<%
}
%>
try{
int openOptions<%=cid%>=com.ibm.mq.MQC.MQOO_INPUT_SHARED | com.ibm.mq.MQC.MQOO_FAIL_IF_QUIESCING | com.ibm.mq.MQC.MQOO_INQUIRE<%if(isBrowse){%> | com.ibm.mq.MQC.MQOO_BROWSE<%}%>;
com.ibm.mq.MQGetMessageOptions gmo<%=cid%>=new com.ibm.mq.MQGetMessageOptions();
<%if(isBrowse){%>
gmo<%=cid%>.options=gmo<%=cid%>.options+com.ibm.mq.MQC.MQGMO_BROWSE_FIRST;
int browseCursor_<%=cid%> = 0;
<%}else{%>
gmo<%=cid%>.options=gmo<%=cid%>.options+com.ibm.mq.MQC.MQGMO_SYNCPOINT;
<%}%>
gmo<%=cid%>.options=gmo<%=cid%>.options+com.ibm.mq.MQC.<%if(("false").equals(kListen)){%>MQGMO_NO_WAIT<%}else{%>MQGMO_WAIT<%}%>;
gmo<%=cid%>.options=gmo<%=cid%>.options+com.ibm.mq.MQC.MQGMO_FAIL_IF_QUIESCING;
gmo<%=cid%>.waitInterval=com.ibm.mq.MQC.MQWI_UNLIMITED;
com.ibm.mq.MQException.log = null;
boolean flag<%=cid%>=true;
remoteQ_<%=cid%>=qMgr_<%=cid%>.accessQueue(<%=queue%>,openOptions<%=cid%>);
<%
if(("false").equals(kListen)) {
%>
if(Integer.valueOf(remoteQ_<%=cid%>.getCurrentDepth()).equals(0))
{
flag<%=cid%>= false;
}
<%
}
%>
System.out.println("Ready to receive message");
System.out.println("Waiting...");
while(flag<%=cid%>){
<%
if(("false").equals(kListen)){
%>
if(Integer.valueOf(remoteQ_<%=cid%>.getCurrentDepth()).equals(1))
{
flag<%=cid%>= false;
}
<%
}
if(isBrowse){
%>
if(browseCursor_<%=cid%> > 0){
gmo<%=cid%>.options=com.ibm.mq.MQC.MQGMO_BROWSE_NEXT;
gmo<%=cid%>.options=gmo<%=cid%>.options+com.ibm.mq.MQC.<%if(("false").equals(kListen)){%>MQGMO_NO_WAIT<%}else{%>MQGMO_WAIT<%}%>;
gmo<%=cid%>.options=gmo<%=cid%>.options+com.ibm.mq.MQC.MQGMO_FAIL_IF_QUIESCING;
}
browseCursor_<%=cid%>++;
<%
}
%>
com.ibm.mq.MQMessage inMessage<%=cid%>=new com.ibm.mq.MQMessage();
<%
if(("true").equals(useMsgId)&& !"Map".equals(msgBobyType)){
%>
inMessage<%=cid%>.messageId = msgId_<%=cid%>.getBytes("ISO-8859-15");
<%
}
if(("false").equals(kListen) && ("true").equals(useMsgId) && !"Map".equals(msgBobyType) ){
%>
try{
remoteQ_<%=cid%>.get(inMessage<%=cid%>,gmo<%=cid%>);
}catch (com.ibm.mq.MQException me_<%=cid%>) {
if (me_<%=cid%>.reasonCode == com.ibm.mq.MQException.MQRC_NO_MSG_AVAILABLE) {
break;
}else{
throw me_<%=cid%>;
}
}
<%
} else {
%>
remoteQ_<%=cid%>.get(inMessage<%=cid%>,gmo<%=cid%>);
<%
}
%>
<%
if (useMqHeader) {
%>
org.talend.mq.headers.rfh2.MQRFH2 mqrfh2_<%=cid %> = new org.talend.mq.headers.rfh2.MQRFH2(inMessage<%=cid %>);
<%}%>
<%
if ("Text".equals(msgBobyType)) {
%>
String msg_<%=cid%>=inMessage<%=cid%>.readStringOfByteLength(inMessage<%=cid%>.getDataLength());
<%
} else if ("Bytes".equals(msgBobyType)) {
%>
byte[] bytesMsgBody_<%=cid%> = new byte[inMessage<%=cid%>.getDataLength()];
inMessage<%=cid%>.readFully(bytesMsgBody_<%=cid%>);
<%
if(!"id_byte[]".equals(metadata.getColumn("message").getTalendType())){
%>
String msg_<%=cid%> = new String(bytesMsgBody_<%=cid%>);
<%
}
} else if ("Map".equals(msgBobyType)) {
%>
java.util.Map msg_<%=cid%> = (java.util.Map)inMessage<%=cid%>.readObject();
<%
}
if(isCommit){
%>
qMgr_<%=cid%>.commit();
<%
}
}
%>

View File

@@ -1,113 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.core.model.process.IConnection
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.IConnectionCategory
org.talend.core.model.utils.NodeUtil
java.util.List
"
class="MomInput"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
boolean isExistConnection = ("true").equals(ElementParameterParser.getValue(node, "__USE_CONNECTION__"));
String connection = ElementParameterParser.getValue(node, "__CONNECTION__");
String serverType=ElementParameterParser.getValue(node, "__SERVER__");
if(isExistConnection){
INode connectionComponent = NodeUtil.getNodeByUniqueName(node.getProcess(),connection);
serverType=ElementParameterParser.getValue(connectionComponent, "__SERVER__");
}
String host=ElementParameterParser.getValue(node, "__SERVERADDRESS__");
String port=ElementParameterParser.getValue(node, "__SERVERPORT__");
String dbuser= ElementParameterParser.getValue(node, "__USER__");
IMetadataTable metadata=null;
List<IMetadataTable> metadatas = node.getMetadataList();
if ((metadatas!=null)&&(metadatas.size()>0)) {
metadata = metadatas.get(0);
}
%>
int nb_line_<%=cid%> = 0;
<%
if(("WebSphere").equals(serverType)){
%>
com.ibm.mq.MQQueueManager qMgr_<%=cid%>=null;
com.ibm.mq.MQQueue remoteQ_<%=cid%>=null;
java.util.List<String> idList_<%=cid%> = new java.util.ArrayList<String>();
try{
<%
if(isExistConnection){
%>
qMgr_<%=cid%> = (com.ibm.mq.MQQueueManager)globalMap.get("qMgr_<%=connection%>");
<%
}else{
String channel=ElementParameterParser.getValue(node, "__CHANNEL__");
String qm=ElementParameterParser.getValue(node, "__QM__");
%>
java.util.Hashtable properties_<%=cid%>=new java.util.Hashtable();
properties_<%=cid%>.put("hostname", <%=host%>);
properties_<%=cid%>.put("port", Integer.valueOf(<%=port%>));
properties_<%=cid%>.put("channel", <%=channel%>);
properties_<%=cid%>.put("CCSID", new Integer(1208));
properties_<%=cid%>.put("transport","MQSeries");
<%
if(!(dbuser == null) && !("\"\"").equals(dbuser) && !("").equals(dbuser)) {
%>
properties_<%=cid%>.put("userID",<%=dbuser%>);
<%
String passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
properties_<%=cid%>.put("password",decryptedPassword_<%=cid%>);
<%
}
%>
qMgr_<%=cid%>=new com.ibm.mq.MQQueueManager(<%=qm%>,properties_<%=cid%>);
<%
}
String queue = ElementParameterParser.getValue(node, "__QUEUE__");
%>
int openOptions_<%=cid%>=com.ibm.mq.MQC.MQOO_FAIL_IF_QUIESCING | com.ibm.mq.MQC.MQOO_INPUT_AS_Q_DEF;
com.ibm.mq.MQGetMessageOptions gmo_<%=cid%>=new com.ibm.mq.MQGetMessageOptions();
gmo_<%=cid%>.options=gmo_<%=cid%>.options+com.ibm.mq.MQC.MQGMO_SYNCPOINT;
gmo_<%=cid%>.options=gmo_<%=cid%>.options+com.ibm.mq.MQC.MQGMO_NO_WAIT;
gmo_<%=cid%>.options=gmo_<%=cid%>.options+com.ibm.mq.MQC.MQGMO_FAIL_IF_QUIESCING;
gmo_<%=cid%>.waitInterval=com.ibm.mq.MQC.MQWI_UNLIMITED;
com.ibm.mq.MQException.log = null;
boolean flag_<%=cid%>=true;
while(flag_<%=cid%>){
remoteQ_<%=cid%>=qMgr_<%=cid%>.accessQueue(<%=queue%>,openOptions_<%=cid%>);
com.ibm.mq.MQMessage inMessage_<%=cid%>=new com.ibm.mq.MQMessage();
remoteQ_<%=cid%>.get(inMessage_<%=cid%>,gmo_<%=cid%>);
idList_<%=cid%>.add(new String(inMessage_<%=cid%>.messageId,"ISO-8859-15"));
remoteQ_<%=cid%>.close();
}
}catch(com.ibm.mq.MQException me_<%=cid%>){
if (me_<%=cid%>.reasonCode == com.ibm.mq.MQException.MQRC_NO_MSG_AVAILABLE) {
remoteQ_<%=cid%>.close();
qMgr_<%=cid%>.backout();
qMgr_<%=cid%>.disconnect();
}else{
throw me_<%=cid%>;
}
}
for(String tmpId_<%=cid%> : idList_<%=cid%>){
nb_line_<%=cid%> ++;
globalMap.put("<%=cid%>_CURRENT_MESSAGE_ID", tmpId_<%=cid%>);
<%
}
%>

View File

@@ -1,96 +0,0 @@
<COMPONENT>
<HEADER
PLATEFORM="ALL"
SERIAL=""
VERSION="0.102"
STATUS="ALPHA"
COMPATIBILITY="ALL"
AUTHOR="Talend"
RELEASE_DATE="20050320A"
STARTABLE="true"
>
<SIGNATURE />
</HEADER>
<FAMILIES>
<FAMILY>Internet/MOM and JMS</FAMILY>
</FAMILIES>
<DOCUMENTATION>
<URL />
</DOCUMENTATION>
<CONNECTORS>
<CONNECTOR CTYPE="FLOW" MAX_OUTPUT="0" MAX_INPUT="0" />
<CONNECTOR CTYPE="ITERATE" MAX_INPUT="1" />
<CONNECTOR CTYPE="SUBJOB_OK" MAX_INPUT="1" />
<CONNECTOR CTYPE="SUBJOB_ERROR" MAX_INPUT="1" />
<CONNECTOR CTYPE="COMPONENT_OK" />
<CONNECTOR CTYPE="COMPONENT_ERROR" />
<CONNECTOR CTYPE="RUN_IF" />
</CONNECTORS>
<PARAMETERS>
<PARAMETER NAME="USE_CONNECTION" FIELD="CHECK" NUM_ROW="1">
<DEFAULT>false</DEFAULT>
</PARAMETER>
<PARAMETER NAME="CONNECTION" FIELD="COMPONENT_LIST" REQUIRED="true" FILTER="tMomConnection" NUM_ROW="1"
SHOW_IF="USE_CONNECTION == 'true'" DYNAMIC_SETTINGS="true" />
<PARAMETER NAME="NOTE_CUSTOMER" FIELD="LABEL" NUM_ROW="2" COLOR="255;0;0"
SHOW_IF="((USE_CONNECTION == 'true') AND (#LINK@NODE.CONNECTION.SERVER != 'WEBSPHERE'))">
<DEFAULT>Connection server type is incorrect!
This component only support Websphere MQ currently!
</DEFAULT>
</PARAMETER>
<PARAMETER NAME="SERVER" FIELD="CLOSED_LIST" NUM_ROW="20" SHOW_IF="(USE_CONNECTION == 'false')">
<ITEMS DEFAULT="WEBSPHERE">
<ITEM NAME="WEBSPHERE" VALUE="WebSphere" />
</ITEMS>
</PARAMETER>
<PARAMETER NAME="SERVERADDRESS" FIELD="TEXT" NUM_ROW="20" SHOW_IF="(USE_CONNECTION == 'false')">
<DEFAULT>"localhost"</DEFAULT>
</PARAMETER>
<PARAMETER NAME="SERVERPORT" FIELD="TEXT" NUM_ROW="20" SHOW_IF="(USE_CONNECTION == 'false')">
<DEFAULT IF="(SERVER == 'WEBSPHERE')">"1414"</DEFAULT>
</PARAMETER>
<PARAMETER NAME="CHANNEL" FIELD="TEXT" NUM_ROW="30"
SHOW_IF="(USE_CONNECTION == 'false') AND (SERVER == 'WEBSPHERE')">
<DEFAULT>"DC.SVRCONN"</DEFAULT>
</PARAMETER>
<PARAMETER NAME="QM" FIELD="TEXT" NUM_ROW="50"
SHOW_IF="(USE_CONNECTION == 'false') AND (SERVER == 'WEBSPHERE')">
<DEFAULT>""</DEFAULT>
</PARAMETER>
<PARAMETER NAME="QUEUE" FIELD="TEXT" NUM_ROW="50"
SHOW_IF="(((USE_CONNECTION == 'true') and (#LINK@NODE.CONNECTION.SERVER== 'WEBSPHERE')) OR ((USE_CONNECTION == 'false') and (SERVER == 'WEBSPHERE')))">
<DEFAULT>""</DEFAULT>
</PARAMETER>
</PARAMETERS>
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="MQ" MODULE="com.ibm.mq.jar" REQUIRED_IF="(USE_CONNECTION=='false' AND SERVER == 'WEBSPHERE')" />
<IMPORT NAME="MQJMS" MODULE="com.ibm.mqjms.jar" REQUIRED_IF="(USE_CONNECTION=='false' AND SERVER == 'WEBSPHERE')" />
<IMPORT NAME="WEBSPHERE CONNECTOR" MODULE="websphere-connector-1_5.jar" REQUIRED_IF="(USE_CONNECTION=='false' AND SERVER == 'WEBSPHERE')" />
<IMPORT NAME="Java Message Service" MODULE="jms.jar" UrlPath="platform:/plugin/org.talend.libraries.esb.ext/lib/jms.jar" REQUIRED_IF="(USE_CONNECTION=='false' AND SERVER == 'WEBSPHERE')" />
</IMPORTS>
</CODEGENERATION>
<RETURNS>
<RETURN NAME="CURRENT_MESSAGE_ID" TYPE="id_String" AVAILABILITY="FLOW" />
<RETURN NAME="NB_LINE" TYPE="id_Integer" AVAILABILITY="AFTER" />
</RETURNS>
</COMPONENT>

View File

@@ -1,103 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.designer.codegen.config.CodeGeneratorArgument
java.util.List
java.util.Map
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
List<Map<String, String>> filelist = (List<Map<String,String>>)ElementParameterParser.getObjectValue(node, "__FILELIST__");
boolean dieOnError = "true".equals(ElementParameterParser.getValue(node, "__DIE_ON_ERROR__"));
if(dieOnError){
%>
boolean isCmdFailed_<%= cid %> = false;
<%
}
%>
StringBuilder command_<%=cid %> = new StringBuilder("rm -f");
ch.ethz.ssh2.Session sessNew_<%=cid%> = conn_<%=cid%>.openSession();
<%
for(Map<String,String> map : filelist){
%>
command_<%=cid %>.append(" ");
command_<%=cid %>.append("\"");
command_<%=cid %>.append(<%= map.get("SOURCE") %>);
command_<%=cid %>.append("\"");
nb_file_<%=cid %> ++;
<%
}
%>
String rmCmd_<%= cid %> = command_<%=cid %>.toString();
if(!"rm -f".equals(rmCmd_<%= cid %>)){
sessNew_<%=cid%>.execCommand(rmCmd_<%= cid %>);
<% if(dieOnError){ %>
StringBuilder errMsg_<%= cid %> = new StringBuilder("File(s) deleting failed.");
int returnCondition_<%= cid %> = sessNew_<%=cid%>.waitForCondition(ch.ethz.ssh2.ChannelCondition.EXIT_STATUS,300L);
Integer exitCode_<%= cid %> = sessNew_<%=cid%>.getExitStatus();
if((returnCondition_<%= cid %> & ch.ethz.ssh2.ChannelCondition.EXIT_STATUS) == ch.ethz.ssh2.ChannelCondition.EXIT_STATUS){
if (exitCode_<%= cid %> != 0) {
isCmdFailed_<%= cid %> = true;
errMsg_<%= cid %>.append("Exit code: ");
errMsg_<%= cid %>.append(exitCode_<%= cid %>);
}
}else if((returnCondition_<%= cid %> & ch.ethz.ssh2.ChannelCondition.TIMEOUT) == ch.ethz.ssh2.ChannelCondition.TIMEOUT){
isCmdFailed_<%= cid %> = true;
errMsg_<%= cid %>.append("The request timeout.");
}else if((returnCondition_<%= cid %> & ch.ethz.ssh2.ChannelCondition.CLOSED) == ch.ethz.ssh2.ChannelCondition.CLOSED){
isCmdFailed_<%= cid %> = true;
errMsg_<%= cid %>.append("Unexpected closed session.");
}else{
System.err.println("Unexpected error.");
isCmdFailed_<%= cid %> = true;
}
<% } %>
java.io.InputStream stderr_<%=cid%> = sessNew_<%=cid%>.getStderr();
java.io.BufferedReader breer_<%=cid%>= new java.io.BufferedReader(new java.io.InputStreamReader(stderr_<%=cid%>));
String line_err_<%=cid%> = "";
StringBuilder stringStderr_<%=cid%> =new StringBuilder();
while((line_err_<%=cid%> = breer_<%=cid%>.readLine()) != null) {
String errInfo_<%= cid %> = new String(line_err_<%=cid%>.getBytes(),"UTF-8");
System.err.println(errInfo_<%= cid %>);
stringStderr_<%=cid%>.append(line_err_<%=cid%> + "\n");
}
String stderrString_<%=cid %> = stringStderr_<%=cid %>.toString();
<% if(dieOnError){
%>
if(stderrString_<%=cid %> != null && stderrString_<%=cid %>.length() > 0){
isCmdFailed_<%= cid %> = true;
}
if(isCmdFailed_<%= cid %>){
throw new RuntimeException(errMsg_<%= cid %>.toString());
}
<%
}
%>
<%for (int i = 0;i<filelist.size();i++) {%>
if(stderrString_<%=cid %>.contains(<%=filelist.get(i).get("SOURCE")%>)){
nb_file_<%=cid %> --;
}
<%}%>
breer_<%=cid%>.close();
stderr_<%=cid%>.close();
if("".equals(stderrString_<%=cid %>) || (stderrString_<%=cid %> == null)){
globalMap.put("<%=cid %>_STATUS","File(s) deleted OK");
}else{
globalMap.put("<%=cid %>_STATUS",stringStderr_<%=cid %>.toString());
}
}else{
globalMap.put("<%=cid %>_STATUS","No file to be deleted.");
}
sessNew_<%=cid%>.close();

View File

@@ -1,275 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.IConnection
org.talend.core.model.process.IConnectionCategory
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
org.talend.core.model.utils.TalendTextUtils
java.util.List
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String endpoint = ElementParameterParser.getValue(node, "__ENDPOINT__");
String apiVersion = ElementParameterParser.getValue(node, "__API_VERSION__");
String username = ElementParameterParser.getValue(node, "__USER__");
String sObject = ElementParameterParser.getValue(node, "__MODULENAME__");
String customModulename = ElementParameterParser.getValue(node, "__CUSTOM_MODULE_NAME__");
if ("CustomModule".equals(sObject)) {
//modulename = customModulename;
sObject = customModulename;
}else{
sObject = "\""+sObject+"\"";
}
String action = ElementParameterParser.getValue(node, "__ACTION__");
String externalId = ElementParameterParser.getValue(node, "__UPSERT_KEY_COLUMN__");
//String contentType = ElementParameterParser.getValue(node, "__CONTENTTYPE__");
String contentType = "csv";
String bulkFileName = ElementParameterParser.getValue(node, "__BULKFILENAME__").trim();
String maxBytes = ElementParameterParser.getValue(node,"__COMMIT_LEVEL_BYTES__");
String maxRows = ElementParameterParser.getValue(node,"__COMMIT_LEVEL_ROWS__");
boolean useProxy = ("true").equals(ElementParameterParser.getValue(node,"__USE_PROXY__"));
String proxyHost = ElementParameterParser.getValue(node,"__PROXY_HOST__");
String proxyPort = ElementParameterParser.getValue(node,"__PROXY_PORT__");
String proxyUsername = ElementParameterParser.getValue(node,"__PROXY_USERNAME__");
String proxyPassword = ElementParameterParser.getValue(node,"__PROXY_PASSWORD__");
boolean useExistingConn = ("true").equals(ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__"));
String connection = ElementParameterParser.getValue(node,"__CONNECTION__");
String concurrencyMode = ElementParameterParser.getValue(node,"__CONCURRENCY_MODE__");
String awaitTime = ElementParameterParser.getValue(node,"__AWAIT_TIME__");
boolean bulkConnection = true; //for tSalesforceOAuth.javajet
String passwordFieldName = "";
String loginType = ElementParameterParser.getValue(node,"__LOGIN_TYPE__");
boolean useOAuth = "OAUTH".equals(loginType);
%>
int nb_line_<%=cid %> = 0;
int nb_success_<%=cid%> = 0;
int nb_reject_<%=cid%> = 0;
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
org.talend.salesforceBulk.SforceBulkConnection sforceConn_<%=cid%> = null;
<%
if(useExistingConn){
%>
if(globalMap.get("conn_<%=connection%>")==null){
throw new RuntimeException("Get null connection from <%=connection %>");
}
sforceConn_<%=cid%> = (org.talend.salesforceBulk.SforceBulkConnection)globalMap.get("conn_<%=connection %>");
<%
}else{
if(useOAuth){
String oauthKey = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_ID__");
String oauthSecret = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_SECRET__");
passwordFieldName = "__OAUTH_CLIENT_SECRET__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedQauthClientPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedQauthClientPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
String tokenFile = ElementParameterParser.getValue(node,"__OAUTH_TOKEN_FILE__");
String callbackHost = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_HOST__");
String callbackPort = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_PORT__");
%>
sforceConn_<%=cid%>
= new org.talend.salesforceBulk.SforceOAuthBulkConnection.Builder(<%=endpoint%>, <%=oauthKey%>, decryptedQauthClientPwd_<%=cid%>, <%=apiVersion%>, <%=callbackHost%>, <%=callbackPort%>)
<%
if(!"".equals(tokenFile) && !"\"\"".equals(tokenFile)){
%>
.setTokenFilePath(<%=tokenFile%>)
<%
}
%>
.build();
<%
}else{
passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
<%
if(useProxy){
passwordFieldName = "__PROXY_PASSWORD__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
%>
<%
}
%>
sforceConn_<%=cid%>
= new org.talend.salesforceBulk.SforceBasicBulkConnection.Builder(<%=endpoint%>,<%=username%>,decryptedPassword_<%=cid%>,<%=apiVersion%>)
<%
if(useProxy){
%>
.setProxy(true,<%=proxyHost%>,<%=TalendTextUtils.removeQuotes(proxyPort)%>,<%=proxyUsername%>,decryptedPwd_<%=cid%>)
<%
}
%>
.build();
<%
}
}
%>
org.talend.salesforceBulk.SalesforceBulkAPI sforceBulk_<%=cid%> = new org.talend.salesforceBulk.SalesforceBulkAPI(sforceConn_<%=cid%>);
sforceBulk_<%=cid%>.setConcurrencyMode("<%=concurrencyMode%>");
sforceBulk_<%=cid%>.setAwaitTime(<%=awaitTime%>);
sforceBulk_<%=cid%>.executeBulk(<%=sObject%>,"<%=action%>",<%=externalId%>,"<%=contentType%>",<%=bulkFileName%>,<%=maxBytes%>,<%=maxRows%>);
<%
List<IMetadataTable> metadatas = node.getMetadataList();
if ((metadatas!=null)&&(metadatas.size()>0)) {//1
IMetadataTable metadata = metadatas.get(0);
if (metadata!=null) {//2
%>
int j_<%=cid%>=0;
int batchCount_<%=cid%> = sforceBulk_<%=cid%>.getBatchCount();
for(int i = 0; i < batchCount_<%=cid%>; i++){
java.util.List<java.util.Map<String,String>> resultListMessage_<%=cid%> = sforceBulk_<%=cid%>.getBatchLog(i);
for(java.util.Map<String,String> resultMessage_<%=cid%> : resultListMessage_<%=cid%>){
j_<%=cid%>++;
<%
List<? extends IConnection> outgoingConns = node.getOutgoingSortedConnections();
if(outgoingConns!=null){
for (int i=0;i<outgoingConns.size();i++) {
IConnection outgoingConn = outgoingConns.get(i);
if (outgoingConn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
%>
<%=outgoingConn.getName() %> = null;
<%
}
}
}
List<? extends IConnection> connsSuccess = node.getOutgoingConnections("MAIN");
List<? extends IConnection> connsReject = node.getOutgoingConnections("REJECT");
%>
if("true".equals(resultMessage_<%=cid%>.get("Success"))){
<%
if (connsSuccess != null && connsSuccess.size() == 1) {
IConnection connSuccess = connsSuccess.get(0);
if (connSuccess.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
%>
nb_success_<%=cid %>++;
<%=connSuccess.getName() %> = new <%=connSuccess.getName() %>Struct();
<%=connSuccess.getName() %>.salesforce_created = resultMessage_<%=cid%>.get("Created");
<%=connSuccess.getName() %>.salesforce_id = resultMessage_<%=cid%>.get("Id");
<%
for (IMetadataColumn column: metadata.getListColumns()) {
String typeToGenerate = JavaTypesManager.getTypeToGenerate(column.getTalendType(), column.isNullable());
JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
String pattern = column.getPattern() == null || column.getPattern().trim().length() == 0 ? null : column.getPattern();
%>
if("#N/A".equals(String.valueOf(resultMessage_<%=cid%>.get("<%=column.getLabel() %>")))){
resultMessage_<%=cid%>.put("<%=column.getLabel() %>",null);
}
<%
if(javaType == JavaTypesManager.STRING ){
%>
<%=connSuccess.getName() %>.<%=column.getLabel() %> = resultMessage_<%=cid%>.get("<%=column.getLabel() %>");
<%
}else if(javaType == JavaTypesManager.DATE){
%>
<%=connSuccess.getName() %>.<%=column.getLabel() %> = ParserUtils.parseTo_Date(resultMessage_<%=cid%>.get("<%=column.getLabel() %>"), <%= pattern %>);
<%
}else if(JavaTypesManager.isNumberType(javaType)) {
%>
<%=connSuccess.getName() %>.<%=column.getLabel() %> = ParserUtils.parseTo_<%=typeToGenerate%>(resultMessage_<%=cid%>.get("<%=column.getLabel() %>"));
<%
}else {
%>
<%=connSuccess.getName() %>.<%=column.getLabel() %> = ParserUtils.parseTo_<%=typeToGenerate%>(resultMessage_<%=cid%>.get("<%=column.getLabel() %>"));
<%
}
}
%>
<%
}
}
%>
}else{
<%
if (connsReject != null && connsReject.size() == 1) {
IConnection connReject = connsReject.get(0);
if (connReject.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
%>
nb_reject_<%=cid %>++;
<%=connReject.getName() %> = new <%=connReject.getName() %>Struct();
<%=connReject.getName() %>.error = resultMessage_<%=cid%>.get("Error");
<%
for (IMetadataColumn column: metadata.getListColumns()) {
String typeToGenerate = JavaTypesManager.getTypeToGenerate(column.getTalendType(), column.isNullable());
JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
String pattern = column.getPattern() == null || column.getPattern().trim().length() == 0 ? null : column.getPattern();
%>
if("#N/A".equals(String.valueOf(resultMessage_<%=cid%>.get("<%=column.getLabel() %>")))){
resultMessage_<%=cid%>.put("<%=column.getLabel() %>", null);
}
<%
if(javaType == JavaTypesManager.STRING ){
%>
<%=connReject.getName() %>.<%=column.getLabel() %> = resultMessage_<%=cid%>.get("<%=column.getLabel() %>");
<%
}else if(javaType == JavaTypesManager.DATE && pattern != null){
%>
<%=connReject.getName() %>.<%=column.getLabel() %> = ParserUtils.parseTo_Date(resultMessage_<%=cid%>.get("<%=column.getLabel() %>"), <%= pattern %>);
<%
}else if(JavaTypesManager.isNumberType(javaType)) {
%>
<%=connReject.getName() %>.<%=column.getLabel() %> = ParserUtils.parseTo_<%=typeToGenerate%>(resultMessage_<%=cid%>.get("<%=column.getLabel() %>"));
<%
}else {
%>
<%=connReject.getName() %>.<%=column.getLabel() %> = ParserUtils.parseTo_<%=typeToGenerate%>(resultMessage_<%=cid%>.get("<%=column.getLabel() %>"));
<%
}
}
%>
<%
}
}else{
%>
System.err.print("Row "+j_<%=cid%>+":"+resultMessage_<%=cid%>.get("Error"));
<%
}
%>
<%
}//2
}//1
%>
}

View File

@@ -1,194 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.process.INode
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.utils.TalendTextUtils
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String endpoint = ElementParameterParser.getValue(node, "__ENDPOINT__");
String username = ElementParameterParser.getValue(node, "__USER__");
String timeout = ElementParameterParser.getValue(node,"__TIMEOUT__");
boolean needCompression = ("true").equals(ElementParameterParser.getValue(node,"__NEED_COMPRESSION__"));
boolean httpTraceMessage = ("true").equals(ElementParameterParser.getValue(node,"__HTTP_TRACEMESSAGE__"));
boolean useProxy = ("true").equals(ElementParameterParser.getValue(node,"__USE_PROXY__"));
String proxyHost = ElementParameterParser.getValue(node,"__PROXY_HOST__");
String proxyPort = ElementParameterParser.getValue(node,"__PROXY_PORT__");
String proxyUsername = ElementParameterParser.getValue(node,"__PROXY_USERNAME__");
boolean bulkConnection = ("true").equals(ElementParameterParser.getValue(node,"__BULK_CONNECTION__"));
String apiVersion = ElementParameterParser.getValue(node,"__API_VERSION__");
String clientID = ElementParameterParser.getValue(node,"__CLIENT_ID__");
%>
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
<%
String passwordFieldName = "";
String loginType = ElementParameterParser.getValue(node,"__LOGIN_TYPE__");
boolean useOAuth = "OAUTH".equals(loginType);
if(bulkConnection){
%>
<%
if(useOAuth){
String oauthKey = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_ID__");
String oauthSecret = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_SECRET__");
passwordFieldName = "__OAUTH_CLIENT_SECRET__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedQauthClientPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedQauthClientPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
String tokenFile = ElementParameterParser.getValue(node,"__OAUTH_TOKEN_FILE__");
String callbackHost = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_HOST__");
String callbackPort = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_PORT__");
%>
org.talend.salesforceBulk.SforceBulkConnection sforceConn_<%=cid%>
= new org.talend.salesforceBulk.SforceOAuthBulkConnection.Builder(<%=endpoint%>, <%=oauthKey%>, decryptedQauthClientPwd_<%=cid%>, <%=apiVersion%>, <%=callbackHost%>, <%=callbackPort%>)
<%
if(!"".equals(tokenFile) && !"\"\"".equals(tokenFile)){
%>
.setTokenFilePath(<%=tokenFile%>)
<%
}
%>
.needCompression(<%=needCompression%>).needTraceMessage(<%=httpTraceMessage%>)
.build();
<%
}else{
passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
<%
if(useProxy){
passwordFieldName = "__PROXY_PASSWORD__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
%>
<%
}
%>
org.talend.salesforceBulk.SforceBulkConnection sforceConn_<%=cid%>
= new org.talend.salesforceBulk.SforceBasicBulkConnection.Builder(<%=endpoint%>,<%=username%>,decryptedPassword_<%=cid%>,<%=apiVersion%>)
.needCompression(<%=needCompression%>).needTraceMessage(<%=httpTraceMessage%>)
<%
if(useProxy){
%>
.setProxy(true,<%=proxyHost%>,<%=TalendTextUtils.removeQuotes(proxyPort)%>,<%=proxyUsername%>,decryptedPwd_<%=cid%>)
<%
}
%>
.build();
<%
}
%>
globalMap.put("conn_<%=cid%>", sforceConn_<%=cid%>);
<%
}else{
%>
<%
if(useOAuth){
String oauthKey = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_ID__");
String oauthSecret = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_SECRET__");
passwordFieldName = "__OAUTH_CLIENT_SECRET__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedQauthClientPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedQauthClientPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
String tokenFile = ElementParameterParser.getValue(node,"__OAUTH_TOKEN_FILE__");
String callbackHost = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_HOST__");
String callbackPort = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_PORT__");
%>
org.talend.salesforce.SforceConnection sforceConn_<%=cid%>
= new org.talend.salesforce.SforceOAuthConnection.Builder(<%=endpoint%>, <%=oauthKey%>, decryptedQauthClientPwd_<%=cid%>, <%=apiVersion%>, <%=callbackHost%>, <%=callbackPort%>)
<%
if(!"".equals(tokenFile) && !"\"\"".equals(tokenFile)){
%>
.setTokenFilePath(<%=tokenFile%>)
<%
}
%>
.setTimeout(<%=timeout%>).needCompression(<%=needCompression%>)
<%
if(clientID != null && !"".equals(clientID) && !"\"\"".equals(clientID)){
%>
.setClientID(<%=clientID%>);
<%
}
%>
.build();
<%
}else{
if(useProxy){
passwordFieldName = "__PROXY_PASSWORD__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
%>
java.util.Properties props_<%=cid%> = System.getProperties();
props_<%=cid%>.put("socksProxyHost",<%=proxyHost%>);
props_<%=cid%>.put("socksProxyPort",<%=proxyPort%>);
props_<%=cid%>.put("java.net.socks.username", <%=proxyUsername%>);
props_<%=cid%>.put("java.net.socks.password", decryptedPwd_<%=cid%>);
<%
}
%>
<%
passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
org.talend.salesforce.SforceConnection sforceConn_<%=cid%>
= new org.talend.salesforce.SforceBasicConnection.Builder(<%=endpoint%>, <%=username%>, decryptedPassword_<%=cid%>)
.setTimeout(<%=timeout%>).needCompression(<%=needCompression%>)
<%
if(clientID!=null && !"".equals(clientID) && !"\"\"".equals(clientID)){
%>
.setClientID(<%=clientID%>);
<%
}
%>
.build();
<%
}
%>
globalMap.put("conn_<%=cid%>", sforceConn_<%=cid%>);
<%
}
%>

View File

@@ -1,156 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.IConnection
java.util.List
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
boolean useProxy = ("true").equals(ElementParameterParser.getValue(node,"__USE_PROXY__"));
String proxyHost = ElementParameterParser.getValue(node,"__PROXY_HOST__");
String proxyPort = ElementParameterParser.getValue(node,"__PROXY_PORT__");
String proxyUsername = ElementParameterParser.getValue(node,"__PROXY_USERNAME__");
boolean needCompression = ("true").equals(ElementParameterParser.getValue(node,"__NEED_COMPRESSION__"));
String cid = node.getUniqueName();
String passwordFieldName = "";
%>
int nb_line_<%=cid%> = 0;
<%
List<IMetadataTable> metadatas = node.getMetadataList();
if ((metadatas != null) && (metadatas.size() > 0)) {
IMetadataTable metadata = metadatas.get(0);
if (metadata != null) {
List<? extends IConnection> outgoingConns = node.getOutgoingSortedConnections();
if (outgoingConns != null && outgoingConns.size() > 0){
String endpoint = ElementParameterParser.getValue(node, "__ENDPOINT__");
String username = ElementParameterParser.getValue(node, "__USER__");
String timeout = ElementParameterParser.getValue(node,"__TIMEOUT__");
boolean useExistingConn = ("true").equals(ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__"));
String connection = ElementParameterParser.getValue(node,"__CONNECTION__");
String clientID = ElementParameterParser.getValue(node,"__CLIENT_ID__");
boolean bulkConnection = false; //for tSalesforceOAuth.javajet
String apiVersion = ElementParameterParser.getValue(node,"__API_VERSION__");
String loginType = ElementParameterParser.getValue(node,"__LOGIN_TYPE__");
boolean useOAuth = "OAUTH".equals(loginType);
%>
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
org.talend.salesforce.SforceConnection sforceConn_<%=cid%> = null;
<%if(useExistingConn){%>
if(globalMap.get("conn_<%=connection%>") == null){
throw new RuntimeException("Get null connection from <%=connection%>");
}
sforceConn_<%=cid%> = (org.talend.salesforce.SforceConnection)globalMap.get("conn_<%=connection%>");
<%}else{
if(useOAuth){
String oauthKey = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_ID__");
String oauthSecret = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_SECRET__");
%>
<%
passwordFieldName = "__OAUTH_CLIENT_SECRET__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedQauthClientPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedQauthClientPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
String tokenFile = ElementParameterParser.getValue(node,"__OAUTH_TOKEN_FILE__");
String callbackHost = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_HOST__");
String callbackPort = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_PORT__");
%>
try{
sforceConn_<%=cid%> =
new org.talend.salesforce.SforceOAuthConnection.Builder(<%=endpoint%>, <%=oauthKey%>, decryptedQauthClientPwd_<%=cid%>, <%=apiVersion%>, <%=callbackHost%>, <%=callbackPort%>)
<%
if(!"".equals(tokenFile) && !"\"\"".equals(tokenFile)){
%>
.setTokenFilePath(<%=tokenFile%>)
<%
}
%>
.setTimeout(<%=timeout%>).needCompression(<%=needCompression%>)
<%
if(clientID != null && !"".equals(clientID) && !"\"\"".equals(clientID)){
%>
.setClientID(<%=clientID%>);
<%
}
%>
.build();
}catch(Exception e){
throw e;
}
<%
}else{
if(useProxy){
passwordFieldName = "__PROXY_PASSWORD__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
%>
java.util.Properties props_<%=cid%> = System.getProperties();
props_<%=cid%>.put("socksProxyHost",<%=proxyHost %>);
props_<%=cid%>.put("socksProxyPort",<%=proxyPort %>);
props_<%=cid%>.put("java.net.socks.username", <%=proxyUsername %>);
props_<%=cid%>.put("java.net.socks.password", decryptedPwd_<%=cid%>);
<%
}
%>
<%
passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
try{
sforceConn_<%=cid%> =
new org.talend.salesforce.SforceBasicConnection.Builder(<%=endpoint%>, <%=username%>, decryptedPassword_<%=cid%>)
.setTimeout(<%=timeout%>).needCompression(<%=needCompression%>)
<%
if(clientID!=null && !"".equals(clientID) && !"\"\"".equals(clientID)){
%>
.setClientID(<%=clientID%>);
<%
}
%>
.build();
}catch(Exception e){
throw e;
}
<%
}
%>
<%
}
%>
org.talend.salesforce.SforceManagement sfMgr_<%=cid%> = new org.talend.salesforce.SforceManagementImpl(sforceConn_<%=cid%>);
<%
}
}
}
%>

View File

@@ -1,265 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.IConnection
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.metadata.types.JavaType
org.talend.core.model.process.IConnectionCategory
java.util.List
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
boolean useProxy = ("true").equals(ElementParameterParser.getValue(node,"__USE_PROXY__"));
String proxyHost = ElementParameterParser.getValue(node,"__PROXY_HOST__");
String proxyPort = ElementParameterParser.getValue(node,"__PROXY_PORT__");
String proxyUsername = ElementParameterParser.getValue(node,"__PROXY_USERNAME__");
boolean needCompression = ("true").equals(ElementParameterParser.getValue(node,"__NEED_COMPRESSION__"));
String cid = node.getUniqueName();
String passwordFieldName = "";
%>
int nb_line_<%=cid%> = 0;
<%
List<IMetadataTable> metadatas = node.getMetadataList();
if ((metadatas != null) && (metadatas.size() > 0)) {
IMetadataTable metadata = metadatas.get(0);
if (metadata != null) {
List<IMetadataColumn> columnList = metadata.getListColumns();
List<? extends IConnection> outgoingConns = node.getOutgoingSortedConnections();
if (outgoingConns != null && outgoingConns.size() > 0){
String sd = ElementParameterParser.getValue(node, "__START_DATE__");
String ed = ElementParameterParser.getValue(node, "__END_DATE__");
String username = ElementParameterParser.getValue(node, "__USER__");
String timeout = ElementParameterParser.getValue(node,"__TIMEOUT__");
String module = ElementParameterParser.getValue(node, "__MODULENAME__");
String customModulename = ElementParameterParser.getValue(node, "__CUSTOM_MODULE_NAME__").trim();
module = (("CustomModule").equals(module)) ? customModulename : "\""+module+"\"";
String endpoint = ElementParameterParser.getValue(node, "__ENDPOINT__");
boolean useExistingConn = ("true").equals(ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__"));
String connection = ElementParameterParser.getValue(node,"__CONNECTION__");
String clientID = ElementParameterParser.getValue(node,"__CLIENT_ID__");
boolean bulkConnection = false; //for tSalesforceOAuth.javajet
String apiVersion = ElementParameterParser.getValue(node,"__API_VERSION__");
String loginType = ElementParameterParser.getValue(node,"__LOGIN_TYPE__");
boolean useOAuth = "OAUTH".equals(loginType);
%>
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
java.text.SimpleDateFormat startdf_<%=cid%> = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
java.text.SimpleDateFormat enddf_<%=cid%> = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
startdf_<%=cid%>.parse(<%=sd%>);
enddf_<%=cid%>.parse(<%=ed%>);
java.util.Calendar startCal_<%=cid%> = startdf_<%=cid%>.getCalendar();
java.util.Calendar endCal_<%=cid%> = enddf_<%=cid%>.getCalendar();
org.talend.salesforce.SforceConnection sforceConn_<%=cid%> = null;
<%if(useExistingConn){%>
if(globalMap.get("conn_<%=connection%>") == null){
throw new RuntimeException("Get null connection from <%=connection%>");
}
sforceConn_<%=cid%> = (org.talend.salesforce.SforceConnection)globalMap.get("conn_<%=connection%>");
<%
}else{
if(useOAuth){
String oauthKey = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_ID__");
String oauthSecret = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_SECRET__");
%>
<%
passwordFieldName = "__OAUTH_CLIENT_SECRET__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedQauthClientPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedQauthClientPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
String tokenFile = ElementParameterParser.getValue(node,"__OAUTH_TOKEN_FILE__");
String callbackHost = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_HOST__");
String callbackPort = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_PORT__");
%>
try{
sforceConn_<%=cid%> =
new org.talend.salesforce.SforceOAuthConnection.Builder(<%=endpoint%>, <%=oauthKey%>, decryptedQauthClientPwd_<%=cid%>, <%=apiVersion%>, <%=callbackHost%>, <%=callbackPort%>)
<%
if(!"".equals(tokenFile) && !"\"\"".equals(tokenFile)){
%>
.setTokenFilePath(<%=tokenFile%>)
<%
}
%>
.setTimeout(<%=timeout%>).needCompression(<%=needCompression%>)
<%
if(clientID != null && !"".equals(clientID) && !"\"\"".equals(clientID)){
%>
.setClientID(<%=clientID%>);
<%
}
%>
.build();
}catch(Exception e){
throw e;
}
<%
}else{
if(useProxy){
passwordFieldName = "__PROXY_PASSWORD__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
%>
java.util.Properties props_<%=cid%> = System.getProperties();
props_<%=cid%>.put("socksProxyHost",<%=proxyHost %>);
props_<%=cid%>.put("socksProxyPort",<%=proxyPort %>);
props_<%=cid%>.put("java.net.socks.username", <%=proxyUsername %>);
props_<%=cid%>.put("java.net.socks.password", decryptedPwd_<%=cid%>);
<%
}
%>
<%
passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
try{
sforceConn_<%=cid%> =
new org.talend.salesforce.SforceBasicConnection.Builder(<%=endpoint%>, <%=username%>, decryptedPassword_<%=cid%>)
.setTimeout(<%=timeout%>).needCompression(<%=needCompression%>)
<%
if(clientID!=null && !"".equals(clientID) && !"\"\"".equals(clientID)){
%>
.setClientID(<%=clientID%>);
<%
}
%>
.build();
}catch(Exception e){
throw e;
}
<%
}
%>
<%
}
%>
org.talend.salesforce.SforceManagement sfMgr_<%=cid%> = new org.talend.salesforce.SforceManagementImpl(sforceConn_<%=cid%>);
<%
java.lang.StringBuilder sb = new java.lang.StringBuilder();
for (IMetadataColumn column: columnList){
if(sb.length() == 0){
sb.append(column.getLabel());
}else{
sb.append(","+column.getLabel());
}
}
String fieldlist = sb.toString();
IConnection outgoingConn = outgoingConns.get(0);
if(outgoingConn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) { // start 1
%>
com.salesforce.soap.partner.sobject.SObject[] so_<%=cid%> = null;
com.salesforce.soap.partner.ID[] ids_<%=cid %> = sfMgr_<%=cid%>.getUpdated(<%=module%>, startCal_<%=cid%>, endCal_<%=cid%>);
if(ids_<%=cid %> !=null && ids_<%=cid %>.length > 0){
int newMax_<%=cid %> = 0;
int newBase_<%=cid %> = 0;
while (newMax_<%=cid %> < ids_<%=cid %>.length){
newBase_<%=cid %> = newMax_<%=cid %>;
newMax_<%=cid %> += 2000;
if (newMax_<%=cid %> > ids_<%=cid %>.length){
newMax_<%=cid %> = ids_<%=cid %>.length;
}
com.salesforce.soap.partner.ID[] localIds_<%=cid %> = new com.salesforce.soap.partner.ID[newMax_<%=cid %>-newBase_<%=cid %>];
for (int i_<%=cid %>=newBase_<%=cid %>;i_<%=cid %> < newMax_<%=cid %>;i_<%=cid %>++){
localIds_<%=cid %>[i_<%=cid %>-newBase_<%=cid %>] = ids_<%=cid %>[i_<%=cid %>];
}
so_<%=cid %> = sfMgr_<%=cid %>.retrieve(localIds_<%=cid %>,<%=module %>,"<%=fieldlist %>");
if(so_<%=cid%> != null){
for (int i_<%=cid %>=0;i_<%=cid %><so_<%=cid%>.length;i_<%=cid %>++){
nb_line_<%=cid%> ++;
if(so_<%=cid%>[i_<%=cid %>]!=null){
org.apache.axiom.om.OMElement[] fields_<%=cid %> = so_<%=cid%>[i_<%=cid %>].getExtraElement();
int len_<%=cid%> = fields_<%=cid %>.length;
<%
for( int i = 0; i < columnList.size(); i++) {
IMetadataColumn column = columnList.get(i);
String typeToGenerate = JavaTypesManager.getTypeToGenerate(column.getTalendType(), column.isNullable());
JavaType javaType = JavaTypesManager.getJavaTypeFromId(column.getTalendType());
String patternValue = column.getPattern() == null || column.getPattern().trim().length() == 0 ? null : column.getPattern();
%>
if (<%=i %> < len_<%=cid%> && fields_<%=cid %>[<%=i%>]!=null && fields_<%=cid %>[<%=i%>].getText() != null && !"".equals(fields_<%=cid %>[<%=i%>].getText())){
<%
if (javaType == JavaTypesManager.STRING || javaType == JavaTypesManager.OBJECT) { // String or Object
%>
<%=outgoingConn.getName()%>.<%=columnList.get(i).getLabel()%> = fields_<%=cid %>[<%=i%>].getText();
<%
} else if(javaType == JavaTypesManager.DATE) { // Date
%>
<%=outgoingConn.getName()%>.<%=columnList.get(i).getLabel()%> = ParserUtils.parseTo_Date(fields_<%=cid %>[<%=i%>].getText(), <%= patternValue %>);
<%
} else if(javaType == JavaTypesManager.BYTE_ARRAY) { // byte[]
%>
<%=outgoingConn.getName()%>.<%=columnList.get(i).getLabel()%> = fields_<%=cid %>[<%=i%>].getText().getBytes();
<%
} else { // other
%>
<%=outgoingConn.getName()%>.<%=columnList.get(i).getLabel()%> = ParserUtils.parseTo_<%= typeToGenerate %>(fields_<%=cid %>[<%=i%>].getText());
<%
}
%>
} else {
<%=outgoingConn.getName()%>.<%=columnList.get(i).getLabel()%> = <%=JavaTypesManager.getDefaultValueFromJavaType(typeToGenerate)%>;
}
<%
}
}
}
}
}
%>

View File

@@ -1,120 +0,0 @@
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.designer.codegen.config.CodeGeneratorArgument
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String endpoint = ElementParameterParser.getValue(node, "__ENDPOINT__");
String username = ElementParameterParser.getValue(node, "__USER__");
String action = ElementParameterParser.getValue(node, "__ACTION__");
String commitLevel = ElementParameterParser.getValue(node, "__COMMIT_LEVEL__");
boolean extendedInsert = ("true").equals(ElementParameterParser.getValue(node, "__EXTENDINSERT__"));
String logFile = ElementParameterParser.getValue(node, "__LOGFILENAME__").trim();
boolean ceaseForError = ("true").equals(ElementParameterParser.getValue(node, "__CEASE_FOR_ERROR__"));
boolean needCompression = ("true").equals(ElementParameterParser.getValue(node,"__NEED_COMPRESSION__"));
boolean useExistingConn = ("true").equals(ElementParameterParser.getValue(node,"__USE_EXISTING_CONNECTION__"));
String connection = ElementParameterParser.getValue(node,"__CONNECTION__");
String timeout = ElementParameterParser.getValue(node,"__TIMEOUT__");
String clientID = ElementParameterParser.getValue(node,"__CLIENT_ID__");
// if the extended insert is disabled set the commit level to 1
if (!extendedInsert) commitLevel = "1";
String passwordFieldName = "";
boolean bulkConnection = false; //for tSalesforceOAuth.javajet
String apiVersion = ElementParameterParser.getValue(node,"__API_VERSION__");
String loginType = ElementParameterParser.getValue(node,"__LOGIN_TYPE__");
boolean useOAuth = "OAUTH".equals(loginType);
%>
int nb_line_<%=cid %> = 0;
int nb_success_<%=cid%> = 0;
int nb_reject_<%=cid%> = 0;
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
org.talend.salesforce.SforceConnection sforceConn_<%=cid%> = null;
<%
if(useExistingConn){
%>
if(globalMap.get("conn_<%=connection%>") == null){
throw new RuntimeException("Get null connection from <%=connection%>");
}
sforceConn_<%=cid%> = (org.talend.salesforce.SforceConnection)globalMap.get("conn_<%=connection%>");
<%
}else{
if(useOAuth){
String oauthKey = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_ID__");
String oauthSecret = ElementParameterParser.getValue(node,"__OAUTH_CLIENT_SECRET__");
%>
<%
passwordFieldName = "__OAUTH_CLIENT_SECRET__";
if (ElementParameterParser.canEncrypt(node, passwordFieldName)) {
%>
String decryptedQauthClientPwd_<%=cid%> = routines.system.PasswordEncryptUtil.decryptPassword(<%=ElementParameterParser.getEncryptedValue(node, passwordFieldName)%>);
<%
} else {
%>
String decryptedQauthClientPwd_<%=cid%> = <%= ElementParameterParser.getValue(node, passwordFieldName)%>;
<%
}
String tokenFile = ElementParameterParser.getValue(node,"__OAUTH_TOKEN_FILE__");
String callbackHost = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_HOST__");
String callbackPort = ElementParameterParser.getValue(node,"__OAUTH_CALLBACK_PORT__");
%>
sforceConn_<%=cid%> =
new org.talend.salesforce.SforceOAuthConnection.Builder(<%=endpoint%>, <%=oauthKey%>, decryptedQauthClientPwd_<%=cid%>, <%=apiVersion%>, <%=callbackHost%>, <%=callbackPort%>)
<%
if(!"".equals(tokenFile) && !"\"\"".equals(tokenFile)){
%>
.setTokenFilePath(<%=tokenFile%>)
<%
}
%>
.setTimeout(<%=timeout%>).needCompression(<%=needCompression%>)
<%
if(clientID != null && !"".equals(clientID) && !"\"\"".equals(clientID)){
%>
.setClientID(<%=clientID%>);
<%
}
%>
.build();
<%
}else{
%>
<%
passwordFieldName = "__PASS__";
%>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
sforceConn_<%=cid%> =
new org.talend.salesforce.SforceBasicConnection.Builder(<%=endpoint%>, <%=username%>, decryptedPassword_<%=cid%>)
.setTimeout(<%=timeout%>).needCompression(<%=needCompression%>)
<%
if(clientID!=null && !"".equals(clientID) && !"\"\"".equals(clientID)){
%>
.setClientID(<%=clientID%>);
<%
}
%>
.build();
<%
}
%>
<%
}
%>
org.talend.salesforce.SforceManagement sforceManagement_<%=cid%> = new org.talend.salesforce.SforceManagementImpl(sforceConn_<%=cid%>, <%=commitLevel%>, <%=ceaseForError%>, <%=logFile%>);
<%if("upsert".equals(action)){%>
org.apache.axiom.om.OMFactory fac_<%=cid%> = org.apache.axiom.om.OMAbstractFactory.getOMFactory();
<%}%>

View File

@@ -1,248 +0,0 @@
<%@ jet
imports="
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
java.util.List
java.util.ArrayList
java.util.LinkedList
"
%>
<%@ include file="../templates/Log4j/Log4jDBConnUtil.javajet"%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String dbServer = ElementParameterParser.getValue(node, "__SERVER__");
String dbname= ElementParameterParser.getValue(node, "__DBNAME__");
String dbhost = ElementParameterParser.getValue(node, "__HOST__");
String dbuser= ElementParameterParser.getValue(node, "__USER__");
String tableName = ElementParameterParser.getValue(node,"__TABLE__");
String commitEvery = ElementParameterParser.getValue(node, "__COMMIT_EVERY__");
String dbproperties = ElementParameterParser.getValue(node, "__PROPERTIES__");
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
log4jCodeGenerateUtil.infoComponentStart(node);
log4jCodeGenerateUtil.initDbDebugRowBuffer();
%>
int nb_line_<%=cid%> = 0;
int nb_line_inserted_<%=cid%> = 0;
int insertedCount_<%=cid%>=0;
java.lang.Class.forName("com.teradata.jdbc.TeraDriver");
String url_<%=cid %> = "jdbc:teradata://" + <%=dbhost%>+"/TYPE=FASTLOAD";
String dbProperties_<%=cid%> = <%=dbproperties%>;
if(dbProperties_<%=cid%> != null && dbProperties_<%=cid%>.trim().length() > 0) {
url_<%=cid %> +=","+dbProperties_<%=cid%>;
}
<%
List<IMetadataColumn> columnList = null;
List<IMetadataTable> metadatas = node.getMetadataList();
if(metadatas !=null && metadatas.size()>0){
IMetadataTable metadata = metadatas.get(0);
if(metadata != null){
columnList = metadata.getListColumns();
}
}
%>
String dbUser_<%=cid %> = <%=dbuser%>;
<% String passwordFieldName = "__PASS__"; %>
<%@ include file="@{org.talend.designer.components.localprovider}/components/templates/password.javajet"%>
String dbPwd_<%=cid %> = decryptedPassword_<%=cid%>;
<%
log4jCodeGenerateUtil.debugConnectionParams(node,"com.teradata.jdbc.TeraDriver");
%>
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - Connection attempt to '" + url_<%=cid%> + "' with the username '" + dbUser_<%=cid%> + "'.");
<%}%>
java.sql.Connection conn_<%=cid%> = java.sql.DriverManager.getConnection(url_<%=cid %>,dbUser_<%=cid%>,dbPwd_<%=cid%>);
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - Connection to '" + url_<%=cid%> + "' has succeeded.");
<%}%>
java.sql.PreparedStatement pstmt_<%=cid %> =null;
<%
if(columnList != null && columnList.size()>0){
class Column{
IMetadataColumn column;
String name;
String sqlStmt;
String value;
boolean addCol;
List<Column> replacement = new ArrayList<Column>();
public Column(String colName,String sqlStmt,boolean addCol){
this.column = null;
this.name = colName;
this.sqlStmt = sqlStmt;
this.value = "?";
this.addCol =addCol;
}
public Column(IMetadataColumn column){
this.column = column;
this.name = column.getLabel();
this.sqlStmt = "=?";
this.value = "?";
this.addCol =false;
}
public boolean isReplaced(){
return replacement.size()>0;
}
public void replace(Column column){
this.replacement.add(column);
}
public List<Column> getReplacement(){
return this.replacement;
}
public void setColumn(IMetadataColumn column){
this.column = column;
}
public IMetadataColumn getColumn(){
return this.column;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}
public void setIsAddCol(boolean isadd){
this.addCol = isadd;
}
public boolean isAddCol(){
return this.addCol;
}
public void setSqlStmt(String sql){
this.sqlStmt = sql;
}
public String getSqlStmt(){
return this.sqlStmt;
}
public void setValue(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
StringBuilder insertColName = new StringBuilder();
StringBuilder insertValueStmt = new StringBuilder();
StringBuilder updateSetStmt = new StringBuilder();
StringBuilder updateWhereStmt = new StringBuilder();
List<Column> stmtStructure = new LinkedList<Column>();
for(IMetadataColumn column:columnList){
stmtStructure.add(new Column(column));
}
int counterOuter =0;
boolean firstKey = true;
boolean firstNoneKey = true;
for(Column colStmt:stmtStructure){
String suffix = ",";
if(colStmt.isReplaced()){
List<Column> replacedColumns = colStmt.getReplacement();
int counterReplace = 0;
if(counterOuter==(stmtStructure.size()-1) && counterReplace==(replacedColumns.size()-1) ){
suffix = "";
}
for(Column replacement:replacedColumns){
insertColName.append(replacement.getName()+suffix);
insertValueStmt.append(replacement.getSqlStmt()+suffix);
if(!colStmt.getColumn().isKey()){
if(!firstNoneKey){
updateSetStmt.append(",");
}else{
firstNoneKey = false;
}
updateSetStmt.append(replacement.getName());
updateSetStmt.append("=" + replacement.getSqlStmt());
}else{
if(!firstKey){
updateWhereStmt.append(" AND ");
}else{
firstKey = false;
}
updateWhereStmt.append(replacement.getName());
updateWhereStmt.append("=" + replacement.getSqlStmt());
}
counterReplace++;
}
}else{
if(counterOuter==(stmtStructure.size()-1)){
suffix = "";
}
if(colStmt.isAddCol()){
insertColName.append(colStmt.getName()+suffix);
insertValueStmt.append(colStmt.getSqlStmt()+suffix);
updateSetStmt.append(colStmt.getName());
updateSetStmt.append("=" + colStmt.getSqlStmt()+suffix);
}else{
insertColName.append(colStmt.getName()+suffix);
insertValueStmt.append(colStmt.getValue()+suffix);
if(!colStmt.getColumn().isKey()){
if(!firstNoneKey){
updateSetStmt.append(",");
}else{
firstNoneKey = false;
}
updateSetStmt.append(colStmt.getName());
updateSetStmt.append(colStmt.getSqlStmt());
}else{
if(!firstKey){
updateWhereStmt.append(" AND ");
}else{
firstKey = false;
}
updateWhereStmt.append(colStmt.getName());
updateWhereStmt.append(colStmt.getSqlStmt());
}
}
}
counterOuter ++;
}
%>
String tableName_<%=cid%> = <%=tableName%>;
String dbname_<%=cid%> = <%=dbname%>;
if(dbname_<%=cid%> == null || dbname_<%=cid%>.trim().length() == 0) {
tableName_<%=cid%> = <%=tableName%>;
} else {
tableName_<%=cid%> = dbname_<%=cid%> + "." + <%=tableName%>;
}
pstmt_<%=cid %> = conn_<%=cid%>.prepareStatement("INSERT INTO "+tableName_<%=cid%>+" (<%=insertColName.toString()%>) VALUES (<%=insertValueStmt.toString()%>)");
int commitCounter_<%=cid%> = 0;
<%
if(!"".equals(commitEvery) && !"0".equals(commitEvery)){
%>
int commitEvery_<%=cid%> = <%=commitEvery%>;
conn_<%=cid%>.setAutoCommit(false);
<%
}
} /* if columnList end */
%>

View File

@@ -1,54 +0,0 @@
<%@ jet
imports="
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
%>
if(commitCounter_<%=cid%> > 0){
int[] resultArr = pstmt_<%=cid %>.executeBatch();
pstmt_<%=cid %>.clearBatch();
commitCounter_<%=cid%>=0;
int sum = 0;
for(int i : resultArr){
sum += (i<0 ? 0 : i);
}
insertedCount_<%=cid%> += sum;
}
pstmt_<%=cid %>.close();
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - Starting to commit.");
<%}%>
conn_<%=cid%>.commit();
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - Commit has succeeded.");
log.info("<%=cid%> - Closing the connection to the database.");
<%}%>
conn_<%=cid%> .close();
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - Connection to the database closed.");
<%}%>
nb_line_inserted_<%=cid%> += insertedCount_<%=cid%>;
globalMap.put("<%=cid %>_NB_LINE",nb_line_<%=cid%>);
globalMap.put("<%=cid %>_NB_LINE_INSERTED",nb_line_inserted_<%=cid%>);
<%if(isLog4jEnabled){%>
log.info("<%=cid%> - Loaded records count:" + nb_line_inserted_<%=cid%> + "." );
log.info("<%=cid%> - Has finished");
<%}%>

View File

@@ -1,397 +0,0 @@
<%@ jet
imports="
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.INode
org.talend.core.model.process.ElementParameterParser
org.talend.core.model.process.IConnection
org.talend.core.model.metadata.IMetadataColumn
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.types.JavaTypesManager
org.talend.core.model.process.IConnectionCategory
java.util.List
java.util.ArrayList
java.util.LinkedList
"
%>
<%
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();
String dieOnError = ElementParameterParser.getValue(node, "__DIE_ON_ERROR__");
String tableName = ElementParameterParser.getValue(node,"__TABLE__");
String commitEvery = ElementParameterParser.getValue(node, "__COMMIT_EVERY__");
String incomingConnName = null;
List<IMetadataColumn> columnList = null;
List<? extends IConnection> conns = node.getIncomingConnections();
if(conns!=null && conns.size()>0){
IConnection conn = conns.get(0);
incomingConnName = conn.getName();
}
List<IMetadataTable> metadatas = node.getMetadataList();
if(metadatas != null && metadatas.size()>0){
IMetadataTable metadata = metadatas.get(0);
if(metadata != null){
columnList = metadata.getListColumns();
}
}
String rejectConnName = null;
List<? extends IConnection> rejectConns = node.getOutgoingConnections("REJECT");
if(rejectConns != null && rejectConns.size() > 0) {
IConnection rejectConn = rejectConns.get(0);
rejectConnName = rejectConn.getName();
}
List<IMetadataColumn> rejectColumnList = null;
IMetadataTable metadataTable = node.getMetadataFromConnector("REJECT");
if(metadataTable != null) {
rejectColumnList = metadataTable.getListColumns();
}
List<? extends IConnection> outgoingConns = node.getOutgoingSortedConnections();
boolean isLog4jEnabled = ("true").equals(ElementParameterParser.getValue(node.getProcess(), "__LOG4J_ACTIVATE__"));
///////////////Inner Class Column///////////////////////////
class Column{
IMetadataColumn column;
String name;
String sqlStmt;
String value;
boolean addCol;
List<Column> replacement = new ArrayList<Column>();
public Column(String colName,String sqlStmt,boolean addCol){
this.column = null;
this.name = colName;
this.sqlStmt = sqlStmt;
this.value = "?";
this.addCol =addCol;
}
public Column(IMetadataColumn column){
this.column = column;
this.name = column.getLabel();
this.sqlStmt = "=?";
this.value = "?";
this.addCol =false;
}
public boolean isReplaced(){
return replacement.size()>0;
}
public void replace(Column column){
this.replacement.add(column);
}
public List<Column> getReplacement(){
return this.replacement;
}
public void setColumn(IMetadataColumn column){
this.column = column;
}
public IMetadataColumn getColumn(){
return this.column;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return this.name;
}
public void setIsAddCol(boolean isadd){
this.addCol = isadd;
}
public boolean isAddCol(){
return this.addCol;
}
public void setSqlStmt(String sql){
this.sqlStmt = sql;
}
public String getSqlStmt(){
return this.sqlStmt;
}
public void setValue(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
StringBuilder insertColName = new StringBuilder();
StringBuilder insertValueStmt = new StringBuilder();
StringBuilder updateSetStmt = new StringBuilder();
StringBuilder updateWhereStmt = new StringBuilder();
List<Column> stmtStructure = new LinkedList<Column>();
for(IMetadataColumn column:columnList){
stmtStructure.add(new Column(column));
}
List<Column> colStruct = new ArrayList();
for(Column colStmt:stmtStructure){
if(!colStmt.isReplaced()&&!colStmt.isAddCol()){
colStruct.add(colStmt);
}
}
class Operation{
public static final int NORMAL_TYPE = 0;
public static final int INSERT_TYPE = 1;
public static final int UPDATE_TYPE = 2;
public String generateType(String typeToGenerate){
if(("byte[]").equals(typeToGenerate)){
typeToGenerate = "Bytes";
}else if(("java.util.Date").equals(typeToGenerate)){
typeToGenerate = "Date";
}else if(("java.util.Timestamp").equals(typeToGenerate)){
typeToGenerate = "Timestamp";
}else if(("Integer").equals(typeToGenerate)){
typeToGenerate = "Int";
}else{
typeToGenerate=typeToGenerate.substring(0,1).toUpperCase()+typeToGenerate.substring(1);
}
return typeToGenerate;
}
public void generateSetStmt(String typeToGenerate,Column column,
int counter,String incomingConnName,String cid,int stmtType){
boolean isObject = false;
String prefix = null;
if(stmtType == Operation.NORMAL_TYPE){
prefix = "pstmt_";
}else if(stmtType == Operation.INSERT_TYPE){
prefix = "pstmtInsert_";
}else if(stmtType == Operation.UPDATE_TYPE){
prefix = "pstmtUpdate_";
}
%>
<%if(("Character").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.CHAR);
<%
}else if(("Date").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.DATE);
<%
}else if(("Timestamp").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.TIMESTAMP);
<%
}else if(("byte[]").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.ARRAY);
<%
}else if(("Long").equals(typeToGenerate)||("Byte").equals(typeToGenerate)||("Integer").equals(typeToGenerate)||("Short").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.INTEGER);
<%
}else if(("String").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.VARCHAR);
<%
}else if(("Object").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.OTHER);
<%
}else if(("Boolean").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.BOOLEAN);
<%
}else if(("Double").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.DOUBLE);
<%
}else if(("Float").equals(typeToGenerate)){
isObject = true;
%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.FLOAT);
<%
}
if(isObject){
%>
}else{
<%
}
typeToGenerate = generateType(typeToGenerate);
if(("Char").equals(typeToGenerate)||("Character").equals(typeToGenerate)){
%>
<%if(isObject){%>
if(<%=incomingConnName%>.<%=column.getName()%>==null){
<%}else{%>
if(("null").equals(String.valueOf(<%=incomingConnName%>.<%=column.getName()%>).toLowerCase())){
<%}%>
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.CHAR);
}else if(<%=incomingConnName%>.<%=column.getName()%> == '\0'){
<%=prefix+cid%>.setString(<%=counter%>,"");
}else{
<%=prefix+cid%>.setString(<%=counter%>,String.valueOf(<%=incomingConnName%>.<%=column.getName()%>));
}
<%
}else if(("Date").equals(typeToGenerate)){
%>
if(<%=incomingConnName%>.<%=column.getName()%>!=null){
<%=prefix+cid%>.setDate(<%=counter%>,new java.sql.Date(<%=incomingConnName%>.<%=column.getName()%>.getTime()));
}else{
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.DATE);
}
<%
}else if(("Timestamp").equals(typeToGenerate)){
%>
if(<%=incomingConnName%>.<%=column.getName()%>!=null){
<%=prefix+cid%>.setTimestamp(<%=counter%>,new java.sql.Timestamp(<%=incomingConnName%>.<%=column.getName()%>.getTime()));
}else{
<%=prefix+cid%>.setNull(<%=counter%>,java.sql.Types.TIMESTAMP);
}
<%
}else{
%>
<%=prefix+cid%>.set<%=typeToGenerate%>(<%=counter%>,<%=incomingConnName%>.<%=column.getName()%>);
<%
}
if(isObject){
%>
}
<%
} /* "if(isObject)" end */
} /* "public void generateSetStmt" end */
} /* "class Operation" end */
Operation operation = new Operation();
if(incomingConnName != null && columnList != null){
int counter = 1;
for(Column column:colStruct){
String typeToGenerate = JavaTypesManager.getTypeToGenerate(column.getColumn().getTalendType(), column.getColumn().isNullable());
operation.generateSetStmt(typeToGenerate,column,counter,incomingConnName,cid,0);
counter++;
}
%>
try{
pstmt_<%=cid %>.addBatch();
}catch(java.lang.Exception e){
<%
if (("true").equals(dieOnError)) {
%>
<%if(isLog4jEnabled){%>
log.fatal("<%=cid%> - " + e.getMessage());
<%}%>
throw(e);
<%
} else {
if(isLog4jEnabled){%>
log.error("<%=cid%> - " + e.getMessage());
<%}
if(rejectConnName != null && rejectColumnList != null && rejectColumnList.size() > 0) {
for(IMetadataColumn column : columnList) {
%>
<%=rejectConnName%>.<%=column.getLabel()%> = <%=incomingConnName%>.<%=column.getLabel()%>;
<%
}
%>
<%=rejectConnName%>.errorMessage = e.getMessage() + " - Line: " + tos_count_<%=node.getUniqueName() %>;
<%
} else {
%>
System.err.print(e.getMessage());
<%
}
}
%>
}
<%
if(isLog4jEnabled){
int count = 0;
for(IMetadataColumn column : columnList) {
count++;
%>
log4jSb_<%=cid%>.append(<%=incomingConnName%>.<%=column.getLabel()%>);
<%if(count < columnList.size()){%>
log4jSb_<%=cid%>.append("|");
<%}
}%>
log.debug("<%=cid%> - Writing the record " + nb_line_<%=cid%> + " " + log4jSb_<%=cid%>);
log4jSb_<%=cid%>.delete(0,log4jSb_<%=cid%>.length());
<%}
if(outgoingConns != null && outgoingConns.size() > 0) {
for(IConnection outgoingConn : outgoingConns) {
if(!outgoingConn.getName().equals(rejectConnName) &&
outgoingConn.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) ) {
for(IMetadataColumn column : columnList) {
%>
<%=outgoingConn.getName()%>.<%=column.getLabel()%> = <%=incomingConnName%>.<%=column.getLabel()%>;
<%
}
}
}
}
%>
commitCounter_<%=cid%>++;
nb_line_<%=cid%>++;
<%
////////////commit every////////////
if(!"".equals(commitEvery) && !"0".equals(commitEvery)){
%>
if(commitEvery_<%=cid%> <= commitCounter_<%=cid%>){
int[] resultArr = pstmt_<%=cid %>.executeBatch();
pstmt_<%=cid %>.clearBatch();
commitCounter_<%=cid%>=0;
int sum = 0;
for(int i : resultArr){
sum += (i<0 ? 0 : i);
}
insertedCount_<%=cid%> += sum;
}
<%
}
}
%>

View File

@@ -1,4 +0,0 @@
output.. = bin/
bin.includes = META-INF/,\
.,\
lib/

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -1,33 +0,0 @@
CreateFTPConnectionAction_create_ftp=Create FTP
CreateFTPConnectionAction_edit_ftp=Edit FTP
CreateFTPConnectionAction_open_ftp=Open FTP
FTPPage_titleCreate_Step=New FTP Connection on repository
FTPForm_authen_method=Authentication method
FTPForm_conn_model=Connection Model
FTPForm_ftps_support=FTPs Support(support tFTPGet temporarily)
FTPForm_passive=Passive
FTPForm_sccks_proxy=Use Socks Proxy
FTPForm_sftp_suport=SFTP Support
FTPForm_ftpHostText_check=Host can not be null.
FTPForm_ftpPortText_check=Port can not be null.
FTPForm_ftpUsernameText_check=Username can not be null.
FTPForm_ftpPasswordText_check=Password can not be null.
FTPForm_ftpUsernameText=Username
FTPForm_ftpPasswordText=Password
FTPForm_ftpHostText=Host
FTPForm_ftpPortText=Port
FTPForm_privatekeyText=Private key
FTPForm_passphraseText=Key Passphrase
FTPForm_keyFileText=Keystore File
FTPForm_keyPasswordText=Keystore Password
FTPForm_proxyHostText=Proxy Host
FTPForm_proxyPortText=Proxy Port
FTPForm_proxyUsernameText=Proxy User
FTPForm_proxyPasswordText=Proxy Password
FTPForm_filepathAlert=Filepath must be specified
FTPWizard_create_ftp_conn=Create a FTPConnection
FTPWizard.CreateNewFTPWizard=Create new FTP
FTPWizard.EditFTPWizard=Edit FTP

View File

@@ -1,799 +0,0 @@
// ============================================================================
//
// 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.repository.ftp.ui.wizards.forms;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.commons.ui.swt.formtools.LabelledCombo;
import org.talend.commons.ui.swt.formtools.LabelledFileField;
import org.talend.commons.ui.swt.formtools.LabelledText;
import org.talend.commons.ui.utils.PathUtils;
import org.talend.commons.utils.PasswordEncryptUtil;
import org.talend.core.model.metadata.builder.connection.FTPConnection;
import org.talend.core.model.properties.ConnectionItem;
import org.talend.cwm.helper.ConnectionHelper;
import org.talend.repository.ftp.i18n.Messages;
import org.talend.repository.ftp.ui.wizards.pags.FTPPage;
import org.talend.repository.ui.swt.utils.AbstractForm;
/**
* DOC hwang class global comment. Detailled comment
*/
public class FTPForm extends AbstractForm {
private static final String ENCODING = "ISO-8859-15"; //$NON-NLS-1$
private static final String PUBLIC_KEY = "Public key"; //$NON-NLS-1$
private static final String CUSTOM = "CUSTOM";//$NON-NLS-1$
private static final String PASSWORD = "Password"; //$NON-NLS-1$
private FTPPage page;
private LabelledText ftpUsernameText;
private LabelledText ftpPasswordText;
private LabelledText ftpPortText;
private LabelledText ftpHostText;
private LabelledText proxyUsernameText;
private LabelledText proxyPasswordText;
private LabelledText proxyPortText;
private LabelledText proxyHostText;
private LabelledFileField privatekeyText;
private LabelledText passphraseText;
private LabelledFileField keyFileText;
private LabelledText keyPasswordText;
private LabelledCombo connModelCombo;
private LabelledCombo encodeCombo;
private LabelledCombo methodCombo;
private Composite tetsCom;
private Text customText;
private Button sftpSuppBut;
private Button ftpsSuppBut;
private Button useSocksBut;
private Group buildGroup;
private Composite sftpChildCom;
private Composite ftpsChildCom;
private Composite proxyCom;
private Composite proxyChildCom;
private GridData sftpChildComGridData;
private GridData ftpsChildComGridData;
private GridData proxyChildComGridData;
/**
* DOC Administrator FTPForm constructor comment.
*
* @param parent
* @param style
*/
public FTPForm(Composite parent, ConnectionItem connectionItem, String[] existingNames, FTPPage page) {
super(parent, SWT.NONE, existingNames);
this.connectionItem = connectionItem;
this.page = page;
setConnectionItem(connectionItem); // must be first.
setupForm(false);
layoutForm();
}
private void layoutForm() {
GridLayout layout = (GridLayout) getLayout();
layout.marginHeight = 0;
setLayout(layout);
}
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.swt.utils.AbstractForm#adaptFormToReadOnly()
*/
@Override
protected void adaptFormToReadOnly() {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.swt.utils.AbstractForm#addFields()
*/
@Override
protected void addFields() {
Group ftpParameterGroup = new Group(this, SWT.NULL);
ftpParameterGroup.setText("Server"); //$NON-NLS-1$
GridLayout layoutGroup = new GridLayout();
layoutGroup.numColumns = 2;
ftpParameterGroup.setLayout(layoutGroup);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
ftpParameterGroup.setLayoutData(gridData);
ftpUsernameText = new LabelledText(ftpParameterGroup, Messages.getString("FTPForm_ftpUsernameText"), true); //$NON-NLS-1$
ftpPasswordText = new LabelledText(ftpParameterGroup,
Messages.getString("FTPForm_ftpPasswordText"), 1, SWT.BORDER | SWT.PASSWORD); //$NON-NLS-1$
ftpHostText = new LabelledText(ftpParameterGroup, Messages.getString("FTPForm_ftpHostText"), true); //$NON-NLS-1$
ftpPortText = new LabelledText(ftpParameterGroup, Messages.getString("FTPForm_ftpPortText"), true); //$NON-NLS-1$
Composite com = new Composite(ftpParameterGroup, SWT.NONE);
layoutGroup = new GridLayout(2, false);
com.setLayout(layoutGroup);
List<String> codeList = new ArrayList<String>();
codeList.add(ENCODING);
codeList.add("UTF-8"); //$NON-NLS-1$
codeList.add(CUSTOM);
encodeCombo = new LabelledCombo(com, "Encoding", "", codeList); //$NON-NLS-1$ //$NON-NLS-2$
if (getConnection().getEcoding() == null || "".equals(getConnection().getEcoding())) { //$NON-NLS-1$
encodeCombo.setText(ENCODING);
getConnection().setEcoding(encodeCombo.getText());
}
customText = new Text(ftpParameterGroup, SWT.BORDER | SWT.SINGLE);
GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
gridData.horizontalSpan = 1;
customText.setLayoutData(gd);
List<String> connList = new ArrayList<String>();
connList.add("Passive"); //$NON-NLS-1$
connList.add("Active"); //$NON-NLS-1$
connModelCombo = new LabelledCombo(ftpParameterGroup, Messages.getString("FTPForm_conn_model"), "", connList); //$NON-NLS-1$ //$NON-NLS-2$
if (getConnection().getMode() == null || "".equals(getConnection().getMode())) { //$NON-NLS-1$
connModelCombo.setText(Messages.getString("FTPForm_passive")); //$NON-NLS-1$
getConnection().setMode(connModelCombo.getText());
}
buildGroup = new Group(this, SWT.NULL);
buildGroup.setText("Parameter"); //$NON-NLS-1$
layoutGroup = new GridLayout(1, false);
buildGroup.setLayout(layoutGroup);
gridData = new GridData(GridData.FILL_HORIZONTAL);
buildGroup.setLayoutData(gridData);
Composite checkButtonCom = new Composite(buildGroup, SWT.NONE);
layoutGroup = new GridLayout(2, false);
checkButtonCom.setLayout(layoutGroup);
gridData = new GridData(GridData.FILL_HORIZONTAL);
checkButtonCom.setLayoutData(gridData);
sftpSuppBut = new Button(checkButtonCom, SWT.CHECK);
sftpSuppBut.setText(Messages.getString("FTPForm_sftp_suport")); //$NON-NLS-1$
ftpsSuppBut = new Button(checkButtonCom, SWT.CHECK);
ftpsSuppBut.setText(Messages.getString("FTPForm_ftps_support")); //$NON-NLS-1$
String[] methodComboStr = { PUBLIC_KEY, PASSWORD };
tetsCom = new Composite(buildGroup, SWT.NONE);
layoutGroup = new GridLayout(1, false);
tetsCom.setLayout(layoutGroup);
gridData = new GridData(GridData.FILL_HORIZONTAL);
tetsCom.setLayoutData(gridData);
sftpChildCom = new Composite(tetsCom, SWT.NONE);
layoutGroup = new GridLayout(3, false);
sftpChildCom.setLayout(layoutGroup);
sftpChildComGridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.minimumWidth = 300;
gridData.minimumHeight = 120;
gridData.widthHint = 300;
gridData.heightHint = 110;
sftpChildCom.setLayoutData(sftpChildComGridData);
methodCombo = new LabelledCombo(sftpChildCom,
Messages.getString("FTPForm_authen_method"), "", methodComboStr, 2, false, SWT.NONE); //$NON-NLS-1$ //$NON-NLS-2$
// file Field
String[] extensions = { "*.*" }; //$NON-NLS-1$
privatekeyText = new LabelledFileField(sftpChildCom, Messages.getString("FTPForm_privatekeyText"), extensions); //$NON-NLS-1$
passphraseText = new LabelledText(sftpChildCom,
Messages.getString("FTPForm_passphraseText"), 1, SWT.BORDER | SWT.PASSWORD); //$NON-NLS-1$
ftpsChildCom = new Composite(tetsCom, SWT.NONE);
layoutGroup = new GridLayout(3, false);
ftpsChildCom.setLayout(layoutGroup);
ftpsChildComGridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.minimumWidth = 300;
gridData.minimumHeight = 120;
gridData.widthHint = 300;
gridData.heightHint = 90;
ftpsChildCom.setLayoutData(ftpsChildComGridData);
keyFileText = new LabelledFileField(ftpsChildCom, Messages.getString("FTPForm_keyFileText"), extensions); //$NON-NLS-1$
keyPasswordText = new LabelledText(ftpsChildCom,
Messages.getString("FTPForm_keyPasswordText"), 1, SWT.BORDER | SWT.PASSWORD); //$NON-NLS-1$
proxyCom = new Composite(buildGroup, SWT.NONE);
layoutGroup = new GridLayout(1, false);
proxyCom.setLayout(layoutGroup);
gridData = new GridData(GridData.FILL_HORIZONTAL);
proxyCom.setLayoutData(gridData);
useSocksBut = new Button(proxyCom, SWT.CHECK);
useSocksBut.setText(Messages.getString("FTPForm_sccks_proxy")); //$NON-NLS-1$
proxyChildCom = new Composite(proxyCom, SWT.NONE);
layoutGroup = new GridLayout(2, false);
proxyChildCom.setLayout(layoutGroup);
proxyChildComGridData = new GridData(GridData.FILL_HORIZONTAL);
proxyChildCom.setLayoutData(proxyChildComGridData);
proxyHostText = new LabelledText(proxyChildCom, Messages.getString("FTPForm_proxyHostText"), true); //$NON-NLS-1$
proxyPortText = new LabelledText(proxyChildCom, Messages.getString("FTPForm_proxyPortText"), true); //$NON-NLS-1$
proxyUsernameText = new LabelledText(proxyChildCom, Messages.getString("FTPForm_proxyUsernameText"), true); //$NON-NLS-1$
proxyPasswordText = new LabelledText(proxyChildCom,
Messages.getString("FTPForm_proxyPasswordText"), 1, SWT.BORDER | SWT.PASSWORD); //$NON-NLS-1$
checkFieldsValue();
}
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.swt.utils.AbstractForm#addFieldsListeners()
*/
@Override
protected void addFieldsListeners() {
ftpUsernameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setUsername(ftpUsernameText.getText());
checkFieldsValue();
}
});
ftpPasswordText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (ftpPasswordText.getText() != null) {
try {
String password = PasswordEncryptUtil.encryptPassword(ftpPasswordText.getText());
getConnection().setPassword(password + PasswordEncryptUtil.ENCRYPT_KEY);
} catch (Exception ex) {
ExceptionHandler.process(ex);
}
}
checkFieldsValue();
}
});
ftpPortText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setPort(ftpPortText.getText());
checkFieldsValue();
}
});
ftpHostText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setHost(ftpHostText.getText());
checkFieldsValue();
}
});
proxyUsernameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setProxyuser(proxyUsernameText.getText());
}
});
proxyPasswordText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (proxyPasswordText.getText() != null) {
try {
String password = PasswordEncryptUtil.encryptPassword(proxyPasswordText.getText());
getConnection().setProxypassword(password + PasswordEncryptUtil.ENCRYPT_KEY);
} catch (Exception ex) {
ExceptionHandler.process(ex);
}
}
}
});
proxyPortText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setProxyport(proxyPortText.getText());
}
});
proxyHostText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setProxyhost(proxyHostText.getText());
}
});
keyFileText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setKeystoreFile(PathUtils.getPortablePath(keyFileText.getText()));
checkFilePathAndManageIt();
}
});
keyPasswordText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (keyPasswordText.getText() != null) {
try {
String password = PasswordEncryptUtil.encryptPassword(keyPasswordText.getText());
getConnection().setKeystorePassword(password + PasswordEncryptUtil.ENCRYPT_KEY);
} catch (Exception ex) {
ExceptionHandler.process(ex);
}
}
}
});
connModelCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setMode(connModelCombo.getText());
}
});
encodeCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setEcoding(encodeCombo.getText());
if (CUSTOM.equals(getConnection().getEcoding())) {
customText.setVisible(true);
customText.setText(ENCODING);
getConnection().setCustomEncode(customText.getText());
} else {
getConnection().setCustomEncode(getConnection().getEcoding());
customText.setVisible(false);
}
}
});
customText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setCustomEncode(customText.getText());
}
});
methodCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setMethod(methodCombo.getText());
if (PUBLIC_KEY.equals(getConnection().getMethod())) {
privatekeyText.setVisible(true);
passphraseText.setVisible(true);
privatekeyText.setText(getConnection().getPrivatekey() != null ? getConnection().getPrivatekey() : ""); //$NON-NLS-1$
// decrypt password
try {
passphraseText.setText(PasswordEncryptUtil.decryptPassword(getConnection().getPassphrase()));
} catch (Exception ex) {
String pwd = ConnectionHelper.getDecryptPassword(getConnection().getPassphrase());
passphraseText.setText(pwd != null ? pwd : getConnection().getPassphrase());
}
} else {
privatekeyText.setVisible(false);
passphraseText.setVisible(false);
}
checkFieldsValue();
}
});
privatekeyText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getConnection().setPrivatekey(PathUtils.getPortablePath(privatekeyText.getText()));
checkFilePathAndManageIt();
}
});
passphraseText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (passphraseText.getText() != null) {
try {
String password = PasswordEncryptUtil.encryptPassword(passphraseText.getText());
getConnection().setPassphrase(password + PasswordEncryptUtil.ENCRYPT_KEY);
} catch (Exception ex) {
ExceptionHandler.process(ex);
}
}
}
});
}
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.swt.utils.AbstractForm#addUtilsButtonListeners()
*/
@Override
protected void addUtilsButtonListeners() {
sftpSuppBut.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
boolean show = sftpSuppBut.getSelection();
if (show) {
sftpChildComGridData.exclude = false;
ftpsChildComGridData.exclude = true;
} else {
sftpChildComGridData.exclude = true;
}
if (show && ftpsSuppBut.getSelection()) {
getConnection().setFTPS(!show);
ftpsSuppBut.setSelection(!show);
}
if (PUBLIC_KEY.equals(methodCombo.getText())) {
privatekeyText.setVisible(show);
passphraseText.setVisible(show);
} else {
privatekeyText.setVisible(false);
passphraseText.setVisible(false);
}
connModelCombo.setEnabled(!show);
getConnection().setSFTP(show);
checkFieldsValue();
sftpChildCom.setVisible(show);
ftpsChildCom.setVisible(!show && ftpsSuppBut.getSelection());
sftpChildCom.layout();
ftpsChildCom.layout();
tetsCom.layout();
buildGroup.layout();
}
});
ftpsSuppBut.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
boolean show = ftpsSuppBut.getSelection();
if (show) {
ftpsChildComGridData.exclude = false;
sftpChildComGridData.exclude = true;
} else {
ftpsChildComGridData.exclude = true;
}
if (show && sftpSuppBut.getSelection()) {
getConnection().setSFTP(!show);
sftpSuppBut.setSelection(!show);
}
connModelCombo.setEnabled(!show);
getConnection().setFTPS(show);
checkFieldsValue();
sftpChildCom.setVisible(!show && sftpSuppBut.getSelection());
ftpsChildCom.setVisible(show);
sftpChildCom.layout();
ftpsChildCom.layout();
tetsCom.layout();
buildGroup.layout();
}
});
useSocksBut.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
boolean show = useSocksBut.getSelection();
if (show) {
proxyChildComGridData.exclude = false;
} else {
proxyChildComGridData.exclude = true;
}
getConnection().setUsesocks(show);
proxyChildCom.setVisible(show);
proxyChildCom.layout();
proxyCom.layout();
tetsCom.layout();
buildGroup.layout();
layout();
}
});
}
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.swt.utils.AbstractForm#checkFieldsValue()
*/
@Override
public boolean checkFieldsValue() {
if (ftpHostText.getCharCount() == 0) {
updateStatus(IStatus.ERROR, Messages.getString("FTPForm_ftpHostText_check")); //$NON-NLS-1$
return false;
}
if (ftpPortText.getCharCount() == 0) {
updateStatus(IStatus.ERROR, Messages.getString("FTPForm_ftpPortText_check")); //$NON-NLS-1$
return false;
}
if (ftpUsernameText.getCharCount() == 0) {
updateStatus(IStatus.ERROR, Messages.getString("FTPForm_ftpUsernameText_check")); //$NON-NLS-1$
return false;
}
// only check the Password model
if (sftpSuppBut.getSelection() && methodCombo != null && PASSWORD.equals(methodCombo.getText())) {
if (ftpPasswordText.getCharCount() == 0) {
updateStatus(IStatus.ERROR, Messages.getString("FTPForm_ftpPasswordText_check")); //$NON-NLS-1$
return false;
}
}
if (sftpSuppBut.getSelection() && methodCombo != null && PUBLIC_KEY.equals(methodCombo.getText())
&& privatekeyText.getText() == "") { //$NON-NLS-1$
updateStatus(IStatus.ERROR, Messages.getString("FTPForm_filepathAlert")); //$NON-NLS-1$
return false;
}
if (ftpsSuppBut.getSelection() && keyFileText.getText() == "") { //$NON-NLS-1$
updateStatus(IStatus.ERROR, Messages.getString("FTPForm_filepathAlert")); //$NON-NLS-1$
return false;
}
updateStatus(IStatus.OK, null);
return true;
}
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.swt.utils.AbstractForm#initialize()
*/
@Override
protected void initialize() {
ftpUsernameText.setText(getConnection().getUsername());
// decrypt password
try {
ftpPasswordText.setText(PasswordEncryptUtil.decryptPassword(getConnection().getPassword()));
} catch (Exception e) {
String pwd = ConnectionHelper.getDecryptPassword(getConnection().getPassword());
ftpPasswordText.setText(pwd != null ? pwd : getConnection().getPassword());
}
ftpPortText.setText(getConnection().getPort());
ftpHostText.setText(getConnection().getHost());
encodeCombo.setText(getConnection().getEcoding());
if (CUSTOM.equals(encodeCombo.getText())) {
customText.setVisible(true);
} else {
customText.setVisible(false);
}
if (getConnection().getCustomEncode() == null) {
customText.setText(ENCODING);
} else {
customText.setText(getConnection().getCustomEncode());
}
connModelCombo.setText(getConnection().getMode());
if (getConnection().isSFTP()) {
sftpChildComGridData.exclude = false;
ftpsChildComGridData.exclude = true;
sftpChildCom.setVisible(true);
ftpsChildCom.setVisible(false);
sftpChildCom.layout();
ftpsChildCom.layout();
tetsCom.layout();
buildGroup.layout();
connModelCombo.setEnabled(false);
sftpSuppBut.setSelection(getConnection().isSFTP());
methodCombo.setText(getConnection().getMethod());
if (PUBLIC_KEY.equals(getConnection().getMethod())) {
privatekeyText.setVisible(true);
passphraseText.setVisible(true);
privatekeyText.setText(getConnection().getPrivatekey() != null ? getConnection().getPrivatekey() : "");//$NON-NLS-1$
// decrypt password
try {
passphraseText.setText(PasswordEncryptUtil.decryptPassword(getConnection().getPassphrase()));
} catch (Exception e) {
String pwd = ConnectionHelper.getDecryptPassword(getConnection().getPassphrase());
passphraseText.setText(pwd != null ? pwd : getConnection().getPassphrase());
}
} else {
privatekeyText.setVisible(false);
passphraseText.setVisible(false);
}
} else {
sftpChildComGridData.exclude = true;
sftpChildCom.setVisible(false);
sftpChildCom.layout();
tetsCom.layout();
buildGroup.layout();
}
if (getConnection().isFTPS()) {
ftpsChildComGridData.exclude = false;
sftpChildComGridData.exclude = true;
sftpChildCom.setVisible(false);
ftpsChildCom.setVisible(true);
sftpChildCom.layout();
ftpsChildCom.layout();
tetsCom.layout();
buildGroup.layout();
connModelCombo.setEnabled(false);
ftpsSuppBut.setSelection(getConnection().isFTPS());
keyFileText.setText(getConnection().getKeystoreFile());
// decrypt password
try {
keyPasswordText.setText(PasswordEncryptUtil.decryptPassword(getConnection().getKeystorePassword()));
} catch (Exception e) {
String pwd = ConnectionHelper.getDecryptPassword(getConnection().getKeystorePassword());
keyPasswordText.setText(pwd != null ? pwd : getConnection().getKeystorePassword());
}
} else {
ftpsChildComGridData.exclude = true;
ftpsChildCom.setVisible(false);
ftpsChildCom.layout();
tetsCom.layout();
buildGroup.layout();
}
if (getConnection().isUsesocks()) {
proxyChildComGridData.exclude = false;
proxyChildCom.setVisible(true);
proxyChildCom.layout();
proxyCom.layout();
buildGroup.layout();
this.layout();
useSocksBut.setSelection(getConnection().isUsesocks());
proxyHostText.setText(getConnection().getProxyhost());
proxyPortText.setText(getConnection().getProxyport());
proxyUsernameText.setText(getConnection().getProxyuser());
// decrypt password
try {
proxyPasswordText.setText(PasswordEncryptUtil.decryptPassword(getConnection().getProxypassword()));
} catch (Exception e) {
String pwd = ConnectionHelper.getDecryptPassword(getConnection().getProxypassword());
proxyPasswordText.setText(pwd != null ? pwd : getConnection().getProxypassword());
}
} else {
proxyChildComGridData.exclude = true;
proxyChildCom.setVisible(false);
proxyChildCom.layout();
proxyCom.layout();
buildGroup.layout();
this.layout();
}
}
public void removeHideValue() {
if (!connModelCombo.getCombo().isVisible()) {
getConnection().setMode(""); //$NON-NLS-1$
}
if (!sftpSuppBut.isVisible()) {
getConnection().setSFTP(false);
}
if (!ftpsSuppBut.isVisible()) {
getConnection().setFTPS(false);
}
if (!useSocksBut.isVisible()) {
getConnection().setUsesocks(false);
}
if (!methodCombo.getCombo().isVisible()) {
getConnection().setMethod(""); //$NON-NLS-1$
}
if (!keyPasswordText.getTextControl().isVisible()) {
getConnection().setKeystorePassword(""); //$NON-NLS-1$
}
if (!keyFileText.getTextControl().isVisible()) {
getConnection().setKeystoreFile(""); //$NON-NLS-1$
}
if (!proxyHostText.getTextControl().isVisible()) {
getConnection().setProxyhost(""); //$NON-NLS-1$
}
if (!proxyPortText.getTextControl().isVisible()) {
getConnection().setProxyport(""); //$NON-NLS-1$
}
if (!proxyPasswordText.getTextControl().isVisible()) {
getConnection().setProxypassword(""); //$NON-NLS-1$
}
if (!proxyUsernameText.getTextControl().isVisible()) {
getConnection().setProxyuser(""); //$NON-NLS-1$
}
if (!customText.isVisible()) {
getConnection().setCustomEncode(ENCODING);
}
if (getConnection().getCustomEncode() == null || "".equals(getConnection().getCustomEncode())) { //$NON-NLS-1$
getConnection().setCustomEncode(ENCODING);
}
}
protected FTPConnection getConnection() {
return (FTPConnection) connectionItem.getConnection();
}
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
checkFieldsValue();
}
/**
* checkFileFieldsValue active fileViewer if file exist.
*/
private void checkFilePathAndManageIt() {
updateStatus(IStatus.OK, null);
String fileStr = privatekeyText.getText();
checkFieldsValue();
}
}

View File

@@ -1,943 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<html>
<head>
<title>
<xsl:value-of select="/project/@i18n.compare.generated.documetation" />
</title>
<style type="text/css">
@page { size: letter; }
SPAN.special { font:12pt
black; }
TABLE.properties { width:95%; }
TD.propname { width:30%;
font:bold; }
TR.profont { font:bold; }
TD.propval { width:70%; }
TD.dependtype { width:20%;}
TD.dependloc { width:60%; }
TABLE.cols
{width:90%; }
TD.constraint { width:20%; font:bold; }
H3.hand {
cursor:hand; }
img.bordercolor {border-color:#AFCA00; }
.FONTSTYLE
{font-family:Arial, Helvetica, sans-serif;}
.LINKSTYLE
{TEXT-DECORATION:none}
a:hover {TEXT-DECORATION:underline}
.TITLESTYLE {font-size: 26px; color: #818181;}
.TOPTITLESTYLE
{font-size: 40px; color: #818181;}
.TABLECOLUMNSTYLE {font-family:
Arial, Helvetica,sans-serif; color: #818181;
background-color:#E6E6E6;align: center}
tr {page-break-inside:
avoid}
</style>
</head>
<body>
<br />
<table border="0" cellspacing="0" width="90%" class="FONTSTYLE"
summary="JobCompare&#160;documentation">
<tr valign="top">
<!--<td width="15%" rowspan="2" align="center"></td> -->
<td align="center">
<a href="{project/@link}">
<img src="{project/@logo}" border="0" align="bottom" alt="" />
</a>
</td>
<!-- <td width="1%" rowspan="2" align="center"></td> -->
<td class="TOPTITLESTYLE">
<xsl:value-of select="/project/@docType" />
</td>
</tr>
<tr valign="top">
<td height="20" align="center" valign="top" class="TITLESTYLE">
<xsl:value-of select="/project/@company" />
</td>
<td height="20" align="left" valign="top" class="TITLESTYLE">
<xsl:value-of select="/project/@title" />
</td>
</tr>
</table>
<br />
<br />
<table border="1" width="90%" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" class="FONTSTYLE"
summary="">
<tr valign="top">
<td align="center" width="25%" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.project.name" />
</td>
<td align="center" width="25%" class="FONTSTYLE">
<xsl:value-of select="/project/@name" />
</td>
<td align="center" width="25%" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.generated.date" />
</td>
<td align="center" width="25%">
<xsl:value-of select="/project/@generatedDate" />
</td>
</tr>
<tr>
<td align="center" width="25%" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.author" />
</td>
<td align="center" width="25%">
<xsl:value-of select="/project/@author" />
</td>
<td align="center" width="25%" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@versionName" />
</td>
<td align="center" width="25%" class="FONTSTYLE">
<xsl:value-of select="/project/@version" />
</td>
</tr>
</table>
<h2 class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.summary" />
</h2>
<div class="FONTSTYLE">
<b>
<a href="#ProjectDescription">
<xsl:value-of select="/project/@i18n.compare.project.description" />
</a>
</b>
</div>
<div class="FONTSTYLE">
<b>
<a href="#CurrentJobPreviewPicture">
<xsl:value-of
select="/project/@i18n.compare.current.job.preview.picture" />
</a>
</b>
</div>
<div class="FONTSTYLE">
<b>
<a href="#ComparedJobPreviewPicture">
<xsl:value-of select="/project/@i18n.compare.compare.job.picture" />
</a>
</b>
</div>
<div class="FONTSTYLE">
<b>
<a href="#JobSettingCompare">
<xsl:value-of
select="/project/@i18n.compare.compare.job.setting.compare" />
</a>
</b>
</div>
<div class="FONTSTYLE">
<b>
<a href="#ComparedComponentList">
<xsl:value-of
select="/project/@i18n.compare.compare.compared.component.list" />
</a>
</b>
</div>
<div class="FONTSTYLE">
<b>
<a href="#ComparedConnectorList">
<xsl:value-of
select="/project/@i18n.compare.compare.compared.connector.list" />
</a>
</b>
</div>
<br />
<br />
<!-- Project Description -->
<!--HR -->
<h2 class="FONTSTYLE">
<a name="#ProjectDescription">
<xsl:value-of select="/project/@i18n.compare.project.description" />
</a>
</h2>
<br />
<table border="1" width="90%" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse; padding-left:10mm;"
bordercolor="#111111" summary="">
<tr>
<th align="left" width="30%" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.properties" />
</th>
<th align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.values" />
</th>
</tr>
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="/project/@i18n.compare.name" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="/project/@name" />
</td>
</tr>
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="/project/@i18n.compare.language" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="/project/@language" />
</td>
</tr>
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="/project/@i18n.compare.description" />
</td>
<td class="FONTSTYLE" align="left">
<pre>
<xsl:value-of select="/project/pro-description"
disable-output-escaping="yes" />
</pre>
</td>
</tr>
</table>
<br />
<br />
<!-- Project Description -->
<!--HR -->
<xsl:variable name="jobCompare" select="/project/jobCompare" />
<xsl:variable name="currentJobPreviewPicture" select="$jobCompare/curJobPreview" />
<xsl:if test="string-length($currentJobPreviewPicture/@picture)!=0">
<h2 class="FONTSTYLE">
<a name="#CurrentJobPreviewPicture">
<xsl:value-of
select="/project/@i18n.compare.current.job.preview.picture" />
</a>
</h2>
<br />
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" align="left" style="border-collapse: collapse"
bordercolor="#111111" summary="">
<tr class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="$currentJobPreviewPicture/@jobName" />
</b>
</td>
</tr>
</table>
<br />
<div class="FONTSTYLE" align="center">
<img src="{$currentJobPreviewPicture/@picture}" usemap="#jobComparemap"
alt="No image available" class="bordercolor" />
<map id="jobComparemap" name="jobComparemap" />
</div>
</xsl:if>
<br />
<br />
<xsl:variable name="comparedJobPreviewPicture" select="$jobCompare/comparedJobPreview" />
<xsl:if test="string-length($comparedJobPreviewPicture/@picture)!=0">
<h2 class="FONTSTYLE">
<a name="#ComparedJobPreviewPicture">
<xsl:value-of select="/project/@i18n.compare.compare.job.picture" />
</a>
</h2>
<br />
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" align="center" style="border-collapse: collapse"
bordercolor="#111111" summary="">
<tr class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="$comparedJobPreviewPicture/@jobName" />
</b>
</td>
</tr>
</table>
<br />
<div class="FONTSTYLE" align="center">
<img src="{$comparedJobPreviewPicture/@picture}" usemap="#jobComparemap"
alt="No image available" class="bordercolor" />
<map id="jobComparemap" name="jobComparemap" />
</div>
</xsl:if>
<br />
<br />
<!--Job Setting Compare -->
<!--HR -->
<xsl:variable name="jobSetting" select="/project/jobSetting" />
<h2 class="FONTSTYLE">
<a name="#JobSettingCompare">
<xsl:value-of select="/project/@i18n.compare.compare.job.setting.compare" />
</a>
</h2>
<xsl:variable name="extraList" select="$jobSetting/extra/extraItem/@param" />
<xsl:if test="string-length($extraList)!=0">
<b class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.extra" />
</b>
<br />
<table width="50%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;" bordercolor="#111111"
frame="box" summary="">
<tr>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.parameter" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.current.value" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.old.value" />
</th>
</tr>
<xsl:for-each select="$jobSetting/extra/extraItem">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@param" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@currentValue" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@oldValue" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:if>
<xsl:variable name="statsAndLogsList"
select="$jobSetting/statsAndLog/statsAndLogItem/@param" />
<xsl:if test="string-length($statsAndLogsList)!=0">
<b class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.stats.logs" />
</b>
<br />
<table width="50%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;" bordercolor="#111111"
frame="box" summary="">
<tr>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.parameter" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.current.value" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.old.value" />
</th>
</tr>
<xsl:for-each select="$jobSetting/statsAndLog/statsAndLogItem">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@param" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@currentValue" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@oldValue" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:if>
<br />
<br />
<!--Compared Component List -->
<!--HR -->
<xsl:variable name="component" select="/project/component" />
<h2 class="FONTSTYLE">
<a name="#ComparedComponentList">
<xsl:value-of
select="/project/@i18n.compare.compare.compared.component.list" />
</a>
</h2>
<xsl:variable name="addComponentList"
select="$component/addedComponentList/addedItem/@name" />
<xsl:if test="string-length($addComponentList)!=0">
<b class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.added.component" />
</b>
<br />
<table width="40%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;" bordercolor="#111111"
frame="box" summary="">
<tr>
<th width="10%" align="left" class="TABLECOLUMNSTYLE">
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.component.name" />
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.component.type" />
</th>
</tr>
<xsl:for-each select="$component/addedComponentList/addedItem">
<tr>
<td class="FONTSTYLE" align="left">
<img src="{@icon}" alt="" />
&#160;&#160;&#160;&#160;&#160;
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@name" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@type" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:if>
<xsl:variable name="deleteComponentList"
select="$component/deletedComponentList/deletedItem/@name" />
<xsl:if test="string-length($deleteComponentList)!=0">
<b class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.current.deleted.component" />
</b>
<br />
<table width="40%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;" bordercolor="#111111"
frame="box" summary="">
<tr>
<th width="10%" align="left" class="TABLECOLUMNSTYLE">
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.component.name" />
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.component.type" />
</th>
</tr>
<xsl:for-each select="$component/deletedComponentList/deletedItem">
<tr>
<td class="FONTSTYLE" align="left">
<img src="{@icon}" alt="" />
&#160;&#160;&#160;&#160;&#160;
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@name" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@type" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:if>
<xsl:variable name="modifyComponentList"
select="$component/modifiedComponentList/modifiedItem/@name" />
<xsl:if test="string-length($modifyComponentList)!=0">
<b class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.added.modified.component" />
</b>
<br />
<table width="40%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;" bordercolor="#111111"
frame="box" summary="">
<tr>
<th width="10%" align="left" class="TABLECOLUMNSTYLE">
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.component.name" />
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.component.type" />
</th>
</tr>
<xsl:for-each select="$component/modifiedComponentList/modifiedItem">
<tr>
<td class="FONTSTYLE" align="center">
<img src="{@icon}" alt="" />
&#160;&#160;&#160;&#160;&#160;
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@name" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@type" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:if>
<br />
<br />
<!-- _START_ Compared Component Modified Detailed List -->
<xsl:variable name="project" select="/project" />
<xsl:if
test="string-length($project/modifyComponentListDetail/modifyComponentItem/@componentName)!=0">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
summary="">
<tr bgcolor="#666666" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of
select="/project/@i18n.compare.current.modified.component.list" />
</b>
</td>
</tr>
</table>
<br />
<xsl:for-each
select="$project/modifyComponentListDetail/modifyComponentItem">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
summary="">
<tr bgcolor="#888888" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="/project/@i18n.compare.components" />
<xsl:value-of select="@componentName" />
</b>
</td>
</tr>
</table>
<br />
<!-- _START_ paramList -->
<xsl:for-each select="paramList">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="@paraName" />
</b>
</td>
</tr>
</table>
<table width="40%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;"
bordercolor="#111111" frame="box" summary="">
<tr>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.parameter" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.current.value" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.old.value" />
</th>
</tr>
<xsl:for-each select="paramItem">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@param" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@currentValue" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@oldValue" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:for-each>
<!-- _END_ paramList -->
<br />
<!-- _START_ schemaList -->
<xsl:for-each select="schema/schemaList">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="/project/@i18n.compare.schemas" />
<xsl:value-of select="@schemaName" />
</b>
</td>
</tr>
</table>
<table width="40%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;"
bordercolor="#111111" frame="box" summary="">
<tr>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.parameter" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.current.value" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.old.value" />
</th>
</tr>
<xsl:for-each select="schemaItem">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@param" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@currentValue" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@oldValue" />
</td>
</tr>
</xsl:for-each>
</table>
</xsl:for-each>
<!-- _END_ schemaList -->
<br />
<!-- _START_ tableTypes -->
<xsl:for-each select="tableType">
<xsl:if
test="string-length(table/@name)!=0 or string-length(added/@name)!=0 or string-length(deleted/@name)!=0">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="@name" />
</b>
</td>
</tr>
</table>
<!-- _START_ Modified tables -->
<xsl:if test="string-length(table/@name)!=0">
<xsl:for-each select="table">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse"
bordercolor="#111111" summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="/project/@i18n.compare.table" />
:
<xsl:value-of select="@name" />
</b>
</td>
</tr>
</table>
<!-- _START_ Modified Columns -->
<xsl:if test="string-length(modified/@name)!=0">
<xsl:for-each select="modified">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse"
bordercolor="#111111" summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="@name" />
</b>
</td>
</tr>
</table>
<table width="40%" border="1" cellpadding="0"
cellspacing="0" style="border-collapse: collapse; padding-left:10mm;"
bordercolor="#111111" frame="box" summary="">
<tr>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.column" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.current.value" />
</th>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.old.value" />
</th>
</tr>
<xsl:for-each select="column">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@name" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@currentValue" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@oldValue" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:for-each>
</xsl:if>
<!-- _END_ Modified Columns -->
<br />
<!-- _START_ Added Columns -->
<xsl:if test="string-length(added/column/@name)!=0">
<xsl:for-each select="added">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse"
bordercolor="#111111" summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="/project/@i18n.compare.added" />
</b>
</td>
</tr>
</table>
<table width="40%" border="1" cellpadding="0"
cellspacing="0" style="border-collapse: collapse; padding-left:10mm;"
bordercolor="#111111" frame="box" summary="">
<tr>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.column" />
</th>
</tr>
<xsl:for-each select="column">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@name" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:for-each>
</xsl:if>
<!-- _END_ Added Columns -->
<br />
<!-- _START_ Deleted Columns -->
<xsl:if test="string-length(deleted/column/@name)!=0">
<xsl:for-each select="deleted">
<table border="0" class="FONTSTYLE" cellpadding="0"
cellspacing="0" style="border-collapse: collapse"
bordercolor="#111111" summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="/project/@i18n.compare.deleted" />
</b>
</td>
</tr>
</table>
<table width="40%" border="1" cellpadding="0"
cellspacing="0" style="border-collapse: collapse; padding-left:10mm;"
bordercolor="#111111" frame="box" summary="">
<tr>
<th width="33%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.column" />
</th>
</tr>
<xsl:for-each select="column">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@name" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:for-each>
</xsl:if>
<!-- _END_ Deleted Columns -->
</xsl:for-each>
</xsl:if>
<br />
<!-- _START_ Modified tables -->
<!-- _START_ Add tables -->
<xsl:if test="string-length(added/@name)!=0">
<table width="40%" border="1" cellpadding="0"
cellspacing="0" style="border-collapse: collapse; padding-left:10mm;"
bordercolor="#111111" frame="box" summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="/project/@i18n.compare.added.tables" />
</b>
</td>
</tr>
<xsl:for-each select="added">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@name" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:if>
<!-- _END_ Added tables -->
<!-- _START_ Deteled tables -->
<xsl:if test="string-length(deleted/@name)!=0">
<table width="40%" border="1" cellpadding="0"
cellspacing="0" style="border-collapse: collapse; padding-left:10mm;"
bordercolor="#111111" frame="box" summary="">
<tr bgcolor="#E6E6E6" class="FONTSTYLE">
<td class="FONTSTYLE">
<b>
<xsl:value-of select="/project/@i18n.compare.deleted.tables" />
</b>
</td>
</tr>
<xsl:for-each select="deleted">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@name" />
</td>
</tr>
</xsl:for-each>
</table>
<br />
</xsl:if>
<!-- _END_ Deteled tables -->
</xsl:if>
</xsl:for-each>
<!-- _END_ tableType -->
</xsl:for-each>
</xsl:if>
<!-- _END_ Compared Component Modified Detailed List -->
<!--Compared Connector List -->
<xsl:variable name="connector" select="/project/connector" />
<h2 class="FONTSTYLE">
<a name="#ComparedConnectorList">
<xsl:value-of
select="/project/@i18n.compare.compare.compared.connector.list" />
</a>
</h2>
<xsl:variable name="addConnectorList"
select="$connector/addedConnectorList/addedItem/@Title" />
<xsl:if test="string-length($addConnectorList)!=0">
<b class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.added.connector" />
</b>
<br />
<xsl:for-each select="$connector/addedConnectorList">
<b class="FONTSTYLE">
<xsl:value-of select="@rowname" />
</b>
<table width="40%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;" bordercolor="#111111"
frame="box" summary="">
<tr>
<th width="10%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.connector.title" />
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.connector.value" />
</th>
</tr>
<xsl:for-each select="addedItem">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@Title" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@NewValue" />
</td>
</tr>
</xsl:for-each>
</table>
<b></b>
</xsl:for-each>
<br />
</xsl:if>
<xsl:variable name="deleteConnectorList"
select="$connector/deletedConnectorList/deletedItem/@Title" />
<xsl:if test="string-length($deleteConnectorList)!=0">
<b class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.current.deleted.connector" />
</b>
<br />
<xsl:for-each select="$connector/deletedConnectorList">
<b class="FONTSTYLE">
<xsl:value-of select="@rowname" />
</b>
<table width="40%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;" bordercolor="#111111"
frame="box" summary="">
<tr>
<th width="10%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.connector.title" />
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.connector.value" />
</th>
</tr>
<xsl:for-each select="deletedItem">
<tr>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@Title" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@OldValue" />
</td>
</tr>
</xsl:for-each>
</table>
<b></b>
</xsl:for-each>
<br />
</xsl:if>
<xsl:variable name="modifyConnectorList"
select="$connector/modifiedConnectorList/modifiedItem/@Title" />
<xsl:if test="string-length($modifyConnectorList)!=0">
<b class="FONTSTYLE">
<xsl:value-of select="/project/@i18n.compare.added.modified.connector" />
</b>
<br />
<xsl:for-each select="$connector/modifiedConnectorList">
<b class="FONTSTYLE">
<xsl:value-of select="@rowname" />
</b>
<table width="40%" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse; padding-left:10mm;" bordercolor="#111111"
frame="box" summary="">
<tr>
<th width="10%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.connector.title" />
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.connector.newvalue" />
</th>
<th width="45%" align="left" class="TABLECOLUMNSTYLE">
<xsl:value-of select="/project/@i18n.compare.connector.oldvalue" />
</th>
</tr>
<xsl:for-each select="modifiedItem">
<tr>
<td class="FONTSTYLE" align="center">
<xsl:value-of select="@Title" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@NewValue" />
</td>
<td class="FONTSTYLE" align="left">
<xsl:value-of select="@OldValue" />
</td>
</tr>
</xsl:for-each>
</table>
<b></b>
</xsl:for-each>
</xsl:if>
<br />
<br />
<!--End Compared Connector List -->
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -1,98 +0,0 @@
// ============================================================================
//
// 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.repository.model.migration;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
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;
/**
* This migration task add the die on error option on the sqoop components. It reverses the default value (from false to
* true) in case of the java API is used.
*
* DOC rdubois class global comment. Detailled comment
*/
public class AddDieOnErrorOnSqoopComponents extends AbstractJobMigrationTask {
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
String[] arrSqoopComponentsName = new String[] {
"tSqoopImport", "tSqoopExport", "tSqoopMerge", "tSqoopImportAllTables" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
for (String sqoopComponentsName : arrSqoopComponentsName) {
IComponentFilter filter = new NameComponentFilter(sqoopComponentsName);
IComponentConversion addOption = new AddDieOnErrorOptionConversion();
ModifyComponentsAction
.searchAndModify(item, processType, filter, Arrays.<IComponentConversion> asList(addOption));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2014, 8, 11, 17, 00, 00);
return gc.getTime();
}
/**
* DOC rdubois AddDieOnErrorOptionConversion class global comment. Detailled comment
*/
private class AddDieOnErrorOptionConversion implements IComponentConversion {
private String field = "CHECK"; //$NON-NLS-1$
private String name = "DIE_ON_ERROR"; //$NON-NLS-1$
private String mode = "USE_COMMANDLINE"; //$NON-NLS-1$
public AddDieOnErrorOptionConversion() {
super();
}
@Override
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, name) == null) {
ComponentUtilities.addNodeProperty(node, name, field);
ComponentUtilities.setNodeValue(node, name, "true"); //$NON-NLS-1$
ElementParameterType modeType = ComponentUtilities.getNodeProperty(node, mode);
if (modeType != null && "true".equals(modeType.getValue())) { //$NON-NLS-1$
ComponentUtilities.setNodeValue(node, name, "false"); //$NON-NLS-1$
}
}
}
}
}

View File

@@ -1,82 +0,0 @@
// ============================================================================
//
// 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.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.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;
/**
* DOC Administrator class global comment. Detailled comment
*/
public class ChangeMappingParameter4Redshift extends
AbstractJobMigrationTask {
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
String[] compNames = {"tRedshiftInput", "tRedshiftOutput"}; //$NON-NLS-1$ //$NON-NLS-2$
IComponentConversion changeDBName4Hive = new IComponentConversion() {
public void transform(NodeType node) {
if(node == null) {
return;
}
ElementParameterType dbId = ComponentUtilities.getNodeProperty(node, "MAPPING"); //$NON-NLS-1$
if (dbId == null) {
return;
}
dbId.setValue("redshift_id");//$NON-NLS-1$
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays
.<IComponentConversion> asList(changeDBName4Hive));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2015, 0, 14, 17, 0, 0);
return gc.getTime();
}
}

View File

@@ -1,72 +0,0 @@
// ============================================================================
//
// 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.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.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;
/**
* DOC Administrator class global comment. Detailled comment
*/
public class ChangeParameterName4tMDMConnection extends
AbstractJobMigrationTask {
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tMDMConnection");
try {
ModifyComponentsAction.searchAndModify(item,processType,filter,
Arrays.<IComponentConversion> asList(new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType username = ComponentUtilities.getNodeProperty(node, "USER"); //$NON-NLS-1$
ElementParameterType passwd = ComponentUtilities.getNodeProperty(node, "PASS"); //$NON-NLS-1$
if (username != null) { //$NON-NLS-1$
ComponentUtilities.getNodeProperty(node, "USER").setName("USERNAME");
}
if (passwd != null) { //$NON-NLS-1$
ComponentUtilities.getNodeProperty(node, "PASS").setName("PASSWORD");
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2014, 9, 21, 12, 0, 0);
return gc.getTime();
}
}

View File

@@ -1,88 +0,0 @@
// ============================================================================
//
// 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.repository.model.migration;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.model.components.ComponentUtilities;
import org.talend.core.model.components.ModifyComponentsAction;
import org.talend.core.model.components.conversions.IComponentConversion;
import org.talend.core.model.components.filters.IComponentFilter;
import org.talend.core.model.components.filters.NameComponentFilter;
import org.talend.core.model.migration.AbstractJobMigrationTask;
import org.talend.core.model.properties.Item;
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
/**
* created by wwang on Aug 15, 2014 Detailled comment
*
*/
public class ChangeRecalculateFormulaValueMigrationTask extends AbstractJobMigrationTask {
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
String[] componentsName = new String[] { "tFileOutputExcel" }; //$NON-NLS-1$
try {
for (String element : componentsName) {
IComponentFilter filter = new NameComponentFilter(element);
ModifyComponentsAction.searchAndModify(item, processType, filter,
Arrays.<IComponentConversion> asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
ElementParameterType ept = ComponentUtilities.getNodeProperty(node, "RECALCULATE_FORMULA");//$NON-NLS-1$
if(ept == null) {
ComponentUtilities.addNodeProperty(node, "RECALCULATE_FORMULA", "CHECK"); //$NON-NLS-1$//$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "RECALCULATE_FORMULA", "true"); //$NON-NLS-1$//$NON-NLS-2$
}
}
})
);
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
/*
* (non-Javadoc)
*
* @see org.talend.migration.IMigrationTask#getOrder()
*/
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2014, 7, 15, 15, 0, 0);
return gc.getTime();
}
}

View File

@@ -1,71 +0,0 @@
// ============================================================================
//
// 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.repository.model.migration;
import java.util.Arrays;
import java.util.Date;
import java.util.GregorianCalendar;
import org.talend.commons.exception.ExceptionHandler;
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.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
/**
* DOC Administrator class global comment. Detailled comment
*/
public class ChangeUseBatchSizetoFalse4AS400 extends AbstractJobMigrationTask {
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
String[] componentsName = new String[] { "tAS400Output" };
try {
for (String element : componentsName) {
IComponentFilter filter = new NameComponentFilter(element);
ModifyComponentsAction.searchAndModify(item, processType, filter,
Arrays.<IComponentConversion> asList(new IComponentConversion() {
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE") == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
}
}
}));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2014, 7, 5, 12, 0, 0);
return gc.getTime();
}
}

View File

@@ -1,108 +0,0 @@
// ============================================================================
//
// 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.repository.model.migration;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
import org.talend.commons.utils.PasswordEncryptUtil;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.FTPConnection;
import org.talend.core.model.migration.AbstractItemMigrationTask;
import org.talend.core.model.properties.FTPConnectionItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.repository.model.ProxyRepositoryFactory;
/**
* created by hcyi on Jul 8, 2014 Detailled comment
*
*/
public class EncryptPassword4FTPItemFileMigrationTask extends AbstractItemMigrationTask {
private ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
if (item instanceof FTPConnectionItem) {
FTPConnectionItem item1 = (FTPConnectionItem) item;
Connection connection = item1.getConnection();
if (connection instanceof FTPConnection) {
FTPConnection ftpConn = (FTPConnection) connection;
try {
if (encryptPassword(ftpConn)) {
factory.save(item, true);
}
} catch (Exception e1) {
ExceptionHandler.process(e1);
return ExecutionResult.FAILURE;
}
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
public boolean encryptPassword(FTPConnection ftpConn) throws Exception {
boolean modified = false;
if (ftpConn.getPassword() != null) {
String password = PasswordEncryptUtil.encryptPassword(ftpConn.getPassword());
ftpConn.setPassword(password + PasswordEncryptUtil.ENCRYPT_KEY);
modified = true;
}
if (ftpConn.getPassphrase() != null) {
String password = PasswordEncryptUtil.encryptPassword(ftpConn.getPassphrase());
ftpConn.setPassphrase(password + PasswordEncryptUtil.ENCRYPT_KEY);
modified = true;
}
if (ftpConn.getKeystorePassword() != null) {
String password = PasswordEncryptUtil.encryptPassword(ftpConn.getKeystorePassword());
ftpConn.setKeystorePassword(password + PasswordEncryptUtil.ENCRYPT_KEY);
modified = true;
}
if (ftpConn.getProxypassword() != null) {
String password = PasswordEncryptUtil.encryptPassword(ftpConn.getProxypassword());
ftpConn.setProxypassword(password + PasswordEncryptUtil.ENCRYPT_KEY);
modified = true;
}
return modified;
}
@Override
public List<ERepositoryObjectType> getTypes() {
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
toReturn.add(ERepositoryObjectType.METADATA_FILE_FTP);
return toReturn;
}
/*
* (non-Javadoc)
*
* @see org.talend.migration.IProjectMigrationTask#getOrder()
*/
@Override
public Date getOrder() {
GregorianCalendar gc = new GregorianCalendar(2014, 7, 8, 12, 0, 0);
return gc.getTime();
}
}

View File

@@ -1,49 +0,0 @@
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.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.NodeType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
public class SetDieOnErrorFalse4tSCPDelete extends AbstractJobMigrationTask {
@Override
public Date getOrder() {
return new GregorianCalendar(2014, 12, 04, 14, 0, 0).getTime();
}
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tSCPDelete");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter,
Arrays.<IComponentConversion> asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "DIE_ON_ERROR") == null) {
ComponentUtilities.addNodeProperty(node, "DIE_ON_ERROR", "CHECK");
}
ComponentUtilities.getNodeProperty(node, "DIE_ON_ERROR").setValue("false");
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
}

Some files were not shown because too many files have changed in this diff Show More