Compare commits

...

29 Commits

Author SHA1 Message Date
oleksandr
9c3d2cfad4 TAC-15694 (#4757)
[7.2.1] TAC jobs cant be killed, and incorrect status reported

Co-authored-by: oleksandr <ovelychko@talend.com>
2021-11-03 20:41:32 +08:00
AlixMetivier
ca9868e83f fix(TBD-10269): force return in case of bad job design (#3287) (#3342) 2020-05-27 15:59:28 +02:00
kjwang
b961dc9002 Fix TUP-26288_Enhance context joblet build in param internal id change (#3331)
problem
https://jira.talendforge.org/browse/TUP-26288
2020-05-26 18:47:10 +08:00
kjwang
ff56cbc16b Fix TUP-26639 Talend Cloud studio Issue -Changes to Context Parameter (#3330)
* Fix TUP-26639 Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake

* Fix TUP-26639 Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake
2020-05-26 18:14:07 +08:00
kjwang
096be8c100 kjwang/Fix TUP-26288 Fix salesforce context var update issue (#3326)
https://jira.talendforge.org/browse/TUP-26288
2020-05-25 15:35:47 +08:00
kjwang
e5ef1fc64d Kjwang/temp 3840 (#3324)
TUP-26696 Enhance context propagation over reference project -
Propagation
https://jira.talendforge.org/browse/TUP-26696
2020-05-22 18:23:54 +08:00
AlixMetivier
f51d183a96 fix(TBD-10370):"Hadoop configuration jar not found" when run spark job (#3221) (#3323)
Co-authored-by: Zhiwei Xue <zwxue@talend.com>
2020-05-22 10:24:19 +02:00
hcyi
7d3efda121 fix(TUP-27000):Talend Salesforce Einstein connector Repository (#3274)
connection issue in Talend 7.3
2020-05-22 12:44:04 +08:00
Chao MENG
c2ca0d161e feat(TUP-26569): merge known conflicts automatically
https://jira.talendforge.org/browse/TUP-26569
2020-05-22 11:11:56 +08:00
Jane Ding
cbd0b4035a fix(TUP-27003):Should disable the Commit button of Uncommitted files (#3273) (#3319)
found dialog when project is in MERGING state
https://jira.talendforge.org/browse/TUP-27003
2020-05-22 10:48:26 +08:00
hwang-talend
5ab96746ea Hwang/tup 26994 (#3282)
* bugfix(TUP-26994):Usage data collector : change the way Studio Unique Id
is calculated
2020-05-21 11:12:25 +08:00
zhangjie
da086ac7d1 feat(TUP-26284)Upgrade AWS SDK for driver in metadata 2020-05-21 11:08:45 +08:00
jiezhang-tlnd
52b5a1dd48 Jzhang/feat/tup 26284 upgrade aws sdk for driver in metadata (#3244)
* feat(TUP-26284)Upgrade AWS SDK for driver in metadata

* feat(TUP-26284)update other jar except aws-java-sdk
2020-05-21 11:08:25 +08:00
Jane Ding
4cec5920fc Jding/patch731/tup 26639 group context and connection issue (#3261)
* fix(TUP-26639):Talend Cloud studio Issues - Group context and (#3233) (#3243)

connections
https://jira.talendforge.org/browse/TUP-26639

* fix(TUP-26639):Talend Cloud studio Issue -Changes to Context Parameter (#3249) (#3256)

* fix(TUP-26639):Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake
https://jira.talendforge.org/browse/TUP-26639

* fix(TUP-26639):Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake
https://jira.talendforge.org/browse/TUP-26639

* fix(TUP-26639):Talend Cloud studio Issue -Changes to Context Parameter
Names is not reflected on the Connection for Snowflake
https://jira.talendforge.org/browse/TUP-26639
2020-05-21 11:05:16 +08:00
hwang-talend
fc00adcb09 Hwang/tup 26870 (#3214)
* bugfix(TUP-26870):Incorrect sorting order
2020-05-19 14:41:16 +08:00
Zhiwei Xue
5d6e0f5bc3 fix(TUP-26961):When save/delete a test case, it might break the poms/CI (#3253) 2020-05-19 14:38:45 +08:00
hwang-talend
56f2c1a39f bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries (#3246)
* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding

* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding

* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding

* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding

* bugfix(TUP-26956):Update Studio top bar to reflect monthly deliveries
for better understanding
2020-05-19 14:36:23 +08:00
Jane Ding
05c389a58c feat(TUP-16546)Prompt users for new password in Studio Connection when (#3119) (#3251)
* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546

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

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

* feat(TUP-16546)Prompt users for new password in Studio Connection when
AD/LDAP credentials change in TAC
https://jira.talendforge.org/browse/TUP-16546
2020-05-19 14:27:24 +08:00
Zhiwei Xue
2074d44db6 fix(TUP-27077): NoClassDefFoundException when using "independent process (#3286)
to run subjob" and tAzureAdlsGen2Input
2020-05-14 20:08:37 +08:00
Liu Xinquan
103829ad63 fix(TDQ-18049) add the "transform" to avoid class conflict when shaded (#3085) (#3263)
Co-authored-by: qiongli <qiongli@talend.com>
2020-05-11 09:55:03 +08:00
Liu Xinquan
25241eaf13 fix(TDQ-18322) throw NPE when retrieve the schema on Sybase (#3234) (#3248) 2020-05-08 21:12:01 +08:00
Zhiwei Xue
544535ecc7 fix(TUP-26809):Job zip should not contain jars from testcase only (#3237) 2020-04-27 17:59:28 +08:00
Zhiwei Xue
6fd415e029 Patch/7.3.1 TPS-3839 monthly patch backport (#3222)
* fix(TUP-26596)Proxy of libraries not working when studio have no (#3165) (#3172)

* fix(TUP-26596)Proxy of libraries not working when studio have no
internet access

* fix(TUP-26596)Proxy of libraries not working when studio have no
internet access

* fix(TUP-26596)Proxy of libraries not working when studio have no
internet access

* fix(TUP-26596)Proxy of libraries not working when studio have no
internet access

* fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy failure (#3101) (#3114)

* fix(TUP-26189): [7.2.1] snowflake metadata connection with proxy failure

https://jira.talendforge.org/browse/TUP-26189

* fix(TUP-26793)JDBC Redshift in context mode still asked for jars
https://jira.talendforge.org/browse/TUP-26793

* fix(TUP-26212): Share more than one car component to nexus3.19.1 will fail to generate the right index file (#3100) (#3120)

* fix(TUP-26212): Share more than one car component to nexus3.19.1 will
fail to generate the right index file

https://jira.talendforge.org/browse/TUP-26212

* fix(TUP-26212): Share more than one car component to nexus3.19.1 will
fail to generate the right index file

https://jira.talendforge.org/browse/TUP-26212

Co-authored-by: bhe-talendbj <52311292+bhe-talendbj@users.noreply.github.com>

* fix(TUP-26539): Unassociate data from associateListeners (#3169)

* fix(TUP-26539): Fix wrong tree node implmentation

* fix(TUP-26539): add test case

* fix(TUP-26539): Remove reference to itself

* fix(TUP-26539): Return root node

* fix(TUP-26539): Update test case

* fix(TUP-26539): update test case

* fix(TUP-26539): Unassociate unnecessary listeners

* fix(TUP-26539): Revert changes of RepositoryNode

* fix(TUP-26539): Add override annotation

* fix(TUP-26876):NoClassDefFoundError when I run spark job with JobServer

Co-authored-by: hzhao-talendbj <49395568+hzhao-talendbj@users.noreply.github.com>
Co-authored-by: kjwang <kjwang@talend.com>
Co-authored-by: zhangjie <jie.zhang@talend.com>
Co-authored-by: Chao MENG <cmeng@talend.com>
Co-authored-by: bhe-talendbj <52311292+bhe-talendbj@users.noreply.github.com>
2020-04-17 14:44:26 +08:00
Liu Xinquan
93f0c89ae0 fix(TDQ-18135) support context variable in tDataEncrypt (#3180) (#3207) 2020-04-15 15:55:10 +08:00
Zhiwei Xue
89dd33e3b7 fix(TUP-26728):fix regression on preview function. 2020-04-09 11:25:39 +08:00
Zhiwei Xue
4f411af729 fix(TUP-26728):Missing spark dependencies when using test cases 2020-04-08 23:34:13 +08:00
Zhiwei Xue
f8b1e6ae34 fix(TUP-26728):The parent DI job misses to load some required libraries
from the Spark job
2020-04-07 17:46:45 +08:00
Jane Ding
4931b8835e fix(TUP-26576):Warning pops up cannot connect to the user libraries (#3154) (#3164)
artifact repository set in administrator
https://jira.talendforge.org/browse/TUP-26576
2020-03-26 11:04:55 +08:00
Zhiwei Xue
b067d61afd fix(TUP-26165):fix jar with classifier missing issue (#3152)
* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP (#3105)

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165)jar referenced in bat or sh classpath missing in build ZIP
file folder lib
https://jira.talendforge.org/browse/TUP-26165

* fix(TUP-26165):fix jar with classifier missing issue

Co-authored-by: Jane Ding <35018295+jding-tlnd@users.noreply.github.com>
2020-03-20 21:01:31 +08:00
91 changed files with 4551 additions and 1865 deletions

View File

@@ -21,6 +21,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
@@ -38,6 +39,8 @@ public class ExceptionMessageDialog extends MessageDialog {
private String exceptionString = null;
private int[] diabledButtonIndex = new int[] {};
public ExceptionMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
int dialogImageType, String[] dialogButtonLabels, int defaultIndex, Throwable ex) {
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
@@ -147,4 +150,21 @@ public class ExceptionMessageDialog extends MessageDialog {
this.exceptionString = exceptionString;
}
public void setDisabledButtons(int[] index) {
this.diabledButtonIndex = index;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
super.createButtonsForButtonBar(parent);
if (diabledButtonIndex == null) {
return;
}
for (int index : diabledButtonIndex) {
Button button = super.getButton(index);
button.setEnabled(false);
}
}
}

View File

@@ -13,7 +13,8 @@ Require-Bundle: org.apache.log4j;visibility:=reexport,
org.talend.libraries.apache,
com.ibm.icu,
org.apache.commons.io,
org.talend.utils
org.talend.utils,
org.eclipse.core.net
Export-Package: org.talend.commons,
org.talend.commons.exception,
org.talend.commons.i18n,

View File

@@ -17,6 +17,7 @@ import java.io.InputStream;
import java.net.URL;
import org.apache.commons.lang.ArrayUtils;
import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.InstanceScope;
@@ -24,6 +25,7 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.talend.commons.exception.ExceptionService;
import org.talend.commons.runtime.debug.TalendDebugHandler;
import org.talend.commons.utils.system.EclipseCommandLine;
@@ -55,6 +57,8 @@ public class CommonsPlugin implements BundleActivator {
// TESB-17856: For commandline builds ESB Micorservice bundle
private static boolean isESBMicorservice = false;
private static ServiceTracker proxyTracker;
public static boolean isWorkbenchCreated() {
return isWorkbenchCreated;
}
@@ -179,4 +183,13 @@ public class CommonsPlugin implements BundleActivator {
return FileLocator.toFileURL(entry);
}
public static IProxyService getProxyService() {
if (proxyTracker == null) {
proxyTracker = new ServiceTracker(Platform.getBundle(PLUGIN_ID).getBundleContext(), IProxyService.class.getName(),
null);
proxyTracker.open();
}
return (IProxyService) proxyTracker.getService();
}
}

View File

@@ -0,0 +1,58 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.commons.exception;
public class ClientException extends PersistenceException {
private Integer httpCode;
public ClientException(String message) {
super(message);
}
public ClientException(Integer httpCode, String message) {
super(message);
this.httpCode = httpCode;
}
public ClientException(String message, Throwable cause) {
super(message, cause);
}
public ClientException(Integer httpCode, String message, Throwable cause) {
super(message, cause);
this.httpCode = httpCode;
}
public ClientException(Throwable cause) {
super(cause);
}
public ClientException(Integer httpCode, Throwable cause) {
super(cause);
this.httpCode = httpCode;
}
public Integer getHttpCode() {
return httpCode;
}
public void setHttpCode(Integer httpCode) {
this.httpCode = httpCode;
}
@Override
public String toString() {
return getLocalizedMessage();
}
}

View File

@@ -42,6 +42,8 @@ public interface ITaCoKitService {
boolean isNeedMigration(String componentName, Map<String, String> properties);
boolean isTaCoKitType(Object repoType);
public static ITaCoKitService getInstance() throws Exception {
BundleContext bc = FrameworkUtil.getBundle(ITaCoKitService.class).getBundleContext();
Collection<ServiceReference<ITaCoKitService>> tacokitServices = Collections.emptyList();

View File

@@ -13,6 +13,8 @@
package org.talend.commons.utils.network;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
@@ -35,8 +37,14 @@ import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Priority;
import org.eclipse.core.internal.net.ProxyManager;
import org.eclipse.core.net.proxy.IProxyService;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.i18n.internal.Messages;
import org.talend.daikon.sandbox.properties.ClassLoaderIsolatedSystemProperties;
import sun.net.spi.DefaultProxySelector;
/**
* DOC cmeng class global comment. Detailled comment
@@ -51,9 +59,23 @@ public class TalendProxySelector extends ProxySelector {
private static final String PROP_ALLOW_PROXY_REDIRECT_EXCLUDE = "talend.studio.proxy.redirect.whiteList";
private static final String PROP_EXECUTE_CONNECTION_FAILED = "talend.studio.proxy.executeConnectionFailed";
private static final String PROP_UPDATE_SYSTEM_PROPERTIES_FOR_JRE = "talend.studio.proxy.jre.updateSystemProperties";
private static final String PROP_CHECK_PROXY = "talend.studio.proxy.checkProxy";
private static final String PROP_VALIDATE_URI = "talend.studio.proxy.validateUri";
private static final String PROP_PROXY_SELECTOR = "talend.studio.proxy.selector";
private static final String PROP_PROXY_SELECTOR_DEFAULT = "default";
private static final String PROP_PROXY_SELECTOR_JRE = "jre";
private static final String PROP_PROXY_HOST_MAP = "talend.studio.proxy.hostMap";
private static final String PROP_DISABLE_DEFAULT_SELECTOR = "talend.studio.proxy.disableDefaultSelector";
private static final String PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER = "talend.studio.proxy.disableDefaultSelectorProvider";
/**
* Example: update.talend.com,socket:http,https:http;nexus.talend.com,socket,http;,socket:http
@@ -67,7 +89,20 @@ public class TalendProxySelector extends ProxySelector {
private static final String KEY_DEFAULT = ":default:";
private ProxySelector defaultSelector;
private static Field uriHostField;
private static Method proxyManagerUpdateSystemPropertiesFunc;
private static boolean checkProxy = Boolean.valueOf(System.getProperty(PROP_CHECK_PROXY, Boolean.TRUE.toString()));
/**
* Note: eclipse default selector may be different between TOS and TIS, TOS may use jre one, TIS may use egit one
*/
private ProxySelector eclipseDefaultSelector;
private ProxySelector jreDefaultSelector;
private EProxySelector eProxySelector;
final private Map<Object, Collection<IProxySelectorProvider>> selectorProviders;
@@ -83,15 +118,36 @@ public class TalendProxySelector extends ProxySelector {
private boolean allowProxyRedirect = false;
private boolean disableDefaultSelector = false;
private boolean disableDefaultSelectorProvider = false;
private TalendProxySelector(final ProxySelector defaultSelector) {
this.defaultSelector = defaultSelector;
private boolean validateUri = true;
private boolean executeConnectionFailed = true;
private boolean updateSystemPropertiesForJre = true;
private TalendProxySelector(final ProxySelector eclipseDefaultSelector) {
this.eclipseDefaultSelector = eclipseDefaultSelector;
this.jreDefaultSelector = new DefaultProxySelector();
selectorProviders = Collections.synchronizedMap(new HashMap<>());
allowProxyRedirect = Boolean.valueOf(System.getProperty(PROP_ALLOW_PROXY_REDIRECT, Boolean.FALSE.toString()));
disableDefaultSelector = Boolean.valueOf(System.getProperty(PROP_DISABLE_DEFAULT_SELECTOR, Boolean.FALSE.toString()));
disableDefaultSelectorProvider = Boolean
.valueOf(System.getProperty(PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER, Boolean.FALSE.toString()));
printProxyLog = Boolean.valueOf(System.getProperty(PROP_PRINT_LOGS, Boolean.FALSE.toString()));
validateUri = Boolean.valueOf(System.getProperty(PROP_VALIDATE_URI, Boolean.TRUE.toString()));
executeConnectionFailed = Boolean.valueOf(System.getProperty(PROP_EXECUTE_CONNECTION_FAILED, Boolean.TRUE.toString()));
updateSystemPropertiesForJre = Boolean
.valueOf(System.getProperty(PROP_UPDATE_SYSTEM_PROPERTIES_FOR_JRE, Boolean.TRUE.toString()));
switch (System.getProperty(PROP_PROXY_SELECTOR, PROP_PROXY_SELECTOR_DEFAULT).toLowerCase()) {
case PROP_PROXY_SELECTOR_JRE:
this.eProxySelector = EProxySelector.jre;
break;
default:
this.eProxySelector = EProxySelector.eclipse_default;
break;
}
initHostMap();
initRedirectList();
@@ -176,6 +232,18 @@ public class TalendProxySelector extends ProxySelector {
synchronized (instanceLock) {
if (instance == null) {
instance = new TalendProxySelector(proxySelector);
try {
uriHostField = URI.class.getDeclaredField("host");
uriHostField.setAccessible(true);
} catch (Exception e) {
ExceptionHandler.process(e);
}
try {
proxyManagerUpdateSystemPropertiesFunc = ProxyManager.class.getDeclaredMethod("updateSystemProperties");
proxyManagerUpdateSystemPropertiesFunc.setAccessible(true);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
}
@@ -188,34 +256,72 @@ public class TalendProxySelector extends ProxySelector {
return null;
}
});
if (instance.getDefaultProxySelector() == null
if (instance.getEclipseDefaultSelector() == null
|| (proxySelector != null && proxySelector.getClass().getName().endsWith(ECLIPSE_PROXY_SELECTOR))) {
instance.setDefaultProxySelector(proxySelector);
instance.setEclipseDefaultSelector(proxySelector);
}
}
return instance;
}
public static void checkProxy() {
if (!checkProxy) {
return;
}
try {
TalendProxySelector.getInstance();
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
@Override
public List<Proxy> select(final URI uri) {
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.select " + uri);
}
if (uri == null) {
return Collections.EMPTY_LIST;
}
URI validatedUri = validateUri(uri);
Set<Proxy> results = new LinkedHashSet<>();
try {
final Set<Proxy> resultFromProviders = getProxysFromProviders(uri);
final Set<Proxy> resultFromProviders = getProxysFromProviders(validatedUri);
if (resultFromProviders != null && !resultFromProviders.isEmpty()) {
results.addAll(resultFromProviders);
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.resultFromProviders " + results);
}
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.defaultProxySelector " + defaultProxySelector);
}
if (defaultProxySelector != null) {
URI newUri = getNewUri(uri);
List<Proxy> defaultProxys = defaultProxySelector.select(newUri);
/**
* don't validate uri here, so that we can know whether it is an issue uri
*/
URI newUri = getNewUri(validatedUri, false);
List<Proxy> defaultProxys = null;
if (validateUri && StringUtils.isBlank(newUri.getHost())) {
/**
* If host is blank, force to use jre proxy selector to avoid the eclipse proxy selector bug
*/
defaultProxys = getJreProxySelector().select(newUri);
} else {
defaultProxys = defaultProxySelector.select(newUri);
}
if (printProxyLog) {
ExceptionHandler.log("TalendProxySelector.defaultProxys " + defaultProxys);
}
try {
results.addAll(filterProxys(uri, defaultProxys));
results.addAll(filterProxys(validatedUri, defaultProxys));
} catch (Exception e) {
results.addAll(defaultProxys);
ExceptionHandler.process(e);
@@ -229,6 +335,54 @@ public class TalendProxySelector extends ProxySelector {
return new LinkedList<Proxy>(results);
}
private URI validateUri(URI uri) {
if (!validateUri) {
return uri;
}
URI validatedUri = null;
try {
/**
* DON'T use URI.create(), MUST use the conductor which requires authority
*/
validatedUri = new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), uri.getQuery(), uri.getFragment());
/**
* Validate the host, if the host is empty, it will cause the eclipse selector to return dirrect
*/
if (StringUtils.isBlank(validatedUri.getHost())) {
String authority = validatedUri.getAuthority();
if (StringUtils.isNotBlank(authority)) {
// example: https://u:p@www.company.com:8081/path/a?param=b
String host = null;
int userInfoIndex = authority.indexOf('@');
if (0 <= userInfoIndex) {
authority = authority.substring(userInfoIndex + 1);
}
int portIndex = authority.lastIndexOf(':');
if (0 <= portIndex) {
host = authority.substring(0, portIndex);
}
try {
uriHostField.set(validatedUri, host);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
if (validatedUri == null) {
validatedUri = uri;
}
}
if (printProxyLog) {
ExceptionHandler.log("After validate: " + uri + " -> " + validatedUri);
}
return validatedUri;
}
private List<Proxy> filterProxys(final URI uri, List<Proxy> defaultProxys) {
List<Proxy> result = new ArrayList<>();
if (defaultProxys != null && !defaultProxys.isEmpty()) {
@@ -264,38 +418,48 @@ public class TalendProxySelector extends ProxySelector {
return result;
}
private URI getNewUri(URI uri) {
private URI getNewUri(URI uri, boolean validateUri) {
URI newUri = uri;
if (newUri != null) {
String host = newUri.getHost();
Map<String, String> protocolMap = null;
if (StringUtils.isNotBlank(host)) {
protocolMap = hostMap.get(host.toLowerCase());
}
if (protocolMap == null) {
protocolMap = hostMap.get(KEY_DEFAULT);
}
try {
// get host before new URI, because the host may be set manually due to URI issue
String host = newUri.getHost();
newUri = new URI(newUri.getScheme(), newUri.getAuthority(), newUri.getPath(), newUri.getQuery(),
newUri.getFragment());
Map<String, String> protocolMap = null;
if (StringUtils.isNotBlank(host)) {
protocolMap = hostMap.get(host.toLowerCase());
}
if (protocolMap == null) {
protocolMap = hostMap.get(KEY_DEFAULT);
}
if (protocolMap != null) {
String schema = newUri.getScheme();
if (schema != null) {
String lowercasedProtocol = schema.toLowerCase();
String preferedProtocol = protocolMap.get(lowercasedProtocol);
if (StringUtils.isNotBlank(preferedProtocol)) {
try {
newUri = new URI(preferedProtocol, newUri.getUserInfo(), newUri.getHost(), newUri.getPort(),
newUri.getPath(), newUri.getQuery(), newUri.getFragment());
} catch (URISyntaxException e) {
if (printProxyLog) {
ExceptionHandler.process(new Exception(
Messages.getString("TalendProxySelector.exception.proxySelectionError", newUri), e),
Priority.WARN);
}
if (protocolMap != null) {
String schema = newUri.getScheme();
if (schema != null) {
String lowercasedProtocol = schema.toLowerCase();
String preferedProtocol = protocolMap.get(lowercasedProtocol);
if (StringUtils.isNotBlank(preferedProtocol)) {
/**
* Note: MUST use the constructor which requires authority, because some uri may be illegal,
* then host info will be stored in authority field instead of host filed
*/
newUri = new URI(preferedProtocol, newUri.getAuthority(), newUri.getPath(), newUri.getQuery(),
newUri.getFragment());
}
}
}
} catch (URISyntaxException e) {
if (printProxyLog) {
ExceptionHandler.process(
new Exception(Messages.getString("TalendProxySelector.exception.proxySelectionError", uri), e),
Priority.WARN);
}
}
}
if (validateUri) {
newUri = validateUri(newUri);
}
return newUri;
}
@@ -395,11 +559,45 @@ public class TalendProxySelector extends ProxySelector {
}
public ProxySelector getDefaultProxySelector() {
return defaultSelector;
switch (eProxySelector) {
case jre:
return getJreProxySelector();
default:
return eclipseDefaultSelector;
}
}
public void setDefaultProxySelector(final ProxySelector selector) {
defaultSelector = selector;
private ProxySelector getJreProxySelector() {
try {
/**
* for tcompv0, daikon may create an isolated system properties for it, so proxies may be ignored in the new
* system properties; here we try to call the method to add proxies into the isolated system properties
*/
if (updateSystemPropertiesForJre && ClassLoaderIsolatedSystemProperties.getInstance()
.isIsolated(Thread.currentThread().getContextClassLoader())) {
if (printProxyLog) {
ExceptionHandler.log("Before update jre proxy system properties for the isolated classloader, http.proxyHost="
+ System.getProperty("http.proxyHost"));
}
IProxyService proxyService = CommonsPlugin.getProxyService();
proxyManagerUpdateSystemPropertiesFunc.invoke(proxyService);
if (printProxyLog) {
ExceptionHandler.log("After updated jre proxy system properties for the isolated classloader, http.proxyHost="
+ System.getProperty("http.proxyHost"));
}
}
} catch (Throwable e) {
ExceptionHandler.process(e);
}
return this.jreDefaultSelector;
}
public ProxySelector getEclipseDefaultSelector() {
return eclipseDefaultSelector;
}
public void setEclipseDefaultSelector(ProxySelector eclipseDefaultSelector) {
this.eclipseDefaultSelector = eclipseDefaultSelector;
}
@Override
@@ -413,21 +611,26 @@ public class TalendProxySelector extends ProxySelector {
});
}
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (defaultProxySelector != null) {
defaultProxySelector.connectFailed(uri, sa, ioe);
if (executeConnectionFailed) {
/**
* Just try to make the behavior of jre proxy selector same like eclipse proxy selector
*/
ProxySelector defaultProxySelector = getDefaultProxySelector();
if (defaultProxySelector != null) {
defaultProxySelector.connectFailed(uri, sa, ioe);
}
}
}
public IProxySelectorProvider createDefaultProxySelectorProvider() {
if (disableDefaultSelector) {
if (disableDefaultSelectorProvider) {
return null;
}
return new DefaultProxySelectorProvider(Thread.currentThread());
}
public IProxySelectorProvider createDefaultProxySelectorProvider(String host) {
if (disableDefaultSelector) {
if (disableDefaultSelectorProvider) {
return null;
}
return new DefaultProxySelectorProvider(host);
@@ -445,6 +648,11 @@ public class TalendProxySelector extends ProxySelector {
return possibleKeys;
}
private enum EProxySelector {
eclipse_default,
jre
}
private class DefaultProxySelectorProvider extends AbstractProxySelectorProvider {
private Thread currentThread = null;
@@ -475,7 +683,7 @@ public class TalendProxySelector extends ProxySelector {
@Override
public boolean canHandle(URI uri) {
if (disableDefaultSelector) {
if (disableDefaultSelectorProvider) {
return false;
}
if (currentThread != null && Thread.currentThread() == currentThread) {

View File

@@ -215,8 +215,12 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
lockerValue.getLock().lockInterruptibly();
traceStackForDebugging(lockerValue);
}
@@ -239,8 +243,12 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = this.prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
boolean locked = lockerValue.getLock().tryLock();
if (locked) {
traceStackForDebugging(lockerValue);
@@ -283,8 +291,12 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = this.prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
interruptIfStopping();
boolean locked = lockerValue.getLock().tryLock(timeout, unit);
if (locked) {
@@ -322,13 +334,17 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = getLockerValue(key);
boolean returnValue = false;
if (lockerValue != null) {
lockerValue.getLock().unlock();
returnValue = true;
LockerValue<KP> lockerValue = this.getLockerValue(key);
boolean returnValue;
try {
returnValue = false;
if (lockerValue != null) {
lockerValue.getLock().unlock();
returnValue = true;
}
} finally {
this.decrementRunningOperations();
}
decrementRunningOperations();
cleanAccordingOperations();
return returnValue;
}

View File

@@ -70,6 +70,7 @@ import org.talend.commons.runtime.service.ITaCoKitService;
import org.talend.commons.ui.gmf.util.DisplayUtils;
import org.talend.commons.ui.runtime.exception.MessageBoxExceptionHandler;
import org.talend.commons.utils.data.container.RootContainer;
import org.talend.commons.utils.network.TalendProxySelector;
import org.talend.commons.utils.time.TimeMeasure;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.AbstractDQModelService;
@@ -872,6 +873,9 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
}
this.repositoryFactoryFromProvider.deleteObjectPhysical(project, object, version, fromEmptyRecycleBin);
if (isFullLogonFinished()) {
fireRepositoryPropertyChange(ERepositoryActionName.AFTER_DELETE.getName(), null, object);
}
// i18n
// log.info("Physical deletion [" + objToDelete + "] by " + getRepositoryContext().getUser() + ".");
String str[] = new String[] { object.toString(), getRepositoryContext().getUser().toString() };
@@ -2034,6 +2038,11 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
TimeMeasure.begin("logOnProject"); //$NON-NLS-1$
try {
/**
* init/check proxy selector, in case default proxy selector is not registed yet
*/
TalendProxySelector.checkProxy();
System.getProperties().put("ReadOnlyUser", Boolean.FALSE.toString()); //$NON-NLS-1$
// remove the auto-build to enhance the build speed and application's use
@@ -2409,9 +2418,14 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
@Override
@SuppressWarnings("unchecked")
public void executeRepositoryWorkUnit(RepositoryWorkUnit workUnit) {
checkProxySettings();
this.repositoryFactoryFromProvider.executeRepositoryWorkUnit(workUnit);
}
private void checkProxySettings() {
TalendProxySelector.checkProxy();
}
@Override
public void unloadResources(Property property) throws PersistenceException {
repositoryFactoryFromProvider.unloadResources(property);

View File

@@ -12,10 +12,14 @@
// ============================================================================
package org.talend.core.repository.model.dnd;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.components.IComponent;
import org.talend.core.model.components.IComponentsService;
import org.talend.core.model.properties.ConnectionItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.SalesforceSchemaConnectionItem;
import org.talend.core.model.repository.ERepositoryObjectType;
@@ -28,6 +32,8 @@ import org.talend.repository.model.RepositoryNode;
*/
public class SalesforceComponentDndFilter extends DefaultRepositoryComponentDndFilter {
public static final String SALSEFORCE = "salesforce"; //$NON-NLS-1$
public static final String COMPONENT_T_SALSEFORCE_CONNECTION = "tSalesforceConnection"; //$NON-NLS-1$
public static final String COMPONENT_T_SALSEFORCE_WAVE_BULK_EXEC = "tSalesforceWaveBulkExec"; //$NON-NLS-1$
@@ -98,7 +104,16 @@ public class SalesforceComponentDndFilter extends DefaultRepositoryComponentDndF
}
}
}
}
if (item instanceof ConnectionItem && SALSEFORCE.equalsIgnoreCase(((ConnectionItem) item).getTypeName())) {
// Special for Javajet components: tSalesforceEinsteinBulkExec/tSalesforceEinsteinOutputBulkExec
IComponentsService service = GlobalServiceRegister.getDefault().getService(IComponentsService.class);
Collection<IComponent> componentAll = service.getComponentsFactory().readComponents();
for (IComponent component : componentAll) {
if (component.getName().startsWith("tSalesforceEinstein") && !components.contains(component)) { //$NON-NLS-1$
components.add(component);
}
}
}
return components;
}

View File

@@ -13,6 +13,8 @@
package org.talend.core.repository.ui.dialog;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -30,12 +32,14 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.IRepositoryObject;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.repository.utils.RepositoryNodeSortUtil;
import org.talend.core.ui.ITestContainerProviderService;
import org.talend.repository.model.RepositoryNode;
import org.talend.repository.model.IRepositoryNode.EProperties;
@@ -107,7 +111,8 @@ public class PastSelectorDialog extends Dialog {
modificationTime.setWidth(200);
modificationTime.setText("Modification Time");
for (IRepositoryViewObject object : versions) {
RepositoryNodeSortUtil util = new RepositoryNodeSortUtil();
for (IRepositoryViewObject object : util.getSortVersion(versions)) {
TableItem item = new TableItem(table, SWT.NONE);
item.setData(object);
item.setText(0, object.getVersion());
@@ -187,7 +192,7 @@ public class PastSelectorDialog extends Dialog {
});
return composite;
}
public Set<IRepositoryViewObject> getSelectedVersionItems() {
return this.selectedVersionItems;
}

View File

@@ -0,0 +1,47 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.repository.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.talend.commons.utils.Version;
import org.talend.core.model.repository.IRepositoryViewObject;
/**
* @author hwang
*
*/
public class RepositoryNodeSortUtil {
public List<IRepositoryViewObject> getSortVersion(List<IRepositoryViewObject> versions) {
List<IRepositoryViewObject> temp = new ArrayList<IRepositoryViewObject>();
temp.addAll(versions);
Collections.sort(temp, new Comparator<IRepositoryViewObject>() {
@Override
public int compare(IRepositoryViewObject o1, IRepositoryViewObject o2) {
String version1 = o1.getVersion();
String version2 = o2.getVersion();
if(version1 != null && version2 != null) {
return new Version(version1).compareTo(new Version(version2));
}
return 0;
}
});
return temp;
}
}

View File

@@ -28,6 +28,7 @@ Export-Package: org.talend.commons.utils.generation,
org.talend.core.model.business,
org.talend.core.model.components,
org.talend.core.model.context,
org.talend.core.model.context.link,
org.talend.core.model.general,
org.talend.core.model.genhtml,
org.talend.core.model.metadata,

View File

@@ -19,6 +19,7 @@
<extension-point id="hadoopConnectionCreator" name="Hadoop Connection Creator" schema="schema/hadoopConnectionCreator.exsd"/>
<extension-point id="artifact_handler" name="Artifact Repository Handler" schema="schema/artifact_handler.exsd"/>
<extension-point id="actionFilterDelegate" name="Action Filter delegate" schema="schema/actionFilterDelegate.exsd"/>
<extension-point id="saveItemContextLinkService" name="Save Item Context Link Service" schema="schema/saveItemContextLinkService.exsd"/>
<extension
point="org.talend.core.runtime.repositoryComponent_provider">
@@ -53,4 +54,16 @@
name="Talend">
</category>
</extension>
<extension
point="org.talend.core.runtime.service">
<Service
class="org.talend.core.model.update.RepositoryContextUpdateService"
serviceId="IRepositoryContextUpdateService">
</Service>
<Service
class="org.talend.core.model.update.GenericDbContextUpdateService"
serviceId="IRepositoryContextUpdateService">
</Service>
</extension>
</plugin>

View File

@@ -0,0 +1,105 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.talend.core.runtime" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="org.talend.core.runtime" id="saveItemContextLinkService" name="Save Item Context Link Service"/>
</appinfo>
<documentation>
Save the context link data for item which contain ContextType object
The extension point must implements interface : org.talend.core.model.context.link.IItemContextLinkService
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence minOccurs="1" maxOccurs="unbounded">
<element ref="creator" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="creator">
<complexType>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":org.talend.core.model.context.link.IItemContextLinkService"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
7.4.1
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
boolean accept(Item item);
boolean saveItemLink(Item item);
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>

View File

@@ -254,6 +254,34 @@ public final class ResourceUtils {
}
}
/**
* Comment method "setFileContent".
*
* @param stream
* @param file
* @throws PersistenceException
*/
public static void setFileContent(InputStream stream, IFile file) throws PersistenceException {
try {
if (stream == null) {
String msg = Messages.getString("resources.file.notCreated", file.getName(), //$NON-NLS-1$
Messages.getString("ResourceUtils.streamNull")); //$NON-NLS-1$
throw new PersistenceException(msg);
}
file.setContents(stream, true, false, null);
} catch (CoreException e) {
String msg = Messages.getString("resources.file.notCreated", file.getName(), e.getMessage()); //$NON-NLS-1$
throw new PersistenceException(msg, e);
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {
CommonExceptionHandler.process(e);
}
}
}
/**
* Convenience method to delete a file.<br/>
*

View File

@@ -12,35 +12,49 @@
// ============================================================================
package org.talend.core;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.runtime.services.IGenericDBService;
/**
* created by ldong on Mar 23, 2015 Detailled comment
*
*/
public class AbstractRepositoryContextUpdateService implements IRepositoryContextUpdateService {
@Override
public void updateRelatedContextVariable(Connection con, String oldValue, String newValue) {
}
public abstract class AbstractRepositoryContextUpdateService implements IRepositoryContextUpdateService {
protected IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
protected String updateHadoopProperties(List<Map<String, Object>> hadoopProperties, String oldValue, String newValue) {
String finalProperties = "";
String finalProperties = null;
boolean isModified = false;
if (!hadoopProperties.isEmpty()) {
for (Map<String, Object> propertyMap : hadoopProperties) {
String propertyValue = (String) propertyMap.get("VALUE");
if (propertyValue.equals(oldValue)) {
propertyMap.put("VALUE", newValue);
isModified = true;
}
}
finalProperties = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopProperties);
if (isModified) {
finalProperties = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopProperties);
}
}
return finalProperties;
}
protected boolean updateCompPropertiesContextParameter(Connection conn, String oldValue, String newValue) {
boolean isModified = false;
Map<String, String> oldToNewHM = new HashMap<String, String>();
oldToNewHM.put(oldValue, newValue);
String compProperties = conn.getCompProperties();
if (service != null && StringUtils.isNotBlank(compProperties)) {
service.updateCompPropertiesForContextMode(conn, oldToNewHM);
isModified = true;
}
return isModified;
}
}

View File

@@ -12,7 +12,9 @@
// ============================================================================
package org.talend.core;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
@@ -247,4 +249,29 @@ public class GlobalServiceRegister {
}
return null;
}
public List findAllService(Class klass) {
List serviceList = new ArrayList();
String key = klass.getName();
IConfigurationElement[] configElements = getConfigurationElements();
if (configElements != null) {
for (IConfigurationElement element : configElements) {
if (element.isValid()) {
String id = element.getAttribute("serviceId"); //$NON-NLS-1$
if (!key.endsWith(id)) {
continue;
}
try {
Object service = element.createExecutableExtension("class"); //$NON-NLS-1$
if (klass.isInstance(service)) {
serviceList.add(service);
};
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
}
}
return serviceList;
}
}

View File

@@ -20,5 +20,7 @@ import org.talend.core.model.metadata.builder.connection.Connection;
*/
public interface IRepositoryContextUpdateService extends IService {
public void updateRelatedContextVariable(Connection con, String oldValue, String newValue);
public boolean accept(Connection connection);
public boolean updateContextParameter(Connection conn, String oldValue, String newValue);
}

View File

@@ -166,9 +166,9 @@ public enum EDatabaseVersion4Drivers {
REDSHIFT(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT, "redshift", "REDSHIFT", //$NON-NLS-1$ //$NON-NLS-2$
"redshift-jdbc42-no-awssdk-1.2.37.1061.jar")), //$NON-NLS-1$
REDSHIFT_SSO(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT_SSO, "redshift sso", "REDSHIFT_SSO", //$NON-NLS-1$ //$NON-NLS-2$
new String[] { "redshift-jdbc42-no-awssdk-1.2.37.1061.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.9.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"jackson-databind-2.9.9.jar", "jackson-annotations-2.9.0.jar", "httpcore-4.4.9.jar", "httpclient-4.5.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
"joda-time-2.8.1.jar", "commons-logging-1.1.3.jar", "commons-codec-1.6.jar" })), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new String[] { "redshift-jdbc42-no-awssdk-1.2.37.1061.jar", "aws-java-sdk-1.11.729.jar", "jackson-core-2.10.1.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"jackson-databind-2.10.1.jar", "jackson-annotations-2.10.1.jar", "httpcore-4.4.11.jar", "httpclient-4.5.9.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
"joda-time-2.8.1.jar", "commons-logging-1.2.jar", "commons-codec-1.11.jar" })), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
AMAZON_AURORA(new DbVersion4Drivers(EDatabaseTypeName.AMAZON_AURORA, "mysql-connector-java-5.1.30-bin.jar")); //$NON-NLS-1$

View File

@@ -21,8 +21,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.EList;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
import org.talend.commons.exception.ExceptionHandler;
@@ -30,6 +33,9 @@ import org.talend.commons.exception.PersistenceException;
import org.talend.commons.utils.platform.PluginChecker;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.language.LanguageManager;
import org.talend.core.model.context.link.ContextLinkService;
import org.talend.core.model.context.link.ContextParamLink;
import org.talend.core.model.context.link.ItemContextLink;
import org.talend.core.model.metadata.MetadataTalendType;
import org.talend.core.model.metadata.MetadataToolHelper;
import org.talend.core.model.metadata.types.ContextParameterJavaTypeManager;
@@ -43,6 +49,7 @@ import org.talend.core.model.properties.JobletProcessItem;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.cwm.helper.ResourceHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
@@ -53,6 +60,8 @@ import org.talend.repository.model.IProxyRepositoryFactory;
*/
public class ContextUtils {
private static final Logger LOGGER = Logger.getLogger(ContextUtils.class);
private static final Set<String> JAVA_KEYWORDS = new HashSet<String>(Arrays.asList("abstract", "continue", "for", "new", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"switch", "assert", "default", "goto", "package", "synchronized", "boolean", "do", "if", "private", "this", "break", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
"double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
@@ -82,15 +91,25 @@ public class ContextUtils {
* update the JobContextParameter form repository ContextItem by context name.
*
*/
public static boolean updateParameterFromRepository(ContextItem sourceItem, IContextParameter contextParam, String contextName) {
public static boolean updateParameterFromRepository(Item sourceItem, IContextParameter contextParam, String contextName) {
return updateParameterFromRepository(sourceItem, contextParam, contextName, null);
}
public static boolean updateParameterFromRepository(Item sourceItem, IContextParameter contextParam, String contextName,
Map<String, String> renameMap) {
if (sourceItem == null || contextParam == null) {
return false;
}
// not found, use default.
ContextType contextType = getContextTypeByName(sourceItem, contextName, true);
ContextType contextType = getContextTypeByName(sourceItem, contextName);
if (contextType != null) {
ContextParameterType parameterType = getContextParameterTypeByName(contextType, contextParam.getName());
String paramName = contextParam.getName();
String newName = ContextUtils.getNewNameFromRenameMap(renameMap, paramName);
if (newName != null) {
paramName = newName;
}
ContextParameterType parameterType = getContextParameterTypeByName(contextType, paramName);
// found parameter, update it.
if (parameterType != null) {
contextParam.setComment(parameterType.getComment());
@@ -98,6 +117,9 @@ public class ContextUtils {
contextParam.setPromptNeeded(parameterType.isPromptNeeded());
contextParam.setType(parameterType.getType());
contextParam.setValue(parameterType.getRawValue());
if (!StringUtils.equals(contextParam.getName(), parameterType.getName())) {
contextParam.setName(parameterType.getName());
}
return true;
}
}
@@ -178,6 +200,28 @@ public class ContextUtils {
return parameterType;
}
public static ContextParameterType getContextParameterTypeById(ContextType contextType, final String uuId,
boolean isFromContextItem) {
if (contextType == null || uuId == null) {
return null;
}
ContextParameterType parameterType = null;
for (ContextParameterType param : (List<ContextParameterType>) contextType.getContextParameter()) {
String paramId = null;
if (isFromContextItem) {
paramId = ResourceHelper.getUUID(param);
} else {
paramId = param.getInternalId();
}
if (uuId.equals(paramId)) {
parameterType = param;
break;
}
}
return parameterType;
}
@SuppressWarnings("unchecked")
private static boolean checkObject(Object obj) {
if (obj == null) {
@@ -372,6 +416,7 @@ public class ContextUtils {
targetParam.setValue(sourceParam.getValue());
targetParam.setPromptNeeded(sourceParam.isPromptNeeded());
targetParam.setComment(sourceParam.getComment());
targetParam.setInternalId(sourceParam.getInternalId());
}
/**
@@ -411,7 +456,7 @@ public class ContextUtils {
targetParam.setValue(sourceParam.getRawValue());
targetParam.setPromptNeeded(sourceParam.isPromptNeeded());
targetParam.setComment(sourceParam.getComment());
targetParam.setInternalId(sourceParam.getInternalId());
}
public static Map<String, Item> getRepositoryContextItemIdMapping() {
@@ -538,8 +583,8 @@ public class ContextUtils {
}
// preference name must match TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE
return Boolean.parseBoolean(CoreRuntimePlugin.getInstance().getDesignerCoreService()
.getPreferenceStore("propagateContextVariable")); //$NON-NLS-1$
return Boolean.parseBoolean(
CoreRuntimePlugin.getInstance().getDesignerCoreService().getPreferenceStore("propagateContextVariable")); //$NON-NLS-1$
}
/**
@@ -573,17 +618,17 @@ public class ContextUtils {
boolean modified = false;
for (String varName : set) {
ContextParameterType contextParameterType = ContextUtils.getContextParameterTypeByName(
contextType, varName);
IContextParameter contextParameter = processJobManager.getDefaultContext().getContextParameter(
varName);
ContextParameterType contextParameterType = ContextUtils
.getContextParameterTypeByName(contextType, varName);
IContextParameter contextParameter = processJobManager.getDefaultContext()
.getContextParameter(varName);
if (contextParameter == null) { // added
addContextParameterType(processJobManager, contextItem, contextParameterType);
modified = true;
}
}
if (modified) {
processJobManager.saveToEmf(processType.getContext());
processJobManager.saveToEmf(processType.getContext(), true);
added = true;
}
}
@@ -672,8 +717,328 @@ public class ContextUtils {
contextParam.setPromptNeeded(contextParamType.isPromptNeeded());
contextParam.setComment(contextParamType.getComment());
contextParam.setInternalId(contextParamType.getInternalId());
contextParam.setSource(contextItem.getProperty().getId());
return contextParam;
}
/**
* Get the context type from item (ContextItem/JobletProcessItem/ProcessItem), If the name is null will use default
* context
*
* @param item
* @param contextName
* @return
*/
public static ContextType getContextTypeByName(Item item, String contextName) {
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
if (contextName == null) {
contextName = contextItem.getDefaultContext();
}
return ContextUtils.getContextTypeByName(contextItem, contextName, true);
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
return ContextUtils.getContextTypeByName((List<ContextType>) jobletProcessItem.getJobletProcess().getContext(),
contextName, jobletProcessItem.getJobletProcess().getDefaultContext());
} else if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return ContextUtils.getContextTypeByName((List<ContextType>) processItem.getProcess().getContext(), contextName,
processItem.getProcess().getDefaultContext());
}
return null;
}
public static String getDefaultContextName(Item item) {
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
return contextItem.getDefaultContext();
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
return jobletProcessItem.getJobletProcess().getDefaultContext();
} else if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return processItem.getProcess().getDefaultContext();
}
return null;
}
public static EList getAllContextType(Item item) {
if (item instanceof ContextItem) {
ContextItem contextItem = (ContextItem) item;
return contextItem.getContext();
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
return jobletProcessItem.getJobletProcess().getContext();
} else if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return processItem.getProcess().getContext();
}
return null;
}
public static Map<String, String> getContextParamterRenamedMap(Item item) {
ItemContextLink itemContextLink = null;
try {
itemContextLink = ContextLinkService.getInstance().loadContextLinkFromJson(item);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
if (itemContextLink != null) {
if (item instanceof ConnectionItem) {
return compareConnectionContextParamName((ConnectionItem) item, itemContextLink);
} else {
return compareContextParamName(item, itemContextLink);
}
}
return Collections.EMPTY_MAP;
}
private static Map<String, String> compareContextParamName(Item processItem, ItemContextLink itemContextLink) {
List<ContextType> contextTypeList = getAllContextType(processItem);
return compareContextParamName(contextTypeList, itemContextLink);
}
public static Map<String, String> compareContextParamName(List<ContextType> contextTypeList,
ItemContextLink itemContextLink) {
Map<String, String> renamedMap = new HashMap<String, String>();
Map<String, Item> tempItemMap = new HashMap<String, Item>();
for (ContextType contextType : contextTypeList) {
for (Object obj : contextType.getContextParameter()) {
if (obj instanceof ContextParameterType) {
ContextParameterType contextParameterType = (ContextParameterType) obj;
ContextParamLink paramLink = itemContextLink.findContextParamLinkByName(
contextParameterType.getRepositoryContextId(), contextType.getName(), contextParameterType.getName());
if (paramLink != null) {
Item item = tempItemMap.get(contextParameterType.getRepositoryContextId());
if (item == null) {
item = ContextUtils.getRepositoryContextItemById(contextParameterType.getRepositoryContextId());
tempItemMap.put(contextParameterType.getRepositoryContextId(), item);
}
if (item != null) {
final ContextType repoContextType = ContextUtils.getContextTypeByName(item, contextType.getName());
ContextParameterType repoContextParam = ContextUtils.getContextParameterTypeById(repoContextType,
paramLink.getId(), item instanceof ContextItem);
if (repoContextParam != null
&& !StringUtils.equals(repoContextParam.getName(), contextParameterType.getName())) {
renamedMap.put(repoContextParam.getName(), contextParameterType.getName());
}
}
}
}
}
}
return renamedMap;
}
private static Map<String, String> compareConnectionContextParamName(ConnectionItem connectionItem,
ItemContextLink itemContextLink) {
Map<String, String> renamedMap = new HashMap<String, String>();
if (connectionItem.getConnection().isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(connectionItem.getConnection().getContextId());
if (contextItem != null) {
ContextType contextType = ContextUtils.getContextTypeByName(contextItem,
connectionItem.getConnection().getContextName(), false);
if (contextType != null) {
for (Object obj : contextType.getContextParameter()) {
if (obj instanceof ContextParameterType) {
ContextParameterType paramType = (ContextParameterType) obj;
ContextParamLink paramLink = itemContextLink.findContextParamLinkById(
connectionItem.getConnection().getContextId(),
connectionItem.getConnection().getContextName(), ResourceHelper.getUUID(paramType));
if (paramLink != null && !StringUtils.equals(paramType.getName(), paramLink.getName())) {
renamedMap.put(paramType.getName(), paramLink.getName());
}
}
}
}
}
}
return renamedMap;
}
/**
*
* @param itemId
* @param contextType
* @return rename map. Key is new name and value is old name.
*/
public static Map<String, String> calculateRenamedMapFromLinkFile(String projectLabel, String itemId, IContext context,
Item repoContextItem) {
Map<String, String> renamedMap = new HashMap<String, String>();
Map<String, Item> idToItemMap = new HashMap<String, Item>();
if (repoContextItem != null) {
idToItemMap.put(repoContextItem.getProperty().getId(), repoContextItem);
}
try {
ItemContextLink itemContextLink = ContextLinkService.getInstance().doLoadContextLinkFromJson(projectLabel, itemId);
if (itemContextLink != null) {
for (Object obj : context.getContextParameterList()) {
if (obj instanceof IContextParameter) {
IContextParameter parameterType = (IContextParameter) obj;
ContextParamLink parameterLink = itemContextLink.findContextParamLinkByName(parameterType.getSource(),
context.getName(), parameterType.getName());
if (parameterLink != null) {
Item item = idToItemMap.get(parameterType.getSource());
if (item == null) {
item = getRepositoryContextItemById(parameterType.getSource());
idToItemMap.put(parameterType.getSource(), item);
}
if (item != null) {
ContextType contextType = ContextUtils.getContextTypeByName(item, context.getName());
ContextParameterType repoParameterType = ContextUtils.getContextParameterTypeById(contextType,
parameterLink.getId(), item instanceof ContextItem);
if (repoParameterType != null
&& !StringUtils.equals(repoParameterType.getName(), parameterType.getName())) {
renamedMap.put(repoParameterType.getName(), parameterType.getName());
}
}
}
}
}
}
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
return renamedMap;
}
/**
*
* DOC hcw ProcessUpdateManager class global comment. Detailled comment
*/
public static class ContextItemParamMap {
private Map<Item, Set<String>> map = new HashMap<Item, Set<String>>();
public void add(Item item, String param) {
Set<String> params = map.get(item);
if (params == null) {
params = new HashSet<String>();
map.put(item, params);
}
params.add(param);
}
@SuppressWarnings("unchecked")
public Set<String> get(Item item) {
Set<String> params = map.get(item);
return (params == null) ? Collections.EMPTY_SET : params;
}
public boolean isEmpty() {
return map.isEmpty();
}
public Set<Item> getContexts() {
return map.keySet();
}
}
public static boolean compareContextParameter(Item contextItem, ContextType contextType, IContextParameter param,
ContextParamLink paramLink, Map<Item, Map<String, String>> repositoryRenamedMap, Map<Item, Set<String>> existedParams,
ContextItemParamMap unsameMap, ContextItemParamMap deleteParams, boolean onlySimpleShow, boolean isDefaultContext) {
boolean builtin = true;
String paramName = param.getName();
if (paramLink != null && paramLink.getId() != null && contextType != null) {// Compare use UUID
String paramId = paramLink.getId();
ContextParameterType contextParameterType = null;
contextParameterType = getContextParameterTypeById(contextType, paramId, contextItem instanceof ContextItem);
if (contextParameterType != null) {
if (!StringUtils.equals(contextParameterType.getName(), paramName)) {
if (isDefaultContext) {
Map<String, String> renameMap = repositoryRenamedMap.get(contextItem);
if (renameMap == null) {
renameMap = new HashMap<String, String>();
repositoryRenamedMap.put(contextItem, renameMap);
}
renameMap.put(contextParameterType.getName(), paramName);
}
} else {
if (isDefaultContext) {
if (existedParams.get(contextItem) == null) {
existedParams.put(contextItem, new HashSet<String>());
}
existedParams.get(contextItem).add(paramName);
}
if (onlySimpleShow || !samePropertiesForContextParameter(param, contextParameterType)) {
unsameMap.add(contextItem, paramName);
}
}
builtin = false;
} else {
// delete context variable
if (isPropagateContextVariable() && isDefaultContext) {
deleteParams.add(contextItem, paramName);
builtin = false;
}
}
} else { // Compare use Name
final ContextParameterType contextParameterType = ContextUtils.getContextParameterTypeByName(contextType, paramName);
if (contextParameterType != null) {
Item repositoryContext = contextItem;
if (isDefaultContext) {
if (existedParams.get(contextItem) == null) {
existedParams.put(repositoryContext, new HashSet<String>());
}
existedParams.get(repositoryContext).add(paramName);
}
if (onlySimpleShow || !ContextUtils.samePropertiesForContextParameter(param, contextParameterType)) {
unsameMap.add(contextItem, paramName);
}
builtin = false;
} else {
// delete context variable
if (ContextUtils.isPropagateContextVariable()) {
deleteParams.add(contextItem, paramName);
builtin = false;
}
}
}
return builtin && isDefaultContext;
}
public static String getParamId(IContextParameter param, ContextParamLink paramLink) {
if (paramLink != null) {
return paramLink.getId();
}
if (param != null) {
return param.getInternalId();
}
return null;
}
public static Item findContextItem(List<ContextItem> allContextItem, String source) {
if (allContextItem != null) {
for (ContextItem contextItem : allContextItem) {
if (StringUtils.equals(contextItem.getProperty().getId(), source)) {
return contextItem;
}
}
}
return getRepositoryContextItemById(source);
}
public static String getNewNameFromRenameMap(Map<String, String> renameMap, String oldName) {
if (renameMap != null) {
for (String key : renameMap.keySet()) {
String value = renameMap.get(key);
if (StringUtils.equals(value, oldName)) {
return key;
}
}
}
return null;
}
public static boolean isBuildInParameter(ContextParameterType paramType) {
if (paramType.getRepositoryContextId() == null || IContextParameter.BUILT_IN.equals(paramType.getRepositoryContextId())) {
return true;
}
return false;
}
}

View File

@@ -19,8 +19,10 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.talend.core.model.metadata.MetadataTalendType;
import org.talend.core.model.metadata.types.ContextParameterJavaTypeManager;
import org.talend.core.model.process.IContext;
@@ -30,6 +32,7 @@ import org.talend.core.model.process.IContextParameter;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.utils.ContextParameterUtils;
import org.talend.cwm.helper.ResourceHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
@@ -74,7 +77,7 @@ public class JobContextManager implements IContextManager {
*/
private Set<String> originalParamerters = new HashSet<String>();
private Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
private Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
/*
* for context group
@@ -251,73 +254,7 @@ public class JobContextManager implements IContextManager {
*/
@Override
public void saveToEmf(EList contextTypeList) {
if (contextTypeList == null) {
return;
}
if (listContext.isEmpty()) {
retrieveDefaultContext();
}
EList newcontextTypeList = new BasicEList();
for (int i = 0; i < listContext.size(); i++) {
IContext context = listContext.get(i);
String contextGroupName = renameGroupContext.get(context);
if (contextGroupName == null) {
contextGroupName = context.getName();
}
ContextType contextType = findContextType(contextTypeList, contextGroupName);
if (contextType == null) {
contextType = TalendFileFactory.eINSTANCE.createContextType();
}
contextType.setName(context.getName());
contextType.setConfirmationNeeded(context.isConfirmationNeeded());
newcontextTypeList.add(contextType);
EList contextTypeParamList = contextType.getContextParameter();
List<IContextParameter> contextParameterList = context.getContextParameterList();
EList newContextTypeParamList = new BasicEList();
if (contextParameterList != null) {
for (int j = 0; j < contextParameterList.size(); j++) {
IContextParameter contextParam = contextParameterList.get(j);
String contexParameterName = nameMap.get(contextParam.getName());
if (contexParameterName == null) {
contexParameterName = contextParam.getName();
}
ContextParameterType contextParamType = findContextParameterType(contextTypeParamList, contexParameterName);
if (contextParamType == null) {
contextParamType = TalendFileFactory.eINSTANCE.createContextParameterType();
}
newContextTypeParamList.add(contextParamType);
contextParamType.setName(contextParam.getName());
contextParamType.setPrompt(contextParam.getPrompt());
contextParamType.setType(contextParam.getType());
contextParamType.setRawValue(contextParam.getValue());
contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
contextParamType.setComment(contextParam.getComment());
if (!contextParam.isBuiltIn()) {
Item item = ContextUtils.getRepositoryContextItemById(contextParam.getSource());
if (item != null) {
contextParamType.setRepositoryContextId(item.getProperty().getId());
} else {
String contextId = contextParam.getSource();
if (!IContextParameter.BUILT_IN.equals(contextId)) {
contextParamType.setRepositoryContextId(contextId);
}
}
}
}
contextTypeParamList.clear(); // remove old
contextTypeParamList.addAll(newContextTypeParamList);
}
}
contextTypeList.clear(); // clear old
contextTypeList.addAll(newcontextTypeList);
saveToEmf(contextTypeList, false);
}
private ContextType findContextType(EList contextTypeList, String contextName) {
@@ -384,6 +321,7 @@ public class JobContextManager implements IContextManager {
contextParam.setContext(context);
contextParam.setName(contextParamType.getName());
contextParam.setPrompt(contextParamType.getPrompt());
contextParam.setInternalId(contextParamType.getInternalId());
originalParamerters.add(contextParam.getName());
boolean exists = true;
try {
@@ -486,16 +424,6 @@ public class JobContextManager implements IContextManager {
}
/**
*
* ggu Comment method "getLostParameters".
*
* @return
*/
public Set<String> getLostParameters() {
return this.lostParameters;
}
public Map<ContextItem, Map<String, String>> getRepositoryRenamedMap() {
return this.repositoryRenamedMap;
}
@@ -516,6 +444,16 @@ public class JobContextManager implements IContextManager {
}
/**
*
* ggu Comment method "getLostParameters".
*
* @return
*/
public Set<String> getLostParameters() {
return this.lostParameters;
}
public void addNewParameters(String param) {
newParameters.add(param);
}
@@ -540,11 +478,11 @@ public class JobContextManager implements IContextManager {
}
}
public Map<ContextItem, Set<String>> getNewParametersMap() {
public Map<Item, Set<String>> getNewParametersMap() {
return newParametersMap;
}
public void setNewParametersMap(Map<ContextItem, Set<String>> newParametersMap) {
public void setNewParametersMap(Map<Item, Set<String>> newParametersMap) {
this.newParametersMap = newParametersMap;
}
@@ -573,4 +511,98 @@ public class JobContextManager implements IContextManager {
public void setConfigContextGroup(boolean isConfigContextGroup) {
this.isConfigContextGroup = isConfigContextGroup;
}
@Override
public void saveToEmf(EList contextTypeList, boolean useInternalId) {
if (contextTypeList == null) {
return;
}
if (listContext.isEmpty()) {
retrieveDefaultContext();
}
EList newcontextTypeList = new BasicEList();
Map<String, Item> idToItemMap = new HashMap<String, Item>();
for (int i = 0; i < listContext.size(); i++) {
IContext context = listContext.get(i);
String contextGroupName = renameGroupContext.get(context);
if (contextGroupName == null) {
contextGroupName = context.getName();
}
ContextType contextType = findContextType(contextTypeList, contextGroupName);
if (contextType == null) {
contextType = TalendFileFactory.eINSTANCE.createContextType();
}
contextType.setName(context.getName());
contextType.setConfirmationNeeded(context.isConfirmationNeeded());
newcontextTypeList.add(contextType);
EList contextTypeParamList = contextType.getContextParameter();
List<IContextParameter> contextParameterList = context.getContextParameterList();
EList newContextTypeParamList = new BasicEList();
if (contextParameterList != null) {
for (int j = 0; j < contextParameterList.size(); j++) {
IContextParameter contextParam = contextParameterList.get(j);
String contexParameterName = nameMap.get(contextParam.getName());
if (contexParameterName == null) {
contexParameterName = contextParam.getName();
}
ContextParameterType contextParamType = findContextParameterType(contextTypeParamList, contexParameterName);
if (contextParamType == null) {
contextParamType = TalendFileFactory.eINSTANCE.createContextParameterType();
}
newContextTypeParamList.add(contextParamType);
contextParamType.setName(contextParam.getName());
contextParamType.setPrompt(contextParam.getPrompt());
contextParamType.setType(contextParam.getType());
contextParamType.setRawValue(contextParam.getValue());
contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
contextParamType.setComment(contextParam.getComment());
if (!contextParam.isBuiltIn()) {
Item item = idToItemMap.get(contextParam.getSource());
if (item == null) {
item = ContextUtils.getRepositoryContextItemById(contextParam.getSource());
idToItemMap.put(contextParam.getSource(), item);
}
if (item != null) {
contextParamType.setRepositoryContextId(item.getProperty().getId());
if (item instanceof ContextItem) {
ContextType repoContextType = ContextUtils.getContextTypeByName(item, contextType.getName());
if (repoContextType != null) {
ContextParameterType repoContextParam = ContextUtils
.getContextParameterTypeByName(repoContextType, contextParam.getName());
if (repoContextParam != null) {
ResourceHelper.setUUid(contextParamType, ResourceHelper.getUUID(repoContextParam));
}
}
}
} else {
String contextId = contextParam.getSource();
if (!IContextParameter.BUILT_IN.equals(contextId)) {
contextParamType.setRepositoryContextId(contextId);
}
}
} else if (useInternalId) {
String internalId = contextParam.getInternalId();
if (StringUtils.isEmpty(internalId)) {
internalId = EcoreUtil.generateUUID();
contextParamType.setInternalId(internalId);
contextParam.setInternalId(internalId);
} else {
contextParamType.setInternalId(internalId);
}
}
}
contextTypeParamList.clear(); // remove old
contextTypeParamList.addAll(newContextTypeParamList);
}
}
contextTypeList.clear(); // clear old
contextTypeList.addAll(newcontextTypeList);
}
}

View File

@@ -45,13 +45,14 @@ public class JobContextParameter implements IContextParameter, Cloneable {
String[] valueList;
String internalId;
/**
* change to save id always for bug 13184.
*/
String source = ""; //$NON-NLS-1$
public JobContextParameter() {
}
@Override
@@ -310,6 +311,14 @@ public class JobContextParameter implements IContextParameter, Cloneable {
this.promptNeeded = promptNeeded;
}
public String getInternalId() {
return internalId;
}
public void setInternalId(String internalId) {
this.internalId = internalId;
}
@Override
public IContextParameter clone() {
IContextParameter clonedContextParameter = null;

View File

@@ -0,0 +1,85 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.context.link;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ContextLink {
@JsonProperty("contextName")
private String contextName;
@JsonProperty("repoId")
private String repoId;
@JsonProperty("parameterList")
private List<ContextParamLink> parameterList = new ArrayList<ContextParamLink>();
public String getRepoId() {
return repoId;
}
public void setRepoId(String repoId) {
this.repoId = repoId;
}
public List<ContextParamLink> getParameterList() {
return parameterList;
}
public void setParameterList(List<ContextParamLink> parameterList) {
this.parameterList = parameterList;
}
public String getContextName() {
return contextName;
}
public void setContextName(String contextName) {
this.contextName = contextName;
}
public ContextParamLink getParamLinkByName(String paramName) {
for (ContextParamLink paramLink : parameterList) {
if (StringUtils.equals(paramLink.getName(), paramName)) {
return paramLink;
}
}
return null;
}
public ContextParamLink getParamLinkById(String id) {
for (ContextParamLink paramLink : parameterList) {
if (StringUtils.equals(paramLink.getId(), id)) {
return paramLink;
}
}
return null;
}
public ContextLink cloneObj() {
ContextLink obj = new ContextLink();
obj.setContextName(contextName);
obj.setRepoId(repoId);
for (ContextParamLink p : parameterList) {
obj.getParameterList().add(p.cloneObj());
}
return obj;
}
}

View File

@@ -0,0 +1,392 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.context.link;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.process.IContextParameter;
import org.talend.core.model.properties.ConnectionItem;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.JobletProcessItem;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Project;
import org.talend.cwm.helper.ResourceHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.repository.ProjectManager;
import org.talend.repository.model.RepositoryConstants;
import com.fasterxml.jackson.databind.ObjectMapper;
public class ContextLinkService {
private static final String CREATOR_EXT_ID = "org.talend.core.runtime.saveItemContextLinkService"; //$NON-NLS-1$
public static final String LINKS_FOLDER_NAME = "links";
public static final String LINK_FILE_POSTFIX = ".link";
private static final List<IItemContextLinkService> registeredService = new ArrayList<IItemContextLinkService>();
private static ContextLinkService instance = new ContextLinkService();
private static final String CURRENT_PROJECT_LABEL = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
private ContextLinkService() {
initService();
}
public static ContextLinkService getInstance() {
return instance;
}
public synchronized boolean saveContextLink(Item item) throws PersistenceException {
for (IItemContextLinkService service : registeredService) {
if (service.accept(item)) {
return service.saveItemLink(item);
}
}
return doSaveContextLink(item);
}
public synchronized boolean doSaveContextLink(Item item) throws PersistenceException {
if (item instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) item;
return saveContextLink(processItem.getProcess().getContext(), item);
} else if (item instanceof JobletProcessItem) {
JobletProcessItem jobletItem = (JobletProcessItem) item;
return saveContextLink(jobletItem.getJobletProcess().getContext(), item);
} else if (item instanceof ConnectionItem) {
ConnectionItem connectionItem = (ConnectionItem) item;
return saveContextLink(connectionItem.getConnection(), item);
}
return false;
}
@SuppressWarnings("unchecked")
private synchronized boolean saveContextLink(Connection connection, Item item) throws PersistenceException {
boolean hasLinkFile = false;
ItemContextLink itemContextLink = new ItemContextLink();
itemContextLink.setItemId(item.getProperty().getId());
if (connection.isContextMode()) {
String contextId = connection.getContextId();
if (StringUtils.isEmpty(contextId) || IContextParameter.BUILT_IN.equals(contextId)) {
return hasLinkFile;
}
ContextLink contextLink = new ContextLink();
contextLink.setContextName(connection.getContextName());
contextLink.setRepoId(contextId);
itemContextLink.getContextList().add(contextLink);
ContextItem contextItem = ContextUtils.getContextItemById2(contextId);
if (contextItem != null) {
ContextType contextType = ContextUtils.getContextTypeByName(contextItem.getContext(),
connection.getContextName());
if (contextType != null) {
for (Object o : contextType.getContextParameter()) {
if (o instanceof ContextParameterType) {
ContextParameterType contextParameterType = (ContextParameterType) o;
ContextParamLink contextParamLink = new ContextParamLink();
contextParamLink.setName(contextParameterType.getName());
contextParamLink.setId(ResourceHelper.getUUID(contextParameterType));
contextLink.getParameterList().add(contextParamLink);
}
}
}
}
}
if (itemContextLink.getContextList().size() > 0) {
saveContextLinkToJson(item, itemContextLink);
hasLinkFile = true;
} else {
deleteContextLinkJsonFile(item);
}
return hasLinkFile;
}
public synchronized boolean saveContextLink(List<ContextType> contextTypeList, Item item) throws PersistenceException {
boolean hasLinkFile = false;
String itemId = item.getProperty().getId();
ItemContextLink itemContextLink = new ItemContextLink();
itemContextLink.setItemId(itemId);
Map<String, Item> tempCache = new HashMap<String, Item>();
if (contextTypeList != null && contextTypeList.size() > 0) {
ItemContextLink backupContextLink = this.loadContextLinkFromJson(item);
for (Object object : contextTypeList) {
if (object instanceof ContextType) {
ContextType jobContextType = (ContextType) object;
for (Object o : jobContextType.getContextParameter()) {
if (o instanceof ContextParameterType) {
ContextParameterType contextParameterType = (ContextParameterType) o;
String repositoryContextId = contextParameterType.getRepositoryContextId();
if (StringUtils.isEmpty(repositoryContextId)
|| IContextParameter.BUILT_IN.equals(repositoryContextId)) {
ContextLink contextLink = itemContextLink.findContextLink(item.getProperty().getId(),
jobContextType.getName());
if (contextLink == null) {
contextLink = new ContextLink();
contextLink.setContextName(jobContextType.getName());
contextLink.setRepoId(itemId);
itemContextLink.getContextList().add(contextLink);
}
ContextParamLink contextParamLink = createParamLink(itemId, jobContextType.getName(),
contextParameterType.getName(), contextParameterType.getInternalId(), tempCache,
backupContextLink);
contextLink.getParameterList().add(contextParamLink);
} else {
ContextLink contextLink = itemContextLink
.findContextLink(contextParameterType.getRepositoryContextId(), jobContextType.getName());
if (contextLink == null) {
contextLink = new ContextLink();
contextLink.setContextName(jobContextType.getName());
contextLink.setRepoId(repositoryContextId);
itemContextLink.getContextList().add(contextLink);
}
ContextParamLink contextParamLink = createParamLink(repositoryContextId, jobContextType.getName(),
contextParameterType.getName(), contextParameterType.getInternalId(), tempCache,
backupContextLink);
contextLink.getParameterList().add(contextParamLink);
}
}
}
}
}
}
if (itemContextLink.getContextList().size() > 0) {
saveContextLinkToJson(item, itemContextLink);
hasLinkFile = true;
} else {
deleteContextLinkJsonFile(item);
}
return hasLinkFile;
}
@SuppressWarnings("unchecked")
private ContextParamLink createParamLink(String repositoryContextId, String contextName, String paramName, String internalId,
Map<String, Item> tempCache, ItemContextLink oldContextLink) {
ContextParamLink contextParamLink = new ContextParamLink();
contextParamLink.setName(paramName);
contextParamLink.setId(internalId);
Item contextItem = tempCache.get(repositoryContextId);
if (contextItem == null) {
contextItem = ContextUtils.getRepositoryContextItemById(repositoryContextId);
tempCache.put(repositoryContextId, contextItem);
}
if (contextItem != null) {
ContextType contextType = ContextUtils.getContextTypeByName(contextItem, contextName);
ContextParameterType repoContextParameterType = ContextUtils.getContextParameterTypeByName(contextType, paramName);
String uuID = null;
if(repoContextParameterType != null) {
if (contextItem instanceof ContextItem) {
uuID = ResourceHelper.getUUID(repoContextParameterType);
} else if (repoContextParameterType.getInternalId() != null) {
uuID = repoContextParameterType.getInternalId();
}
}
if (repoContextParameterType == null && oldContextLink != null) {
ContextParamLink oldParamLink = oldContextLink.findContextParamLinkByName(repositoryContextId, contextName,
paramName);
if (oldParamLink != null) {
uuID = oldParamLink.getId();
}
}
contextParamLink.setId(uuID);
}
return contextParamLink;
}
private synchronized void saveContextLinkToJson(Item item, ItemContextLink itemContextLink) throws PersistenceException {
IFolder linksFolder = getLinksFolder(getItemProjectLabel(item));
if (!linksFolder.exists()) {
ResourceUtils.createFolder(linksFolder);
}
IFile linkFile = calContextLinkFile(item);
ObjectMapper objectMapper = new ObjectMapper();
try {
String content = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(itemContextLink);
if (!linkFile.exists()) {
ResourceUtils.createFile(new ByteArrayInputStream(content.getBytes()), linkFile);
} else {
ResourceUtils.setFileContent(new ByteArrayInputStream(content.getBytes()), linkFile);
}
} catch (Exception e) {
throw new PersistenceException(e);
}
}
public synchronized boolean changeRepositoryId(Item item, Map<String, String> old2NewMap) throws PersistenceException {
boolean isModofied = false;
ItemContextLink itemContextLink = loadContextLinkFromJson(item);
if (itemContextLink != null) {
for (ContextLink contextLink : itemContextLink.getContextList()) {
if (old2NewMap.containsKey(contextLink.getRepoId())) {
contextLink.setRepoId(old2NewMap.get(contextLink.getRepoId()));
isModofied = true;
}
}
}
if (isModofied) {
this.saveContextLinkToJson(item, itemContextLink);
}
return isModofied;
}
public synchronized ItemContextLink loadContextLinkFromJson(Item item) throws PersistenceException {
for (IItemContextLinkService service : registeredService) {
if (service.accept(item)) {
return service.loadItemLink(item);
}
}
return doLoadContextLinkFromJson(item);
}
public synchronized ItemContextLink doLoadContextLinkFromJson(Item item) throws PersistenceException {
IFile linkFile = calContextLinkFile(item);
return doLoadContextLinkFromFile(linkFile);
}
public synchronized ItemContextLink doLoadContextLinkFromJson(String projectLabel, String id) throws PersistenceException {
IFile linkFile = calContextLinkFile(projectLabel, id);
return doLoadContextLinkFromFile(linkFile);
}
public synchronized ItemContextLink doLoadContextLinkFromFile(IFile linkFile) throws PersistenceException {
if (linkFile == null || !linkFile.exists()) {
return null;
}
ItemContextLink contextLink = null;
try {
contextLink = new ObjectMapper().readValue(linkFile.getLocation().toFile(), ItemContextLink.class);
} catch (IOException e) {
throw new PersistenceException(e);
}
return contextLink;
}
public synchronized void deleteContextLinkJsonFile(Item item) throws PersistenceException {
IFile linkFile = calContextLinkFile(item);
if (linkFile != null && linkFile.exists()) {
try {
linkFile.delete(true, null);
} catch (CoreException e) {
throw new PersistenceException(e);
}
}
}
public static IFile calContextLinkFile(Item item) throws PersistenceException {
if (item == null) {
return null;
}
IFolder linksFolder = getLinksFolder(getItemProjectLabel(item));
return linksFolder.getFile(calLinkFileName(item.getProperty().getId()));
}
public static IFile calContextLinkFile(String projectLabel, String itemId) throws PersistenceException {
if (projectLabel == null || itemId == null) {
return null;
}
IFolder linksFolder = getLinksFolder(projectLabel);
return linksFolder.getFile(calLinkFileName(itemId));
}
public static String getItemProjectLabel(Item item) {
Project project = ProjectManager.getInstance().getProject(item);
if (project != null) {
return project.getTechnicalLabel();
}
return CURRENT_PROJECT_LABEL;
}
private static String calLinkFileName(String id) {
StringBuilder sb = new StringBuilder();
sb.append(id).append(LINK_FILE_POSTFIX);
return sb.toString();
}
public static IFile calLinksFile(IFolder projectFolder, String id) {
IFolder settingFolder = projectFolder.getFolder(RepositoryConstants.SETTING_DIRECTORY);
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
return linksFolder.getFile(getLinkFileName(id));
}
public static String calLinksFilePath(String projectPath, String id) {
StringBuilder sb = new StringBuilder(projectPath);
sb.append(File.separator).append(RepositoryConstants.SETTING_DIRECTORY);
sb.append(File.separator).append(LINKS_FOLDER_NAME);
sb.append(File.separator).append(getLinkFileName(id));
return sb.toString();
}
public static IFile calLinksFile(IProject project, String id) {
IFolder settingFolder = project.getFolder(RepositoryConstants.SETTING_DIRECTORY);
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
return linksFolder.getFile(getLinkFileName(id));
}
public static String getLinkFileName(String id) {
return id + LINK_FILE_POSTFIX;
}
private static IFolder getLinksFolder(String projectLabel) throws PersistenceException {
IProject iProject = ResourceUtils.getProject(projectLabel);
IFolder settingFolder = iProject.getFolder(RepositoryConstants.SETTING_DIRECTORY);
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
return linksFolder;
}
private static void initService() {
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CREATOR_EXT_ID);
if (extensionPoint != null) {
IExtension[] extensions = extensionPoint.getExtensions();
for (IExtension extension : extensions) {
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
for (IConfigurationElement configurationElement : configurationElements) {
try {
Object creator = configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
if (creator instanceof IItemContextLinkService) {
IItemContextLinkService service = (IItemContextLinkService) creator;
registeredService.add(service);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
}
}
}
}

View File

@@ -0,0 +1,48 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.context.link;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ContextParamLink {
@JsonProperty("id")
private String id;
@JsonProperty("name")
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ContextParamLink cloneObj() {
ContextParamLink obj = new ContextParamLink();
obj.setId(id);
obj.setName(name);
return obj;
}
}

View File

@@ -0,0 +1,26 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.context.link;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.model.properties.Item;
public interface IItemContextLinkService {
boolean accept(Item item);
boolean saveItemLink(Item item) throws PersistenceException;
ItemContextLink loadItemLink(Item item) throws PersistenceException;
}

View File

@@ -0,0 +1,80 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.context.link;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
public class ItemContextLink {
@JsonProperty("itemId")
private String itemId;
@JsonProperty("contextList")
private List<ContextLink> contextList = new ArrayList<ContextLink>();
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public List<ContextLink> getContextList() {
return contextList;
}
public void setContextList(List<ContextLink> contextList) {
this.contextList = contextList;
}
public ContextParamLink findContextParamLinkByName(String repoContextId, String contextName, String paramName) {
ContextLink contextLink = findContextLink(repoContextId, contextName);
if (contextLink != null) {
return contextLink.getParamLinkByName(paramName);
}
return null;
}
public ContextParamLink findContextParamLinkById(String repoContextId, String contextName, String paramId) {
ContextLink contextLink = findContextLink(repoContextId, contextName);
if (contextLink != null) {
return contextLink.getParamLinkById(paramId);
}
return null;
}
public ContextLink findContextLink(String repoContextId, String contextName) {
for (ContextLink contextLink : contextList) {
if ((repoContextId == null || StringUtils.equals(repoContextId, contextLink.getRepoId()))
&& StringUtils.equals(contextName, contextLink.getContextName())) {
return contextLink;
}
}
return null;
}
public ItemContextLink cloneObj() {
ItemContextLink obj = new ItemContextLink();
obj.setItemId(itemId);
for (ContextLink c : contextList) {
obj.getContextList().add(c.cloneObj());
}
return obj;
}
}

View File

@@ -56,6 +56,7 @@ public class ConnectionBean implements Cloneable {
private static final String TOKEN = "token"; //$NON-NLS-1$
private static final String URL = "url"; //$NON-NLS-1$
/**
* DOC smallet ConnectionBean constructor comment.
*/
@@ -396,4 +397,15 @@ public class ConnectionBean implements Cloneable {
}
}
public String getUrl() {
try {
if (conDetails.has(URL)) {
return conDetails.getString(URL);
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
return "";
}
}

View File

@@ -87,6 +87,7 @@ import org.talend.core.model.repository.DragAndDropManager;
import org.talend.core.model.update.UpdatesConstants;
import org.talend.core.model.utils.IDragAndDropServiceHandler;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.services.IGenericWizardService;
import org.talend.core.service.IMetadataManagmentService;
import org.talend.core.service.IMetadataManagmentUiService;
import org.talend.core.utils.KeywordsValidator;
@@ -155,12 +156,12 @@ public class RepositoryToComponentProperty {
return getEDIFACTSchemaValue((EDIFACTConnection) connection, value);
}
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
if (handler.canHandle(connection)) {
return handler.getComponentValue(connection, value, table, targetComponent, contextMap);
}
// Special for Javajet components: tSalesforceEinsteinBulkExec/tSalesforceEinsteinOutputBulkExec
if (targetComponent != null && targetComponent.startsWith("tSalesforceEinstein")) { //$NON-NLS-1$
return getSpecialGenericValue(connection, value, table, targetComponent, contextMap);
}
return null;
return getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
}
@@ -213,8 +214,7 @@ public class RepositoryToComponentProperty {
return;
}
SAPFunctionUnit unit = null;
for (int i = 0; i < conn.getFuntions().size(); i++) {
SAPFunctionUnit tmp = conn.getFuntions().get(i);
for (SAPFunctionUnit tmp : conn.getFuntions()) {
if (tmp.getLabel().equals(functionLabel)) {
unit = tmp;
break;
@@ -230,9 +230,8 @@ public class RepositoryToComponentProperty {
if (isInput) {
mergeColumn(table, table.getChildren(), value2);
} else {
for (int i = 0; i < table.getChildren().size(); i++) {
for (SAPFunctionParameter column : table.getChildren()) {
Map<String, Object> map = new HashMap<String, Object>();
SAPFunctionParameter column = table.getChildren().get(i);
// this part maybe no use , didn't find OUTPUT_PARAMS in sap component
map.put("SAP_PARAMETER_TYPE", column.getType().replace('.', '_')); //$NON-NLS-1$
map.put("SAP_TABLE_NAME", TalendQuoteUtils.addQuotes("")); //$NON-NLS-1$
@@ -298,8 +297,8 @@ public class RepositoryToComponentProperty {
if (conn == null) {
return null;
}
for (int i = 0; i < conn.getFuntions().size(); i++) {
unit = conn.getFuntions().get(i);
for (SAPFunctionUnit element : conn.getFuntions()) {
unit = element;
if (unit.getLabel().equals(functionLabel)) {
break;
}
@@ -626,6 +625,50 @@ public class RepositoryToComponentProperty {
return null;
}
private static Object getSpecialGenericValue(Connection connection, String value, IMetadataTable table,
String targetComponent,
Map<Object, Object> contextMap) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
IGenericWizardService wizardService = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
if (wizardService != null && wizardService.isGenericConnection(connection)) {
if (value != null) {
if ("ENDPOINT".equals(value)) { //$NON-NLS-1$
value = "connection.endpoint"; //$NON-NLS-1$
} else if ("USER_NAME".equals(value)) { //$NON-NLS-1$
value = "connection.userPassword.userId"; //$NON-NLS-1$
} else if ("PASSWORD".equals(value)) { //$NON-NLS-1$
// salesforce javajet component:pwd = pwd + token
value = "connection.userPassword.password"; //$NON-NLS-1$
Object password = getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
String skValue = "connection.userPassword.securityKey"; //$NON-NLS-1$
Object securityKey = getHandlerComponentValue(connection, skValue, table, targetComponent, contextMap);
if (securityKey != null) {
if (isContextMode(connection, String.valueOf(password))) {
return String.valueOf(password) + "+" + String.valueOf(securityKey); //$NON-NLS-1$
} else {
return TalendQuoteUtils.addQuotes(TalendQuoteUtils.removeQuotesIfExist(String.valueOf(password))
+ TalendQuoteUtils.removeQuotesIfExist(String.valueOf(securityKey)));
}
}
return password;
}
return getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
}
}
}
return null;
}
private static Object getHandlerComponentValue(Connection connection, String value, IMetadataTable table,
String targetComponent, Map<Object, Object> contextMap) {
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
if (handler.canHandle(connection)) {
return handler.getComponentValue(connection, value, table, targetComponent, contextMap);
}
}
return null;
}
private static SalesforceModuleUnit getSaleforceModuleUnitByTable(IMetadataTable table,
EList<SalesforceModuleUnit> moduleList) {
for (SalesforceModuleUnit unit : moduleList) {
@@ -746,9 +789,9 @@ public class RepositoryToComponentProperty {
public static List<Map<String, String>> getOutputWSDLValue(EList list) {
List<Map<String, String>> newList = new ArrayList<Map<String, String>>();
for (int i = 0; i < list.size(); i++) {
for (Object element : list) {
Map<String, String> map = new HashMap<String, String>();
WSDLParameter node = (WSDLParameter) list.get(i);
WSDLParameter node = (WSDLParameter) element;
map.put("EXPRESSION", node.getExpression());
map.put("COLUMN", node.getColumn());
map.put("SOURCE", node.getSource());
@@ -1001,8 +1044,9 @@ public class RepositoryToComponentProperty {
} else {
String version = connection.getDbVersionString();
if (EDatabaseVersion4Drivers.ORACLE_18.name().equals(version)) {
if (StringUtils.equals(CDCTypeMode.LOG_MODE.getName(), connection.getCdcTypeMode()))
if (StringUtils.equals(CDCTypeMode.LOG_MODE.getName(), connection.getCdcTypeMode())) {
return CDCTypeMode.LOG_UNSUPPORTED_MODE.getName();
}
}
return connection.getCdcTypeMode();
}
@@ -1491,7 +1535,7 @@ public class RepositoryToComponentProperty {
String clusterID = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
if (clusterID != null) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
IHadoopClusterService hadoopClusterService = (IHadoopClusterService) GlobalServiceRegister.getDefault()
IHadoopClusterService hadoopClusterService = GlobalServiceRegister.getDefault()
.getService(IHadoopClusterService.class);
Map<String, String> hadoopCustomLibraries = hadoopClusterService.getHadoopCustomLibraries(clusterID);
@@ -1735,7 +1779,7 @@ public class RepositoryToComponentProperty {
private static boolean isContextMode(Connection connection, String value) {
IMetadataManagmentUiService mmService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentUiService.class)) {
mmService = (IMetadataManagmentUiService) GlobalServiceRegister.getDefault()
mmService = GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentUiService.class);
}
if (mmService != null) {
@@ -2022,7 +2066,7 @@ public class RepositoryToComponentProperty {
Path p = new Path(connection.getXmlFilePath());
if ((p.toPortableString()).endsWith("xsd")) { //$NON-NLS-1$
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentUiService.class)) {
IMetadataManagmentUiService mmUIService = (IMetadataManagmentUiService) GlobalServiceRegister.getDefault()
IMetadataManagmentUiService mmUIService = GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentUiService.class);
String newPath = mmUIService.getAndOpenXSDFileDialog(p);
if (newPath != null) {
@@ -2142,9 +2186,9 @@ public class RepositoryToComponentProperty {
public static List<Map<String, String>> getOutputXmlValue(EList list) {
List<Map<String, String>> newList = new ArrayList<Map<String, String>>();
for (int i = 0; i < list.size(); i++) {
for (Object element : list) {
Map<String, String> map = new HashMap<String, String>();
XMLFileNode node = (XMLFileNode) list.get(i);
XMLFileNode node = (XMLFileNode) element;
String defaultValue = node.getDefaultValue();
if (defaultValue == null) {
defaultValue = ""; //$NON-NLS-1$
@@ -2388,7 +2432,7 @@ public class RepositoryToComponentProperty {
} else {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentService.class)) {
IMetadataManagmentService mmService = (IMetadataManagmentService) GlobalServiceRegister.getDefault()
IMetadataManagmentService mmService = GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentService.class);
IMetadataTable convert = mmService.convertMetadataTable(repTable);
String uinqueTableName = node.getProcess()
@@ -2643,8 +2687,7 @@ public class RepositoryToComponentProperty {
boolean foundColumn = false;
Map<String, Object> map = new HashMap<String, Object>();
map.put("QUERY", null); //$NON-NLS-1$
for (int i = 0; i < schemaTargets.size(); i++) {
SchemaTarget sch = schemaTargets.get(i);
for (SchemaTarget sch : schemaTargets) {
if (col.getLabel().equals(sch.getTagName())) {
// map.put("SCHEMA_COLUMN", sch.getTagName());
foundColumn = true;
@@ -2653,8 +2696,7 @@ public class RepositoryToComponentProperty {
}
if (!foundColumn && colRenameMap != null && !colRenameMap.isEmpty()) {
Set<String> newNameSet = colRenameMap.keySet();
for (int i = 0; i < schemaTargets.size(); i++) {
SchemaTarget sch = schemaTargets.get(i);
for (SchemaTarget sch : schemaTargets) {
if (newNameSet.contains(sch.getTagName())) {
String oldColLabel = colRenameMap.get(sch.getTagName());
if (col.getLabel().equals(oldColLabel)) {
@@ -2713,8 +2755,7 @@ public class RepositoryToComponentProperty {
for (IMetadataColumn col : metadataTable.getListColumns()) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("QUERY", null); //$NON-NLS-1$
for (int i = 0; i < conceptTargets.size(); i++) {
ConceptTarget cpt = conceptTargets.get(i);
for (ConceptTarget cpt : conceptTargets) {
if (col.getLabel().equals(cpt.getTargetName())) {
// map.put("SCHEMA_COLUMN", sch.getTagName());
map.put("QUERY", TalendQuoteUtils.addQuotes(cpt.getRelativeLoopExpression())); //$NON-NLS-1$

View File

@@ -44,6 +44,8 @@ public interface IContextManager {
public void saveToEmf(EList contextTypeList);
public void saveToEmf(EList contextTypeList, boolean useInternalId);
public void loadFromEmf(EList contextTypeList, String defaultContextName);
public boolean sameAs(IContextManager contextManager);

View File

@@ -71,4 +71,8 @@ public interface IContextParameter {
public void setSource(final String sourceName);
public boolean isBuiltIn();
public String getInternalId();
public void setInternalId(String internalId);
}

View File

@@ -426,6 +426,11 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
*/
public final static ERepositoryObjectType JOBLET = ERepositoryObjectType.valueOf("JOBLET"); //$NON-NLS-1$
/**
* <font color="red">This value may be <b>null</b> in some products, <b>should add NPE check</b></font>
*/
public final static ERepositoryObjectType SERVICES = ERepositoryObjectType.valueOf("SERVICES"); //$NON-NLS-1$
public final static ERepositoryObjectType JOBLET_DESIGNS = ERepositoryObjectType.valueOf("JOBLET_DESIGNS"); //$NON-NLS-1$
public final static ERepositoryObjectType SPARK_JOBLET = ERepositoryObjectType.valueOf("SPARK_JOBLET"); //$NON-NLS-1$
@@ -438,6 +443,8 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
public final static ERepositoryObjectType ROUTINES = ERepositoryObjectType.valueOf("ROUTINES"); //$NON-NLS-1$
public final static ERepositoryObjectType BEANS = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
public final static ERepositoryObjectType METADATA_HEADER_FOOTER = ERepositoryObjectType.valueOf("METADATA_HEADER_FOOTER"); //$NON-NLS-1$
public final static ERepositoryObjectType JOB_SCRIPT = ERepositoryObjectType.valueOf("JOB_SCRIPT"); //$NON-NLS-1$

View File

@@ -0,0 +1,34 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update;
import org.talend.core.AbstractRepositoryContextUpdateService;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.runtime.services.IGenericDBService;
public class GenericDbContextUpdateService extends AbstractRepositoryContextUpdateService {
IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
@Override
public boolean accept(Connection connection) {
return connection.getCompProperties() != null;
}
@Override
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
return updateCompPropertiesContextParameter(conn, oldValue, newValue);
}
}

View File

@@ -0,0 +1,424 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.update;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang.StringUtils;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.talend.core.AbstractRepositoryContextUpdateService;
import org.talend.core.database.conn.ConnParameterKeys;
import org.talend.core.database.conn.template.EDatabaseConnTemplate;
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
import org.talend.core.model.metadata.builder.connection.AdditionalConnectionProperty;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.connection.DelimitedFileConnection;
import org.talend.core.model.metadata.builder.connection.FileExcelConnection;
import org.talend.core.model.metadata.builder.connection.LdifFileConnection;
import org.talend.core.model.metadata.builder.connection.PositionalFileConnection;
import org.talend.core.model.metadata.builder.connection.RegexpFileConnection;
import org.talend.core.model.metadata.builder.connection.SAPConnection;
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
import org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection;
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
import org.talend.core.model.metadata.builder.connection.XmlXPathLoopDescriptor;
public class RepositoryContextUpdateService extends AbstractRepositoryContextUpdateService {
@Override
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.isContextMode()) {
if (conn instanceof DatabaseConnection) {
return updateDatabaseConnectinParam((DatabaseConnection) conn, oldValue, newValue);
}
if (conn instanceof FileExcelConnection) {
return updateFileExcelConnectionParam((FileExcelConnection) conn, oldValue, newValue);
}
if (conn instanceof DelimitedFileConnection) {
return updatDelimitedFileConnectionParam((DelimitedFileConnection) conn, oldValue, newValue);
}
if (conn instanceof RegexpFileConnection) {
return updateRegexpFileConnectionParam((RegexpFileConnection) conn, oldValue, newValue);
}
if (conn instanceof LdifFileConnection) {
return updateLdifFileConnectionParam((LdifFileConnection) conn, oldValue, newValue);
}
if (conn instanceof PositionalFileConnection) {
return updatePositionalFileConnectionParam((PositionalFileConnection) conn, oldValue, newValue);
}
if (conn instanceof XmlFileConnection) {
return updateXmlFileConnectionParam((XmlFileConnection) conn, oldValue, newValue);
}
if (conn instanceof SalesforceSchemaConnection) {
return updateSalesforceSchemaConnectionParam((SalesforceSchemaConnection) conn, oldValue, newValue);
}
if (conn instanceof WSDLSchemaConnection) {
return updateWSDLSchemaConnectionParam((WSDLSchemaConnection) conn, oldValue, newValue);
}
if (conn instanceof SAPConnection) {
return updateSAPConnectionParam((SAPConnection) conn, oldValue, newValue);
}
}
return isModified;
}
private boolean updateParameters(DatabaseConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
EMap<String, String> parameters = dbConn.getParameters();
if (parameters != null && !parameters.isEmpty()) {
for (Entry<String, String> entry : parameters.entrySet()) {
if (entry != null) {
String value = entry.getValue();
if (StringUtils.equals(value, oldValue)) {
entry.setValue(newValue);
isModified = true;
}
}
}
}
boolean hadoopUpdateResult = updateHadoopPropertiesForDbConnection(dbConn, oldValue, newValue);
return isModified || hadoopUpdateResult;
}
private boolean updateHadoopPropertiesForDbConnection(DatabaseConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
EMap<String, String> parameters = dbConn.getParameters();
String databaseType = parameters.get(ConnParameterKeys.CONN_PARA_KEY_DB_TYPE);
String hadoopProperties = "";
if (databaseType != null) {
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES);
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES);
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES);
}
List<Map<String, Object>> hadoopPropertiesList = HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties);
if (!hadoopPropertiesList.isEmpty()) {
for (Map<String, Object> propertyMap : hadoopPropertiesList) {
String propertyValue = (String) propertyMap.get("VALUE");
if (propertyValue.equals(oldValue)) {
propertyMap.put("VALUE", newValue);
isModified = true;
}
}
String hadoopPropertiesJson = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopPropertiesList);
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES, hadoopPropertiesJson);
isModified = true;
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES, hadoopPropertiesJson);
isModified = true;
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES, hadoopPropertiesJson);
isModified = true;
}
}
}
return isModified;
}
private boolean updateDatabaseConnectinParam(DatabaseConnection dbConn, String oldValue, String newValue) {
boolean compPropertiesResult = updateCompPropertiesContextParameter(dbConn, oldValue, newValue);
boolean isModified = false;
if (dbConn.getAdditionalParams() != null && dbConn.getAdditionalParams().equals(oldValue)) {
dbConn.setAdditionalParams(newValue);
isModified = true;
} else if (dbConn.getUsername() != null && dbConn.getUsername().equals(oldValue)) {
dbConn.setUsername(newValue);
isModified = true;
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
dbConn.setPassword(newValue);
isModified = true;
} else if (dbConn.getServerName() != null && dbConn.getServerName().equals(oldValue)) {
dbConn.setServerName(newValue);
isModified = true;
} else if (dbConn.getPort() != null && dbConn.getPort().equals(oldValue)) {
dbConn.setPort(newValue);
isModified = true;
} else if (dbConn.getSID() != null && dbConn.getSID().equals(oldValue)) {
dbConn.setSID(newValue);
isModified = true;
} else if (dbConn.getDbmsId() != null && dbConn.getDbmsId().equals(oldValue)) {
dbConn.setDbmsId(newValue);
isModified = true;
} else if (dbConn.getDriverClass() != null && dbConn.getDriverClass().equals(oldValue)) {
dbConn.setDriverClass(newValue);
isModified = true;
} else if (dbConn.getDriverJarPath() != null && dbConn.getDriverJarPath().equals(oldValue)) {
dbConn.setDriverJarPath(newValue);
isModified = true;
} else if (dbConn.getURL() != null && dbConn.getURL().equals(oldValue)) {
dbConn.setURL(newValue);
isModified = true;
} else if (dbConn.getUiSchema() != null && dbConn.getUiSchema().equals(oldValue)) {
// Added by Marvin Wang on Nov.7, 2012 for bug TDI-12596, because schema can not
// be
// propagated to metadata db.
dbConn.setUiSchema(newValue);
isModified = true;
} else {
isModified = updateParameters(dbConn, oldValue, newValue);
}
return isModified || compPropertiesResult;
}
private boolean updateFileExcelConnectionParam(FileExcelConnection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.getFirstColumn() != null && conn.getFirstColumn().equals(oldValue)) {
conn.setFirstColumn(newValue);
isModified = true;
} else if (conn.getLastColumn() != null && conn.getLastColumn().equals(oldValue)) {
conn.setLastColumn(newValue);
isModified = true;
} else if (conn.getThousandSeparator() != null && conn.getThousandSeparator().equals(oldValue)) {
conn.setThousandSeparator(newValue);
isModified = true;
} else if (conn.getDecimalSeparator() != null && conn.getDecimalSeparator().equals(oldValue)) {
conn.setDecimalSeparator(newValue);
isModified = true;
} else if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
conn.setFilePath(newValue);
isModified = true;
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
conn.setEncoding(newValue);
isModified = true;
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
conn.setLimitValue(newValue);
isModified = true;
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
conn.setHeaderValue(newValue);
isModified = true;
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
conn.setFooterValue(newValue);
isModified = true;
}
return isModified;
}
private boolean updatDelimitedFileConnectionParam(DelimitedFileConnection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
conn.setFilePath(newValue);
isModified = true;
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
conn.setEncoding(newValue);
isModified = true;
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
conn.setLimitValue(newValue);
isModified = true;
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
conn.setHeaderValue(newValue);
isModified = true;
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
conn.setFooterValue(newValue);
isModified = true;
} else if (conn.getRowSeparatorValue() != null && conn.getRowSeparatorValue().equals(oldValue)) {
conn.setRowSeparatorValue(newValue);
isModified = true;
} else if (conn.getFieldSeparatorValue() != null && conn.getFieldSeparatorValue().equals(oldValue)) {
conn.setFieldSeparatorValue(newValue);
isModified = true;
}
return isModified;
}
private boolean updateRegexpFileConnectionParam(RegexpFileConnection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
conn.setFilePath(newValue);
isModified = true;
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
conn.setEncoding(newValue);
isModified = true;
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
conn.setLimitValue(newValue);
isModified = true;
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
conn.setHeaderValue(newValue);
isModified = true;
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
conn.setFooterValue(newValue);
isModified = true;
} else if (conn.getRowSeparatorValue() != null && conn.getRowSeparatorValue().equals(oldValue)) {
conn.setRowSeparatorValue(newValue);
isModified = true;
} else if (conn.getFieldSeparatorValue() != null && conn.getFieldSeparatorValue().equals(oldValue)) {
conn.setFieldSeparatorValue(newValue);
isModified = true;
}
return isModified;
}
private boolean updateLdifFileConnectionParam(LdifFileConnection conn, String oldValue, String newValue) {
boolean isModified = false;
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
conn.setFilePath(newValue);
isModified = true;
}
return isModified;
}
private boolean updatePositionalFileConnectionParam(PositionalFileConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
dbConn.setFilePath(newValue);
isModified = true;
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
dbConn.setEncoding(newValue);
isModified = true;
} else if (dbConn.getLimitValue() != null && dbConn.getLimitValue().equals(oldValue)) {
dbConn.setLimitValue(newValue);
isModified = true;
} else if (dbConn.getHeaderValue() != null && dbConn.getHeaderValue().equals(oldValue)) {
dbConn.setHeaderValue(newValue);
isModified = true;
} else if (dbConn.getFooterValue() != null && dbConn.getFooterValue().equals(oldValue)) {
dbConn.setFooterValue(newValue);
isModified = true;
} else if (dbConn.getRowSeparatorValue() != null && dbConn.getRowSeparatorValue().equals(oldValue)) {
dbConn.setRowSeparatorValue(newValue);
isModified = true;
} else if (dbConn.getFieldSeparatorValue() != null && dbConn.getFieldSeparatorValue().equals(oldValue)) {
dbConn.setFieldSeparatorValue(newValue);
isModified = true;
}
return isModified;
}
private boolean updateXmlFileConnectionParam(XmlFileConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
if (dbConn.getXmlFilePath() != null && dbConn.getXmlFilePath().equals(oldValue)) {
dbConn.setXmlFilePath(newValue);
isModified = true;
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
dbConn.setEncoding(newValue);
isModified = true;
} else if (dbConn.getOutputFilePath() != null && dbConn.getOutputFilePath().equals(oldValue)) {
dbConn.setOutputFilePath(newValue);
isModified = true;
}
EList schema = dbConn.getSchema();
if (schema != null && schema.size() > 0) {
if (schema.get(0) instanceof XmlXPathLoopDescriptor) {
XmlXPathLoopDescriptor descriptor = (XmlXPathLoopDescriptor) schema.get(0);
if (descriptor.getAbsoluteXPathQuery() != null && descriptor.getAbsoluteXPathQuery().equals(oldValue)) {
descriptor.setAbsoluteXPathQuery(newValue);
isModified = true;
}
}
}
return isModified;
}
private boolean updateSalesforceSchemaConnectionParam(SalesforceSchemaConnection ssConn, String oldValue, String newValue) {
boolean isModified = false;
if (ssConn.getWebServiceUrl() != null && ssConn.getWebServiceUrl().equals(oldValue)) {
ssConn.setWebServiceUrl(newValue);
isModified = true;
} else if (ssConn.getPassword() != null && ssConn.getPassword().equals(oldValue)) {
// in fact, because in context mode. can setPassword directly.
// ssConn.setPassword(ssConn.getValue(newValue,true));
ssConn.setPassword(newValue);
isModified = true;
} else if (ssConn.getUserName() != null && ssConn.getUserName().equals(oldValue)) {
ssConn.setUserName(newValue);
isModified = true;
} else if (ssConn.getTimeOut() != null && ssConn.getTimeOut().equals(oldValue)) {
ssConn.setTimeOut(newValue);
isModified = true;
} else if (ssConn.getBatchSize() != null && ssConn.getBatchSize().equals(oldValue)) {
ssConn.setBatchSize(newValue);
isModified = true;
} else if (ssConn.getQueryCondition() != null && ssConn.getQueryCondition().equals(oldValue)) {
ssConn.setQueryCondition(newValue);
isModified = true;
}
return isModified;
}
private boolean updateWSDLSchemaConnectionParam(WSDLSchemaConnection dbConn, String oldValue, String newValue) {
boolean isModified = false;
if (dbConn.getUserName() != null && dbConn.getUserName().equals(oldValue)) {
dbConn.setUserName(newValue);
isModified = true;
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
dbConn.setPassword(newValue);
isModified = true;
} else if (dbConn.getProxyHost() != null && dbConn.getProxyHost().equals(oldValue)) {
dbConn.setProxyHost(newValue);
isModified = true;
} else if (dbConn.getProxyPassword() != null && dbConn.getProxyPassword().equals(oldValue)) {
dbConn.setProxyPassword(newValue);
isModified = true;
} else if (dbConn.getProxyUser() != null && dbConn.getProxyUser().equals(oldValue)) {
dbConn.setProxyUser(newValue);
isModified = true;
} else if (dbConn.getProxyPort() != null && dbConn.getProxyPort().equals(oldValue)) {
dbConn.setProxyPort(newValue);
isModified = true;
}
return isModified;
}
private boolean updateSAPConnectionParam(SAPConnection sapConn, String oldValue, String newValue) {
boolean isModified = false;
if (sapConn.getClient() != null && sapConn.getClient().equals(oldValue)) {
sapConn.setClient(newValue);
isModified = true;
} else if (sapConn.getUsername() != null && sapConn.getUsername().equals(oldValue)) {
sapConn.setUsername(newValue);
isModified = true;
} else if (sapConn.getPassword() != null && sapConn.getPassword().equals(oldValue)) {
sapConn.setPassword(newValue);
isModified = true;
} else if (sapConn.getHost() != null && sapConn.getHost().equals(oldValue)) {
sapConn.setHost(newValue);
isModified = true;
} else if (sapConn.getSystemNumber() != null && sapConn.getSystemNumber().equals(oldValue)) {
sapConn.setSystemNumber(newValue);
isModified = true;
} else if (sapConn.getLanguage() != null && sapConn.getLanguage().equals(oldValue)) {
sapConn.setLanguage(newValue);
isModified = true;
} else {
for (AdditionalConnectionProperty sapProperty : sapConn.getAdditionalProperties()) {
if (sapProperty.getValue() != null && sapProperty.getValue().equals(oldValue)) {
sapProperty.setValue(newValue);
isModified = true;
}
}
}
return isModified;
}
@Override
public boolean accept(Connection connection) {
if (connection instanceof DatabaseConnection || connection instanceof FileExcelConnection
|| connection instanceof DelimitedFileConnection || connection instanceof RegexpFileConnection
|| connection instanceof LdifFileConnection || connection instanceof PositionalFileConnection
|| connection instanceof XmlFileConnection || connection instanceof SalesforceSchemaConnection
|| connection instanceof WSDLSchemaConnection || connection instanceof SAPConnection) {
return true;
}
return false;
}
}

View File

@@ -21,14 +21,12 @@ import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
@@ -41,11 +39,8 @@ import org.talend.commons.exception.PersistenceException;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.ICoreService;
import org.talend.core.IRepositoryContextUpdateService;
import org.talend.core.IService;
import org.talend.core.ITDQPatternService;
import org.talend.core.ITDQRepositoryService;
import org.talend.core.database.conn.ConnParameterKeys;
import org.talend.core.database.conn.template.EDatabaseConnTemplate;
import org.talend.core.hadoop.BigDataBasicUtil;
import org.talend.core.hadoop.HadoopConstants;
import org.talend.core.hadoop.IHadoopClusterService;
@@ -54,28 +49,23 @@ import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.context.JobContext;
import org.talend.core.model.context.JobContextManager;
import org.talend.core.model.context.JobContextParameter;
import org.talend.core.model.context.link.ContextLink;
import org.talend.core.model.context.link.ContextLinkService;
import org.talend.core.model.context.link.ContextParamLink;
import org.talend.core.model.context.link.ItemContextLink;
import org.talend.core.model.metadata.IMetadataColumn;
import org.talend.core.model.metadata.IMetadataTable;
import org.talend.core.model.metadata.MetadataSchemaType;
import org.talend.core.model.metadata.builder.connection.AdditionalConnectionProperty;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.connection.DelimitedFileConnection;
import org.talend.core.model.metadata.builder.connection.FileExcelConnection;
import org.talend.core.model.metadata.builder.connection.GenericSchemaConnection;
import org.talend.core.model.metadata.builder.connection.LdifFileConnection;
import org.talend.core.model.metadata.builder.connection.MetadataTable;
import org.talend.core.model.metadata.builder.connection.PositionalFileConnection;
import org.talend.core.model.metadata.builder.connection.QueriesConnection;
import org.talend.core.model.metadata.builder.connection.Query;
import org.talend.core.model.metadata.builder.connection.RegexpFileConnection;
import org.talend.core.model.metadata.builder.connection.SAPConnection;
import org.talend.core.model.metadata.builder.connection.SAPFunctionUnit;
import org.talend.core.model.metadata.builder.connection.SAPIDocUnit;
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
import org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection;
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
import org.talend.core.model.metadata.builder.connection.XmlXPathLoopDescriptor;
import org.talend.core.model.process.IContext;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IContextParameter;
@@ -94,10 +84,12 @@ import org.talend.core.model.relationship.RelationshipItemBuilder;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.update.extension.UpdateManagerProviderDetector;
import org.talend.core.model.utils.ContextParameterUtils;
import org.talend.core.model.utils.UpdateRepositoryHelper;
import org.talend.core.prefs.ITalendCorePrefConstants;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.core.runtime.i18n.Messages;
import org.talend.core.runtime.services.IGenericDBService;
import org.talend.core.service.IMRProcessService;
import org.talend.core.service.IMetadataManagmentService;
import org.talend.core.service.IStormProcessService;
@@ -110,7 +102,6 @@ import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.runprocess.ItemCacheManager;
import org.talend.repository.model.IProxyRepositoryFactory;
import org.talend.repository.model.IProxyRepositoryService;
import org.talend.repository.model.IRepositoryService;
import org.talend.repository.model.RepositoryNode;
@@ -119,6 +110,12 @@ import org.talend.repository.model.RepositoryNode;
*/
public abstract class RepositoryUpdateManager {
private static final Logger LOGGER = Logger.getLogger(RepositoryUpdateManager.class);
private static final IProxyRepositoryFactory FACTORY = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
private static List<IRepositoryContextUpdateService> CONTEXT_UPDATE_SERVICE_LIST = null;
/**
* for repository context rename.
*/
@@ -147,7 +144,7 @@ public abstract class RepositoryUpdateManager {
*/
protected Object parameter;
private Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
private Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
private boolean onlyOpeningJob = false;
@@ -279,7 +276,7 @@ public abstract class RepositoryUpdateManager {
private boolean openRenameCheckedDialog() {
return MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),
Messages.getString("RepositoryUpdateManager.RenameContextTitle"), //$NON-NLS-1$
Messages.getString("RepositoryUpdateManager.RenameContextMessages")); //$NON-NLS-1$
Messages.getString("RepositoryUpdateManager.RenameContextMessagesNoBuiltIn")); //$NON-NLS-1$
}
@@ -288,7 +285,7 @@ public abstract class RepositoryUpdateManager {
}
public boolean needForcePropagation() {
return needForcePropagationForContext() || (getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty());
return getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty();
}
private boolean needForcePropagationForContext() {
@@ -687,469 +684,191 @@ public abstract class RepositoryUpdateManager {
if (valueMap == null) {
return;
}
Set<String> set = valueMap.keySet();
List<String> list = new ArrayList<String>(set);
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
for (String newValue : list) {
String oldValue = valueMap.get(newValue);
oldValue = "context." + oldValue;
newValue = "context." + newValue;
List<IRepositoryViewObject> dbConnList = factory.getAll(ERepositoryObjectType.METADATA_CONNECTIONS, true);
for (IRepositoryViewObject obj : dbConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof DatabaseConnection) {
DatabaseConnection dbConn = (DatabaseConnection) conn;
if (dbConn.getAdditionalParams() != null && dbConn.getAdditionalParams().equals(oldValue)) {
dbConn.setAdditionalParams(newValue);
} else if (dbConn.getUsername() != null && dbConn.getUsername().equals(oldValue)) {
dbConn.setUsername(newValue);
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
dbConn.setPassword(newValue);
} else if (dbConn.getServerName() != null && dbConn.getServerName().equals(oldValue)) {
dbConn.setServerName(newValue);
} else if (dbConn.getPort() != null && dbConn.getPort().equals(oldValue)) {
dbConn.setPort(newValue);
} else if (dbConn.getSID() != null && dbConn.getSID().equals(oldValue)) {
dbConn.setSID(newValue);
} else if (dbConn.getDbmsId() != null && dbConn.getDbmsId().equals(oldValue)) {
dbConn.setDbmsId(newValue);
} else if (dbConn.getDriverClass() != null && dbConn.getDriverClass().equals(oldValue)) {
dbConn.setDriverClass(newValue);
} else if (dbConn.getDriverJarPath() != null && dbConn.getDriverJarPath().equals(oldValue)) {
dbConn.setDriverJarPath(newValue);
} else if (dbConn.getURL() != null && dbConn.getURL().equals(oldValue)) {
dbConn.setURL(newValue);
} else if (dbConn.getUiSchema() != null && dbConn.getUiSchema().equals(oldValue)) {
// Added by Marvin Wang on Nov.7, 2012 for bug TDI-12596, because schema can not be
// propagated to metadata db.
dbConn.setUiSchema(newValue);
} else {
updateParameters(dbConn, oldValue, newValue);
}
factory.save(item);
}
}
}
}
List<IRepositoryViewObject> dbConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_CONNECTIONS, true);
for (IRepositoryViewObject obj : dbConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
List<IRepositoryViewObject> excelConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_EXCEL, true);
for (IRepositoryViewObject obj : excelConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof FileExcelConnection) {
if (((FileExcelConnection) conn).getFirstColumn() != null
&& ((FileExcelConnection) conn).getFirstColumn().equals(oldValue)) {
((FileExcelConnection) conn).setFirstColumn(newValue);
} else if (((FileExcelConnection) conn).getLastColumn() != null
&& ((FileExcelConnection) conn).getLastColumn().equals(oldValue)) {
((FileExcelConnection) conn).setLastColumn(newValue);
} else if (((FileExcelConnection) conn).getThousandSeparator() != null
&& ((FileExcelConnection) conn).getThousandSeparator().equals(oldValue)) {
((FileExcelConnection) conn).setThousandSeparator(newValue);
} else if (((FileExcelConnection) conn).getDecimalSeparator() != null
&& ((FileExcelConnection) conn).getDecimalSeparator().equals(oldValue)) {
((FileExcelConnection) conn).setDecimalSeparator(newValue);
} else if (((FileExcelConnection) conn).getFilePath() != null
&& ((FileExcelConnection) conn).getFilePath().equals(oldValue)) {
((FileExcelConnection) conn).setFilePath(newValue);
} else if (((FileExcelConnection) conn).getEncoding() != null
&& ((FileExcelConnection) conn).getEncoding().equals(oldValue)) {
((FileExcelConnection) conn).setEncoding(newValue);
} else if (((FileExcelConnection) conn).getLimitValue() != null
&& ((FileExcelConnection) conn).getLimitValue().equals(oldValue)) {
((FileExcelConnection) conn).setLimitValue(newValue);
} else if (((FileExcelConnection) conn).getHeaderValue() != null
&& ((FileExcelConnection) conn).getHeaderValue().equals(oldValue)) {
((FileExcelConnection) conn).setHeaderValue(newValue);
} else if (((FileExcelConnection) conn).getFooterValue() != null
&& ((FileExcelConnection) conn).getFooterValue().equals(oldValue)) {
((FileExcelConnection) conn).setFooterValue(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> excelConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_EXCEL, true);
for (IRepositoryViewObject obj : excelConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> deliConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_DELIMITED, true);
for (IRepositoryViewObject obj : deliConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof DelimitedFileConnection) {
if (((DelimitedFileConnection) conn).getFilePath() != null
&& ((DelimitedFileConnection) conn).getFilePath().equals(oldValue)) {
((DelimitedFileConnection) conn).setFilePath(newValue);
} else if (((DelimitedFileConnection) conn).getEncoding() != null
&& ((DelimitedFileConnection) conn).getEncoding().equals(oldValue)) {
((DelimitedFileConnection) conn).setEncoding(newValue);
} else if (((DelimitedFileConnection) conn).getLimitValue() != null
&& ((DelimitedFileConnection) conn).getLimitValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setLimitValue(newValue);
} else if (((DelimitedFileConnection) conn).getHeaderValue() != null
&& ((DelimitedFileConnection) conn).getHeaderValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setHeaderValue(newValue);
} else if (((DelimitedFileConnection) conn).getFooterValue() != null
&& ((DelimitedFileConnection) conn).getFooterValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setFooterValue(newValue);
} else if (((DelimitedFileConnection) conn).getRowSeparatorValue() != null
&& ((DelimitedFileConnection) conn).getRowSeparatorValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setRowSeparatorValue(newValue);
} else if (((DelimitedFileConnection) conn).getFieldSeparatorValue() != null
&& ((DelimitedFileConnection) conn).getFieldSeparatorValue().equals(oldValue)) {
((DelimitedFileConnection) conn).setFieldSeparatorValue(newValue);
}
factory.save(item);
}
List<IRepositoryViewObject> deliConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_DELIMITED, true);
for (IRepositoryViewObject obj : deliConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> regConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_REGEXP, true);
for (IRepositoryViewObject obj : regConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> ldifConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_LDIF, true);
for (IRepositoryViewObject obj : ldifConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> posiConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_POSITIONAL, true);
for (IRepositoryViewObject obj : posiConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> xmlConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_XML, true);
for (IRepositoryViewObject obj : xmlConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> saleConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA, true);
for (IRepositoryViewObject obj : saleConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
List<IRepositoryViewObject> wsdlConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_WSDL_SCHEMA, true);
for (IRepositoryViewObject obj : wsdlConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
}
}
}
List<IRepositoryViewObject> sapConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_SAPCONNECTIONS, true);
for (IRepositoryViewObject obj : sapConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
List<IRepositoryViewObject> regConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_REGEXP, true);
for (IRepositoryViewObject obj : regConnList) {
}
for (String updateType : UpdateRepositoryHelper.getAllHadoopConnectionTypes()) {
List<IRepositoryViewObject> hadoopConnList = FACTORY
.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, updateType), true);
for (IRepositoryViewObject obj : hadoopConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof RegexpFileConnection) {
if (((RegexpFileConnection) conn).getFilePath() != null
&& ((RegexpFileConnection) conn).getFilePath().equals(oldValue)) {
((RegexpFileConnection) conn).setFilePath(newValue);
} else if (((RegexpFileConnection) conn).getEncoding() != null
&& ((RegexpFileConnection) conn).getEncoding().equals(oldValue)) {
((RegexpFileConnection) conn).setEncoding(newValue);
} else if (((RegexpFileConnection) conn).getLimitValue() != null
&& ((RegexpFileConnection) conn).getLimitValue().equals(oldValue)) {
((RegexpFileConnection) conn).setLimitValue(newValue);
} else if (((RegexpFileConnection) conn).getHeaderValue() != null
&& ((RegexpFileConnection) conn).getHeaderValue().equals(oldValue)) {
((RegexpFileConnection) conn).setHeaderValue(newValue);
} else if (((RegexpFileConnection) conn).getFooterValue() != null
&& ((RegexpFileConnection) conn).getFooterValue().equals(oldValue)) {
((RegexpFileConnection) conn).setFooterValue(newValue);
} else if (((RegexpFileConnection) conn).getRowSeparatorValue() != null
&& ((RegexpFileConnection) conn).getRowSeparatorValue().equals(oldValue)) {
((RegexpFileConnection) conn).setRowSeparatorValue(newValue);
} else if (((RegexpFileConnection) conn).getFieldSeparatorValue() != null
&& ((RegexpFileConnection) conn).getFieldSeparatorValue().equals(oldValue)) {
((RegexpFileConnection) conn).setFieldSeparatorValue(newValue);
}
factory.save(item);
}
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
}
}
}
}
}
List<IRepositoryViewObject> ldifConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_LDIF, true);
for (IRepositoryViewObject obj : ldifConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof LdifFileConnection) {
LdifFileConnection dbConn = (LdifFileConnection) conn;
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
dbConn.setFilePath(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> posiConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_POSITIONAL, true);
for (IRepositoryViewObject obj : posiConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof PositionalFileConnection) {
PositionalFileConnection dbConn = (PositionalFileConnection) conn;
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
dbConn.setFilePath(newValue);
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
dbConn.setEncoding(newValue);
} else if (dbConn.getLimitValue() != null && dbConn.getLimitValue().equals(oldValue)) {
dbConn.setLimitValue(newValue);
} else if (dbConn.getHeaderValue() != null && dbConn.getHeaderValue().equals(oldValue)) {
dbConn.setHeaderValue(newValue);
} else if (dbConn.getFooterValue() != null && dbConn.getFooterValue().equals(oldValue)) {
dbConn.setFooterValue(newValue);
} else if (dbConn.getRowSeparatorValue() != null
&& dbConn.getRowSeparatorValue().equals(oldValue)) {
dbConn.setRowSeparatorValue(newValue);
} else if (dbConn.getFieldSeparatorValue() != null
&& dbConn.getFieldSeparatorValue().equals(oldValue)) {
dbConn.setFieldSeparatorValue(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> xmlConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_XML, true);
for (IRepositoryViewObject obj : xmlConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof XmlFileConnection) {
XmlFileConnection dbConn = (XmlFileConnection) conn;
if (dbConn.getXmlFilePath() != null && dbConn.getXmlFilePath().equals(oldValue)) {
dbConn.setXmlFilePath(newValue);
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
dbConn.setEncoding(newValue);
} else if (dbConn.getOutputFilePath() != null && dbConn.getOutputFilePath().equals(oldValue)) {
dbConn.setOutputFilePath(newValue);
}
EList schema = dbConn.getSchema();
if (schema != null && schema.size() > 0) {
if (schema.get(0) instanceof XmlXPathLoopDescriptor) {
XmlXPathLoopDescriptor descriptor = (XmlXPathLoopDescriptor) schema.get(0);
if (descriptor.getAbsoluteXPathQuery() != null
&& descriptor.getAbsoluteXPathQuery().equals(oldValue)) {
descriptor.setAbsoluteXPathQuery(newValue);
}
}
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> saleConnList = factory.getAll(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA, true);
for (IRepositoryViewObject obj : saleConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof SalesforceSchemaConnection) {
SalesforceSchemaConnection ssConn = (SalesforceSchemaConnection) conn;
if (ssConn.getWebServiceUrl() != null && ssConn.getWebServiceUrl().equals(oldValue)) {
ssConn.setWebServiceUrl(newValue);
} else if (ssConn.getPassword() != null && ssConn.getPassword().equals(oldValue)) {
// in fact, because in context mode. can setPassword directly.
// ssConn.setPassword(ssConn.getValue(newValue,true));
ssConn.setPassword(newValue);
} else if (ssConn.getUserName() != null && ssConn.getUserName().equals(oldValue)) {
ssConn.setUserName(newValue);
} else if (ssConn.getTimeOut() != null && ssConn.getTimeOut().equals(oldValue)) {
ssConn.setTimeOut(newValue);
} else if (ssConn.getBatchSize() != null && ssConn.getBatchSize().equals(oldValue)) {
ssConn.setBatchSize(newValue);
} else if (ssConn.getQueryCondition() != null && ssConn.getQueryCondition().equals(oldValue)) {
ssConn.setQueryCondition(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> wsdlConnList = factory.getAll(ERepositoryObjectType.METADATA_WSDL_SCHEMA, true);
for (IRepositoryViewObject obj : wsdlConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof WSDLSchemaConnection) {
WSDLSchemaConnection dbConn = (WSDLSchemaConnection) conn;
if (dbConn.getUserName() != null && dbConn.getUserName().equals(oldValue)) {
dbConn.setUserName(newValue);
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
dbConn.setPassword(newValue);
} else if (dbConn.getProxyHost() != null && dbConn.getProxyHost().equals(oldValue)) {
dbConn.setProxyHost(newValue);
} else if (dbConn.getProxyPassword() != null && dbConn.getProxyPassword().equals(oldValue)) {
dbConn.setProxyPassword(newValue);
} else if (dbConn.getProxyUser() != null && dbConn.getProxyUser().equals(oldValue)) {
dbConn.setProxyUser(newValue);
} else if (dbConn.getProxyPort() != null && dbConn.getProxyPort().equals(oldValue)) {
dbConn.setProxyPort(newValue);
}
factory.save(item);
}
}
}
}
}
List<IRepositoryViewObject> sapConnList = factory.getAll(ERepositoryObjectType.METADATA_SAPCONNECTIONS, true);
for (IRepositoryViewObject obj : sapConnList) {
Item item = obj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (conn instanceof SAPConnection) {
SAPConnection sapConn = (SAPConnection) conn;
if (sapConn.getClient() != null && sapConn.getClient().equals(oldValue)) {
sapConn.setClient(newValue);
} else if (sapConn.getUsername() != null && sapConn.getUsername().equals(oldValue)) {
sapConn.setUsername(newValue);
} else if (sapConn.getPassword() != null && sapConn.getPassword().equals(oldValue)) {
sapConn.setPassword(newValue);
} else if (sapConn.getHost() != null && sapConn.getHost().equals(oldValue)) {
sapConn.setHost(newValue);
} else if (sapConn.getSystemNumber() != null && sapConn.getSystemNumber().equals(oldValue)) {
sapConn.setSystemNumber(newValue);
} else if (sapConn.getLanguage() != null && sapConn.getLanguage().equals(oldValue)) {
sapConn.setLanguage(newValue);
} else {
for (AdditionalConnectionProperty sapProperty : sapConn.getAdditionalProperties()) {
if (sapProperty.getValue() != null && sapProperty.getValue().equals(oldValue)) {
sapProperty.setValue(newValue);
}
}
}
factory.save(item);
}
}
}
}
}
for (String updateType : UpdateRepositoryHelper.getAllHadoopConnectionTypes()) {
List<IRepositoryViewObject> hadoopConnList = factory
.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, updateType), true);
for (IRepositoryViewObject obj : hadoopConnList) {
Item item = obj.getProperty().getItem();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
for (ERepositoryObjectType objectType : service.getAllGenericMetadataDBRepositoryType()) {
List<IRepositoryViewObject> repositoryObjects = FACTORY.getAll(objectType);
for (IRepositoryViewObject object : repositoryObjects) {
Item item = object.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
if (contextItem == null) {
continue;
}
if (citem == contextItem) {
if (GlobalServiceRegister.getDefault()
.isServiceRegistered(IRepositoryContextUpdateService.class)) {
IService service = GlobalServiceRegister.getDefault()
.getService(IRepositoryContextUpdateService.class);
IRepositoryContextUpdateService repositoryContextUpdateService = (IRepositoryContextUpdateService) service;
repositoryContextUpdateService.updateRelatedContextVariable(conn, oldValue, newValue);
}
factory.save(item);
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
}
}
}
}
}
private static void updateConnectionContextParam(ConnectionItem conntectionItem, ContextItem citem,
Map<String, String> newToOldValueMap) throws PersistenceException {
boolean isModified = false;
if (conntectionItem != null && conntectionItem.getConnection() != null && citem != null
&& citem.getProperty() != null
&& StringUtils.equals(conntectionItem.getConnection().getContextId(), citem.getProperty().getId())) {
for (String newValue : newToOldValueMap.keySet()) {
String oldValue = newToOldValueMap.get(newValue);
boolean result = updateConnectionContextParam(conntectionItem, oldValue, newValue);
isModified = isModified || result;
}
if (isModified) {
FACTORY.save(conntectionItem, false);
}
}
}
private static boolean updateConnectionContextParam(ConnectionItem conntectionItem, String oldValue, String newValue) {
Connection conn = conntectionItem.getConnection();
if (conn.isContextMode()) {
IRepositoryContextUpdateService updater = null;
updater = findContextParameterUpdater(conn);
if (updater != null) {
return updater.updateContextParameter(conn, addContextParamPrefix(oldValue), addContextParamPrefix(newValue));
}
}
return false;
}
public static void updateConnectionContextParam(RepositoryNode connNode) throws PersistenceException {
if (connNode.getObject() == null || connNode.getObject().getProperty() == null
|| connNode.getObject().getProperty().getItem() == null) {
return;
}
ConnectionItem conntectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
updateConnectionContextParam(conntectionItem);
}
public static void updateConnectionContextParam(ConnectionItem conntectionItem)
throws PersistenceException {
Connection conn = conntectionItem.getConnection();
if (conn.isContextMode()) {
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
ItemContextLink itemContextLink = null;
try {
itemContextLink = ContextLinkService.getInstance().loadContextLinkFromJson(conntectionItem);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
ContextLink contextLink = null;
if (itemContextLink != null) {
contextLink = itemContextLink.findContextLink(null, conn.getContextName());
}
if (contextLink != null) {
ContextType contextType = ContextUtils.getContextTypeByName(contextItem, conn.getContextName(), false);
IRepositoryContextUpdateService updateServce = findContextParameterUpdater(conn);
if (updateServce != null) {
boolean isModified = false;
for (ContextParamLink paramLink : contextLink.getParameterList()) {
ContextParameterType paramType = ContextUtils.getContextParameterTypeByName(contextType,
paramLink.getName());
if (paramType == null) {
paramType = ContextUtils.getContextParameterTypeById(contextType, paramLink.getId(), true);
if (paramType != null) {
boolean result = updateServce.updateContextParameter(conn,
addContextParamPrefix(paramLink.getName()), addContextParamPrefix(paramType.getName()));
isModified = isModified || result;
}
}
}
}
}
}
}
private void updateParameters(DatabaseConnection dbConn, String oldValue, String newValue) {
EMap<String, String> parameters = dbConn.getParameters();
if (parameters != null && !parameters.isEmpty()) {
for (Entry<String, String> entry : parameters.entrySet()) {
if (entry != null) {
String value = entry.getValue();
if (StringUtils.equals(value, oldValue)) {
entry.setValue(newValue);
if (isModified) {
FACTORY.save(conntectionItem, false);
}
}
}
}
updateHadoopPropertiesForDbConnection(dbConn, oldValue, newValue);
}
private void updateHadoopPropertiesForDbConnection(DatabaseConnection dbConn, String oldValue, String newValue) {
EMap<String, String> parameters = dbConn.getParameters();
String databaseType = parameters.get(ConnParameterKeys.CONN_PARA_KEY_DB_TYPE);
String hadoopProperties = "";
if (databaseType != null) {
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES);
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES);
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES);
}
List<Map<String, Object>> hadoopPropertiesList = HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties);
if (!hadoopPropertiesList.isEmpty()) {
for (Map<String, Object> propertyMap : hadoopPropertiesList) {
String propertyValue = (String) propertyMap.get("VALUE");
if (propertyValue.equals(oldValue)) {
propertyMap.put("VALUE", newValue);
}
}
String hadoopPropertiesJson = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopPropertiesList);
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES, hadoopPropertiesJson);
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES, hadoopPropertiesJson);
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES, hadoopPropertiesJson);
}
}
private static String addContextParamPrefix(String value) {
if (!value.startsWith(ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX)) {
value = ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + value;
}
return value;
}
public static IEditorReference[] getEditors() {
if (CommonsPlugin.isHeadless() || !getProxyRepositoryFactory().isFullLogonFinished()) {
if (CommonsPlugin.isHeadless() || !FACTORY.isFullLogonFinished()) {
return new IEditorReference[0];
}
final List<IEditorReference> list = new ArrayList<IEditorReference>();
@@ -1245,6 +964,7 @@ public abstract class RepositoryUpdateManager {
jobParam.setSource(repositoryId);
jobParam.setType(repoParam.getType());
jobParam.setValue(repoParam.getValue());
jobParam.setInternalId(repoParam.getInternalId());
jobContext.getContextParameterList().add(jobParam);
}
addContextGroupList.add(jobContext);
@@ -1529,7 +1249,6 @@ public abstract class RepositoryUpdateManager {
*/
public static boolean updateServices(ConnectionItem connectionItem, boolean show, final boolean onlySimpleShow) {
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.SERVICES_RELATION);
@@ -1623,7 +1342,6 @@ public abstract class RepositoryUpdateManager {
* @return
*/
public static boolean updateValidationRuleConnection(ConnectionItem connectionItem, boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.VALIDATION_RULE_RELATION);
@@ -1977,7 +1695,6 @@ public abstract class RepositoryUpdateManager {
public static boolean updateWSDLConnection(ConnectionItem connectionItem, boolean show, final boolean onlySimpleShow) {
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
@@ -2062,7 +1779,6 @@ public abstract class RepositoryUpdateManager {
* @return
*/
public static boolean updateSAPFunction(final SAPFunctionUnit sapFunction, boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(sapFunction.getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
@@ -2091,8 +1807,6 @@ public abstract class RepositoryUpdateManager {
* @return
*/
public static boolean updateSAPIDoc(final SAPIDocUnit sapIDoc, boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(sapIDoc.getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
@@ -2151,8 +1865,6 @@ public abstract class RepositoryUpdateManager {
protected static boolean updateSchema(final Object table, ConnectionItem connItem, Map<String, String> schemaRenamedMap,
boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo((connItem).getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
@@ -2208,8 +1920,6 @@ public abstract class RepositoryUpdateManager {
}
private static boolean updateQueryObject(Object parameter, boolean show, boolean onlySimpleShow) {
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
List<Relation> relations = null;
if (parameter instanceof Query) {
relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(((Query) parameter).getId(),
@@ -2340,7 +2050,7 @@ public abstract class RepositoryUpdateManager {
repositoryUpdateManager.setContextRenamedMap(repositoryRenamedMap);
// newly added parameters
Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
if (!repositoryContextManager.getNewParameters().isEmpty()) {
newParametersMap.put(item, repositoryContextManager.getNewParameters());
}
@@ -2352,16 +2062,14 @@ public abstract class RepositoryUpdateManager {
ExceptionHandler.process(e);
}
return repositoryUpdateManager.doWork(show, onlySimpleShow);
}
public Map<ContextItem, Set<String>> getNewParametersMap() {
public Map<Item, Set<String>> getNewParametersMap() {
return newParametersMap;
}
public void setNewParametersMap(Map<ContextItem, Set<String>> newParametersMap) {
public void setNewParametersMap(Map<Item, Set<String>> newParametersMap) {
this.newParametersMap = newParametersMap;
}
@@ -2464,7 +2172,6 @@ public abstract class RepositoryUpdateManager {
// Added TDQ-11688 20170309 yyin
public static boolean updateDQPattern(Item patternItem) {
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(patternItem.getProperty().getId(),
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PATTERN_RELATION);
@@ -2482,9 +2189,19 @@ public abstract class RepositoryUpdateManager {
return repositoryUpdateManager.doWork(true, false);
}
private static IProxyRepositoryFactory getProxyRepositoryFactory() {
return ((IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class))
.getProxyRepositoryFactory();
}
public static IRepositoryContextUpdateService findContextParameterUpdater(Connection connection) {
if (CONTEXT_UPDATE_SERVICE_LIST == null) {
CONTEXT_UPDATE_SERVICE_LIST = GlobalServiceRegister.getDefault()
.findAllService(IRepositoryContextUpdateService.class);
}
for (IRepositoryContextUpdateService updater : CONTEXT_UPDATE_SERVICE_LIST) {
if (updater.accept(connection)) {
return updater;
}
}
LOGGER.error(
"Can't find any connection context parameter updater for connection type:" + connection.getClass().getName());
return null;
}
}

View File

@@ -187,11 +187,13 @@ public class TalendLibsServerManager {
* Check user library connection with the setting from remote administrator
*
* @return
* @throws PersistenceException
*/
public boolean canConnectUserLibrary() {
public boolean canConnectUserLibrary() throws PersistenceException {
boolean canConnect = false;
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
RepositoryContext repositoryContext = factory.getRepositoryContext();
ArtifactRepositoryBean bean = null;
try {
if (repositoryContext != null && repositoryContext.getFields() != null && !factory.isLocalConnectionProvider()
&& !repositoryContext.isOffline()) {
@@ -208,7 +210,7 @@ public class TalendLibsServerManager {
&& GlobalServiceRegister.getDefault().isServiceRegistered(IRemoteService.class)) {
IRemoteService remoteService = (IRemoteService) GlobalServiceRegister.getDefault()
.getService(IRemoteService.class);
ArtifactRepositoryBean bean = remoteService.getLibNexusServer(userName, password, adminUrl);
bean = remoteService.getLibNexusServer(userName, password, adminUrl);
if (bean != null) {
IRepositoryArtifactHandler handler = RepositoryArtifactHandlerManager.getRepositoryHandler(bean);
if (handler.checkConnection()) {
@@ -223,6 +225,9 @@ public class TalendLibsServerManager {
} catch (Exception e) {
ExceptionHandler.process(e);
}
if (bean == null) {
throw new PersistenceException(Messages.getString("TalendLibsServerManager.cannotGetUserLibraryServer"));
}
return canConnect;
}

View File

@@ -32,8 +32,12 @@ public class LastGenerationInfo {
private HashMap<String, Set<ModuleNeeded>> modulesNeededWithSubjobPerJob;
private HashMap<String, Set<ModuleNeeded>> highPriorityModuleNeededPerJob;
private HashMap<String, Set<ModuleNeeded>> highPriorityModuleNeeded;
private HashMap<String, Set<ModuleNeeded>> testcaseModuleNeeded;
private HashMap<String, Set<String>> routinesNeededWithSubjobPerJob;
private HashMap<String, Set<String>> contextPerJob;
@@ -52,7 +56,9 @@ public class LastGenerationInfo {
modulesNeededPerJob = new HashMap<String, Set<ModuleNeeded>>();
contextPerJob = new HashMap<String, Set<String>>();
modulesNeededWithSubjobPerJob = new HashMap<String, Set<ModuleNeeded>>();
highPriorityModuleNeededPerJob = new HashMap<>();
highPriorityModuleNeeded = new HashMap<>();
testcaseModuleNeeded = new HashMap<>();
lastGeneratedjobs = new HashSet<JobInfo>();
routinesNeededPerJob = new HashMap<String, Set<String>>();
routinesNeededWithSubjobPerJob = new HashMap<String, Set<String>>();
@@ -235,6 +241,22 @@ public class LastGenerationInfo {
return routinesNeededPerJob.get(key);
}
public Set<ModuleNeeded> getHighPriorityModuleNeededPerJob(String jobId, String jobVersion) {
String key = getProcessKey(jobId, jobVersion);
if (!highPriorityModuleNeededPerJob.containsKey(key)) {
highPriorityModuleNeededPerJob.put(key, new LinkedHashSet<>());
}
return highPriorityModuleNeededPerJob.get(key);
}
public void setHighPriorityModuleNeededPerJob(String jobId, String jobVersion, Set<ModuleNeeded> moduleNeeded) {
String key = getProcessKey(jobId, jobVersion);
if (!highPriorityModuleNeededPerJob.containsKey(key)) {
highPriorityModuleNeededPerJob.put(key, new LinkedHashSet<>());
}
highPriorityModuleNeededPerJob.get(key).addAll(moduleNeeded);
}
public Set<ModuleNeeded> getHighPriorityModuleNeeded(String jobId, String jobVersion) {
String key = getProcessKey(jobId, jobVersion);
if (!highPriorityModuleNeeded.containsKey(key)) {
@@ -251,7 +273,20 @@ public class LastGenerationInfo {
highPriorityModuleNeeded.get(key).addAll(moduleNeeded);
}
public Set<ModuleNeeded> getTestcaseModuleNeeded(String jobId, String jobVersion) {
String key = getProcessKey(jobId, jobVersion);
if (!testcaseModuleNeeded.containsKey(key)) {
testcaseModuleNeeded.put(key, new HashSet<>());
}
return testcaseModuleNeeded.get(key);
}
public void setTestcaseModuleNeeded(String jobId, String jobVersion, Set<ModuleNeeded> modulesNeeded) {
testcaseModuleNeeded.put(getProcessKey(jobId, jobVersion), new HashSet<>(modulesNeeded));
}
public void clearHighPriorityModuleNeeded() {
highPriorityModuleNeededPerJob.clear();
highPriorityModuleNeeded.clear();
}
@@ -292,26 +327,19 @@ public class LastGenerationInfo {
routinesNeededWithSubjobPerJob.put(key, new HashSet<String>(modulesNeeded));
}
public void clearModulesNeededWithSubjobPerJob() {
if (!modulesNeededWithSubjobPerJob.isEmpty()) {
modulesNeededWithSubjobPerJob.clear();
}
}
/**
* Clear modules per job cache, not thread safe
*/
public void clearModulesNeededPerJob() {
if (!modulesNeededPerJob.isEmpty()) {
modulesNeededPerJob.clear();
}
public void clearCaches() {
clearHighPriorityModuleNeeded();
modulesNeededPerJob.clear();
modulesNeededWithSubjobPerJob.clear();
testcaseModuleNeeded.clear();
}
public void clean() {
modulesNeededPerJob.clear();
routinesNeededPerJob.clear();
modulesNeededWithSubjobPerJob.clear();
highPriorityModuleNeeded.clear();
clearHighPriorityModuleNeeded();
testcaseModuleNeeded.clear();
routinesNeededWithSubjobPerJob.clear();
contextPerJob.clear();

View File

@@ -64,7 +64,10 @@ public interface TalendProcessOptionConstants {
public static final int MODULES_WITH_INDEPENDENT = 1 << 2;
// include joblet module but without joblet's dependencies
/**
* @Deprecated will get all modules of node inside joblet recursively, use {@link #MODULES_DEFAULT} instead.
*/
@Deprecated
public static final int MODULES_WITH_JOBLET = 1 << 3;
public static final int MODULES_FOR_MR = 1 << 4;

View File

@@ -64,4 +64,8 @@ public interface IGenericDBService extends IService{
public ERepositoryObjectType getExtraDBType(ERepositoryObjectType type);
public void updateCompPropertiesForContextMode(Connection connection, Map<String, String> contextVarMap);
public List<ERepositoryObjectType> getAllGenericMetadataDBRepositoryType();
}

View File

@@ -18,7 +18,6 @@ import java.util.Set;
import org.apache.log4j.Level;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -26,6 +25,7 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.IService;
import org.talend.core.language.ECodeLanguage;
import org.talend.core.language.ICodeProblemsChecker;
@@ -244,4 +244,13 @@ public interface IRunProcessService extends IService {
public IFolder getJavaProjectExternalResourcesFolder(IProcess process);
public boolean isCIMode();
public static IRunProcessService get() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
return GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
}
return null;
}
}

View File

@@ -21,6 +21,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -91,11 +92,14 @@ public final class ProjectManager {
private Set<Object> updatedRemoteHandlerRecords;
private Set<Project> tempProjects;
private ProjectManager() {
beforeLogonRecords = new HashSet<String>();
logonRecords = new HashSet<String>();
migrationRecords = new HashSet<String>();
updatedRemoteHandlerRecords = new HashSet<Object>();
tempProjects = new HashSet<>();
initCurrentProject();
}
@@ -106,6 +110,18 @@ public final class ProjectManager {
return singleton;
}
public void clearTempProjects() {
tempProjects.clear();
}
public boolean removeTempProject(Project project) {
return tempProjects.remove(project);
}
public boolean addTempProject(Project project) {
return tempProjects.add(project);
}
public Project getProjectFromProjectLabel(String label) {
if (currentProject == null) {
initCurrentProject();
@@ -119,6 +135,12 @@ public final class ProjectManager {
return project;
}
}
for (Project project : tempProjects) {
if (StringUtils.equals(project.getLabel(), label)) {
return project;
}
}
return null;
}
@@ -136,6 +158,11 @@ public final class ProjectManager {
return project;
}
}
for (Project project : tempProjects) {
if (StringUtils.equals(project.getTechnicalLabel(), label)) {
return project;
}
}
return null;
}

View File

@@ -30,6 +30,7 @@ public enum ERepositoryActionName {
DELETE_TO_RECYCLE_BIN("delete to recycle bin"), //$NON-NLS-1$
DELETE_FOREVER("delete forever"), //$NON-NLS-1$
AFTER_DELETE("after delete"), //$NON-NLS-1$
// these actions bellow are only for jobs and joblet actually, need to review.

View File

@@ -33,6 +33,8 @@ public class RepositoryConstants {
public static final String PROJECT_BRANCH_ID = "repository.project.branch"; //$NON-NLS-1$
public static final String PROJECT_ID = "repository.project.id";
public static final String IMG_DIRECTORY = "images"; //$NON-NLS-1$
public static final String IMG_DIRECTORY_OF_JOB_OUTLINE = "images/job_outlines"; //$NON-NLS-1$

View File

@@ -12,6 +12,7 @@
// ============================================================================
package org.talend.core.ui.token;
import org.apache.commons.codec.digest.DigestUtils;
import org.eclipse.jface.preference.IPreferenceStore;
import org.talend.commons.utils.VersionUtils;
import org.talend.core.GlobalServiceRegister;
@@ -49,7 +50,11 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
public static String calcUniqueId() {
return TokenGenerator.generateMachineToken((src) -> StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(src));
}
public static String hashUniqueId() {
return TokenGenerator.generateMachineToken((src) -> DigestUtils.sha256Hex(src));
}
/*
* (non-Javadoc)
*
@@ -61,7 +66,7 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
// version
tokenStudioObject.put(VERSION.getKey(), VersionUtils.getInternalVersion());
// uniqueId
tokenStudioObject.put(UNIQUE_ID.getKey(), calcUniqueId());
tokenStudioObject.put(UNIQUE_ID.getKey(), hashUniqueId());
// typeStudio
if (GlobalServiceRegister.getDefault().isServiceRegistered(IBrandingService.class)) {

View File

@@ -77,5 +77,7 @@ public interface ICoreTisService extends IService {
Map<String, String> getDropBundleInfo() throws IOException;
Set<String> getComponentBlackList();
public String getLatestInstalledVersion();
}

View File

@@ -565,8 +565,10 @@ public class ProcessorUtilities {
neededLibraries);
// get all job testcases needed modules
neededLibraries.addAll(getAllJobTestcaseModules(selectedProcessItem));
Set<ModuleNeeded> testcaseModules = getAllJobTestcaseModules(selectedProcessItem);
LastGenerationInfo.getInstance().setTestcaseModuleNeeded(jobInfo.getJobId(), jobInfo.getJobVersion(),
testcaseModules);
neededLibraries.addAll(testcaseModules);
// must install the needed libraries before generate codes with poms.
CorePlugin.getDefault().getRunProcessService().updateLibraries(neededLibraries, currentProcess,
retrievedJarsForCurrentBuild);
@@ -1246,7 +1248,10 @@ public class ProcessorUtilities {
neededLibraries);
// get all job testcases needed modules
neededLibraries.addAll(getAllJobTestcaseModules(selectedProcessItem));
Set<ModuleNeeded> testcaseModules = getAllJobTestcaseModules(selectedProcessItem);
LastGenerationInfo.getInstance().setTestcaseModuleNeeded(jobInfo.getJobId(), jobInfo.getJobVersion(),
testcaseModules);
neededLibraries.addAll(testcaseModules);
// must install the needed libraries before generate codes with poms.
CorePlugin.getDefault().getRunProcessService().updateLibraries(neededLibraries, currentProcess,
@@ -2850,6 +2855,10 @@ public class ProcessorUtilities {
return jarFilePath;
}
public static boolean isCIMode() {
return isCIMode;
}
public static void setCIMode(boolean isCIMode) {
ProcessorUtilities.isCIMode = isCIMode;
}

View File

@@ -25,7 +25,7 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.providers.file.FileWagon;
import org.apache.maven.wagon.providers.http.HttpWagon;
import org.apache.maven.wagon.providers.http.LightweightHttpWagon;
import org.apache.maven.wagon.providers.http.LightweightHttpWagonAuthenticator;
import org.apache.maven.wagon.providers.http.LightweightHttpsWagon;
import org.codehaus.plexus.DefaultPlexusContainer;
@@ -238,9 +238,13 @@ public class MavenLibraryResolverProvider {
LightweightHttpsWagon https = new LightweightHttpsWagon();
https.setAuthenticator(new LightweightHttpWagonAuthenticator());
https.setPreemptiveAuthentication(true);
LightweightHttpWagon http = new LightweightHttpWagon();
http.setAuthenticator(new LightweightHttpWagonAuthenticator());
http.setPreemptiveAuthentication(true);
pc.addComponent(https, Wagon.class, "https");
pc.addComponent(new HttpWagon(), Wagon.class, "http");
pc.addComponent(http, Wagon.class, "http");
pc.addComponent(new FileWagon(), Wagon.class, "file");
WagonTransporterFactory tf = (WagonTransporterFactory) locator.getService(TransporterFactory.class);

View File

@@ -13,7 +13,7 @@
package org.talend.designer.maven.tools;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -24,16 +24,19 @@ import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Model;
import org.eclipse.core.runtime.IProgressMonitor;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.ILibraryManagerService;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.process.IProcess2;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.runtime.process.LastGenerationInfo;
import org.talend.core.runtime.process.TalendProcessOptionConstants;
import org.talend.core.ui.ITestContainerProviderService;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.maven.utils.SortableDependency;
import org.talend.designer.runprocess.IProcessor;
import org.talend.designer.runprocess.ProcessorException;
@@ -45,54 +48,71 @@ public class ProcessorDependenciesManager {
private final IProcessor processor;
private final Property property;
public ProcessorDependenciesManager(IProcessor processor) {
this.processor = processor;
property = processor.getProperty();
}
/**
* Will add the dependencies to the maven model.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public boolean updateDependencies(IProgressMonitor progressMonitor, Model model) throws ProcessorException {
try {
List neededDependencies = new ArrayList<Dependency>();
Set<ModuleNeeded> neededLibraries = getAllModuleNeededWithTestCase();
Set<String> uniquDependenciesSet = new HashSet<>();
for (ModuleNeeded module : neededLibraries) {
Dependency dependency = null;
// if (module.getDeployStatus() == ELibraryInstallStatus.DEPLOYED) {
// }
final String mavenUri = module.getMavenUri();
if (uniquDependenciesSet.contains(mavenUri)) {
continue; // must be same GAV, avoid the different other attrs for modules
}
uniquDependenciesSet.add(mavenUri);
dependency = PomUtil.createModuleDependency(mavenUri);
if (dependency != null) {
if (module.isExcludeDependencies()) {
Exclusion exclusion = new Exclusion();
exclusion.setGroupId("*"); //$NON-NLS-1$
exclusion.setArtifactId("*"); //$NON-NLS-1$
dependency.addExclusion(exclusion);
}
neededDependencies.add(dependency);
Set<ModuleNeeded> neededLibraries = new HashSet<>();
Set<String> uniqueDependencies = new HashSet<>();
Set<ModuleNeeded> jobModules = getProcessNeededModules();
Set<ModuleNeeded> testcaseModules = getTestcaseNeededModules(property);
neededLibraries.addAll(jobModules);
neededLibraries.addAll(testcaseModules);
if (!neededLibraries.isEmpty()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
ILibraryManagerService repositoryBundleService = GlobalServiceRegister.getDefault()
.getService(ILibraryManagerService.class);
repositoryBundleService.installModules(neededLibraries, null);
}
}
java.util.Collections.sort(neededDependencies);
List neededDependencies = new ArrayList<>();
neededDependencies.addAll(convertToDependency(jobModules, uniqueDependencies, false));
neededDependencies.addAll(convertToDependency(testcaseModules, uniqueDependencies, true));
Collections.sort(neededDependencies);
boolean fresh = false;
if (processor.getProperty() != null && processor.getProperty().getItem() != null
&& processor.getProcess() instanceof IProcess2) {
if (property != null && property.getItem() != null && processor.getProcess() instanceof IProcess2) {
// is standard job.
fresh = true;
}
return updateDependencies(progressMonitor, model, neededDependencies, fresh);
} catch (Exception e) {
throw new ProcessorException(e);
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private List convertToDependency(Set<ModuleNeeded> neededLibraries, Set<String> uniqueDependencies, boolean optional) {
List neededDependencies = new ArrayList<>();
for (ModuleNeeded module : neededLibraries) {
final String mavenUri = module.getMavenUri();
if (uniqueDependencies.contains(mavenUri)) {
continue; // must be same GAV, avoid the different other attrs for modules
}
uniqueDependencies.add(mavenUri);
Dependency dependency = PomUtil.createModuleDependency(mavenUri);
if (dependency != null) {
((SortableDependency) dependency).setAssemblyOptional(optional);
if (module.isExcludeDependencies()) {
Exclusion exclusion = new Exclusion();
exclusion.setGroupId("*"); //$NON-NLS-1$
exclusion.setArtifactId("*"); //$NON-NLS-1$
dependency.addExclusion(exclusion);
}
neededDependencies.add(dependency);
}
}
return neededDependencies;
}
/**
*
* DOC ggu Comment method "updateDependencies". add the job Needed Libraries for current model.
@@ -159,35 +179,35 @@ public class ProcessorDependenciesManager {
return changed;
}
private Set<ModuleNeeded> getAllModuleNeededWithTestCase() throws PersistenceException {
// add the job modules.
Set<ModuleNeeded> neededLibraries = new HashSet<>();
Collection<ModuleNeeded> modulesNeeded = LastGenerationInfo.getInstance()
private Set<ModuleNeeded> getProcessNeededModules() {
Set<ModuleNeeded> neededLibraries = LastGenerationInfo.getInstance()
.getModulesNeededPerJob(processor.getProcess().getId(), processor.getProcess().getVersion());
if (modulesNeeded.isEmpty()) {
modulesNeeded = processor.getNeededModules(TalendProcessOptionConstants.MODULES_WITH_JOBLET);
}
neededLibraries.addAll(modulesNeeded);
// add testcase modules
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testcontainerService = (ITestContainerProviderService) GlobalServiceRegister
.getDefault().getService(ITestContainerProviderService.class);
Set<ModuleNeeded> testcaseModules = null;
if (processor.getProperty() != null && processor.getProperty().getItem() instanceof ProcessItem) {
ProcessItem item = (ProcessItem) processor.getProperty().getItem();
testcaseModules = testcontainerService.getAllJobTestcaseModules(item);
neededLibraries.addAll(testcaseModules);
if (testcaseModules != null) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
ILibraryManagerService repositoryBundleService = (ILibraryManagerService) GlobalServiceRegister
.getDefault().getService(ILibraryManagerService.class);
repositoryBundleService.installModules(neededLibraries, null);
}
}
}
if (neededLibraries.isEmpty()) {
neededLibraries = processor.getNeededModules(TalendProcessOptionConstants.MODULES_DEFAULT);
}
return neededLibraries;
}
public static Set<ModuleNeeded> getTestcaseNeededModules(Property property) {
if (property == null || !(property.getItem() instanceof ProcessItem)) {
return Collections.emptySet();
}
Set<ModuleNeeded> testcaseModules = LastGenerationInfo.getInstance().getTestcaseModuleNeeded(property.getId(),
property.getVersion());
if (testcaseModules.isEmpty()) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testcontainerService = GlobalServiceRegister.getDefault()
.getService(ITestContainerProviderService.class);
try {
testcaseModules = testcontainerService.getAllJobTestcaseModules((ProcessItem) property.getItem());
LastGenerationInfo.getInstance().setTestcaseModuleNeeded(property.getId(), property.getVersion(),
testcaseModules);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
return testcaseModules;
}
}

View File

@@ -206,6 +206,17 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
// Xpp3Dom minimizeJar = new Xpp3Dom("minimizeJar"); //$NON-NLS-1$
// minimizeJar.setValue("true"); //$NON-NLS-1$
// configuration.addChild(minimizeJar);
// TDQ-18049 when shaded,avoid to conflict the same name class from different jars. e.g,"ImagePreloader"
// in "fop-2.3.jar/META-INF/services/" and "xmlgraphics-commons-2.3.jar"
Xpp3Dom transforms = new Xpp3Dom("transformers"); //$NON-NLS-1$
Xpp3Dom transform = new Xpp3Dom("transform");
transform
.setAttribute("implementation",
"org.apache.maven.plugins.shade.resource.ServicesResourceTransformer");
transforms.addChild(transform);
configuration.addChild(transforms);
Xpp3Dom artifactSet = new Xpp3Dom("artifactSet"); //$NON-NLS-1$
configuration.addChild(artifactSet);
Xpp3Dom excludes = new Xpp3Dom("excludes"); //$NON-NLS-1$

View File

@@ -18,18 +18,22 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.model.Activation;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
@@ -57,11 +61,10 @@ import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Project;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.repository.utils.ItemResourceUtil;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.runtime.process.JobInfoProperties;
import org.talend.core.runtime.process.LastGenerationInfo;
@@ -75,6 +78,7 @@ import org.talend.core.utils.TemplateFileUtils;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.template.ETalendMavenVariables;
import org.talend.designer.maven.template.MavenTemplateManager;
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
import org.talend.designer.maven.utils.PomIdsHelper;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.maven.utils.SortableDependency;
@@ -620,139 +624,107 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
}
protected void updateDependencySet(IFile assemblyFile) {
Map<String, Dependency> jobCoordinateMap = new HashMap<String, Dependency>();
Set<JobInfo> childrenJobInfo = new HashSet<>();
if (!hasLoopDependency()) {
childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
}
// add children jobs
for (JobInfo jobInfo : childrenJobInfo) {
Property property = jobInfo.getProcessItem().getProperty();
String coordinate =
getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property));
Dependency dependency = getDependencyObject(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo), PomIdsHelper.getJobVersion(property),
MavenConstants.PACKAGING_JAR, null);
jobCoordinateMap.put(coordinate, dependency);
}
// add parent job
Property parentProperty = this.getJobProcessor().getProperty();
String parentCoordinate =
getCoordinate(PomIdsHelper.getJobGroupId(parentProperty), PomIdsHelper.getJobArtifactId(parentProperty),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(parentProperty));
Dependency parentDependency = getDependencyObject(PomIdsHelper.getJobGroupId(parentProperty), PomIdsHelper.getJobArtifactId(parentProperty), PomIdsHelper.getJobVersion(parentProperty),
MavenConstants.PACKAGING_JAR, null);
jobCoordinateMap.put(parentCoordinate, parentDependency);
// add talend libraries and codes
Map<String, Dependency> talendLibCoordinateMap = new HashMap<String, Dependency>();
String projectTechName = ProjectManager.getInstance().getProject(parentProperty).getTechnicalLabel();
String projectGroupId = PomIdsHelper.getProjectGroupId(projectTechName);
// codes
List<Dependency> dependencies = new ArrayList<>();
addCodesDependencies(dependencies);
for (Dependency dependency : dependencies) {
talendLibCoordinateMap.put(getCoordinate(dependency), dependency);
}
// libraries
dependencies.clear();
Set<ModuleNeeded> modules = getJobProcessor()
.getNeededModules(TalendProcessOptionConstants.MODULES_WITH_JOBLET
| TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED);
for (ModuleNeeded module : modules) {
String mavenUri = module.getMavenUri();
Dependency dependency = PomUtil.createModuleDependency(mavenUri);
dependencies.add(dependency);
}
for (Dependency dependency : dependencies) {
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
continue;
}
String dependencyGroupId = dependency.getGroupId();
String coordinate = getCoordinate(dependency);
if (!jobCoordinateMap.containsKey(coordinate)) {
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(dependencyGroupId)) {
talendLibCoordinateMap.put(coordinate, dependency);
}
}
}
// add 3rd party libraries
Map<String, Dependency> _3rdDepLibMap = new HashMap<String, Dependency>();
Set<String> jobCoordinate = new HashSet<>();
Set<String> talendLibCoordinate = new HashSet<>();
Set<String> _3rdLibCoordinate = new HashSet<>();
Map<String, Set<Dependency>> duplicateLibs = new HashMap<>();
for (Dependency dependency : dependencies) {
if (MavenConstants.PACKAGING_POM.equals(dependency.getType())) {
continue;
}
String coordinate = getCoordinate(dependency);
if (!jobCoordinateMap.containsKey(coordinate) && !talendLibCoordinateMap.containsKey(coordinate)) {
_3rdDepLibMap.put(coordinate, dependency);
addToDuplicateLibs(duplicateLibs, dependency);
}
}
IProcessor processor = getJobProcessor();
// add missing modules from the job generation of children
Set<ModuleNeeded> fullModulesList = new HashSet<>();
for (JobInfo jobInfo : childrenJobInfo) {
fullModulesList
.addAll(LastGenerationInfo
.getInstance()
.getModulesNeededWithSubjobPerJob(jobInfo.getJobId(), jobInfo.getJobVersion()));
}
for (ModuleNeeded moduleNeeded : fullModulesList) {
if (moduleNeeded.isExcluded()) {
continue;
// current job
Property currentJobProperty = processor.getProperty();
jobCoordinate.add(getJobCoordinate(currentJobProperty));
// children jobs without test cases
Set<JobInfo> childrenJobInfo = !hasLoopDependency() ? processor.getBuildChildrenJobs().stream().filter(j -> !j.isTestContainer()).collect(Collectors.toSet()) : Collections.emptySet();
childrenJobInfo.forEach(j -> jobCoordinate.add(getJobCoordinate(j.getProcessItem().getProperty())));
// talend libraries and codes
String projectGroupId = PomIdsHelper.getProjectGroupId(ProjectManager.getInstance().getProject(currentJobProperty).getTechnicalLabel());
List<Dependency> dependencies = new ArrayList<>();
// codes
addCodesDependencies(dependencies);
// codes dependencies (optional)
ERepositoryObjectType.getAllTypesOfCodes().forEach(t -> dependencies.addAll(PomUtil.getCodesDependencies(t)));
// libraries of talend/3rd party
dependencies.addAll(processor.getNeededModules(TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED).stream()
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet()));
// missing modules from the job generation of children
childrenJobInfo.forEach(j -> dependencies
.addAll(LastGenerationInfo.getInstance().getModulesNeededPerJob(j.getJobId(), j.getJobVersion()).stream()
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet())));
Set<ModuleNeeded> modules = new HashSet<>();
// testcase modules from current job (optional)
modules.addAll(ProcessorDependenciesManager.getTestcaseNeededModules(currentJobProperty));
// testcase modules from children job (optional)
childrenJobInfo.forEach(
j -> modules.addAll(ProcessorDependenciesManager.getTestcaseNeededModules(j.getProcessItem().getProperty())));
dependencies.addAll(
modules.stream().filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, true)).collect(Collectors.toSet()));
dependencies.stream().filter(d -> !MavenConstants.PACKAGING_POM.equals(d.getType())).forEach(d -> {
String coordinate = getCoordinate(d);
String groupId = d.getGroupId();
boolean optional = ((SortableDependency) d).isAssemblyOptional();
if (jobCoordinate.contains(coordinate) || talendLibCoordinate.contains(coordinate)
|| _3rdLibCoordinate.contains(coordinate)) {
return;
}
MavenArtifact artifact = MavenUrlHelper.parseMvnUrl(moduleNeeded.getMavenUri());
String coordinate = getCoordinate(artifact.getGroupId(), artifact.getArtifactId(), artifact.getType(),
artifact.getVersion());
if (!jobCoordinateMap.containsKey(coordinate) && !talendLibCoordinateMap.containsKey(coordinate)
&& !_3rdDepLibMap.containsKey(coordinate)) {
Dependency dependencyObject = getDependencyObject(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier());
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(artifact.getGroupId())
|| artifact.getGroupId().startsWith(projectGroupId)) {
talendLibCoordinateMap.put(coordinate, dependencyObject);
} else {
_3rdDepLibMap.put(coordinate, dependencyObject);
Dependency dependency = PomUtil
.createDependency(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
artifact.getType(), artifact.getClassifier());
addToDuplicateLibs(duplicateLibs, dependency);
if (MavenConstants.DEFAULT_LIB_GROUP_ID.equals(groupId) || groupId.startsWith(projectGroupId)) {
if (!optional) {
talendLibCoordinate.add(coordinate);
}
} else {
if (!optional) {
_3rdLibCoordinate.add(coordinate);
}
addToDuplicateLibs(duplicateLibs, d);
}
}
});
Iterator<String> iterator = duplicateLibs.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
Set<Dependency> dupDependencies = duplicateLibs.get(key);
if (dupDependencies.size() < 2) {
// remove non-duplicated dependencies
Set<Dependency> dupDependencies = duplicateLibs.get(iterator.next());
if (dupDependencies.size() < 2 // remove unique dependency
/* || dupDependencies.stream().filter(d -> !((SortableDependency) d).isAssemblyOptional()).count() == 1 */) {
// remove when only one required dependencies, means others are from codes/testcase
// don't do this now at least it won't have problem in studio
// in some case, the needed jar is not in main job pom, maven will get the nearest one which could be
// wrong
iterator.remove();
} else {
// remove duplicated dependencies from 3rd lib list
for (Dependency dependency : dupDependencies) {
_3rdDepLibMap.remove(getCoordinate(dependency));
}
// remove duplicate dependencies from 3rd party libs
dupDependencies.stream().map(d -> getCoordinate(d)).forEach(c -> _3rdLibCoordinate.remove(c));
}
}
try {
Document document = PomUtil.loadAssemblyFile(null, assemblyFile);
// add talend libs & codes
setupDependencySetNode(document, talendLibCoordinateMap, "lib", "${artifact.artifactId}.${artifact.extension}",
setupDependencySetNode(document, talendLibCoordinate, "lib", "${artifact.artifactId}.${artifact.extension}", false,
false);
// add 3rd party libs: groupId:artifactId:type:version
setupDependencySetNode(document,
_3rdLibCoordinate.stream().filter(s -> s.split(":").length == 4).collect(Collectors.toSet()), "lib", null,
false, false);
// add 3rd party libs <dependencySet>
setupDependencySetNode(document, _3rdDepLibMap, "lib", null, false, false);
// add 3rd party libs with classifier: groupId:artifactId:type:classifier:version
setupDependencySetNode(document,
_3rdLibCoordinate.stream().filter(s -> s.split(":").length == 5).collect(Collectors.toSet()), "lib", null,
false, false);
// FIXME if later add classifier for org.talend.libraries libs, code and job artifact, need to handle it
// like 3rd libs as well
// add jobs
setupDependencySetNode(document, jobCoordinateMap, "${talend.job.name}",
setupDependencySetNode(document, jobCoordinate, "${talend.job.name}",
"${artifact.build.finalName}.${artifact.extension}", true, false);
// add duplicate dependencies if exists
setupFileNode(document, duplicateLibs);
setupFileNode(document, duplicateLibs.values().stream().flatMap(s -> s.stream()).collect(Collectors.toSet()));
PomUtil.saveAssemblyFile(assemblyFile, document);
} catch (Exception e) {
@@ -760,66 +732,92 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
}
}
// remove duplicate job dependencies and only keep the latest one
// keep high priority dependencies if set by tLibraryLoad
// FIXME not used now since tacokit component use specific dependency version. so we must include all job dependencies.
// but problem will remain for CI when need to download jars from nexus, maven will only resolve one of them.
private Set<Dependency> convertToDistinctedJobDependencies(String jobId, String jobVersion, Set<ModuleNeeded> neededModules) {
Set<Dependency> highPriorityDependencies = LastGenerationInfo.getInstance()
.getHighPriorityModuleNeededPerJob(jobId, jobVersion).stream().map(m -> createDenpendency(m, false))
.collect(Collectors.toSet());
Map<String, Dependency> highPriorityDependenciesMap = new HashMap<>();
highPriorityDependencies.forEach(d -> highPriorityDependenciesMap.putIfAbsent(getCheckDupCoordinate(d), d));
Set<Dependency> jobDependencies = neededModules.stream().filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet());
Map<String, Set<Dependency>> jobDependenciesMap = new HashMap<>();
jobDependencies.forEach(d -> {
String coordinate = getCheckDupCoordinate(d);
if (jobDependenciesMap.get(coordinate) == null) {
jobDependenciesMap.put(coordinate, new LinkedHashSet<>());
}
jobDependenciesMap.get(coordinate).add(d);
});
Set<Dependency> filteredDependencies = new HashSet<>();
jobDependenciesMap.forEach((key, value) -> {
Optional<Dependency> target = null;
if (highPriorityDependenciesMap.containsKey(key)) {
Dependency highPriorityDependency = highPriorityDependenciesMap.get(key);
target = value.stream().filter(d -> getCoordinate(highPriorityDependency).equals(getCoordinate(d))).findFirst();
} else {
target = value.stream().sorted(
(d1, d2) -> new ComparableVersion(d2.getVersion()).compareTo(new ComparableVersion(d1.getVersion())))
.findFirst();
}
if (target.isPresent()) {
filteredDependencies.add(target.get());
}
});
return filteredDependencies;
}
private Dependency createDenpendency(ModuleNeeded moduleNeeded, boolean optional) {
SortableDependency dependency = (SortableDependency) PomUtil.createModuleDependency(moduleNeeded.getMavenUri());
dependency.setAssemblyOptional(optional);
return dependency;
}
private String getCoordinate(Dependency dependency) {
return getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(),
dependency.getVersion());
dependency.getVersion(), dependency.getClassifier());
}
protected String getCoordinate(String groupId, String artifactId, String type, String version) {
String separator = ":"; //$NON-NLS-1$
String coordinate = groupId + separator;
coordinate += artifactId + separator;
if (type != null) {
coordinate += type;
}
private String getCheckDupCoordinate(Dependency dependency) {
return getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null,
dependency.getClassifier());
}
if (version != null) {
protected String getJobCoordinate(Property property) {
return getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(property),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property), null);
}
protected String getCoordinate(String groupId, String artifactId, String type, String version, String classifier) {
String separator = ":"; //$NON-NLS-1$
String coordinate = groupId + separator + artifactId;
if (StringUtils.isNotBlank(type)) {
coordinate += separator + type;
}
if (StringUtils.isNotBlank(classifier)) {
coordinate += separator + classifier;
}
if (StringUtils.isNotBlank(version)) {
coordinate += separator + version;
}
return coordinate;
}
protected String getAssemblyCoordinate(Dependency dependency) {
String separator = ":"; //$NON-NLS-1$
String coordinate = dependency.getGroupId() + separator;
coordinate += dependency.getArtifactId() + separator;
if (dependency.getType() != null) {
coordinate += dependency.getType();
}
if (dependency.getClassifier() != null) {
coordinate += separator + "*";
}
if (dependency.getVersion() != null) {
coordinate += separator + dependency.getVersion();
}
return coordinate;
}
protected Dependency getDependencyObject(String groupId, String artifactId, String version, String type, String classifier) {
Dependency object = new SortableDependency();
object.setGroupId(groupId);
object.setArtifactId(artifactId);
object.setVersion(version);
object.setType(type);
object.setClassifier(classifier);
return object;
}
private void addToDuplicateLibs(Map<String, Set<Dependency>> map, Dependency dependency) {
String coordinate =
getCoordinate(dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), null);
String coordinate = getCheckDupCoordinate(dependency);
if (!map.containsKey(coordinate)) {
Set<Dependency> set = new HashSet<>();
map.put(coordinate, set);
map.put(coordinate, new HashSet<>());
}
map.get(coordinate).add(dependency);
}
protected void setupDependencySetNode(Document document, Map<String, Dependency> libIncludes, String outputDir,
String fileNameMapping, boolean useProjectArtifact, boolean unpack) {
protected void setupDependencySetNode(Document document, Set<String> libIncludes, String outputDir, String fileNameMapping,
boolean useProjectArtifact, boolean unpack) {
if (libIncludes.isEmpty()) {
return;
}
@@ -839,9 +837,9 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
Node includesNode = document.createElement("includes");
dependencySetNode.appendChild(includesNode);
for (Dependency dependency : libIncludes.values()) {
for (String coodinate : libIncludes) {
Node includeNode = document.createElement("include");
includeNode.setTextContent(getAssemblyCoordinate(dependency));
includeNode.setTextContent(coodinate);
includesNode.appendChild(includeNode);
}
@@ -863,44 +861,40 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
}
private void setupFileNode(Document document, Map<String, Set<Dependency>> duplicateDependencies) {
private void setupFileNode(Document document, Set<Dependency> duplicateDependencies) throws CoreException {
Node filesNode = document.getElementsByTagName("files").item(0);
// TESB-27614:NPE while building a route
if (filesNode == null) {
return;
}
if (duplicateDependencies.isEmpty()) {
return;
}
try {
IMaven maven = MavenPlugin.getMaven();
ArtifactRepository repository = maven.getLocalRepository();
Node filesNode = document.getElementsByTagName("files").item(0);
// TESB-27614:NPE while building a route
if (filesNode != null) {
for (Entry<String, Set<Dependency>> entry : duplicateDependencies.entrySet()) {
Set<Dependency> dependencies = entry.getValue();
for (Dependency dependency : dependencies) {
String sourceLocation = maven
.getArtifactPath(repository, dependency.getGroupId(), dependency.getArtifactId(),
dependency.getVersion(), dependency.getType(), dependency.getClassifier());
Path path = new File(repository.getBasedir()).toPath().resolve(sourceLocation);
sourceLocation = path.toString();
String destName = path.getFileName().toString();
Node fileNode = document.createElement("file");
filesNode.appendChild(fileNode);
Node sourcesNode = document.createElement("source");
sourcesNode.setTextContent(sourceLocation);
fileNode.appendChild(sourcesNode);
Node outputDirNode = document.createElement("outputDirectory");
outputDirNode.setTextContent("lib");
fileNode.appendChild(outputDirNode);
Node destNameNode = document.createElement("destName");
destNameNode.setTextContent(destName);
fileNode.appendChild(destNameNode);
}
}
IMaven maven = MavenPlugin.getMaven();
ArtifactRepository repository = maven.getLocalRepository();
for (Dependency dependency : duplicateDependencies) {
if (((SortableDependency) dependency).isAssemblyOptional()) {
continue;
}
} catch (CoreException e) {
ExceptionHandler.process(e);
String sourceLocation = maven.getArtifactPath(repository, dependency.getGroupId(), dependency.getArtifactId(),
dependency.getVersion(), dependency.getType(), dependency.getClassifier());
Path path = new File(repository.getBasedir()).toPath().resolve(sourceLocation);
sourceLocation = path.toString();
String destName = path.getFileName().toString();
Node fileNode = document.createElement("file");
filesNode.appendChild(fileNode);
Node sourcesNode = document.createElement("source");
sourcesNode.setTextContent(sourceLocation);
fileNode.appendChild(sourcesNode);
Node outputDirNode = document.createElement("outputDirectory");
outputDirNode.setTextContent("lib");
fileNode.appendChild(outputDirNode);
Node destNameNode = document.createElement("destName");
destNameNode.setTextContent(destName);
fileNode.appendChild(destNameNode);
}
}

View File

@@ -17,16 +17,14 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.Profile;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -45,7 +43,6 @@ import org.talend.core.model.relationship.RelationshipItemBuilder;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.process.ITalendProcessJavaProject;
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
import org.talend.core.runtime.process.TalendProcessOptionConstants;
@@ -54,7 +51,6 @@ import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.template.MavenTemplateManager;
import org.talend.designer.maven.tools.AggregatorPomsHelper;
import org.talend.designer.maven.utils.PomIdsHelper;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.runprocess.IProcessor;
import org.talend.repository.model.IProxyRepositoryFactory;
@@ -190,31 +186,22 @@ public class CreateMavenStandardJobOSGiPom extends CreateMavenJobPom {
@Override
protected void updateDependencySet(IFile assemblyFile) {
Map<String, Dependency> jobCoordinateMap = new HashMap<String, Dependency>();
Set<String> jobCoordinate = new HashSet<>();
if (!hasLoopDependency()) {
// add children jobs
Set<JobInfo> childrenJobInfo = getJobProcessor().getBuildChildrenJobs();
for (JobInfo jobInfo : childrenJobInfo) {
Property property = jobInfo.getProcessItem().getProperty();
String coordinate = getCoordinate(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo),
MavenConstants.PACKAGING_JAR, PomIdsHelper.getJobVersion(property));
Dependency dependency = getDependencyObject(PomIdsHelper.getJobGroupId(property), PomIdsHelper.getJobArtifactId(jobInfo), PomIdsHelper.getJobVersion(property),
MavenConstants.PACKAGING_JAR, null);
jobCoordinateMap.put(coordinate, dependency);
jobCoordinate.add(getJobCoordinate(jobInfo.getProcessItem().getProperty()));
}
}
// add parent job
Property parentProperty = this.getJobProcessor().getProperty();
String parentCoordinate = getCoordinate(PomIdsHelper.getJobGroupId(parentProperty),
PomIdsHelper.getJobArtifactId(parentProperty), MavenConstants.PACKAGING_JAR,
PomIdsHelper.getJobVersion(parentProperty));
Dependency parentDependency = getDependencyObject(PomIdsHelper.getJobGroupId(parentProperty), PomIdsHelper.getJobArtifactId(parentProperty), PomIdsHelper.getJobVersion(parentProperty),
MavenConstants.PACKAGING_JAR, null);
jobCoordinateMap.put(parentCoordinate, parentDependency);
// add current job
Property currentJobProperty = getJobProcessor().getProperty();
String parentCoordinate = getJobCoordinate(currentJobProperty);
jobCoordinate.add(parentCoordinate);
try {
Document document = PomUtil.loadAssemblyFile(null, assemblyFile);
// add jobs
setupDependencySetNode(document, jobCoordinateMap, null, "${artifact.build.finalName}.${artifact.extension}", true,
setupDependencySetNode(document, jobCoordinate, null, "${artifact.build.finalName}.${artifact.extension}", true,
true);
PomUtil.saveAssemblyFile(assemblyFile, document);
} catch (Exception e) {

View File

@@ -34,6 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Collectors;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -81,6 +82,7 @@ import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.relationship.Relation;
import org.talend.core.model.relationship.RelationshipItemBuilder;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.nexus.TalendMavenResolver;
@@ -96,6 +98,7 @@ import org.talend.designer.maven.template.MavenTemplateManager;
import org.talend.designer.maven.tools.AggregatorPomsHelper;
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
import org.talend.designer.runprocess.IProcessor;
import org.talend.designer.runprocess.IRunProcessService;
import org.talend.repository.ProjectManager;
import org.talend.utils.xml.XmlUtils;
import org.w3c.dom.Attr;
@@ -1133,4 +1136,20 @@ public class PomUtil {
}
return found;
}
public static Set<Dependency> getCodesDependencies(ERepositoryObjectType codeType) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService runProcessService = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
try {
Model model = MODEL_MANAGER.readMavenModel(runProcessService.getTalendCodeJavaProject(codeType).getProjectPom());
return model.getDependencies().stream().map(
d -> createDependency(d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getType(), d.getClassifier()))
.peek(d -> ((SortableDependency) d).setAssemblyOptional(true)).collect(Collectors.toSet());
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
return Collections.emptySet();
}
}

View File

@@ -1,13 +1,80 @@
package org.talend.designer.maven.utils;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.apache.maven.model.Dependency;
public class SortableDependency extends Dependency implements Comparable<SortableDependency> {
private static final long serialVersionUID = -6295226523517981508L;
/**
* dependencies in testcase/routines/beans no need to be assembled in final zip.
*/
private boolean isAssemblyOptional;
@Override
public int compareTo(SortableDependency o) {
int compare = getArtifactId().compareTo(o.getArtifactId());
if (compare == 0) {
// FIXME according to Maven official Doc for dependencies:
// https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
// when pom has duplicate version of dependencies, Maven should take the first one
// but in practice(maven 3.5.3 embedded), it always take the last one
// we only need job dependencies in final job zip rather than testcase's
// so we always put the latest job dependency at the bottom
// if maven fix it in future, we need to reverse the order as well.
if (isAssemblyOptional && !o.isAssemblyOptional) {
return -1;
}
if (!isAssemblyOptional && o.isAssemblyOptional) {
return 1;
}
return new ComparableVersion(getVersion()).compareTo(new ComparableVersion(o.getVersion()));
}
return compare;
}
return getArtifactId().compareTo(o.getArtifactId());
public boolean isAssemblyOptional() {
return isAssemblyOptional;
}
public void setAssemblyOptional(boolean isAssemblyOptional) {
this.isAssemblyOptional = isAssemblyOptional;
}
@Override
public int hashCode() {
int result = 17;
result = 31 * result + (getGroupId() == null ? 0 : getGroupId().hashCode());
result = 31 * result + (getArtifactId() == null ? 0 : getArtifactId().hashCode());
result = 31 * result + (getVersion() == null ? 0 : getVersion().hashCode());
result = 31 * result + (getType() == null ? 0 : getType().hashCode());
result = 31 * result + (getClassifier() == null ? 0 : getClassifier().hashCode());
result = 31 * result + (isAssemblyOptional() ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SortableDependency)) {
return false;
}
SortableDependency caseobj = (SortableDependency) obj;
return (getGroupId() == caseobj.getGroupId() || (getGroupId() != null && getGroupId().equals(caseobj.getGroupId())))
&& (getArtifactId() == caseobj.getArtifactId()
|| (getArtifactId() != null && getArtifactId().equals(caseobj.getArtifactId())))
&& (getVersion() == caseobj.getVersion() || (getVersion() != null && getVersion().equals(caseobj.getVersion())))
&& (getType() == caseobj.getType() || (getType() != null && getType().equals(caseobj.getType())))
&& (getClassifier() == caseobj.getClassifier()
|| (getClassifier() != null && getClassifier().equals(caseobj.getClassifier())))
&& (isAssemblyOptional() == caseobj.isAssemblyOptional());
}
}

View File

@@ -85,6 +85,7 @@ import org.talend.core.model.general.ILibrariesService;
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
import org.talend.core.model.general.ModuleStatusProvider;
import org.talend.core.model.general.ModuleToInstall;
import org.talend.core.nexus.TalendLibsServerManager;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.designer.core.IDesignerCoreService;
import org.talend.librariesmanager.ui.LibManagerUiPlugin;
@@ -147,7 +148,8 @@ public class ExternalModulesInstallDialog extends TitleAreaDialog implements IMo
}
private void checkNetworkStatus() {
boolean networkValid = NetworkUtil.isNetworkValid(System.getProperty("nexus.proxy.url"));
boolean networkValid = NetworkUtil
.isNetworkValid(TalendLibsServerManager.getInstance().getTalentArtifactServer().getServer());
if (!networkValid) {
setErrorMessage(Messages.getString("ExternalModulesInstallDialog.networkUnavailable.msg")); //$NON-NLS-1$
}

View File

@@ -148,7 +148,8 @@ public class RemoteModulesHelper {
Set<String> unavailableModules = new HashSet<String>();
// if the network is not valid, all jars are not available.
boolean networkValid = NetworkUtil.isNetworkValid(System.getProperty("nexus.proxy.url"));
boolean networkValid = NetworkUtil
.isNetworkValid(TalendLibsServerManager.getInstance().getTalentArtifactServer().getServer());
if (!networkValid) {
if (!alreadyWarnedAboutConnectionIssue) {
log.warn("failed to connect to internet");

View File

@@ -14,7 +14,6 @@ package routines.system;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.HashMap;
import java.util.List;
import org.dom4j.Element;
@@ -110,26 +109,31 @@ public class GetJarsToRegister {
private String addLibsPath(String line, java.util.Map<String, String> crcMap) {
for (java.util.Map.Entry<String, String> entry : crcMap.entrySet()) {
line = adaptLibPaths(line, entry);
if (new java.io.File(line).exists()) {
break;
}
}
return line;
}
private String adaptLibPaths(String line, java.util.Map.Entry<String, String> entry) {
line = line.replace("\\", "/");
String jarName = entry.getValue();
String crc = entry.getKey();
String libStringFinder = "../lib/" + jarName;
String libStringFinder2 = "./" + jarName; // for the job jar itself.
String replacement = "../../../cache/lib/" + crc + "/" + jarName;
if (line.contains(libStringFinder)) {
line = line.replace(libStringFinder, "../../../cache/lib/" + crc + "/" + jarName);
line = line.replace(libStringFinder, replacement);
} else if (line.toLowerCase().contains(libStringFinder2)) {
line = line.toLowerCase().replace(libStringFinder2, "../../../cache/lib/" + crc + "/" + jarName);
line = line.toLowerCase().replace(libStringFinder2, replacement);
} else if (line.toLowerCase().equals(jarName)) {
line = "../../../cache/lib/" + crc + "/" + jarName;
line = replacement;
} else if (line.contains(":$ROOT_PATH/" + jarName + ":")) {
line = line.replace(":$ROOT_PATH/" + jarName + ":", ":$ROOT_PATH/../../../cache/lib/" + crc + "/" + jarName + ":");
line = line.replace(":$ROOT_PATH/" + jarName + ":", ":$ROOT_PATH/" + replacement + ":");
} else if (line.contains(";" + jarName + ";")) {
line = line.replace(";" + jarName + ";", ";../../../cache/lib/" + crc + "/" + jarName + ";");
line = line.replace(";" + jarName + ";", ";" + replacement + ";");
}
return line;
}

View File

@@ -58,11 +58,22 @@ public class JDBCUtil {
}
public static Date getDate(ResultSet rs, int index) throws java.sql.SQLException {
if(rs.getTimestamp(index) != null) {
return new Date(rs.getTimestamp(index).getTime());
Date result = null;
try {
if(rs.getTimestamp(index) != null) {
result = new Date(rs.getTimestamp(index).getTime());
return result;
}
} catch (java.sql.SQLException e) {
}
return null;
try {
if(rs.getDate(index) != null) {
result = new Date(rs.getDate(index).getTime());
return result;
}
} catch (java.sql.SQLException e) {
}
return result;
}
//decrease the get method call number

View File

@@ -685,17 +685,20 @@ public final class ConnectionContextHelper {
// get the context variables from the node parameters.
Set<String> neededVars = retrieveContextVar(elementParameters, connection, category);
boolean isGeneric = isGenericConnection(connection);
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
if (neededVars != null && !neededVars.isEmpty() || isGeneric) {
ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
if (contextItem != null) {
// find added variables
neededVars.removeAll(renamedMap.keySet());
neededVars.addAll(renamedMap.values());
Set<String> tempVars = null;
if(isGeneric){
tempVars = checkAndAddContextVariables(contextItem, process.getContextManager(),
false);
false, renamedMap);
}else{
tempVars = checkAndAddContextVariables(contextItem, neededVars, process.getContextManager(),
false);
false, renamedMap);
}
Set<String> addedVars = tempVars;
@@ -785,17 +788,19 @@ public final class ConnectionContextHelper {
List<ContextItem> contextItems = new ArrayList<>();
if (contextItem != null || hadoopClusterContextItem != null) {
Map<String, String> renamedMap = ContextUtils
.getContextParamterRenamedMap(process.getProperty().getItem());
// find added variables
Set<String> connAddedVars = null;
Set<String> hcAddedVars = null;
if (contextItem != null) {
connAddedVars = checkAndAddContextVariables(contextItem, neededVars, process.getContextManager(),
false);
false, renamedMap);
contextItems.add(contextItem);
}
if (hadoopClusterContextItem != null) {
hcAddedVars = checkAndAddContextVariables(hadoopClusterContextItem, hcNeededVars,
process.getContextManager(), false);
process.getContextManager(), false, renamedMap);
contextItems.add(hadoopClusterContextItem);
}
@@ -846,7 +851,9 @@ public final class ConnectionContextHelper {
private static void addContextVarsToExistVariable(IProcess2 process, ContextItem contextItem, Set<String> addedVars,
IContextManager contextMgr) {
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, addedVars, contextMgr, false);
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, addedVars, contextMgr, false,
renamedMap);
if (addedContext != null && addedContext.size() > 0) {
ConnectionContextHelper.addContextVarForJob(process, contextItem, addedVars);
}
@@ -904,8 +911,9 @@ public final class ConnectionContextHelper {
ShowAddedContextdialog showDialog = new ShowAddedContextdialog(addedVarsMap, true);
if (showDialog.open() == Window.OK) {
if (ConnectionContextHelper.containsVariable(contextManager)) {
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, addedVars,
contextManager, false);
contextManager, false, renamedMap);
if (addedContext != null && addedContext.size() > 0) {
ConnectionContextHelper.addContextVarForJob(process, contextItem, addedVars);
}
@@ -967,6 +975,7 @@ public final class ConnectionContextHelper {
//
if (!varsMap.isEmpty()) {
Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
for (String id : varsMap.keySet()) {
ConnectionItem connItem = UpdateRepositoryUtils.getConnectionItemByItemId(id);
if (connItem != null) {
@@ -974,7 +983,7 @@ public final class ConnectionContextHelper {
if (contextItem != null) {
// add needed vars into job
Set<String> addedVars = checkAndAddContextVariables(contextItem, varsMap.get(id),
process.getContextManager(), false);
process.getContextManager(), false, renamedMap);
if (addedVars != null && !addedVars.isEmpty()) {
String source = UpdateRepositoryUtils.getRepositorySourceName(connItem);
addedVarsMap.put(source, addedVars);
@@ -1065,6 +1074,7 @@ public final class ConnectionContextHelper {
}
}
public static Set<String> retrieveContextVar(List<? extends IElementParameter> elementParameters, Connection connection,
EComponentCategory category) {
return retrieveContextVar(elementParameters, connection, category, false, new HashMap<Object, Object>());
@@ -1567,20 +1577,6 @@ public final class ConnectionContextHelper {
}
/**
* add the context from contextItem into the ctxManager: add the variables and the context groups.
*
* @param contextItem
* @param ctxManager
* @param addedVars the variables need to adding
* @param contextGoupNameSet the context group need to adding
*/
public static void checkAndAddContextVariables(ContextItem contextItem, IContextManager ctxManager, Set<String> addedVars,
Set<String> contextGoupNameSet) {
mergeContextVariables(contextItem.getContext(), contextItem.getDefaultContext(), contextItem.getProperty().getId(),
ctxManager, addedVars, contextGoupNameSet, false);
}
/**
* add the variables from ctxParams into JobContext.
*
@@ -1630,13 +1626,13 @@ public final class ConnectionContextHelper {
* ggu Comment method "checkAndAddContextVariables".
*/
public static Set<String> checkAndAddContextVariables(final ContextItem contextItem, final Set<String> neededVars,
final IContextManager ctxManager, boolean added) {
final IContextManager ctxManager, boolean added, Map<String, String> renamedMap) {
return checkAndAddContextVariables(contextItem.getContext(), contextItem.getDefaultContext(), contextItem.getProperty()
.getId(), neededVars, ctxManager, added);
.getId(), neededVars, ctxManager, added, renamedMap);
}
public static Set<String> checkAndAddContextVariables(final ContextItem contextItem,
final IContextManager ctxManager, boolean added) {
final IContextManager ctxManager, boolean added, Map<String, String> renamedMap) {
List<ContextType> contexts = contextItem.getContext();
String defaultContextName = contextItem.getDefaultContext();
String contextItemId = contextItem.getProperty().getId();
@@ -1645,9 +1641,17 @@ public final class ConnectionContextHelper {
ContextType type = ContextUtils.getContextTypeByName(contexts, context.getName(), defaultContextName);
if (type != null) {
for (ContextParameterType param :(List<ContextParameterType>)type.getContextParameter()){
String paramName = param.getName();
if (context.getContextParameter(param.getName()) != null) {
continue;
}
String oldVar = renamedMap.get(paramName);
if (oldVar != null) {
IContextParameter contextParamter = context.getContextParameter(oldVar);
if (contextParamter != null) {
continue;
}
}
if(added){
JobContextParameter contextParam = new JobContextParameter();
@@ -1678,14 +1682,16 @@ public final class ConnectionContextHelper {
* @return
*/
public static Set<String> checkAndAddContextVariables(final List<ContextType> contexts, final String defaultContextName,
final String contextItemId, final Set<String> neededVars, final IContextManager ctxManager, boolean added) {
final String contextItemId, final Set<String> neededVars, final IContextManager ctxManager, boolean added,
Map<String, String> renamedMap) {
Set<String> addedVars = new HashSet<String>();
for (IContext context : ctxManager.getListContext()) {
ContextType type = ContextUtils.getContextTypeByName(contexts, context.getName(), defaultContextName);
if (type != null) {
for (IContextParameter jobParam : context.getContextParameterList()) {
if (contextItemId.equals(jobParam.getSource())
&& ContextUtils.getContextParameterTypeByName(type, jobParam.getName()) == null) {
&& (ContextUtils.getContextParameterTypeByName(type, jobParam.getName()) == null
&& !renamedMap.values().contains(jobParam.getName()))) {
jobParam.setSource(IContextParameter.BUILT_IN);
}
}
@@ -1693,6 +1699,13 @@ public final class ConnectionContextHelper {
if (context.containsSameParameterIgnoreCase(var)) {
continue;
}
String oldVar = renamedMap.get(var);
if (oldVar != null) {
IContextParameter contextParamter = context.getContextParameter(oldVar);
if (contextParamter != null) {
continue;
}
}
ContextParameterType param = ContextUtils.getContextParameterTypeByName(type, var);
if (param != null) {
//

View File

@@ -234,7 +234,7 @@ public class ContextModeWizard extends CheckLastVersionRepositoryWizard implemen
if (creation && isCreateContext) {
String nextId = factory.getNextId();
contextProperty.setId(nextId);
contextManager.saveToEmf(contextItem.getContext());
contextManager.saveToEmf(contextItem.getContext(), false);
contextItem.setDefaultContext(contextManager.getDefaultContext().getName());
final IPath path = ((PropertiesWizardPage) contextModePage.getPropertiesPage()).getDestinationPath();
final IWorkspaceRunnable op = new IWorkspaceRunnable() {

View File

@@ -235,7 +235,7 @@ public class ContextWizard extends CheckLastVersionRepositoryWizard implements I
if (creation) {
String nextId = factory.getNextId();
contextProperty.setId(nextId);
contextManager.saveToEmf(contextItem.getContext());
contextManager.saveToEmf(contextItem.getContext(), false);
contextItem.setDefaultContext(contextManager.getDefaultContext().getName());
final IPath path = contextWizardPage0.getDestinationPath();
final IWorkspaceRunnable op = new IWorkspaceRunnable() {

View File

@@ -67,13 +67,25 @@ public class ContextSetsSelectionDialog extends SelectionDialog {
initSets();
}
/**
* DOC xqliu Comment method "initDialog".
*
* @param object
* @param cancelFlag
* @param message
*/
public ContextSetsSelectionDialog(ContextItem contextItem) {
this(calcShell(), contextItem, false);
}
public ContextSetsSelectionDialog(List<ContextType> contexts, String defaultContextName, boolean canCancel) {
super(calcShell());
initDialog(contexts, canCancel, Messages.getString("ContextSetsSelectionDialog.ReportMessages")); //$NON-NLS-1$
this.defalutContext = defaultContextName;
initSets();
}
public ContextSetsSelectionDialog(Shell parentShell, Object source, boolean canCancel, String defaultContextName,
String message) {
super(parentShell == null ? calcShell() : parentShell);
initDialog(source, canCancel, message); // $NON-NLS-1$
this.defalutContext = defaultContextName;
initSets();
}
private void initDialog(Object object, boolean cancelFlag, String message) {
this.source = object;
this.canCancel = cancelFlag;
@@ -89,17 +101,6 @@ public class ContextSetsSelectionDialog extends SelectionDialog {
newShell.setImage(ImageProvider.getImage(ECoreImage.CONTEXT_ICON));
}
public ContextSetsSelectionDialog(ContextItem contextItem) {
this(calcShell(), contextItem, false);
}
public ContextSetsSelectionDialog(List<ContextType> contexts, String defaultContextName, boolean canCancel) {
super(calcShell());
initDialog(contexts, canCancel, Messages.getString("ContextSetsSelectionDialog.ReportMessages")); //$NON-NLS-1$
this.defalutContext = defaultContextName;
initSets();
}
/**
* DOC zli Comment method "calcShell".
*

View File

@@ -1039,7 +1039,7 @@ public class ExtractMetaDataUtils {
if (driverJarPathArg.contains(";")) {
String jars[] = driverJarPathArg.split(";");
for (String jar : jars) {
String jarName = librairesManagerService.getJarNameFromMavenuri(driverJarPathArg);
String jarName = librairesManagerService.getJarNameFromMavenuri(jar);
// TDQ-16842 msjian:sometimes for the import jdbc connection, the jarName is null
if (jarName == null) {
jarName = jar.split("/")[1] + ".jar";

View File

@@ -445,7 +445,8 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
ResultSet catalogNames = null;
if (dbJDBCMetadata instanceof SybaseDatabaseMetaData) {
// Whether in context mode or not, metaConnection can get the correct username always
catalogNames = ((SybaseDatabaseMetaData) dbJDBCMetadata).getCatalogs(metaConnection.getUsername());
String username = metaConnection == null ? dbConn.getUsername() : metaConnection.getUsername();
catalogNames = ((SybaseDatabaseMetaData) dbJDBCMetadata).getCatalogs(username);
} else {
catalogNames = dbJDBCMetadata.getCatalogs();
}

View File

@@ -255,6 +255,13 @@
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="internalId" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="inernalId"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="ContextType">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">

View File

@@ -44,6 +44,7 @@
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute TalendFile.ecore#//ContextParameterType/repositoryContextId"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute TalendFile.ecore#//ContextParameterType/type"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute TalendFile.ecore#//ContextParameterType/value"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute TalendFile.ecore#//ContextParameterType/internalId"/>
</genClasses>
<genClasses ecoreClass="TalendFile.ecore#//ContextType">
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference TalendFile.ecore#//ContextType/contextParameter"/>

View File

@@ -13,6 +13,7 @@ import org.eclipse.emf.ecore.EObject;
*
* <p>
* The following features are supported:
* </p>
* <ul>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getComment <em>Comment</em>}</li>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getName <em>Name</em>}</li>
@@ -21,8 +22,8 @@ import org.eclipse.emf.ecore.EObject;
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getRepositoryContextId <em>Repository Context Id</em>}</li>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getType <em>Type</em>}</li>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getValue <em>Value</em>}</li>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getInternalId <em>Internal Id</em>}</li>
* </ul>
* </p>
*
* @see org.talend.designer.core.model.utils.emf.talendfile.TalendFilePackage#getContextParameterType()
* @model extendedMetaData="name='ContextParameter_._type' kind='empty'"
@@ -245,6 +246,29 @@ public interface ContextParameterType extends EObject {
*/
void setValue(String value);
/**
* Returns the value of the '<em><b>Internal Id</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the value of the '<em>Internal Id</em>' attribute.
* @see #setInternalId(String)
* @see org.talend.designer.core.model.utils.emf.talendfile.TalendFilePackage#getContextParameterType_InternalId()
* @model dataType="org.eclipse.emf.ecore.xml.type.String"
* extendedMetaData="kind='attribute' name='inernalId' namespace='##targetNamespace'"
* @generated
*/
String getInternalId();
/**
* Sets the value of the '{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getInternalId <em>Internal Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Internal Id</em>' attribute.
* @see #getInternalId()
* @generated
*/
void setInternalId(String value);
/**
* Specially for Password type of context, and the value should be encrypt always.
*

View File

@@ -414,6 +414,15 @@ public interface TalendFilePackage extends EPackage {
*/
int CONTEXT_PARAMETER_TYPE__VALUE = 6;
/**
* The feature id for the '<em><b>Internal Id</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
int CONTEXT_PARAMETER_TYPE__INTERNAL_ID = 7;
/**
* The number of structural features of the '<em>Context Parameter Type</em>' class.
* <!-- begin-user-doc -->
@@ -421,7 +430,7 @@ public interface TalendFilePackage extends EPackage {
* @generated
* @ordered
*/
int CONTEXT_PARAMETER_TYPE_FEATURE_COUNT = 7;
int CONTEXT_PARAMETER_TYPE_FEATURE_COUNT = 8;
/**
* The meta object id for the '{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl <em>Context Type</em>}' class.
@@ -2177,6 +2186,17 @@ public interface TalendFilePackage extends EPackage {
*/
EAttribute getContextParameterType_Value();
/**
* Returns the meta object for the attribute '{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getInternalId <em>Internal Id</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the meta object for the attribute '<em>Internal Id</em>'.
* @see org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getInternalId()
* @see #getContextParameterType()
* @generated
*/
EAttribute getContextParameterType_InternalId();
/**
* Returns the meta object for class '{@link org.talend.designer.core.model.utils.emf.talendfile.ContextType <em>Context Type</em>}'.
* <!-- begin-user-doc -->
@@ -3474,6 +3494,7 @@ public interface TalendFilePackage extends EPackage {
* @see java.util.Map.Entry
* @model keyDataType="org.eclipse.emf.ecore.EString"
* valueDataType="org.eclipse.emf.ecore.xml.type.Base64Binary"
* annotation="MapEntry"
* @generated
*/
EClass getScreenshotsMap();
@@ -3508,6 +3529,7 @@ public interface TalendFilePackage extends EPackage {
* @see java.util.Map.Entry
* @model keyDataType="org.eclipse.emf.ecore.EString"
* valueDataType="org.eclipse.emf.ecore.EString"
* annotation="MapEntry"
* @generated
*/
EClass getAdditionalFieldMap();
@@ -3858,6 +3880,14 @@ public interface TalendFilePackage extends EPackage {
*/
EAttribute CONTEXT_PARAMETER_TYPE__VALUE = eINSTANCE.getContextParameterType_Value();
/**
* The meta object literal for the '<em><b>Internal Id</b></em>' attribute feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
EAttribute CONTEXT_PARAMETER_TYPE__INTERNAL_ID = eINSTANCE.getContextParameterType_InternalId();
/**
* The meta object literal for the '{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl <em>Context Type</em>}' class.
* <!-- begin-user-doc -->

View File

@@ -19,6 +19,7 @@ import org.talend.utils.security.StudioEncryption;
* end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getComment <em>Comment</em>}</li>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getName <em>Name</em>}</li>
@@ -27,8 +28,8 @@ import org.talend.utils.security.StudioEncryption;
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getRepositoryContextId <em>Repository Context Id</em>}</li>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getType <em>Type</em>}</li>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getValue <em>Value</em>}</li>
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getInternalId <em>Internal Id</em>}</li>
* </ul>
* </p>
*
* @generated
*/
@@ -182,6 +183,26 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
*/
protected String value = VALUE_EDEFAULT;
/**
* The default value of the '{@link #getInternalId() <em>Internal Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInternalId()
* @generated
* @ordered
*/
protected static final String INTERNAL_ID_EDEFAULT = null;
/**
* The cached value of the '{@link #getInternalId() <em>Internal Id</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInternalId()
* @generated
* @ordered
*/
protected String internalId = INTERNAL_ID_EDEFAULT;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
@@ -364,6 +385,27 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
eNotify(new ENotificationImpl(this, Notification.SET, TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE, oldValue, value));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getInternalId() {
return internalId;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setInternalId(String newInternalId) {
String oldInternalId = internalId;
internalId = newInternalId;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID, oldInternalId, internalId));
}
public void setRawValue(String newValue) {
if (newValue != null && newValue.length() > 0 && PasswordEncryptUtil.isPasswordType(getType())) {
String encryptValue = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
@@ -396,6 +438,8 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
return getType();
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE:
return getValue();
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID:
return getInternalId();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -427,6 +471,9 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE:
setValue((String)newValue);
return;
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID:
setInternalId((String)newValue);
return;
}
super.eSet(featureID, newValue);
}
@@ -458,6 +505,9 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE:
setValue(VALUE_EDEFAULT);
return;
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID:
setInternalId(INTERNAL_ID_EDEFAULT);
return;
}
super.eUnset(featureID);
}
@@ -482,6 +532,8 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE:
return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID:
return INTERNAL_ID_EDEFAULT == null ? internalId != null : !INTERNAL_ID_EDEFAULT.equals(internalId);
}
return super.eIsSet(featureID);
}
@@ -508,6 +560,8 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
result.append(type);
result.append(", value: ");
result.append(value);
result.append(", internalId: ");
result.append(internalId);
result.append(')');
return result.toString();
}

View File

@@ -91,6 +91,7 @@ import org.talend.core.model.utils.TalendPropertiesUtil;
import org.talend.core.prefs.IDEInternalPreferences;
import org.talend.core.prefs.ITalendCorePrefConstants;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.services.ICoreTisService;
import org.talend.core.ui.CoreUIPlugin;
import org.talend.core.ui.branding.IBrandingConfiguration;
import org.talend.core.ui.branding.IBrandingService;
@@ -184,7 +185,18 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
} catch (PersistenceException e) {
localProvider = true;
}
String buildIdField = " (" + VersionUtils.getVersion() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
ICoreTisService pachService = (ICoreTisService) GlobalServiceRegister
.getDefault().getService(ICoreTisService.class);
if (pachService != null) {
String patchVersion = pachService.getLatestInstalledVersion();
if(patchVersion != null) {
buildIdField = " (" + patchVersion + ")"; //$NON-NLS-1$ //$NON-NLS-2$;
}
}
}
if (TalendPropertiesUtil.isHideBuildNumber()) {
buildIdField = ""; //$NON-NLS-1$
}

View File

@@ -187,7 +187,7 @@ public class DynamicContentProvider extends IntroProvider {
if (activeDataCollector && version != null && edition != null) {
// uuid
DefaultTokenCollector dtc = new DefaultTokenCollector();
url.append("?version=").append(sb.toString()).append("&uid=").append(dtc.calcUniqueId()).append("&edition=") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
url.append("?version=").append(sb.toString()).append("&uid=").append(dtc.hashUniqueId()).append("&edition=") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
.append(edition);
} else if (!activeDataCollector && version != null && edition != null) {
url.append("?version=").append(sb.toString()).append("&edition=").append(edition); //$NON-NLS-1$ //$NON-NLS-2$

View File

@@ -252,7 +252,7 @@ public class RegisterManagement {
String version = VersionUtils.getVersion();
// UNIQUE_ID
String uniqueId = DefaultTokenCollector.calcUniqueId();
String uniqueId = DefaultTokenCollector.hashUniqueId();
RegisterUserPortTypeProxy proxy = new RegisterUserPortTypeProxy();
proxy.setEndpoint("https://www.talend.com/TalendRegisterWS/registerws.php"); //$NON-NLS-1$
@@ -464,7 +464,7 @@ public class RegisterManagement {
URL registURL = null;
try {
// UNIQUE_ID
String uniqueId = DefaultTokenCollector.calcUniqueId();
String uniqueId = DefaultTokenCollector.hashUniqueId();
uniqueId = uniqueId.replace("#", "%23");
uniqueId = uniqueId.replace("$", "%24");
uniqueId = uniqueId.replace("%", "%25");

View File

@@ -471,16 +471,32 @@ public class ImportExportHandlersManager {
@Override
public int compare(ImportItem o1, ImportItem o2) {
if (o1.getRepositoryType().getType().equals("SERVICES")) {
return -1;
} else if (o2.getRepositoryType().getType().equals("SERVICES")) {
return 1;
return getImportPriority(o1) - getImportPriority(o2);
}
private int getImportPriority(ImportItem item) {
if (ERepositoryObjectType.CONTEXT.getType().equals(item.getRepositoryType().getType())) {
return 10;
} else if ("SERVICES".equals(item.getRepositoryType().getType())) {
return 20;
} else if (ERepositoryObjectType.JOBLET != null
&& ERepositoryObjectType.JOBLET.getType().equals(item.getRepositoryType().getType())) {
return 30;
} else if (ERepositoryObjectType.PROCESS_ROUTELET != null
&& ERepositoryObjectType.PROCESS_ROUTELET.getType().equals(item.getRepositoryType().getType())) {
return 40;
}
return 0;
return 100;
}
});
ImportCacheHelper importCacheHelper = ImportCacheHelper.getInstance();
try {
for (ImportItem itemRecord : checkedItemRecords) {
if (itemRecord.getProperty() != null) {
itemRecord.setOriginProperyId(itemRecord.getProperty().getId());
}
}
// cache
importCacheHelper.beforeImportItems();

View File

@@ -31,6 +31,13 @@ public class SyncChildrenSourceCodeProvider implements IBuildResourcesProvider {
@Override
public void prepare(IProgressMonitor monitor, Map<String, Object> parameters) throws Exception {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
if (service.isCIMode()) {
// don't sync any children source code to parent job in CI.
return;
}
}
if (parameters == null) {
return;
}

View File

@@ -14,6 +14,8 @@ package org.talend.repository.items.importexport.handlers.imports;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -31,6 +33,9 @@ import java.util.stream.Collectors;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Priority;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -52,9 +57,11 @@ import org.talend.commons.runtime.model.repository.ERepositoryStatus;
import org.talend.commons.runtime.utils.io.FileCopyUtils;
import org.talend.commons.utils.VersionUtils;
import org.talend.commons.utils.time.TimeMeasure;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.context.Context;
import org.talend.core.context.RepositoryContext;
import org.talend.core.model.context.link.ContextLinkService;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.ConnectionPackage;
import org.talend.core.model.migration.IMigrationToolService;
@@ -833,11 +840,14 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
logError(e);
}
if (selectedImportItem.isImported()) {
File linkFile = findSourceContextLinkFile(selectedImportItem);
selectedImportItem.setImportPath(path.toPortableString());
selectedImportItem.setRepositoryType(itemType);
selectedImportItem.setItemId(selectedImportItem.getProperty().getId());
selectedImportItem.setItemVersion(selectedImportItem.getProperty().getVersion());
if (linkFile != null && linkFile.exists()) {
copyContextLinkFile(linkFile, tmpItem);
}
repObjectcache.addToCache(tmpItem);
}
@@ -874,11 +884,42 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
}
}
private boolean isNeedDeleteOnRemote(String importingLabel, String existLabel) {
if (importingLabel != null && importingLabel.equalsIgnoreCase(importingLabel) && !importingLabel.equals(existLabel)) {
return true;
protected File findSourceContextLinkFile(ImportItem importItem) {
String techLabel = importItem.getItemProject().getTechnicalLabel();
File projectFolder = null, linkFile = null;
File file = new File(importItem.getPath().toPortableString());
while (file.getParentFile() != null) {
if (file.getParentFile().getName().equals(techLabel)) {
projectFolder = file.getParentFile();
break;
}
file = file.getParentFile();
}
if (projectFolder != null) {
linkFile = new File(
ContextLinkService.calLinksFilePath(projectFolder.getAbsolutePath(), importItem.getOriginProperyId()));
}
return linkFile;
}
protected void copyContextLinkFile(File sourceLinkFile, Item item)
throws IOException, PersistenceException, CoreException {
String techLabel = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
IProject iProject = ResourceUtils.getProject(techLabel);
IFolder settingFolder = ResourceUtils.getFolder(iProject, RepositoryConstants.SETTING_DIRECTORY, false);
if (!settingFolder.exists()) {
settingFolder.create(true, true, null);
}
IFolder linksFolder = settingFolder.getFolder(ContextLinkService.LINKS_FOLDER_NAME);
if (!linksFolder.exists()) {
linksFolder.create(true, true, null);
}
IFile linkFile = linksFolder.getFile(ContextLinkService.getLinkFileName(item.getProperty().getId()));
if (!linkFile.exists()) {
ResourceUtils.createFile(new FileInputStream(sourceLinkFile), linkFile);
} else {
ResourceUtils.setFileContent(new FileInputStream(sourceLinkFile), linkFile);
}
return false;
}
/**
@@ -994,7 +1035,6 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
}
protected void beforeCreatingItem(ImportItem selectedImportItem) {
// noting to do specially.
}
protected void afterCreatedItem(ResourcesManager resManager, ImportItem selectedImportItem) throws Exception {

View File

@@ -73,6 +73,8 @@ public class ImportItem {
private boolean removeProjectStatslog;
private String originProperyId;
/**
* add for tdm
*/
@@ -392,6 +394,14 @@ public class ImportItem {
this.isSystemItem = isSystemItem;
}
public String getOriginProperyId() {
return originProperyId;
}
public void setOriginProperyId(String originProperyId) {
this.originProperyId = originProperyId;
}
@Override
public int hashCode() {
final int prime = 31;

View File

@@ -27,6 +27,7 @@ import org.apache.log4j.Priority;
import org.eclipse.emf.common.util.EList;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.context.link.ContextLinkService;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.process.IContext;
import org.talend.core.model.process.IContextManager;
@@ -300,6 +301,7 @@ public class ChangeIdManager {
} else {
throw new Exception("Unsupported id change: id[" + property.getId() + "], name[" + property.getLabel() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
ContextLinkService.getInstance().changeRepositoryId(item, old2NewMap);
if (modified) {
ProxyRepositoryFactory.getInstance().save(project, item);
RelationshipItemBuilder.getInstance().addOrUpdateItem(property.getItem());

View File

@@ -29,6 +29,7 @@ import org.talend.core.PluginChecker;
import org.talend.core.hadoop.IHadoopClusterService;
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ItemState;
import org.talend.core.model.properties.Project;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.ui.ITestContainerProviderService;
@@ -234,9 +235,12 @@ public class ImportNodesBuilder {
parentImportNode = findAndCreateFolderNode(typeImportNode, path);
parentImportNode.setItemRecord(itemRecord);
} else {
String path = item.getState().getPath();
if (StringUtils.isNotEmpty(path)) { // if has path, will find the real path node.
parentImportNode = findAndCreateFolderNode(typeImportNode, new Path(path));
ItemState state = item.getState();
if (state != null) {
String path = state.getPath();
if (StringUtils.isNotEmpty(path)) { // if has path, will find the real path node.
parentImportNode = findAndCreateFolderNode(typeImportNode, new Path(path));
}
}
ItemImportNode itemNode = new ItemImportNode(itemRecord);
parentImportNode.addChild(itemNode);

View File

@@ -90,6 +90,7 @@ import org.talend.commons.utils.io.FilesUtils;
import org.talend.commons.utils.workbench.resources.ResourceUtils;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.context.RepositoryContext;
import org.talend.core.model.context.link.ContextLinkService;
import org.talend.core.model.general.Project;
import org.talend.core.model.general.TalendNature;
import org.talend.core.model.metadata.MetadataManager;
@@ -170,7 +171,12 @@ import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
import org.talend.core.ui.branding.IBrandingService;
import org.talend.cwm.helper.ConnectionHelper;
import org.talend.cwm.helper.ResourceHelper;
import org.talend.cwm.helper.SubItemHelper;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl;
import org.talend.designer.core.model.utils.emf.talendfile.impl.TalendFilePackageImpl;
import org.talend.repository.ProjectManager;
import org.talend.repository.RepositoryWorkUnit;
import org.talend.repository.localprovider.exceptions.IncorrectFileException;
@@ -1346,11 +1352,17 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
// Getting the folder :
try {
IFolder folder = ResourceUtils.getFolder(fsProject, completePath, true);
IFolder folder = null;
try {
folder = ResourceUtils.getFolder(fsProject, completePath, true);
} catch (PersistenceException e) {
}
// changed by hqzhang for TDI-20600, FolderHelper.deleteFolder will fire the DeletedFolderListener in
// ProjectRepoAbstractContentProvider class to refresh the node, if don't delete resource first, the deleted
// foler display in repository view
deleteResource(folder);
if (folder != null && folder.exists()) {
deleteResource(folder);
}
} finally {
// even if the folder do not exist anymore, clean the list on the project
getFolderHelper(project.getEmfProject()).deleteFolder(completePath);
@@ -1790,6 +1802,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
for (Resource resource : affectedResources) {
deleteResource(resource, isDeleteOnRemote);
}
ContextLinkService.getInstance().deleteContextLinkJsonFile(currentProperty.getItem());
// ADD msjian TDQ-6791 2013-2-20:when the resource is invalid(null), delete its file
EList<EObject> eCrossReferences = currentItem.eCrossReferences();
@@ -2365,8 +2378,37 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
private Resource create(IProject project, ContextItem item, IPath path) throws PersistenceException {
Resource itemResource = xmiResourceManager.createItemResource(project, item, path, ERepositoryObjectType.CONTEXT, false);
itemResource.getContents().addAll(item.getContext());
Map<String, String> contextIdMaps = new HashMap<String, String>();
Map<String, Map<String, String>> paramIdMaps = new HashMap<String, Map<String, String>>();
EList list = item.getContext();
for (Object obj : list) {
if (obj instanceof ContextType) {
ContextType contextType = (ContextType) obj;
contextIdMaps.put(contextType.getName(), ResourceHelper.getUUID(contextType));
Map<String, String> idMap = new HashMap<String, String>();
paramIdMaps.put(contextType.getName(), idMap);
for (Object op : contextType.getContextParameter()) {
if (op instanceof ContextParameterType) {
ContextParameterType p = (ContextParameterType) op;
idMap.put(p.getName(), ResourceHelper.getUUID(p));
}
}
}
}
itemResource.getContents().addAll(item.getContext());
ContextType[] newContextArray = EcoreUtil
.getObjectsByType(itemResource.getContents(), TalendFilePackageImpl.eINSTANCE.getContextType())
.toArray(new ContextType[0]);
for (int i = 0; i < newContextArray.length; i++) {
ContextTypeImpl newContextType = (ContextTypeImpl) newContextArray[i];
ResourceHelper.setUUid(newContextType, contextIdMaps.get(newContextType.getName()));
Map<String, String> idMap = paramIdMaps.get(newContextType.getName());
for (int j = 0; j < newContextType.getContextParameter().size(); j++) {
ContextParameterType newParam = (ContextParameterType) newContextType.getContextParameter().get(j);
ResourceHelper.setUUid(newParam, idMap.get(newParam.getName()));
}
}
return itemResource;
}
@@ -2623,6 +2665,11 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
}
this.copyScreenshotFlag = false;
}
saveContextLinkInfo(item);
}
private void saveContextLinkInfo(Item item) throws PersistenceException {
ContextLinkService.getInstance().saveContextLink(item);
}
@Override
@@ -3022,7 +3069,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
xmiResourceManager.saveResource(screenshotsResource);
xmiResourceManager.saveResource(itemResource);
xmiResourceManager.saveResource(propertyResource);
saveContextLinkInfo(item);
if (isImportItem.length == 0 || !isImportItem[0]) {
saveProject(project);
}

View File

@@ -33,6 +33,7 @@ import org.talend.core.model.properties.DatabaseConnectionItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.RepositoryObject;
import org.talend.core.model.update.RepositoryUpdateManager;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.repository.ui.actions.metadata.AbstractCreateAction;
import org.talend.core.runtime.services.IGenericDBService;
@@ -175,12 +176,14 @@ public class CreateConnectionAction extends AbstractCreateAction {
Property property = node.getObject().getProperty();
Property updatedProperty = null;
try {
if (!creation) {
RepositoryUpdateManager.updateConnectionContextParam(node);
}
updatedProperty = ProxyRepositoryFactory.getInstance().getUptodateProperty(
new Project(ProjectManager.getInstance().getProject(property.getItem())), property);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
DatabaseWizard databaseWizard;

View File

@@ -444,4 +444,21 @@ public class RepoViewCommonViewer extends CommonViewer implements INavigatorCont
super.dispose();
}
@Override
public void associate(Object element, Item item) {
Object data = item.getData();
if (data != element) {
if (data != null) {
disassociate(item);
}
item.setData(element);
mapElement(element, item);
} else {
// Always map the element, even if data == element,
// since unmapAllElements() can leave the map inconsistent
// See bug 2741 for details.
mapElement(element, item);
}
}
}

View File

@@ -24,6 +24,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.talend.commons.utils.network.NetworkUtil;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.general.ModuleToInstall;
import org.talend.core.nexus.TalendLibsServerManager;
import org.talend.librariesmanager.model.ModulesNeededProvider;
import org.talend.librariesmanager.utils.RemoteModulesHelper;
import org.talend.updates.runtime.i18n.Messages;
@@ -38,6 +39,7 @@ public class PluginOptionalMissingJarsExtraUpdatesFactory extends AbstractExtraU
private static Logger log = Logger.getLogger(PluginOptionalMissingJarsExtraUpdatesFactory.class);
/*
* (non-Javadoc)
*
@@ -48,7 +50,7 @@ public class PluginOptionalMissingJarsExtraUpdatesFactory extends AbstractExtraU
@Override
public void retrieveUninstalledExtraFeatures(IProgressMonitor monitor, Set<ExtraFeature> uninstalledExtraFeatures)
throws Exception {
if (!NetworkUtil.isNetworkValid(System.getProperty("nexus.proxy.url"))) {
if (!NetworkUtil.isNetworkValid(TalendLibsServerManager.getInstance().getTalentArtifactServer().getServer())) {
return;
}
@@ -94,7 +96,5 @@ public class PluginOptionalMissingJarsExtraUpdatesFactory extends AbstractExtraU
.getString("missing.optional.third.parties.libs.feature.description"), false/* mustInstall */)); //$NON-NLS-1$
}
}// else nothing to install so nothing to install ;)
}
}
}

View File

@@ -12,6 +12,8 @@
// ============================================================================
package org.talend.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -21,9 +23,11 @@ import java.util.regex.Pattern;
*/
public class ProductVersion implements Comparable<ProductVersion> {
private static final Pattern THREE_DIGIT_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+).*");
private static final Pattern THREE_DIGIT_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+).*"); //$NON-NLS-1$
private static final Pattern EXTENDED_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*");
private static final Pattern EXTENDED_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*"); //$NON-NLS-1$
private static final Pattern FOUR_PART_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)\\.(.*)"); //$NON-NLS-1$
private int major;
@@ -33,6 +37,10 @@ public class ProductVersion implements Comparable<ProductVersion> {
private boolean setMicro = false;
private String extraInfo;
private boolean setExtraInfo = false;
/**
* ProductVersion constructor.
*
@@ -48,6 +56,20 @@ public class ProductVersion implements Comparable<ProductVersion> {
this.setMicro = true;
}
/**
* ProductVersion constructor.
*
* @param major
* @param minor
* @param micro
* @param extraInfo
*/
public ProductVersion(int major, int minor, int micro, String extraInfo) {
this(major, minor, micro);
this.extraInfo = extraInfo;
this.setExtraInfo = true;
}
/**
* ProductVersion constructor.
*
@@ -62,6 +84,17 @@ public class ProductVersion implements Comparable<ProductVersion> {
this.setMicro = false;
}
/**
* this ProductVersion constructor generate a ProductVersion with versionDate.
*
* @param ProductVersion
* @param Date
*/
public ProductVersion(ProductVersion productVersion, Date versionDate) {
this(productVersion.getMajor(), productVersion.getMinor(), productVersion.getMicro(),
new SimpleDateFormat("yyyyMMdd").format(versionDate)); //$NON-NLS-1$
}
/**
* Method "fromString".
*
@@ -73,6 +106,7 @@ public class ProductVersion implements Comparable<ProductVersion> {
if (!extendedVersion) {
return fromString(version);
}
Matcher matcher = EXTENDED_PATTERN.matcher(version);
if (matcher.find()) {
int major = Integer.parseInt(matcher.group(1));
@@ -88,6 +122,29 @@ public class ProductVersion implements Comparable<ProductVersion> {
return null;
}
/**
* DOC msjian Comment method "fromString".
*
* @param version the version to parse
* @param extendedVersion true if the version could be a 2 or 3 digit version
* @param isFourPartVersion true if the version contains 4 part like: 7.3.1.20200507 or 7.3.1.20200417_1111-patch
* @return the product version
*/
public static ProductVersion fromString(String version, boolean extendedVersion, boolean isFourPartVersion) {
if (isFourPartVersion) {
Matcher matcher4 = FOUR_PART_PATTERN.matcher(version);
if (matcher4.find() && matcher4.groupCount() == 4) {
int major = Integer.parseInt(matcher4.group(1));
int minor = Integer.parseInt(matcher4.group(2));
String microStr = matcher4.group(3);
String extraInfo = matcher4.group(4);
int micro = Integer.parseInt(microStr);
return new ProductVersion(major, minor, micro, extraInfo);
}
}
return fromString(version, extendedVersion);
}
/**
* Method "fromString".
*
@@ -121,6 +178,17 @@ public class ProductVersion implements Comparable<ProductVersion> {
return diff;
}
}
if (setExtraInfo) {
if (other.setExtraInfo) {
return extraInfo.compareTo(other.extraInfo);
} else {
return 1;
}
} else {
if (other.setExtraInfo) {
return -1;
}
}
return 0;
}
@@ -131,6 +199,9 @@ public class ProductVersion implements Comparable<ProductVersion> {
result = prime * result + major;
result = prime * result + micro;
result = prime * result + minor;
if (setExtraInfo) {
result = prime * result + extraInfo.length();
}
return result;
}
@@ -155,6 +226,11 @@ public class ProductVersion implements Comparable<ProductVersion> {
if (micro != other.micro) {
return false;
}
if (setExtraInfo && other.setExtraInfo) {
if (!extraInfo.equals(other.extraInfo)) {
return false;
}
}
return true;
}
@@ -163,12 +239,16 @@ public class ProductVersion implements Comparable<ProductVersion> {
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(major);
stringBuilder.append(".");
stringBuilder.append("."); //$NON-NLS-1$
stringBuilder.append(minor);
if (setMicro) {
stringBuilder.append(".");
stringBuilder.append("."); //$NON-NLS-1$
stringBuilder.append(micro);
}
if (setExtraInfo) {
stringBuilder.append("."); //$NON-NLS-1$
stringBuilder.append(extraInfo);
}
return stringBuilder.toString();
}
@@ -183,4 +263,16 @@ public class ProductVersion implements Comparable<ProductVersion> {
public int getMinor() {
return minor;
}
public boolean isSetMicro() {
return setMicro;
}
public String getExtraInfo() {
return this.extraInfo;
}
public boolean isSetExtraInfo() {
return setExtraInfo;
}
}

View File

@@ -44,7 +44,7 @@ public class StudioEncryption {
private static final String PREFIX_PASSWORD_M3 = "ENC:[";
private static final String PREFIX_PASSWORD = "enc:"; //$NON-NLS-1$
public static final String PREFIX_PASSWORD = "enc:"; //$NON-NLS-1$
private static final Pattern REG_ENCRYPTED_DATA_SYSTEM = Pattern
.compile("^enc\\:system\\.encryption\\.key\\.v\\d\\:\\p{Print}+");

View File

@@ -0,0 +1,82 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.utils;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.talend.core.model.properties.ItemState;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.repository.RepositoryViewObject;
import org.talend.core.repository.utils.RepositoryNodeSortUtil;
/**
* @author hwang
*
*/
public class RepositoryNodeSortUtilTest {
@Test
public void testGetSortVersion() {
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId("property1"); //$NON-NLS-1$
property1.setVersion("2.9"); //$NON-NLS-1$
property1.setLabel("test1");//$NON-NLS-1$
ProcessItem item1 = PropertiesFactory.eINSTANCE.createProcessItem();
ItemState state = PropertiesFactory.eINSTANCE.createItemState();
state.setDeleted(false);
item1.setState(state);
property1.setItem(item1);
IRepositoryViewObject object1 = new RepositoryViewObject(property1, true);
property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId("property1"); //$NON-NLS-1$
property1.setVersion("0.3"); //$NON-NLS-1$
property1.setLabel("test1");//$NON-NLS-1$
item1 = PropertiesFactory.eINSTANCE.createProcessItem();
state = PropertiesFactory.eINSTANCE.createItemState();
state.setDeleted(false);
item1.setState(state);
property1.setItem(item1);
IRepositoryViewObject object2 = new RepositoryViewObject(property1, true);
property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId("property1"); //$NON-NLS-1$
property1.setVersion("2.11"); //$NON-NLS-1$
property1.setLabel("test1");//$NON-NLS-1$
item1 = PropertiesFactory.eINSTANCE.createProcessItem();
state = PropertiesFactory.eINSTANCE.createItemState();
state.setDeleted(false);
item1.setState(state);
property1.setItem(item1);
IRepositoryViewObject object3 = new RepositoryViewObject(property1, true);
List<IRepositoryViewObject> temp = new ArrayList<IRepositoryViewObject>();
RepositoryNodeSortUtil util = new RepositoryNodeSortUtil();
temp = new ArrayList<IRepositoryViewObject>();
temp.add(object3);
temp.add(object2);
temp.add(object1);
List<IRepositoryViewObject> result = util.getSortVersion(temp);
assertTrue("0.3".equals(result.get(0).getVersion()));
assertTrue("2.9".equals(result.get(1).getVersion()));
assertTrue("2.11".equals(result.get(2).getVersion()));
}
}

View File

@@ -9,3 +9,4 @@ Require-Bundle: org.junit;bundle-version="4.11.0",
org.talend.testutils,
org.talend.components.common,
javax.xml.soap
Import-Package: org.talend.core.repository.model

View File

@@ -0,0 +1,56 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.model.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.repository.model.IRepositoryNode.ENodeType;
import org.talend.repository.model.IRepositoryNode.EProperties;
import org.talend.repository.model.RepositoryNode;
/*
* Created by bhe on Mar 30, 2020
*/
public class RepositoryNodeTest {
@Test
public void testEquals() throws Exception {
RepositoryNode parent = new RepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
parent.setProperties(EProperties.LABEL, "system");
parent.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.PROCESS);
parent.setType(ENodeType.STABLE_SYSTEM_FOLDER);
assertNotNull(parent);
RepositoryNode parentNew = new RepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
parentNew.setProperties(EProperties.LABEL, "system");
parentNew.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.PROCESS);
parentNew.setType(ENodeType.STABLE_SYSTEM_FOLDER);
assertEquals(parent, parentNew);
assertEquals(parent.hashCode(), parentNew.hashCode());
RepositoryNode son = new RepositoryNode(null, null, ENodeType.STABLE_SYSTEM_FOLDER);
son.setProperties(EProperties.LABEL, ERepositoryObjectType.PROCESS);
son.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.PROCESS);
assertNotNull(son);
assertFalse(parent.equals(son));
}
}

View File

@@ -0,0 +1,49 @@
// ============================================================================
//
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.designer.maven.utils;
import java.util.HashSet;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
/**
* DOC jding class global comment. Detailled comment
*/
public class SortableDependencyTest {
@Test
public void testEqualsHashcode() {
SortableDependency dependency = new SortableDependency();
dependency.setGroupId("org.example.test");
dependency.setArtifactId("test");
SortableDependency dependency1 = new SortableDependency();
dependency1.setGroupId("org.example.test");
dependency1.setArtifactId("test");
Set<SortableDependency> dependencySet = new HashSet<SortableDependency>();
dependencySet.add(dependency);
dependencySet.add(dependency1);
Assert.assertEquals(1, dependencySet.size());
Assert.assertTrue(dependency.equals(dependency1));
dependency.setVersion("0.1");
dependency1.setVersion("0.2");
dependencySet.add(dependency1);
Assert.assertEquals(2, dependencySet.size());
Assert.assertFalse(dependency.equals(dependency1));
}
}

View File

@@ -12,32 +12,25 @@
// ============================================================================
package org.talend.metadata.managment.ui.utils;
import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.junit.Test;
import org.talend.commons.utils.VersionUtils;
import org.talend.core.context.Context;
import org.talend.core.context.RepositoryContext;
import org.talend.core.model.context.JobContext;
import org.talend.core.model.context.JobContextManager;
import org.talend.core.model.context.JobContextParameter;
import org.talend.core.model.metadata.builder.connection.Connection;
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
import org.talend.core.model.metadata.types.JavaTypesManager;
import org.talend.core.model.process.IContext;
import org.talend.core.model.process.IContextManager;
import org.talend.core.model.process.IContextParameter;
import org.talend.core.model.properties.ContextItem;
import org.talend.core.model.properties.ItemState;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
import org.talend.core.runtime.CoreRuntimePlugin;
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
@@ -108,7 +101,8 @@ public class ConnectionContextHelperTest {
contextItem.setProperty(myContextProperty);
contextItem.setDefaultContext("Default");
Set<String> set = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextManager, false);
Set<String> set = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextManager, false,
new HashMap<String, String>());
assertTrue(set.size() == 2);
}

View File

@@ -12,9 +12,9 @@ package org.talend.utils;
//
// ============================================================================
import junit.framework.TestCase;
import java.util.Calendar;
import org.talend.utils.ProductVersion;
import junit.framework.TestCase;
/***/
public class ProductVersionTest extends TestCase {
@@ -28,6 +28,14 @@ public class ProductVersionTest extends TestCase {
}
public void testParse() {
assertEquals(new ProductVersion(7, 3, 1, "20200417_1111-patch"),
ProductVersion.fromString("7.3.1.20200417_1111-patch", true, true));
assertEquals(new ProductVersion(7, 3, 1, "20200507"), ProductVersion.fromString("7.3.1.20200507", true, true));
assertEquals(new ProductVersion(7, 3, 1), ProductVersion.fromString("7.3.1.20200417_1111-patch", true));
assertEquals(new ProductVersion(7, 3, 1), ProductVersion.fromString("7.3.1.20200507", true));
assertEquals(new ProductVersion(1, 2, 3), ProductVersion.fromString("1.2.3"));
assertEquals(new ProductVersion(1, 2, 3), ProductVersion.fromString("1.2.3.r12345"));
assertEquals(new ProductVersion(1, 2, 3), ProductVersion.fromString("1.2.3RC1"));
@@ -40,6 +48,7 @@ public class ProductVersionTest extends TestCase {
assertEquals(new ProductVersion(9, 2), ProductVersion.fromString("Oracle9i Release 9.2.0.1.0 - Production", true));
assertEquals(new ProductVersion(9, 2), ProductVersion.fromString("Oracle9i Release 9.2.0.1.0 - Production\n"
+ "JServer Release 9.2.0.1.0 - Production", true));
}
public void testCompare() {
@@ -71,5 +80,18 @@ public class ProductVersionTest extends TestCase {
fail();
}
ProductVersion productVersion1 = new ProductVersion(7, 3, 1, "20200417_1111-patch");
ProductVersion productVersion2 = new ProductVersion(7, 3, 1, "20200507");
ProductVersion productVersion3 = ProductVersion.fromString("7.3.1.20200417_1111-patch", true, true);
ProductVersion productVersion4 = new ProductVersion(7, 3, 1);
Calendar calender = Calendar.getInstance();
calender.set(2020, 4, 7);
ProductVersion productVersion5 = new ProductVersion(productVersion4, calender.getTime());
assertTrue(productVersion1.compareTo(productVersion2) < 0);
assertTrue(productVersion1.compareTo(productVersion3) == 0);
assertTrue(productVersion1.compareTo(productVersion4) > 0);
assertTrue(productVersion2.compareTo(productVersion4) > 0);
assertTrue(productVersion2.compareTo(productVersion5) == 0);
assertTrue(productVersion1.compareTo(productVersion5) < 0);
}
}