Compare commits
162 Commits
hwang/TUP-
...
cmeng/back
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6775da2599 | ||
|
|
9a219873f1 | ||
|
|
d013d08bdc | ||
|
|
761dcc7902 | ||
|
|
0a85c8056c | ||
|
|
3df4cf1348 | ||
|
|
c7965cf552 | ||
|
|
61b55c0d2a | ||
|
|
be41bcbef3 | ||
|
|
2827919dae | ||
|
|
33848db788 | ||
|
|
ac359e295a | ||
|
|
6965eb79fa | ||
|
|
80f02ef1e7 | ||
|
|
7c50efdf21 | ||
|
|
7f40393753 | ||
|
|
356dba9940 | ||
|
|
83f7a577d9 | ||
|
|
e87f557a49 | ||
|
|
a51b3316d3 | ||
|
|
46a22c4ad0 | ||
|
|
f8cc600d06 | ||
|
|
3146ed307f | ||
|
|
f4f91a5323 | ||
|
|
2aee38595f | ||
|
|
dde32c8b49 | ||
|
|
563b69231f | ||
|
|
1ea6227f59 | ||
|
|
148e9e9253 | ||
|
|
1e6a43650f | ||
|
|
67616537b2 | ||
|
|
1df4e819e0 | ||
|
|
b3d6c45f2d | ||
|
|
f1341cd69f | ||
|
|
a64bcecb0c | ||
|
|
5707d4db94 | ||
|
|
5e20a78752 | ||
|
|
85e44cd5c6 | ||
|
|
8582c20f1a | ||
|
|
6216fd76ea | ||
|
|
71d339fc0a | ||
|
|
d286276e6d | ||
|
|
3996d24893 | ||
|
|
f37b5b6073 | ||
|
|
060a9c7f9e | ||
|
|
789b4c02c0 | ||
|
|
4c3e3dfb2c | ||
|
|
7b3a20a3b3 | ||
|
|
e3880f3904 | ||
|
|
d54ed2a62c | ||
|
|
cde1129ce4 | ||
|
|
1081ae3680 | ||
|
|
3e02adb157 | ||
|
|
c212142789 | ||
|
|
ab67a4cc91 | ||
|
|
675da3fc7d | ||
|
|
6f9ad53b0d | ||
|
|
6cfffe1775 | ||
|
|
3c2d416677 | ||
|
|
f7f5627679 | ||
|
|
939c328d1b | ||
|
|
cb31b968bf | ||
|
|
c0636a6822 | ||
|
|
1e31b9ed97 | ||
|
|
d07e5beaf9 | ||
|
|
281c39428c | ||
|
|
3eaef89b5d | ||
|
|
de34e9bcaa | ||
|
|
5d1956966c | ||
|
|
1b1966058f | ||
|
|
ca65a35c8e | ||
|
|
c0a2a27815 | ||
|
|
832b460e4b | ||
|
|
3e8c7bb5d6 | ||
|
|
2f5f944d0b | ||
|
|
cf52e1e004 | ||
|
|
a05b2538a1 | ||
|
|
b456595669 | ||
|
|
bf2699c7c9 | ||
|
|
35047b473d | ||
|
|
50233f93f3 | ||
|
|
bf3bbf6430 | ||
|
|
735bbef8f3 | ||
|
|
28782a40d4 | ||
|
|
da57b8a80a | ||
|
|
9d0049bede | ||
|
|
1bd0f7939c | ||
|
|
b8e4c3bc7a | ||
|
|
931178184c | ||
|
|
3f8fc4ef4f | ||
|
|
ad3490606d | ||
|
|
085406b8da | ||
|
|
e9ef85f8e5 | ||
|
|
7543617b31 | ||
|
|
e21bb53627 | ||
|
|
a8f36c79f5 | ||
|
|
58171338ac | ||
|
|
cebd4646d9 | ||
|
|
9f2997692a | ||
|
|
1387f66674 | ||
|
|
7ee7eddb9d | ||
|
|
e674ec78f7 | ||
|
|
08c2082e8a | ||
|
|
8740f3b1da | ||
|
|
e08c225198 | ||
|
|
fef6605f83 | ||
|
|
af83d9d393 | ||
|
|
45a92717f9 | ||
|
|
7191b77c5c | ||
|
|
18c2e53223 | ||
|
|
16fbcf34f3 | ||
|
|
495ebda155 | ||
|
|
8f36da5ee1 | ||
|
|
0828f2951a | ||
|
|
5da999c4bd | ||
|
|
39eee08210 | ||
|
|
1ab6486d9a | ||
|
|
aa7da99e0d | ||
|
|
a73f8621ed | ||
|
|
09cfc769da | ||
|
|
2a1d017208 | ||
|
|
1189973653 | ||
|
|
c80a96768e | ||
|
|
0e3957c3d7 | ||
|
|
e7399f9df5 | ||
|
|
7f67aeaf0e | ||
|
|
d12826089a | ||
|
|
2bb3e43bc6 | ||
|
|
55ff7cc279 | ||
|
|
56811e6ce4 | ||
|
|
e3701ceb7c | ||
|
|
bcebeb1e99 | ||
|
|
6e12e77255 | ||
|
|
a2a09fa98c | ||
|
|
a88b035f03 | ||
|
|
6173437d9b | ||
|
|
69c2ecd88f | ||
|
|
78e7aae03e | ||
|
|
62ba9f8604 | ||
|
|
4f5c792187 | ||
|
|
77ee82d889 | ||
|
|
8f81ff4534 | ||
|
|
0a8f2e769e | ||
|
|
28f8e109a6 | ||
|
|
5d21d9d3ea | ||
|
|
7d223ecff8 | ||
|
|
1ff9877dce | ||
|
|
75d51647fc | ||
|
|
4f55385a9a | ||
|
|
c942bade7a | ||
|
|
551eb69025 | ||
|
|
c0b192f427 | ||
|
|
ccd1d6d1d5 | ||
|
|
0d2e0c8149 | ||
|
|
67a9b521c9 | ||
|
|
4a8869304b | ||
|
|
6118d69c3e | ||
|
|
2fecdf1ceb | ||
|
|
60869a1240 | ||
|
|
332f6ff85b | ||
|
|
45caecd7f2 | ||
|
|
6e9daf05fb |
@@ -13,7 +13,6 @@
|
||||
<plugin id="org.talend.libraries.jdbc.ingres" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.mysql" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.paraccel" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.postgresql" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.sqlite3" download-size="0" install-size="0" version="0.0.0"/>
|
||||
<plugin id="org.talend.libraries.jdbc.teradata" download-size="0" install-size="0" version="0.0.0"/>
|
||||
</feature>
|
||||
|
||||
@@ -14,7 +14,10 @@ Require-Bundle: org.apache.log4j;visibility:=reexport,
|
||||
com.ibm.icu,
|
||||
org.apache.commons.io,
|
||||
org.talend.utils,
|
||||
org.eclipse.core.net
|
||||
org.eclipse.core.net,
|
||||
org.eclipse.m2e.core,
|
||||
org.eclipse.m2e.maven.runtime,
|
||||
org.eclipse.core.resources
|
||||
Export-Package: org.talend.commons,
|
||||
org.talend.commons.exception,
|
||||
org.talend.commons.i18n,
|
||||
|
||||
@@ -111,7 +111,8 @@ public class CommonsPlugin implements BundleActivator {
|
||||
}
|
||||
|
||||
public static boolean isDebugMode() {
|
||||
return ArrayUtils.contains(Platform.getApplicationArgs(), TalendDebugHandler.TALEND_DEBUG);
|
||||
return Boolean.getBoolean("talendDebug") //$NON-NLS-1$
|
||||
|| ArrayUtils.contains(Platform.getApplicationArgs(), TalendDebugHandler.TALEND_DEBUG);
|
||||
}
|
||||
|
||||
public static boolean isJUnitTest() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
|
||||
public enum MojoType {
|
||||
|
||||
CI_BUILDER("org.talend.ci", "builder-maven-plugin", "ci.builder.version"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
CLOUD_PUBLISHER("org.talend.ci", "cloudpublisher-maven-plugin", "cloud.publisher.version"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
SIGNER("org.talend.ci", "signer-maven-plugin", "signer.version"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
OSGI_HELPER("org.talend.ci", "osgihelper-maven-plugin", "osgihelper.version"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
private String groupId;
|
||||
|
||||
private String artifactId;
|
||||
|
||||
private String versionKey;
|
||||
|
||||
private MojoType(String groupId, String artifactId, String versionKey) {
|
||||
this.groupId = groupId;
|
||||
this.artifactId = artifactId;
|
||||
this.versionKey = versionKey;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public String getArtifactId() {
|
||||
return artifactId;
|
||||
}
|
||||
|
||||
public String getVersionKey() {
|
||||
return versionKey;
|
||||
}
|
||||
|
||||
public String getMojoArtifactIdFolder() {
|
||||
Path basePath = new File(MavenPlugin.getMaven().getLocalRepositoryPath()).toPath();
|
||||
return basePath.resolve(getGroupId().replaceAll("\\.", "/")).resolve(getArtifactId()).toString(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
public String getMojoGAV() {
|
||||
return getGroupId() + ":" + getArtifactId() + ":" + getVersionKey(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,15 +15,17 @@ package org.talend.commons.utils;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
@@ -230,10 +232,50 @@ public class VersionUtils {
|
||||
* Check if studio version < other studio version record in remote project.
|
||||
*/
|
||||
public static boolean isInvalidProductVersion(String remoteFullProductVersion) {
|
||||
String localProductVersion = getInternalVersion();
|
||||
return isInvalidProductVersion(localProductVersion, remoteFullProductVersion);
|
||||
}
|
||||
|
||||
protected static boolean isInvalidProductVersion(String localProductVersion, String remoteFullProductVersion) {
|
||||
if (remoteFullProductVersion == null) {
|
||||
return false;
|
||||
}
|
||||
return getInternalVersion().compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) < 0;
|
||||
if (skipCheckingNightlyBuilds(localProductVersion, remoteFullProductVersion)) {
|
||||
return false;
|
||||
}
|
||||
return localProductVersion.compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) < 0;
|
||||
}
|
||||
|
||||
public static boolean productVersionIsNewer(String remoteFullProductVersion) {
|
||||
String localProductVersion = getInternalVersion();
|
||||
return productVersionIsNewer(localProductVersion, remoteFullProductVersion);
|
||||
}
|
||||
|
||||
protected static boolean productVersionIsNewer(String localProductVersion, String remoteFullProductVersion) {
|
||||
if (remoteFullProductVersion == null) {
|
||||
return false;
|
||||
}
|
||||
if (skipCheckingNightlyBuilds(localProductVersion, remoteFullProductVersion)) {
|
||||
return false;
|
||||
}
|
||||
return localProductVersion.compareTo(getProductVersionWithoutBranding(remoteFullProductVersion)) > 0;
|
||||
}
|
||||
|
||||
private static boolean skipCheckingNightlyBuilds(String localProductVersion, String remoteFullProductVersion) {
|
||||
String separator = "-"; //$NON-NLS-1$
|
||||
String localSuffix = StringUtils.substringAfterLast(localProductVersion, separator);
|
||||
|
||||
String remoteProductVersion = getProductVersionWithoutBranding(remoteFullProductVersion);
|
||||
String remoteSuffix = StringUtils.substringAfterLast(remoteProductVersion, separator);
|
||||
|
||||
String nightly = "SNAPSHOT"; //$NON-NLS-1$
|
||||
String milestone = "M"; //$NON-NLS-1$
|
||||
if ((localSuffix.equals(nightly) || localSuffix.startsWith(milestone))
|
||||
&& (remoteSuffix.equals(nightly) || remoteSuffix.startsWith(milestone))) {
|
||||
// skip checking between nightly/milestone build.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getTalendVersion(String productVersion) {
|
||||
@@ -262,24 +304,28 @@ public class VersionUtils {
|
||||
return version;
|
||||
}
|
||||
|
||||
public static String getMojoVersion(String mojoKey) {
|
||||
String version = null;
|
||||
public static String getMojoVersion(MojoType mojoType) {
|
||||
String mojoKey = mojoType.getVersionKey();
|
||||
String version = System.getProperty(mojoKey);
|
||||
if (StringUtils.isNotBlank(version)) {
|
||||
return version;
|
||||
}
|
||||
String talendVersion = getTalendVersion();
|
||||
Properties properties = new Properties();
|
||||
File file = new Path(Platform.getConfigurationLocation().getURL().getPath()).append("mojo_version.properties").toFile(); //$NON-NLS-1$
|
||||
if (file.exists()) {
|
||||
try (InputStream inStream = new FileInputStream(file)) {
|
||||
properties.load(inStream);
|
||||
version = properties.getProperty(mojoKey);
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (version != null && !version.startsWith(talendVersion)) {
|
||||
ExceptionHandler
|
||||
.process(new Exception(
|
||||
"Incompatible Mojo version:" + mojoKey + "[" + version + "], use default version.")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
version = null;
|
||||
String majorVersion = StringUtils.substringBeforeLast(talendVersion, "."); //$NON-NLS-1$
|
||||
String artifactIdFolder = mojoType.getMojoArtifactIdFolder();
|
||||
Optional<File> optional = Stream.of(new File(artifactIdFolder).listFiles())
|
||||
.filter(f -> f.isDirectory() && f.getName().startsWith(majorVersion))
|
||||
.sorted((f1, f2) -> new DefaultArtifactVersion(f2.getName()).compareTo(new DefaultArtifactVersion(f1.getName())))
|
||||
.findFirst();
|
||||
if (optional.isPresent()) {
|
||||
File latestArtifact = optional.get();
|
||||
String fileName = mojoType.getArtifactId() + "-" + latestArtifact.getName(); //$NON-NLS-1$
|
||||
if (Stream.of(latestArtifact.listFiles())
|
||||
.filter(f -> f.getName().equals(fileName + ".jar") || f.getName().equals(fileName + ".pom")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
.count() != 2) {
|
||||
ExceptionHandler.process(new Exception("Can't find plugin artifact " + mojoType.getMojoGAV())); //$NON-NLS-1$
|
||||
}
|
||||
version = latestArtifact.getName();
|
||||
}
|
||||
// default version
|
||||
if (StringUtils.isBlank(version)) {
|
||||
@@ -293,6 +339,7 @@ public class VersionUtils {
|
||||
version += "-" + revision; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
System.setProperty(mojoKey, version);
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -302,4 +349,25 @@ public class VersionUtils {
|
||||
talendVersion = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getSimplifiedPatchName(String projectPatchName) {
|
||||
|
||||
if (projectPatchName != null) {
|
||||
String result = null;
|
||||
if (projectPatchName.contains("_") && projectPatchName.split("_").length >= 3) {
|
||||
result = projectPatchName.split("_")[2];
|
||||
if (!result.startsWith("R")) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (projectPatchName.contains("-")) {
|
||||
String[] split = projectPatchName.split("-");
|
||||
if (split != null && split.length > 0) {
|
||||
return result + "-" + split[split.length - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils.network;
|
||||
|
||||
public interface ITalendNexusPrefConstants {
|
||||
|
||||
public static final String NEXUS_TIMEOUT = "NEXUS_TIMEOUT"; //$NON-NLS-1$
|
||||
}
|
||||
@@ -15,6 +15,7 @@ package org.talend.commons.utils.network;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.Authenticator;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.Inet6Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.PasswordAuthentication;
|
||||
@@ -22,10 +23,17 @@ import java.net.SocketException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.runtime.utils.io.FileCopyUtils;
|
||||
|
||||
/**
|
||||
@@ -44,7 +52,17 @@ public class NetworkUtil {
|
||||
|
||||
private static final String HTTP_NETWORK_URL = "https://talend-update.talend.com";
|
||||
|
||||
private static final int DEFAULT_TIMEOUT = 4000;
|
||||
|
||||
private static final int DEFAULT_NEXUS_TIMEOUT = 20000;// same as preference value
|
||||
|
||||
public static final String ORG_TALEND_DESIGNER_CORE = "org.talend.designer.core"; //$NON-NLS-1$
|
||||
|
||||
public static boolean isNetworkValid() {
|
||||
return isNetworkValid(DEFAULT_TIMEOUT);
|
||||
}
|
||||
|
||||
public static boolean isNetworkValid(Integer timeout) {
|
||||
String disableInternet = System.getProperty(TALEND_DISABLE_INTERNET);
|
||||
if ("true".equals(disableInternet)) { //$NON-NLS-1$
|
||||
return false;
|
||||
@@ -55,8 +73,9 @@ public class NetworkUtil {
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setDefaultUseCaches(false);
|
||||
conn.setUseCaches(false);
|
||||
conn.setConnectTimeout(4000);
|
||||
conn.setReadTimeout(4000);
|
||||
int conntimeout = timeout != null ? timeout.intValue() : DEFAULT_TIMEOUT;
|
||||
conn.setConnectTimeout(conntimeout);
|
||||
conn.setReadTimeout(conntimeout);
|
||||
conn.setRequestMethod("HEAD"); //$NON-NLS-1$
|
||||
String strMessage = conn.getResponseMessage();
|
||||
if (strMessage.compareTo("Not Found") == 0) { //$NON-NLS-1$
|
||||
@@ -73,22 +92,23 @@ public class NetworkUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isNetworkValid(String url) {
|
||||
public static boolean isNetworkValid(String url, Integer timeout) {
|
||||
if (url == null) {
|
||||
return isNetworkValid();
|
||||
return isNetworkValid(timeout);
|
||||
}
|
||||
return checkValidWithHttp(url);
|
||||
return checkValidWithHttp(url, timeout);
|
||||
}
|
||||
|
||||
private static boolean checkValidWithHttp(String urlString) {
|
||||
private static boolean checkValidWithHttp(String urlString, Integer timeout) {
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
URL url = new URL(urlString);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setDefaultUseCaches(false);
|
||||
conn.setUseCaches(false);
|
||||
conn.setConnectTimeout(4000);
|
||||
conn.setReadTimeout(4000);
|
||||
int conntimeout = timeout != null ? timeout.intValue() : DEFAULT_TIMEOUT;
|
||||
conn.setConnectTimeout(conntimeout);
|
||||
conn.setReadTimeout(conntimeout);
|
||||
conn.setRequestMethod("HEAD"); //$NON-NLS-1$
|
||||
conn.getResponseMessage();
|
||||
} catch (Exception e) {
|
||||
@@ -101,6 +121,18 @@ public class NetworkUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getNexusTimeout() {
|
||||
int timeout = DEFAULT_NEXUS_TIMEOUT;
|
||||
try {
|
||||
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(ORG_TALEND_DESIGNER_CORE);
|
||||
timeout = node.getInt(ITalendNexusPrefConstants.NEXUS_TIMEOUT, DEFAULT_NEXUS_TIMEOUT);
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public static Authenticator getDefaultAuthenticator() {
|
||||
try {
|
||||
Field theAuthenticatorField = Authenticator.class.getDeclaredField("theAuthenticator");
|
||||
@@ -123,6 +155,28 @@ public class NetworkUtil {
|
||||
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
String httpProxyHost = System.getProperty("http.proxyHost"); //$NON-NLS-1$
|
||||
String httpProxyPort = System.getProperty("http.proxyPort"); //$NON-NLS-1$
|
||||
String httpsProxyHost = System.getProperty("https.proxyHost"); //$NON-NLS-1$
|
||||
String httpsProxyPort = System.getProperty("https.proxyPort"); //$NON-NLS-1$
|
||||
String requestingHost = getRequestingHost();
|
||||
int requestingPort = getRequestingPort();
|
||||
String proxyHost = null;
|
||||
String proxyPort = null;
|
||||
boolean isHttp = false;
|
||||
if ("http".equalsIgnoreCase(getRequestingScheme())) {
|
||||
isHttp = true;
|
||||
}
|
||||
if (isHttp && StringUtils.isNotBlank(httpProxyHost)) {
|
||||
proxyHost = httpProxyHost;
|
||||
proxyPort = httpProxyPort;
|
||||
} else {
|
||||
proxyHost = httpsProxyHost;
|
||||
proxyPort = httpsProxyPort;
|
||||
}
|
||||
if (!StringUtils.equals(proxyHost, requestingHost) || !StringUtils.equals(proxyPort, "" + requestingPort)) {
|
||||
return null;
|
||||
}
|
||||
String httpProxyUser = System.getProperty("http.proxyUser"); //$NON-NLS-1$
|
||||
String httpProxyPassword = System.getProperty("http.proxyPassword"); //$NON-NLS-1$
|
||||
String httpsProxyUser = System.getProperty("https.proxyUser"); //$NON-NLS-1$
|
||||
@@ -140,7 +194,11 @@ public class NetworkUtil {
|
||||
proxyPassword = httpsProxyPassword.toCharArray();
|
||||
}
|
||||
}
|
||||
return new PasswordAuthentication(proxyUser, proxyPassword);
|
||||
if (StringUtils.isBlank(proxyUser)) {
|
||||
return null;
|
||||
} else {
|
||||
return new PasswordAuthentication(proxyUser, proxyPassword);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@@ -179,6 +237,54 @@ public class NetworkUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getLocalLoopbackAddresses(boolean wrapIpV6) {
|
||||
Set<String> addresses = new LinkedHashSet<>();
|
||||
try {
|
||||
addresses.add(getIp(InetAddress.getLoopbackAddress(), wrapIpV6));
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
try {
|
||||
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
while (networkInterfaces.hasMoreElements()) {
|
||||
NetworkInterface networkInterface = networkInterfaces.nextElement();
|
||||
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
|
||||
while (inetAddresses.hasMoreElements()) {
|
||||
InetAddress inetAddress = inetAddresses.nextElement();
|
||||
if (inetAddress != null && inetAddress.isLoopbackAddress()) {
|
||||
addresses.add(getIp(inetAddress, wrapIpV6));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
if (addresses.isEmpty()) {
|
||||
addresses.add("127.0.0.1");
|
||||
String ipv6Loopback = "::1";
|
||||
if (wrapIpV6) {
|
||||
ipv6Loopback = "[" + ipv6Loopback + "]";
|
||||
}
|
||||
addresses.add(ipv6Loopback);
|
||||
}
|
||||
|
||||
return new ArrayList<>(addresses);
|
||||
}
|
||||
|
||||
private static String getIp(InetAddress inetAddress, boolean wrapIpV6) {
|
||||
if (wrapIpV6 && Inet6Address.class.isInstance(inetAddress)) {
|
||||
String addr = inetAddress.getHostAddress();
|
||||
if (!addr.startsWith("[") || !addr.endsWith("]")) {
|
||||
addr = "[" + addr + "]";
|
||||
}
|
||||
return addr;
|
||||
} else {
|
||||
return inetAddress.getHostAddress();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isSelfAddress(String addr) {
|
||||
if (addr == null || addr.isEmpty()) {
|
||||
return false; // ?
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.net.URISyntaxException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -38,6 +39,8 @@ 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.internal.net.ProxyType;
|
||||
import org.eclipse.core.net.proxy.IProxyChangeEvent;
|
||||
import org.eclipse.core.net.proxy.IProxyService;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
@@ -77,6 +80,14 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
private static final String PROP_DISABLE_DEFAULT_SELECTOR_PROVIDER = "talend.studio.proxy.disableDefaultSelectorProvider";
|
||||
|
||||
private static final String PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY = "talend.studio.proxy.excludeLoopbackAutomatically";
|
||||
|
||||
private static final String PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY_DEFAULT = "true";
|
||||
|
||||
private static final String PROP_PROXY_HTTP_NON_PROXYHOSTS = "http.nonProxyHosts";
|
||||
|
||||
private static final String PROP_PROXY_HTTPS_NON_PROXYHOSTS = "https.nonProxyHosts";
|
||||
|
||||
/**
|
||||
* Example: update.talend.com,socket:http,https:http;nexus.talend.com,socket,http;,socket:http
|
||||
*/
|
||||
@@ -104,6 +115,8 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
private EProxySelector eProxySelector;
|
||||
|
||||
private IProxyService proxyManager;
|
||||
|
||||
final private Map<Object, Collection<IProxySelectorProvider>> selectorProviders;
|
||||
|
||||
private Map<String, Map<String, String>> hostMap;
|
||||
@@ -114,6 +127,10 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
private static Object instanceLock = new Object();
|
||||
|
||||
private List<String> localLoopbackAddresses;
|
||||
|
||||
private Object localLoopbackAddressesLock = new Object();
|
||||
|
||||
private boolean printProxyLog = false;
|
||||
|
||||
private boolean allowProxyRedirect = false;
|
||||
@@ -126,6 +143,8 @@ public class TalendProxySelector extends ProxySelector {
|
||||
|
||||
private boolean updateSystemPropertiesForJre = true;
|
||||
|
||||
private boolean excludeLoopbackAddressAutomatically = false;
|
||||
|
||||
private TalendProxySelector(final ProxySelector eclipseDefaultSelector) {
|
||||
this.eclipseDefaultSelector = eclipseDefaultSelector;
|
||||
this.jreDefaultSelector = new DefaultProxySelector();
|
||||
@@ -139,6 +158,8 @@ public class TalendProxySelector extends ProxySelector {
|
||||
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()));
|
||||
excludeLoopbackAddressAutomatically = Boolean.valueOf(System.getProperty(
|
||||
PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY, PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY_DEFAULT));
|
||||
|
||||
switch (System.getProperty(PROP_PROXY_SELECTOR, PROP_PROXY_SELECTOR_DEFAULT).toLowerCase()) {
|
||||
case PROP_PROXY_SELECTOR_JRE:
|
||||
@@ -148,11 +169,83 @@ public class TalendProxySelector extends ProxySelector {
|
||||
this.eProxySelector = EProxySelector.eclipse_default;
|
||||
break;
|
||||
}
|
||||
proxyManager = ProxyManager.getProxyManager();
|
||||
checkProxyManager(IProxyChangeEvent.PROXY_DATA_CHANGED);
|
||||
proxyManager.addProxyChangeListener(event -> checkProxyManager(event.getChangeType()));
|
||||
|
||||
initHostMap();
|
||||
initRedirectList();
|
||||
}
|
||||
|
||||
private void checkProxyManager(int changeEvent) {
|
||||
try {
|
||||
if (IProxyChangeEvent.PROXY_DATA_CHANGED == changeEvent
|
||||
|| IProxyChangeEvent.NONPROXIED_HOSTS_CHANGED == changeEvent) {
|
||||
if (this.excludeLoopbackAddressAutomatically && proxyManager.isProxiesEnabled()) {
|
||||
List<String> addresses = getLocalLoopbackAddresses();
|
||||
if (addresses != null && !addresses.isEmpty()) {
|
||||
if (org.eclipse.core.internal.net.ProxySelector
|
||||
.canSetBypassHosts(org.eclipse.core.internal.net.ProxySelector.getDefaultProvider())) {
|
||||
List<String> configuredProxies = Arrays.asList(proxyManager.getNonProxiedHosts());
|
||||
if (!configuredProxies.containsAll(addresses)) {
|
||||
Set<String> nonProxyHosts = new HashSet<>(addresses);
|
||||
nonProxyHosts.addAll(configuredProxies);
|
||||
ExceptionHandler.log(
|
||||
this.getClass().getName() + ":" + "-D" + PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY
|
||||
+ "=true, adding missing loopback addresses into eclipse nonProxyHosts: "
|
||||
+ nonProxyHosts);
|
||||
proxyManager.setNonProxiedHosts(nonProxyHosts.toArray(new String[0]));
|
||||
}
|
||||
} else {
|
||||
updateNonProxyHosts(addresses, PROP_PROXY_HTTP_NON_PROXYHOSTS);
|
||||
updateNonProxyHosts(addresses, PROP_PROXY_HTTPS_NON_PROXYHOSTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateNonProxyHosts(List<String> localLoopbackAddresses, final String nonProxyProperty) {
|
||||
if (localLoopbackAddresses != null && !localLoopbackAddresses.isEmpty()) {
|
||||
Set<String> nonProxyHosts = new HashSet<>(localLoopbackAddresses);
|
||||
String property = System.getProperty(nonProxyProperty);
|
||||
boolean update = true;
|
||||
if (StringUtils.isNotBlank(property)) {
|
||||
List<String> configuredProxies = Arrays.asList(ProxyType.convertPropertyStringToHosts(property));
|
||||
if (configuredProxies.containsAll(localLoopbackAddresses)) {
|
||||
update = false;
|
||||
} else {
|
||||
nonProxyHosts.addAll(configuredProxies);
|
||||
}
|
||||
}
|
||||
if (update) {
|
||||
ExceptionHandler.log(this.getClass().getName() + ":" + "-D" + PROP_PROXY_EXCLUDE_LOOPBACK_ADDRESS_AUTOMATICALLY
|
||||
+ "=true, adding missing loopback addresses into " + nonProxyProperty + ": " + nonProxyHosts);
|
||||
System.setProperty(nonProxyProperty,
|
||||
ProxyType.convertHostsToPropertyString(nonProxyHosts.toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getLocalLoopbackAddresses() {
|
||||
if (this.localLoopbackAddresses == null) {
|
||||
synchronized (localLoopbackAddressesLock) {
|
||||
if (this.localLoopbackAddresses == null) {
|
||||
List<String> addresses = NetworkUtil.getLocalLoopbackAddresses(false);
|
||||
final String localhost = "localhost";
|
||||
if (!addresses.contains(localhost)) {
|
||||
addresses.add(localhost);
|
||||
}
|
||||
this.localLoopbackAddresses = addresses;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.localLoopbackAddresses;
|
||||
}
|
||||
|
||||
private void initHostMap() {
|
||||
try {
|
||||
hostMap = new HashMap<>();
|
||||
@@ -282,7 +375,27 @@ public class TalendProxySelector extends ProxySelector {
|
||||
ExceptionHandler.log("TalendProxySelector.select " + uri);
|
||||
}
|
||||
if (uri == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
List<Proxy> result = new ArrayList<>();
|
||||
result.add(Proxy.NO_PROXY);
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
if (this.excludeLoopbackAddressAutomatically) {
|
||||
List<String> addresses = getLocalLoopbackAddresses();
|
||||
if (addresses != null) {
|
||||
String host = uri.getHost();
|
||||
if (addresses.contains(host)) {
|
||||
if (printProxyLog) {
|
||||
ExceptionHandler.log(uri + " is excluded from proxy");
|
||||
}
|
||||
List<Proxy> result = new ArrayList<>();
|
||||
result.add(Proxy.NO_PROXY);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
URI validatedUri = validateUri(uri);
|
||||
Set<Proxy> results = new LinkedHashSet<>();
|
||||
@@ -332,6 +445,9 @@ public class TalendProxySelector extends ProxySelector {
|
||||
ExceptionHandler.log("Selected proxys for " + uri + ", " + proxys);
|
||||
ExceptionHandler.process(new Exception("Proxy call stacks"), Priority.INFO);
|
||||
}
|
||||
if (results.isEmpty()) {
|
||||
results.add(Proxy.NO_PROXY);
|
||||
}
|
||||
return new LinkedList<Proxy>(results);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,15 +19,18 @@ import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.runtime.service.ITaCoKitService;
|
||||
|
||||
@@ -62,6 +65,10 @@ public class UpdatesHelper {
|
||||
|
||||
public static final String NEW_COMPONENT_PREFIX = "installer$$";
|
||||
|
||||
public static final String PRE_TALEND_PATCH = "talend.patch";
|
||||
|
||||
public static final String RECORD_SEPERATOR = ",";
|
||||
|
||||
public static boolean existArtifacts(File base) {
|
||||
return new File(base, FILE_ARTIFACTS).exists() || new File(base, FILE_JAR_ARTIFACTS).exists()
|
||||
|| new File(base, FILE_XZ_ARTIFACTS).exists();
|
||||
@@ -85,6 +92,9 @@ public class UpdatesHelper {
|
||||
* will check that existed the plugins folder only.
|
||||
*/
|
||||
public static boolean isPlainUpdate(File file) {
|
||||
if (skipPatchFile(file)) {
|
||||
return false;
|
||||
}
|
||||
if (file != null && file.exists()) {
|
||||
if (file.isFile() && file.getName().endsWith(FileExtensions.ZIP_FILE_SUFFIX)) {
|
||||
ZipFileStatus status = new ZipFileStatus(file);
|
||||
@@ -112,6 +122,9 @@ public class UpdatesHelper {
|
||||
* need check that contain "artifacts.xml", "content.xml" and "plugins" folder in same place.
|
||||
*/
|
||||
public static boolean isUpdateSite(File file) {
|
||||
if (skipPatchFile(file)) {
|
||||
return false;
|
||||
}
|
||||
if (file != null && file.exists()) {
|
||||
if (file.isFile() && file.getName().endsWith(FileExtensions.ZIP_FILE_SUFFIX)) {
|
||||
|
||||
@@ -173,7 +186,8 @@ public class UpdatesHelper {
|
||||
}
|
||||
|
||||
private static void findUpdateBaseFile(Set<File> foundUpdateFiles, File baseFile) {
|
||||
if (isPlainUpdate(baseFile) || isUpdateSite(baseFile) && !isComponentUpdateSite(baseFile)) {
|
||||
if (isPlainUpdate(baseFile)
|
||||
|| isUpdateSite(baseFile) && !isComponentUpdateSite(baseFile)) {
|
||||
foundUpdateFiles.add(baseFile);
|
||||
} else if (baseFile.isDirectory()) {
|
||||
final File[] listFiles = baseFile.listFiles();
|
||||
@@ -186,6 +200,10 @@ public class UpdatesHelper {
|
||||
}
|
||||
|
||||
public static boolean isComponentUpdateSite(File file) {
|
||||
|
||||
if (skipPatchFile(file)) {
|
||||
return false;
|
||||
}
|
||||
if (file != null && file.exists()) {
|
||||
if (file.isFile() && file.getName().endsWith(FileExtensions.ZIP_FILE_SUFFIX)) {
|
||||
ZipFileStatus status = new ZipFileStatus(file) {
|
||||
@@ -312,4 +330,53 @@ public class UpdatesHelper {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static File getProductFile() {
|
||||
try {
|
||||
return new File(Platform.getInstallLocation().getDataArea(FILE_ECLIPSE_PRODUCT).getPath());
|
||||
} catch (IOException e) {
|
||||
//
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Properties loadProductProperties(File productFile) {
|
||||
Properties prop = new Properties();
|
||||
if (productFile != null && productFile.exists()) {
|
||||
try (FileInputStream fis = new FileInputStream(productFile)) {
|
||||
prop.load(fis);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return prop;
|
||||
}
|
||||
|
||||
public static Set<String> getPatchesInstalled() {
|
||||
Set<String> installed = new HashSet<String>();
|
||||
File productFile = getProductFile();
|
||||
Properties props = loadProductProperties(productFile);
|
||||
props.forEach((k, v) -> {
|
||||
String key = String.valueOf(k);
|
||||
if (key.startsWith(PRE_TALEND_PATCH)) {
|
||||
String val = String.valueOf(v);
|
||||
String[] vals = val.split(RECORD_SEPERATOR);
|
||||
if (vals.length > 1) {
|
||||
installed.add(vals[1]);
|
||||
} else {
|
||||
installed.add(val);
|
||||
}
|
||||
}
|
||||
});
|
||||
return installed;
|
||||
}
|
||||
|
||||
public static boolean skipPatchFile(File patchFile) {
|
||||
Set<String> installedPathNames = getPatchesInstalled();
|
||||
if (patchFile != null && patchFile.isFile()) {
|
||||
String patchName = FilenameUtils.getBaseName(patchFile.getName());
|
||||
return installedPathNames.contains(patchName);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,11 +49,17 @@ public class EclipseCommandLine {
|
||||
*/
|
||||
static public final String TALEND_PROJECT_TYPE_COMMAND = "-talendProjectType"; //$NON-NLS-1$
|
||||
|
||||
static public final String TALEND_LICENCE_PATH = "talend.licence.path"; //$NON-NLS-1$
|
||||
|
||||
static public final String ARG_TALEND_LICENCE_PATH = "-" + TALEND_LICENCE_PATH; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* for relaunch of the plugins when relaunching the Studio
|
||||
*/
|
||||
static public final String TALEND_RELOAD_COMMAND = "-talendReload"; //$NON-NLS-1$
|
||||
|
||||
static public final String LOGIN_ONLINE_UPDATE = "--loginOnlineUpdate";
|
||||
|
||||
static public final String ARG_TALEND_BUNDLES_CLEANED = "-talend.studio.bundles.cleaned"; //$NON-NLS-1$
|
||||
|
||||
static public final String PROP_TALEND_BUNDLES_DO_CLEAN = "-talend.studio.bundles.doclean"; //$NON-NLS-1$
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils.time;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.log4j.Hierarchy;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.apache.log4j.RollingFileAppender;
|
||||
import org.apache.log4j.spi.LoggerFactory;
|
||||
import org.apache.log4j.spi.RootLogger;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
||||
public class PerformanceLogManager {
|
||||
|
||||
private Hierarchy hierarchy;
|
||||
|
||||
public PerformanceLogManager() {
|
||||
Properties properties = new Properties();
|
||||
properties.put("log4j.rootCategory", ", A1");
|
||||
properties.put("log4j.appender.A1", RollingFileAppender.class.getName());
|
||||
IPath performanceLogPath = Platform.getLogFileLocation().removeLastSegments(1).append("performance.log");
|
||||
properties.put("log4j.appender.A1.File", performanceLogPath.toOSString());
|
||||
properties.put("log4j.appender.A1.MaxBackupIndex", "10");// same as .log's max backup log file count
|
||||
properties.put("log4j.appender.A1.MaxFileSize", "1000000");//1000*1000 byte, same as .log's max file size
|
||||
properties.put("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout");
|
||||
properties.put("log4j.appender.A1.layout.ConversionPattern", "%d %-5p %c %x - %m%n");
|
||||
|
||||
this.hierarchy = new Hierarchy(new RootLogger(Level.INFO));
|
||||
new PropertyConfigurator().doConfigure(properties,hierarchy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this PluginLogManager is disabled for this level.
|
||||
* @param level level value
|
||||
* @return boolean true if it is disabled
|
||||
*/
|
||||
public boolean isDisabled(int level) {
|
||||
return this.hierarchy.isDisabled(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable logging for logging requests with level l or higher.
|
||||
* By default all levels are enabled.
|
||||
* @param level level object
|
||||
*/
|
||||
public void setThreshold(Level level) {
|
||||
this.hierarchy.setThreshold(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* The string version of setThreshold(Level level)
|
||||
* @param level level string
|
||||
*/
|
||||
public void setThreshold(String level) {
|
||||
this.hierarchy.setThreshold(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the repository-wide threshold.
|
||||
* @return Level
|
||||
*/
|
||||
public Level getThreshold() {
|
||||
return this.hierarchy.getThreshold();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new logger instance named as the first parameter
|
||||
* using the default factory. If a logger of that name already exists,
|
||||
* then it will be returned. Otherwise, a new logger will be instantiated
|
||||
* and then linked with its existing ancestors as well as children.
|
||||
* @param name logger name
|
||||
* @return Logger
|
||||
*/
|
||||
public Logger getLogger(String name) {
|
||||
return this.hierarchy.getLogger(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* The same as getLogger(String name) but using a factory instance instead of
|
||||
* a default factory.
|
||||
* @param name logger name
|
||||
* @param factory factory instance
|
||||
* @return Logger
|
||||
*/
|
||||
public Logger getLogger(String name, LoggerFactory factory) {
|
||||
return this.hierarchy.getLogger(name,factory);
|
||||
}
|
||||
|
||||
public Logger getRootLogger() {
|
||||
return this.hierarchy.getRootLogger();
|
||||
}
|
||||
|
||||
public Logger exists(String name) {
|
||||
return this.hierarchy.exists(name);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
this.hierarchy.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the loggers in this manager.
|
||||
* @return Enumeration logger enumeration
|
||||
*/
|
||||
public Enumeration getCurrentLoggers() {
|
||||
return this.hierarchy.getCurrentLoggers();
|
||||
}
|
||||
|
||||
public void resetConfiguration() {
|
||||
this.hierarchy.resetConfiguration();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,371 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils.time;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.talend.commons.exception.CommonExceptionHandler;
|
||||
|
||||
/**
|
||||
* DOC sbliu class global comment. Detailled comment
|
||||
*/
|
||||
public class PerformanceStatisticUtil {
|
||||
|
||||
private static final int MEGABYTE = 1024 * 1024;// MB = 1024*1024 byte
|
||||
|
||||
private static final int KILOBYTE = 1024;// kb=1024 byte
|
||||
|
||||
private static final int numOfBlocks = 256;
|
||||
|
||||
private static final int blockSizeKb = 512;
|
||||
|
||||
private static final String dataFile = "testio.data";
|
||||
|
||||
private static String recordingFileName = "performance_record";
|
||||
|
||||
private static File recordingFile = null;
|
||||
|
||||
private static enum BlockSequence {
|
||||
SEQUENTIAL,
|
||||
RANDOM;
|
||||
}
|
||||
|
||||
public static enum StatisticKeys {
|
||||
|
||||
IO_COUNT("I/O.count"), // io count
|
||||
IO_W_MB_SEC("I/O.write"), // write speed MB
|
||||
IO_R_MB_SEC("I/O.read"), // read speed MB
|
||||
IO_W_AVERAGE_MB_SEC("I/O.write.average"), // average speed of write MB
|
||||
IO_R_AVERAGE_MB_SEC("I/O.read.average"), // average speed of read
|
||||
|
||||
STARTUP_AVERAGE("startup.average"),
|
||||
STARTUP_MAX("startup.max"),
|
||||
STARTUP_COUNT("startup.count");
|
||||
|
||||
private String key;
|
||||
|
||||
StatisticKeys(String _key) {
|
||||
key = _key;
|
||||
}
|
||||
|
||||
public String get() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
public static void recordStartupEpapsedTime(double elapsedTimeInSeconds) {
|
||||
File file = getRecordingFile();
|
||||
|
||||
Properties props = read(file, true);
|
||||
String propCount = props.getProperty(StatisticKeys.STARTUP_COUNT.get(), "0");
|
||||
String propMax = props.getProperty(StatisticKeys.STARTUP_MAX.get(), "0");
|
||||
String propAverage = props.getProperty(StatisticKeys.STARTUP_AVERAGE.get(), "0");
|
||||
|
||||
int iPropCount = Integer.parseInt(propCount);
|
||||
double iPropMax = Double.parseDouble(propMax);
|
||||
double iPropAverage = Double.parseDouble(propAverage);
|
||||
|
||||
iPropMax = iPropMax > elapsedTimeInSeconds ? iPropMax : elapsedTimeInSeconds;
|
||||
iPropAverage = (iPropAverage * iPropCount + elapsedTimeInSeconds) / (iPropCount + 1);
|
||||
iPropCount++;
|
||||
|
||||
props.setProperty(StatisticKeys.STARTUP_COUNT.get(), "" + iPropCount);
|
||||
props.setProperty(StatisticKeys.STARTUP_MAX.get(), "" + iPropMax);
|
||||
props.setProperty(StatisticKeys.STARTUP_AVERAGE.get(), "" + iPropAverage);
|
||||
|
||||
store(file, props);
|
||||
}
|
||||
|
||||
public static File getRecordingFile() {
|
||||
if (recordingFile != null) {
|
||||
return recordingFile;
|
||||
}
|
||||
|
||||
String configurationLocation = Platform.getConfigurationLocation().getURL().getPath();
|
||||
File file = new File(configurationLocation + "/" + recordingFileName);
|
||||
return file;
|
||||
}
|
||||
|
||||
public static void setRecordingFile(File _recordingFile) {
|
||||
recordingFile = _recordingFile;
|
||||
}
|
||||
|
||||
public static synchronized Properties read(File recordFile, boolean createIfNotExist) {
|
||||
Properties props = new Properties();
|
||||
if (recordFile != null && exist(recordFile, createIfNotExist)) {
|
||||
FileInputStream inStream = null;
|
||||
try {
|
||||
inStream = new FileInputStream(recordFile);
|
||||
props.load(inStream);
|
||||
} catch (Exception e) {
|
||||
CommonExceptionHandler.log(e.getMessage());
|
||||
} finally {
|
||||
if (inStream != null) {
|
||||
try {
|
||||
inStream.close();
|
||||
} catch (IOException e) {//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
public static synchronized void store(File recordFile, Properties props) {
|
||||
if (props == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (recordFile != null && exist(recordFile, true)) {
|
||||
FileOutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new FileOutputStream(recordFile);
|
||||
props.store(outputStream, "");
|
||||
} catch (IOException e) {
|
||||
CommonExceptionHandler.log(e.getMessage());
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean exist(File recordFile, boolean createIfNotExist) {
|
||||
boolean exists = recordFile.exists();
|
||||
if (!exists && createIfNotExist) {
|
||||
try {
|
||||
exists = recordFile.createNewFile();
|
||||
if (!exists) {
|
||||
throw new FileNotFoundException(recordFile.getName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CommonExceptionHandler.log(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
private static Lock lock = new ReentrantLock();
|
||||
private static Condition condition = lock.newCondition();
|
||||
private static boolean measureIOFinished = true;
|
||||
|
||||
public static void waitUntilFinish() throws InterruptedException {
|
||||
lock.lock();
|
||||
|
||||
try {
|
||||
if(!measureIOFinished) {
|
||||
condition.await(20, TimeUnit.SECONDS);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static void measureIO() {
|
||||
new Thread() {
|
||||
public void run() {
|
||||
measureIOFinished = false;
|
||||
try {
|
||||
_measureIO();
|
||||
} finally {
|
||||
measureIOFinished = true;
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
private static void _measureIO() {
|
||||
File file = getRecordingFile();
|
||||
Properties props = read(file, true);
|
||||
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
File workspace = root.getLocation().makeAbsolute().toFile();
|
||||
File locationDir = new File(workspace, "temp"); // here is workspace/temp dir
|
||||
File testFile = detectTestDataFile(locationDir);
|
||||
|
||||
if (testFile != null) {
|
||||
measureWrite(props, testFile);
|
||||
measureRead(props, testFile);
|
||||
|
||||
store(file, props);
|
||||
}
|
||||
}
|
||||
|
||||
private static void measureWrite(Properties props, File testFile) {
|
||||
int blockSize = blockSizeKb * KILOBYTE;
|
||||
|
||||
long startTime = System.nanoTime();
|
||||
long totalBytesWrittenInMark = writeIO(numOfBlocks, BlockSequence.RANDOM, blockSize, testFile);
|
||||
totalBytesWrittenInMark = totalBytesWrittenInMark + writeIO(numOfBlocks, BlockSequence.SEQUENTIAL, blockSize, testFile);
|
||||
long endTime = System.nanoTime();
|
||||
|
||||
long elapsedTimeNs = endTime - startTime;
|
||||
double sec = (double) elapsedTimeNs / (double) 1000000000;
|
||||
double mbWritten = (double) totalBytesWrittenInMark / (double) MEGABYTE;
|
||||
double bwMbSec = mbWritten / sec;
|
||||
|
||||
String ioCount = props.getProperty(StatisticKeys.IO_COUNT.get(), "0");
|
||||
String ioWAverageMbSec = props.getProperty(StatisticKeys.IO_W_AVERAGE_MB_SEC.get(), "0");
|
||||
String ioWMbSec = props.getProperty(StatisticKeys.IO_W_MB_SEC.get(), "0");
|
||||
|
||||
int digital_ioCount = Integer.parseInt(ioCount);
|
||||
double digital_ioWAverageMbSec = Double.parseDouble(ioWAverageMbSec);
|
||||
double digital_ioWMbSec = Double.parseDouble(ioWMbSec);
|
||||
|
||||
digital_ioWAverageMbSec = (digital_ioWAverageMbSec * digital_ioCount + bwMbSec) / (digital_ioCount + 1);
|
||||
digital_ioWMbSec = bwMbSec;
|
||||
|
||||
props.setProperty(StatisticKeys.IO_W_AVERAGE_MB_SEC.get(), format(digital_ioWAverageMbSec));
|
||||
props.setProperty(StatisticKeys.IO_W_MB_SEC.get(), format(digital_ioWMbSec));
|
||||
}
|
||||
|
||||
private static long writeIO(int numOfBlocks, BlockSequence blockSequence, int blockSize, File testFile) {
|
||||
byte[] blockArr = new byte[blockSize];
|
||||
for (int b = 0; b < blockArr.length; b++) {
|
||||
if (b % 2 == 0) {
|
||||
blockArr[b] = (byte) 0xFF;
|
||||
}
|
||||
}
|
||||
String mode = "rwd";// "rwd"
|
||||
|
||||
long totalBytesWrittenInMark = 0;
|
||||
try {
|
||||
try (RandomAccessFile rAccFile = new RandomAccessFile(testFile, mode)) {
|
||||
for (int b = 0; b < numOfBlocks; b++) {
|
||||
if (blockSequence == BlockSequence.RANDOM) {
|
||||
int rLoc = randInt(0, numOfBlocks - 1);
|
||||
rAccFile.seek(rLoc * blockSize);
|
||||
} else {
|
||||
rAccFile.seek(b * blockSize);
|
||||
}
|
||||
rAccFile.write(blockArr, 0, blockSize);
|
||||
totalBytesWrittenInMark += blockSize;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
CommonExceptionHandler.log(e.getMessage());
|
||||
}
|
||||
|
||||
return totalBytesWrittenInMark;
|
||||
}
|
||||
|
||||
private static File detectTestDataFile(File location) {
|
||||
if (!location.exists()) {
|
||||
location.mkdirs();
|
||||
}
|
||||
|
||||
File testFile = null;
|
||||
try {
|
||||
testFile = new File(location.getAbsolutePath() + File.separator + dataFile);
|
||||
testFile.deleteOnExit();
|
||||
testFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
CommonExceptionHandler.log(e.getMessage());
|
||||
}
|
||||
|
||||
return testFile;
|
||||
}
|
||||
|
||||
public static void measureRead(Properties props, File testFile) {
|
||||
int blockSize = blockSizeKb * KILOBYTE;
|
||||
|
||||
long startTime = System.nanoTime();
|
||||
long totalBytesReadInMark = readIO(numOfBlocks, BlockSequence.RANDOM, blockSize, testFile);
|
||||
totalBytesReadInMark = totalBytesReadInMark + readIO(numOfBlocks, BlockSequence.SEQUENTIAL, blockSize, testFile);
|
||||
long endTime = System.nanoTime();
|
||||
long elapsedTimeNs = endTime - startTime;
|
||||
double sec = (double) elapsedTimeNs / (double) 1000000000;
|
||||
double mbRead = (double) totalBytesReadInMark / (double) MEGABYTE;
|
||||
double bwMbSec = mbRead / sec;
|
||||
|
||||
String ioCount = props.getProperty(StatisticKeys.IO_COUNT.get(), "0");
|
||||
String ioRAverageMbSec = props.getProperty(StatisticKeys.IO_R_AVERAGE_MB_SEC.get(), "0");
|
||||
String ioRMbSec = props.getProperty(StatisticKeys.IO_R_MB_SEC.get(), "0");
|
||||
|
||||
int digital_ioCount = Integer.parseInt(ioCount);
|
||||
double digital_ioRAverageMbSec = Double.parseDouble(ioRAverageMbSec);
|
||||
double digital_ioRMbSec = Double.parseDouble(ioRMbSec);
|
||||
digital_ioRAverageMbSec = (digital_ioRAverageMbSec * digital_ioCount + bwMbSec) / (digital_ioCount + 1);
|
||||
digital_ioRMbSec = bwMbSec;
|
||||
digital_ioCount++;
|
||||
|
||||
props.setProperty(StatisticKeys.IO_R_AVERAGE_MB_SEC.get(), format(digital_ioRAverageMbSec));
|
||||
props.setProperty(StatisticKeys.IO_R_MB_SEC.get(), format(digital_ioRMbSec));
|
||||
props.setProperty(StatisticKeys.IO_COUNT.get(), "" + digital_ioCount);
|
||||
}
|
||||
|
||||
public static String format(double dvalue) {
|
||||
return BigDecimal.valueOf(dvalue).setScale(2, RoundingMode.HALF_UP).toString();
|
||||
}
|
||||
|
||||
private static long readIO(int numOfBlocks, BlockSequence blockSequence, int blockSize, File testFile) {
|
||||
long totalBytesReadInMark = 0;
|
||||
|
||||
byte[] blockArr = new byte[blockSize];
|
||||
for (int b = 0; b < blockArr.length; b++) {
|
||||
if (b % 2 == 0) {
|
||||
blockArr[b] = (byte) 0xFF;
|
||||
}
|
||||
}
|
||||
try {
|
||||
try (RandomAccessFile rAccFile = new RandomAccessFile(testFile, "r")) {
|
||||
for (int b = 0; b < numOfBlocks; b++) {
|
||||
if (blockSequence == BlockSequence.RANDOM) {
|
||||
int rLoc = randInt(0, numOfBlocks - 1);
|
||||
rAccFile.seek(rLoc * blockSize);
|
||||
} else {
|
||||
rAccFile.seek(b * blockSize);
|
||||
}
|
||||
rAccFile.readFully(blockArr, 0, blockSize);
|
||||
totalBytesReadInMark += blockSize;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
CommonExceptionHandler.log(e.getMessage());
|
||||
}
|
||||
return totalBytesReadInMark;
|
||||
}
|
||||
|
||||
private static int randInt(int min, int max) {
|
||||
// nextInt is normally exclusive of the top value,
|
||||
// so add 1 to make it inclusive
|
||||
int randomNum = new Random().nextInt((max - min) + 1) + min;
|
||||
|
||||
return randomNum;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.utils.time;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* DOC sbliu class global comment. Detailled comment
|
||||
*/
|
||||
public class TimeMeasurePerformance extends TimeMeasure{
|
||||
static private Logger logger;
|
||||
|
||||
private static HashMap<String, TimeStack> timers;
|
||||
|
||||
private static long startTime = -1L;
|
||||
|
||||
private static int indent = 0;
|
||||
|
||||
public static void begin(String idTimer, String description) {
|
||||
startTime = System.nanoTime();
|
||||
|
||||
init();
|
||||
if (timers.containsKey(idTimer)) {
|
||||
log(indent(indent) + "Warning (start): timer " + idTimer + " already exists"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else {
|
||||
indent++;
|
||||
TimeStack times = new TimeStack();
|
||||
timers.put(idTimer, times);
|
||||
|
||||
String message = "Start '" + idTimer + "' ...";
|
||||
if (description != null) {
|
||||
message = "Start '" + idTimer + "', " + description + " ...";
|
||||
}
|
||||
log(indent(indent) + message); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
private static void init() {
|
||||
if (timers == null) {
|
||||
timers = new HashMap<String, TimeStack>();
|
||||
}
|
||||
|
||||
if(logger == null) {
|
||||
configureLogger();
|
||||
}
|
||||
}
|
||||
|
||||
private static void log (String message) {
|
||||
logger.info(message);
|
||||
}
|
||||
|
||||
public static long end(String idTimer) {
|
||||
init();
|
||||
if (!timers.containsKey(idTimer)) {
|
||||
log(indent(indent) + "Warning (end): timer " + idTimer + " doesn't exist"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return -1;
|
||||
} else {
|
||||
TimeStack timeStack = timers.get(idTimer);
|
||||
timers.remove(idTimer);
|
||||
long elapsedTimeSinceLastRequest = timeStack.getLastStepElapsedTime();
|
||||
log(indent(indent) + "End '" + idTimer + "', elapsed time since last request: " //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ elapsedTimeSinceLastRequest + " ms "); //$NON-NLS-1$
|
||||
|
||||
long totalElapsedTime = timeStack.getTotalElapsedTime();
|
||||
|
||||
log(indent(indent) + "End '" + idTimer + "', total elapsed time: " + totalElapsedTime + " ms "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
indent--;
|
||||
return totalElapsedTime;
|
||||
}
|
||||
}
|
||||
|
||||
public static long step(String idTimer, String stepName) {
|
||||
init();
|
||||
if (!timers.containsKey(idTimer)) {
|
||||
log(indent(indent) + "Warning (end): timer " + idTimer + " does'nt exist"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
return -1;
|
||||
} else {
|
||||
TimeStack timeStack = timers.get(idTimer);
|
||||
timeStack.addStep();
|
||||
/*
|
||||
* trace the timeline of every step,problem is that the code below " Calendar ca = Calendar.getInstance();
|
||||
* Date now = ca.getTime();" will cost almost 13ms~15ms
|
||||
*/
|
||||
long time = timeStack.getLastStepElapsedTime();
|
||||
String timerStepName = idTimer + "', step name '" + stepName; //$NON-NLS-1$
|
||||
|
||||
log(indent(indent)
|
||||
+ "-> '" + timerStepName + "', elapsed time since previous step: " + time + " ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
return time;
|
||||
}
|
||||
}
|
||||
|
||||
private static void configureLogger() {
|
||||
try {
|
||||
PerformanceLogManager logManager = new PerformanceLogManager();
|
||||
logger = logManager.getLogger(TimeMeasurePerformance.class.getName());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error while initializing log properties.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void afterStartup() {
|
||||
double elapsedTimeInSeconds = (double)(System.nanoTime() - startTime)/1000000000;
|
||||
PerformanceStatisticUtil.recordStartupEpapsedTime(elapsedTimeInSeconds);
|
||||
PerformanceStatisticUtil.measureIO();
|
||||
}
|
||||
}
|
||||
@@ -212,4 +212,8 @@ public class CommonTextCellEditorWithProposal {
|
||||
return this.contentProposalAdapter;
|
||||
}
|
||||
|
||||
public int getPreviousActivatedIndex() {
|
||||
return previousActivatedIndex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -97,4 +97,7 @@ public class ExtendedTextCellEditorWithProposal extends ExtendedTextCellEditor i
|
||||
super.fireCancelEditor();
|
||||
}
|
||||
|
||||
public CommonTextCellEditorWithProposal getCommonTextEditor() {
|
||||
return commonTextEditor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ public class JobAndNodesParametersRelationshipHandler implements IItemRelationsh
|
||||
}
|
||||
}
|
||||
}
|
||||
relationsMap.values().removeIf(value -> value.isEmpty());
|
||||
return relationsMap;
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.talend.core.repository.handlers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.talend.core.model.properties.Item;
|
||||
@@ -43,8 +44,13 @@ public class JobRoutinesItemRelationshipHandler extends AbstractJobItemRelations
|
||||
Set<Relation> relationSet = new HashSet<Relation>();
|
||||
|
||||
if (processType.getParameters() != null && processType.getParameters().getRoutinesParameter() != null) {
|
||||
Map<String, String> currentSystemRoutinesMap = RelationshipItemBuilder.getInstance().getCurrentSystemRoutinesMap();
|
||||
for (Object o : processType.getParameters().getRoutinesParameter()) {
|
||||
RoutinesParameterType itemInfor = (RoutinesParameterType) o;
|
||||
if (currentSystemRoutinesMap.containsValue(itemInfor.getName())) {
|
||||
// exclude system routines relation
|
||||
continue;
|
||||
}
|
||||
|
||||
Relation addedRelation = new Relation();
|
||||
addedRelation.setId(itemInfor.getName());
|
||||
|
||||
@@ -67,4 +67,9 @@ public class SyncLibrariesLoginTask extends AbstractLoginTask implements IRunnab
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiredAlways() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -837,8 +837,8 @@ public abstract class AbstractEMFRepositoryFactory extends AbstractRepositoryFac
|
||||
Object fullFolder = getFullFolder(project, type, relativeFolder);
|
||||
serializableAllVersion = getSerializableFromFolder(project, fullFolder, id, type, false, false, true, true);
|
||||
if (serializableAllVersion.isEmpty()) {
|
||||
// look in all folders
|
||||
serializableAllVersion = getSerializable(project, id, false, false);
|
||||
// look in all folders for this item type
|
||||
serializableAllVersion = getSerializableFromFolder(project, fullFolder, id, type, false, true, true, true, true);
|
||||
}
|
||||
int size = serializableAllVersion.size();
|
||||
|
||||
|
||||
@@ -270,6 +270,8 @@ public interface IRepositoryFactory {
|
||||
|
||||
public void create(Project project, Item item, IPath path, boolean... isImportItem) throws PersistenceException;
|
||||
|
||||
public void save(Project project, Item item, boolean isMigrationTask) throws PersistenceException;
|
||||
|
||||
public void save(Project project, Item item) throws PersistenceException;
|
||||
|
||||
public void save(Project project, Property property) throws PersistenceException;
|
||||
|
||||
@@ -1064,6 +1064,9 @@ public class ProjectRepositoryNode extends RepositoryNode implements IProjectRep
|
||||
}
|
||||
if (newProject != null && newProject.getEmfProject() != null) {
|
||||
List<FolderItem> folderItems = ProjectManager.getInstance().getFolders(newProject.getEmfProject());
|
||||
if (folderItems != null) {
|
||||
folderItems = new ArrayList<>(folderItems);
|
||||
}
|
||||
for (FolderItem folder : folderItems) {
|
||||
String folderName = folder.getProperty().getLabel();
|
||||
if (("process".equals(folderName) || "joblets".equals(folderName)) && folder.getChildren() != null
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.core.repository.model;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -71,7 +72,7 @@ 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.time.TimeMeasurePerformance;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.AbstractDQModelService;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
@@ -84,6 +85,7 @@ import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.exception.TalendInternalPersistenceException;
|
||||
import org.talend.core.hadoop.BigDataBasicUtil;
|
||||
import org.talend.core.model.general.ILibrariesService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
@@ -108,6 +110,7 @@ import org.talend.core.model.properties.SpagoBiServer;
|
||||
import org.talend.core.model.properties.Status;
|
||||
import org.talend.core.model.properties.User;
|
||||
import org.talend.core.model.properties.impl.FolderItemImpl;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.Folder;
|
||||
import org.talend.core.model.repository.IRepositoryContentHandler;
|
||||
@@ -123,16 +126,21 @@ import org.talend.core.repository.constants.Constant;
|
||||
import org.talend.core.repository.constants.FileConstants;
|
||||
import org.talend.core.repository.i18n.Messages;
|
||||
import org.talend.core.repository.recyclebin.RecycleBinManager;
|
||||
import org.talend.core.repository.utils.LoginTaskRegistryReader;
|
||||
import org.talend.core.repository.utils.ProjectDataJsonProvider;
|
||||
import org.talend.core.repository.utils.RepositoryPathProvider;
|
||||
import org.talend.core.repository.utils.XmiResourceManager;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.repository.item.ItemProductKeys;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.runtime.services.IMavenUIService;
|
||||
import org.talend.core.runtime.util.ItemDateParser;
|
||||
import org.talend.core.service.ICoreUIService;
|
||||
import org.talend.core.service.IUpdateService;
|
||||
import org.talend.cwm.helper.SubItemHelper;
|
||||
import org.talend.cwm.helper.TableHelper;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.login.ILoginTask;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.ReferenceProjectProblemManager;
|
||||
import org.talend.repository.ReferenceProjectProvider;
|
||||
@@ -174,6 +182,8 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
|
||||
private boolean isCancelled;
|
||||
|
||||
private static final LoginTaskRegistryReader LOGIN_TASK_REGISTRY_READER = new LoginTaskRegistryReader();
|
||||
|
||||
@Override
|
||||
public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
|
||||
if (l == null) {
|
||||
@@ -223,6 +233,13 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ILibrariesService getLibrariesService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -1210,6 +1227,28 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
return this.repositoryFactoryFromProvider.getLastVersion(project, ProcessUtils.getPureItemId(id), folderPath, type);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IRepositoryViewObject getLastVersion(String id, ERepositoryObjectType type)
|
||||
throws PersistenceException {
|
||||
return getLastVersion(id , "", type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRepositoryViewObject getLastVersion(String id, List<ERepositoryObjectType> types) throws PersistenceException {
|
||||
if (types != null) {
|
||||
IRepositoryViewObject object = null;
|
||||
for (ERepositoryObjectType type : types) {
|
||||
object = getLastVersion(id, type);
|
||||
if (object != null) {
|
||||
return object;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRepositoryViewObject getLastVersion(String id, String folderPath, ERepositoryObjectType type)
|
||||
throws PersistenceException {
|
||||
String objId = id;
|
||||
@@ -1221,7 +1260,25 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
return this.repositoryFactoryFromProvider.getLastVersion(project, objId, folderPath, type);
|
||||
}
|
||||
}
|
||||
return this.repositoryFactoryFromProvider.getLastVersion(projectManager.getCurrentProject(), objId , folderPath, type);
|
||||
return getLastRefVersion(projectManager.getCurrentProject(), objId , folderPath, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRepositoryViewObject getLastRefVersion(Project project, String id, String folderPath, ERepositoryObjectType type) throws PersistenceException {
|
||||
String projectLabel = ProcessUtils.getProjectLabelFromItemId(id);
|
||||
IRepositoryViewObject lastVersion = getLastVersion(project, ProcessUtils.getPureItemId(id), folderPath, type);
|
||||
if (lastVersion == null) {
|
||||
for (Project p : projectManager.getReferencedProjects(project)) {
|
||||
if (projectLabel != null && !projectLabel.equals(p.getTechnicalLabel())) {
|
||||
continue;
|
||||
}
|
||||
lastVersion = getLastRefVersion(p, id);
|
||||
if (lastVersion != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lastVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1543,14 +1600,15 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
|
||||
@Override
|
||||
public void save(Project project, Item item, boolean... isMigrationTask) throws PersistenceException {
|
||||
this.repositoryFactoryFromProvider.save(project, item);
|
||||
if (isMigrationTask == null || isMigrationTask.length == 0 || !isMigrationTask[0]) {
|
||||
this.repositoryFactoryFromProvider.save(project, item);
|
||||
boolean avoidGenerateProm = false;
|
||||
if (isMigrationTask != null && isMigrationTask.length == 2) {
|
||||
avoidGenerateProm = isMigrationTask[1];
|
||||
}
|
||||
fireRepositoryPropertyChange(ERepositoryActionName.SAVE.getName(), avoidGenerateProm, item);
|
||||
|
||||
} else {
|
||||
this.repositoryFactoryFromProvider.save(project, item, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2032,11 +2090,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
*/
|
||||
public void logOnProject(Project project, IProgressMonitor monitor) throws LoginException, PersistenceException {
|
||||
try {
|
||||
TimeMeasure.display = CommonsPlugin.isDebugMode();
|
||||
TimeMeasure.displaySteps = CommonsPlugin.isDebugMode();
|
||||
TimeMeasure.measureActive = CommonsPlugin.isDebugMode();
|
||||
|
||||
TimeMeasure.begin("logOnProject"); //$NON-NLS-1$
|
||||
TimeMeasurePerformance.begin("logOnProject", "logon project name '" + project.getLabel()+"'"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
try {
|
||||
/**
|
||||
* init/check proxy selector, in case default proxy selector is not registed yet
|
||||
@@ -2062,6 +2116,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
SubMonitor subMonitor = SubMonitor.convert(monitor, MAX_TASKS);
|
||||
SubMonitor currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.logonInProgress"), 1); //$NON-NLS-1$
|
||||
|
||||
project.setReferenceProjectProvider(null);
|
||||
getRepositoryContext().setProject(null);
|
||||
initEmfProjectContent();
|
||||
@@ -2079,10 +2134,35 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
this.repositoryFactoryFromProvider.beforeLogon(project);
|
||||
ProjectManager.getInstance().getBeforeLogonRecords().clear();
|
||||
ProjectManager.getInstance().getUpdatedRemoteHandlerRecords().clear();
|
||||
ILibrariesService librariesService = getLibrariesService();
|
||||
if (librariesService != null) {
|
||||
librariesService.setForceReloadCustomUri();
|
||||
}
|
||||
|
||||
ProjectDataJsonProvider.checkAndRectifyRelationShipSetting(project.getEmfProject());
|
||||
|
||||
try {
|
||||
// load additional jdbc
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
service.loadAdditionalJDBC();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// in case, to avoid block logon
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
// init dynamic distirbution after `beforeLogon`, before loading libraries.
|
||||
initDynamicDistribution(monitor);
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUpdateService.class)) {
|
||||
IUpdateService updateService = GlobalServiceRegister.getDefault().getService(IUpdateService.class);
|
||||
updateService.syncComponentM2Jars(currentMonitor);
|
||||
}
|
||||
|
||||
// init sdk component
|
||||
try {
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
@@ -2100,7 +2180,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
// monitorWrap.worked(1);
|
||||
TimeMeasure.step("logOnProject", "beforeLogon"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "beforeLogon"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// Check project compatibility
|
||||
checkProjectCompatibility(project);
|
||||
@@ -2118,7 +2198,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.synchronizeLibraries"), 1); //$NON-NLS-1$
|
||||
coreService.syncLibraries(currentMonitor);
|
||||
TimeMeasure.step("logOnProject", "Sync components libraries"); //$NON-NLS-1$
|
||||
TimeMeasurePerformance.step("logOnProject", "Sync components libraries"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
@@ -2127,7 +2207,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
executeMigrations(project, true, currentMonitor);
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
// monitorWrap.worked(1);
|
||||
TimeMeasure.step("logOnProject", "executeMigrations(beforeLogonTasks)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "executeMigrations(beforeLogonTasks)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.logonInProgress"), 1); //$NON-NLS-1$
|
||||
@@ -2135,7 +2215,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
this.repositoryFactoryFromProvider.logOnProject(project);
|
||||
ProjectManager.getInstance().getLogonRecords().clear();
|
||||
// monitorWrap.worked(1);
|
||||
TimeMeasure.step("logOnProject", "logOnProject"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "logOnProject"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
emptyTempFolder(project);
|
||||
|
||||
@@ -2161,7 +2241,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
executeMigrations(project, false, currentMonitor);
|
||||
ProjectManager.getInstance().getMigrationRecords().clear();
|
||||
TimeMeasure.step("logOnProject", "executeMigrations(afterLogonTasks)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "executeMigrations(afterLogonTasks)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
@@ -2177,12 +2257,12 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
// clean workspace
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.cleanWorkspace"), 1); //$NON-NLS-1$
|
||||
|
||||
TimeMeasure.step("logOnProject", "clean Java project"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "clean Java project"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
if (workspace instanceof Workspace) {
|
||||
((Workspace) workspace).getFileSystemManager().getHistoryStore().clean(currentMonitor);
|
||||
}
|
||||
TimeMeasure.step("logOnProject", "clean workspace history"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "clean workspace history"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
currentMonitor = subMonitor.newChild(1, SubMonitor.SUPPRESS_NONE);
|
||||
currentMonitor.beginTask(Messages.getString("ProxyRepositoryFactory.synch.repo.items"), 1); //$NON-NLS-1$
|
||||
@@ -2208,12 +2288,12 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
if (monitor != null && monitor.isCanceled()) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
TimeMeasure.step("logOnProject", "sync repository (routines/rules/beans)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "sync repository (routines/rules/beans)"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// log4j prefs
|
||||
if (coreUiService != null && coreService != null) {
|
||||
coreService.syncLog4jSettings(null);
|
||||
TimeMeasure.step("logOnProject", "sync log4j"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "sync log4j"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -2222,6 +2302,8 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
// set the project mappings url
|
||||
System.setProperty("talend.mappings.url", url.toString()); // $NON-NLS-1$
|
||||
}
|
||||
// for new added mapping file, sync to project mapping folder
|
||||
MetadataTalendType.syncNewMappingFileToProject();
|
||||
} catch (SystemException e) {
|
||||
// ignore
|
||||
ExceptionHandler.process(e);
|
||||
@@ -2230,7 +2312,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
if (runProcessService != null && !isCommandLineLocalRefProject) {
|
||||
runProcessService.initializeRootPoms(monitor);
|
||||
|
||||
TimeMeasure.step("logOnProject", "install / setup root poms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
TimeMeasurePerformance.step("logOnProject", "install / setup root poms"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
|
||||
ITDQRepositoryService tdqRepositoryService = GlobalServiceRegister.getDefault()
|
||||
@@ -2239,13 +2321,15 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
tdqRepositoryService.initProxyRepository();
|
||||
}
|
||||
}
|
||||
// regenerate relationship index
|
||||
if (project.getEmfProject().getItemsRelations().isEmpty()) {
|
||||
RelationshipItemBuilder.getInstance().buildAndSaveIndex();
|
||||
}
|
||||
|
||||
fullLogonFinished = true;
|
||||
this.repositoryFactoryFromProvider.afterLogon(monitor);
|
||||
} finally {
|
||||
TimeMeasure.end("logOnProject"); //$NON-NLS-1$
|
||||
TimeMeasure.display = false;
|
||||
TimeMeasure.displaySteps = false;
|
||||
TimeMeasure.measureActive = false;
|
||||
TimeMeasurePerformance.end("logOnProject"); //$NON-NLS-1$
|
||||
}
|
||||
String str[] = new String[] { getRepositoryContext().getUser() + "", projectManager.getCurrentProject() + "" }; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
log.info(Messages.getString("ProxyRepositoryFactory.log.loggedOn", str)); //$NON-NLS-1$
|
||||
@@ -2646,4 +2730,13 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
public RepositoryWorkUnit getWorkUnitInProgress() {
|
||||
return repositoryFactoryFromProvider.getWorkUnitInProgress();
|
||||
}
|
||||
|
||||
public void executeRequiredLoginTasks(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
ILoginTask[] allLoginTasks = LOGIN_TASK_REGISTRY_READER.getAllTaskListInstance();
|
||||
for (ILoginTask task : allLoginTasks) {
|
||||
if (task.isRequiredAlways()) {
|
||||
task.run(monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.talend.core.repository.recyclebin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@@ -24,6 +25,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
@@ -106,7 +108,8 @@ public class RecycleBinManager {
|
||||
List<IRepositoryViewObject> deletedObjects = new ArrayList<IRepositoryViewObject>();
|
||||
final EList<TalendItem> deletedItems = projectRecyclebins.get(project.getTechnicalLabel()).getDeletedItems();
|
||||
List<TalendItem> notDeletedItems = new ArrayList<TalendItem>();
|
||||
for (TalendItem deletedItem : deletedItems) {
|
||||
List<TalendItem> dup_deletedItems = new ArrayList<>(deletedItems);
|
||||
for (TalendItem deletedItem : dup_deletedItems) {
|
||||
try {
|
||||
final ERepositoryObjectType type = ERepositoryObjectType.getType(deletedItem.getType());
|
||||
// ignore the generated doc in recycle bin
|
||||
@@ -274,7 +277,40 @@ public class RecycleBinManager {
|
||||
resource = createRecycleBinResource(project);
|
||||
}
|
||||
resource.getContents().clear();
|
||||
recycleBin.setLastUpdate(new Date());
|
||||
EList<String> deletedFolders = recycleBin.getDeletedFolders();
|
||||
if (deletedFolders != null) {
|
||||
List<String> folders = new LinkedList<>(deletedFolders);
|
||||
Collections.sort(folders);
|
||||
deletedFolders.clear();
|
||||
deletedFolders.addAll(folders);
|
||||
}
|
||||
EList<TalendItem> deletedItems = recycleBin.getDeletedItems();
|
||||
if (deletedItems != null) {
|
||||
List<TalendItem> items = new LinkedList<>(deletedItems);
|
||||
items.sort((l, r) -> {
|
||||
if (l == null && r == null) {
|
||||
return 0;
|
||||
} else if (l == null) {
|
||||
return -1;
|
||||
} else if (r == null) {
|
||||
return 1;
|
||||
}
|
||||
int result = StringUtils.compare(l.getType(), r.getType());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
result = StringUtils.compare(l.getPath(), r.getPath());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
return StringUtils.compare(l.getId(), r.getId());
|
||||
});
|
||||
deletedItems.clear();
|
||||
deletedItems.addAll(items);
|
||||
}
|
||||
|
||||
// set date to null to avoid timezone conflict
|
||||
recycleBin.setLastUpdate(null);
|
||||
resource.getContents().add(recycleBin);
|
||||
EmfHelper.saveResource(resource);
|
||||
lastSavedRecycleBinMap.put(recycleBin, EcoreUtil.copy(recycleBin));
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -32,6 +33,7 @@ import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
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.properties.ImplicitContextSettings;
|
||||
@@ -43,6 +45,7 @@ import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.properties.StatAndLogsSettings;
|
||||
import org.talend.core.model.properties.Status;
|
||||
import org.talend.core.model.properties.impl.PropertiesFactoryImpl;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.repository.constants.FileConstants;
|
||||
import org.talend.core.repository.recyclebin.RecycleBinManager;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
@@ -140,9 +143,10 @@ public class ProjectDataJsonProvider {
|
||||
ProjectDataJsonProvider.loadProjectSettings(project, input);
|
||||
}
|
||||
IPath relationShipPath = settingFolderPath.append(FileConstants.RELATIONSHIP_FILE_NAME);
|
||||
input = inputStreamProvider.getStream(relationShipPath);
|
||||
if (input != null) {
|
||||
ProjectDataJsonProvider.loadRelationShips(project, input);
|
||||
try (InputStream is = inputStreamProvider.getStream(relationShipPath)) {
|
||||
if (is != null) {
|
||||
ProjectDataJsonProvider.loadRelationShips(project, is);
|
||||
}
|
||||
}
|
||||
IPath migrationTaskPath = settingFolderPath.append(FileConstants.MIGRATION_TASK_FILE_NAME);
|
||||
input = inputStreamProvider.getStream(migrationTaskPath);
|
||||
@@ -184,10 +188,11 @@ public class ProjectDataJsonProvider {
|
||||
private static void loadRelationShips(Project project, IPath projectFolderPath) throws PersistenceException {
|
||||
File file = getLoadingConfigurationFile(projectFolderPath, FileConstants.RELATIONSHIP_FILE_NAME);
|
||||
if (file != null && file.exists()) {
|
||||
try {
|
||||
loadRelationShips(project, new FileInputStream(file));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new PersistenceException(e);
|
||||
try (FileInputStream fis = new FileInputStream(file)) {
|
||||
loadRelationShips(project, fis);
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,11 +211,72 @@ public class ProjectDataJsonProvider {
|
||||
project.getItemsRelations().add(json.toEmfObject());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkAndRectifyRelationShipSetting(Project project) throws PersistenceException {
|
||||
File file = getSavingConfigurationFile(project.getTechnicalLabel(), FileConstants.RELATIONSHIP_FILE_NAME);
|
||||
if (file == null || !file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<ItemRelationsJson> itemRelationsJsonsList = null;
|
||||
TypeReference<List<ItemRelationsJson>> typeReference = new TypeReference<List<ItemRelationsJson>>() {
|
||||
};
|
||||
FileInputStream input = null;
|
||||
try {
|
||||
input = new FileInputStream(file);
|
||||
itemRelationsJsonsList = new ObjectMapper().readValue(new FileInputStream(file), typeReference);
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
} finally {
|
||||
closeInputStream(input);
|
||||
}
|
||||
|
||||
if (itemRelationsJsonsList == null || itemRelationsJsonsList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> idVersionSet = new HashSet<String>();
|
||||
List<ItemRelationsJson> relationJsonList = new ArrayList<ItemRelationsJson>();
|
||||
Map<String, String> currentSystemRoutinesMap = RelationshipItemBuilder.getInstance().getCurrentSystemRoutinesMap();
|
||||
boolean needModify = false;
|
||||
for (ItemRelationsJson relationJson : itemRelationsJsonsList) {
|
||||
ItemRelationJson baseItem = relationJson.getBaseItem();
|
||||
String idversion = baseItem.getId() + ";" + baseItem.getVersion();
|
||||
if (idVersionSet.contains(idversion)) {
|
||||
// in case duplicate
|
||||
needModify = true;
|
||||
continue;
|
||||
}
|
||||
// remove system routines relation
|
||||
int originalSize = relationJson.getRelatedItems().size();
|
||||
relationJson.getRelatedItems()
|
||||
.removeIf(relatedItem -> RelationshipItemBuilder.ROUTINE_RELATION.equals(relatedItem.getType())
|
||||
&& currentSystemRoutinesMap.containsValue(relatedItem.getId()));
|
||||
if (relationJson.getRelatedItems().size() != originalSize) {
|
||||
needModify = true;
|
||||
}
|
||||
if (!relationJson.getRelatedItems().isEmpty()) {
|
||||
relationJsonList.add(relationJson);
|
||||
}
|
||||
idVersionSet.add(idversion);
|
||||
}
|
||||
|
||||
if (needModify) {
|
||||
// re-load to project
|
||||
if (relationJsonList != null && !relationJsonList.isEmpty()) {
|
||||
project.getItemsRelations().clear();
|
||||
for (ItemRelationsJson json : relationJsonList) {
|
||||
project.getItemsRelations().add(json.toEmfObject());
|
||||
}
|
||||
}
|
||||
// re-save relationship setting json file
|
||||
saveRelationShips(project);
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadMigrationTaskSetting(Project project, IPath projectFolderPath) throws PersistenceException {
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -37,6 +38,7 @@ import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.URI;
|
||||
import org.eclipse.emf.ecore.EObject;
|
||||
import org.eclipse.emf.ecore.resource.Resource;
|
||||
@@ -69,6 +71,7 @@ import org.talend.core.model.properties.ValidationRulesConnectionItem;
|
||||
import org.talend.core.model.properties.helper.ByteArrayResource;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.constants.FileConstants;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.utils.ResourceFilenameHelper.FileName;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
@@ -647,6 +650,23 @@ public class XmiResourceManager {
|
||||
}
|
||||
|
||||
public void saveResource(Resource resource) throws PersistenceException {
|
||||
try {
|
||||
if (resource != null) {
|
||||
Object objectByType = EcoreUtil.getObjectByType(resource.getContents(), PropertiesPackage.eINSTANCE.getProject());
|
||||
if (objectByType != null) {
|
||||
Project project = (Project) objectByType;
|
||||
EList migrationTasks = project.getMigrationTask();
|
||||
if (migrationTasks != null && 1 < migrationTasks.size()) {
|
||||
org.talend.commons.exception.ExceptionHandler.process(new Exception("Bad saving logic for Project"),
|
||||
Priority.WARN);
|
||||
ProxyRepositoryFactory.getInstance().saveProject(new org.talend.core.model.general.Project(project));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
org.talend.commons.exception.ExceptionHandler.process(e);
|
||||
}
|
||||
EmfHelper.saveResource(resource);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<?xml version="1.0"?>
|
||||
<mapping>
|
||||
<dbms product="DATABRICKS_DELTA_LAKE" id="databricks_delta_lake_id" label="Mapping Delta Lake" default="true">
|
||||
<dbTypes>
|
||||
<dbType type="SMALLINT" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="FLOAT" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="DOUBLE" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="BIGINT" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="INT" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="TINYINT" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="STRING" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="DECIMAL" ignoreLen="false" ignorePre="false"/>
|
||||
<dbType type="BOOLEAN" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="STRUCT" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="MAP" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="ARRAY" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="TIMESTAMP" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="DATE" ignoreLen="true" ignorePre="true"/>
|
||||
</dbTypes>
|
||||
|
||||
<language name="java">
|
||||
<talendToDbTypes><!-- Adviced mappings -->
|
||||
<talendType type="id_List"/>
|
||||
<talendType type="id_Boolean">
|
||||
<dbType type="BOOLEAN" default="true"/>
|
||||
</talendType>
|
||||
<talendType type="id_Byte">
|
||||
<dbType type="TINYINT" default="true"/>
|
||||
<dbType type="BIGINT"/>
|
||||
<dbType type="INT"/>
|
||||
<dbType type="SMALLINT"/>
|
||||
</talendType>
|
||||
<talendType type="id_byte[]"/>
|
||||
<talendType type="id_Character">
|
||||
<dbType type="STRING" default="true"/>
|
||||
</talendType>
|
||||
<talendType type="id_Date">
|
||||
<dbType type="TIMESTAMP" default="true"/>
|
||||
<dbType type="DATE"/>
|
||||
</talendType>
|
||||
<talendType type="id_BigDecimal">
|
||||
<dbType type="DECIMAL" default="true"/>
|
||||
<dbType type="BIGINT"/>
|
||||
<dbType type="FLOAT"/>
|
||||
<dbType type="DOUBLE"/>
|
||||
</talendType>
|
||||
<talendType type="id_Double">
|
||||
<dbType type="DOUBLE" default="true" />
|
||||
<dbType type="FLOAT"/>
|
||||
</talendType>
|
||||
<talendType type="id_Float">
|
||||
<dbType type="FLOAT" default="true" />
|
||||
<dbType type="DOUBLE"/>
|
||||
</talendType>
|
||||
<talendType type="id_Integer">
|
||||
<dbType type="INT" default="true" />
|
||||
<dbType type="BIGINT" />
|
||||
</talendType>
|
||||
<talendType type="id_Long">
|
||||
<dbType type="BIGINT" default="true" />
|
||||
</talendType>
|
||||
<talendType type="id_Object">
|
||||
<dbType type="STRUCT" default="true" />
|
||||
<dbType type="MAP" />
|
||||
<dbType type="ARRAY" />
|
||||
</talendType>
|
||||
<talendType type="id_Short">
|
||||
<dbType type="SMALLINT" default="true" />
|
||||
<dbType type="INT" />
|
||||
</talendType>
|
||||
<talendType type="id_String">
|
||||
<dbType type="STRING" default="true"/>
|
||||
</talendType>
|
||||
</talendToDbTypes>
|
||||
<dbToTalendTypes><!-- Adviced mappings -->
|
||||
<dbType type="STRING">
|
||||
<talendType type="id_String" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="BOOLEAN">
|
||||
<talendType type="id_Boolean" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="DOUBLE">
|
||||
<talendType type="id_Double" default="true"/>
|
||||
<talendType type="id_BigDecimal"/>
|
||||
<talendType type="id_Float"/>
|
||||
</dbType>
|
||||
<dbType type="DECIMAL">
|
||||
<talendType type="id_BigDecimal" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="BIGINT">
|
||||
<talendType type="id_Long" default="true"/>
|
||||
<talendType type="id_Integer"/>
|
||||
</dbType>
|
||||
<dbType type="INT">
|
||||
<talendType type="id_Integer" default="true"/>
|
||||
<talendType type="id_Short"/>
|
||||
</dbType>
|
||||
<dbType type="SMALLINT">
|
||||
<talendType type="id_Short" default="true"/>
|
||||
<talendType type="id_Byte"/>
|
||||
</dbType>
|
||||
<dbType type="TINYINT">
|
||||
<talendType type="id_Byte" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="FLOAT">
|
||||
<talendType type="id_Float" default="true"/>
|
||||
<talendType type="id_Double"/>
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="STRUCT">
|
||||
<talendType type="id_Object" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="MAP">
|
||||
<talendType type="id_Object" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="ARRAY">
|
||||
<talendType type="id_Object" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="TIMESTAMP">
|
||||
<talendType type="id_Date" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="DATE">
|
||||
<talendType type="id_Date" default="true"/>
|
||||
</dbType>
|
||||
</dbToTalendTypes>
|
||||
</language>
|
||||
</dbms>
|
||||
</mapping>
|
||||
@@ -40,7 +40,7 @@
|
||||
<dbType type="SET" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIME" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIMESTAMP" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIMESTAMP" ignoreLen="true" ignorePre="false" />
|
||||
<dbType type="TINYBLOB" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TINYINT" ignorePre="true" />
|
||||
<dbType type="TINYINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
<?xml version="1.0"?>
|
||||
<mapping>
|
||||
<dbms product="SINGLESTORE" id="singlestore_id" label="Mapping SingleStore"
|
||||
default="true">
|
||||
<dbTypes>
|
||||
<dbType type="BOOL" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="BOOLEAN" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="BIGINT" ignorePre="true"/>
|
||||
<dbType type="BIGINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="BINARY" ignorePre="true"/>
|
||||
<dbType type="BIT" ignorePre="true" />
|
||||
<dbType type="BLOB" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="CHAR" defaultLength="200" ignorePre="true"/>
|
||||
<dbType type="DATE" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="DATETIME" ignoreLen="true" ignorePre="false" />
|
||||
<dbType type="DECIMAL" defaultLength="20" defaultPrecision="10" preBeforelen="false"/>
|
||||
<dbType type="DOUBLE" defaultLength="20" defaultPrecision="10"/>
|
||||
<dbType type="DOUBLE UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="ENUM" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="FLOAT" defaultPrecision="2"/>
|
||||
<dbType type="FLOAT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="GEOGRAPHY" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="GEOGRAPHYPOINT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="INT" ignorePre="true" />
|
||||
<dbType type="INT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="INTEGER" ignorePre="true" />
|
||||
<dbType type="INTEGER UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="LONGTEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="LONGBLOB" ignoreLen="true" ignorePre="true"/>
|
||||
<dbType type="MEDIUMBLOB" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="MEDIUMINT" ignorePre="true" />
|
||||
<dbType type="MEDIUMINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="MEDIUMTEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="SMALLINT" ignorePre="true" />
|
||||
<dbType type="SMALLINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="SET" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIME" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TIMESTAMP" ignoreLen="true" ignorePre="false" />
|
||||
<dbType type="TINYBLOB" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TINYINT" ignorePre="true" />
|
||||
<dbType type="TINYINT UNSIGNED" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="TINYTEXT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="VARBINARY" ignorePre="true" />
|
||||
<dbType type="VARCHAR" default="true" defaultLength="100" ignorePre="true"/>
|
||||
<dbType type="YEAR" ignorePre="true"/>
|
||||
<dbType type="JSON" ignoreLen="true" ignorePre="true"/>
|
||||
</dbTypes>
|
||||
|
||||
<language name="java">
|
||||
<talendToDbTypes><!-- Adviced mappings -->
|
||||
<talendType type="id_List"/>
|
||||
<talendType type="id_Boolean">
|
||||
<dbType type="BOOL" default="true" />
|
||||
</talendType>
|
||||
<talendType type="id_Byte">
|
||||
<dbType type="TINYINT" default="true" />
|
||||
<dbType type="BIGINT" />
|
||||
<dbType type="INT" />
|
||||
<dbType type="MEDIUMINT" />
|
||||
<dbType type="SMALLINT" />
|
||||
</talendType>
|
||||
<talendType type="id_byte[]">
|
||||
<dbType type="VARBINARY" default="true" />
|
||||
<dbType type="BINARY" />
|
||||
<dbType type="BIT" />
|
||||
<dbType type="BLOB" />
|
||||
<dbType type="LONGBLOB" />
|
||||
<dbType type="MEDIUMBLOB" />
|
||||
<dbType type="TINYBLOB" />
|
||||
</talendType>
|
||||
<talendType type="id_Character">
|
||||
<dbType type="CHAR" default="true" />
|
||||
<dbType type="VARCHAR"/>
|
||||
</talendType>
|
||||
<talendType type="id_Date">
|
||||
<dbType type="DATE" />
|
||||
<dbType type="DATETIME" default="true" />
|
||||
<dbType type="TIME" />
|
||||
<dbType type="YEAR" />
|
||||
<dbType type="TIMESTAMP" />
|
||||
</talendType>
|
||||
<talendType type="id_BigDecimal">
|
||||
<dbType type="DECIMAL" default="true" />
|
||||
<dbType type="FLOAT"/>
|
||||
<dbType type="DOUBLE" />
|
||||
</talendType>
|
||||
<talendType type="id_Double">
|
||||
<dbType type="DOUBLE" default="true" />
|
||||
<dbType type="FLOAT"/>
|
||||
<dbType type="DECIMAL" />
|
||||
</talendType>
|
||||
<talendType type="id_Float">
|
||||
<dbType type="FLOAT" default="true" />
|
||||
<dbType type="DOUBLE"/>
|
||||
<dbType type="DECIMAL" />
|
||||
</talendType>
|
||||
<talendType type="id_Integer">
|
||||
<dbType type="INT" default="true" />
|
||||
<dbType type="BIGINT" />
|
||||
</talendType>
|
||||
<talendType type="id_Long">
|
||||
<dbType type="BIGINT" default="true" />
|
||||
</talendType>
|
||||
<talendType type="id_Object">
|
||||
<dbType type="BLOB" default="true"/>
|
||||
<dbType type="ENUM" />
|
||||
<dbType type="GEOGRAPHY" />
|
||||
<dbType type="GEOGRAPHYPOINT" />
|
||||
<dbType type="MEDIUMINT" />
|
||||
<dbType type="LONGBLOB" />
|
||||
<dbType type="MEDIUMBLOB" />
|
||||
<dbType type="SET" />
|
||||
<dbType type="TINYBLOB" />
|
||||
</talendType>
|
||||
<talendType type="id_Short">
|
||||
<dbType type="SMALLINT" default="true" />
|
||||
<dbType type="INT" />
|
||||
<dbType type="BIGINT"/>
|
||||
<dbType type="MEDIUMINT" />
|
||||
</talendType>
|
||||
<talendType type="id_String">
|
||||
<dbType type="VARCHAR" default="true" />
|
||||
<dbType type="LONGTEXT"/>
|
||||
<dbType type="MEDIUMTEXT" />
|
||||
<dbType type="TEXT" />
|
||||
<dbType type="TINYTEXT" />
|
||||
<dbType type="CHAR" />
|
||||
<dbType type="JSON" />
|
||||
</talendType>
|
||||
</talendToDbTypes>
|
||||
<dbToTalendTypes>
|
||||
<dbType type="BOOL">
|
||||
<talendType type="id_Boolean" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BOOLEAN">
|
||||
<talendType type="id_Boolean" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BIGINT">
|
||||
<talendType type="id_Long" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BINARY">
|
||||
<talendType type="id_byte[]" />
|
||||
<talendType type="id_Boolean" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BIT">
|
||||
<talendType type="id_byte[]" />
|
||||
<talendType type="id_Boolean" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BLOB">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="CHAR">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="DATE">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="DATETIME">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="DECIMAL">
|
||||
<talendType type="id_Float"/>
|
||||
<talendType type="id_Double"/>
|
||||
<talendType type="id_BigDecimal" default="true"/>
|
||||
</dbType>
|
||||
<dbType type="DOUBLE">
|
||||
<talendType type="id_Double" default="true" />
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="ENUM">
|
||||
<talendType type="id_Object" default="true" />
|
||||
</dbType>
|
||||
<dbType type="FLOAT">
|
||||
<talendType type="id_Float" default="true" />
|
||||
<talendType type="id_Double"/>
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="GEOGRAPHY">
|
||||
<talendType type="id_Object" default="true" />
|
||||
</dbType>
|
||||
<dbType type="GEOGRAPHYPOINT">
|
||||
<talendType type="id_Object" default="true" />
|
||||
</dbType>
|
||||
<dbType type="JSON">
|
||||
<talendType type="id_String" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="INT">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long"/>
|
||||
</dbType>
|
||||
<dbType type="INTEGER">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long"/>
|
||||
</dbType>
|
||||
<dbType type="LONGTEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="LONGBLOB">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="MEDIUMBLOB">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="MEDIUMINT">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long"/>
|
||||
</dbType>
|
||||
<dbType type="MEDIUMTEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="SMALLINT">
|
||||
<talendType type="id_Short" default="true" />
|
||||
<talendType type="id_Long"/>
|
||||
<talendType type="id_Integer"/>
|
||||
</dbType>
|
||||
<dbType type="SET">
|
||||
<talendType type="id_Object" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TIME">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TIMESTAMP">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="TINYBLOB">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
<talendType type="id_Object" />
|
||||
</dbType>
|
||||
<dbType type="TINYINT">
|
||||
<talendType type="id_Byte" default="true" />
|
||||
<talendType type="id_Integer"/>
|
||||
<talendType type="id_Long"/>
|
||||
<talendType type="id_Short"/>
|
||||
</dbType>
|
||||
<dbType type="TINYTEXT">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="VARBINARY">
|
||||
<talendType type="id_byte[]" default="true" />
|
||||
</dbType>
|
||||
<dbType type="VARCHAR">
|
||||
<talendType type="id_String" default="true" />
|
||||
</dbType>
|
||||
<dbType type="YEAR">
|
||||
<talendType type="id_Date" default="true" />
|
||||
</dbType>
|
||||
<dbType type="BIGINT UNSIGNED" >
|
||||
</dbType>
|
||||
<dbType type="DOUBLE UNSIGNED" >
|
||||
<talendType type="id_Double" default="true" />
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="FLOAT UNSIGNED" >
|
||||
<talendType type="id_Double" default="true" />
|
||||
<talendType type="id_BigDecimal"/>
|
||||
</dbType>
|
||||
<dbType type="INT UNSIGNED" >
|
||||
<talendType type="id_Long" default="true" />
|
||||
</dbType>
|
||||
<dbType type="INTEGER UNSIGNED" >
|
||||
<talendType type="id_Long" default="true" />
|
||||
</dbType>
|
||||
<dbType type="MEDIUMINT UNSIGNED" >
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long" />
|
||||
</dbType>
|
||||
<dbType type="SMALLINT UNSIGNED" >
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Long" />
|
||||
</dbType>
|
||||
<dbType type="TINYINT UNSIGNED" >
|
||||
<talendType type="id_Short" default="true" />
|
||||
<talendType type="id_Integer" />
|
||||
<talendType type="id_Long" />
|
||||
</dbType>
|
||||
</dbToTalendTypes>
|
||||
</language>
|
||||
</dbms>
|
||||
|
||||
</mapping>
|
||||
@@ -9,13 +9,14 @@
|
||||
<dbType type="CHAR" defaultLength="50" ignorePre="true"/>
|
||||
<dbType type="CHARACTER" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="CHARACTER VARYING" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="DATE" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="DATE" ignoreLen="true" ignorePre="true" defaultPattern="dd-MM-yyyy" />
|
||||
<dbType type="DATETIME" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="DECIMAL" defaultLength="20" defaultPrecision="10" />
|
||||
<dbType type="DOUBLE PRECISION" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="UNSIGNED INT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="FLOAT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="INT" ignoreLen="true" ignorePre="true" />
|
||||
<dbType type="INTEGER" defaultLength="10" ignorePre="false" />
|
||||
<dbType type="NUMERIC" defaultLength="20" defaultPrecision="10"/>
|
||||
<dbType type="REAL" />
|
||||
<dbType type="SMALLINT" ignoreLen="true" ignorePre="true" />
|
||||
@@ -175,6 +176,11 @@
|
||||
<talendType type="id_Short"/>
|
||||
<talendType type="id_Long"/>
|
||||
</dbType>
|
||||
<dbType type="INTEGER">
|
||||
<talendType type="id_Integer" default="true" />
|
||||
<talendType type="id_Short"/>
|
||||
<talendType type="id_Long"/>
|
||||
</dbType>
|
||||
<dbType type="NUMERIC">
|
||||
<talendType type="id_Double"/>
|
||||
<talendType type="id_Float"/>
|
||||
|
||||
@@ -100,6 +100,11 @@
|
||||
<xs:restriction base="xs:short"/>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="defaultPattern">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string"/>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="default" type="xs:boolean"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -66,4 +66,16 @@
|
||||
serviceId="IRepositoryContextUpdateService">
|
||||
</Service>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.talend.core.runtime.saveItemContextLinkService">
|
||||
<creator
|
||||
class="org.talend.core.model.context.link.ProcessItemContextLinkService">
|
||||
</creator>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.talend.core.runtime.saveItemContextLinkService">
|
||||
<creator
|
||||
class="org.talend.core.model.context.link.ConnectionItemContextLinkService">
|
||||
</creator>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
||||
@@ -42,6 +42,7 @@ import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
@@ -50,11 +51,16 @@ import org.eclipse.core.resources.IContainer;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.talend.commons.exception.CommonExceptionHandler;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
@@ -1173,4 +1179,33 @@ public class FilesUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void executeFolderAction(IProgressMonitor monitor, IResource parentFolder, IWorkspaceRunnable run)
|
||||
throws CoreException {
|
||||
if (Job.getJobManager().currentRule() == null) {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
ISchedulingRule defaultRule = workspace.getRuleFactory().modifyRule(parentFolder);
|
||||
ISchedulingRule noBlockRule = new ISchedulingRule() {
|
||||
|
||||
@Override
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
return this.contains(rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
if (this.equals(rule)) {
|
||||
return true;
|
||||
}
|
||||
if (defaultRule.contains(rule)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
workspace.run(run, noBlockRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} else {
|
||||
run.run(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -214,5 +214,5 @@ public interface ITDQRepositoryService extends IService {
|
||||
/**
|
||||
* @param chooseContext the context name which want to swtich
|
||||
*/
|
||||
void popupSwitchContextFailedMessage(String chooseContext);
|
||||
boolean popupSwitchContextFailedMessage(String chooseContext);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.runtime.hd.hive.HiveMetadataHelper;
|
||||
|
||||
/**
|
||||
* DOC hzhao class global comment. Detailled comment
|
||||
*/
|
||||
public enum EImpalaDriver {
|
||||
|
||||
HIVE2("HIVE2", "HIVE2", "org.apache.hive.jdbc.HiveDriver"),
|
||||
IMPALA40("IMPALA40", "IMPALA40", "com.cloudera.impala.jdbc4.Driver"),
|
||||
IMPALA41("IMPALA41", "IMPALA41", "com.cloudera.impala.jdbc41.Driver");
|
||||
|
||||
EImpalaDriver(String displayName, String name, String driver) {
|
||||
this.displayName = displayName;
|
||||
this.name = name;
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
private String displayName;
|
||||
|
||||
private String name;
|
||||
|
||||
private String driver;
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public static boolean isSupport(String distribution, String version, boolean byDisplay, String supportMethodName) {
|
||||
return HiveMetadataHelper.doSupportMethod(distribution, version, byDisplay, supportMethodName);
|
||||
}
|
||||
|
||||
public static String[] getImpalaDriverDisplay(String distribution, String version, boolean byDisplay) {
|
||||
List<String> list = new ArrayList<>(0);
|
||||
for (EImpalaDriver driver : EImpalaDriver.values()) {
|
||||
if (isSupport(distribution, version, byDisplay, "doSupportImpalaConnector")) {
|
||||
list.add(driver.getDisplayName());
|
||||
}
|
||||
}
|
||||
return list.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static EImpalaDriver getByDisplay(String display) {
|
||||
for (EImpalaDriver driver : EImpalaDriver.values()) {
|
||||
if (driver.getDisplayName().equals(display)) {
|
||||
return driver;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EImpalaDriver getByName(String name) {
|
||||
for (EImpalaDriver driver : EImpalaDriver.values()) {
|
||||
if (driver.getName().equals(name)) {
|
||||
return driver;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -186,6 +186,10 @@ public class ConnParameterKeys {
|
||||
|
||||
public static final String CONN_PARA_KEY_HDI_PASSWORD = "CONN_PARA_KEY_HDI_PASSWORD"; //$NON-NLS-1$
|
||||
|
||||
public static final String CONN_PARA_KEY_AZURE_HDINSIGHT_STORAGE = "CONN_PARA_KEY_AZURE_HDINSIGHT_STORAGE"; //$NON-NLS-1$
|
||||
|
||||
public static final String CONN_PARA_KEY_AZURE_HDINSIGHT_STORAGE_USE_TLS = "CONN_PARA_KEY_AZURE_HDINSIGHT_STORAGE_USE_TLS"; //$NON-NLS-1$
|
||||
|
||||
public static final String CONN_PARA_KEY_AZURE_HOSTNAME = "CONN_PARA_KEY_AZURE_HOSTNAME"; //$NON-NLS-1$
|
||||
|
||||
public static final String CONN_PARA_KEY_AZURE_CONTAINER = "CONN_PARA_KEY_AZURE_CONTAINER"; //$NON-NLS-1$
|
||||
@@ -263,6 +267,8 @@ public class ConnParameterKeys {
|
||||
|
||||
public static final String IMPALA_AUTHENTICATION_PRINCIPLA = "IMPALA_AUTHENTICATION_PRINCIPLA";//$NON-NLS-1$
|
||||
|
||||
public static final String IMPALA_DRIVER = "IMPALA_DRIVER";
|
||||
|
||||
/**
|
||||
* Google Dataproc keys.
|
||||
*/
|
||||
@@ -302,6 +308,8 @@ public class ConnParameterKeys {
|
||||
/**DataBricks*/
|
||||
public static final String CONN_PARA_KEY_DATABRICKS_ENDPOINT="CONN_PARA_KEY_DATABRICKS_ENDPOINT";
|
||||
|
||||
public static final String CONN_PARA_KEY_DATABRICKS_CLOUD_PROVIDER = "CONN_PARA_KEY_DATABRICKS_CLOUD_PROVIDER";
|
||||
|
||||
public static final String CONN_PARA_KEY_DATABRICKS_CLUSTER_ID="CONN_PARA_KEY_DATABRICKS_CLUSTER_ID";
|
||||
|
||||
public static final String CONN_PARA_KEY_DATABRICKS_TOKEN="CONN_PARA_KEY_DATABRICKS_TOKEN";
|
||||
|
||||
@@ -224,6 +224,7 @@ public class DatabaseConnStrUtil {
|
||||
if (template.startsWith(DbConnStrForHive.URL_HIVE_2_TEMPLATE)) {
|
||||
url = getImpalaURLString(false, server, port, sidOrDatabase, impalaPrincipal);
|
||||
}
|
||||
url = attachAdditionalHiveParameters(url, dbConn, false);
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
|
||||
/**
|
||||
* cli class global comment. Detailled comment
|
||||
@@ -326,6 +327,16 @@ public enum EDatabaseConnTemplate {
|
||||
databaseType.add(typeName);
|
||||
}
|
||||
}
|
||||
// add additional jdbc (actually JDBC RepositoryObjectType)
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
List<String> allAdditionalJDBCTypes = service.getAllAdditionalJDBCTypes();
|
||||
if (!allAdditionalJDBCTypes.isEmpty()) {
|
||||
databaseType.addAll(allAdditionalJDBCTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sort) {
|
||||
String[] sortedArray = databaseType.toArray(new String[0]);
|
||||
Arrays.sort(sortedArray, new Comparator<String>() {
|
||||
|
||||
@@ -102,12 +102,12 @@ public enum EDatabaseVersion4Drivers {
|
||||
|
||||
GREENPLUM(new DbVersion4Drivers(EDatabaseTypeName.GREENPLUM, "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$
|
||||
// PSQL_V10(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v10", "V10", "postgresql-42.2.5.jar")),
|
||||
PSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v9 and later", "V9_X", "postgresql-42.2.9.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
PSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v9 and later", "V9_X", "postgresql-42.2.14.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
PSQL_PRIOR_TO_V9(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "Prior to v9", "PRIOR_TO_V9", "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
PLUSPSQL_PRIOR_TO_V9(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL,
|
||||
"Prior to v9", "PRIOR_TO_V9", "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
PLUSPSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL, "v9 and later", "V9_X", "postgresql-9.4-1201.jdbc41.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
PLUSPSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL, "v9 and later", "V9_X", "postgresql-42.2.14.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
IBMDB2(new DbVersion4Drivers(EDatabaseTypeName.IBMDB2, new String[] { "db2jcc4.jar", "db2jcc_license_cu.jar", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"db2jcc_license_cisuz.jar" })), //$NON-NLS-1$
|
||||
IBMDB2ZOS(new DbVersion4Drivers(EDatabaseTypeName.IBMDB2ZOS, new String[] { "db2jcc4.jar", "db2jcc_license_cu.jar", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
@@ -166,7 +166,7 @@ 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.729.jar", "jackson-core-2.10.1.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.848.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$
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ public enum EHadoopProperties {
|
||||
QUBOLE_S3_REGION,
|
||||
|
||||
DATABRICKS_ENDPOINT,
|
||||
DATABRICKS_CLOUD_PROVIDER,
|
||||
DATABRICKS_CLUSTER_ID,
|
||||
DATABRICKS_TOKEN,
|
||||
DATABRICKS_DBFS_DEP_FOLDER;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.hadoop.version;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* created by hcyi on May 27, 2020
|
||||
* Detailled comment
|
||||
*
|
||||
*/
|
||||
public enum EHdinsightStorage {
|
||||
|
||||
ADLS_GEN2("ADLS Gen2"), //$NON-NLS-1$
|
||||
|
||||
AZURE_STORAGE("Azure storage"); //$NON-NLS-1$
|
||||
|
||||
private String displayName;
|
||||
|
||||
EHdinsightStorage(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public static List<String> getAllHdinsightStorageDisplayNames() {
|
||||
return getAllHdinsightStorageNames(true);
|
||||
}
|
||||
|
||||
public static List<String> getAllHdinsightStorageNames(boolean display) {
|
||||
List<String> names = new ArrayList<String>();
|
||||
EHdinsightStorage[] values = values();
|
||||
for (EHdinsightStorage storage : values) {
|
||||
if (display) {
|
||||
names.add(storage.getDisplayName());
|
||||
} else {
|
||||
names.add(storage.getName());
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public static EHdinsightStorage getHdinsightStoragenByDisplayName(String name) {
|
||||
return getHdinsightStorageByName(name, true);
|
||||
}
|
||||
|
||||
public static EHdinsightStorage getHdinsightStorageByName(String name, boolean display) {
|
||||
if (name != null) {
|
||||
for (EHdinsightStorage storage : values()) {
|
||||
if (display) {
|
||||
if (name.equalsIgnoreCase(storage.getDisplayName())) {
|
||||
return storage;
|
||||
}
|
||||
} else {
|
||||
if (name.equalsIgnoreCase(storage.getName())) {
|
||||
return storage;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,11 @@ public final class ComponentUtilities {
|
||||
|
||||
public static void setNodeValue(NodeType node, String name, String value) {
|
||||
ElementParameterType property = getNodeProperty(node, name);
|
||||
|
||||
if (property == null) {
|
||||
throw new IllegalArgumentException( "The component node "+node.getComponentName()+" doesn't have the property "+name );
|
||||
}
|
||||
|
||||
property.setValue(value);
|
||||
}
|
||||
|
||||
@@ -113,6 +118,12 @@ public final class ComponentUtilities {
|
||||
if (value != null) {
|
||||
String replaceAll = value.replaceAll(oldName2, newName);
|
||||
t.setValue(replaceAll);
|
||||
if (!"UNIQUE_NAME".equals(t.getName())) {
|
||||
if (replaceAll.contains(oldName)) {
|
||||
replaceAll = replaceAll.replaceAll(oldName, newName);
|
||||
t.setValue(replaceAll);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,4 +111,6 @@ public interface IComponentsFactory {
|
||||
public Map<String, File> getComponentsProvidersFolder();
|
||||
|
||||
public List<ComponentProviderInfo> getComponentsProvidersInfo();
|
||||
|
||||
public String getCustomComponentBundlePath();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -320,7 +320,8 @@ public class JobContextManager implements IContextManager {
|
||||
contextParam = new JobContextParameter();
|
||||
contextParam.setContext(context);
|
||||
contextParam.setName(contextParamType.getName());
|
||||
contextParam.setPrompt(contextParamType.getPrompt());
|
||||
contextParam.setPrompt(
|
||||
contextParamType.getPrompt() == null ? (contextParamType.getName() + "?") : contextParamType.getPrompt());
|
||||
contextParam.setInternalId(contextParamType.getInternalId());
|
||||
originalParamerters.add(contextParam.getName());
|
||||
boolean exists = true;
|
||||
@@ -341,7 +342,8 @@ public class JobContextManager implements IContextManager {
|
||||
|
||||
String repositoryContextId = contextParamType.getRepositoryContextId();
|
||||
String source = IContextParameter.BUILT_IN;
|
||||
if (repositoryContextId != null && !"".equals(repositoryContextId)) { //$NON-NLS-1$
|
||||
if (repositoryContextId != null && !"".equals(repositoryContextId) //$NON-NLS-1$
|
||||
&& !IContextParameter.BUILT_IN.equals(repositoryContextId)) {
|
||||
Item item = ContextUtils.getContextItemById(contextItemList, repositoryContextId);
|
||||
if (item == null) {
|
||||
item = ContextUtils.getRepositoryContextItemById(repositoryContextId);
|
||||
@@ -585,15 +587,16 @@ public class JobContextManager implements IContextManager {
|
||||
contextParamType.setRepositoryContextId(contextId);
|
||||
}
|
||||
}
|
||||
} else if (useInternalId) {
|
||||
} else {
|
||||
contextParamType.setRepositoryContextId(contextParam.getSource());
|
||||
}
|
||||
if (useInternalId) {
|
||||
String internalId = contextParam.getInternalId();
|
||||
if (StringUtils.isEmpty(internalId)) {
|
||||
internalId = EcoreUtil.generateUUID();
|
||||
contextParamType.setInternalId(internalId);
|
||||
contextParam.setInternalId(internalId);
|
||||
} else {
|
||||
contextParamType.setInternalId(internalId);
|
||||
}
|
||||
contextParamType.setInternalId(internalId);
|
||||
}
|
||||
}
|
||||
contextTypeParamList.clear(); // remove old
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package org.talend.core.model.context.link;
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// ============================================================================
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
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.repository.ProjectManager;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
|
||||
|
||||
public abstract class AbstractItemContextLinkService implements IItemContextLinkService {
|
||||
|
||||
@Override
|
||||
public boolean mergeItemLink(Item item, ItemContextLink backupContextLink, InputStream remoteLinkFileInput) throws PersistenceException {
|
||||
ItemContextLink remoteContextLink = ContextLinkService.getInstance().doLoadContextLinkFromFile(remoteLinkFileInput);
|
||||
List<ContextType> contextTypeList = ContextUtils.getAllContextType(item);
|
||||
return saveContextLink(contextTypeList, item, backupContextLink, remoteContextLink);
|
||||
}
|
||||
|
||||
public synchronized boolean saveContextLink(List<ContextType> contextTypeList, Item item,
|
||||
ItemContextLink backupContextLink, ItemContextLink remoteContextLink)
|
||||
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) {
|
||||
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 (!ContextUtils.isBuildInParameter(contextParameterType)) {
|
||||
ContextLink contextLink = itemContextLink
|
||||
.findContextLink(contextParameterType.getRepositoryContextId(), jobContextType.getName());
|
||||
if (contextLink == null) {
|
||||
contextLink = new ContextLink();
|
||||
contextLink.setContextName(jobContextType.getName());
|
||||
contextLink.setRepoId(repositoryContextId);
|
||||
}
|
||||
ContextParamLink contextParamLink = createParamLink(repositoryContextId, jobContextType.getName(),
|
||||
contextParameterType.getName(), contextParameterType.getInternalId(), tempCache,
|
||||
backupContextLink, remoteContextLink);
|
||||
if (contextParamLink != null) {
|
||||
contextLink.getParameterList().add(contextParamLink);
|
||||
}
|
||||
|
||||
if (contextLink.getParameterList().size() > 0
|
||||
&& !itemContextLink.getContextList().contains(contextLink)) {
|
||||
itemContextLink.getContextList().add(contextLink);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemContextLink.getContextList().size() > 0) {
|
||||
ContextLinkService.getInstance().saveContextLinkToJson(item, itemContextLink);
|
||||
hasLinkFile = true;
|
||||
} else {
|
||||
ContextLinkService.getInstance().deleteContextLinkJsonFile(item);
|
||||
}
|
||||
return hasLinkFile;
|
||||
}
|
||||
|
||||
public synchronized boolean saveContextLink(List<ContextType> contextTypeList, Item item) throws PersistenceException {
|
||||
ItemContextLink backupContextLink = ContextLinkService.getInstance().loadContextLinkFromJson(item);
|
||||
return saveContextLink(contextTypeList, item, backupContextLink, null);
|
||||
}
|
||||
|
||||
private ContextParamLink createParamLink(String repositoryContextId, String contextName, String paramName, String internalId,
|
||||
Map<String, Item> tempCache, ItemContextLink oldContextLink, ItemContextLink remoteContextLink) {
|
||||
ContextParamLink contextParamLink = null;
|
||||
|
||||
if (StringUtils.isNotBlank(internalId)) {
|
||||
contextParamLink = new ContextParamLink();
|
||||
contextParamLink.setName(paramName);
|
||||
contextParamLink.setId(internalId);
|
||||
}
|
||||
|
||||
Item contextItem = tempCache.get(repositoryContextId);
|
||||
IRepositoryService repositoryService = GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
if (contextItem == null) {
|
||||
contextItem = ContextUtils.getRepositoryContextItemById(repositoryContextId);
|
||||
tempCache.put(repositoryContextId, contextItem);
|
||||
if (contextItem != null && !(contextItem instanceof ContextItem)
|
||||
&& ProjectManager.getInstance().isInCurrentMainProject(contextItem)
|
||||
&& checkRepoItemContextParamInternalId(contextItem)) {
|
||||
try {
|
||||
repositoryService.getProxyRepositoryFactory().save(contextItem, true); // This should only using for migration phase // case the internal id is null
|
||||
} catch (Exception ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (contextItem != null) {
|
||||
ContextType contextType = ContextUtils.getContextTypeByName(contextItem, contextName);
|
||||
ContextParameterType repoContextParameterType = ContextUtils.getContextParameterTypeByName(contextType, paramName);
|
||||
if (repoContextParameterType != null && repoContextParameterType.eResource() == null) {
|
||||
// processItem save before than contextItem, caused eResource null
|
||||
|
||||
try {
|
||||
repositoryService.getProxyRepositoryFactory().save(contextItem, false);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
String uuID = null;
|
||||
boolean isFromContextItem = (contextItem instanceof ContextItem);
|
||||
if (repoContextParameterType != null) {
|
||||
if (isFromContextItem) {
|
||||
uuID = ResourceHelper.getUUID(repoContextParameterType);
|
||||
} else if (repoContextParameterType.getInternalId() != null) {
|
||||
uuID = repoContextParameterType.getInternalId();
|
||||
}
|
||||
}
|
||||
if (repoContextParameterType == null && remoteContextLink != null) {
|
||||
ContextParamLink remoteParamLink = remoteContextLink.findContextParamLinkByName(repositoryContextId, contextName,
|
||||
paramName);
|
||||
if (remoteParamLink != null && remoteParamLink.getId() != null) {
|
||||
repoContextParameterType = findContextParamTypeById(contextType, isFromContextItem, remoteParamLink.getId());
|
||||
uuID = remoteParamLink.getId();
|
||||
}
|
||||
}
|
||||
if (repoContextParameterType == null && oldContextLink != null) {
|
||||
ContextParamLink oldParamLink = oldContextLink.findContextParamLinkByName(repositoryContextId, contextName,
|
||||
paramName);
|
||||
if (oldParamLink != null) {
|
||||
uuID = oldParamLink.getId();
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(uuID)) {
|
||||
contextParamLink = new ContextParamLink();
|
||||
contextParamLink.setName(paramName);
|
||||
contextParamLink.setId(uuID);
|
||||
}
|
||||
}
|
||||
return contextParamLink;
|
||||
}
|
||||
|
||||
protected ContextParameterType findContextParamTypeById(ContextType contextType, boolean isFromContextItem, String id) {
|
||||
for (Object obj : contextType.getContextParameter()) {
|
||||
if (obj instanceof ContextParameterType) {
|
||||
ContextParameterType repoParam = (ContextParameterType) obj;
|
||||
if (isFromContextItem && StringUtils.equals(id, ResourceHelper.getUUID(repoParam))) {
|
||||
return repoParam;
|
||||
}
|
||||
if (!isFromContextItem && StringUtils.equals(id, repoParam.getInternalId())) {
|
||||
return repoParam;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean checkRepoItemContextParamInternalId(Item item) {
|
||||
boolean isModified = false;
|
||||
EList<?> contextTypeList = ContextUtils.getAllContextType(item);
|
||||
if (contextTypeList != null) {
|
||||
for (Object typeObj : contextTypeList) {
|
||||
if (typeObj instanceof ContextType) {
|
||||
ContextType type = (ContextType) typeObj;
|
||||
for (Object obj : type.getContextParameter()) {
|
||||
if (obj instanceof ContextParameterType) {
|
||||
ContextParameterType contextParam = (ContextParameterType) obj;
|
||||
if (ContextUtils.isBuildInParameter(contextParam)
|
||||
&& StringUtils.isEmpty(contextParam.getInternalId())) {
|
||||
contextParam
|
||||
.setInternalId(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory().getNextId());
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.InputStream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
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.cwm.helper.ResourceHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
|
||||
|
||||
public class ConnectionItemContextLinkService extends AbstractItemContextLinkService {
|
||||
|
||||
@Override
|
||||
public boolean accept(Item item) {
|
||||
if (item instanceof ConnectionItem) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveItemLink(Item item) throws PersistenceException {
|
||||
if (item instanceof ConnectionItem) {
|
||||
ConnectionItem connectionItem = (ConnectionItem) item;
|
||||
return saveContextLink(connectionItem.getConnection(), item, null, null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private synchronized boolean saveContextLink(Connection connection, Item item, ItemContextLink backupContextLink,
|
||||
ItemContextLink remoteContextLink) 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Because we don't know db connection using which values, we save all for merge operation
|
||||
if (backupContextLink != null) {
|
||||
for (ContextLink cl : backupContextLink.getContextList()) {
|
||||
if (StringUtils.equals(cl.getRepoId(), contextId)
|
||||
&& StringUtils.equals(cl.getContextName(), connection.getContextName())) {
|
||||
for (ContextParamLink cpl : cl.getParameterList()) {
|
||||
if (contextLink.getParamLinkByName(cpl.getName()) == null) {
|
||||
contextLink.getParameterList().add(cpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (remoteContextLink != null) {
|
||||
for (ContextLink cl : remoteContextLink.getContextList()) {
|
||||
if (StringUtils.equals(cl.getRepoId(), contextId)
|
||||
&& StringUtils.equals(cl.getContextName(), connection.getContextName())) {
|
||||
for (ContextParamLink cpl : cl.getParameterList()) {
|
||||
if (contextLink.getParamLinkByName(cpl.getName()) == null) {
|
||||
contextLink.getParameterList().add(cpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemContextLink.getContextList().size() > 0) {
|
||||
ContextLinkService.getInstance().saveContextLinkToJson(item, itemContextLink);
|
||||
hasLinkFile = true;
|
||||
} else {
|
||||
ContextLinkService.getInstance().deleteContextLinkJsonFile(item);
|
||||
}
|
||||
return hasLinkFile;
|
||||
}
|
||||
|
||||
public ItemContextLink loadItemLink(Item item) throws PersistenceException {
|
||||
return ContextLinkService.getInstance().doLoadContextLinkFromJson(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mergeItemLink(Item item, ItemContextLink backupContextLink, InputStream remoteLinkFileInput)
|
||||
throws PersistenceException {
|
||||
if (item instanceof ConnectionItem) {
|
||||
ConnectionItem connectionItem = (ConnectionItem) item;
|
||||
ItemContextLink remoteContextLink = ContextLinkService.getInstance().doLoadContextLinkFromFile(remoteLinkFileInput);
|
||||
return saveContextLink(connectionItem.getConnection(), item, backupContextLink, remoteContextLink);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,12 +15,13 @@ package org.talend.core.model.context.link;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
@@ -34,24 +35,23 @@ 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.core.model.relationship.Relation;
|
||||
import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
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.repository.ProjectManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.RepositoryConstants;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class ContextLinkService {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ContextLinkService.class);
|
||||
|
||||
private static final String CREATOR_EXT_ID = "org.talend.core.runtime.saveItemContextLinkService"; //$NON-NLS-1$
|
||||
|
||||
public static final String LINKS_FOLDER_NAME = "links";
|
||||
@@ -78,162 +78,38 @@ public class ContextLinkService {
|
||||
return service.saveItemLink(item);
|
||||
}
|
||||
}
|
||||
return doSaveContextLink(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
public synchronized boolean mergeContextLink(Item item, ItemContextLink backupContextLink, InputStream remoteLinkFile)
|
||||
throws PersistenceException {
|
||||
for (IItemContextLinkService service : registeredService) {
|
||||
if (service.accept(item)) {
|
||||
return service.mergeItemLink(item, backupContextLink, remoteLinkFile);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean isSupportContextLink(Item item) {
|
||||
for (IItemContextLinkService service : registeredService) {
|
||||
if (service.accept(item)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (itemContextLink.getContextList().size() > 0) {
|
||||
saveContextLinkToJson(item, itemContextLink);
|
||||
hasLinkFile = true;
|
||||
} else {
|
||||
deleteContextLinkJsonFile(item);
|
||||
}
|
||||
return hasLinkFile;
|
||||
return false;
|
||||
}
|
||||
|
||||
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 {
|
||||
public synchronized void saveContextLinkToJson(Item item, ItemContextLink itemContextLink) throws PersistenceException {
|
||||
IFolder linksFolder = getLinksFolder(getItemProjectLabel(item));
|
||||
if (!linksFolder.exists()) {
|
||||
ResourceUtils.createFolder(linksFolder);
|
||||
}
|
||||
IFile linkFile = calContextLinkFile(item);
|
||||
saveContextLinkToJson(linkFile, itemContextLink);
|
||||
}
|
||||
|
||||
public synchronized void saveContextLinkToJson(IFile linkFile, ItemContextLink itemContextLink) throws PersistenceException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
String content = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(itemContextLink);
|
||||
@@ -296,6 +172,25 @@ public class ContextLinkService {
|
||||
return contextLink;
|
||||
}
|
||||
|
||||
public synchronized ItemContextLink doLoadContextLinkFromFile(InputStream inputStream) throws PersistenceException {
|
||||
if (inputStream == null) {
|
||||
return null;
|
||||
}
|
||||
ItemContextLink contextLink = null;
|
||||
try {
|
||||
contextLink = new ObjectMapper().readValue(inputStream, ItemContextLink.class);
|
||||
} catch (IOException e) {
|
||||
throw new PersistenceException(e);
|
||||
} finally {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
LOGGER.info("Close input stream failed.");
|
||||
}
|
||||
}
|
||||
return contextLink;
|
||||
}
|
||||
|
||||
public synchronized void deleteContextLinkJsonFile(Item item) throws PersistenceException {
|
||||
IFile linkFile = calContextLinkFile(item);
|
||||
if (linkFile != null && linkFile.exists()) {
|
||||
@@ -307,6 +202,74 @@ public class ContextLinkService {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void updateRelatedContextParameterId(String sourceId, Map<String, String> repositoryIdChangedMap,
|
||||
Map<String, Map<String, String>> changedContextParameterId) throws PersistenceException {
|
||||
List<Relation> relationList = RelationshipItemBuilder.getInstance()
|
||||
.getItemsHaveRelationWith(sourceId, RelationshipItemBuilder.LATEST_VERSION, false);
|
||||
for (Relation relation : relationList) {
|
||||
String id = relation.getId();
|
||||
IFile linkFile = calContextLinkFile(ProjectManager.getInstance().getCurrentProject().getTechnicalLabel(), id);
|
||||
ItemContextLink itemContextLink = doLoadContextLinkFromFile(linkFile);
|
||||
String newRepoId = null;
|
||||
boolean isModified = false;
|
||||
if (repositoryIdChangedMap != null && repositoryIdChangedMap.containsKey(sourceId)) {
|
||||
newRepoId = repositoryIdChangedMap.get(sourceId);
|
||||
}
|
||||
if (itemContextLink != null) {
|
||||
for (ContextLink contextLink : itemContextLink.getContextList()) {
|
||||
for (String repoId : changedContextParameterId.keySet()) {
|
||||
if (StringUtils.equals(repoId, contextLink.getRepoId())) {
|
||||
Map<String, String> oldToNewId = changedContextParameterId.get(repoId);
|
||||
for (String oldId : oldToNewId.keySet()) {
|
||||
ContextParamLink paramLink = contextLink.getParamLinkById(oldId);
|
||||
if (paramLink != null) {
|
||||
paramLink.setId(oldToNewId.get(oldId));
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sourceId.equals(repoId) && newRepoId != null) {
|
||||
isModified = true;
|
||||
contextLink.setRepoId(newRepoId);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isModified) {
|
||||
saveContextLinkToJson(linkFile, itemContextLink);
|
||||
}
|
||||
}
|
||||
isModified = false;
|
||||
if (newRepoId != null) {
|
||||
Item relatedItem = ContextUtils.getRepositoryContextItemById(id);
|
||||
if (relatedItem != null) {
|
||||
List contextTypes = ContextUtils.getAllContextType(relatedItem);
|
||||
if (contextTypes != null) {
|
||||
for (Object object : contextTypes) {
|
||||
if (object instanceof ContextType) {
|
||||
ContextType context = (ContextType) object;
|
||||
for (Object obj : context.getContextParameter()) {
|
||||
if (obj instanceof ContextParameterType) {
|
||||
ContextParameterType parameterType = (ContextParameterType) obj;
|
||||
if (!ContextUtils.isBuildInParameter(parameterType)
|
||||
&& sourceId.equals(parameterType.getRepositoryContextId())) {
|
||||
parameterType.setRepositoryContextId(newRepoId);
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isModified) {
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
factory.save(relatedItem, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static IFile calContextLinkFile(Item item) throws PersistenceException {
|
||||
if (item == null) {
|
||||
return null;
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.model.context.link;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.properties.Item;
|
||||
|
||||
@@ -23,4 +25,7 @@ public interface IItemContextLinkService {
|
||||
|
||||
ItemContextLink loadItemLink(Item item) throws PersistenceException;
|
||||
|
||||
boolean mergeItemLink(Item item, ItemContextLink backupContextLink, InputStream otherVersionLinkFile)
|
||||
throws PersistenceException;
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,18 @@ public class ItemContextLink {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContextParamLink findContextParamLinkByIdIgnoreContextName(String repoContextId, String paramId) {
|
||||
for (ContextLink contextLink : contextList) {
|
||||
if (StringUtils.equals(repoContextId, contextLink.getRepoId())) {
|
||||
ContextParamLink paramLink = contextLink.getParamLinkById(paramId);
|
||||
if (paramLink != null) {
|
||||
return paramLink;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContextLink findContextLink(String repoContextId, String contextName) {
|
||||
for (ContextLink contextLink : contextList) {
|
||||
if ((repoContextId == null || StringUtils.equals(repoContextId, contextLink.getRepoId()))
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.talend.core.model.context.link;
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// ============================================================================
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
|
||||
|
||||
public class ProcessItemContextLinkService extends AbstractItemContextLinkService {
|
||||
|
||||
@Override
|
||||
public boolean accept(Item item) {
|
||||
if (item instanceof ProcessItem || item instanceof JobletProcessItem) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveItemLink(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);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemContextLink loadItemLink(Item item) throws PersistenceException {
|
||||
return ContextLinkService.getInstance().doLoadContextLinkFromJson(item);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.commons.exception.BusinessException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
|
||||
import org.talend.core.model.process.IElement;
|
||||
@@ -119,6 +120,8 @@ public interface ILibrariesService extends IService {
|
||||
List<ModuleNeeded> getModuleNeeded(String id, boolean isGroup);
|
||||
|
||||
public void deployProjectLibrary(File source) throws IOException;
|
||||
|
||||
public void setForceReloadCustomUri();
|
||||
|
||||
/**
|
||||
* Listener used to fire that libraries status has been changed (new lib or new check install).
|
||||
@@ -131,4 +134,14 @@ public interface ILibrariesService extends IService {
|
||||
public void afterChangingLibraries();
|
||||
}
|
||||
|
||||
public static ILibrariesService get() {
|
||||
GlobalServiceRegister gsr = GlobalServiceRegister.getDefault();
|
||||
if (gsr != null) {
|
||||
if (gsr.isServiceRegistered(ILibrariesService.class)) {
|
||||
return gsr.getService(ILibrariesService.class);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
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.utils.TalendQuoteUtils;
|
||||
|
||||
/**
|
||||
* This bean is use to manage needed moduless (perl) and libraries (java).<br/>
|
||||
@@ -110,6 +111,15 @@ public class ModuleNeeded {
|
||||
|
||||
}
|
||||
|
||||
public static ModuleNeeded newInstance(String context, String value, String informationMsg, boolean required) {
|
||||
String val = TalendQuoteUtils.removeQuotesIfExist(value);
|
||||
if (val.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
|
||||
return new ModuleNeeded(context, informationMsg, required, val);
|
||||
}
|
||||
// won't do migration for old MODULE_LIST but still make it compatible
|
||||
return new ModuleNeeded(context, val, informationMsg, required);
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC smallet ModuleNeeded constructor comment.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.talend.core.model.metadata;
|
||||
|
||||
public class DbDefaultDatePattern {
|
||||
private String defaultPattern;
|
||||
private String dbTypeName;
|
||||
|
||||
public DbDefaultDatePattern() {
|
||||
|
||||
}
|
||||
|
||||
public String getDefaultPattern() {
|
||||
return defaultPattern;
|
||||
}
|
||||
|
||||
public void setDefaultPattern(String defaultPattern) {
|
||||
this.defaultPattern = defaultPattern;
|
||||
}
|
||||
|
||||
public String getDbTypeName() {
|
||||
return dbTypeName;
|
||||
}
|
||||
|
||||
public void setDbTypeName(String dbTypeName) {
|
||||
this.dbTypeName = dbTypeName;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ public class Dbms {
|
||||
private Set<MappingType> talendToDbTypes;
|
||||
|
||||
private List<DbDefaultLengthAndPrecision> defaultLengthPrecision;
|
||||
|
||||
private List<DbDefaultDatePattern> defaultPattern;
|
||||
|
||||
private List<DbIgnoreLengthAndPrecision> ignoreLengthPrecision;
|
||||
|
||||
@@ -62,6 +64,14 @@ public class Dbms {
|
||||
List<DbDefaultLengthAndPrecision> defaultLengthPrecision) {
|
||||
this.defaultLengthPrecision = defaultLengthPrecision;
|
||||
}
|
||||
public List<DbDefaultDatePattern> getDefaultPattern() {
|
||||
return defaultPattern;
|
||||
}
|
||||
|
||||
public void setDefaultPattern(
|
||||
List<DbDefaultDatePattern> defaultLengthPrecision) {
|
||||
this.defaultPattern = defaultLengthPrecision;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC amaumont Dbms constructor comment.
|
||||
|
||||
@@ -125,10 +125,12 @@ public class MappingFileLoader {
|
||||
// search and load preBeforelen nodes
|
||||
ArrayList<String> dbTypes = new ArrayList<String>();
|
||||
ArrayList<DbDefaultLengthAndPrecision> dbDefault = new ArrayList<DbDefaultLengthAndPrecision>();
|
||||
ArrayList<DbDefaultDatePattern> dbDefaultPattern = new ArrayList<DbDefaultDatePattern>();
|
||||
ArrayList<DbIgnoreLengthAndPrecision> dbIgnore = new ArrayList<DbIgnoreLengthAndPrecision>();
|
||||
ArrayList<DbPreBeforeLength> dbPbeforeLList = new ArrayList<DbPreBeforeLength>();
|
||||
dbms.setDbmsTypes(dbTypes);
|
||||
dbms.setDefaultLengthPrecision(dbDefault);
|
||||
dbms.setDefaultPattern(dbDefaultPattern);
|
||||
dbms.setIgnoreLengthPrecision(dbIgnore);
|
||||
dbms.setPrebeforelength(dbPbeforeLList);
|
||||
List<Node> typeNodes = getChildElementNodes(dbTypesNode);
|
||||
@@ -149,19 +151,25 @@ public class MappingFileLoader {
|
||||
dbTypes.add(typeValue);
|
||||
hAllDbTypes.add(typeValue);
|
||||
DbDefaultLengthAndPrecision dbDefaultLP = new DbDefaultLengthAndPrecision();
|
||||
DbDefaultDatePattern dbDefaultPt = new DbDefaultDatePattern();
|
||||
DbIgnoreLengthAndPrecision dbIgnoreLP = new DbIgnoreLengthAndPrecision();
|
||||
DbPreBeforeLength dbPBeforeL = new DbPreBeforeLength();
|
||||
// default length and precision
|
||||
Node defaultLengthItem = typeNodeAtttributes.getNamedItem("defaultLength"); //$NON-NLS-1$
|
||||
Node defaultPrecision = typeNodeAtttributes.getNamedItem("defaultPrecision"); //$NON-NLS-1$
|
||||
Node defaultPattern = typeNodeAtttributes.getNamedItem("defaultPattern"); //$NON-NLS-1$
|
||||
|
||||
if (defaultLengthItem != null)
|
||||
dbDefaultLP.setDefaultLength(Integer.parseInt(defaultLengthItem.getNodeValue()));
|
||||
if (defaultPrecision != null)
|
||||
dbDefaultLP.setDefaultPrecision(Integer.parseInt(defaultPrecision.getNodeValue()));
|
||||
if (defaultPattern != null)
|
||||
dbDefaultPt.setDefaultPattern(defaultPattern.getNodeValue());
|
||||
|
||||
dbDefaultLP.setDbTypeName(typeValue);
|
||||
dbDefaultPt.setDbTypeName(typeValue);
|
||||
dbDefault.add(dbDefaultLP);
|
||||
dbDefaultPattern.add(dbDefaultPt);
|
||||
|
||||
// ignore Length and Precision
|
||||
Node ignoreLength = typeNodeAtttributes.getNamedItem("ignoreLen"); //$NON-NLS-1$
|
||||
|
||||
@@ -191,6 +191,24 @@ public class MappingTypeRetriever {
|
||||
}// end for
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getDefaultPattern(String dbmsId, String dbType) {
|
||||
Dbms dbms = MetadataTalendType.getDbms(dbmsId);
|
||||
List<DbDefaultDatePattern> defaultPattern = dbms.getDefaultPattern();
|
||||
String pattern = new String(""); //$NON-NLS-1$
|
||||
for (int i = 0; i < defaultPattern.size(); i++) {
|
||||
DbDefaultDatePattern dbPattern = (DbDefaultDatePattern) defaultPattern.get(i);
|
||||
if (dbPattern.getDbTypeName().equalsIgnoreCase(dbType)) {
|
||||
pattern = dbPattern.getDefaultPattern();
|
||||
if (pattern == null) {
|
||||
return "";
|
||||
} else {
|
||||
return pattern;
|
||||
}
|
||||
}// end if
|
||||
}// end for
|
||||
return pattern;
|
||||
}
|
||||
|
||||
private boolean isExtensionPrecisionIgnored(String dbmsId, String dbType) {
|
||||
Map<String, Map<String, List<DBTypeUtil>>> javaTypeMappingFromExtension = JavaTypesManager
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.core.model.metadata;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -31,8 +32,11 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
@@ -488,6 +492,42 @@ public final class MetadataTalendType {
|
||||
}
|
||||
}
|
||||
|
||||
public static void syncNewMappingFileToProject() throws SystemException {
|
||||
try {
|
||||
File sysMappingFiles = new File(MetadataTalendType.getSystemForderURLOfMappingsFile().getPath());
|
||||
IFolder projectMappingFolder = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject())
|
||||
.getFolder(MetadataTalendType.PROJECT_MAPPING_FOLDER);
|
||||
File projectMappingFiles = projectMappingFolder.getFullPath().toFile();
|
||||
if (sysMappingFiles.list().length == new File(projectMappingFolder.getLocationURI()).list().length) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File sysMapping : sysMappingFiles.listFiles()) {
|
||||
IFile projectMapping = projectMappingFolder.getFile(sysMapping.getName());
|
||||
if (!projectMapping.exists()) {
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(sysMapping);
|
||||
projectMapping.create(fis, true, null);
|
||||
} catch (CoreException coreExc) {
|
||||
throw new SystemException(coreExc);
|
||||
} finally {
|
||||
if (fis != null) {
|
||||
try {
|
||||
fis.close();
|
||||
} catch (IOException ioExc) {
|
||||
throw new SystemException(ioExc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new SystemException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Load db types and mapping with the current activated language (Java, Perl, ...).
|
||||
|
||||
@@ -621,6 +621,7 @@ public final class MetadataToolHelper {
|
||||
target.getListColumns().addAll(columnsTAdd);
|
||||
target.sortCustomColumns();
|
||||
target.setLabel(source.getLabel());
|
||||
target.setDbms(source.getDbms());
|
||||
setTargetOriginalColumns(source, target);
|
||||
// List<String> originalColumnsList = null;
|
||||
// if (source.getOriginalColumns() != null) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
@@ -26,9 +27,11 @@ import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.database.EDatabase4DriverClassName;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.database.conn.DatabaseConnStrUtil;
|
||||
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
|
||||
import org.talend.core.model.components.EComponentType;
|
||||
import org.talend.core.model.metadata.Dbms;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
@@ -70,6 +73,7 @@ import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.model.utils.IDragAndDropServiceHandler;
|
||||
import org.talend.core.runtime.i18n.Messages;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.helper.PackageHelper;
|
||||
@@ -152,6 +156,17 @@ public class ComponentToRepositoryProperty {
|
||||
conn.setDbmsId(mapping);
|
||||
}
|
||||
}
|
||||
// set default mapping for additional jdbc
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
Dbms dbms4AdditionalJDBC = service.getDbms4AdditionalJDBC(conn.getProductId());
|
||||
if (dbms4AdditionalJDBC != null) {
|
||||
conn.setDbmsId(dbms4AdditionalJDBC.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (IElementParameter param : node.getElementParameters()) {
|
||||
String repositoryValue = param.getRepositoryValue();
|
||||
@@ -365,6 +380,20 @@ public class ComponentToRepositoryProperty {
|
||||
if (para.getRepositoryValue().endsWith(EDatabaseTypeName.GENERAL_JDBC.getProduct())) {
|
||||
connection.setDatabaseType(EDatabaseTypeName.GENERAL_JDBC.getProduct());
|
||||
connection.setProductId(EDatabaseTypeName.GENERAL_JDBC.getProduct());
|
||||
|
||||
// additional JDBC e.g. Delta Lake
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
String database = service.getDatabseNameByNode(node);
|
||||
if (StringUtils.isNotBlank(database) && service.getIfAdditionalJDBCDBType(database)) {
|
||||
connection.setProductId(database);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// vertica output component have no TYPE ElementParameter .
|
||||
if (para.getRepositoryValue().endsWith(EDatabaseTypeName.VERTICA.getProduct())) {
|
||||
@@ -667,6 +696,18 @@ public class ComponentToRepositoryProperty {
|
||||
connection.setServerName(value);
|
||||
}
|
||||
}
|
||||
if ("IMPALA_DRIVER".equals(param.getRepositoryValue())) {
|
||||
String value = getParameterValue(connection, node, param);
|
||||
if (value != null) {
|
||||
connection.getParameters().put(ConnParameterKeys.IMPALA_DRIVER, value);
|
||||
}
|
||||
}
|
||||
if ("IMPALA_ADDITIONAL_JDBC".equals(param.getRepositoryValue())) {
|
||||
String value = getParameterValue(connection, node, param);
|
||||
if (value != null) {
|
||||
connection.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (connection.getDatabaseType().equals(EDatabaseTypeName.ORACLEFORSID.getDisplayName())) {
|
||||
setDatabaseValueForOracleSid(connection, node, param);
|
||||
|
||||
@@ -47,6 +47,10 @@ public enum EParameterNameForComponent {
|
||||
|
||||
PARA_NAME_HDINSIGHT_PASSWORD("HDINSIGHT_PASSWORD"), //$NON-NLS-1$
|
||||
|
||||
PARA_NAME_HDINSIGHT_STORAGE("HDINSIGHT_STORAGE"), //$NON-NLS-1$
|
||||
|
||||
PARA_NAME_HDINSIGHT_STORAGE_USE_TLS("HDINSIGHT_STORAGE_USE_TLS"), //$NON-NLS-1$
|
||||
|
||||
PARA_NAME_WASB_HOST("WASB_HOST"), //$NON-NLS-1$
|
||||
|
||||
PARA_NAME_WASB_CONTAINER("WASB_CONTAINER"), //$NON-NLS-1$
|
||||
|
||||
@@ -1490,21 +1490,24 @@ public class RepositoryToComponentProperty {
|
||||
}
|
||||
|
||||
if (value.equals("USE_SSL") && (EDatabaseTypeName.HIVE.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType))) {
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.IMPALA.getDisplayName().equals(databaseType))) {
|
||||
String message = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_SSL);
|
||||
return Boolean.parseBoolean(message);
|
||||
}
|
||||
|
||||
if ((value.equals("SSL_TRUST_STORE") || value.equals("SSL_TRUSTSERVER_TRUSTSTORE"))
|
||||
&& (EDatabaseTypeName.HIVE.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType))) {
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.IMPALA.getDisplayName().equals(databaseType))) {
|
||||
return getAppropriateValue(connection,
|
||||
connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PATH));
|
||||
}
|
||||
|
||||
if ((value.equals("SSL_TRUST_STORE_PASSWORD") || value.equals("SSL_TRUSTSERVER_PASSWORD"))
|
||||
&& (EDatabaseTypeName.HIVE.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType))) {
|
||||
|| EDatabaseTypeName.ORACLE_CUSTOM.getDisplayName().equals(databaseType)
|
||||
|| EDatabaseTypeName.IMPALA.getDisplayName().equals(databaseType))) {
|
||||
return getAppropriateValue(connection, connection
|
||||
.getValue(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SSL_TRUST_STORE_PASSWORD), false));
|
||||
}
|
||||
@@ -1752,9 +1755,21 @@ public class RepositoryToComponentProperty {
|
||||
EDatabaseTypeName typeFromDbType = EDatabaseTypeName.getTypeFromDbType(repositoryType);
|
||||
return typeFromDbType.getXMLType();
|
||||
}
|
||||
|
||||
if (StringUtils.equals("MAPPING", value)) {//$NON-NLS-1$
|
||||
return connection.getDbmsId();
|
||||
}
|
||||
if ("IMPALA_ADDITIONAL_JDBC".equals(value)) { //$NON-NLS-1$
|
||||
String additionJdbc = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
|
||||
if (isContextMode(connection, additionJdbc)) {
|
||||
return additionJdbc;
|
||||
} else {
|
||||
return TalendQuoteUtils.addQuotes(additionJdbc);
|
||||
}
|
||||
}
|
||||
if ("IMPALA_DRIVER".equals(value)) {
|
||||
return connection.getParameters().get(ConnParameterKeys.IMPALA_DRIVER);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private static String getAppropriateValue(Connection connection, String rawValue) {
|
||||
|
||||
@@ -240,6 +240,11 @@ public class ContextParameterJavaTypeManager {
|
||||
if (javaType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(javaType.equals(JavaTypesManager.PASSWORD)) {
|
||||
return "Password";
|
||||
}
|
||||
|
||||
Class primitiveClass = javaType.getPrimitiveClass();
|
||||
Class nullableClass = javaType.getNullableClass();
|
||||
if (nullable) {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.process;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public abstract class AbsJobletReplaceNodeHandler extends AbsReplaceNodeHandler implements IJobletReplaceNodeHandler {
|
||||
|
||||
public AbsJobletReplaceNodeHandler(String prefix) {
|
||||
super();
|
||||
this.setPrefix(prefix);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.process;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public abstract class AbsReplaceNodeHandler implements IReplaceNodeHandler {
|
||||
|
||||
private String prefix;
|
||||
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -122,6 +122,8 @@ public abstract class AbstractNode implements INode {
|
||||
// for MR, tag this component is the ref(lookup) start node
|
||||
private boolean isRefNode = false;
|
||||
|
||||
private IReplaceNodeHandler replaceNodeHandler;
|
||||
|
||||
public String getComponentName() {
|
||||
return componentName;
|
||||
}
|
||||
@@ -1322,6 +1324,15 @@ public abstract class AbstractNode implements INode {
|
||||
return componentProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReplaceNodeHandler getReplaceNodeHandler() {
|
||||
return replaceNodeHandler;
|
||||
}
|
||||
|
||||
public void setReplaceNodeHandler(IReplaceNodeHandler replaceNodeHandler) {
|
||||
this.replaceNodeHandler = replaceNodeHandler;
|
||||
}
|
||||
|
||||
public INode getRealGraphicalNode() {
|
||||
return realGraphicalNode;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
package org.talend.core.model.process;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -368,4 +369,38 @@ public class BigDataNode extends AbstractNode implements IBigDataNode {
|
||||
public void processDatasetConditions(){
|
||||
// BigDataNode does not do anything related to Dataset, only anabled from SparkNode
|
||||
}
|
||||
|
||||
public List<? extends IConnection> getIncomingConnections(EConnectionType... connectionTypes) {
|
||||
List<IConnection> conns = null;
|
||||
List<EConnectionType> types = Arrays.asList(connectionTypes);
|
||||
List<? extends IConnection> incomingConnections = this.getIncomingConnections();
|
||||
if (incomingConnections != null) {
|
||||
conns = new ArrayList<IConnection>();
|
||||
|
||||
for (int i = 0; i < incomingConnections.size(); i++) {
|
||||
IConnection connection = incomingConnections.get(i);
|
||||
if (types.contains(connection.getLineStyle())) {
|
||||
conns.add(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
return conns;
|
||||
}
|
||||
|
||||
public List<? extends IConnection> getOutgoingConnections(EConnectionType... connectionTypes) {
|
||||
List<IConnection> conns = null;
|
||||
List<EConnectionType> types = Arrays.asList(connectionTypes);
|
||||
List<? extends IConnection> incomingConnections = this.getOutgoingConnections();
|
||||
if (incomingConnections != null) {
|
||||
conns = new ArrayList<IConnection>();
|
||||
|
||||
for (int i = 0; i < incomingConnections.size(); i++) {
|
||||
IConnection connection = incomingConnections.get(i);
|
||||
if (types.contains(connection.getLineStyle())) {
|
||||
conns.add(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
return conns;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public enum EComponentCategory {
|
||||
DYNAMICS_SETTINGS(Messages.getString("EComponentCategory_dynamicSetting"), 13), //$NON-NLS-1$
|
||||
SQL_PATTERN(Messages.getString("EComponentCategory_sqlTemplate"), 14), //$NON-NLS-1$
|
||||
BREAKPOINT(Messages.getString("EComponentCategory.breakpoint"), 15), //$NON-NLS-1$
|
||||
BREAKPOINT_CAMEL(Messages.getString("EComponentCategory.breakpoint"), 16), //$NON-NLS-1$
|
||||
BASICRUN(Messages.getString("EComponentCategory.basicRun"), 1), //$NON-NLS-1$
|
||||
DEBUGRUN(Messages.getString("EComponentCategory.debugRun"), 2), //$NON-NLS-1$
|
||||
ADVANCESETTING(Messages.getString("EComponentCategory.advancedSettings"), 3), //$NON-NLS-1$
|
||||
|
||||
@@ -113,8 +113,6 @@ public enum EParameterFieldType {
|
||||
|
||||
GROUPING_CAMPAIGN_CHOOSER, // htyin added for DQ Matching components
|
||||
MULTI_PATTERN, // yyin added TDQ-13437
|
||||
SYNC_NEXUS_BUTTON,
|
||||
CHECK_NEXUS_BUTTON,
|
||||
PATTERN_PROPERTY, // yyin, added TDQ-13437
|
||||
|
||||
UNIFIED_COMPONENTS,
|
||||
|
||||
@@ -141,5 +141,19 @@ public interface IBigDataNode extends INode {
|
||||
* Loading and processing should be separated because conditions can be dependent on future component (in subjob order)
|
||||
*/
|
||||
public void processDatasetConditions();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param connectionTypes
|
||||
* @return connections according to multiple EConnectionType
|
||||
*/
|
||||
public List<? extends IConnection> getIncomingConnections(EConnectionType... connectionTypes);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param connectionTypes
|
||||
* @return connections according to multiple EConnectionType
|
||||
*/
|
||||
public List<? extends IConnection> getOutgoingConnections(EConnectionType... connectionTypes);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.process;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public interface IJobletReplaceNodeHandler extends IReplaceNodeHandler {
|
||||
|
||||
}
|
||||
@@ -312,6 +312,10 @@ public interface INode extends IElement {
|
||||
|
||||
public boolean isSubtreeStart();
|
||||
|
||||
default public IReplaceNodeHandler getReplaceNodeHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setComponentProperties(ComponentProperties props);
|
||||
|
||||
public ComponentProperties getComponentProperties();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.process;
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public interface IReplaceNodeHandler {
|
||||
|
||||
String getPrefix();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.process;
|
||||
|
||||
|
||||
/**
|
||||
* DOC cmeng class global comment. Detailled comment
|
||||
*/
|
||||
public class JobletReplaceNodeHandler extends AbsJobletReplaceNodeHandler {
|
||||
|
||||
public JobletReplaceNodeHandler(String prefix) {
|
||||
super(prefix);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1003,4 +1003,12 @@ public final class ProcessUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isChildRouteProcess(IProcess process) {
|
||||
List n = process.getNodesOfType("tRouteInput");
|
||||
if (n!=null && n.size()!=0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.routines.RoutinesUtil;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.i18n.Messages;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
@@ -50,6 +51,7 @@ import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IRepositoryNode;
|
||||
|
||||
/**
|
||||
* This class store all relationships between jobs/joblets and other items from the repository. Be sure to update the
|
||||
@@ -130,6 +132,8 @@ public class RelationshipItemBuilder {
|
||||
|
||||
private Map<Relation, Set<Relation>> referencesItemsRelations;
|
||||
|
||||
private Map<String, String> systemRoutinesMap;
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
private boolean loading = false;
|
||||
@@ -219,6 +223,28 @@ public class RelationshipItemBuilder {
|
||||
this.proxyRepositoryFactory = proxyRepositoryFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Current System Routines Map, key: routine id, value: routine name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getCurrentSystemRoutinesMap() {
|
||||
if (systemRoutinesMap != null && !systemRoutinesMap.isEmpty()) {
|
||||
return systemRoutinesMap;
|
||||
}
|
||||
|
||||
if (systemRoutinesMap == null) {
|
||||
systemRoutinesMap = new HashMap<String, String>();
|
||||
}
|
||||
List<IRepositoryViewObject> currentSystemRoutines = RoutinesUtil.getCurrentSystemRoutines();
|
||||
for (IRepositoryViewObject object : currentSystemRoutines) {
|
||||
systemRoutinesMap.put(object.getProperty().getId(), object.getProperty().getLabel());
|
||||
}
|
||||
|
||||
return systemRoutinesMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for every linked items who use the selected id, no matter the version. Usefull when want to delete an item
|
||||
* since it will delete every versions.
|
||||
@@ -242,6 +268,10 @@ public class RelationshipItemBuilder {
|
||||
* @return
|
||||
*/
|
||||
public List<Relation> getItemsHaveRelationWith(String itemId, String version) {
|
||||
return getItemsHaveRelationWith(itemId, version, true);
|
||||
}
|
||||
|
||||
public List<Relation> getItemsHaveRelationWith(String itemId, String version, boolean withReferenceProject) {
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
@@ -251,12 +281,13 @@ public class RelationshipItemBuilder {
|
||||
if (itemsRelations != null) {
|
||||
relations.addAll(itemsRelations);
|
||||
}
|
||||
itemsRelations = getItemsHaveRelationWith(referencesItemsRelations, itemId, version);
|
||||
if (itemsRelations != null) {
|
||||
relations.addAll(itemsRelations);
|
||||
if (withReferenceProject) {
|
||||
itemsRelations = getItemsHaveRelationWith(referencesItemsRelations, itemId, version);
|
||||
if (itemsRelations != null) {
|
||||
relations.addAll(itemsRelations);
|
||||
}
|
||||
}
|
||||
return new ArrayList<Relation>(relations);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -463,7 +494,7 @@ public class RelationshipItemBuilder {
|
||||
}
|
||||
|
||||
private Set<Relation> getItemsRelatedTo(Map<Relation, Set<Relation>> itemsRelations, String itemId, String version,
|
||||
String relationType) {
|
||||
String relationType) {
|
||||
|
||||
Relation itemToTest = new Relation();
|
||||
itemId = ProcessUtils.getPureItemId(itemId);
|
||||
@@ -757,7 +788,8 @@ public class RelationshipItemBuilder {
|
||||
for (ItemRelations relations : oldRelations) {
|
||||
boolean isIdSame = relations.getBaseItem().getId().equals(relation.getId());
|
||||
boolean isVersionSame = StringUtils.equals(relations.getBaseItem().getVersion(), relation.getVersion());
|
||||
if (isIdSame && isVersionSame) {
|
||||
boolean isTypeSame = StringUtils.equals(relations.getBaseItem().getType(), relation.getType());
|
||||
if (isIdSame && isVersionSame && isTypeSame) {
|
||||
usedList.add(relations);
|
||||
itemRelations = relations;
|
||||
exist = true;
|
||||
@@ -898,7 +930,10 @@ public class RelationshipItemBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private void addRelationShip(Item baseItem, String relatedId, String relatedVersion, String type) {
|
||||
public void addRelationShip(Item baseItem, String relatedId, String relatedVersion, String type) {
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
Relation relation = new Relation();
|
||||
relation.setId(baseItem.getProperty().getId());
|
||||
relation.setType(getTypeFromItem(baseItem));
|
||||
@@ -914,8 +949,32 @@ public class RelationshipItemBuilder {
|
||||
itemRelations.put(relation, new HashSet<Relation>());
|
||||
}
|
||||
itemRelations.get(relation).add(addedRelation);
|
||||
|
||||
autoSaveRelations();
|
||||
}
|
||||
|
||||
public Set<Relation> getBeanRelations(Collection<Item> items) {
|
||||
Set<Relation> relationships = new HashSet<Relation>();
|
||||
for (Item item : items) {
|
||||
Relation relation = new Relation();
|
||||
relation.setId(item.getProperty().getId());
|
||||
relation.setType(getTypeFromItem(item));
|
||||
relation.setVersion(item.getProperty().getVersion());
|
||||
|
||||
Map<Relation, Set<Relation>> itemRelations = getRelatedRelations(item);
|
||||
|
||||
Set<Relation> repositoryNode = (Set<Relation>) itemRelations.getOrDefault(relation, new HashSet<Relation>());
|
||||
|
||||
for (Relation rel : repositoryNode) {
|
||||
if (rel.getType().equals("Beans")) {
|
||||
relationships.add(rel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return relationships;
|
||||
}
|
||||
|
||||
private Map<Relation, Set<Relation>> getRelatedRelations(Item baseItem) {
|
||||
Map<Relation, Set<Relation>> itemRelations = currentProjectItemsRelations;
|
||||
if (!ProjectManager.getInstance().isInMainProject(getAimProject(), baseItem)) {
|
||||
@@ -931,18 +990,26 @@ public class RelationshipItemBuilder {
|
||||
|
||||
private void buildIndex(Map<Relation, Set<Relation>> itemRelations, Project project, IProgressMonitor monitor) {
|
||||
modified = true;
|
||||
|
||||
if (!project.getEmfProject().getItemsRelations().isEmpty()) {
|
||||
loadRelations(itemRelations, project);
|
||||
if (loaded) { // check if already loaded successfully
|
||||
return;
|
||||
}
|
||||
}
|
||||
generateIndex(project, getTypes(), true, monitor);
|
||||
if (modified) {
|
||||
autoSaveRelations();
|
||||
}
|
||||
monitor.done();
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
private void generateIndex(Project project, List<ERepositoryObjectType> supportedTypes, boolean fromMigration,
|
||||
IProgressMonitor monitor) {
|
||||
IProxyRepositoryFactory factory = getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> list = new ArrayList<IRepositoryViewObject>();
|
||||
try {
|
||||
for (ERepositoryObjectType curTyp : getTypes()) {
|
||||
for (ERepositoryObjectType curTyp : supportedTypes) {
|
||||
if (curTyp != null) {
|
||||
list.addAll(factory.getAll(project, curTyp, true, true));
|
||||
}
|
||||
@@ -956,21 +1023,44 @@ public class RelationshipItemBuilder {
|
||||
for (IRepositoryViewObject object : list) {
|
||||
Item item = object.getProperty().getItem();
|
||||
monitor.subTask(Messages.getString("RelationshipItemBuilder.forItem") + item.getProperty().getLabel()); //$NON-NLS-1$
|
||||
addOrUpdateItem(item, true);
|
||||
findRelationItems(item, fromMigration);
|
||||
monitor.worked(1);
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
autoSaveRelations();
|
||||
monitor.done();
|
||||
loaded = true;
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildAndSaveIndex() {
|
||||
log.info("relationship.index generating");
|
||||
currentProjectItemsRelations = new ConcurrentHashMap<Relation, Set<Relation>>();
|
||||
referencesItemsRelations = new ConcurrentHashMap<Relation, Set<Relation>>();
|
||||
generateIndex(this.aimProject, allSupportedTypes(), false, new NullProgressMonitor());
|
||||
try {
|
||||
// sync to project
|
||||
synchronizeItemRelationToProject(this.aimProject);
|
||||
// persist index
|
||||
getProxyRepositoryFactory().saveProject(this.aimProject);
|
||||
log.info("relationship.index generated");
|
||||
} catch (PersistenceException e) {
|
||||
log.error("relationship.index generating error", e);
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ERepositoryObjectType> allSupportedTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess2());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfTestContainer());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfCodes());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfJoblet());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private List<ERepositoryObjectType> getTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.add(ERepositoryObjectType.PROCESS);
|
||||
@@ -1092,14 +1182,24 @@ public class RelationshipItemBuilder {
|
||||
}
|
||||
|
||||
public void addOrUpdateItem(Item item, boolean fromMigration) {
|
||||
if (!supportRelation(item)) {
|
||||
return;
|
||||
}
|
||||
if (!loaded) {
|
||||
loadRelations();
|
||||
}
|
||||
boolean relationsModified = findRelationItems(item, fromMigration);
|
||||
if (relationsModified && !modified) {
|
||||
modified = true;
|
||||
}
|
||||
if (!fromMigration && modified) {
|
||||
autoSaveRelations();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean findRelationItems(Item item, boolean fromMigration) {
|
||||
if (!supportRelation(item)) {
|
||||
return false;
|
||||
}
|
||||
if (item == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean relationsModified = true;
|
||||
@@ -1143,12 +1243,7 @@ public class RelationshipItemBuilder {
|
||||
currentProjectItemsRelations.get(relation).addAll(oldProjectRelations);
|
||||
}
|
||||
}
|
||||
if (relationsModified && !modified) {
|
||||
modified = true;
|
||||
}
|
||||
if (!fromMigration && modified) {
|
||||
autoSaveRelations();
|
||||
}
|
||||
return relationsModified;
|
||||
}
|
||||
|
||||
public Set<Relation> getItemRelations(Item item) {
|
||||
@@ -1427,4 +1522,5 @@ public class RelationshipItemBuilder {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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$
|
||||
@@ -1407,12 +1414,8 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<ERepositoryObjectType> getAllTypesOfProcess() {
|
||||
public static List<ERepositoryObjectType> getAllTypesOfBigDataProcess() {
|
||||
List<ERepositoryObjectType> allTypes = new ArrayList<ERepositoryObjectType>();
|
||||
|
||||
if (ERepositoryObjectType.PROCESS != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS);
|
||||
}
|
||||
if (ERepositoryObjectType.PROCESS_MR != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS_MR);
|
||||
}
|
||||
@@ -1425,6 +1428,17 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
if (ERepositoryObjectType.PROCESS_SPARKSTREAMING != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS_SPARKSTREAMING);
|
||||
}
|
||||
return allTypes;
|
||||
}
|
||||
|
||||
public static List<ERepositoryObjectType> getAllTypesOfProcess() {
|
||||
List<ERepositoryObjectType> allTypes = new ArrayList<ERepositoryObjectType>();
|
||||
|
||||
allTypes.addAll(getAllTypesOfBigDataProcess());
|
||||
|
||||
if (ERepositoryObjectType.PROCESS != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS);
|
||||
}
|
||||
if (ERepositoryObjectType.PROCESS_ROUTE != null) {
|
||||
allTypes.add(ERepositoryObjectType.PROCESS_ROUTE);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public interface SVNConstant {
|
||||
|
||||
public static final String NAME_MASTER = "master"; //$NON-NLS-1$
|
||||
|
||||
public static final String NAME_MAIN = "main"; //$NON-NLS-1$
|
||||
|
||||
public static final String NAME_ORIGIN = "origin"; //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
|
||||
@@ -750,6 +750,17 @@ public abstract class RepositoryUpdateManager {
|
||||
}
|
||||
}
|
||||
|
||||
ERepositoryObjectType jsonType = ERepositoryObjectType.valueOf("json");
|
||||
if (jsonType != null) {
|
||||
List<IRepositoryViewObject> jsonConnList = FACTORY.getAll(jsonType);
|
||||
for (IRepositoryViewObject obj : jsonConnList) {
|
||||
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();
|
||||
|
||||
@@ -307,30 +307,41 @@ public class RepositoryUpdateManagerHelper {
|
||||
processRep.addAll(factory.getAll(sparkStreamJoblet, true));
|
||||
}
|
||||
|
||||
List<ERepositoryObjectType> testcases = ERepositoryObjectType.getAllTypesOfTestContainer();
|
||||
for (ERepositoryObjectType testcase : testcases) {
|
||||
if (testcase != null) {
|
||||
processRep.addAll(factory.getAll(testcase, true));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
// all the jobs
|
||||
for (IRepositoryViewObject process : processRep) {
|
||||
Item item = process.getProperty().getItem();
|
||||
boolean found = false;
|
||||
for (IProcess2 open : openedProcessList) {
|
||||
if (open.getId().equals(item.getProperty().getId())) {
|
||||
found = true;
|
||||
try {
|
||||
Item item = process.getProperty().getItem();
|
||||
boolean found = false;
|
||||
for (IProcess2 open : openedProcessList) {
|
||||
if (open.getId().equals(item.getProperty().getId())) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
continue;
|
||||
}
|
||||
checkMonitorCanceled(parentMonitor);
|
||||
parentMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(item.getProperty()));
|
||||
if (found) {
|
||||
continue;
|
||||
}
|
||||
checkMonitorCanceled(parentMonitor);
|
||||
parentMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(item.getProperty()));
|
||||
|
||||
// List<UpdateResult> resultFromProcess = getResultFromProcess(process, types, onlySimpleShow);
|
||||
// List<UpdateResult> resultFromProcess = getResultFromProcess(process, types, onlySimpleShow);
|
||||
|
||||
List<UpdateResult> resultFromProcess = getUpdatesNeededFromItems(parentMonitor, item, types);
|
||||
if (resultFromProcess != null) {
|
||||
resultList.addAll(resultFromProcess);
|
||||
List<UpdateResult> resultFromProcess = getUpdatesNeededFromItems(parentMonitor, item, types);
|
||||
if (resultFromProcess != null) {
|
||||
resultList.addAll(resultFromProcess);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
parentMonitor.worked(1);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,11 @@ import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.INodeConnector;
|
||||
import org.talend.core.model.process.IProcess;
|
||||
import org.talend.core.model.process.IProcess2;
|
||||
import org.talend.core.model.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.runtime.IAdditionalInfo;
|
||||
import org.talend.core.runtime.projectsetting.RuntimeLineageManager;
|
||||
import org.talend.designer.core.ICamelDesignerCoreService;
|
||||
|
||||
/**
|
||||
@@ -866,6 +870,170 @@ public class NodeUtil {
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
||||
public static String getRuntimeParameterValue(INode node, IElementParameter ep) {
|
||||
if (EParameterFieldType.TABLE.equals(ep.getFieldType())) {
|
||||
Map<String, IElementParameter> types = new HashMap<String, IElementParameter>();
|
||||
Object[] itemsValue = ep.getListItemsValue();
|
||||
if (itemsValue != null) {
|
||||
for (Object o : itemsValue) {
|
||||
IElementParameter cep = (IElementParameter) o;
|
||||
if (cep.isShow(node.getElementParameters())) {
|
||||
types.put(cep.getName(), cep);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Map<String, String>> lines = (List<Map<String, String>>) ElementParameterParser.getObjectValue(node,
|
||||
"__" + ep.getName() + "__");
|
||||
StringBuilder value = new StringBuilder();
|
||||
// implement List & Map toString(), different is the value of Map
|
||||
Iterator<Map<String, String>> linesIter = lines.iterator();
|
||||
if (!linesIter.hasNext()) {
|
||||
return "\"[]\"";
|
||||
}
|
||||
value.append("new StringBuilder().append(\"[");
|
||||
for (;;) {
|
||||
Map<String, String> columns = linesIter.next();
|
||||
Iterator<Entry<String, String>> columnsIter = columns.entrySet().iterator();
|
||||
|
||||
value.append("{");
|
||||
Entry<String, String> column = null;
|
||||
boolean printedColumnExist = false;
|
||||
while (columnsIter.hasNext()) {
|
||||
column = columnsIter.next();
|
||||
if (types.get(column.getKey()) == null) {
|
||||
continue;
|
||||
}
|
||||
printedColumnExist = true;
|
||||
|
||||
value.append(column.getKey());
|
||||
value.append("=\").append(");
|
||||
value.append(getRuntimeParameterValue(column.getValue(), types.get(column.getKey()), true));
|
||||
value.append(").append(\"");
|
||||
|
||||
if (columnsIter.hasNext()) {
|
||||
value.append(", ");
|
||||
}
|
||||
}
|
||||
if (printedColumnExist && column != null && (types.get(column.getKey()) == null)) {
|
||||
value.setLength(value.length() - 2);
|
||||
}
|
||||
value.append("}");
|
||||
|
||||
if (!linesIter.hasNext()) {
|
||||
return value.append("]\").toString()").toString();
|
||||
}
|
||||
value.append(",").append(" ");
|
||||
}
|
||||
} else {
|
||||
String value = ElementParameterParser.getValue(node, "__" + ep.getName() + "__");
|
||||
if (EParameterFieldType.TABLE_BY_ROW.equals(ep.getFieldType())) {
|
||||
value = ep.getValue().toString();
|
||||
}
|
||||
return getRuntimeParameterValue(value, ep, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getRuntimeParameterValue(String value, IElementParameter ep, boolean itemFromTable) {
|
||||
if (value == null) {
|
||||
value = "";
|
||||
}
|
||||
|
||||
value = value.trim();
|
||||
|
||||
boolean isMemo = false;
|
||||
|
||||
List<EParameterFieldType> needRemoveCRLFList = Arrays.asList(EParameterFieldType.MEMO, EParameterFieldType.MEMO_JAVA,
|
||||
EParameterFieldType.MEMO_SQL, EParameterFieldType.MEMO_IMPORT, EParameterFieldType.MEMO_MESSAGE);
|
||||
if (needRemoveCRLFList.contains(ep.getFieldType())) {
|
||||
isMemo = true;
|
||||
value = value.replaceAll("[\r\n]", " ");
|
||||
}
|
||||
|
||||
List<EParameterFieldType> needQuoteList = Arrays.asList(EParameterFieldType.CLOSED_LIST,
|
||||
EParameterFieldType.COMPONENT_LIST, EParameterFieldType.COLUMN_LIST, EParameterFieldType.PREV_COLUMN_LIST,
|
||||
EParameterFieldType.CONNECTION_LIST, EParameterFieldType.LOOKUP_COLUMN_LIST,
|
||||
EParameterFieldType.CONTEXT_PARAM_NAME_LIST, EParameterFieldType.PROCESS_TYPE, EParameterFieldType.COLOR,
|
||||
EParameterFieldType.TABLE_BY_ROW, EParameterFieldType.HADOOP_JARS_DIALOG, EParameterFieldType.UNIFIED_COMPONENTS);
|
||||
List<EParameterFieldType> needQuoteListForItem = itemFromTable ? Arrays.asList(EParameterFieldType.SCHEMA_TYPE,
|
||||
EParameterFieldType.SAP_SCHEMA_TYPE, EParameterFieldType.MODULE_LIST) : new ArrayList<EParameterFieldType>();
|
||||
// TODO: add RAW attribute when SCHEMA_COLUMN generated by BASED_ON_SCHEMA
|
||||
List<String> needQuoteListByName = Arrays.asList("SCHEMA_COLUMN");// SCHEMA_COLUMN for BASED_ON_SCHEMA="true"
|
||||
|
||||
if (needQuoteList.contains(ep.getFieldType()) || needQuoteListForItem.contains(ep.getFieldType())
|
||||
|| needQuoteListByName.contains(ep.getName()) || ep.isRaw()) {
|
||||
value = value.replaceAll("\\\\", "\\\\\\\\");
|
||||
value = value.replaceAll("\\\"", "\\\\\\\"");
|
||||
return "\"" + value + "\"";
|
||||
}
|
||||
|
||||
if (itemFromTable) {
|
||||
if ("*".equals(value)) {
|
||||
return "\"" + value + "\"";
|
||||
}
|
||||
if (value.endsWith(";")) {
|
||||
value = value.substring(0, value.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
if("".equals(value) || "\"\"".equals(value)) {
|
||||
return "\"\"";
|
||||
} else if("null".equals(value)) {
|
||||
return "(Object)null";
|
||||
}
|
||||
|
||||
// copied it from Log4jFileUtil.javajet but need more comment for this script
|
||||
if ("\"\\n\"".equals(value) || "\"\\r\"".equals(value) || "\"\\r\\n\"".equals(value)) {
|
||||
// for the value is "\n" "\r" "\r\n"
|
||||
return value.replaceAll("\\\\", "\\\\\\\\");
|
||||
} else if ("\"\"\"".equals(value)) {
|
||||
return "\"" + "\\" + "\"" + "\"";
|
||||
} else if ("\"\"\\r\\n\"\"".equals(value)) {
|
||||
return "\"\\\\r\\\\n\"";
|
||||
} else if ("\"\"\\r\"\"".equals(value)) {
|
||||
return "\"\\\\r\"";
|
||||
} else if ("\"\"\\n\"\"".equals(value)) {
|
||||
return "\"\\\\n\"";
|
||||
}
|
||||
// ftom 20141008 - patch to fix javajet compilation errors due to hard-coded studio TableEditor mechanism
|
||||
// linked to BUILDIN properties checks, this item is a boolean set to TRUE or FALSE
|
||||
// fix is just transforming into true or false to make logging OK
|
||||
else if ("BUILDIN".equals(ep.getName())) {
|
||||
return value.toLowerCase();
|
||||
}
|
||||
|
||||
//suppose all memo fields are processed well already, no need to go though this with dangerous
|
||||
if (!isMemo && !org.talend.core.model.utils.ContextParameterUtils.isDynamic(value)) {
|
||||
if(value.length() > 1 && value.startsWith("\"") && value.endsWith("\"")) {
|
||||
if(itemFromTable && "ARGS".equals(ep.getName())) {
|
||||
value = value.substring(1, value.length());
|
||||
value = value.substring(0, value.length() - 1);
|
||||
return "\"" + checkStringQuotationMarks(value) + "\"";
|
||||
} else {
|
||||
//do nothing
|
||||
return value;
|
||||
}
|
||||
} else {
|
||||
return "\"" + checkStringQuotationMarks(value) + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
//TODO remove it
|
||||
if (value.endsWith("*")) {
|
||||
return value.substring(0, value.length() - 1) + "\"*\"";
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private static String checkStringQuotationMarks(String str) {
|
||||
String result = str;
|
||||
if (result.contains("\"")) {
|
||||
result = result.replace("\"", "\\\"");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String getNormalizeParameterValue(INode node, IElementParameter ep) {
|
||||
if (EParameterFieldType.TABLE.equals(ep.getFieldType())) {
|
||||
@@ -1189,7 +1357,7 @@ public class NodeUtil {
|
||||
} else if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(node.getComponent().getType())) {
|
||||
INodeConnector tmp = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
|
||||
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault()
|
||||
ICamelDesignerCoreService camelService = GlobalServiceRegister.getDefault()
|
||||
.getService(ICamelDesignerCoreService.class);
|
||||
tmp = node.getConnectorFromType(camelService.getTargetConnectionType(node));
|
||||
} else {
|
||||
@@ -1232,4 +1400,37 @@ public class NodeUtil {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isJobUsingRuntimeLineage(IProcess process) {
|
||||
// Just support DI jobs now
|
||||
boolean isSupport = isStandardJob(process) && !ProcessUtils.isTestContainer(process) && !isGuessSchemaJob(process);
|
||||
if (!isSupport) {
|
||||
return false;
|
||||
}
|
||||
RuntimeLineageManager runtimeLineageManager = new RuntimeLineageManager();
|
||||
if (runtimeLineageManager.isUseRuntimeLineageAll()) {
|
||||
return true;
|
||||
}
|
||||
if (runtimeLineageManager.getSelectedJobIds().isEmpty()) {
|
||||
runtimeLineageManager.load();
|
||||
}
|
||||
return runtimeLineageManager.isRuntimeLineageSetting(process.getId());
|
||||
}
|
||||
|
||||
public static boolean isStandardJob(IProcess process) {
|
||||
if (process != null && process instanceof IProcess2) {
|
||||
Property property = ((IProcess2) process).getProperty();
|
||||
return property != null && property.getItem() != null
|
||||
&& ComponentCategory.CATEGORY_4_DI.getName().equals(process.getComponentsType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isGuessSchemaJob(IProcess process) {
|
||||
if (process != null && process instanceof IProcess2) {
|
||||
Property property = ((IProcess2) process).getProperty();
|
||||
return property != null && "ID".equals(property.getId()) && "Mock_job_for_Guess_schema".equals(property.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.core.model.utils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty;
|
||||
@@ -23,6 +24,7 @@ import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.update.UpdatesConstants;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
|
||||
/**
|
||||
* ggu class global comment. Detailled comment
|
||||
@@ -47,6 +49,14 @@ public final class UpdateRepositoryHelper {
|
||||
if (connection instanceof DatabaseConnection) {
|
||||
String currentDbType = (String) RepositoryToComponentProperty.getValue(connection, UpdatesConstants.TYPE,
|
||||
null);
|
||||
String productId = ((DatabaseConnection) connection).getProductId();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IGenericWizardService.class);
|
||||
if (service != null && service.getIfAdditionalJDBCDBType(productId)) {
|
||||
currentDbType = productId;
|
||||
}
|
||||
}
|
||||
aliasName += " (" + currentDbType + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (repositoryObjectType.getType().equals("SERVICES")) {
|
||||
|
||||
@@ -73,4 +73,6 @@ public interface IRepositoryArtifactHandler {
|
||||
|
||||
public String resolveRemoteSha1(MavenArtifact artifact, boolean fromRelease) throws Exception;
|
||||
|
||||
public List<MavenArtifact> search(String name, boolean fromSnapshot) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
@@ -36,10 +38,8 @@ import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.commons.utils.network.NetworkUtil;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
|
||||
/**
|
||||
@@ -48,16 +48,21 @@ import org.talend.core.runtime.maven.MavenArtifact;
|
||||
*/
|
||||
public class NexusServerUtils {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static final String ORG_TALEND_DESIGNER_CORE = "org.talend.designer.core"; //$NON-NLS-1$
|
||||
public static final String ORG_TALEND_DESIGNER_CORE = NetworkUtil.ORG_TALEND_DESIGNER_CORE;
|
||||
|
||||
public static final int CONNECTION_OK = 200;
|
||||
|
||||
// the max search result is 200 by defult from nexus
|
||||
private static final int MAX_SEARCH_COUNT = 200;
|
||||
|
||||
public static final Set<String> IGNORED_TYPES = new HashSet<String>();
|
||||
|
||||
static {
|
||||
IGNORED_TYPES.add("pom");
|
||||
IGNORED_TYPES.add("sha1");
|
||||
IGNORED_TYPES.add("md5");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC check if the repository exist or not
|
||||
@@ -69,9 +74,7 @@ public class NexusServerUtils {
|
||||
* @return
|
||||
*/
|
||||
public static int getTimeout() {
|
||||
IEclipsePreferences node = InstanceScope.INSTANCE.getNode(ORG_TALEND_DESIGNER_CORE);
|
||||
int timeout = node.getInt(ITalendCorePrefConstants.NEXUS_TIMEOUT, 20000);
|
||||
return timeout;
|
||||
return NetworkUtil.getNexusTimeout();
|
||||
}
|
||||
|
||||
public static boolean checkConnectionStatus(String nexusUrl, String repositoryId, final String userName, final String password) {
|
||||
@@ -243,36 +246,36 @@ public class NexusServerUtils {
|
||||
private static int readDocument(Document document, List<MavenArtifact> artifacts) throws Exception {
|
||||
List<Node> list = document.selectNodes("/searchNGResponse/data/artifact");//$NON-NLS-1$
|
||||
for (Node arNode : list) {
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
artifacts.add(artifact);
|
||||
artifact.setGroupId(arNode.selectSingleNode("groupId").getText());//$NON-NLS-1$
|
||||
artifact.setArtifactId(arNode.selectSingleNode("artifactId").getText());//$NON-NLS-1$
|
||||
artifact.setVersion(arNode.selectSingleNode("version").getText());//$NON-NLS-1$
|
||||
Node descNode = arNode.selectSingleNode("description");//$NON-NLS-1$
|
||||
if (descNode != null) {
|
||||
artifact.setDescription(descNode.getText());
|
||||
}
|
||||
Node urlNode = arNode.selectSingleNode("url");//$NON-NLS-1$
|
||||
if (urlNode != null) {
|
||||
artifact.setUrl(urlNode.getText());
|
||||
}
|
||||
Node licenseNode = arNode.selectSingleNode("license");//$NON-NLS-1$
|
||||
if (licenseNode != null) {
|
||||
artifact.setLicense(licenseNode.getText());
|
||||
}
|
||||
|
||||
Node licenseUrlNode = arNode.selectSingleNode("licenseUrl");//$NON-NLS-1$
|
||||
if (licenseUrlNode != null) {
|
||||
artifact.setLicenseUrl(licenseUrlNode.getText());
|
||||
}
|
||||
|
||||
List<Node> artLinks = arNode.selectNodes("artifactHits/artifactHit/artifactLinks/artifactLink");//$NON-NLS-1$
|
||||
for (Node link : artLinks) {
|
||||
MavenArtifact artifact = new MavenArtifact();
|
||||
|
||||
artifact.setGroupId(arNode.selectSingleNode("groupId").getText());//$NON-NLS-1$
|
||||
artifact.setArtifactId(arNode.selectSingleNode("artifactId").getText());//$NON-NLS-1$
|
||||
artifact.setVersion(arNode.selectSingleNode("version").getText());//$NON-NLS-1$
|
||||
Node descNode = arNode.selectSingleNode("description");//$NON-NLS-1$
|
||||
if (descNode != null) {
|
||||
artifact.setDescription(descNode.getText());
|
||||
}
|
||||
Node urlNode = arNode.selectSingleNode("url");//$NON-NLS-1$
|
||||
if (urlNode != null) {
|
||||
artifact.setUrl(urlNode.getText());
|
||||
}
|
||||
Node licenseNode = arNode.selectSingleNode("license");//$NON-NLS-1$
|
||||
if (licenseNode != null) {
|
||||
artifact.setLicense(licenseNode.getText());
|
||||
}
|
||||
|
||||
Node licenseUrlNode = arNode.selectSingleNode("licenseUrl");//$NON-NLS-1$
|
||||
if (licenseUrlNode != null) {
|
||||
artifact.setLicenseUrl(licenseUrlNode.getText());
|
||||
}
|
||||
Node extensionElement = link.selectSingleNode("extension");//$NON-NLS-1$
|
||||
String extension = null;
|
||||
String classifier = null;
|
||||
if (extensionElement != null) {
|
||||
if ("pom".equals(extensionElement.getText())) {//$NON-NLS-1$
|
||||
if (IGNORED_TYPES.contains(extensionElement.getText())) {// $NON-NLS-1$
|
||||
continue;
|
||||
}
|
||||
extension = extensionElement.getText();
|
||||
@@ -283,6 +286,7 @@ public class NexusServerUtils {
|
||||
}
|
||||
artifact.setType(extension);
|
||||
artifact.setClassifier(classifier);
|
||||
artifacts.add(artifact);
|
||||
}
|
||||
}
|
||||
return list.size();
|
||||
@@ -377,4 +381,37 @@ public class NexusServerUtils {
|
||||
|
||||
}
|
||||
|
||||
public static List<MavenArtifact> search(String nexusUrl, String userName, String password, String repositoryId, String name)
|
||||
throws Exception {
|
||||
List<MavenArtifact> artifacts = new ArrayList<MavenArtifact>();
|
||||
|
||||
int totalCount = 0;
|
||||
String service = NexusConstants.SERVICES_SEARCH + getSearchQuery(repositoryId, null, null, null, 0, MAX_SEARCH_COUNT)
|
||||
+ "&q=" + name;
|
||||
|
||||
URI requestURI = getSearchURI(nexusUrl, service);
|
||||
Document document = downloadDocument(requestURI, userName, password);
|
||||
if (document != null) {
|
||||
Node countNode = document.selectSingleNode("/searchNGResponse/totalCount");
|
||||
if (countNode != null) {
|
||||
try {
|
||||
totalCount = Integer.parseInt(countNode.getText());
|
||||
} catch (NumberFormatException e) {
|
||||
totalCount = 0;
|
||||
}
|
||||
}
|
||||
int searchDone = readDocument(document, artifacts);
|
||||
while (searchDone < totalCount) {
|
||||
service = NexusConstants.SERVICES_SEARCH
|
||||
+ getSearchQuery(repositoryId, null, null, null, searchDone, MAX_SEARCH_COUNT) + "&q=" + name;
|
||||
requestURI = getSearchURI(nexusUrl, service);
|
||||
|
||||
document = downloadDocument(requestURI, userName, password);
|
||||
searchDone = searchDone + readDocument(document, artifacts);
|
||||
}
|
||||
}
|
||||
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.prefs;
|
||||
|
||||
import org.talend.commons.utils.network.ITalendNexusPrefConstants;
|
||||
|
||||
/**
|
||||
* Core preferences. Detailled comment <br/>
|
||||
*
|
||||
@@ -190,7 +192,7 @@ public interface ITalendCorePrefConstants {
|
||||
|
||||
public static final String PERFORMANCE_JAVA_PROCESS_CODE_FORMATE_TIMEOUT = "PERFORMANCE_JAVA_PROCESS_CODE_FORMATE_TIMEOUT"; //$NON-NLS-1$
|
||||
|
||||
public static final String NEXUS_TIMEOUT = "NEXUS_TIMEOUT"; //$NON-NLS-1$
|
||||
public static final String NEXUS_TIMEOUT = ITalendNexusPrefConstants.NEXUS_TIMEOUT;
|
||||
|
||||
public static final String NEXUS_REFRESH_FREQUENCY = "NEXUS_REFRESH_FREQUENCY"; //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ package org.talend.core.runtime.evaluator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.runtime.util.GenericTypeUtils;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.daikon.properties.property.Property;
|
||||
@@ -28,6 +29,10 @@ import org.talend.daikon.properties.property.StringProperty;
|
||||
public abstract class AbstractPropertyValueEvaluator implements PropertyValueEvaluator {
|
||||
|
||||
public Object getTypedValue(Property property, Object rawValue) {
|
||||
return getTypedValue(property, null, rawValue);
|
||||
}
|
||||
|
||||
public Object getTypedValue(Property property, Object storedValue, Object rawValue) {
|
||||
if (GenericTypeUtils.isSchemaType(property)) {
|
||||
return rawValue;
|
||||
}
|
||||
@@ -105,6 +110,12 @@ public abstract class AbstractPropertyValueEvaluator implements PropertyValueEva
|
||||
String stringStoredValue = TalendQuoteUtils.removeQuotes(stringValue);
|
||||
for (Object possibleValue : possibleValues) {
|
||||
if (possibleValue.toString().equals(stringStoredValue)) {
|
||||
// Update since enum type set as context for tcompv0 .
|
||||
String currentStoredValue = String.valueOf(storedValue);
|
||||
if (storedValue != null && ContextParameterUtils.isContainContextParam(currentStoredValue)) {
|
||||
property.setTaggedValue("IS_CONTEXT_MODE", false);
|
||||
property.setValue(possibleValue);
|
||||
}
|
||||
return possibleValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ public interface MavenConstants {
|
||||
|
||||
static final String USE_PROFILE_MODULE = "USE_PROFILE_MODULE";
|
||||
|
||||
static final String EXCLUDE_DELETED_ITEMS = "EXCLUDE_DELETED_ITEMS";
|
||||
|
||||
/*
|
||||
* for lib
|
||||
*/
|
||||
|
||||
@@ -174,7 +174,7 @@ public class MavenUrlHelper {
|
||||
if (jarName != null && jarName.length() > 0) {
|
||||
String artifactId = jarName;
|
||||
String type = null;
|
||||
if (jarName.endsWith(MavenConstants.TYPE_JAR)) { // remove the extension .jar
|
||||
if (jarName.endsWith("." + MavenConstants.TYPE_JAR)) { // remove the extension .jar
|
||||
artifactId = jarName.substring(0, jarName.lastIndexOf(MavenConstants.TYPE_JAR) - 1);
|
||||
if (withPackage) {
|
||||
type = MavenConstants.TYPE_JAR;
|
||||
@@ -380,4 +380,14 @@ public class MavenUrlHelper {
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
public static String getSNAPSHOTVersion(String rVersion) {
|
||||
if (rVersion == null) {
|
||||
return rVersion;
|
||||
}
|
||||
if (rVersion.contains("-")) {
|
||||
return rVersion.substring(0, rVersion.indexOf("-") + 1) + MavenUrlHelper.VERSION_SNAPSHOT;
|
||||
}
|
||||
return rVersion;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@ public interface TalendProcessArgumentConstant {
|
||||
|
||||
static final String ARG_AVOID_BRANCH_NAME = "AVOID_BRANCH_NAME";
|
||||
|
||||
static final String ARG_CLEAR_PASSWORD_CONTEXT_PARAMETERS = "CLEAR_PASSWORD_CONTEXT_PARAMETERS";
|
||||
|
||||
static final String CMD_ARG_STATS_PORT_PARAM = "stat_port";
|
||||
|
||||
static final String CMD_ARG_TRACE_PORT_PARAM = "trace_port";
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.runtime.projectsetting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
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.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.RepositoryConstants;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.utils.json.JSONObject;
|
||||
|
||||
import us.monoid.json.JSONArray;
|
||||
|
||||
/**
|
||||
* created by hcyi on Jul 27, 2020
|
||||
* Detailled comment
|
||||
*
|
||||
*/
|
||||
public class RuntimeLineageManager {
|
||||
|
||||
public static final String RUNTIMELINEAGE_RESOURCES = "org.talend.runtimelineage"; //$NON-NLS-1$
|
||||
|
||||
public static final String RUNTIMELINEAGE_ALL = "runtimelineage.all"; //$NON-NLS-1$
|
||||
|
||||
public static final String RUNTIMELINEAGE_SELECTED = "runtimelineage.selected"; //$NON-NLS-1$
|
||||
|
||||
public static final String JOB_ID = "id"; //$NON-NLS-1$
|
||||
|
||||
public static final String RUNTIMELINEAGE_OUTPUT_PATH = "-Druntime.lineage.outputpath="; //$NON-NLS-1$
|
||||
|
||||
public static final String OUTPUT_PATH = "output.path"; //$NON-NLS-1$
|
||||
|
||||
private List<String> selectedJobIds = new ArrayList<String>();
|
||||
|
||||
private ProjectPreferenceManager prefManager = null;
|
||||
|
||||
private boolean useRuntimeLineageAll = false;
|
||||
|
||||
private String outputPath = null;
|
||||
|
||||
public RuntimeLineageManager() {
|
||||
if (prefManager == null) {
|
||||
prefManager = new ProjectPreferenceManager(RUNTIMELINEAGE_RESOURCES, true);
|
||||
}
|
||||
useRuntimeLineageAll = prefManager.getBoolean(RUNTIMELINEAGE_ALL);
|
||||
outputPath = prefManager.getValue(OUTPUT_PATH);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
try {
|
||||
String jobsJsonStr = prefManager.getValue(RUNTIMELINEAGE_SELECTED);
|
||||
if (StringUtils.isNotBlank(jobsJsonStr)) {
|
||||
JSONArray jobsJsonArray = new JSONArray(jobsJsonStr);
|
||||
for (int i = 0; i < jobsJsonArray.length(); i++) {
|
||||
Object jobJsonObj = jobsJsonArray.get(i);
|
||||
JSONObject jobJson = new JSONObject(String.valueOf(jobJsonObj));
|
||||
Iterator sortedKeys = jobJson.sortedKeys();
|
||||
String jobId = null;
|
||||
while (sortedKeys.hasNext()) {
|
||||
String key = (String) sortedKeys.next();
|
||||
if (JOB_ID.equals(key)) {
|
||||
jobId = jobJson.getString(key);
|
||||
}
|
||||
}
|
||||
if (jobId != null) {
|
||||
selectedJobIds.add(jobId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void save(List<RepositoryNode> checkedObjects, boolean all) {
|
||||
try {
|
||||
JSONArray jobsJson = new JSONArray();
|
||||
if (!all) {
|
||||
for (RepositoryNode node : checkedObjects) {
|
||||
JSONObject jobJson = new JSONObject();
|
||||
if (!jobsJson.toString().contains(node.getId())) {
|
||||
jobJson.put(JOB_ID, node.getId());
|
||||
jobsJson.put(jobJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
prefManager.setValue(RUNTIMELINEAGE_ALL, all);
|
||||
prefManager.setValue(RUNTIMELINEAGE_SELECTED, jobsJson.toString());
|
||||
prefManager.setValue(OUTPUT_PATH, outputPath);
|
||||
prefManager.save();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRuntimeLineageSetting(String id) {
|
||||
return selectedJobIds.contains(id);
|
||||
}
|
||||
|
||||
public boolean isRuntimeLineagePrefsExist() {
|
||||
try {
|
||||
IProject project = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
|
||||
IFolder prefSettingFolder = ResourceUtils.getFolder(project, RepositoryConstants.SETTING_DIRECTORY, false);
|
||||
IFile presRuntimeLineageFile = prefSettingFolder.getFile(RUNTIMELINEAGE_RESOURCES + ".prefs"); //$NON-NLS-1$
|
||||
if (presRuntimeLineageFile.exists()) {
|
||||
return true;
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isUseRuntimeLineageAll() {
|
||||
return this.useRuntimeLineageAll;
|
||||
}
|
||||
|
||||
public ProjectPreferenceManager getPrefManager() {
|
||||
return this.prefManager;
|
||||
}
|
||||
|
||||
public List<String> getSelectedJobIds() {
|
||||
return this.selectedJobIds;
|
||||
}
|
||||
|
||||
public void setSelectedJobIds(List<String> selectedJobIds) {
|
||||
this.selectedJobIds = selectedJobIds;
|
||||
}
|
||||
|
||||
public String getOutputPath() {
|
||||
return this.outputPath;
|
||||
}
|
||||
|
||||
public void setOutputPath(String outputPath) {
|
||||
this.outputPath = outputPath;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import java.util.Map;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.process.INode;
|
||||
|
||||
@@ -46,6 +47,8 @@ public interface IGenericService extends IService {
|
||||
|
||||
public boolean isTcompv0(IComponent component);
|
||||
|
||||
public void validateGenericConnection(Connection conn) throws Exception;
|
||||
|
||||
public static IGenericService getService() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(IGenericService.class);
|
||||
|
||||
@@ -20,11 +20,14 @@ import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.ui.swt.actions.ITreeContextualAction;
|
||||
import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.metadata.Dbms;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
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.MetadataTable;
|
||||
import org.talend.core.model.process.EComponentCategory;
|
||||
import org.talend.core.model.process.Element;
|
||||
import org.talend.core.model.process.IElement;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
@@ -146,4 +149,19 @@ public interface IGenericWizardService extends IService {
|
||||
* @return the default action which will be invoked when double click the node.
|
||||
*/
|
||||
public ITreeContextualAction getDefaultAction(RepositoryNode node);
|
||||
|
||||
public void loadAdditionalJDBC();
|
||||
|
||||
public List<String> getAllAdditionalJDBCTypes();
|
||||
|
||||
public boolean getIfAdditionalJDBCDBType(String dbType);
|
||||
|
||||
public void initAdditonalJDBCConnectionValue(DatabaseConnection connection, Composite dynamicForm, String dbType,
|
||||
String propertyId);
|
||||
|
||||
public String getDefinitionName4AdditionalJDBC(IElement element);
|
||||
|
||||
public String getDatabseNameByNode(IElement node);
|
||||
|
||||
public Dbms getDbms4AdditionalJDBC(String typeName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.talend.core.runtime.util;
|
||||
//============================================================================
|
||||
//
|
||||
//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
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
public interface ComponentsLocationProvider {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.talend.core.runtime.util;
|
||||
//============================================================================
|
||||
//
|
||||
//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
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
public interface SharedStudioInfoProvider {
|
||||
public boolean isSupportCurrentMode();
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.runtime.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.components.IComponentsFactory;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.service.IUpdateService;
|
||||
import org.talend.utils.io.FilesUtils;
|
||||
|
||||
public class SharedStudioUtils {
|
||||
|
||||
public static final String FILE_EXTRA_FEATURE_INDEX = "extra_feature.index"; //$NON-NLS-1$
|
||||
|
||||
public static final String SIGNATURE_FILE_NAME_SUFFIX = ".sig"; //$NON-NLS-1$
|
||||
public static final String PROP_DEVMODE = "osgi.dev"; //$NON-NLS-1$
|
||||
|
||||
public static boolean updateExtraFeatureFile() {
|
||||
File userConfigFolder = new File(Platform.getConfigurationLocation().getURL().getPath());
|
||||
File studioConfigFolder = new File(Platform.getInstallLocation().getURL().getPath(), "configuration");//$NON-NLS-1$
|
||||
if (!userConfigFolder.getAbsolutePath().equals(studioConfigFolder.getAbsolutePath())) {
|
||||
File studioExtraFile = new File(studioConfigFolder, FILE_EXTRA_FEATURE_INDEX);
|
||||
File studioExtraSignFile = new File(studioConfigFolder, FILE_EXTRA_FEATURE_INDEX + SIGNATURE_FILE_NAME_SUFFIX);
|
||||
File userExtraFile = new File(userConfigFolder, FILE_EXTRA_FEATURE_INDEX);
|
||||
File userExtraSignFile = new File(userConfigFolder, FILE_EXTRA_FEATURE_INDEX + SIGNATURE_FILE_NAME_SUFFIX);
|
||||
boolean isNeedUpdate = false;
|
||||
if (!studioExtraSignFile.exists() && userExtraSignFile.exists()) {
|
||||
userExtraSignFile.delete();
|
||||
if (userExtraFile.exists()) {
|
||||
userExtraFile.delete();
|
||||
}
|
||||
return true;
|
||||
} else if (studioExtraSignFile.exists()) {
|
||||
isNeedUpdate = true;
|
||||
}
|
||||
if (isNeedUpdate) {
|
||||
try {
|
||||
FilesUtils.copyFile(studioExtraFile, userExtraFile);
|
||||
FilesUtils.copyFile(studioExtraSignFile, userExtraSignFile);
|
||||
} catch (IOException ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSharedStudioMode() {
|
||||
if (isDevEnvironment()) {
|
||||
return false;
|
||||
}
|
||||
File configFolder = new File (Platform.getConfigurationLocation().getURL().getFile());
|
||||
File studioFolder = new File (Platform.getInstallLocation().getURL().getFile());
|
||||
if (configFolder != null && studioFolder != null && configFolder.getParentFile() != null
|
||||
&& configFolder.getParentFile().getAbsolutePath().equals(studioFolder.getAbsolutePath())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isDevEnvironment() {
|
||||
if (CoreRuntimePlugin.getInstance().getBundle().getBundleContext().getProperty(PROP_DEVMODE) != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean installedPatch() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUpdateService.class)) {
|
||||
IUpdateService updateService = GlobalServiceRegister.getDefault().getService(IUpdateService.class);
|
||||
try {
|
||||
return updateService.syncSharedStudioLibraryInPatch(new NullProgressMonitor());
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static File getSharedStudioComponentsParentFolder() {
|
||||
File configFolder = new File(Platform.getConfigurationLocation().getURL().getFile());
|
||||
return configFolder;
|
||||
}
|
||||
|
||||
public static File getSharedStudioComponentsExtFolder() {
|
||||
File componentFolder = SharedStudioUtils.getSharedStudioComponentsParentFolder();
|
||||
IPath path = new Path(IComponentsFactory.COMPONENTS_INNER_FOLDER);
|
||||
path = path.append(IComponentsFactory.EXTERNAL_COMPONENTS_INNER_FOLDER);
|
||||
File extchangeFolder = new File (componentFolder, path.toOSString());
|
||||
return extchangeFolder;
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,17 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.service;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.talend.core.IService;
|
||||
|
||||
public interface IUpdateService extends IService {
|
||||
|
||||
boolean checkComponentNexusUpdate();
|
||||
|
||||
void syncComponentM2Jars(IProgressMonitor monitor);
|
||||
|
||||
public boolean syncSharedStudioLibraryInPatch(IProgressMonitor monitor) throws Exception;
|
||||
|
||||
public String getSharedStudioMissingPatchVersion();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.ui;
|
||||
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
|
||||
/**
|
||||
* @author hwang
|
||||
*
|
||||
*/
|
||||
public interface IInstalledPatchService extends IService {
|
||||
|
||||
public String getLatestInstalledVersion(boolean isBar);
|
||||
|
||||
public MavenArtifact getLastIntalledP2Patch();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.talend.core.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.talend.commons.CommonsPlugin;
|
||||
|
||||
public class DialogUtils {
|
||||
|
||||
private static ELoginInfoCase finalCase;
|
||||
|
||||
public static void setWarningInfo(ELoginInfoCase warnningInfo) {
|
||||
finalCase = warnningInfo;
|
||||
}
|
||||
|
||||
public static void syncOpenWarningDialog(String title) {
|
||||
if (CommonsPlugin.isHeadless() || DialogUtils.finalCase == null) {
|
||||
return;
|
||||
}
|
||||
int dialogType = DialogUtils.finalCase.getDialogType();
|
||||
String[] contents = DialogUtils.finalCase.getContents();
|
||||
List<String> asList = Arrays.asList(contents);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
asList.forEach(w -> {
|
||||
sb.append(w);
|
||||
sb.append("\n");// $NON-NLS-1$
|
||||
});
|
||||
int[] selectIndex = new int[1];
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String[] dialogButtonLabels = new String[] { IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL, };
|
||||
|
||||
if (dialogType == MessageDialog.ERROR) {
|
||||
dialogButtonLabels = new String[] { IDialogConstants.CANCEL_LABEL };
|
||||
}
|
||||
int open = MessageDialog.open(dialogType, Display.getDefault().getActiveShell(), title, sb.toString(), SWT.NONE,
|
||||
dialogButtonLabels);
|
||||
selectIndex[0] = open;
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
DialogUtils.finalCase = null;
|
||||
if (dialogType == MessageDialog.ERROR) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
if (1 == selectIndex[0]) {
|
||||
throw new OperationCanceledException(""); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.talend.core.utils;
|
||||
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
|
||||
public enum ELoginInfoCase {
|
||||
|
||||
STUDIO_LOWER_THAN_PROJECT(MessageDialog.ERROR),
|
||||
|
||||
STUDIO_HIGHER_THAN_PROJECT(MessageDialog.WARNING);
|
||||
|
||||
private int dialogType;
|
||||
|
||||
private String[] contents;
|
||||
|
||||
ELoginInfoCase(int dialogType) {
|
||||
this.dialogType = dialogType;
|
||||
}
|
||||
|
||||
ELoginInfoCase(int dialogType, String[] contents) {
|
||||
this.dialogType = dialogType;
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
public int getDialogType() {
|
||||
return dialogType;
|
||||
}
|
||||
|
||||
public void setDialogType(int dialogType) {
|
||||
this.dialogType = dialogType;
|
||||
}
|
||||
|
||||
public String[] getContents() {
|
||||
return contents;
|
||||
}
|
||||
|
||||
public void setContents(String[] contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,4 +46,8 @@ public class TrackerUtil {
|
||||
Version version = new Version(strVersion);
|
||||
return getStrVersion(version);
|
||||
}
|
||||
|
||||
public static String getRedshiftTracker() {
|
||||
return "--Talend -v " + getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user