Compare commits
45 Commits
undx/TDI-4
...
patch/TPS-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
990640d3ea | ||
|
|
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 |
73
PATCH_RELEASE_NOTE.md
Normal file
73
PATCH_RELEASE_NOTE.md
Normal file
@@ -0,0 +1,73 @@
|
||||
---
|
||||
version: 7.3.1
|
||||
module: https://talend.poolparty.biz/coretaxonomy/42
|
||||
product:
|
||||
- https://talend.poolparty.biz/coretaxonomy/23
|
||||
---
|
||||
|
||||
# TPS-4452
|
||||
|
||||
| Info | Value |
|
||||
| ---------------- | ---------------- |
|
||||
| Patch Name | Patch\_20201005\_TPS-4452\_v1-7.3.1 |
|
||||
| Release Date | 2020-10-05 |
|
||||
| Target Version | 20200219\_1130-V7.3.1 |
|
||||
| Product affected | Talend Studio |
|
||||
|
||||
## Introduction
|
||||
|
||||
This is a self-contained patch.
|
||||
|
||||
**NOTE**: For information on how to obtain this patch, reach out to your Support contact at Talend.
|
||||
|
||||
## Fixed issues
|
||||
|
||||
This patch contains the following fixes:
|
||||
|
||||
- TPS-4452 [7.3.1] Job fails with Stream closed exception when executed on Job server (TDI-44962)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Consider the following requirements for your system:
|
||||
|
||||
- Talend Studio 7.3.1 with 7.3.1-R2020-09 patch must be installed.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
### Installing the patch using Software update
|
||||
|
||||
1) Logon TAC and switch to Configuration->Software Update, then enter the correct values and save referring to the documentation: https://help.talend.com/reader/f7Em9WV_cPm2RRywucSN0Q/j9x5iXV~vyxMlUafnDejaQ
|
||||
|
||||
2) Switch to Software update page, where the new patch will be listed. The patch can be downloaded from here into the nexus repository.
|
||||
|
||||
3) On Studio Side: Logon Studio with remote mode, on the logon page the Update button is displayed: click this button to install the patch.
|
||||
|
||||
### Installing the patch using Talend Studio
|
||||
|
||||
1) Create a folder named "patches" under your studio installer directory and copy the patch .zip file to this folder.
|
||||
|
||||
2) Restart your studio: a window pops up, then click OK to install the patch, or restart the commandline and the patch will be installed automatically.
|
||||
|
||||
### Installing the patch using Commandline
|
||||
|
||||
Execute the following commands:
|
||||
|
||||
1. Talend-Studio-win-x86_64.exe -nosplash -application org.talend.commandline.CommandLine -consoleLog -data commandline-workspace startServer -p 8002 --talendDebug
|
||||
2. initRemote {tac_url} -ul {TAC login username} -up {TAC login password}
|
||||
3. checkAndUpdate -tu {TAC login username} -tup {TAC login password}
|
||||
|
||||
## Uninstallation
|
||||
Backup the Affected files list below. Uninstall the patch by restore the backup files.
|
||||
|
||||
## Affected files for this patch
|
||||
|
||||
The following files are installed by this patch:
|
||||
|
||||
- {Talend\_Studio\_path}/plugins/org.talend.librariesmanager\_7.3.1.20200924\_0610-patch/resources/java/routines/system/ResumeUtil.java
|
||||
- {Talend\_Studio\_path}/plugins/org.talend.librariesmanager\_7.3.1.20200924\_0610-patch/routines/system/ResumeUtil$JobLogItem.class
|
||||
- {Talend\_Studio\_path}/plugins/org.talend.librariesmanager\_7.3.1.20200924\_0610-patch/routines/system/ResumeUtil$LogPriority.class
|
||||
- {Talend\_Studio\_path}/plugins/org.talend.librariesmanager\_7.3.1.20200924\_0610-patch/routines/system/ResumeUtil$ResumeCommonInfo.class
|
||||
- {Talend\_Studio\_path}/plugins/org.talend.librariesmanager\_7.3.1.20200924\_0610-patch/routines/system/ResumeUtil$ResumeEventType.class
|
||||
- {Talend\_Studio\_path}/plugins/org.talend.librariesmanager\_7.3.1.20200924\_0610-patch/routines/system/ResumeUtil$SimpleCsvWriter.class
|
||||
- {Talend\_Studio\_path}/plugins/org.talend.librariesmanager\_7.3.1.20200924\_0610-patch/routines/system/ResumeUtil.class
|
||||
@@ -16,7 +16,8 @@ Require-Bundle: org.apache.log4j;visibility:=reexport,
|
||||
org.talend.utils,
|
||||
org.eclipse.core.net,
|
||||
org.eclipse.m2e.core,
|
||||
org.eclipse.m2e.maven.runtime
|
||||
org.eclipse.m2e.maven.runtime,
|
||||
org.eclipse.core.resources
|
||||
Export-Package: org.talend.commons,
|
||||
org.talend.commons.exception,
|
||||
org.talend.commons.i18n,
|
||||
|
||||
@@ -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,368 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.text.DecimalFormat;
|
||||
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 DecimalFormat DF = new DecimalFormat("###.##");
|
||||
|
||||
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(), "" + DF.format(digital_ioWAverageMbSec));
|
||||
props.setProperty(StatisticKeys.IO_W_MB_SEC.get(), "" + DF.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(), "" + DF.format(digital_ioRAverageMbSec));
|
||||
props.setProperty(StatisticKeys.IO_R_MB_SEC.get(), "" + DF.format(digital_ioRMbSec));
|
||||
props.setProperty(StatisticKeys.IO_COUNT.get(), "" + digital_ioCount);
|
||||
}
|
||||
|
||||
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,116 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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) {
|
||||
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);
|
||||
log(indent(indent) + "Start '" + idTimer + "' ..."); //$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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -124,6 +126,7 @@ 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;
|
||||
@@ -136,6 +139,7 @@ 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;
|
||||
@@ -177,6 +181,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) {
|
||||
@@ -226,6 +232,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)
|
||||
*
|
||||
@@ -1213,6 +1226,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;
|
||||
@@ -1224,7 +1259,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
|
||||
@@ -1546,14 +1599,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2035,11 +2089,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"); //$NON-NLS-1$
|
||||
try {
|
||||
/**
|
||||
* init/check proxy selector, in case default proxy selector is not registed yet
|
||||
@@ -2083,12 +2133,21 @@ 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());
|
||||
|
||||
// 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);
|
||||
@@ -2106,7 +2165,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);
|
||||
@@ -2124,7 +2183,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);
|
||||
@@ -2133,7 +2192,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$
|
||||
@@ -2141,7 +2200,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);
|
||||
|
||||
@@ -2157,11 +2216,6 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
|
||||
fireRepositoryPropertyChange(ERepositoryActionName.PROJECT_PREFERENCES_RELOAD.getName(), null, null);
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IUpdateService.class)) {
|
||||
IUpdateService updateService = GlobalServiceRegister.getDefault().getService(IUpdateService.class);
|
||||
updateService.syncComponentM2Jars(currentMonitor);
|
||||
}
|
||||
|
||||
IRunProcessService runProcessService = getRunProcessService();
|
||||
if (runProcessService != null) {
|
||||
runProcessService.initMavenJavaProject(monitor, project);
|
||||
@@ -2172,7 +2226,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$
|
||||
}
|
||||
@@ -2188,12 +2242,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$
|
||||
@@ -2219,12 +2273,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 {
|
||||
@@ -2233,6 +2287,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);
|
||||
@@ -2241,7 +2297,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()
|
||||
@@ -2258,10 +2314,7 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
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$
|
||||
@@ -2662,4 +2715,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;
|
||||
@@ -275,6 +277,38 @@ public class RecycleBinManager {
|
||||
resource = createRecycleBinResource(project);
|
||||
}
|
||||
resource.getContents().clear();
|
||||
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);
|
||||
|
||||
@@ -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>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -267,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.
|
||||
*/
|
||||
|
||||
@@ -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$
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.model.context;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -47,12 +48,14 @@ 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.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.cwm.helper.ResourceHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
import org.talend.migration.IMigrationTask.ExecutionResult;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
|
||||
/**
|
||||
@@ -71,6 +74,7 @@ public class ContextUtils {
|
||||
private static final Set<String> SECURE_SENSITIVE_CONTEXT_NAMES_EXP = new HashSet<String>(Arrays.asList("resource_flow_temp_folder", "resource_webhook_payload", "resource_file_[\\w]+",
|
||||
"resource_directory_[\\w]+", "connection_[a-zA-Z0-9]+_[\\w]"));
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* ggu Comment method "isJavaKeyWords".
|
||||
@@ -88,7 +92,7 @@ public class ContextUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* ggu Comment method "isSecureSensitiveParam".
|
||||
@@ -241,7 +245,6 @@ public class ContextUtils {
|
||||
return parameterType;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean checkObject(Object obj) {
|
||||
if (obj == null) {
|
||||
return true;
|
||||
@@ -288,7 +291,7 @@ public class ContextUtils {
|
||||
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
try {
|
||||
final IRepositoryViewObject lastVersion = factory.getLastVersion(contextId);
|
||||
final IRepositoryViewObject lastVersion = factory.getLastVersion(contextId, ERepositoryObjectType.CONTEXT);
|
||||
if (lastVersion != null) {
|
||||
final Item item = lastVersion.getProperty().getItem();
|
||||
if (item != null && item instanceof ContextItem) {
|
||||
@@ -505,9 +508,13 @@ public class ContextUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<ERepositoryObjectType> possibleTypes = new ArrayList<ERepositoryObjectType>();
|
||||
possibleTypes.add(ERepositoryObjectType.CONTEXT);
|
||||
possibleTypes.addAll(ERepositoryObjectType.getAllTypesOfJoblet());
|
||||
possibleTypes.addAll(ERepositoryObjectType.getAllTypesOfProcess());
|
||||
try {
|
||||
final IRepositoryViewObject lastVersion = factory.getLastVersion(contextId);
|
||||
IRepositoryViewObject lastVersion = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory()
|
||||
.getLastVersion(contextId, possibleTypes);
|
||||
if (lastVersion != null) {
|
||||
final Item item = lastVersion.getProperty().getItem();
|
||||
if (item != null) {
|
||||
@@ -601,7 +608,8 @@ public class ContextUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
// preference name must match TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE
|
||||
// preference name must match
|
||||
// TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE
|
||||
return Boolean.parseBoolean(
|
||||
CoreRuntimePlugin.getInstance().getDesignerCoreService().getPreferenceStore("propagateContextVariable")); //$NON-NLS-1$
|
||||
}
|
||||
@@ -1056,4 +1064,70 @@ public class ContextUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ExecutionResult doCreateContextLinkMigration(Item item) {
|
||||
IProxyRepositoryFactory proxyRepositoryFactory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
boolean modified = false, hasLinkFile = false;
|
||||
try {
|
||||
List<ContextType> contextTypeList = ContextUtils.getAllContextType(item);
|
||||
if (contextTypeList != null && contextTypeList.size() > 0) {
|
||||
for (ContextType contextType : contextTypeList) {
|
||||
for (Object obj : contextType.getContextParameter()) {
|
||||
if (obj instanceof ContextParameterType) {
|
||||
ContextParameterType paramType = (ContextParameterType) obj;
|
||||
if (ContextUtils.isBuildInParameter(paramType)) {
|
||||
if (StringUtils.isEmpty(paramType.getInternalId())) {
|
||||
paramType.setInternalId(proxyRepositoryFactory.getNextId());
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
hasLinkFile = ContextLinkService.getInstance().saveContextLink(item);
|
||||
} catch (Exception ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
if (modified || hasLinkFile) {
|
||||
try {
|
||||
if (modified) {
|
||||
proxyRepositoryFactory.save(item, true);
|
||||
}
|
||||
return ExecutionResult.SUCCESS_NO_ALERT;
|
||||
} catch (Exception ex) {
|
||||
ExceptionHandler.process(ex);
|
||||
return ExecutionResult.FAILURE;
|
||||
}
|
||||
}
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
public static ExecutionResult doCreateContextLinkMigration(ERepositoryObjectType repositoryType, Item item) {
|
||||
if (item != null && getAllSupportContextLinkTypes().contains(repositoryType)) {
|
||||
return doCreateContextLinkMigration(item);
|
||||
}
|
||||
return ExecutionResult.NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
public static List<ERepositoryObjectType> getAllSupportContextLinkTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess2());
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfTestContainer());
|
||||
toReturn.addAll(getAllMetaDataType());
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
private static List<ERepositoryObjectType> getAllMetaDataType() {
|
||||
List<ERepositoryObjectType> list = new ArrayList<ERepositoryObjectType>();
|
||||
ERepositoryObjectType[] allTypes = (ERepositoryObjectType[]) ERepositoryObjectType.values();
|
||||
for (ERepositoryObjectType object : allTypes) {
|
||||
if (object.isChildTypeOf(ERepositoryObjectType.METADATA)) {
|
||||
list.add(object);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,15 +18,18 @@ 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;
|
||||
|
||||
|
||||
@@ -106,16 +109,26 @@ public abstract class AbstractItemContextLinkService implements IItemContextLink
|
||||
}
|
||||
|
||||
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
|
||||
IRepositoryService repositoryService = GlobalServiceRegister.getDefault().getService(IRepositoryService.class);
|
||||
|
||||
try {
|
||||
repositoryService.getProxyRepositoryFactory().save(contextItem, false);
|
||||
} catch (PersistenceException e) {
|
||||
@@ -170,6 +183,30 @@ public abstract class AbstractItemContextLinkService implements IItemContextLink
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -119,6 +119,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).
|
||||
|
||||
@@ -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, ...).
|
||||
|
||||
@@ -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,6 +27,7 @@ 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;
|
||||
@@ -70,6 +72,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;
|
||||
@@ -365,6 +368,21 @@ public class ComponentToRepositoryProperty {
|
||||
if (para.getRepositoryValue().endsWith(EDatabaseTypeName.GENERAL_JDBC.getProduct())) {
|
||||
connection.setDatabaseType(EDatabaseTypeName.GENERAL_JDBC.getProduct());
|
||||
connection.setProductId(EDatabaseTypeName.GENERAL_JDBC.getProduct());
|
||||
if (!node.getComponent().getDisplayName().equals(node.getComponent().getName())) {
|
||||
// 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)) {
|
||||
connection.setProductId(database);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// vertica output component have no TYPE ElementParameter .
|
||||
if (para.getRepositoryValue().endsWith(EDatabaseTypeName.VERTICA.getProduct())) {
|
||||
@@ -667,6 +685,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);
|
||||
|
||||
@@ -1755,8 +1755,18 @@ public class RepositoryToComponentProperty {
|
||||
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) {
|
||||
|
||||
@@ -51,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
|
||||
@@ -493,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);
|
||||
@@ -929,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));
|
||||
@@ -945,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.get(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)) {
|
||||
@@ -1022,7 +1050,7 @@ public class RelationshipItemBuilder {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private List<ERepositoryObjectType> allSupportedTypes() {
|
||||
List<ERepositoryObjectType> toReturn = new ArrayList<ERepositoryObjectType>();
|
||||
toReturn.addAll(ERepositoryObjectType.getAllTypesOfProcess());
|
||||
@@ -1494,4 +1522,5 @@ public class RelationshipItemBuilder {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,11 +51,6 @@ public interface ITalendProcessJavaProject {
|
||||
*/
|
||||
IFolder getExternalResourcesFolder();
|
||||
|
||||
/**
|
||||
* src/main/tacokit-resources as external resources folder
|
||||
*/
|
||||
IFolder getTaCoKitResourcesFolder();
|
||||
|
||||
/**
|
||||
* src/main/resources as internal resources folder
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,9 +22,11 @@ import org.talend.components.api.properties.ComponentProperties;
|
||||
import org.talend.core.IService;
|
||||
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 +148,14 @@ 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 initAdditionalJDBCRepositoryObjType();
|
||||
|
||||
public boolean getIfAdditionalJDBCDBType(String dbType);
|
||||
|
||||
public void initAdditonalJDBCConnectionValue(DatabaseConnection connection, Composite dynamicForm, String dbType,
|
||||
String propertyId);
|
||||
|
||||
public String getDatabseNameByNode(IElement node);
|
||||
|
||||
}
|
||||
|
||||
@@ -42,4 +42,9 @@ public abstract class AbstractLoginTask implements ILoginTask {
|
||||
return gc.getTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRequiredAlways() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,4 +27,10 @@ public interface ILoginTask {
|
||||
public boolean isCommandlineTask();
|
||||
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Which indicates the task will be executed for each logon of a project, by default return false(execute only once
|
||||
* at the time of logon studio).
|
||||
*/
|
||||
boolean isRequiredAlways();
|
||||
}
|
||||
|
||||
@@ -268,12 +268,20 @@ public interface IProxyRepositoryFactory {
|
||||
|
||||
public abstract IRepositoryViewObject getLastVersion(Project project, String id, String relativeFolder,
|
||||
ERepositoryObjectType type) throws PersistenceException;
|
||||
|
||||
public abstract IRepositoryViewObject getLastVersion(String id, String folderPath, ERepositoryObjectType type) throws PersistenceException;
|
||||
|
||||
public abstract IRepositoryViewObject getLastVersion(String id, ERepositoryObjectType type) throws PersistenceException;
|
||||
|
||||
public abstract IRepositoryViewObject getLastVersion(String id, List<ERepositoryObjectType> types) throws PersistenceException;
|
||||
|
||||
public abstract IRepositoryViewObject getLastVersion(Project project, String id) throws PersistenceException;
|
||||
|
||||
public abstract IRepositoryViewObject getLastVersion(String id) throws PersistenceException;
|
||||
|
||||
public IRepositoryViewObject getLastRefVersion(Project project, String id) throws PersistenceException;
|
||||
|
||||
public IRepositoryViewObject getLastRefVersion(Project project, String id, String folderPath, ERepositoryObjectType type) throws PersistenceException;
|
||||
|
||||
public abstract IRepositoryViewObject getSpecificVersion(Project project, String id, String version, boolean avoidSaveProject)
|
||||
throws PersistenceException;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jna-platform.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jna.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/oshi-core.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
|
||||
@@ -31,7 +31,10 @@ Require-Bundle: org.apache.commons.lang,
|
||||
org.talend.themes.core,
|
||||
ca.odell.glazedlists,
|
||||
org.talend.core,
|
||||
org.apache.commons.io
|
||||
org.apache.commons.io,
|
||||
org.apache.httpcomponents.httpcore,
|
||||
org.apache.httpcomponents.httpclient,
|
||||
org.slf4j.api
|
||||
Import-Package: org.eclipse.jdt.internal.ui.workingsets
|
||||
Export-Package: org.talend.core.ui,
|
||||
org.talend.core.ui.actions,
|
||||
@@ -79,3 +82,7 @@ Bundle-Vendor: .Talend SA.
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Activator: org.talend.core.ui.CoreUIPlugin
|
||||
Bundle-Localization: plugin
|
||||
Bundle-ClassPath: lib/jna-platform.jar,
|
||||
lib/jna.jar,
|
||||
lib/oshi-core.jar,
|
||||
.
|
||||
|
||||
@@ -5,4 +5,7 @@ bin.includes = .,\
|
||||
icons/,\
|
||||
plugin.properties,\
|
||||
schema/,\
|
||||
META-INF/
|
||||
META-INF/,\
|
||||
lib/jna-platform.jar,\
|
||||
lib/jna.jar,\
|
||||
lib/oshi-core.jar
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
id="org.talend.core.runtime.defaultProvider"
|
||||
name="default">
|
||||
</provider>
|
||||
<provider
|
||||
collector="org.talend.core.ui.token.PerformanceTokenCollector"
|
||||
description="collect such as hardware info, I/O info, startup time"
|
||||
id="org.talend.core.ui.token.PerformanceProvider"
|
||||
name="performance">
|
||||
</provider>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
|
||||
@@ -9,4 +9,42 @@
|
||||
</parent>
|
||||
<artifactId>org.talend.core.ui</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>5.2.5</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includeScope>runtime</includeScope>
|
||||
<outputDirectory>${project.basedir}/lib</outputDirectory>
|
||||
<stripVersion>true</stripVersion>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -75,9 +75,9 @@ public class ComponentsSettingsHelper {
|
||||
hiddenComponents.put(component.getPaletteType(), new HashMap<String, Set<String>>());
|
||||
}
|
||||
if (!component.isVisibleInComponentDefinition()) {
|
||||
hiddenComponents.get(component.getPaletteType()).put(component.getName(), new HashSet<String>());
|
||||
hiddenComponents.get(component.getPaletteType()).put(component.getDisplayName(), new HashSet<String>());
|
||||
for (String family : component.getOriginalFamilyName().split(ComponentsFactoryProvider.FAMILY_SEPARATOR_REGEX)) {
|
||||
hiddenComponents.get(component.getPaletteType()).get(component.getName()).add(family);
|
||||
hiddenComponents.get(component.getPaletteType()).get(component.getDisplayName()).add(family);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,8 +168,8 @@ public class ComponentsSettingsHelper {
|
||||
}
|
||||
|
||||
if (hiddenComponents.containsKey(component.getPaletteType())) {
|
||||
if (hiddenComponents.get(component.getPaletteType()).containsKey(component.getName())) {
|
||||
if (hiddenComponents.get(component.getPaletteType()).get(component.getName()).contains(family)) {
|
||||
if (hiddenComponents.get(component.getPaletteType()).containsKey(component.getDisplayName())) {
|
||||
if (hiddenComponents.get(component.getPaletteType()).get(component.getDisplayName()).contains(family)) {
|
||||
// not visible if in the hidden component list;
|
||||
return false;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public class ComponentsSettingsHelper {
|
||||
EList list = emfProject.getComponentsSettings();
|
||||
if (!list.isEmpty()) {
|
||||
list.clear();
|
||||
IRepositoryService service = (IRepositoryService) GlobalServiceRegister.getDefault().getService(
|
||||
IRepositoryService service = GlobalServiceRegister.getDefault().getService(
|
||||
IRepositoryService.class);
|
||||
|
||||
IProxyRepositoryFactory prf = service.getProxyRepositoryFactory();
|
||||
|
||||
@@ -29,6 +29,8 @@ public class ContextAutoResizeTextPainter extends TextPainter {
|
||||
|
||||
private boolean changeBackgroundColor = false;
|
||||
|
||||
private boolean containsRowName = false;
|
||||
|
||||
public ContextAutoResizeTextPainter(boolean wrapText, boolean paintBg, boolean calculate) {
|
||||
super(wrapText, paintBg, calculate);
|
||||
}
|
||||
@@ -43,6 +45,8 @@ public class ContextAutoResizeTextPainter extends TextPainter {
|
||||
super.setupGCFromConfig(gc, cellStyle);
|
||||
if (cellStyle.getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR).equals(GUIHelper.COLOR_RED)) {
|
||||
gc.setForeground(GUIHelper.COLOR_BLACK);
|
||||
} else if (containsRowName) {
|
||||
gc.setForeground(GUIHelper.COLOR_RED);
|
||||
} else if (changeBackgroundColor) {
|
||||
gc.setForeground(GUIHelper.COLOR_WIDGET_DARK_SHADOW);
|
||||
}
|
||||
@@ -52,6 +56,9 @@ public class ContextAutoResizeTextPainter extends TextPainter {
|
||||
changeBackgroundColor = isChange;
|
||||
}
|
||||
|
||||
public void setContainsRowName(boolean containsRowName) {
|
||||
this.containsRowName = containsRowName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setNewMinLength(ILayerCell cell, int contentWidth) {
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.ui.context.nattableTree;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
|
||||
import org.eclipse.nebula.widgets.nattable.data.IDataProvider;
|
||||
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsDataProvider;
|
||||
@@ -23,6 +28,7 @@ import org.eclipse.swt.graphics.GC;
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.talend.core.ui.context.ContextTreeTable.ContextTreeNode;
|
||||
import org.talend.core.ui.context.model.ContextTabChildModel;
|
||||
import org.talend.core.ui.context.model.ContextTabParentModel;
|
||||
import org.talend.core.ui.context.model.table.ContextTableTabParentModel;
|
||||
|
||||
/**
|
||||
@@ -33,6 +39,8 @@ public class ContextNatTableBackGroudPainter extends BackgroundPainter {
|
||||
|
||||
private IDataProvider dataProvider;
|
||||
|
||||
private Map<String, String> rowNames = new HashMap<String, String>();
|
||||
|
||||
public ContextNatTableBackGroudPainter(ICellPainter painter, IDataProvider dataProvider) {
|
||||
super(painter);
|
||||
this.dataProvider = dataProvider;
|
||||
@@ -53,9 +61,11 @@ public class ContextNatTableBackGroudPainter extends BackgroundPainter {
|
||||
ContextTabChildModel rowChildModel = (ContextTabChildModel) rowNode.getTreeData();
|
||||
if (rowChildModel != null) {
|
||||
((ContextAutoResizeTextPainter) getWrappedPainter()).setChangeBackgroundColor(true);
|
||||
checkContainsRowName(rowNode, rowChildModel);
|
||||
}
|
||||
}
|
||||
super.paintCell(cell, gc, bounds, configRegistry);
|
||||
((ContextAutoResizeTextPainter) getWrappedPainter()).setContainsRowName(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,4 +73,33 @@ public class ContextNatTableBackGroudPainter extends BackgroundPainter {
|
||||
return super.getBackgroundColour(cell, configRegistry);
|
||||
}
|
||||
|
||||
private void checkContainsRowName(ContextTreeNode rowNode, ContextTabChildModel rowChildModel) {
|
||||
// Check any duplicate / similar variable from different context to show in red .
|
||||
String rowName = rowNode.getName();
|
||||
String parentSourceName = null;
|
||||
ContextTabParentModel rowTabParentModel = rowChildModel.getParent();
|
||||
if (rowTabParentModel != null && rowTabParentModel instanceof ContextTableTabParentModel) {
|
||||
ContextTableTabParentModel rowTableTabParentModel = (ContextTableTabParentModel) rowTabParentModel;
|
||||
parentSourceName = rowTableTabParentModel.getSourceName();
|
||||
}
|
||||
if (StringUtils.isNotBlank(rowName) && StringUtils.isNotBlank(parentSourceName)) {
|
||||
rowName = rowName.toUpperCase();
|
||||
parentSourceName = parentSourceName.toUpperCase();
|
||||
if (rowNames.containsValue(rowName)) {
|
||||
Iterator<String> iterator = rowNames.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String key = iterator.next();
|
||||
String value = rowNames.get(key);
|
||||
if (rowName.equalsIgnoreCase(value)) {
|
||||
if (!parentSourceName.equalsIgnoreCase(key)) {
|
||||
((ContextAutoResizeTextPainter) getWrappedPainter()).setContainsRowName(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rowNames.put(parentSourceName, rowName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
|
||||
jsonObject.put("os.arch", System.getProperty("os.arch"));
|
||||
jsonObject.put("os.version", System.getProperty("os.version"));
|
||||
tokenStudioObject.put(OS.getKey(), jsonObject);
|
||||
|
||||
|
||||
final IPreferenceStore preferenceStore = CoreUIPlugin.getDefault().getPreferenceStore();
|
||||
long syncNb = preferenceStore.getLong(COLLECTOR_SYNC_NB);
|
||||
tokenStudioObject.put(SYNC_NB.getKey(), syncNb);
|
||||
@@ -91,6 +91,7 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
|
||||
} else {
|
||||
tokenStudioObject.put(STOP_COLLECTOR.getKey(), "0"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return tokenStudioObject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.ui.token;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.talend.commons.exception.CommonExceptionHandler;
|
||||
import org.talend.commons.utils.time.PerformanceStatisticUtil;
|
||||
import org.talend.commons.utils.time.PerformanceStatisticUtil.StatisticKeys;
|
||||
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.Baseboard;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.CentralProcessor.ProcessorIdentifier;
|
||||
import oshi.hardware.ComputerSystem;
|
||||
import oshi.hardware.GlobalMemory;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import us.monoid.json.JSONObject;
|
||||
|
||||
/**
|
||||
* DOC sbliu class global comment. Detailled comment
|
||||
*/
|
||||
public class PerformanceTokenCollector extends AbstractTokenCollector {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.talend.core.ui.token.AbstractTokenCollector#collect()
|
||||
*/
|
||||
@Override
|
||||
public JSONObject collect() throws Exception {
|
||||
checkAndWait();
|
||||
|
||||
JSONObject tokenStudioObject = new JSONObject();
|
||||
//
|
||||
JSONObject jsonObjectHDInfo = new JSONObject();
|
||||
|
||||
SystemInfo si = new SystemInfo();
|
||||
HardwareAbstractionLayer hal = si.getHardware();
|
||||
CentralProcessor processor = hal.getProcessor();
|
||||
ProcessorIdentifier processorIdentifier = processor.getProcessorIdentifier();
|
||||
ComputerSystem cs = hal.getComputerSystem();//computer system
|
||||
Baseboard baseboard = cs.getBaseboard();//motherboard
|
||||
GlobalMemory memory = hal.getMemory();
|
||||
|
||||
jsonObjectHDInfo.put("computer vendor", cs.getManufacturer());
|
||||
jsonObjectHDInfo.put("board vendor", baseboard.getManufacturer());
|
||||
jsonObjectHDInfo.put("board version", baseboard.getVersion());
|
||||
jsonObjectHDInfo.put("processor", processorIdentifier.getName());
|
||||
jsonObjectHDInfo.put("physical memory", Math.ceil((memory.getTotal() /(1024d*1024*1024))) + "GB");
|
||||
tokenStudioObject.put("hardware", jsonObjectHDInfo);
|
||||
|
||||
//
|
||||
JSONObject jsonObjectIOInfo = new JSONObject();
|
||||
Properties props = PerformanceStatisticUtil.read(PerformanceStatisticUtil.getRecordingFile(),false);
|
||||
jsonObjectIOInfo.put(StatisticKeys.STARTUP_AVERAGE.get(), props.getProperty(StatisticKeys.STARTUP_AVERAGE.get()));
|
||||
jsonObjectIOInfo.put(StatisticKeys.STARTUP_MAX.get(), props.getProperty(StatisticKeys.STARTUP_MAX.get()));
|
||||
jsonObjectIOInfo.put(StatisticKeys.IO_R_MB_SEC.get(), props.getProperty(StatisticKeys.IO_R_MB_SEC.get()));
|
||||
jsonObjectIOInfo.put(StatisticKeys.IO_R_AVERAGE_MB_SEC.get(), props.getProperty(StatisticKeys.IO_R_AVERAGE_MB_SEC.get()));
|
||||
jsonObjectIOInfo.put(StatisticKeys.IO_W_MB_SEC.get(), props.getProperty(StatisticKeys.IO_W_MB_SEC.get()));
|
||||
jsonObjectIOInfo.put(StatisticKeys.IO_W_AVERAGE_MB_SEC.get(), props.getProperty(StatisticKeys.IO_W_AVERAGE_MB_SEC.get()));
|
||||
tokenStudioObject.put("performance", jsonObjectIOInfo);
|
||||
|
||||
return tokenStudioObject;
|
||||
}
|
||||
|
||||
private void checkAndWait() {
|
||||
try {
|
||||
PerformanceStatisticUtil.waitUntilFinish();
|
||||
} catch (InterruptedException e) {
|
||||
CommonExceptionHandler.log(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,15 +14,39 @@ package org.talend.core.ui.token;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.Authenticator;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.net.Proxy;
|
||||
import java.net.Proxy.Type;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.protocol.HttpClientContext;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.entity.mime.content.ByteArrayBody;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
@@ -36,17 +60,13 @@ import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.ui.preferences.ScopedPreferenceStore;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.network.NetworkUtil;
|
||||
import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.core.ui.CoreUIPlugin;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
|
||||
import us.monoid.json.JSONObject;
|
||||
import us.monoid.web.AbstractContent;
|
||||
import us.monoid.web.FormData;
|
||||
import us.monoid.web.Resty;
|
||||
import us.monoid.web.TextResource;
|
||||
import us.monoid.web.mime.MultipartContent;
|
||||
|
||||
/**
|
||||
* ggu class global comment. Detailled comment
|
||||
@@ -214,26 +234,18 @@ public final class TokenCollectorFactory {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
if (NetworkUtil.isNetworkValid()) {
|
||||
Authenticator defaultAuth = NetworkUtil.getDefaultAuthenticator();
|
||||
try {
|
||||
JSONObject tokenInfors = collectTokenInfors();
|
||||
Resty r = new Resty();
|
||||
// set back the rath for Resty.
|
||||
Field rathField = Resty.class.getDeclaredField("rath"); //$NON-NLS-1$
|
||||
rathField.setAccessible(true);
|
||||
Authenticator auth = (Authenticator) rathField.get(null);
|
||||
Authenticator.setDefault(auth);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzos = new GZIPOutputStream(baos);
|
||||
gzos.write(tokenInfors.toString().getBytes());
|
||||
gzos.close();
|
||||
AbstractContent ac = Resty.content(baos.toByteArray());
|
||||
byte[] data = baos.toByteArray();
|
||||
baos.close();
|
||||
MultipartContent mpc = Resty.form(new FormData("data", ac)); //$NON-NLS-1$
|
||||
|
||||
TextResource result = r.text("https://www.talend.com/TalendRegisterWS/tokenstudio_v2.php", mpc); //$NON-NLS-1$
|
||||
String resultStr = new JSONObject(result.toString()).getString("result"); //$NON-NLS-1$
|
||||
String responseString = sendData(data);
|
||||
String resultStr = new JSONObject(responseString).getString("result"); //$NON-NLS-1$
|
||||
boolean okReturned = (resultStr != null && resultStr.endsWith("OK")); //$NON-NLS-1$
|
||||
if (okReturned) {
|
||||
// set new days
|
||||
@@ -253,7 +265,6 @@ public final class TokenCollectorFactory {
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
} finally {
|
||||
Authenticator.setDefault(defaultAuth);
|
||||
}
|
||||
}
|
||||
return org.eclipse.core.runtime.Status.OK_STATUS;
|
||||
@@ -274,4 +285,84 @@ public final class TokenCollectorFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addProxy(String url, HttpClientBuilder clientBuilder) throws URISyntaxException {
|
||||
TalendProxySelector proxySelector = TalendProxySelector.getInstance();
|
||||
final List<Proxy> proxyList = proxySelector.getDefaultProxySelector().select(new URI(url));
|
||||
Proxy usedProxy = null;
|
||||
if (proxyList != null && !proxyList.isEmpty()) {
|
||||
usedProxy = proxyList.get(0);
|
||||
}
|
||||
|
||||
if (usedProxy != null) {
|
||||
if (!Type.DIRECT.equals(usedProxy.type())) {
|
||||
final Proxy finalProxy = usedProxy;
|
||||
InetSocketAddress address = (InetSocketAddress) finalProxy.address();
|
||||
String proxyServer = address.getHostString();
|
||||
int proxyPort = address.getPort();
|
||||
PasswordAuthentication proxyAuthentication = proxySelector.getHttpPasswordAuthentication();
|
||||
if (proxyAuthentication != null) {
|
||||
String proxyUser = proxyAuthentication.getUserName();
|
||||
if (StringUtils.isNotBlank(proxyUser)) {
|
||||
String proxyPassword = "";
|
||||
char[] passwordChars = proxyAuthentication.getPassword();
|
||||
if (passwordChars != null) {
|
||||
proxyPassword = new String(passwordChars);
|
||||
}
|
||||
BasicCredentialsProvider credProvider = new BasicCredentialsProvider();
|
||||
credProvider.setCredentials(new AuthScope(proxyServer, proxyPort),
|
||||
new UsernamePasswordCredentials(proxyUser, proxyPassword));
|
||||
clientBuilder.setDefaultCredentialsProvider(credProvider);
|
||||
}
|
||||
}
|
||||
HttpHost proxyHost = new HttpHost(proxyServer, proxyPort);
|
||||
clientBuilder.setProxy(proxyHost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String sendData(byte[] data) throws Exception {
|
||||
CloseableHttpClient client = null;
|
||||
CloseableHttpResponse response = null;
|
||||
try {
|
||||
final String url = "https://www.talend.com/TalendRegisterWS/tokenstudio_v2.php";
|
||||
|
||||
HttpClientBuilder clientBuilder = HttpClients.custom();
|
||||
clientBuilder.disableCookieManagement();
|
||||
addProxy(url, clientBuilder);
|
||||
client = clientBuilder.build();
|
||||
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
httpPost.setConfig(RequestConfig.DEFAULT);
|
||||
|
||||
MultipartEntityBuilder dataBuilder = MultipartEntityBuilder.create();
|
||||
dataBuilder.addPart("data", new ByteArrayBody(data, null));
|
||||
HttpEntity reqEntity = dataBuilder.build();
|
||||
httpPost.setEntity(reqEntity);
|
||||
|
||||
response = client.execute(httpPost, HttpClientContext.create());
|
||||
StatusLine statusLine = response.getStatusLine();
|
||||
String responseStr = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
if (HttpURLConnection.HTTP_OK != statusLine.getStatusCode()) {
|
||||
throw new Exception(statusLine.toString() + ", server message: [" + responseStr + "]");
|
||||
}
|
||||
return responseStr;
|
||||
} finally {
|
||||
if (response != null) {
|
||||
try {
|
||||
response.close();
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
if (client != null) {
|
||||
try {
|
||||
client.close();
|
||||
} catch (Throwable e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@ import org.eclipse.emf.common.util.URI;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.exception.SystemException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
|
||||
/**
|
||||
@@ -78,4 +80,18 @@ public interface ICoreTisService extends IService {
|
||||
|
||||
Set<String> getComponentBlackList();
|
||||
|
||||
public void afterImport (Property property) throws PersistenceException;
|
||||
|
||||
boolean hasNewPatchInPatchesFolder();
|
||||
|
||||
boolean isDefaultLicenseAndProjectType();
|
||||
|
||||
void refreshPatchesFolderCache();
|
||||
|
||||
static ICoreTisService get() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1492,15 +1492,13 @@ public class ProcessorUtilities {
|
||||
}
|
||||
while (relativepath.hasNext()) {
|
||||
String relativePath = relativepath.next();
|
||||
if (!(relativePath.startsWith("MAVEN-INF") || relativePath.startsWith("TALEND-INF"))) {
|
||||
Set<URL> sources = resouece.getResourcesByRelativePath(relativePath);
|
||||
for (URL sourceUrl : sources) {
|
||||
File currentResource = new File(
|
||||
org.talend.commons.utils.io.FilesUtils.getFileRealPath(sourceUrl.getPath()));
|
||||
if (currentResource.exists()) {
|
||||
FilesUtils.copyDirectory(currentResource, new File(
|
||||
targetFolder.getLocation().toPortableString() + File.separator + pathStr));
|
||||
}
|
||||
Set<URL> sources = resouece.getResourcesByRelativePath(relativePath);
|
||||
for (URL sourceUrl : sources) {
|
||||
File currentResource = new File(
|
||||
org.talend.commons.utils.io.FilesUtils.getFileRealPath(sourceUrl.getPath()));
|
||||
if (currentResource.exists()) {
|
||||
FilesUtils.copyDirectory(currentResource, new File(
|
||||
targetFolder.getLocation().toPortableString() + File.separator + pathStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>studio-tacokit-dependencies</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
<tacokit.components.version>1.9.0</tacokit.components.version>
|
||||
<tacokit.components.version>1.13.0</tacokit.components.version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<tcomp.version>1.1.15</tcomp.version>
|
||||
<tcomp.version>1.1.25</tcomp.version>
|
||||
<slf4j.version>1.7.25</slf4j.version>
|
||||
</properties>
|
||||
|
||||
@@ -106,6 +106,11 @@
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.14</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -27,8 +27,6 @@ public class MavenSystemFolders {
|
||||
|
||||
public static final ProjectSystemFolder EXT_RESOURCES = new ProjectSystemFolder("src/main/ext-resources", "target/classes");
|
||||
|
||||
public static final ProjectSystemFolder TCK_RESOURCES = new ProjectSystemFolder("src/main/tacokit-resources", "target/classes");
|
||||
|
||||
public static final ProjectSystemFolder BUNDLE_RESOURCES = new ProjectSystemFolder("src/main/bundle-resources", "target/classes");
|
||||
|
||||
public static final ProjectSystemFolder RESOURCES_TEST = new ProjectSystemFolder("src/test/resources", "target/test-classes");
|
||||
|
||||
@@ -17,7 +17,9 @@ import static org.talend.designer.maven.model.TalendJavaProjectConstants.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -55,6 +57,7 @@ import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
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.process.ProcessUtils;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ProjectReference;
|
||||
@@ -169,9 +172,18 @@ public class AggregatorPomsHelper {
|
||||
|
||||
@Override
|
||||
protected void run() {
|
||||
updateCodeProject(monitor, ERepositoryObjectType.ROUTINES, forceBuild);
|
||||
if (ProcessUtils.isRequiredBeans(null)) {
|
||||
updateCodeProject(monitor, ERepositoryObjectType.valueOf("BEANS"), forceBuild); //$NON-NLS-1$
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
for (ERepositoryObjectType codeType : ERepositoryObjectType.getAllTypesOfCodes()) {
|
||||
try {
|
||||
if (CodeM2CacheManager.needUpdateCodeProject(currentProject, codeType)) {
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
|
||||
buildAndInstallCodesProject(monitor, codeType, true, forceBuild);
|
||||
CodeM2CacheManager.updateCodeProjectCache(currentProject, codeType);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -179,16 +191,6 @@ public class AggregatorPomsHelper {
|
||||
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);
|
||||
}
|
||||
|
||||
private void updateCodeProject(IProgressMonitor monitor, ERepositoryObjectType codeType, boolean forceBuild) {
|
||||
try {
|
||||
ITalendProcessJavaProject codeProject = getCodesProject(codeType);
|
||||
updateCodeProjectPom(monitor, codeType, codeProject.getProjectPom());
|
||||
buildAndInstallCodesProject(monitor, codeType, true, forceBuild);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateCodeProjectPom(IProgressMonitor monitor, ERepositoryObjectType type, IFile pomFile)
|
||||
throws Exception {
|
||||
if (type != null) {
|
||||
@@ -209,27 +211,15 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
|
||||
public static void updateAllCodesProjectNeededModules(IProgressMonitor monitor) {
|
||||
updateCodesProjectNeededModulesByType(ERepositoryObjectType.ROUTINES, monitor);
|
||||
if (ProcessUtils.isRequiredBeans(null)) {
|
||||
updateCodesProjectNeededModulesByType(ERepositoryObjectType.valueOf("BEANS"), monitor); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateCodesProjectNeededModulesByType(ERepositoryObjectType codeType,
|
||||
IProgressMonitor monitor) {
|
||||
Set<ModuleNeeded> neededModules = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
|
||||
ILibrariesService librariesService =
|
||||
(ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
|
||||
neededModules = librariesService.getCodesModuleNeededs(codeType);
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
ILibraryManagerService repositoryBundleService =
|
||||
(ILibraryManagerService) GlobalServiceRegister.getDefault().getService(
|
||||
ILibraryManagerService.class);
|
||||
if (neededModules != null && !neededModules.isEmpty()) {
|
||||
repositoryBundleService.installModules(neededModules, monitor);
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)
|
||||
&& GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
|
||||
Set<ModuleNeeded> neededModules = new HashSet<>();
|
||||
ILibrariesService librariesService = GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
|
||||
ERepositoryObjectType.getAllTypesOfCodes()
|
||||
.forEach(c -> neededModules.addAll(librariesService.getCodesModuleNeededs(c)));
|
||||
ILibraryManagerService repositoryBundleService = GlobalServiceRegister.getDefault()
|
||||
.getService(ILibraryManagerService.class);
|
||||
repositoryBundleService.installModules(neededModules, monitor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +256,7 @@ public class AggregatorPomsHelper {
|
||||
if (install) {
|
||||
Map<String, Object> argumentsMap = new HashMap<>();
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_GOAL, TalendMavenConstants.GOAL_INSTALL);
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_PROGRAM_ARGUMENTS, "-Dmaven.main.skip=true"); //$NON-NLS-1$
|
||||
argumentsMap.put(TalendProcessArgumentConstant.ARG_PROGRAM_ARGUMENTS, TalendMavenConstants.ARG_MAIN_SKIP);
|
||||
codeProject.buildModules(monitor, null, argumentsMap);
|
||||
BuildCacheManager.getInstance().updateCodeLastBuildDate(codeType);
|
||||
}
|
||||
@@ -328,26 +318,10 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
|
||||
public static void addToParentModules(IFile pomFile, Property property, boolean checkFilter) throws Exception {
|
||||
// Check relation for ESB service job, should not be added into main pom
|
||||
if (property != null) {
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(property.getId(),
|
||||
property.getVersion(), RelationshipItemBuilder.JOB_RELATION);
|
||||
for (Relation relation : relations) {
|
||||
if (RelationshipItemBuilder.SERVICES_RELATION.equals(relation.getType())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!checkIfCanAddToParentModules(property, checkFilter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkFilter) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IFilterService.class)) {
|
||||
IFilterService filterService = (IFilterService) GlobalServiceRegister.getDefault()
|
||||
.getService(IFilterService.class);
|
||||
if (property != null && !filterService.isFilterAccepted(property.getItem(), PomIdsHelper.getPomFilter())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
IFile parentPom = getParentModulePomFile(pomFile);
|
||||
if (parentPom != null) {
|
||||
if (!parentPom.isSynchronized(IResource.DEPTH_ZERO)) {
|
||||
@@ -367,6 +341,36 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkIfCanAddToParentModules(Property property, boolean checkFilter) {
|
||||
// Check relation for ESB service job, should not be added into main pom
|
||||
if (property != null) {
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(property.getId(),
|
||||
property.getVersion(), RelationshipItemBuilder.JOB_RELATION);
|
||||
for (Relation relation : relations) {
|
||||
if (RelationshipItemBuilder.SERVICES_RELATION.equals(relation.getType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// for import won't add for exclude option
|
||||
if (property.getItem() != null && property.getItem().getState() != null && property.getItem().getState().isDeleted()
|
||||
&& PomIdsHelper.getIfExcludeDeletedItems(property)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkFilter) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IFilterService.class)) {
|
||||
IFilterService filterService = (IFilterService) GlobalServiceRegister.getDefault()
|
||||
.getService(IFilterService.class);
|
||||
if (property != null && !filterService.isFilterAccepted(property.getItem(), PomIdsHelper.getPomFilter())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void removeFromParentModules(IFile pomFile) throws Exception {
|
||||
IFile parentPom = getParentModulePomFile(pomFile);
|
||||
if (parentPom != null) {
|
||||
@@ -384,6 +388,69 @@ public class AggregatorPomsHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeAllVersionsFromParentModules(Property property) throws Exception {
|
||||
IFile parentPom = getParentModulePomFile(
|
||||
AggregatorPomsHelper.getItemPomFolder(property).getFile(TalendMavenConstants.POM_FILE_NAME));
|
||||
if (parentPom == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> relativePathList = new ArrayList<String>();
|
||||
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(property.getId());
|
||||
for (IRepositoryViewObject object : allVersion) {
|
||||
IFile pomFile = AggregatorPomsHelper.getItemPomFolder(object.getProperty())
|
||||
.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
String relativePath = pomFile.getParent().getLocation().makeRelativeTo(parentPom.getParent().getLocation())
|
||||
.toPortableString();
|
||||
if (StringUtils.isNotBlank(relativePath)) {
|
||||
relativePathList.add(relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
Model model = MavenPlugin.getMaven().readModel(parentPom.getContents());
|
||||
List<String> modules = model.getModules();
|
||||
if (modules != null && modules.size() > 0) {
|
||||
modules.removeAll(relativePathList);
|
||||
PomUtil.savePom(null, model, parentPom);
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreAllVersionsFromParentModules(Property property) throws Exception {
|
||||
IFile parentPom = getParentModulePomFile(
|
||||
AggregatorPomsHelper.getItemPomFolder(property).getFile(TalendMavenConstants.POM_FILE_NAME));
|
||||
if (parentPom == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> relativePathList = new ArrayList<String>();
|
||||
Model model = MavenPlugin.getMaven().readModel(parentPom.getContents());
|
||||
List<String> modules = model.getModules();
|
||||
if (modules == null) {
|
||||
modules = new ArrayList<>();
|
||||
model.setModules(modules);
|
||||
}
|
||||
|
||||
List<IRepositoryViewObject> allVersion = ProxyRepositoryFactory.getInstance().getAllVersion(property.getId());
|
||||
for (IRepositoryViewObject object : allVersion) {
|
||||
Property itemProperty = object.getProperty();
|
||||
if (!checkIfCanAddToParentModules(itemProperty, true)) {
|
||||
continue;
|
||||
}
|
||||
IFile pomFile = AggregatorPomsHelper.getItemPomFolder(object.getProperty(), object.getVersion())
|
||||
.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
|
||||
String relativePath = pomFile.getParent().getLocation().makeRelativeTo(parentPom.getParent().getLocation())
|
||||
.toPortableString();
|
||||
if (StringUtils.isNoneBlank(relativePath) && !modules.contains(relativePath)) {
|
||||
relativePathList.add(relativePath);
|
||||
}
|
||||
}
|
||||
Collections.sort(relativePathList);
|
||||
modules.addAll(relativePathList);
|
||||
PomUtil.savePom(null, model, parentPom);
|
||||
|
||||
}
|
||||
|
||||
private static IFile getParentModulePomFile(IFile pomFile) {
|
||||
IFile parentPom = null;
|
||||
if (pomFile == null || pomFile.getParent() == null || pomFile.getParent().getParent() == null) {
|
||||
@@ -538,7 +605,10 @@ public class AggregatorPomsHelper {
|
||||
String jobFolderName = getJobProjectFolderName(property.getLabel(), version);
|
||||
ERepositoryObjectType type = ERepositoryObjectType.getItemType(property.getItem());
|
||||
IFolder jobFolder = helper.getProcessFolder(type).getFolder(itemRelativePath).getFolder(jobFolderName);
|
||||
createFoldersIfNeeded(jobFolder);
|
||||
List<ERepositoryObjectType> allTypesOfProcess2 = ERepositoryObjectType.getAllTypesOfProcess2();
|
||||
if (allTypesOfProcess2.contains(type)) {
|
||||
createFoldersIfNeeded(jobFolder);
|
||||
}
|
||||
return jobFolder;
|
||||
}
|
||||
|
||||
|
||||
@@ -395,4 +395,24 @@ public class BuildCacheManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsMultipleVersionModules() {
|
||||
return containsMultipleVersionModules(currentJobletmodules) || containsMultipleVersionModules(currentJobmodules);
|
||||
}
|
||||
|
||||
private static boolean containsMultipleVersionModules(Set<String> mods) {
|
||||
Set<String> joblets = new HashSet<String>();
|
||||
for (String mod : mods) {
|
||||
int idx = mod.lastIndexOf('_');
|
||||
if (idx == -1) {
|
||||
continue;
|
||||
}
|
||||
String jobletWithoutVersion = mod.substring(0, idx);
|
||||
if (joblets.contains(jobletWithoutVersion)) {
|
||||
return true;
|
||||
} else {
|
||||
joblets.add(jobletWithoutVersion);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.tools;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.repository.item.ItemProductKeys;
|
||||
import org.talend.cwm.helper.ResourceHelper;
|
||||
import org.talend.designer.maven.utils.PomIdsHelper;
|
||||
|
||||
public class CodeM2CacheManager {
|
||||
|
||||
private static final String KEY_SEPERATOR = "|"; //$NON-NLS-1$
|
||||
|
||||
public static boolean needUpdateCodeProject(Project project, ERepositoryObjectType codeType) {
|
||||
try {
|
||||
String projectTechName = project.getTechnicalLabel();
|
||||
File cacheFile = getCacheFile(projectTechName, codeType);
|
||||
if (!cacheFile.exists()) {
|
||||
return true;
|
||||
}
|
||||
Properties cache = new Properties();
|
||||
cache.load(new FileInputStream(cacheFile));
|
||||
List<IRepositoryViewObject> allCodes = ProxyRepositoryFactory.getInstance().getAll(project, codeType, false);
|
||||
// check A/D
|
||||
if (allCodes.size() != cache.size()) {
|
||||
return true;
|
||||
}
|
||||
// check M
|
||||
for (IRepositoryViewObject codeItem : allCodes) {
|
||||
Property property = codeItem.getProperty();
|
||||
String key = getCacheKey(projectTechName, property);
|
||||
String cachedTimestamp = cache.getProperty(key);
|
||||
if (cachedTimestamp != null) {
|
||||
Date currentDate = ResourceHelper.dateFormat().parse(getCacheDate(projectTechName, property));
|
||||
Date cachedDate = ResourceHelper.dateFormat().parse(cachedTimestamp);
|
||||
if (currentDate.compareTo(cachedDate) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException | IOException | ParseException e) {
|
||||
ExceptionHandler.process(e);
|
||||
// if any exception, still update in case breaking build job
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void updateCodeProjectCache(Project project, ERepositoryObjectType codeType) {
|
||||
String projectTechName = project.getTechnicalLabel();
|
||||
File cacheFile = getCacheFile(projectTechName, codeType);
|
||||
try (OutputStream out = new FileOutputStream(cacheFile)) {
|
||||
List<IRepositoryViewObject> allCodes = ProxyRepositoryFactory.getInstance().getAll(project, codeType, false);
|
||||
Properties cache = new Properties();
|
||||
for (IRepositoryViewObject codeItem : allCodes) {
|
||||
Property property = codeItem.getProperty();
|
||||
String key = getCacheKey(projectTechName, property);
|
||||
String value = getCacheDate(projectTechName, property);
|
||||
cache.put(key, value);
|
||||
}
|
||||
cache.store(out, StringUtils.EMPTY);
|
||||
} catch (PersistenceException | IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static File getCacheFile(String projectTechName, ERepositoryObjectType codeType) {
|
||||
String cacheFileName = PomIdsHelper.getProjectGroupId(projectTechName) + "." + codeType.name().toLowerCase() + "-" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ PomIdsHelper.getCodesVersion(projectTechName) + ".cache"; // $NON-NLS-1$
|
||||
return new File(MavenPlugin.getMaven().getLocalRepositoryPath(), cacheFileName);
|
||||
}
|
||||
|
||||
private static String getCacheKey(String projectTechName, Property property) {
|
||||
return projectTechName + KEY_SEPERATOR + property.getId() + KEY_SEPERATOR + property.getVersion(); // $NON-NLS-1$
|
||||
}
|
||||
|
||||
private static String getCacheDate(String projectTechName, Property property) {
|
||||
return (String) property.getAdditionalProperties().get(ItemProductKeys.DATE.getModifiedKey());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.runtime.process.LastGenerationInfo;
|
||||
import org.talend.core.runtime.process.TalendProcessOptionConstants;
|
||||
import org.talend.core.service.ITaCoKitDependencyService;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.maven.utils.SortableDependency;
|
||||
@@ -51,16 +50,9 @@ public class ProcessorDependenciesManager {
|
||||
|
||||
private final Property property;
|
||||
|
||||
private final ITaCoKitDependencyService tckService;
|
||||
|
||||
public ProcessorDependenciesManager(IProcessor processor) {
|
||||
this.processor = processor;
|
||||
property = processor.getProperty();
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITaCoKitDependencyService.class)) {
|
||||
tckService = GlobalServiceRegister.getDefault().getService(ITaCoKitDependencyService.class);
|
||||
} else {
|
||||
tckService = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,30 +61,10 @@ public class ProcessorDependenciesManager {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public boolean updateDependencies(IProgressMonitor progressMonitor, Model model) throws ProcessorException {
|
||||
try {
|
||||
Set<ModuleNeeded> jobModules = new HashSet<>();
|
||||
Set<ModuleNeeded> testcaseModules = new HashSet<>();
|
||||
//
|
||||
if (tckService != null && tckService
|
||||
.hasTaCoKitComponents(tckService.getJobComponents(property.getItem()))) {
|
||||
final Set<String> depsonly = tckService
|
||||
.getTaCoKitOnlyDependencies(tckService.getJobComponents(property.getItem()));
|
||||
for (ModuleNeeded module : getProcessNeededModules()) {
|
||||
if (depsonly.stream().noneMatch(dep -> dep.equals(module.getModuleName()))) {
|
||||
jobModules.add(module);
|
||||
}
|
||||
}
|
||||
for (ModuleNeeded module : getTestcaseNeededModules(property)) {
|
||||
if (depsonly.stream().noneMatch(dep -> dep.equals(module.getModuleName()))) {
|
||||
testcaseModules.add(module);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
jobModules = getProcessNeededModules();
|
||||
testcaseModules = getTestcaseNeededModules(property);
|
||||
}
|
||||
//
|
||||
Set<ModuleNeeded> neededLibraries = new HashSet<>();
|
||||
Set<String> uniqueDependencies = new HashSet<>();
|
||||
Set<ModuleNeeded> jobModules = getProcessNeededModules();
|
||||
Set<ModuleNeeded> testcaseModules = getTestcaseNeededModules(property);
|
||||
neededLibraries.addAll(jobModules);
|
||||
neededLibraries.addAll(testcaseModules);
|
||||
if (!neededLibraries.isEmpty()) {
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.librariesmanager.model.ModulesNeededProvider;
|
||||
import org.talend.librariesmanager.model.service.CustomUriManager;
|
||||
import org.talend.librariesmanager.ui.dialogs.CustomURITextCellEditor;
|
||||
import org.talend.librariesmanager.ui.dialogs.InstallModuleDialog;
|
||||
import org.talend.librariesmanager.ui.i18n.Messages;
|
||||
@@ -298,6 +299,7 @@ public class ModulesViewComposite extends Composite {
|
||||
* @see org.talend.designer.codegen.perlmodule.ui.views.IModulesViewComposite#refresh()
|
||||
*/
|
||||
public void refresh() {
|
||||
CustomUriManager.getInstance().setForeceReloadCustomUri();
|
||||
List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
|
||||
modulesNeeded.addAll(ModulesNeededProvider.getAllManagedModules());
|
||||
ModulesViewComposite.getTableViewerCreator().init(modulesNeeded);
|
||||
|
||||
@@ -263,26 +263,31 @@ public class TalendDate {
|
||||
|
||||
/**
|
||||
* Tests string value as a date with right pattern using strict rules.
|
||||
* This validation uses Java 8 time tools such {@link DateTimeFormatter#parse }
|
||||
* and {@link DateTimeFormatter#format }
|
||||
* </br>
|
||||
* </br>
|
||||
* Examples:
|
||||
* </br>
|
||||
* <code>isDateStrict("20110327 121711", "yyyyMMdd HHmmss")</code> return <code>true</code></br>
|
||||
* <code>isDateStrict("01100327 121711", "yyyyMMdd HHmmss")</code> return <code>false</code></br>
|
||||
* <code>isDateStrict("20180229 221711", "yyyyMMdd HHmmss")</code> return <code>false</code></br>
|
||||
* <code>isDateStrict("2016-02-29 22:17:11", "yyyy-MM-dd HH:mm:ss")</code> return <code>true</code></br>
|
||||
* <code>isDateStrict("2011/03/27 22:17:11+0100", "yyyy/MM/dd HH:mm:ssZ")</code> return <code>true</code></br>
|
||||
* <code>isDateStrict("20110327 021711+1900", "yyyyMMdd HHmmssZ")</code> return <code>false</code></br>
|
||||
* </br>
|
||||
* This validation uses Java 8 time tools.
|
||||
*
|
||||
* The range of time-zone offsets is restricted to -18:00 to 18:00 inclusive.
|
||||
*
|
||||
* @param stringDate the date to judge
|
||||
* @param pattern the specified pattern, like: "yyyy-MM-dd HH:mm:ss")
|
||||
* @return whether the stringDate is a date string with a right pattern.
|
||||
*
|
||||
* @param stringDate (The <code>String</code> of the date to judge)
|
||||
* @param pattern (The <code>String</code> of a specified pattern, like: "yyyy-MM-dd HH:mm:ss")
|
||||
* @return A boolean value that whether the stringDate is a date string with a right pattern.
|
||||
* @throws IllegalArgumentException if pattern is not defined.
|
||||
*
|
||||
*
|
||||
* {talendTypes} Boolean
|
||||
*
|
||||
* {Category} TalendDate
|
||||
*
|
||||
* {param} String(mydate) stringDate : the date to judge
|
||||
*
|
||||
* {param} String("yyyy-MM-dd HH:mm:ss") pattern : the specified pattern
|
||||
*
|
||||
* {examples}
|
||||
*
|
||||
* ->> isDateStrict("20110327 121711", "yyyyMMdd HHmmss") return true
|
||||
* ->> isDateStrict("01100327 121711", "yyyyMMdd HHmmss") return false
|
||||
* ->> isDateStrict("20180229 221711", "yyyyMMdd HHmmss") return false
|
||||
* ->> isDateStrict("2016-02-29 22:17:11", "yyyy-MM-dd HH:mm:ss") return true
|
||||
* ->> isDateStrict("2011/03/27 22:17:11+0100", "yyyy/MM/dd HH:mm:ssZ") return true
|
||||
* ->> isDateStrict("20110327 021711+1900", "yyyyMMdd HHmmssZ") return false
|
||||
*/
|
||||
public static boolean isDateStrict(String stringDate, String pattern) {
|
||||
if (stringDate == null) {
|
||||
|
||||
@@ -21,17 +21,19 @@
|
||||
// ============================================================================
|
||||
package routines.system;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
//TODO split to several classes by the level when have a clear requirement or design : job, component, connection
|
||||
public class JobStructureCatcherUtils {
|
||||
|
||||
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
|
||||
|
||||
// TODO split it as too big, even for storing the reference only which point
|
||||
// null
|
||||
@@ -59,8 +61,6 @@ public class JobStructureCatcherUtils {
|
||||
|
||||
public String job_version;
|
||||
|
||||
public Long systemPid = JobStructureCatcherUtils.getPid();
|
||||
|
||||
public boolean current_connector_as_input;
|
||||
|
||||
public String current_connector_type;
|
||||
@@ -84,11 +84,17 @@ public class JobStructureCatcherUtils {
|
||||
|
||||
public long end_time;
|
||||
|
||||
public String moment = sdf.format(new Date());
|
||||
public String moment;
|
||||
|
||||
public String status;
|
||||
|
||||
public LogType log_type;
|
||||
|
||||
//process uuid
|
||||
public String pid = ProcessIdAndThreadId.getProcessId();
|
||||
|
||||
//thread uuid
|
||||
public String tid = ProcessIdAndThreadId.getThreadId();
|
||||
|
||||
public JobStructureCatcherMessage() {
|
||||
}
|
||||
@@ -101,7 +107,10 @@ public class JobStructureCatcherUtils {
|
||||
RUNCOMPONENT,
|
||||
FLOWINPUT,
|
||||
FLOWOUTPUT,
|
||||
PERFORMANCE
|
||||
PERFORMANCE,
|
||||
|
||||
RUNTIMEPARAMETER,
|
||||
RUNTIMESCHEMA
|
||||
}
|
||||
|
||||
java.util.List<JobStructureCatcherMessage> messages = java.util.Collections
|
||||
@@ -118,6 +127,42 @@ public class JobStructureCatcherUtils {
|
||||
this.job_id = jobId;
|
||||
this.job_version = jobVersion;
|
||||
}
|
||||
|
||||
public void addComponentParameterMessage(String component_id, String component_name, Map<String, String> component_parameters) {
|
||||
JobStructureCatcherMessage scm = new JobStructureCatcherMessage();
|
||||
scm.job_name = this.job_name;
|
||||
scm.job_id = this.job_id;
|
||||
scm.job_version = this.job_version;
|
||||
|
||||
scm.component_id = component_id;
|
||||
scm.component_name = component_name;
|
||||
|
||||
scm.component_parameters = component_parameters;
|
||||
|
||||
scm.log_type = LogType.RUNTIMEPARAMETER;
|
||||
|
||||
messages.add(scm);
|
||||
}
|
||||
|
||||
public void addConnectionSchemaMessage(String source_component_id, String source_component_name, String target_component_id, String target_component_name,
|
||||
String current_connector, List<Map<String, String>> component_schema) {
|
||||
JobStructureCatcherMessage scm = new JobStructureCatcherMessage();
|
||||
scm.job_name = this.job_name;
|
||||
scm.job_id = this.job_id;
|
||||
scm.job_version = this.job_version;
|
||||
|
||||
scm.current_connector = current_connector;
|
||||
scm.sourceId = source_component_id;
|
||||
scm.sourceComponentName = source_component_name;
|
||||
scm.targetId = target_component_id;
|
||||
scm.targetComponentName = target_component_name;
|
||||
|
||||
scm.component_schema = component_schema;
|
||||
|
||||
scm.log_type = LogType.RUNTIMESCHEMA;
|
||||
|
||||
messages.add(scm);
|
||||
}
|
||||
|
||||
public void addConnectionMessage(String component_id, String component_label, String component_name, boolean current_connector_as_input,
|
||||
String current_connector_type, String current_connector, long total_row_number, long start_time,
|
||||
@@ -163,6 +208,8 @@ public class JobStructureCatcherUtils {
|
||||
|
||||
public void addJobStartMessage() {
|
||||
JobStructureCatcherMessage scm = new JobStructureCatcherMessage();
|
||||
scm.moment = sdf.format(new Date());
|
||||
|
||||
scm.job_name = this.job_name;
|
||||
scm.job_id = this.job_id;
|
||||
scm.job_version = this.job_version;
|
||||
@@ -174,6 +221,8 @@ public class JobStructureCatcherUtils {
|
||||
|
||||
public void addJobEndMessage(long start_time, long end_time, String status) {
|
||||
JobStructureCatcherMessage scm = new JobStructureCatcherMessage();
|
||||
scm.moment = sdf.format(new Date());
|
||||
|
||||
scm.job_name = this.job_name;
|
||||
scm.job_id = this.job_id;
|
||||
scm.job_version = this.job_version;
|
||||
@@ -198,16 +247,6 @@ public class JobStructureCatcherUtils {
|
||||
return messagesToSend;
|
||||
}
|
||||
|
||||
public static long getPid() {
|
||||
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
|
||||
String[] mxNameTable = mx.getName().split("@");
|
||||
if (mxNameTable.length == 2) {
|
||||
return Long.parseLong(mxNameTable[0]);
|
||||
} else {
|
||||
return Thread.currentThread().getId();
|
||||
}
|
||||
}
|
||||
|
||||
public void addConnectionMessage4PerformanceMonitor(String current_connector, String sourceId, String sourceLabel,
|
||||
String sourceComponentName, String targetId, String targetLabel, String targetComponentName, int row_count,
|
||||
long start_time, long end_time) {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package routines.system;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ProcessIdAndThreadId {
|
||||
|
||||
private static class PTId {
|
||||
String processId;
|
||||
String threadId;
|
||||
}
|
||||
|
||||
private static final ThreadLocal<PTId> Id = new ThreadLocal<PTId>() {
|
||||
@Override
|
||||
protected PTId initialValue() {
|
||||
PTId id = new PTId();
|
||||
id.processId = getPid();
|
||||
id.threadId = UUID.randomUUID().toString();
|
||||
return id;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static String getPid() {
|
||||
RuntimeMXBean mx = ManagementFactory.getRuntimeMXBean();
|
||||
String processName = mx.getName();
|
||||
try {
|
||||
return UUID.nameUUIDFromBytes(processName.getBytes("UTF8")).toString();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getProcessId() {
|
||||
return Id.get().processId;
|
||||
}
|
||||
|
||||
public static String getThreadId() {
|
||||
return Id.get().threadId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,8 +58,16 @@ public class RunStat implements Runnable {
|
||||
|
||||
private final JobStructureCatcherUtils jscu;
|
||||
|
||||
public RunStat(JobStructureCatcherUtils jscu) {
|
||||
this.jscu = jscu;
|
||||
public RunStat(JobStructureCatcherUtils jscu, String interval) {
|
||||
this.jscu = jscu;
|
||||
|
||||
if(interval!=null) {
|
||||
try {
|
||||
this.interval = Long.valueOf(interval);
|
||||
} catch(Exception e) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class StatBean {
|
||||
@@ -342,7 +350,7 @@ public class RunStat implements Runnable {
|
||||
|
||||
private Map<String, StatBean> processStats4Meter = new HashMap<String, StatBean>();
|
||||
|
||||
private final static long INTERVAL = 500;
|
||||
private long interval = 500;
|
||||
|
||||
private long lastLogUpdate = 0;
|
||||
|
||||
@@ -354,7 +362,7 @@ public class RunStat implements Runnable {
|
||||
StatBean stateBean = log(connectionId, mode, nbLine);
|
||||
|
||||
long currentLogUpdate = System.currentTimeMillis();
|
||||
if (lastLogUpdate == 0 || lastLogUpdate + INTERVAL < currentLogUpdate) {
|
||||
if (lastLogUpdate == 0 || lastLogUpdate + interval < currentLogUpdate) {
|
||||
lastLogUpdate = currentLogUpdate;
|
||||
jscu.addConnectionMessage4PerformanceMonitor(
|
||||
connectionId, sourceId, sourceLabel, sourceComponentName, targetId, targetLabel, targetComponentName, stateBean.nbLine, stateBean.startTime, currentLogUpdate);
|
||||
|
||||
@@ -318,4 +318,8 @@ public abstract class AbstractLibrariesService implements ILibrariesService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForceReloadCustomUri() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ public class CustomUriManager {
|
||||
private static final String CUSTOM_URI_MAP = "custom_uri_mapping.json";
|
||||
|
||||
private static long lastModified = 0;
|
||||
|
||||
private static boolean isNeedReload = false;
|
||||
|
||||
private CustomUriManager() {
|
||||
try {
|
||||
@@ -159,15 +161,19 @@ public class CustomUriManager {
|
||||
try {
|
||||
File file = new File(getResourcePath(), CUSTOM_URI_MAP);
|
||||
long modifyDate = file.lastModified();
|
||||
if (modifyDate > lastModified) {
|
||||
if (isNeedReload || modifyDate > lastModified) {
|
||||
customURIObject.clear();
|
||||
JSONObject loadResources = loadResources(getResourcePath(), CUSTOM_URI_MAP);
|
||||
customURIObject.putAll(loadResources);
|
||||
lastModified = modifyDate;
|
||||
isNeedReload = false;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setForeceReloadCustomUri() {
|
||||
isNeedReload = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,5 +267,9 @@ public class LibrariesService implements ILibrariesService {
|
||||
public void deployLibrary(URL source, String mavenUri, boolean refresh, boolean updateNexusJar) throws IOException {
|
||||
getLibrariesService().deployLibrary(source, mavenUri, refresh, updateNexusJar);
|
||||
}
|
||||
|
||||
public void setForceReloadCustomUri() {
|
||||
CustomUriManager.getInstance().setForeceReloadCustomUri();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ import org.talend.core.runtime.services.IMavenUIService;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.maven.tools.BuildCacheManager;
|
||||
import org.talend.designer.maven.utils.PomUtil;
|
||||
import org.talend.designer.runprocess.IRunProcessService;
|
||||
import org.talend.librariesmanager.maven.MavenArtifactsHandler;
|
||||
import org.talend.librariesmanager.model.ExtensionModuleManager;
|
||||
import org.talend.librariesmanager.model.ModulesNeededProvider;
|
||||
@@ -1054,7 +1055,13 @@ public class LocalLibraryManager implements ILibraryManagerService, IChangedLibr
|
||||
MavenArtifact ma = MavenUrlHelper.parseMvnUrl(mvnUri);
|
||||
if (ma != null) {
|
||||
String repositoryUrl = ma.getRepositoryUrl();
|
||||
if (repositoryUrl == null || repositoryUrl.trim().isEmpty()
|
||||
boolean isCIMode = false;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
IRunProcessService runProcessService = GlobalServiceRegister.getDefault()
|
||||
.getService(IRunProcessService.class);
|
||||
isCIMode = runProcessService.isCIMode();
|
||||
}
|
||||
if (isCIMode || repositoryUrl == null || repositoryUrl.trim().isEmpty()
|
||||
|| MavenConstants.LOCAL_RESOLUTION_URL.equalsIgnoreCase(repositoryUrl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1634,6 +1634,10 @@ public final class DBConnectionContextUtils {
|
||||
String impalaPrin = conn.getParameters().get(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA);
|
||||
conn.getParameters().put(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA,
|
||||
ContextParameterUtils.getOriginalValue(contextType, impalaPrin));
|
||||
String addtionalJDBCParameters = conn.getParameters()
|
||||
.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
|
||||
conn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS,
|
||||
ContextParameterUtils.getOriginalValue(contextType, addtionalJDBCParameters));
|
||||
}
|
||||
|
||||
if (EDatabaseTypeName.ORACLE_CUSTOM.equals(EDatabaseTypeName.getTypeFromDbType(conn.getDatabaseType()))) {
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
@@ -103,7 +102,8 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
newContextName = newContextType == null ? null : newContextType.getName();
|
||||
}
|
||||
|
||||
if (!isContextIsValidAndInUse(newContextName, oldContextName, connItem)) {
|
||||
if (!isContextIsValid(newContextName, oldContextName, connItem) && hasDependency(connItem)) {
|
||||
// can not update connection when context is invalid(catalog or schema is null) and has dependecy
|
||||
return false;
|
||||
}
|
||||
con.setContextName(newContextName);
|
||||
@@ -111,7 +111,7 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
DatabaseConnection dbConn = (DatabaseConnection) connItem.getConnection();
|
||||
String newURL = getChangedURL(dbConn, newContextName);
|
||||
dbConn.setURL(newURL);
|
||||
|
||||
// do nothing when schema or catalog is null
|
||||
updateConnectionForSidOrUiSchema(dbConn, oldContextName);
|
||||
}
|
||||
|
||||
@@ -126,13 +126,25 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean hasDependency(ConnectionItem connItem) {
|
||||
// Added TDQ-18565
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
|
||||
ITDQRepositoryService tdqRepService =
|
||||
GlobalServiceRegister.getDefault().getService(ITDQRepositoryService.class);
|
||||
if (tdqRepService.hasClientDependences(connItem)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC talend Comment method "checkContextIsValid".
|
||||
*
|
||||
* @param selectedContext
|
||||
* @paramconn
|
||||
*/
|
||||
private boolean isContextIsValidAndInUse(String selectedContext, String oldContextName, ConnectionItem connItem) {
|
||||
private boolean isContextIsValid(String selectedContext, String oldContextName, ConnectionItem connItem) {
|
||||
boolean retCode = false;
|
||||
Connection conn = connItem.getConnection();
|
||||
if (conn instanceof DatabaseConnection) {
|
||||
@@ -164,14 +176,7 @@ public class SwitchContextGroupNameImpl implements ISwitchContext {
|
||||
}else {//some db didnot have catelog and schema
|
||||
retCode = true;
|
||||
}
|
||||
// Added TDQ-18565
|
||||
if (!retCode && GlobalServiceRegister.getDefault().isServiceRegistered(ITDQRepositoryService.class)) {
|
||||
ITDQRepositoryService tdqRepService = GlobalServiceRegister.getDefault()
|
||||
.getService(ITDQRepositoryService.class);
|
||||
if (!tdqRepService.hasClientDependences(connItem)) {
|
||||
retCode = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} else if (conn instanceof FileConnection) {
|
||||
retCode = true;
|
||||
|
||||
@@ -48,6 +48,7 @@ public class MetadataContextPropertyValueEvaluator extends AbstractPropertyValue
|
||||
if (Boolean.valueOf(String.valueOf(property.getTaggedValue(IComponentConstants.SUPPORT_CONTEXT)))) {
|
||||
isPropertySupportContext = true;
|
||||
}
|
||||
Object currentStoredValue = storedValue;
|
||||
if (connection != null && connection.isContextMode() && isPropertySupportContext) {
|
||||
ContextType contextType = ConnectionContextHelper.context;
|
||||
if(contextType == null){
|
||||
@@ -61,7 +62,7 @@ public class MetadataContextPropertyValueEvaluator extends AbstractPropertyValue
|
||||
}
|
||||
|
||||
}
|
||||
return getTypedValue(property, storedValue);
|
||||
return getTypedValue(property, currentStoredValue, storedValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.talend.core.classloader.ClassLoaderFactory;
|
||||
import org.talend.core.classloader.DynamicClassLoader;
|
||||
import org.talend.core.database.EDatabase4DriverClassName;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.EImpalaDriver;
|
||||
import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.hadoop.IHadoopDistributionService;
|
||||
import org.talend.core.hadoop.conf.EHadoopConfProperties;
|
||||
@@ -38,6 +39,7 @@ import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.hd.IHDistribution;
|
||||
import org.talend.core.runtime.hd.IHDistributionVersion;
|
||||
import org.talend.core.runtime.hd.hive.HiveMetadataHelper;
|
||||
import org.talend.core.utils.ReflectionUtils;
|
||||
|
||||
import metadata.managment.i18n.Messages;
|
||||
@@ -71,15 +73,13 @@ public class ImpalaConnectionManager extends DataBaseConnectionManager {
|
||||
String connURL = metadataConn.getUrl();
|
||||
String username = metadataConn.getUsername();
|
||||
String password = metadataConn.getPassword();
|
||||
|
||||
// 1. Get class loader.
|
||||
ClassLoader currClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
ClassLoader impalaClassLoader = getClassLoader(metadataConn);
|
||||
Thread.currentThread().setContextClassLoader(impalaClassLoader);
|
||||
try {
|
||||
// 2. Fetch the HiveDriver from the new classloader
|
||||
Class<?> driver = Class.forName(EDatabase4DriverClassName.IMPALA.getDriverClass(), true, impalaClassLoader);
|
||||
Driver hiveDriver = (Driver) driver.newInstance();
|
||||
String driverClass = EDatabase4DriverClassName.IMPALA.getDriverClass();
|
||||
|
||||
Map<String, Object> otherParametersMap = metadataConn.getOtherParameters();
|
||||
if (otherParametersMap != null) {
|
||||
@@ -92,7 +92,60 @@ public class ImpalaConnectionManager extends DataBaseConnectionManager {
|
||||
ReflectionUtils.invokeStaticMethod("org.apache.hadoop.security.UserGroupInformation", //$NON-NLS-1$
|
||||
impalaClassLoader, "setConfiguration", new Object[] { conf }); //$NON-NLS-1$
|
||||
}
|
||||
// addtional jdbc settings
|
||||
Object jdbcObj = otherParametersMap.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
|
||||
if (jdbcObj != null) {
|
||||
String addJDBCSetting = String.valueOf(jdbcObj);
|
||||
if (!"".equals(addJDBCSetting.trim())) {
|
||||
if (!addJDBCSetting.startsWith(";")) {
|
||||
addJDBCSetting = ";" + addJDBCSetting;
|
||||
}
|
||||
connURL += addJDBCSetting;
|
||||
}
|
||||
}
|
||||
IHadoopDistributionService hadoopService = getHadoopDistributionService();
|
||||
if ((hadoopService != null)) {
|
||||
// driver
|
||||
Object driverObj = otherParametersMap.get(ConnParameterKeys.IMPALA_DRIVER);
|
||||
String driverType = null;
|
||||
String impalaDriver = null;
|
||||
if (driverObj != null) {
|
||||
driverType = String.valueOf(driverObj);
|
||||
}
|
||||
// distribution
|
||||
Object distObj = otherParametersMap.get(ConnParameterKeys.CONN_PARA_KEY_IMPALA_DISTRIBUTION);
|
||||
String distribution = null;
|
||||
if (distObj != null) {
|
||||
distribution = String.valueOf(distObj);
|
||||
}
|
||||
// version
|
||||
Object versionObj = otherParametersMap.get(ConnParameterKeys.CONN_PARA_KEY_IMPALA_VERSION);
|
||||
String version = null;
|
||||
if (versionObj != null) {
|
||||
version = String.valueOf(versionObj);
|
||||
}
|
||||
IHDistribution impalaDistribution = hadoopService.getImpalaDistributionManager()
|
||||
.getDistribution(distribution, false);
|
||||
if (distribution != null && version != null) {
|
||||
if (driverType != null && !"".equals(driverType.trim()) && (impalaDistribution.useCustom()
|
||||
|| HiveMetadataHelper.doSupportHive2(distribution, version, false))) {
|
||||
if (EImpalaDriver.HIVE2.getDisplayName().equalsIgnoreCase(driverType)) {
|
||||
driverClass = EImpalaDriver.HIVE2.getDriver();
|
||||
}
|
||||
if (EImpalaDriver.IMPALA40.getDisplayName().equalsIgnoreCase(driverType)) {
|
||||
driverClass = EImpalaDriver.IMPALA40.getDriver();
|
||||
}
|
||||
if (EImpalaDriver.IMPALA41.getDisplayName().equalsIgnoreCase(driverType)) {
|
||||
driverClass = EImpalaDriver.IMPALA41.getDriver();
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("impala can not work with Hive1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Class<?> driver = Class.forName(driverClass, true, impalaClassLoader);
|
||||
Driver hiveDriver = (Driver) driver.newInstance();
|
||||
|
||||
// 3. Try to connect by driver
|
||||
Properties info = new Properties();
|
||||
|
||||
@@ -1615,11 +1615,14 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
ExtractMetaDataUtils.getInstance().getIntMetaDataInfo(columns, "DECIMAL_DIGITS"));
|
||||
column.setTalendType(talendType);
|
||||
column.setSourceType(typeName);
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = mappingTypeRetriever.getDefaultPattern(dbmsId, typeName);
|
||||
column.setPattern(StringUtils.isNotBlank(pattern1) ? TalendQuoteUtils.addQuotes(pattern1)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy"));//$NON-NLS-1$
|
||||
if (StringUtils.isBlank(column.getPattern())) {
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = mappingTypeRetriever.getDefaultPattern(dbmsId, typeName);
|
||||
column.setPattern(
|
||||
StringUtils.isNotBlank(pattern1) ? TalendQuoteUtils.addQuotes(pattern1)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy"));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1809,12 +1812,16 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
column.setTalendType(talendType);
|
||||
String defaultSelectedDbType = mappingTypeRetriever.getDefaultSelectedDbType(talendType);
|
||||
column.setSourceType(defaultSelectedDbType);
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = mappingTypeRetriever.getDefaultPattern(dbmsId, defaultSelectedDbType);
|
||||
column.setPattern(StringUtils.isNotBlank(pattern1) ? TalendQuoteUtils.addQuotes(pattern1)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy"));//$NON-NLS-1$
|
||||
if (StringUtils.isBlank(column.getPattern())) {
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = mappingTypeRetriever.getDefaultPattern(dbmsId, defaultSelectedDbType);
|
||||
column.setPattern(
|
||||
StringUtils.isNotBlank(pattern1) ? TalendQuoteUtils.addQuotes(pattern1)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy"));//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Comment
|
||||
|
||||
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||
org.talend.commons.runtime,
|
||||
org.apache.commons.lang,
|
||||
org.talend.core.repository,
|
||||
org.talend.utils
|
||||
org.talend.utils,
|
||||
org.talend.core
|
||||
Eclipse-LazyStart: true
|
||||
Export-Package: org.talend.migrationtool.model
|
||||
Eclipse-RegisterBuddy: org.talend.testutils
|
||||
|
||||
@@ -64,6 +64,7 @@ import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.utils.ProjectDataJsonProvider;
|
||||
import org.talend.core.repository.utils.RoutineUtils;
|
||||
import org.talend.core.repository.utils.URIHelper;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.designer.codegen.ICodeGeneratorService;
|
||||
import org.talend.designer.codegen.ITalendSynchronizer;
|
||||
import org.talend.migration.IMigrationTask;
|
||||
@@ -312,13 +313,22 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
|
||||
@Override
|
||||
public int compare(ERepositoryObjectType arg0, ERepositoryObjectType arg1) {
|
||||
if (arg0 == ERepositoryObjectType.PROCESS) {
|
||||
return 1;
|
||||
return getImportPriority(arg0) - getImportPriority(arg1);
|
||||
}
|
||||
|
||||
private int getImportPriority(ERepositoryObjectType objectType) {
|
||||
if (ERepositoryObjectType.CONTEXT.getType().equals(objectType)) {
|
||||
return 10;
|
||||
} else if ("SERVICES".equals(objectType)) {
|
||||
return 20;
|
||||
} else if (ERepositoryObjectType.JOBLET != null
|
||||
&& ERepositoryObjectType.JOBLET.getType().equals(objectType)) {
|
||||
return 30;
|
||||
} else if (ERepositoryObjectType.PROCESS_ROUTELET != null
|
||||
&& ERepositoryObjectType.PROCESS_ROUTELET.getType().equals(objectType)) {
|
||||
return 40;
|
||||
}
|
||||
if (arg0 == ERepositoryObjectType.JOBLET) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 100;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -422,7 +432,19 @@ public class MigrationToolService implements IMigrationToolService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
if (object.getProperty().eResource() == null) { // In case some
|
||||
// migration task has
|
||||
// unloaded.
|
||||
object = repFactory.getSpecificVersion(object.getProperty().getId(),
|
||||
object.getProperty().getVersion(), true);
|
||||
}
|
||||
if (object != null) {
|
||||
ICoreTisService service = GlobalServiceRegister.getDefault()
|
||||
.getService(ICoreTisService.class);
|
||||
service.afterImport(object.getProperty());
|
||||
}
|
||||
}
|
||||
if (object instanceof RepositoryObject) {
|
||||
((RepositoryObject) object).unload();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ package org.talend.rcp.exportLogs;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
@@ -26,6 +27,7 @@ import java.util.Map.Entry;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
@@ -90,6 +92,11 @@ public class ExportLogsWizardPage extends WizardPage {
|
||||
private static final String NEW_LINE = System.lineSeparator();
|
||||
|
||||
private static final String BLANK = " "; //$NON-NLS-1$
|
||||
|
||||
/** The extension used for log files */
|
||||
private static final String LOG_EXT = ".log"; //$NON-NLS-1$
|
||||
/** The extension markup to use for backup log files*/
|
||||
private static final String BACKUP_MARK = ".bak_"; //$NON-NLS-1$
|
||||
|
||||
protected ExportLogsWizardPage(String pageName) {
|
||||
super(pageName);
|
||||
@@ -214,6 +221,7 @@ public class ExportLogsWizardPage extends WizardPage {
|
||||
try {
|
||||
exportSysconfig(new File(lastPath));
|
||||
exportLogs(new File(lastPath));
|
||||
exportPerformanceLogs(new File(lastPath));
|
||||
exportStudioInfo(new File(lastPath));
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -241,16 +249,70 @@ public class ExportLogsWizardPage extends WizardPage {
|
||||
String zipFile = dest.getAbsolutePath();
|
||||
|
||||
String tmpFolder = ExportJobUtil.getTmpFolder();
|
||||
IPath logFileLocation = Platform.getLogFileLocation();
|
||||
String logFile = logFileLocation.toOSString();
|
||||
zipLogFile(zipFile, tmpFolder, logFile);// zip .log
|
||||
|
||||
//
|
||||
String logFileName = logFileLocation.lastSegment();
|
||||
if (logFileName.toLowerCase().endsWith(LOG_EXT)) {
|
||||
logFileName = logFileName.substring(0, logFileName.length() - LOG_EXT.length());
|
||||
}
|
||||
String _backlogPattern = logFileName + BACKUP_MARK + "\\d+";
|
||||
if (logFileLocation.lastSegment().toLowerCase().endsWith(LOG_EXT)) {
|
||||
_backlogPattern += LOG_EXT;
|
||||
}
|
||||
|
||||
final String backlogPattern = _backlogPattern;
|
||||
IPath parentPath = logFileLocation.removeLastSegments(1);
|
||||
String[] back_logs = parentPath.makeAbsolute().toFile().list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.matches(backlogPattern);
|
||||
}
|
||||
});
|
||||
|
||||
for(String logfile:back_logs) {
|
||||
String backlogFile = parentPath.append(logfile).toOSString();
|
||||
zipLogFile(zipFile, tmpFolder, backlogFile);//zip .bak_X.log
|
||||
}
|
||||
}
|
||||
|
||||
private void zipLogFile(String zipFile, String tmpFolder, String logFile) throws Exception {
|
||||
try {
|
||||
String logFile = Platform.getLogFileLocation().toOSString();
|
||||
String destFile = new File(tmpFolder + File.separator + new File(logFile).getName()).getAbsolutePath();
|
||||
ZipToFile.copyFile(logFile, destFile);
|
||||
ZipToFile.zipFile(tmpFolder, zipFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportPerformanceLogs(File dest) throws Exception {
|
||||
String zipFile = dest.getAbsolutePath();
|
||||
|
||||
String tmpFolder = ExportJobUtil.getTmpFolder();
|
||||
|
||||
IPath logFileLocation = Platform.getLogFileLocation();
|
||||
IPath parentPath = logFileLocation.removeLastSegments(1);
|
||||
|
||||
String performanceLogFile = "performance.log";
|
||||
IPath performanceLog = parentPath.append(performanceLogFile);
|
||||
zipLogFile(zipFile, tmpFolder, performanceLog.toOSString());//zip performance.log
|
||||
|
||||
final String backlogPattern = performanceLogFile + "\\.\\d+";
|
||||
String[] back_logs = parentPath.makeAbsolute().toFile().list(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.matches(backlogPattern);
|
||||
}
|
||||
});
|
||||
for(String logfile:back_logs) {
|
||||
String backlogFile = parentPath.append(logfile).toOSString();
|
||||
zipLogFile(zipFile, tmpFolder, backlogFile);//zip performance.log.X file
|
||||
}
|
||||
}
|
||||
|
||||
private void exportStudioInfo(File dest) {
|
||||
|
||||
StringBuffer info = new StringBuffer();
|
||||
|
||||
@@ -41,6 +41,7 @@ import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
import org.talend.commons.exception.BusinessException;
|
||||
import org.talend.commons.runtime.helper.LocalComponentInstallHelper;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.runtime.helper.PatchComponentHelper;
|
||||
import org.talend.commons.runtime.service.ComponentsInstallComponent;
|
||||
import org.talend.commons.runtime.service.PatchComponent;
|
||||
@@ -51,6 +52,7 @@ import org.talend.commons.utils.network.TalendProxySelector;
|
||||
import org.talend.commons.utils.system.EclipseCommandLine;
|
||||
import org.talend.core.BrandingChecker;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
import org.talend.core.model.migration.IMigrationToolService;
|
||||
import org.talend.core.model.utils.TalendPropertiesUtil;
|
||||
import org.talend.core.repository.CoreRepositoryPlugin;
|
||||
@@ -160,49 +162,7 @@ public class Application implements IApplication {
|
||||
service.executeWorspaceTasks();
|
||||
// saveConnectionBean(email);
|
||||
|
||||
boolean needRelaunch = false;
|
||||
final PatchComponent patchComponent = PatchComponentHelper.getPatchComponent();
|
||||
if (patchComponent != null) {
|
||||
final boolean installed = patchComponent.install();
|
||||
if (installed) {
|
||||
final String installedMessages = patchComponent.getInstalledMessages();
|
||||
if (installedMessages != null) {
|
||||
log.log(Level.INFO, installedMessages);
|
||||
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Installing Patches",
|
||||
installedMessages);
|
||||
}
|
||||
if (patchComponent.needRelaunch()) {
|
||||
needRelaunch = true;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(patchComponent.getFailureMessage())) {
|
||||
log.log(Level.ERROR, patchComponent.getFailureMessage());
|
||||
}
|
||||
}
|
||||
|
||||
final ComponentsInstallComponent installComponent = LocalComponentInstallHelper.getComponent();
|
||||
if (installComponent != null) {
|
||||
try {
|
||||
// install component silently
|
||||
installComponent.setLogin(true);
|
||||
if (installComponent.install()) {
|
||||
final String installedMessages = installComponent.getInstalledMessages();
|
||||
if (installedMessages != null) {
|
||||
log.log(Level.INFO, installedMessages);
|
||||
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Installing Components",
|
||||
installedMessages);
|
||||
}
|
||||
if (installComponent.needRelaunch()) {
|
||||
needRelaunch = true;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(installComponent.getFailureMessage())) {
|
||||
log.log(Level.ERROR, installComponent.getFailureMessage());
|
||||
}
|
||||
} finally {
|
||||
installComponent.setLogin(false);
|
||||
}
|
||||
}
|
||||
boolean needRelaunch = installLocalPatches();
|
||||
if (needRelaunch) {
|
||||
setRelaunchData();
|
||||
return IApplication.EXIT_RELAUNCH;
|
||||
@@ -211,6 +171,9 @@ public class Application implements IApplication {
|
||||
boolean logUserOnProject = logUserOnProject(display.getActiveShell());
|
||||
if (LoginHelper.isRestart && LoginHelper.isAutoLogonFailed) {
|
||||
setRelaunchData();
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.CLEAN, null, true, true);
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.TALEND_RELOAD_COMMAND,
|
||||
Boolean.TRUE.toString(), true);
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
|
||||
EclipseCommandLine.TALEND_PROJECT_TYPE_COMMAND, null, true);
|
||||
return IApplication.EXIT_RELAUNCH;
|
||||
@@ -308,14 +271,99 @@ public class Application implements IApplication {
|
||||
|
||||
}
|
||||
|
||||
private boolean installLocalPatches() {
|
||||
try {
|
||||
final boolean forceCheck = Boolean.getBoolean("talend.studio.localpatch.forcecheck");
|
||||
if (!forceCheck) {
|
||||
ICoreTisService tisService = ICoreTisService.get();
|
||||
if (tisService != null) {
|
||||
if (tisService.hasNewPatchInPatchesFolder()) {
|
||||
if (!tisService.isDefaultLicenseAndProjectType()) {
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
|
||||
EclipseCommandLine.TALEND_PROJECT_TYPE_COMMAND, "", true);
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
|
||||
EclipseCommandLine.ARG_TALEND_LICENCE_PATH, "", true);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (PluginChecker.isTIS()) {
|
||||
ExceptionHandler.process(new Exception("Can't check patch in patches folder due to missing CoreTisService"));
|
||||
return false;
|
||||
} else {
|
||||
// it's TOS here, just force to check it everytime.
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
boolean needRelaunch = false;
|
||||
final PatchComponent patchComponent = PatchComponentHelper.getPatchComponent();
|
||||
if (patchComponent != null) {
|
||||
final boolean installed = patchComponent.install();
|
||||
if (installed) {
|
||||
final String installedMessages = patchComponent.getInstalledMessages();
|
||||
if (installedMessages != null) {
|
||||
log.log(Level.INFO, installedMessages);
|
||||
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Installing Patches", installedMessages);
|
||||
}
|
||||
if (patchComponent.needRelaunch()) {
|
||||
needRelaunch = true;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(patchComponent.getFailureMessage())) {
|
||||
log.log(Level.ERROR, patchComponent.getFailureMessage());
|
||||
}
|
||||
}
|
||||
|
||||
final ComponentsInstallComponent installComponent = LocalComponentInstallHelper.getComponent();
|
||||
if (installComponent != null) {
|
||||
try {
|
||||
// install component silently
|
||||
installComponent.setLogin(true);
|
||||
if (installComponent.install()) {
|
||||
final String installedMessages = installComponent.getInstalledMessages();
|
||||
if (installedMessages != null) {
|
||||
log.log(Level.INFO, installedMessages);
|
||||
MessageDialog.openInformation(Display.getDefault().getActiveShell(), "Installing Components",
|
||||
installedMessages);
|
||||
}
|
||||
if (installComponent.needRelaunch()) {
|
||||
needRelaunch = true;
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(installComponent.getFailureMessage())) {
|
||||
log.log(Level.ERROR, installComponent.getFailureMessage());
|
||||
}
|
||||
} finally {
|
||||
installComponent.setLogin(false);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
ICoreTisService tisService = ICoreTisService.get();
|
||||
if (tisService != null) {
|
||||
tisService.refreshPatchesFolderCache();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
}
|
||||
return needRelaunch;
|
||||
}
|
||||
|
||||
private void setRelaunchData() {
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.CLEAN, null, false, true);
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.TALEND_RELOAD_COMMAND,
|
||||
Boolean.TRUE.toString(), false);
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.ARG_TALEND_BUNDLES_CLEANED,
|
||||
Boolean.FALSE.toString(), false);
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(EclipseCommandLine.ARG_TALEND_BUNDLES_CLEANED,
|
||||
Boolean.FALSE.toString(), true);
|
||||
// if relaunch, should delete the "disableLoginDialog" argument in eclipse data for bug TDI-19214
|
||||
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand(
|
||||
EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND, null, true);
|
||||
EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND, null, true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,6 +74,7 @@ import org.talend.commons.exception.LoginException;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.utils.CheatSheetPerspectiveAdapter;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.time.TimeMeasurePerformance;
|
||||
import org.talend.commons.utils.workbench.extensions.ExtensionImplementationProvider;
|
||||
import org.talend.commons.utils.workbench.extensions.ExtensionPointLimiterImpl;
|
||||
import org.talend.commons.utils.workbench.extensions.IExtensionPointLimiter;
|
||||
@@ -247,6 +248,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
||||
@Override
|
||||
public void postWindowOpen() {
|
||||
CommonsPlugin.setWorkbenchCreated(true);
|
||||
TimeMeasurePerformance.afterStartup();
|
||||
// TDQ-11355 avoid "java.nio.channels.ClosedChannelException" .If the current perspective is DQ, delay this
|
||||
// commit at here,it will be committed with DQ side(see DQRespositoryView Constructor).
|
||||
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
|
||||
|
||||
@@ -24,12 +24,12 @@ import java.util.StringTokenizer;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.forms.widgets.FormToolkit;
|
||||
import org.eclipse.ui.internal.intro.impl.presentations.BrowserIntroPartImplementation;
|
||||
import org.eclipse.ui.intro.config.IIntroContentProviderSite;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.ui.html.TalendHtmlModelUtil;
|
||||
import org.talend.commons.ui.runtime.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.network.NetworkUtil;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.PluginChecker;
|
||||
@@ -64,6 +64,8 @@ public class DynamicContentProvider extends IntroProvider {
|
||||
|
||||
private static final String LEVEL_SEPARATOR = "."; //$NON-NLS-1$
|
||||
|
||||
private IIntroContentProviderSite site;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -203,27 +205,37 @@ public class DynamicContentProvider extends IntroProvider {
|
||||
createOnlinePage(dom, parent, CLOUD_PAGE_URL, null);
|
||||
}
|
||||
|
||||
private static Boolean accessible = null;
|
||||
|
||||
protected void createOnlinePage(Document dom, Element parent, String onlinePageUrl, String title) {
|
||||
if (!NetworkUtil.isNetworkValid()) {
|
||||
setDIVStyle(dom, false);
|
||||
return;
|
||||
}
|
||||
HttpURLConnection urlConnection = null;
|
||||
try {
|
||||
URL url = new URL(getOnlinePageURL(onlinePageUrl));
|
||||
urlConnection = (HttpURLConnection) url.openConnection();
|
||||
urlConnection.setRequestMethod("GET"); //$NON-NLS-1$
|
||||
urlConnection.setDoOutput(true);
|
||||
urlConnection.setDoInput(true);
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.setReadTimeout(2000);
|
||||
urlConnection.getInputStream();
|
||||
String realOnlinePageURL = getOnlinePageURL(onlinePageUrl);
|
||||
if (accessible == null) {
|
||||
try {
|
||||
URL url = new URL(realOnlinePageURL);
|
||||
urlConnection = (HttpURLConnection) url.openConnection();
|
||||
urlConnection.setRequestMethod("GET"); //$NON-NLS-1$
|
||||
urlConnection.setDoOutput(true);
|
||||
urlConnection.setDoInput(true);
|
||||
urlConnection.setUseCaches(false);
|
||||
urlConnection.setConnectTimeout(3000);
|
||||
if (urlConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
|
||||
accessible = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
if (accessible == null) {
|
||||
accessible = false;
|
||||
}
|
||||
urlConnection.disconnect();
|
||||
}
|
||||
}
|
||||
if (accessible) {
|
||||
setDIVStyle(dom, true);
|
||||
} catch (Exception e) {
|
||||
} else {
|
||||
setDIVStyle(dom, false);
|
||||
return;
|
||||
} finally {
|
||||
urlConnection.disconnect();
|
||||
}
|
||||
|
||||
// online content
|
||||
@@ -245,12 +257,21 @@ public class DynamicContentProvider extends IntroProvider {
|
||||
}
|
||||
|
||||
Element iFrame = dom.createElement("iframe"); //$NON-NLS-1$
|
||||
iFrame.setAttribute("src", getOnlinePageURL(onlinePageUrl)); //$NON-NLS-1$
|
||||
iFrame.setAttribute("src", realOnlinePageURL); //$NON-NLS-1$
|
||||
iFrame.setAttribute("frameborder", "0"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
iFrame.setAttribute("width", "240px"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
iFrame.setAttribute("height", "370px"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
iFrame.appendChild(dom.createTextNode(" ")); //$NON-NLS-1$
|
||||
div.appendChild(iFrame);
|
||||
|
||||
updateHistory(realOnlinePageURL);
|
||||
}
|
||||
|
||||
// update history to avoid call createOnlinePage twice
|
||||
private void updateHistory(String realOnlinePageURL) {
|
||||
if (site instanceof BrowserIntroPartImplementation) {
|
||||
((BrowserIntroPartImplementation) site).updateHistory(realOnlinePageURL);
|
||||
}
|
||||
}
|
||||
|
||||
protected void createTopMessage(Document dom, Element parent) {
|
||||
@@ -399,6 +420,7 @@ public class DynamicContentProvider extends IntroProvider {
|
||||
*/
|
||||
@Override
|
||||
public void init(IIntroContentProviderSite site) {
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||
org.talend.commons.runtime,
|
||||
org.talend.core.runtime,
|
||||
org.talend.core.repository,
|
||||
org.talend.designer.maven
|
||||
org.talend.designer.maven,
|
||||
org.talend.core
|
||||
Bundle-Localization: plugin
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-RegisterBuddy: org.talend.testutils
|
||||
|
||||
@@ -61,6 +61,7 @@ import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.context.link.ContextLinkService;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionPackage;
|
||||
@@ -99,6 +100,7 @@ import org.talend.core.repository.utils.ProjectDataJsonProvider;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.services.ICoreTisService;
|
||||
import org.talend.core.utils.WorkspaceUtils;
|
||||
import org.talend.designer.business.model.business.BusinessPackage;
|
||||
import org.talend.designer.business.model.business.BusinessProcess;
|
||||
@@ -120,7 +122,6 @@ import org.talend.repository.model.RepositoryConstants;
|
||||
* DOC ggu class global comment. Detailled comment
|
||||
*/
|
||||
public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
|
||||
/**
|
||||
* set by extension point, will be the base path which relative to import project.
|
||||
*
|
||||
@@ -350,7 +351,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
|
||||
/**
|
||||
*
|
||||
* check the item is valid or not。
|
||||
* check the item is valid or not銆<EFBFBD>
|
||||
*/
|
||||
public boolean checkItem(ResourcesManager resManager, ImportItem importItem, boolean overwrite) {
|
||||
try {
|
||||
@@ -1306,18 +1307,32 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
IRepositoryViewObject object;
|
||||
try {
|
||||
Property property = importItem.getProperty();
|
||||
boolean isReloaded = false;
|
||||
if (property == null) {
|
||||
object = factory.getSpecificVersion(importItem.getItemId(), importItem.getItemVersion(), true);
|
||||
property = object.getProperty();
|
||||
isReloaded = true;
|
||||
}
|
||||
if (factory.isFullLogonFinished() && importItem.isImported()
|
||||
&& ContextUtils.getAllSupportContextLinkTypes().contains(importItem.getRepositoryType())) {
|
||||
if (!isReloaded) {
|
||||
object = factory.getSpecificVersion(importItem.getItemId(), importItem.getItemVersion(), true);
|
||||
property = object.getProperty();
|
||||
}
|
||||
ContextUtils.doCreateContextLinkMigration(importItem.getRepositoryType(), property.getItem());
|
||||
}
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
|
||||
ICoreTisService service = GlobalServiceRegister.getDefault().getService(ICoreTisService.class);
|
||||
service.afterImport(property);
|
||||
}
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(property.getItem(), true);
|
||||
// importItem.setProperty(null);
|
||||
// factory.unloadResources(property);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected IPath getReferenceItemPath(IPath importItemPath, ReferenceFileItem rfItem) {
|
||||
return HandlerUtil.getReferenceItemPath(importItemPath, rfItem.getExtension());
|
||||
|
||||
@@ -207,5 +207,4 @@ public final class ImportCacheHelper {
|
||||
public synchronized List<ImportItem> getImportedItemRecords() {
|
||||
return this.importedItemRecords;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2512,6 +2512,11 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
|
||||
@Override
|
||||
public void save(Project project, Item item) throws PersistenceException {
|
||||
save(project, item, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(Project project, Item item, boolean isMigrationTask) throws PersistenceException {
|
||||
|
||||
ResourceSet resourceSet = null;
|
||||
Resource resource = item.eResource();
|
||||
@@ -2674,7 +2679,9 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
}
|
||||
this.copyScreenshotFlag = false;
|
||||
}
|
||||
saveContextLinkInfo(item);
|
||||
if (!isMigrationTask) {
|
||||
saveContextLinkInfo(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveContextLinkInfo(Item item) throws PersistenceException {
|
||||
@@ -3078,8 +3085,8 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
xmiResourceManager.saveResource(screenshotsResource);
|
||||
xmiResourceManager.saveResource(itemResource);
|
||||
xmiResourceManager.saveResource(propertyResource);
|
||||
saveContextLinkInfo(item);
|
||||
if (isImportItem.length == 0 || !isImportItem[0]) {
|
||||
saveContextLinkInfo(item);
|
||||
saveProject(project);
|
||||
}
|
||||
|
||||
@@ -3160,7 +3167,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
public void createUser(Project project) throws PersistenceException {
|
||||
Resource projectResource = project.getEmfProject().eResource();
|
||||
projectResource.getContents().add(getRepositoryContext().getUser());
|
||||
xmiResourceManager.saveResource(projectResource);
|
||||
saveProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -850,6 +850,8 @@ DatabaseForm.hbase.distributionAlert=Distribution must be specified
|
||||
DatabaseForm.impala.distributionAlert=Distribution must be specified
|
||||
DatabaseForm.hbase.versionAlert=HBase version must be specified
|
||||
DatabaseForm.impala.versionAlert=Impala version must be specified
|
||||
DatabaseForm.impala.driverVersion=Impala Driver
|
||||
DatabaseForm.impala.driverVersion.tip=Select a hive impala driver
|
||||
DatabaseForm.maprdb.settings=Version
|
||||
DatabaseForm.maprdb.distribution=Distribution
|
||||
DatabaseForm.maprdb.distribution.tooltip=Set the hadoop distribution
|
||||
|
||||
@@ -13,11 +13,9 @@
|
||||
package org.talend.repository.ui.wizards.metadata.connection.database;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.swt.events.ModifyEvent;
|
||||
import org.eclipse.swt.events.ModifyListener;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
@@ -25,23 +23,15 @@ import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.talend.commons.ui.swt.formtools.LabelledCombo;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.platform.PluginChecker;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.template.EDatabaseConnTemplate;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.metadata.builder.database.ExtractMetaDataFromDataBase;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.ui.branding.IBrandingConfiguration;
|
||||
import org.talend.metadata.managment.utils.MetadataConnectionUtils;
|
||||
import org.talend.repository.metadata.i18n.Messages;
|
||||
@@ -81,11 +71,16 @@ public class DBTypeForm {
|
||||
public void initialize() {
|
||||
this.dbType = getConnectionDBType();
|
||||
addDBSelectCombo();
|
||||
EDatabaseConnTemplate template = EDatabaseConnTemplate.indexOfTemplate(getConnectionDBType());
|
||||
String displayConnectionDBType = getDisplayConnectionDBType();
|
||||
EDatabaseConnTemplate template = EDatabaseConnTemplate.indexOfTemplate(displayConnectionDBType);
|
||||
if (template != null) {
|
||||
if (dbTypeCombo.getText().length() == 0 || !dbTypeCombo.getText().equals(template.getDbType().getDisplayName())) {
|
||||
dbTypeCombo.setText(template.getDbType().getDisplayName());
|
||||
}
|
||||
} else if (isAdditionalJDBC(getDisplayConnectionDBType())) {
|
||||
if (dbTypeCombo.getText().length() == 0 || !dbTypeCombo.getText().equals(displayConnectionDBType)) {
|
||||
dbTypeCombo.setText(displayConnectionDBType);
|
||||
}
|
||||
}
|
||||
addListerner();
|
||||
adaptFormToReadOnly();
|
||||
@@ -201,12 +196,17 @@ public class DBTypeForm {
|
||||
public void modifyText(final ModifyEvent e) {
|
||||
wizardPage.setPageComplete(!isReadOnly);
|
||||
wizardPage.setErrorMessage(null);
|
||||
dbType = dbTypeCombo.getText();
|
||||
String oldType = getConnectionDBType();
|
||||
if(dbType.equals(oldType)){
|
||||
String displayDBType = dbTypeCombo.getText();
|
||||
dbType = displayDBType;
|
||||
if (isAdditionalJDBC(displayDBType)) {
|
||||
dbType = "JDBC";
|
||||
}
|
||||
String oldType = getDisplayConnectionDBType();
|
||||
|
||||
if (displayDBType.equals(oldType)) {
|
||||
return;
|
||||
}
|
||||
if(needDisposeOldForm(dbType, oldType)){
|
||||
if (needDisposeOldForm(displayDBType, oldType)) {
|
||||
reCreateConnection();
|
||||
setConnectionDBType(dbType);
|
||||
if(!wizardPage.isTCOMDB(dbType)){
|
||||
@@ -225,16 +225,20 @@ public class DBTypeForm {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean needDisposeOldForm(String newType, String oldType){
|
||||
if(newType.equals(oldType)){
|
||||
return false;
|
||||
}
|
||||
if(wizardPage.isTCOMDB(newType) != wizardPage.isTCOMDB(oldType)){
|
||||
return true;
|
||||
private boolean isAdditionalJDBC(String dbType) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService service = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
|
||||
if (service != null) {
|
||||
return service.getIfAdditionalJDBCDBType(dbType);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean needDisposeOldForm(String newType, String oldType){
|
||||
return !newType.equals(oldType);
|
||||
}
|
||||
|
||||
private void reCreateConnection(){
|
||||
if(wizardPage.isTCOMDB(dbType)){
|
||||
IGenericDBService dbService = null;
|
||||
@@ -267,4 +271,18 @@ public class DBTypeForm {
|
||||
((DatabaseConnection)connectionItem.getConnection()).setDatabaseType(type);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplayConnectionDBType() {
|
||||
DatabaseConnection connection = (DatabaseConnection) connectionItem.getConnection();
|
||||
String databaseType = connection.getDatabaseType();
|
||||
String productId = connection.getProductId();
|
||||
if (wizardPage.isTCOMDB(databaseType) && !databaseType.equals(productId)) {
|
||||
return productId;
|
||||
}
|
||||
return databaseType;
|
||||
}
|
||||
|
||||
public String getDisplayDBType() {
|
||||
return dbTypeCombo.getText();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ILibraryManagerService;
|
||||
import org.talend.core.ILibraryManagerUIService;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.EImpalaDriver;
|
||||
import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.database.conn.DatabaseConnStrUtil;
|
||||
import org.talend.core.database.conn.EDatabaseConnVar;
|
||||
@@ -214,6 +215,8 @@ public class DatabaseForm extends AbstractForm {
|
||||
*/
|
||||
private LabelledCombo hiveServerVersionCombo;
|
||||
|
||||
private LabelledCombo impalaDriverCombo;
|
||||
|
||||
private LabelledText serverText;
|
||||
|
||||
private LabelledText portText;
|
||||
@@ -980,6 +983,7 @@ public class DatabaseForm extends AbstractForm {
|
||||
.getString("DatabaseForm.dbversion.tip"), new String[0], 2, true); //$NON-NLS-1$
|
||||
|
||||
createHiveServerVersionField(typeDbCompositeParent);
|
||||
createImpalaDriverField(typeDbCompositeParent);
|
||||
|
||||
setHideVersionInfoWidgets(true);
|
||||
|
||||
@@ -1826,7 +1830,7 @@ public class DatabaseForm extends AbstractForm {
|
||||
}
|
||||
|
||||
private void showIfAdditionalJDBCSettings() {
|
||||
setHidAdditionalJDBCSettings(!isSupportHiveAdditionalSettings());
|
||||
setHidAdditionalJDBCSettings(!isSupportHiveAdditionalSettings() && !isSupportImpalaAdditionalSettings());
|
||||
}
|
||||
|
||||
private void showIfHiveMetastore() {
|
||||
@@ -1870,6 +1874,20 @@ public class DatabaseForm extends AbstractForm {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isSupportImpalaAdditionalSettings() {
|
||||
if (isImpalaDBConnSelected()) {
|
||||
IHDistribution hiveDistribution = getCurrentImpalaDistribution(true);
|
||||
String hiveVerson = getImpalaVersionCombo().getText();
|
||||
if (hiveDistribution != null && hiveVerson != null) {
|
||||
if (!EImpalaDriver.isSupport(hiveDistribution.getDisplayName(), hiveVerson, true, "useCloudLauncher")
|
||||
&& HiveMetadataHelper.doSupportHive2(hiveDistribution.getDisplayName(), hiveVerson, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateCheckButtonStatus() {
|
||||
if (isHiveDBConnSelected()) {
|
||||
boolean update = HiveMetadataHelper.isHiveWizardCheckEnabled(hiveDistributionCombo.getText(),
|
||||
@@ -3209,6 +3227,7 @@ public class DatabaseForm extends AbstractForm {
|
||||
hcPropertyTypeCombo.setReadOnly(isContextMode());
|
||||
hiveModeCombo.setReadOnly(isContextMode());
|
||||
hiveServerVersionCombo.setReadOnly(isContextMode());
|
||||
impalaDriverCombo.setReadOnly(isContextMode());
|
||||
|
||||
useKerberos.setEnabled(!isContextMode());
|
||||
useKeyTab.setEnabled(!isContextMode());
|
||||
@@ -3745,6 +3764,14 @@ public class DatabaseForm extends AbstractForm {
|
||||
hiveServerVersionCombo.setHideWidgets(true);
|
||||
}
|
||||
|
||||
private void createImpalaDriverField(Composite parent) {
|
||||
impalaDriverCombo = new LabelledCombo(parent, Messages.getString("DatabaseForm.impala.driverVersion"), //$NON-NLS-1$
|
||||
Messages.getString("DatabaseForm.impala.driverVersion.tip"), //$NON-NLS-1$
|
||||
new String[] {}, 2, true);
|
||||
|
||||
impalaDriverCombo.setHideWidgets(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Added by Marvin Wang on Oct. 15, 2012.
|
||||
*
|
||||
@@ -5085,6 +5112,8 @@ public class DatabaseForm extends AbstractForm {
|
||||
}
|
||||
if (isImpalaDBConnSelected()) {
|
||||
fillDefaultsWhenImpalaVersionChanged();
|
||||
} else {
|
||||
doImpalaNotSelected();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5551,8 +5580,10 @@ public class DatabaseForm extends AbstractForm {
|
||||
handleHadoopCustomVersion(ECustomVersionType.HIVE);
|
||||
}
|
||||
});
|
||||
regHiveRelatedWidgetImpalaDriverComboListener();
|
||||
}
|
||||
|
||||
|
||||
private void handleHadoopCustomVersion(final ECustomVersionType type) {
|
||||
HadoopCustomVersionDefineDialog customVersionDialog = new HadoopCustomVersionDefineDialog(getShell(),
|
||||
HadoopVersionControlUtils.getCustomVersionMap(getConnection(), type.getGroup())) {
|
||||
@@ -6525,7 +6556,8 @@ public class DatabaseForm extends AbstractForm {
|
||||
passwordText.hide();
|
||||
} else if (isImpala) {
|
||||
// usernameText.hide();
|
||||
passwordText.hide();
|
||||
// passwordText.hide();
|
||||
impalaDriverCombo.setHideWidgets(false);
|
||||
} else if (isHiveDBConnSelected()) {
|
||||
if (isHiveEmbeddedMode()) {
|
||||
// Need to revert if required, changed by Marvin Wang on Nov. 22, 2012.
|
||||
@@ -6728,6 +6760,8 @@ public class DatabaseForm extends AbstractForm {
|
||||
addContextParams(EDBParamName.Port, true);
|
||||
addContextParams(EDBParamName.Database, true);
|
||||
addContextParams(EDBParamName.ImpalaPrincipal, useKerberosForImpala.getSelection());
|
||||
addContextParams(EDBParamName.Password, true);
|
||||
addContextParams(EDBParamName.hiveAdditionalJDBCParameters, isSupportImpalaAdditionalSettings());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7026,6 +7060,7 @@ public class DatabaseForm extends AbstractForm {
|
||||
if (isImpalaDBConnSelected()) {
|
||||
adaptImpalaHadoopPartEditable();
|
||||
updateHadoopProperties(!isContextMode());
|
||||
additionalJDBCSettingsText.setEditable(!isContextMode());
|
||||
}
|
||||
if (isOracleCustomDBConnSelected()) {
|
||||
adaptOracleCustomPartEditable();
|
||||
@@ -7085,7 +7120,6 @@ public class DatabaseForm extends AbstractForm {
|
||||
|
||||
String useKrb = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_KRB);
|
||||
String impalaPrincipla = connection.getParameters().get(ConnParameterKeys.IMPALA_AUTHENTICATION_PRINCIPLA);
|
||||
|
||||
if (Boolean.valueOf(useKrb)) {
|
||||
useKerberosForImpala.setSelection(true);
|
||||
GridData hadoopData = (GridData) authenticationComForImpala.getLayoutData();
|
||||
@@ -7097,7 +7131,23 @@ public class DatabaseForm extends AbstractForm {
|
||||
authenticationComForImpala.getParent().layout();
|
||||
}
|
||||
impalaPrincipalTxt.setText(impalaPrincipla == null ? "impala/_HOST@EXAMPLE.COM" : impalaPrincipla); //$NON-NLS-1$
|
||||
|
||||
String distributionObj = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_IMPALA_DISTRIBUTION);
|
||||
String impalaVersion = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_IMPALA_VERSION);
|
||||
IHadoopDistributionService hadoopService = getHadoopDistributionService();
|
||||
if (hadoopService != null) {
|
||||
IHDistribution impalaDistribution = hadoopService.getImpalaDistributionManager().getDistribution(distributionObj,
|
||||
false);
|
||||
IHDistributionVersion hdVersion = null;
|
||||
if (impalaDistribution != null) {
|
||||
hdVersion = impalaDistribution.getHDVersion(impalaVersion, false);
|
||||
}
|
||||
updateImpalaVersionPart(impalaDistribution);
|
||||
updateImpalaDriverAndMakeSelection(impalaDistribution, hdVersion);
|
||||
}
|
||||
// addtional jdbc setting
|
||||
String additionalJDBCSettings = connection.getParameters()
|
||||
.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_ADDITIONAL_JDBC_SETTINGS);
|
||||
additionalJDBCSettingsText.setText(additionalJDBCSettings == null ? "" : additionalJDBCSettings);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -7483,6 +7533,16 @@ public class DatabaseForm extends AbstractForm {
|
||||
});
|
||||
}
|
||||
|
||||
private void regHiveRelatedWidgetImpalaDriverComboListener() {
|
||||
impalaDriverCombo.getCombo().addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
doImpalaDriverSelected();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a listener for the text widget of metastore connection url, it invokes
|
||||
* {@link #doMetastoreConnURLModify()()} when the text contents is changed. Added by Marvin Wang on Oct 17, 2012.
|
||||
@@ -8068,6 +8128,14 @@ public class DatabaseForm extends AbstractForm {
|
||||
updateHiveServerAndMakeSelection(hiveDistribution, hiveVersion);
|
||||
}
|
||||
|
||||
protected void doImpalaDriverSelected() {
|
||||
if (!isContextMode()) {
|
||||
modifyFieldValue();
|
||||
getConnection().getParameters().put(ConnParameterKeys.IMPALA_DRIVER,
|
||||
EImpalaDriver.getByDisplay(impalaDriverCombo.getText()).getName());
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateHiveDistributionAndMakeSelection(IHDistribution hiveDistribution) {
|
||||
hiveDistributionCombo.getCombo().setItems(HiveMetadataHelper.getDistributionsDisplay());
|
||||
if (hiveDistribution != null) {
|
||||
@@ -8089,6 +8157,18 @@ public class DatabaseForm extends AbstractForm {
|
||||
return hiveDistribution;
|
||||
}
|
||||
|
||||
private IHDistribution getCurrentImpalaDistribution(boolean withDefault) {
|
||||
IHDistribution hiveDistribution = HiveMetadataHelper.getDistribution(impalaDistributionCombo.getText(), true);
|
||||
IHadoopDistributionService hadoopService = getHadoopDistributionService();
|
||||
if (withDefault && hiveDistribution == null && hadoopService != null) {
|
||||
IHDistribution[] distributions = hadoopService.getImpalaDistributionManager().getDistributions();
|
||||
if (distributions.length > 0) {
|
||||
hiveDistribution = distributions[0];
|
||||
}
|
||||
}
|
||||
return hiveDistribution;
|
||||
}
|
||||
|
||||
protected void updateHiveVersionAndMakeSelection(IHDistribution hiveDistribution, IHDistributionVersion hiveVersion) {
|
||||
if (hiveDistribution == null) {
|
||||
hiveDistribution = getCurrentHiveDistribution(true);
|
||||
@@ -8171,6 +8251,43 @@ public class DatabaseForm extends AbstractForm {
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateImpalaDriverAndMakeSelection(IHDistribution hiveDistribution,
|
||||
IHDistributionVersion hiveVersion) {
|
||||
if (hiveDistribution == null) {
|
||||
hiveDistribution = getCurrentHiveDistribution(true);
|
||||
}
|
||||
IHadoopDistributionService hadoopDistributionService = getHadoopDistributionService();
|
||||
if (hiveDistribution == null || hadoopDistributionService == null) {
|
||||
return;
|
||||
}
|
||||
IHDistributionVersion[] hdVersions = hiveDistribution.getHDVersions();
|
||||
if (hiveVersion == null && hdVersions.length > 0) {
|
||||
hiveVersion = hdVersions[0];
|
||||
}
|
||||
|
||||
DatabaseConnection conn = getConnection();
|
||||
String[] impalaDriverDisplay = EImpalaDriver.getImpalaDriverDisplay(hiveDistribution.getName(),
|
||||
hiveVersion == null ? null : hiveVersion.getVersion(), false);
|
||||
if (impalaDriverDisplay != null && impalaDriverDisplay.length == 0) {
|
||||
// hive2 by default
|
||||
impalaDriverCombo.getCombo().setItems(EImpalaDriver.HIVE2.getDisplayName());
|
||||
} else {
|
||||
impalaDriverCombo.getCombo().setItems(impalaDriverDisplay);
|
||||
}
|
||||
String impalaDriver = conn.getParameters().get(ConnParameterKeys.IMPALA_DRIVER);
|
||||
if (impalaDriver != null) {
|
||||
EImpalaDriver driver = EImpalaDriver.getByName(impalaDriver);
|
||||
if (driver != null) {
|
||||
impalaDriverCombo.setText(driver.getDisplayName());
|
||||
} else {
|
||||
impalaDriverCombo.select(0);
|
||||
}
|
||||
} else {
|
||||
impalaDriverCombo.select(0);
|
||||
}
|
||||
getConnection().getParameters().put(ConnParameterKeys.IMPALA_DRIVER,
|
||||
EImpalaDriver.getByDisplay(impalaDriverCombo.getText()).getName());
|
||||
}
|
||||
/**
|
||||
* It is invoked when the mode STANDALONE is selected. Added by Marvin Wang on Aug. 3, 2012.
|
||||
*/
|
||||
@@ -8304,6 +8421,9 @@ public class DatabaseForm extends AbstractForm {
|
||||
doHiveUIContentsLayout();
|
||||
}
|
||||
|
||||
protected void doImpalaNotSelected() {
|
||||
impalaDriverCombo.setHideWidgets(true);
|
||||
}
|
||||
/**
|
||||
* This method is used to handle the groups including version info, hadoop info and metastore info are hide or
|
||||
* visible. Added by Marvin Wang on Oct 16, 2012.
|
||||
@@ -8646,6 +8766,10 @@ public class DatabaseForm extends AbstractForm {
|
||||
return this.hiveVersionCombo;
|
||||
}
|
||||
|
||||
public LabelledCombo getImpalaVersionCombo() {
|
||||
return this.impalaVersionCombo;
|
||||
}
|
||||
|
||||
public ContextType getSelectedContextType() {
|
||||
return this.selectedContextType;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.window.Window;
|
||||
@@ -88,6 +87,7 @@ import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.metadata.managment.connection.manager.HiveConnectionManager;
|
||||
import org.talend.metadata.managment.model.MetadataFillFactory;
|
||||
import org.talend.metadata.managment.repository.ManagerConnection;
|
||||
import org.talend.metadata.managment.ui.utils.ConnectionContextHelper;
|
||||
import org.talend.metadata.managment.ui.utils.DBConnectionContextUtils;
|
||||
import org.talend.metadata.managment.ui.utils.SwitchContextGroupNameImpl;
|
||||
@@ -555,17 +555,25 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
|
||||
Boolean isSuccess = true;
|
||||
if (creation) {
|
||||
// to create a new connection no need to consider dependency and other modify on the original
|
||||
// one
|
||||
handleCreation(getDatabaseConnection(), metadataConnection, tdqRepService);
|
||||
} else if (tdqRepService != null&&connection.isContextMode() &&contextItem != null && contextItem.getContext().size() > 1
|
||||
&& originalSelectedContextType != null) {
|
||||
// modify case and it is with context mode and we know the source and target when do context
|
||||
// switch
|
||||
isSuccess = SwitchContextGroupNameImpl
|
||||
.getInstance()
|
||||
.updateContextGroup(connectionItem, contextName, originalSelectedContextType.getName());
|
||||
if (!isSuccess) {
|
||||
// Open dialog to let customer choose continue or not when update connection
|
||||
// failed(catalog/schema is null and has analysis dependency on the
|
||||
// connection)
|
||||
isSuccess = tdqRepService.popupSwitchContextFailedMessage(contextName);
|
||||
}else {
|
||||
isSuccess &= handleDatabaseUpdate(metadataConnection, tdqRepService);
|
||||
}
|
||||
// reload connection if customer want to continue else do nothing
|
||||
isSuccess = isSuccess && handleDatabaseUpdate(metadataConnection, tdqRepService);
|
||||
|
||||
} else {
|
||||
// when connection is Database connection and creating==false and don't switch context
|
||||
isSuccess = handleDatabaseUpdate(metadataConnection, tdqRepService);
|
||||
@@ -824,6 +832,17 @@ public class DatabaseWizard extends CheckLastVersionRepositoryWizard implements
|
||||
connectionProperty.setLabel(tempName);
|
||||
connectionProperty.setDisplayName(tempName);
|
||||
}// ~
|
||||
// keep hive connection exist correctly uiSchema after reload
|
||||
DatabaseConnection dbConnection = SwitchHelpers.DATABASECONNECTION_SWITCH.doSwitch(connection);
|
||||
if (dbConnection != null) {
|
||||
String uiSchema = null;
|
||||
String databaseType = dbConnection.getDatabaseType();
|
||||
if (ManagerConnection.isSchemaFromSidOrDatabase(EDatabaseTypeName.getTypeFromDbType(databaseType))) {
|
||||
uiSchema = dbConnection.getSID();
|
||||
dbConnection.setUiSchema(uiSchema);
|
||||
}
|
||||
}
|
||||
// ~
|
||||
if (!retCode.isOk()) {
|
||||
return Boolean.FALSE;
|
||||
} else {
|
||||
|
||||
@@ -270,14 +270,18 @@ public class DatabaseWizardPage extends WizardPage {
|
||||
}
|
||||
if(isTCOMDB(dbTypeForm.getDBType())){
|
||||
if(dynamicParentForm == null || dynamicParentForm.isDisposed()){
|
||||
createDynamicForm();;
|
||||
createDynamicForm();
|
||||
}
|
||||
dynamicParentForm.setVisible(true);
|
||||
databaseForm.setVisible(false);
|
||||
if (databaseForm != null && !databaseForm.isDisposed()) {
|
||||
databaseForm.setVisible(false);
|
||||
}
|
||||
setControl(dynamicForm);
|
||||
resetDynamicConnectionItem(connItem);
|
||||
|
||||
DatabaseConnection dbConnection = ((DatabaseConnection) connItem.getConnection());
|
||||
String product = dbTypeForm.getDBType();
|
||||
((DatabaseConnection)connItem.getConnection()).setProductId(product);
|
||||
dbConnection.setProductId(product);
|
||||
String mapping = null;
|
||||
if (MetadataTalendType.getDefaultDbmsFromProduct(product) != null) {
|
||||
mapping = MetadataTalendType.getDefaultDbmsFromProduct(product).getId();
|
||||
@@ -285,7 +289,9 @@ public class DatabaseWizardPage extends WizardPage {
|
||||
if (mapping == null) {
|
||||
mapping = "mysql_id"; // default value //$NON-NLS-1$
|
||||
}
|
||||
((DatabaseConnection)connItem.getConnection()).setDbmsId(mapping);
|
||||
dbConnection.setDbmsId(mapping);
|
||||
initJDBCDefaultConnection4SwitchType(dbConnection);
|
||||
|
||||
}else{
|
||||
databaseForm.setVisible(true);
|
||||
if(dynamicParentForm != null && !dynamicParentForm.isDisposed()){
|
||||
@@ -297,6 +303,20 @@ public class DatabaseWizardPage extends WizardPage {
|
||||
parentContainer.layout();
|
||||
}
|
||||
|
||||
private void initJDBCDefaultConnection4SwitchType(DatabaseConnection connection) {
|
||||
String displayDBType = dbTypeForm.getDisplayDBType();
|
||||
IGenericWizardService service = null;
|
||||
GlobalServiceRegister register = GlobalServiceRegister.getDefault();
|
||||
if (register.isServiceRegistered(IGenericWizardService.class)) {
|
||||
service = register.getService(IGenericWizardService.class);
|
||||
}
|
||||
if (service == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
service.initAdditonalJDBCConnectionValue(connection, dynamicForm, displayDBType, connectionItem.getProperty().getId());
|
||||
}
|
||||
|
||||
|
||||
public void disposeDBForm(){
|
||||
if(databaseForm != null && !databaseForm.isDisposed()){
|
||||
|
||||
@@ -1168,10 +1168,10 @@ public class DatabaseTableForm extends AbstractForm {
|
||||
metadataColumn.setPattern(pattern);// $NON-NLS-1$
|
||||
} else {
|
||||
metadataColumn.setPattern(TalendQuoteUtils.addQuotes("dd-MM-yyyy")); //$NON-NLS-1$
|
||||
}
|
||||
if (EDatabaseTypeName.MSSQL.getDisplayName().equals(metadataconnection.getDbType())) {
|
||||
if ("TIME".equals(metadataColumn.getSourceType())) {
|
||||
metadataColumn.setPattern(TalendQuoteUtils.addQuotes("HH:mm:ss")); //$NON-NLS-1$
|
||||
if (EDatabaseTypeName.MSSQL.getDisplayName().equals(metadataconnection.getDbType())) {
|
||||
if ("TIME".equals(metadataColumn.getSourceType())) {
|
||||
metadataColumn.setPattern(TalendQuoteUtils.addQuotes("HH:mm:ss")); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1253,11 +1253,14 @@ public class DatabaseTableForm extends AbstractForm {
|
||||
}
|
||||
oneColum.setSourceType(dbType);
|
||||
if (mappingTypeRetriever != null) {
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = getPatternFromMapping(mappingTypeRetriever, dbType);
|
||||
oneColum.setPattern(pattern1);// $NON-NLS-1$
|
||||
if (StringUtils.isBlank(oneColum.getPattern())) {
|
||||
if (JavaTypesManager.DATE.getId().equals(talendType)
|
||||
|| PerlTypesManager.DATE.equals(talendType)) {
|
||||
String pattern1 = getPatternFromMapping(mappingTypeRetriever, dbType);
|
||||
oneColum.setPattern(pattern1);// $NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1305,8 +1308,15 @@ public class DatabaseTableForm extends AbstractForm {
|
||||
}
|
||||
|
||||
private String getPatternFromMapping(MappingTypeRetriever mappingTypeRetriever, String dbType) {
|
||||
String pattern1 = mappingTypeRetriever.getDefaultPattern(metadataconnection.getMapping(), dbType);
|
||||
return StringUtils.isNotBlank(pattern1) ? TalendQuoteUtils.addQuotes(pattern1)
|
||||
boolean isMssql = EDatabaseTypeName.MSSQL.getDisplayName().equals(metadataconnection.getDbType());
|
||||
String pattern = mappingTypeRetriever.getDefaultPattern(metadataconnection.getMapping(), dbType);
|
||||
if (isMssql) {
|
||||
if ("TIME".equals(dbType)) {//$NON-NLS-1$
|
||||
return StringUtils.isNotBlank(pattern) ? TalendQuoteUtils.addQuotes(pattern)
|
||||
: TalendQuoteUtils.addQuotes("HH:mm:ss");//$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return StringUtils.isNotBlank(pattern) ? TalendQuoteUtils.addQuotes(pattern)
|
||||
: TalendQuoteUtils.addQuotes("dd-MM-yyyy");//$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
@@ -201,8 +201,8 @@ SHOW_IF="USE_FILE_AMBIGUOUS=='true'">
|
||||
<CODEGENERATION>
|
||||
<IMPORTS>
|
||||
<IMPORT NAME="Talen File Enhanced"
|
||||
MODULE="talend_file_enhanced_20070724.jar"
|
||||
MVN="mvn:org.talend.libraries/talend_file_enhanced_20070724/6.0.0" REQUIRED="true" />
|
||||
MODULE="talend_file_enhanced-1.0.jar"
|
||||
MVN="mvn:org.talend.components.lib/talend_file_enhanced/1.0" REQUIRED="true" />
|
||||
<IMPORT NAME="Talend_CSV" MODULE="talendcsv.jar"
|
||||
MVN="mvn:org.talend.libraries/talendcsv/6.0.0"
|
||||
REQUIRED="true" />
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.preference;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
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.core.model.general.Project;
|
||||
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
|
||||
import org.talend.core.runtime.projectsetting.RuntimeLineageManager;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.utils.json.JSONObject;
|
||||
|
||||
import us.monoid.json.JSONArray;
|
||||
|
||||
/**
|
||||
* created by hcyi on Jul 29, 2020
|
||||
* Detailled comment
|
||||
*
|
||||
*/
|
||||
public class RuntimeLineageManagerTest {
|
||||
|
||||
static final String TEST_FILE_PREFIX = "org.talend.runtimeLineage"; //$NON-NLS-1$
|
||||
|
||||
private RuntimeLineageManager runtimeLineageManager = new RuntimeLineageManager();
|
||||
|
||||
@BeforeClass
|
||||
@AfterClass
|
||||
public static void clean() throws PersistenceException {
|
||||
Project currentProject = ProjectManager.getInstance().getCurrentProject();
|
||||
IProject project = ResourceUtils.getProject(currentProject);
|
||||
IFolder settingsFolder = project.getFolder(ProjectPreferenceManager.DEFAULT_PREFERENCES_DIRNAME);
|
||||
if (settingsFolder.exists()) {
|
||||
File folder = settingsFolder.getLocation().toFile();
|
||||
File[] testPrefFiles = folder.listFiles(new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.startsWith(TEST_FILE_PREFIX);
|
||||
}
|
||||
});
|
||||
if (testPrefFiles != null) {
|
||||
for (File f : testPrefFiles) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
try {
|
||||
ProjectPreferenceManager prefManager = runtimeLineageManager.getPrefManager();
|
||||
JSONArray jobsJson = new JSONArray();
|
||||
JSONObject jobJson = new JSONObject();
|
||||
jobJson.put(runtimeLineageManager.JOB_ID, "_HT5BMNFmEeqhpr5Qh0-X9g");
|
||||
jobsJson.put(jobJson);
|
||||
prefManager.setValue(runtimeLineageManager.RUNTIMELINEAGE_ALL, false);
|
||||
prefManager.setValue(runtimeLineageManager.RUNTIMELINEAGE_SELECTED, jobsJson.toString());
|
||||
prefManager.save();
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSaveValue4NULL() {
|
||||
runtimeLineageManager.save(null, true);
|
||||
runtimeLineageManager.load();
|
||||
|
||||
Assert.assertEquals(0, runtimeLineageManager.getSelectedJobIds().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsRuntimeLineageSetting4NULL() {
|
||||
Assert.assertFalse(runtimeLineageManager.isRuntimeLineageSetting(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsRuntimeLineageSetting() {
|
||||
init();
|
||||
runtimeLineageManager.load();
|
||||
|
||||
Assert.assertTrue(runtimeLineageManager.isRuntimeLineageSetting("_HT5BMNFmEeqhpr5Qh0-X9g")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsRuntimeLineagePrefsExist() {
|
||||
runtimeLineageManager.save(null, true);
|
||||
|
||||
Assert.assertTrue(runtimeLineageManager.isRuntimeLineagePrefsExist());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsUseRuntimeLineageAll() {
|
||||
runtimeLineageManager.save(null, true);
|
||||
ProjectPreferenceManager prefManager = runtimeLineageManager.getPrefManager();
|
||||
|
||||
Assert.assertTrue(prefManager.getBoolean(RuntimeLineageManager.RUNTIMELINEAGE_ALL));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.maven.tools;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.properties.ItemState;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.properties.RoutineItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.RepositoryViewObject;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.repository.ProjectManager;
|
||||
|
||||
|
||||
public class CodeM2CacheManagerTest {
|
||||
|
||||
private RoutineItem testRoutine;
|
||||
|
||||
private ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
testRoutine = createTempRoutineItem();
|
||||
// in case other tests A/D/M routines and didn't do clean up.
|
||||
updateCodeProject();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if (testRoutine != null) {
|
||||
ProxyRepositoryFactory.getInstance().deleteObjectPhysical(new RepositoryViewObject(testRoutine.getProperty()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNeedUpdateCodeProject() throws Exception {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
// add
|
||||
factory.create(testRoutine, new Path(""));
|
||||
assertTrue(CodeM2CacheManager.needUpdateCodeProject(project, ERepositoryObjectType.ROUTINES));
|
||||
updateCodeProject();
|
||||
|
||||
// modify
|
||||
testRoutine.getContent().setInnerContent("content changed!".getBytes());
|
||||
factory.save(testRoutine);
|
||||
assertTrue(CodeM2CacheManager.needUpdateCodeProject(project, ERepositoryObjectType.ROUTINES));
|
||||
updateCodeProject();
|
||||
|
||||
// delete logical
|
||||
factory.deleteObjectLogical(factory.getLastVersion(testRoutine.getProperty().getId()));
|
||||
assertTrue(CodeM2CacheManager.needUpdateCodeProject(project, ERepositoryObjectType.ROUTINES));
|
||||
updateCodeProject();
|
||||
|
||||
// restore
|
||||
factory.restoreObject(factory.getLastVersion(testRoutine.getProperty().getId()), new Path(""));
|
||||
assertTrue(CodeM2CacheManager.needUpdateCodeProject(project, ERepositoryObjectType.ROUTINES));
|
||||
updateCodeProject();
|
||||
|
||||
// delete physical
|
||||
factory.deleteObjectPhysical(factory.getLastVersion(testRoutine.getProperty().getId()));
|
||||
assertTrue(CodeM2CacheManager.needUpdateCodeProject(project, ERepositoryObjectType.ROUTINES));
|
||||
testRoutine = null;
|
||||
updateCodeProject();
|
||||
|
||||
}
|
||||
|
||||
private void updateCodeProject() {
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
CodeM2CacheManager.updateCodeProjectCache(project, ERepositoryObjectType.ROUTINES);
|
||||
assertFalse(CodeM2CacheManager.needUpdateCodeProject(project, ERepositoryObjectType.ROUTINES));
|
||||
}
|
||||
|
||||
private RoutineItem createTempRoutineItem() {
|
||||
RoutineItem routineItem = PropertiesFactory.eINSTANCE.createRoutineItem();
|
||||
Property myProperty = PropertiesFactory.eINSTANCE.createProperty();
|
||||
routineItem.setProperty(myProperty);
|
||||
ItemState itemState = PropertiesFactory.eINSTANCE.createItemState();
|
||||
itemState.setDeleted(false);
|
||||
itemState.setPath("");
|
||||
routineItem.setState(itemState);
|
||||
myProperty.setLabel("testRoutineUpdate");
|
||||
myProperty.setId(factory.getNextId());
|
||||
myProperty.setVersion("0.1");
|
||||
routineItem.setContent(PropertiesFactory.eINSTANCE.createByteArray());
|
||||
routineItem.getContent().setInnerContent("myRoutineContent".getBytes());
|
||||
return routineItem;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,14 +24,14 @@ public class CreateMavenJobPomTest {
|
||||
@Test
|
||||
public void testNormalizeSpaces() throws Exception {
|
||||
String inputSh = "#!/bin/sh\n" + "cd `dirname $0`\n" + "ROOT_PATH=`pwd`\n"
|
||||
+ "java -Dtalend.component.manager.m2.repository=$ROOT_PATH/../lib -cp .:$ROOT_PATH:$ROOT_PATH/../lib/routines.jar:$ROOT_PATH/../lib/log4j-slf4j-impl-2.12.1.jar:$ROOT_PATH/../lib/log4j-api-2.12.1.jar:$ROOT_PATH/../lib/log4j-core-2.12.1.jar:$ROOT_PATH/../lib/antlr-runtime-3.5.2.jar:$ROOT_PATH/../lib/org.talend.dataquality.parser.jar:$ROOT_PATH/../lib/crypto-utils.jar:$ROOT_PATH/../lib/talend_file_enhanced_20070724.jar:$ROOT_PATH/../lib/slf4j-api-1.7.25.jar:$ROOT_PATH/../lib/dom4j-2.1.1.jar:$ROOT_PATH/nojvmparam_0_1.jar: local_project.nojvmparam_0_1.noJVMparam --context=Default \"$@\"\n";
|
||||
+ "java -Dtalend.component.manager.m2.repository=$ROOT_PATH/../lib -cp .:$ROOT_PATH:$ROOT_PATH/../lib/routines.jar:$ROOT_PATH/../lib/log4j-slf4j-impl-2.12.1.jar:$ROOT_PATH/../lib/log4j-api-2.12.1.jar:$ROOT_PATH/../lib/log4j-core-2.12.1.jar:$ROOT_PATH/../lib/antlr-runtime-3.5.2.jar:$ROOT_PATH/../lib/org.talend.dataquality.parser.jar:$ROOT_PATH/../lib/crypto-utils.jar:$ROOT_PATH/../lib/talend_file_enhanced-1.0.jar:$ROOT_PATH/../lib/slf4j-api-1.7.25.jar:$ROOT_PATH/../lib/dom4j-2.1.1.jar:$ROOT_PATH/nojvmparam_0_1.jar: local_project.nojvmparam_0_1.noJVMparam --context=Default \"$@\"\n";
|
||||
String expectSh = "#!/bin/sh\n" + "cd `dirname $0`\n" + "ROOT_PATH=`pwd`\n"
|
||||
+ "java -Dtalend.component.manager.m2.repository=$ROOT_PATH/../lib -cp .:$ROOT_PATH:$ROOT_PATH/../lib/routines.jar:$ROOT_PATH/../lib/log4j-slf4j-impl-2.12.1.jar:$ROOT_PATH/../lib/log4j-api-2.12.1.jar:$ROOT_PATH/../lib/log4j-core-2.12.1.jar:$ROOT_PATH/../lib/antlr-runtime-3.5.2.jar:$ROOT_PATH/../lib/org.talend.dataquality.parser.jar:$ROOT_PATH/../lib/crypto-utils.jar:$ROOT_PATH/../lib/talend_file_enhanced_20070724.jar:$ROOT_PATH/../lib/slf4j-api-1.7.25.jar:$ROOT_PATH/../lib/dom4j-2.1.1.jar:$ROOT_PATH/nojvmparam_0_1.jar: local_project.nojvmparam_0_1.noJVMparam --context=Default \"$@\"\n";
|
||||
+ "java -Dtalend.component.manager.m2.repository=$ROOT_PATH/../lib -cp .:$ROOT_PATH:$ROOT_PATH/../lib/routines.jar:$ROOT_PATH/../lib/log4j-slf4j-impl-2.12.1.jar:$ROOT_PATH/../lib/log4j-api-2.12.1.jar:$ROOT_PATH/../lib/log4j-core-2.12.1.jar:$ROOT_PATH/../lib/antlr-runtime-3.5.2.jar:$ROOT_PATH/../lib/org.talend.dataquality.parser.jar:$ROOT_PATH/../lib/crypto-utils.jar:$ROOT_PATH/../lib/talend_file_enhanced-1.0.jar:$ROOT_PATH/../lib/slf4j-api-1.7.25.jar:$ROOT_PATH/../lib/dom4j-2.1.1.jar:$ROOT_PATH/nojvmparam_0_1.jar: local_project.nojvmparam_0_1.noJVMparam --context=Default \"$@\"\n";
|
||||
|
||||
String inputBat = "%~d0\n" + "cd %~dp0\n"
|
||||
+ "java -Dtalend.component.manager.m2.repository=\"%cd%/../lib\" -cp .;../lib/routines.jar;../lib/log4j-slf4j-impl-2.12.1.jar;../lib/log4j-api-2.12.1.jar;../lib/log4j-core-2.12.1.jar;../lib/antlr-runtime-3.5.2.jar;../lib/org.talend.dataquality.parser.jar;../lib/crypto-utils.jar;../lib/talend_file_enhanced_20070724.jar;../lib/slf4j-api-1.7.25.jar;../lib/dom4j-2.1.1.jar;nojvmparam_0_1.jar; local_project.nojvmparam_0_1.noJVMparam --context=Default %*\n";
|
||||
+ "java -Dtalend.component.manager.m2.repository=\"%cd%/../lib\" -cp .;../lib/routines.jar;../lib/log4j-slf4j-impl-2.12.1.jar;../lib/log4j-api-2.12.1.jar;../lib/log4j-core-2.12.1.jar;../lib/antlr-runtime-3.5.2.jar;../lib/org.talend.dataquality.parser.jar;../lib/crypto-utils.jar;../lib/talend_file_enhanced-1.0.jar;../lib/slf4j-api-1.7.25.jar;../lib/dom4j-2.1.1.jar;nojvmparam_0_1.jar; local_project.nojvmparam_0_1.noJVMparam --context=Default %*\n";
|
||||
String expectBat = "%~d0\n" + "cd %~dp0\n"
|
||||
+ "java -Dtalend.component.manager.m2.repository=\"%cd%/../lib\" -cp .;../lib/routines.jar;../lib/log4j-slf4j-impl-2.12.1.jar;../lib/log4j-api-2.12.1.jar;../lib/log4j-core-2.12.1.jar;../lib/antlr-runtime-3.5.2.jar;../lib/org.talend.dataquality.parser.jar;../lib/crypto-utils.jar;../lib/talend_file_enhanced_20070724.jar;../lib/slf4j-api-1.7.25.jar;../lib/dom4j-2.1.1.jar;nojvmparam_0_1.jar; local_project.nojvmparam_0_1.noJVMparam --context=Default %*\n";
|
||||
+ "java -Dtalend.component.manager.m2.repository=\"%cd%/../lib\" -cp .;../lib/routines.jar;../lib/log4j-slf4j-impl-2.12.1.jar;../lib/log4j-api-2.12.1.jar;../lib/log4j-core-2.12.1.jar;../lib/antlr-runtime-3.5.2.jar;../lib/org.talend.dataquality.parser.jar;../lib/crypto-utils.jar;../lib/talend_file_enhanced-1.0.jar;../lib/slf4j-api-1.7.25.jar;../lib/dom4j-2.1.1.jar;nojvmparam_0_1.jar; local_project.nojvmparam_0_1.noJVMparam --context=Default %*\n";
|
||||
|
||||
String actualSh = CreateMavenJobPom.normalizeSpaces(inputSh);
|
||||
assertEquals(expectSh, actualSh);
|
||||
|
||||
Reference in New Issue
Block a user