Compare commits

...

22 Commits

Author SHA1 Message Date
apoltavtsev
fcd87908ce Update PomIdsHelper.java 2020-10-12 12:33:35 +02:00
apoltavtsev
e8e0002aa7 Update AbstractMavenProcessorPom.java 2020-10-11 20:13:27 +02:00
apoltavtsev
a7580e0ee3 Update JobUtils.java 2020-10-11 20:11:40 +02:00
apoltavtsev
b13dc822ec Update AbstractMavenProcessorPom.java 2020-10-11 19:36:02 +02:00
apoltavtsev
82a487b9e7 fix(TESB-29553) Publishing a route with cTalendJob from Studio and commandline gives different results 2020-10-01 09:52:28 +02:00
vyu-talend
16fc19571c fix(TDI-44726):add some necessary annotation. (#3666) (#3682) 2020-09-27 16:14:50 +08:00
kjwang
a68463d184 Fix TUP-28603 'Export item' missing signature (#3643) (#3678)
* Fix TUP-28603 'Export item' missing signature
https://jira.talendforge.org/browse/TUP-28603
2020-09-27 15:34:29 +08:00
Jane Ding
d04f7db182 feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE (#3592) (#3667)
* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE (#3592)

* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE
https://jira.talendforge.org/browse/TUP-27654

* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE
https://jira.talendforge.org/browse/TUP-27654

Signed-off-by: jding-tlnd <jding@talend.com>

* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE
https://jira.talendforge.org/browse/TUP-27654

Signed-off-by: jding-tlnd <jding@talend.com>

* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE
TUP-28615:[Bug] Save the property to metadata will change Delta Lake to
JDBC.
https://jira.talendforge.org/browse/TUP-27654

* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE
https://jira.talendforge.org/browse/TUP-27654

* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE
https://jira.talendforge.org/browse/TUP-27654

* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE
https://jira.talendforge.org/browse/TUP-27654

* feat(TUP-27654):Databricks Delta Lake - Support ELT & MERGE (#3670)

https://jira.talendforge.org/browse/TUP-27654
2020-09-24 09:12:47 +08:00
sbliu
dd201ac7fa feat(TUP-28434) fix the test failure. 2020-09-23 10:03:01 +08:00
bhe-talendbj
7ce1c256dd feat(TUP-28666): Extract TalendTextUtils (#3648)
* feat(TUP-28666): Extract TalendTextUtils

* feat(TUP-28666): call new TalendTextUtils

* feat(TUP-28666): fix removeQuotesIfExist

* feat(TUP-28666): rename TalendTextUtils
2020-09-22 21:32:23 +08:00
Jane Ding
199f4dde6e fix(TUP-28519):Update org.talend.libraries.apache.google jars (#3631)
remove org.talend.libraries.apache.google plugin
https://jira.talendforge.org/browse/TUP-28519
2020-09-22 15:10:56 +08:00
Zhiwei Xue
c029f53402 feat(TUP-28323):Improve the maven build time spent during login project (#3649) 2020-09-21 15:17:16 +08:00
Chao MENG
8aea05339a Cmeng/workitem/tup 28063 improve start (#3565)
* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063

* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063

* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063

* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063

* workitem(TUP-28063): Improve studio bundles reloading logic
https://jira.talendforge.org/browse/TUP-28063
2020-09-21 14:12:47 +08:00
wang wei
cf19586e10 fix(TDI-44745): FileInputDelimited fails to properly consume CipherInputStream(#3590) (#3661) 2020-09-18 15:10:03 +08:00
wang wei
c68419a4e2 fix(TDI-44623): [OBSERVABILITY] : add PID and (Thread-ID OR UUID) information (#3614) (#3662)
* fix(TDI-44623): [OBSERVABILITY] : add PID and (Thread-ID OR UUID)
information

* decrease the expensive call number for getting pid

* fix(TDI-44807): Observability: initialize moment only when necessary

* fix(TDI-44806): Observability: Add customization for event frequency
2020-09-18 15:06:44 +08:00
Chao MENG
819477f327 fix(TUP-26413): Be able to compare metadata connection conflicts (#3658)
https://jira.talendforge.org/browse/TUP-26413
2020-09-18 12:27:18 +08:00
hzhao-talendbj
eab0938fb0 update PSQL_V9_X to 42.2.14 (#3617) 2020-09-17 16:10:29 +08:00
hcyi
40da0e6196 feat(TUP-23827): Runtime Lineage (#3646)
* feat(TUP-23827):Runtime Lineage for studio.

* fix(TUP-28635):[bug] output path always be changed when path contains
2020-09-17 14:55:09 +08:00
sbliu
8264ddedf8 feature(TUP-28405) Collect hardware info. also add function to measure performance( IO speed, startup time), show them in preference..
performance data show in preference won't show unit.
2020-09-17 14:37:48 +08:00
Chao MENG
b76af1a75a fix(TUP-28682): Connection info missing when create dataset for tck (#3654)
components

https://jira.talendforge.org/browse/TUP-28682
2020-09-17 11:06:29 +08:00
hcyi
eecc3eff20 fix(TUP-27518):revert the code since get some error log . (#3650) 2020-09-16 18:33:34 +08:00
Haiting Yin
b8293db502 TMDM-12594 [Component] Legacy 5 version is no more supported (#3647) 2020-09-16 15:27:13 +08:00
66 changed files with 1751 additions and 642 deletions

View File

@@ -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,

View File

@@ -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$

View File

@@ -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;
}
}

View File

@@ -23,10 +23,14 @@ 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$
@@ -103,4 +107,10 @@ public class TimeMeasurePerformance extends TimeMeasure{
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();
}
}

View File

@@ -838,7 +838,7 @@ public abstract class AbstractEMFRepositoryFactory extends AbstractRepositoryFac
serializableAllVersion = getSerializableFromFolder(project, fullFolder, id, type, false, false, true, true);
if (serializableAllVersion.isEmpty()) {
// look in all folders for this item type
serializableAllVersion = getSerializableFromFolder(project, fullFolder, id, type, false, false, true, true, true);
serializableAllVersion = getSerializableFromFolder(project, fullFolder, id, type, false, true, true, true, true);
}
int size = serializableAllVersion.size();

View File

@@ -2281,6 +2281,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);

View File

@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<mapping>
<dbms product="DATABRICKS_DELTA_LAKE" id="databricks_delta_lake_id" label="Mapping Databricks Delta Lake" default="true">
<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"/>

View File

@@ -102,7 +102,7 @@ public enum EDatabaseVersion4Drivers {
GREENPLUM(new DbVersion4Drivers(EDatabaseTypeName.GREENPLUM, "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$
// PSQL_V10(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v10", "V10", "postgresql-42.2.5.jar")),
PSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v9 and later", "V9_X", "postgresql-42.2.9.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PSQL_V9_X(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "v9 and later", "V9_X", "postgresql-42.2.14.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PSQL_PRIOR_TO_V9(new DbVersion4Drivers(EDatabaseTypeName.PSQL, "Prior to v9", "PRIOR_TO_V9", "postgresql-8.4-703.jdbc4.jar")), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
PLUSPSQL_PRIOR_TO_V9(new DbVersion4Drivers(EDatabaseTypeName.PLUSPSQL,

View File

@@ -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, ...).

View File

@@ -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;
@@ -71,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;
@@ -366,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())) {

View File

@@ -813,13 +813,7 @@ public class RepositoryToComponentProperty {
* @return
*/
private static Object getMDMValue(MDMConnection connection, String value, IMetadataTable table) {
if ("MDM_VERSION".equals(value)) {//$NON-NLS-1$
if (connection.getVersion() == null || "".equals(connection.getVersion())) {
return MDMVersions.MDM_S56.getKey();
} else {
return connection.getVersion();
}
} else if ("MDMURL".equals(value)) { //$NON-NLS-1$
if ("MDMURL".equals(value)) { //$NON-NLS-1$
if (isContextMode(connection, connection.getServerUrl())) {
return connection.getServerUrl();
} else {

View File

@@ -1003,4 +1003,12 @@ public final class ProcessUtils {
}
return false;
}
public static boolean isChildRouteProcess(IProcess process) {
List n = process.getNodesOfType("tRouteInput");
if (n!=null && n.size()!=0) {
return true;
}
return false;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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"/>

View File

@@ -33,7 +33,8 @@ Require-Bundle: org.apache.commons.lang,
org.talend.core,
org.apache.commons.io,
org.apache.httpcomponents.httpcore,
org.apache.httpcomponents.httpclient
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,
@@ -81,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,
.

View File

@@ -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

View File

@@ -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

View File

@@ -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>

View File

@@ -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;
}
}

View File

@@ -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());
}
}
}

View File

@@ -462,19 +462,25 @@ public class TalendTextUtils {
return TalendQuoteUtils.removeQuotes(text);
}
/**
* @Deprecated use org.talend.utils.string.StudioContextUtils.removeQuotesIfExist instead
*/
@Deprecated
public static String removeQuotesIfExist(String text) {
return TalendQuoteUtils.removeQuotesIfExist(text);
return org.talend.utils.string.StudioContextUtils.removeQuotesIfExist(text,
org.talend.utils.string.StudioContextUtils.QUOTATION_MARK);
}
/**
* qzhang Comment method "removeQuotes".
* @Deprecated use org.talend.utils.string.StudioContextUtils.removeQuotes
*
* @param text
* @param quotation_mark2
* @return
*/
@Deprecated
public static String removeQuotes(String text, String quotation) {
return TalendQuoteUtils.removeQuotes(text, quotation);
return org.talend.utils.string.StudioContextUtils.removeQuotes(text, quotation);
}
public static boolean isEnclosed(String text) {
@@ -489,41 +495,12 @@ public class TalendTextUtils {
return TalendQuoteUtils.getStringDeclare();
}
/**
* @Deprecated use org.talend.utils.string.StudioContextUtils.encodeValue instead
*/
@Deprecated
public static String trimParameter(String value) {
if (value == null) {
return null;
}
int length = value.length();
String result = removeQuotes(value);
if (length > 1
&& (((value.startsWith("\"") && value.endsWith("\""))) || (value.startsWith("\'") && value.endsWith("\'")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
result = value.substring(1, length - 1);
if (result.contains("\\")) { //$NON-NLS-1$
result = result.replaceAll("\\\\n", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
result = result.replaceAll("\\\\b", "\b"); //$NON-NLS-1$ //$NON-NLS-2$
result = result.replaceAll("\\\\f", "\f"); //$NON-NLS-1$ //$NON-NLS-2$
result = result.replaceAll("\\\\r", "\r"); //$NON-NLS-1$ //$NON-NLS-2$
result = result.replaceAll("\\\\t", "\t"); //$NON-NLS-1$ //$NON-NLS-2$
result = result.replaceAll("\\\\\"", "\""); //$NON-NLS-1$ //$NON-NLS-2$
result = result.replaceAll("\\\\\\\\", "\\\\"); //$NON-NLS-1$ //$NON-NLS-2$
// handle unicode
if (result.contains("\\u")) {
for (int indexStart = 0; result.indexOf("\\u", indexStart) >= 0; indexStart = result.indexOf("\\u", indexStart)) {
if (result.indexOf("\\u", indexStart) + 5 <= result.length()) { //$NON-NLS-1$
int unicodeStart = result.indexOf("\\u"); //$NON-NLS-1$
int unicodeEnd = unicodeStart + 5;
result = result.substring(0, Math.max(0, unicodeStart))
+ StringEscapeUtils.unescapeJava(result.substring(unicodeStart, unicodeEnd + 1))
+ result.substring(Math.min(unicodeEnd + 1, result.length()), result.length());
}
}
}
}
}
return result;
return org.talend.utils.string.StudioContextUtils.encodeValue(value);
}
public static String getQuoteChar() {

View File

@@ -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;
}
}

View File

@@ -19,6 +19,7 @@ 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;
@@ -56,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;
@@ -170,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);
}
}
}
};
@@ -180,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) {
@@ -210,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);
}
}
@@ -267,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);
}

View File

@@ -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());
}
}

View File

@@ -45,6 +45,7 @@ import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.runtime.maven.MavenArtifact;
import org.talend.core.runtime.maven.MavenConstants;
import org.talend.core.runtime.maven.MavenUrlHelper;
import org.talend.core.runtime.process.LastGenerationInfo;
import org.talend.core.runtime.process.TalendProcessArgumentConstant;
import org.talend.core.runtime.projectsetting.IProjectSettingTemplateConstants;
import org.talend.core.runtime.repository.build.IMavenPomCreator;
@@ -52,6 +53,7 @@ import org.talend.core.ui.ITestContainerProviderService;
import org.talend.designer.maven.model.TalendMavenConstants;
import org.talend.designer.maven.template.ETalendMavenVariables;
import org.talend.designer.maven.tools.ProcessorDependenciesManager;
import org.talend.designer.maven.utils.JobUtils;
import org.talend.designer.maven.utils.PomIdsHelper;
import org.talend.designer.maven.utils.PomUtil;
import org.talend.designer.runprocess.IBigDataProcessor;
@@ -134,9 +136,16 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
Map<ETalendMavenVariables, String> variablesValuesMap = new HashMap<ETalendMavenVariables, String>();
// no need check property is null or not, because if null, will get default ids.
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(property));
variablesValuesMap.put(ETalendMavenVariables.JobArtifactId, PomIdsHelper.getJobArtifactId(property));
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(property));
if (JobUtils.isJob(property) && ProcessUtils.isChildRouteProcess(process)) {
JobInfo lastMainJob = LastGenerationInfo.getInstance().getLastMainJob();
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(lastMainJob.getProcessor().getProperty()));
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(lastMainJob.getProcessor().getProperty()));
}else {
variablesValuesMap.put(ETalendMavenVariables.JobGroupId, PomIdsHelper.getJobGroupId(property));
variablesValuesMap.put(ETalendMavenVariables.JobVersion, PomIdsHelper.getJobVersion(property));
}
variablesValuesMap.put(ETalendMavenVariables.JobArtifactId, PomIdsHelper.getJobArtifactId(property));
variablesValuesMap.put(ETalendMavenVariables.TalendJobVersion, property.getVersion());
final String jobName = JavaResourcesHelper.escapeFileName(process.getName());
variablesValuesMap.put(ETalendMavenVariables.JobName, jobName);

View File

@@ -19,11 +19,14 @@ import java.util.Set;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.process.INode;
import org.talend.core.model.process.IProcess;
import org.talend.core.model.process.JobInfo;
import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.ERepositoryObjectType;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.utils.JavaResourcesHelper;
import org.talend.core.runtime.CoreRuntimePlugin;
@@ -97,5 +100,22 @@ public class JobUtils {
}
return clonedJobInfos;
}
public static boolean isJob(JobInfo job) {
if (job != null && job.getProcessItem() != null) {
Property p = job.getProcessItem().getProperty();
if (p != null) {
return isJob(p);
}
}
return false;
}
public static boolean isJob(Property p) {
if (p != null) {
return ERepositoryObjectType.getType(p).equals(ERepositoryObjectType.PROCESS);
}
return false;
}
}

View File

@@ -247,6 +247,17 @@ public class PomIdsHelper {
return version;
}
public static String getCustomJobVersion(Property property) {
String version = null;
if (property != null) {
if (property.getAdditionalProperties() != null) {
version = (String) property.getAdditionalProperties().get(MavenConstants.NAME_USER_VERSION);
}
}
return version;
}
public static String getJobVersion(JobInfo jobInfo) {
if (jobInfo != null) {
return jobInfo.getJobVersion();

View File

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

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.talend.libraries.apache.google</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -1,6 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Google
Bundle-SymbolicName: org.talend.libraries.apache.google
Bundle-Version: 7.4.1.qualifier
Eclipse-BundleShape: dir

View File

@@ -1 +0,0 @@
jarprocessor.exclude.children=true

View File

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

View File

@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.talend.studio</groupId>
<artifactId>tcommon-studio-se</artifactId>
<version>7.4.1-SNAPSHOT</version>
<relativePath>../../../</relativePath>
</parent>
<artifactId>org.talend.libraries.apache.google</artifactId>
<packaging>eclipse-plugin</packaging>
</project>

View File

@@ -34,9 +34,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
@@ -48,7 +45,6 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.talend.commons.CommonsPlugin;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.utils.network.NetworkUtil;
import org.talend.commons.utils.threading.TalendCustomThreadPoolExecutor;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.ILibraryManagerService;
import org.talend.core.model.general.ModuleNeeded;
@@ -100,8 +96,6 @@ public class RemoteModulesHelper {
*/
private final Map<String, List<ModuleNeeded>> contextMap;
private TalendCustomThreadPoolExecutor threadPool = null;
/**
*
* DOC wchen RemoteModulesFetchRunnable constructor comment.
@@ -118,17 +112,6 @@ public class RemoteModulesHelper {
this.onlyUseLocalLicenseData = onlyUseLocalLicenseData;
}
public TalendCustomThreadPoolExecutor getThreadPool() {
if (threadPool != null) {
return threadPool;
}
synchronized (this) {
threadPool = new TalendCustomThreadPoolExecutor(50, 100, 0, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>(200), new ThreadPoolExecutor.CallerRunsPolicy());
}
return threadPool;
}
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final Set<String> mavenUrisTofetch = new HashSet<String>(contextMap.keySet());
@@ -277,36 +260,24 @@ public class RemoteModulesHelper {
}
private void searchFromRemoteNexus(Set<String> mavenUristoSearch, IProgressMonitor monitor) {
try {
LibraryDataService service = LibraryDataService.getInstance();
List<MavenArtifact> artifactList = Collections.synchronizedList(new ArrayList<MavenArtifact>());
final Iterator<String> iterator = mavenUristoSearch.iterator();
while (iterator.hasNext()) {
if (monitor.isCanceled()) {
break;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
String uriToCheck = iterator.next();
final MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(uriToCheck);
if (parseMvnUrl != null) {
service.fillLibraryDataByRemote(uriToCheck, parseMvnUrl);
if (!MavenConstants.DOWNLOAD_MANUAL.equals(parseMvnUrl.getDistribution())) {
artifactList.add(parseMvnUrl);
}
}
}
};
getThreadPool().execute(runnable);
LibraryDataService service = LibraryDataService.getInstance();
List<MavenArtifact> artifactList = new ArrayList<MavenArtifact>();
final Iterator<String> iterator = mavenUristoSearch.iterator();
while (iterator.hasNext()) {
if (monitor.isCanceled()) {
break;
}
String uriToCheck = iterator.next();
final MavenArtifact parseMvnUrl = MavenUrlHelper.parseMvnUrl(uriToCheck);
if (parseMvnUrl != null) {
service.fillLibraryDataByRemote(uriToCheck, parseMvnUrl);
if (!MavenConstants.DOWNLOAD_MANUAL.equals(parseMvnUrl.getDistribution())) {
artifactList.add(parseMvnUrl);
}
}
service.saveData();
addModulesToCache(mavenUristoSearch, artifactList, remoteCache);
} finally {
getThreadPool().clearThreads();
threadPool = null;
}
service.saveData();
addModulesToCache(mavenUristoSearch, artifactList, remoteCache);
}
private void addModulesToCache(Set<String> mavenUristoSearch, List<MavenArtifact> searchResults,
@@ -670,7 +641,7 @@ public class RemoteModulesHelper {
public RemoteModulesFetchRunnable getNotInstalledModulesRunnable(List<ModuleNeeded> neededModules,
List<ModuleToInstall> toInstall, boolean collectModulesWithJarName, boolean useLocalLicenseData, boolean onlyUseLocalLicenseData) {
Map<String, List<ModuleNeeded>> contextMap = new HashMap<String, List<ModuleNeeded>>();
ILibraryManagerService librairesManagerService = GlobalServiceRegister.getDefault()
ILibraryManagerService librairesManagerService = (ILibraryManagerService) GlobalServiceRegister.getDefault()
.getService(ILibraryManagerService.class);
// collect mvnuri and modules incase many modules have the same mvnuri
final Iterator<ModuleNeeded> iterator = neededModules.iterator();

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -1,211 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.metadata.managment.mdm;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.axis.client.Stub;
import org.talend.core.classloader.ClassLoaderFactory;
import org.talend.core.classloader.DynamicClassLoader;
import org.talend.core.model.metadata.builder.connection.MDMConnection;
import org.talend.core.model.metadata.designerproperties.MDMVersions;
import org.talend.core.utils.ReflectionUtils;
/**
* created by wchen on Apr 15, 2015 Detailled comment
*
*/
public class S56MdmConnectionHelper extends AbsMdmConnectionHelper {
@Override
public Object checkConnection(String url, String universe, String userName, String password) throws Exception {
Stub stub = null;
DynamicClassLoader classLoader = ClassLoaderFactory.getClassLoader(MDMVersions.MDM_S56.name(), this.getClass()
.getClassLoader());
stub = getStub(classLoader, url, universe, userName, password);
return stub;
}
private Stub getStub(DynamicClassLoader classLoader, String url, String universe, String userName, String password)
throws Exception {
Stub stub = null;
Object serviceLocator = ReflectionUtils.newInstance("org.talend.mdm.webservice.XtentisServiceLocator", classLoader,
new Object[0]);
ReflectionUtils.invokeMethod(serviceLocator, "setXtentisPortEndpointAddress", new Object[] { url });
Object invokeMethod = ReflectionUtils.invokeMethod(serviceLocator, "getXtentisPort", new Object[0]);
if (invokeMethod instanceof Stub) {
stub = (Stub) invokeMethod;
if (universe == null || universe.trim().length() == 0) {
stub.setUsername(userName);
} else {
stub.setUsername(universe + "/" + userName); //$NON-NLS-1$
}
stub.setPassword(password);
Object wsping = ReflectionUtils.newInstance("org.talend.mdm.webservice.WSPing", classLoader, new Object[0]);
ReflectionUtils.invokeMethod(stub, "ping", new Object[] { wsping });
}
return stub;
}
/**
*
* DOC wchen Comment method "getPKs". used to call getDataModelPKs,getDataClusterPKs,getUniversePKs
*
* @param stub
* @param modelOrContainerMethod
* @param modelOrContainerClass
* @return
*/
@Override
public List<String> getPKs(Object stub, String getDataPKsMethod, String dataPKsClass, String pkRegex,
String getWsDataPKsMethod) throws Exception {
List<String> dataModelStrs = new ArrayList<String>();
DynamicClassLoader classLoader = ClassLoaderFactory.getClassLoader(MDMVersions.MDM_S56.name(), this.getClass()
.getClassLoader());
Object modelPK = ReflectionUtils.newInstance(dataPKsClass, classLoader, new Object[] { pkRegex });
Object dataModels = ReflectionUtils.invokeMethod(stub, getDataPKsMethod, new Object[] { modelPK });
if (dataModels instanceof Object[]) {
Object[] dataModelArray = (Object[]) dataModels;
for (Object dataModel : dataModelArray) {
Object pk = ReflectionUtils.invokeMethod(dataModel, "getPk", new Object[0]);
if (pk instanceof String) {
dataModelStrs.add((String) pk);
}
}
}
return dataModelStrs;
}
@Override
public void initConcept(MDMConnection mdmConn, File file) throws Exception {
String userName = mdmConn.getUsername();
String password = mdmConn.getValue(mdmConn.getPassword(), false);
String universe = mdmConn.getUniverse();
String datamodel = mdmConn.getDatamodel();
DynamicClassLoader classLoader = ClassLoaderFactory.getClassLoader(MDMVersions.MDM_S56.name(), this.getClass()
.getClassLoader());
String url = mdmConn.getServerUrl();
Stub stub = getStub(classLoader, url, universe, userName, password);
if (stub == null) {
return;
}
stub.setUsername(userName);
stub.setPassword(password);
Object wsping = ReflectionUtils.newInstance("org.talend.mdm.webservice.WSPing", classLoader, new Object[0]);
ReflectionUtils.invokeMethod(stub, "ping", new Object[] { wsping });
if (universe != null && !"".equals(universe)) { //$NON-NLS-1$
stub.setUsername(universe + "/" + userName); //$NON-NLS-1$
stub.setPassword(password);
} else {
stub.setUsername(userName);
stub.setPassword(password);
}
// find data model pk
Object wsModelPKs = ReflectionUtils.newInstance("org.talend.mdm.webservice.WSRegexDataModelPKs", classLoader,
new Object[] { "" });
Object dataModelPKs = ReflectionUtils.invokeMethod(stub, "getDataModelPKs", new Object[] { wsModelPKs });
if (dataModelPKs == null) {
return;
}
Object findDataModelPK = null;
if (dataModelPKs instanceof Object[]) {
Object[] dataModelPKArray = (Object[]) dataModelPKs;
for (Object dataModelPK : dataModelPKArray) {
Object pk = ReflectionUtils.invokeMethod(dataModelPK, "getPk", new Object[0]);
if (datamodel != null && datamodel.equals(pk)) {
findDataModelPK = dataModelPK;
break;
}
}
}
if (findDataModelPK == null) {
return;
}
// find data model
Object wsDataModel = ReflectionUtils.newInstance("org.talend.mdm.webservice.WSGetDataModel", classLoader,
new Object[] { findDataModelPK });
Object dataModel = ReflectionUtils.invokeMethod(stub, "getDataModel", new Object[] { wsDataModel });
if (dataModel == null) {
return;
}
Object xsdSchema = ReflectionUtils.invokeMethod(dataModel, "getXsdSchema", new Object[0]);
if (xsdSchema instanceof String) {
writeInFile(file, (String) xsdSchema);
}
}
@Override
public String getXsdSchema(Object stub, String resName) throws Exception {
String xsdSchema = "";
DynamicClassLoader classLoader = ClassLoaderFactory.getClassLoader(MDMVersions.MDM_S56.name(), this.getClass()
.getClassLoader());
Object wsModelPKs = ReflectionUtils.newInstance("org.talend.mdm.webservice.WSDataModelPK", classLoader,
new Object[] { resName });
Object wsDataModel = ReflectionUtils.newInstance("org.talend.mdm.webservice.WSGetDataModel", classLoader,
new Object[] { wsModelPKs });
Object dataModel = ReflectionUtils.invokeMethod(stub, "getDataModel", new Object[] { wsDataModel });
if (dataModel != null) {
Object xsdSchemaObj = ReflectionUtils.invokeMethod(dataModel, "getXsdSchema", new Object[0]);
if (xsdSchemaObj instanceof String) {
xsdSchema = (String) xsdSchemaObj;
}
}
return xsdSchema;
}
private static void writeInFile(File file, String schema) {
StringReader reader = new StringReader(schema);
try {
FileOutputStream outputStream = new FileOutputStream(file);
OutputStreamWriter writer = new OutputStreamWriter(outputStream, "UTF-8");
char[] c = new char[1024];
int l = 0;
while ((l = reader.read(c)) != -1) {
writer.write(c, 0, l);
}
writer.flush();
writer.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/*
* (non-Javadoc)
*
* @see org.talend.metadata.managment.mdm.AbsMdmConnectionHelper#resetStubUser(java.lang.Object, java.lang.String)
*/
@Override
public void resetUniverseUser(Object stub, String universeUser) {
if (stub instanceof Stub) {
Stub stub2 = (Stub) stub;
stub2.setUsername(universeUser + stub2.getUsername());
}
}
}

View File

@@ -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

View File

@@ -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;
@@ -431,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();
}

View File

@@ -40,6 +40,7 @@ import org.eclipse.ui.PlatformUI;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
import org.talend.commons.exception.BusinessException;
import org.talend.commons.exception.ExceptionHandler;
import org.talend.commons.runtime.helper.LocalComponentInstallHelper;
import org.talend.commons.runtime.helper.PatchComponentHelper;
import org.talend.commons.runtime.service.ComponentsInstallComponent;
@@ -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;
@@ -171,50 +173,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;
@@ -223,6 +182,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;
@@ -320,14 +282,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);
}
/**

View File

@@ -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();

View File

@@ -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

View File

@@ -32,7 +32,6 @@ import java.util.stream.Collectors;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -101,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;
@@ -1325,6 +1325,10 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
}
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);
@@ -1332,6 +1336,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
ExceptionHandler.process(e);
}
}
protected IPath getReferenceItemPath(IPath importItemPath, ReferenceFileItem rfItem) {
return HandlerUtil.getReferenceItemPath(importItemPath, rfItem.getExtension());

View File

@@ -42,14 +42,14 @@ public class MdmAddVersionMigrationTask extends AbstractItemMigrationTask {
MDMConnectionItem mdmItem = (MDMConnectionItem) item;
MDMConnection connection = (MDMConnection) mdmItem.getConnection();
if (connection.getVersion() == null) {
connection.setVersion(MDMVersions.MDM_S56.getKey());
connection.setVersion(MDMVersions.MDM_S60.getKey());
if (connection.getServerUrl() == null) {
if (connection.getServer() != null && connection.getPort() != null) {
connection.setServerUrl("http://" + connection.getServer() + ":" + connection.getPort()
+ "/talend/TalendPort");
+ "/talendmdm/services/soap");
} else {
// set default url
connection.setServerUrl("http://localhost:8180/talend/TalendPort");
connection.setServerUrl("http://localhost:8180/talendmdm/services/soap");
}
}
factory.save(item, true);

View File

@@ -44,8 +44,6 @@ import org.talend.repository.mdm.i18n.Messages;
*/
public class MDMForm extends AbstractForm {
private LabelledCombo versionComb;
// control fields
private LabelledText mdmUsernameText;
@@ -102,7 +100,6 @@ public class MDMForm extends AbstractForm {
@Override
protected void adaptFormToReadOnly() {
readOnly = isReadOnly();
versionComb.setReadOnly(readOnly);
mdmUsernameText.setReadOnly(readOnly);
mdmPasswordText.setReadOnly(readOnly);
serverURLText.setReadOnly(readOnly);
@@ -124,7 +121,6 @@ public class MDMForm extends AbstractForm {
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
mdmParameterGroup.setLayoutData(gridData);
versionComb = new LabelledCombo(mdmParameterGroup, "Version", "Version", MDMVersions.getVersions(), true);
mdmUsernameText = new LabelledText(mdmParameterGroup, Messages.getString("MDMForm_userName"), true); //$NON-NLS-1$
mdmPasswordText = new LabelledText(mdmParameterGroup, Messages.getString("MDMForm_pass"), 1, SWT.BORDER | SWT.PASSWORD); //$NON-NLS-1$
serverURLText = new LabelledText(mdmParameterGroup, Messages.getString("MDMForm_server_url"), true); //$NON-NLS-1$
@@ -160,21 +156,6 @@ public class MDMForm extends AbstractForm {
*/
@Override
protected void addFieldsListeners() {
versionComb.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
String key = MDMVersions.getKey(versionComb.getText());
getConnection().setVersion(key);
if (MDMVersions.MDM_S60.getKey().equals(key)) {
serverURLText.setText(SERVER_RUL_S60);
} else {
serverURLText.setText(SERVER_RUL_S56);
}
checkFieldsValue();
}
});
mdmUsernameText.addModifyListener(new ModifyListener() {
@Override
@@ -310,29 +291,12 @@ public class MDMForm extends AbstractForm {
MDMConnection mdmConn = getConnection();
if (isContextMode()) {
adaptFormToEditable();
versionComb.setText(MDMVersions.getDispalyName(mdmConn.getVersion()));
mdmUsernameText.setText(mdmConn.getUsername());
mdmPasswordText.setText(mdmConn.getPassword());
serverURLText.setText(mdmConn.getServerUrl());
} else {
String version = mdmConn.getVersion();
String serverUrl = mdmConn.getServerUrl();
if (creation) {
mdmConn.setVersion(MDMVersions.MDM_S60.getKey());
mdmConn.setServerUrl(SERVER_RUL_S60);
} else {
if (version == null || "".equals(version)) {
mdmConn.setVersion(MDMVersions.MDM_S56.getKey());
}
if (serverUrl == null || "".equals(serverUrl)) {
if (MDMVersions.MDM_S60.getKey().equals(mdmConn.getVersion())) {
mdmConn.setServerUrl(SERVER_RUL_S60);
} else {
mdmConn.setServerUrl(SERVER_RUL_S56);
}
}
}
versionComb.setText(MDMVersions.getDispalyName(mdmConn.getVersion()));
mdmConn.setVersion(MDMVersions.MDM_S60.getKey());
mdmConn.setServerUrl(SERVER_RUL_S60);
mdmUsernameText.setText(mdmConn.getUsername());
mdmPasswordText.setText(mdmConn.getValue(mdmConn.getPassword(), false));
serverURLText.setText(mdmConn.getServerUrl());

View File

@@ -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();
}
}

View File

@@ -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()){

View File

@@ -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" />

View File

@@ -98,7 +98,6 @@
<module>main/plugins/org.talend.libraries.apache.chemistry</module>
<module>main/plugins/org.talend.libraries.apache.common</module>
<module>main/plugins/org.talend.libraries.apache.cxf</module>
<module>main/plugins/org.talend.libraries.apache.google</module>
<module>main/plugins/org.talend.libraries.apache.http</module>
<module>main/plugins/org.talend.libraries.apache.lucene</module>
<module>main/plugins/org.talend.libraries.apache.lucene4</module>

View File

@@ -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));
}
}

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -381,10 +381,10 @@ public class LocalComponentsInstallComponentTest {
installComp.setLogin(false); // only for user component
final boolean install = installComp.doInstall();
Assert.assertTrue("Install failure", install);
Assert.assertFalse("Install failure", install);
Assert.assertFalse("Install success, no need restart", installComp.needRelaunch());
Assert.assertNotNull(installComp.getInstalledMessages());
Assert.assertNull(installComp.getInstalledMessages());
final List<File> failedComponents = installComp.getFailedComponents();
Assert.assertNotNull(failedComponents);
@@ -451,10 +451,10 @@ public class LocalComponentsInstallComponentTest {
installComp.setLogin(true); // add patches folder
final boolean install = installComp.doInstall();
Assert.assertTrue("Install failure", install);
Assert.assertFalse("Install failure", install);
Assert.assertFalse("Install success, no need restart", installComp.needRelaunch());
Assert.assertNotNull(installComp.getInstalledMessages());
Assert.assertNull(installComp.getInstalledMessages());
final List<File> failedComponents = installComp.getFailedComponents();
Assert.assertNotNull(failedComponents);
@@ -481,78 +481,4 @@ public class LocalComponentsInstallComponentTest {
Assert.assertFalse("Should install failure", installed);
}
@Test
public void test_doInstall_hasPatchFolderFailure() throws Exception {
final File testDataFile = BundleFileUtil.getBundleFile(this.getClass(), P2InstallerTest.TEST_COMP_MYJIRA);
Assert.assertNotNull(testDataFile);
Assert.assertTrue(testDataFile.exists());
final File userCompFolder = new File(tmpFolder, "user");
userCompFolder.mkdir();
final File userCompFile = new File(userCompFolder, testDataFile.getName());
FilesUtils.copyFile(testDataFile, userCompFile);
final File patchesFolder = new File(tmpFolder, "patches");
patchesFolder.mkdir();
final File patchFile = new File(patchesFolder, testDataFile.getName());
FilesUtils.copyFile(testDataFile, patchFile);
final URI patchURI = PathUtils.getP2RepURIFromCompFile(patchFile);
LocalComponentsInstallComponent installComp = new LocalComponentsInstallComponentTestClass() {
@Override
protected File getUserComponentFolder() {
return userCompFolder;
}
@Override
protected File getPatchesFolder() {
return patchesFolder;
}
@Override
protected ComponentP2ExtraFeature createComponentFeature(File f) {
return new ComponentP2ExtraFeature(f) {
@Override
public boolean canBeInstalled(IProgressMonitor progress) throws P2ExtraFeatureException {
return true;
}
@Override
public IStatus install(IProgressMonitor progress, List<URI> allRepoUris) throws P2ExtraFeatureException {
if (allRepoUris.contains(patchURI)) {
throw new RuntimeException();
}
return Messages.createOkStatus("sucessfull.install.of.components", getP2IuId(), getVersion()); //$NON-NLS-1$
}
@Override
public boolean needRestart() {
return false;
}
};
}
};
try {
installComp.setLogin(true); // when install patch folder will have error
final boolean install = installComp.doInstall();
Assert.assertTrue("Install failure", install);
Assert.assertFalse("Install success, no need restart", installComp.needRelaunch());
Assert.assertNotNull(installComp.getInstalledMessages());
final List<File> failedComponents = installComp.getFailedComponents();
Assert.assertNotNull(failedComponents);
Assert.assertEquals(1, failedComponents.size());
final File file = failedComponents.get(0);
Assert.assertEquals(patchFile, file); // install failure file
} finally {
installComp.setLogin(false);
}
}
}