Compare commits
43 Commits
onimych/TD
...
maintenanc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df7c9d2d4d | ||
|
|
e53716ba54 | ||
|
|
7ff2675b86 | ||
|
|
46471c878e | ||
|
|
42120c6db3 | ||
|
|
768c0247ca | ||
|
|
8bffe9239a | ||
|
|
d9a9934e2c | ||
|
|
25ae09285a | ||
|
|
38f0cdb4a8 | ||
|
|
8d31e21051 | ||
|
|
68b84b1590 | ||
|
|
be546937be | ||
|
|
a3359f65c5 | ||
|
|
8b3798a5cd | ||
|
|
ff6e1466ef | ||
|
|
7c23b55695 | ||
|
|
908016db95 | ||
|
|
b66a48d0e8 | ||
|
|
4263d6c113 | ||
|
|
568b699a66 | ||
|
|
c4939b8d17 | ||
|
|
cf37143e88 | ||
|
|
5025e1313e | ||
|
|
b4ff690dd4 | ||
|
|
8178c0ed6c | ||
|
|
e411bf27e9 | ||
|
|
bac868243d | ||
|
|
11759c0e39 | ||
|
|
4c5f8d2c6a | ||
|
|
6377917727 | ||
|
|
6470a49143 | ||
|
|
c4ed60ffe4 | ||
|
|
0a495661ec | ||
|
|
ac55c8a332 | ||
|
|
94137658bd | ||
|
|
fabaf19e9b | ||
|
|
5ab9f488ac | ||
|
|
ebd37ef57a | ||
|
|
890f446373 | ||
|
|
af6a19aed6 | ||
|
|
13ae1d14f3 | ||
|
|
3332b8a299 |
@@ -21,6 +21,7 @@ import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
@@ -38,6 +39,8 @@ public class ExceptionMessageDialog extends MessageDialog {
|
||||
|
||||
private String exceptionString = null;
|
||||
|
||||
private int[] diabledButtonIndex = new int[] {};
|
||||
|
||||
public ExceptionMessageDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage,
|
||||
int dialogImageType, String[] dialogButtonLabels, int defaultIndex, Throwable ex) {
|
||||
super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
|
||||
@@ -147,4 +150,21 @@ public class ExceptionMessageDialog extends MessageDialog {
|
||||
this.exceptionString = exceptionString;
|
||||
}
|
||||
|
||||
public void setDisabledButtons(int[] index) {
|
||||
this.diabledButtonIndex = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
super.createButtonsForButtonBar(parent);
|
||||
if (diabledButtonIndex == null) {
|
||||
return;
|
||||
}
|
||||
for (int index : diabledButtonIndex) {
|
||||
Button button = super.getButton(index);
|
||||
button.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,8 @@ public interface ITaCoKitService {
|
||||
|
||||
boolean isNeedMigration(String componentName, Map<String, String> properties);
|
||||
|
||||
boolean isTaCoKitType(Object repoType);
|
||||
|
||||
public static ITaCoKitService getInstance() throws Exception {
|
||||
BundleContext bc = FrameworkUtil.getBundle(ITaCoKitService.class).getBundleContext();
|
||||
Collection<ServiceReference<ITaCoKitService>> tacokitServices = Collections.emptyList();
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.commons.utils.database;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
/**
|
||||
* created by qiongli on 2013-11-13 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class Sybase16SADatabaseMetaData extends SybaseDatabaseMetaData {
|
||||
|
||||
private static Logger log = Logger.getLogger(Sybase16SADatabaseMetaData.class);
|
||||
|
||||
/**
|
||||
* DOC qiongli SybaseIQDatabaseMetaData constructor comment.
|
||||
*
|
||||
* @param connection
|
||||
* @throws SQLException
|
||||
*/
|
||||
public Sybase16SADatabaseMetaData(Connection connection) throws SQLException {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
public ResultSet getCatalogs(String login, String database) throws SQLException {
|
||||
List<String[]> list = new ArrayList<String[]>();
|
||||
|
||||
List<String> catList = new ArrayList<String>();
|
||||
if (!StringUtils.isEmpty(database)) {
|
||||
catList.add(database);
|
||||
}
|
||||
|
||||
for (String catalogName : catList) {
|
||||
String sql = createSqlByLoginAndCatalog(login, catalogName);
|
||||
ResultSet rs = null;
|
||||
Statement stmt = null;
|
||||
try {
|
||||
stmt = connection.createStatement();
|
||||
rs = stmt.executeQuery(sql);
|
||||
|
||||
while (rs.next()) {
|
||||
int temp = rs.getInt(1);
|
||||
if (temp > 0) {
|
||||
String[] r = new String[] { catalogName };
|
||||
list.add(r);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.error(e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SybaseResultSet tableResultSet = new SybaseResultSet();
|
||||
tableResultSet.setMetadata(new String[] { "TABLE_CAT" }); //$NON-NLS-1$
|
||||
tableResultSet.setData(list);
|
||||
return tableResultSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern)
|
||||
throws SQLException {
|
||||
return super.getColumns(null, schemaPattern, tableNamePattern, columnNamePattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
|
||||
return super.getPrimaryKeys(null, schema, table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
|
||||
throws SQLException {
|
||||
return super.getTables(null, schemaPattern, tableNamePattern, types);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* get a sql query by login name and catalog name.
|
||||
*
|
||||
* @param loginName
|
||||
* @param catalogName
|
||||
* @return
|
||||
*/
|
||||
protected String createSqlByLoginAndCatalog(String loginName, String catalogName) {
|
||||
String sql = "select count(*) from " + catalogName
|
||||
+ ".dbo.sysusers where suid in (select suid from "+catalogName+".dbo.syslogins where name = '" + loginName
|
||||
+ "')";
|
||||
return sql;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -225,7 +225,7 @@ public abstract class ExtendedPushButton implements IExtendedPushButton {
|
||||
if (extendedControlModel == null) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
return !extendedControlModel.isReadonly();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,5 +94,9 @@ public abstract class AbstractExtendedControlModel {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isReadonly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -398,4 +398,9 @@ public class ExtendedTableModel<B> extends AbstractExtendedControlModel {
|
||||
this.tableViewer = tableViewer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadonly() {
|
||||
return super.isReadonly();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -874,6 +874,9 @@ public final class ProxyRepositoryFactory implements IProxyRepositoryFactory {
|
||||
}
|
||||
|
||||
this.repositoryFactoryFromProvider.deleteObjectPhysical(project, object, version, fromEmptyRecycleBin);
|
||||
if (isFullLogonFinished()) {
|
||||
fireRepositoryPropertyChange(ERepositoryActionName.AFTER_DELETE.getName(), null, object);
|
||||
}
|
||||
// i18n
|
||||
// log.info("Physical deletion [" + objToDelete + "] by " + getRepositoryContext().getUser() + ".");
|
||||
String str[] = new String[] { object.toString(), getRepositoryContext().getUser().toString() };
|
||||
|
||||
@@ -12,10 +12,14 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.repository.model.dnd;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.components.IComponentsService;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.SalesforceSchemaConnectionItem;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
@@ -28,6 +32,8 @@ import org.talend.repository.model.RepositoryNode;
|
||||
*/
|
||||
public class SalesforceComponentDndFilter extends DefaultRepositoryComponentDndFilter {
|
||||
|
||||
public static final String SALSEFORCE = "salesforce"; //$NON-NLS-1$
|
||||
|
||||
public static final String COMPONENT_T_SALSEFORCE_CONNECTION = "tSalesforceConnection"; //$NON-NLS-1$
|
||||
|
||||
public static final String COMPONENT_T_SALSEFORCE_WAVE_BULK_EXEC = "tSalesforceWaveBulkExec"; //$NON-NLS-1$
|
||||
@@ -98,7 +104,16 @@ public class SalesforceComponentDndFilter extends DefaultRepositoryComponentDndF
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (item instanceof ConnectionItem && SALSEFORCE.equalsIgnoreCase(((ConnectionItem) item).getTypeName())) {
|
||||
// Special for Javajet components: tSalesforceEinsteinBulkExec/tSalesforceEinsteinOutputBulkExec
|
||||
IComponentsService service = GlobalServiceRegister.getDefault().getService(IComponentsService.class);
|
||||
Collection<IComponent> componentAll = service.getComponentsFactory().readComponents();
|
||||
for (IComponent component : componentAll) {
|
||||
if (component.getName().startsWith("tSalesforceEinstein") && !components.contains(component)) { //$NON-NLS-1$
|
||||
components.add(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
return components;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ Export-Package: org.talend.commons.utils.generation,
|
||||
org.talend.core.model.business,
|
||||
org.talend.core.model.components,
|
||||
org.talend.core.model.context,
|
||||
org.talend.core.model.context.link,
|
||||
org.talend.core.model.general,
|
||||
org.talend.core.model.genhtml,
|
||||
org.talend.core.model.metadata,
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<extension-point id="hadoopConnectionCreator" name="Hadoop Connection Creator" schema="schema/hadoopConnectionCreator.exsd"/>
|
||||
<extension-point id="artifact_handler" name="Artifact Repository Handler" schema="schema/artifact_handler.exsd"/>
|
||||
<extension-point id="actionFilterDelegate" name="Action Filter delegate" schema="schema/actionFilterDelegate.exsd"/>
|
||||
<extension-point id="saveItemContextLinkService" name="Save Item Context Link Service" schema="schema/saveItemContextLinkService.exsd"/>
|
||||
|
||||
<extension
|
||||
point="org.talend.core.runtime.repositoryComponent_provider">
|
||||
@@ -53,4 +54,16 @@
|
||||
name="Talend">
|
||||
</category>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
point="org.talend.core.runtime.service">
|
||||
<Service
|
||||
class="org.talend.core.model.update.RepositoryContextUpdateService"
|
||||
serviceId="IRepositoryContextUpdateService">
|
||||
</Service>
|
||||
<Service
|
||||
class="org.talend.core.model.update.GenericDbContextUpdateService"
|
||||
serviceId="IRepositoryContextUpdateService">
|
||||
</Service>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.talend.core.runtime" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.talend.core.runtime" id="saveItemContextLinkService" name="Save Item Context Link Service"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
Save the context link data for item which contain ContextType object
|
||||
The extension point must implements interface : org.talend.core.model.context.link.IItemContextLinkService
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<element ref="creator" minOccurs="1" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="creator">
|
||||
<complexType>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.talend.core.model.context.link.IItemContextLinkService"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
7.4.1
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="apiinfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
boolean accept(Item item);
|
||||
|
||||
boolean saveItemLink(Item item);
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
</schema>
|
||||
@@ -254,6 +254,34 @@ public final class ResourceUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment method "setFileContent".
|
||||
*
|
||||
* @param stream
|
||||
* @param file
|
||||
* @throws PersistenceException
|
||||
*/
|
||||
public static void setFileContent(InputStream stream, IFile file) throws PersistenceException {
|
||||
try {
|
||||
if (stream == null) {
|
||||
String msg = Messages.getString("resources.file.notCreated", file.getName(), //$NON-NLS-1$
|
||||
Messages.getString("ResourceUtils.streamNull")); //$NON-NLS-1$
|
||||
throw new PersistenceException(msg);
|
||||
}
|
||||
file.setContents(stream, true, false, null);
|
||||
} catch (CoreException e) {
|
||||
String msg = Messages.getString("resources.file.notCreated", file.getName(), e.getMessage()); //$NON-NLS-1$
|
||||
throw new PersistenceException(msg, e);
|
||||
} finally {
|
||||
try {
|
||||
if (stream != null) {
|
||||
stream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
CommonExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Convenience method to delete a file.<br/>
|
||||
*
|
||||
|
||||
@@ -12,35 +12,49 @@
|
||||
// ============================================================================
|
||||
package org.talend.core;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
|
||||
/**
|
||||
* created by ldong on Mar 23, 2015 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class AbstractRepositoryContextUpdateService implements IRepositoryContextUpdateService {
|
||||
|
||||
@Override
|
||||
public void updateRelatedContextVariable(Connection con, String oldValue, String newValue) {
|
||||
|
||||
}
|
||||
|
||||
public abstract class AbstractRepositoryContextUpdateService implements IRepositoryContextUpdateService {
|
||||
protected IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
|
||||
protected String updateHadoopProperties(List<Map<String, Object>> hadoopProperties, String oldValue, String newValue) {
|
||||
String finalProperties = "";
|
||||
String finalProperties = null;
|
||||
boolean isModified = false;
|
||||
if (!hadoopProperties.isEmpty()) {
|
||||
for (Map<String, Object> propertyMap : hadoopProperties) {
|
||||
String propertyValue = (String) propertyMap.get("VALUE");
|
||||
if (propertyValue.equals(oldValue)) {
|
||||
propertyMap.put("VALUE", newValue);
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
finalProperties = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopProperties);
|
||||
if (isModified) {
|
||||
finalProperties = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopProperties);
|
||||
}
|
||||
}
|
||||
return finalProperties;
|
||||
}
|
||||
|
||||
protected boolean updateCompPropertiesContextParameter(Connection conn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
Map<String, String> oldToNewHM = new HashMap<String, String>();
|
||||
oldToNewHM.put(oldValue, newValue);
|
||||
String compProperties = conn.getCompProperties();
|
||||
if (service != null && StringUtils.isNotBlank(compProperties)) {
|
||||
service.updateCompPropertiesForContextMode(conn, oldToNewHM);
|
||||
isModified = true;
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
// ============================================================================
|
||||
package org.talend.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
@@ -247,4 +249,29 @@ public class GlobalServiceRegister {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List findAllService(Class klass) {
|
||||
List serviceList = new ArrayList();
|
||||
String key = klass.getName();
|
||||
IConfigurationElement[] configElements = getConfigurationElements();
|
||||
if (configElements != null) {
|
||||
for (IConfigurationElement element : configElements) {
|
||||
if (element.isValid()) {
|
||||
String id = element.getAttribute("serviceId"); //$NON-NLS-1$
|
||||
if (!key.endsWith(id)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Object service = element.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
if (klass.isInstance(service)) {
|
||||
serviceList.add(service);
|
||||
};
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return serviceList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,5 +20,7 @@ import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
*/
|
||||
public interface IRepositoryContextUpdateService extends IService {
|
||||
|
||||
public void updateRelatedContextVariable(Connection con, String oldValue, String newValue);
|
||||
public boolean accept(Connection connection);
|
||||
|
||||
public boolean updateContextParameter(Connection conn, String oldValue, String newValue);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ public enum EDatabaseTypeName {
|
||||
"IBM DB2 ZOS", "IBM DB2 ZOS", Boolean.TRUE, "IBM_DB2", "DB2", EDatabaseSchemaOrCatalogMapping.Sid, EDatabaseSchemaOrCatalogMapping.Schema), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
SYBASEASE(
|
||||
"SybaseASE", "Sybase (ASE and IQ)", Boolean.TRUE, "SYBASE", EDatabaseSchemaOrCatalogMapping.Sid, EDatabaseSchemaOrCatalogMapping.None), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
SYBASEASE_SA(
|
||||
"SybaseASE", "SQL Anywhere", Boolean.TRUE, "SYBASE", EDatabaseSchemaOrCatalogMapping.Sid, EDatabaseSchemaOrCatalogMapping.None), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
// this Sybase IQ not used.
|
||||
SYBASEIQ(
|
||||
|
||||
@@ -114,7 +114,7 @@ public enum EDatabaseVersion4Drivers {
|
||||
"db2jcc_license_cisuz.jar" })), //$NON-NLS-1$
|
||||
SYBASEASE(new DbVersion4Drivers(EDatabaseTypeName.SYBASEASE, "Sybase 12/15", "SYBSEIQ_12_15", "jconn3.jar")), //$NON-NLS-1$
|
||||
SYBASEIQ_16(new DbVersion4Drivers(EDatabaseTypeName.SYBASEASE, "Sybase 16", "SYBSEIQ_16", "jconn4.jar")), //$NON-NLS-1$
|
||||
SYBASEIQ_16_SA(new DbVersion4Drivers(EDatabaseTypeName.SYBASEASE, "Sybase 16 (SQL Anywhere)", "SYBSEIQ_16_SA", "sajdbc4.jar")),
|
||||
SYBASEIQ_16_SA(new DbVersion4Drivers(EDatabaseTypeName.SYBASEASE, "Sybase 16 (SQL Anywhere)", "SYBSEIQ_16_SA", "sajdbc4-17.0.0.jar")),
|
||||
SYBASEIQ(new DbVersion4Drivers(EDatabaseTypeName.SYBASEIQ, "jconn3.jar")), //$NON-NLS-1$
|
||||
|
||||
// for bug 0013127
|
||||
@@ -166,9 +166,9 @@ public enum EDatabaseVersion4Drivers {
|
||||
REDSHIFT(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT, "redshift", "REDSHIFT", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"redshift-jdbc42-no-awssdk-1.2.37.1061.jar")), //$NON-NLS-1$
|
||||
REDSHIFT_SSO(new DbVersion4Drivers(EDatabaseTypeName.REDSHIFT_SSO, "redshift sso", "REDSHIFT_SSO", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
new String[] { "redshift-jdbc42-no-awssdk-1.2.37.1061.jar", "aws-java-sdk-1.11.406.jar", "jackson-core-2.9.9.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"jackson-databind-2.9.9.jar", "jackson-annotations-2.9.0.jar", "httpcore-4.4.9.jar", "httpclient-4.5.5.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
|
||||
"joda-time-2.8.1.jar", "commons-logging-1.1.3.jar", "commons-codec-1.6.jar" })), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
new String[] { "redshift-jdbc42-no-awssdk-1.2.37.1061.jar", "aws-java-sdk-1.11.729.jar", "jackson-core-2.10.1.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"jackson-databind-2.10.1.jar", "jackson-annotations-2.10.1.jar", "httpcore-4.4.11.jar", "httpclient-4.5.9.jar", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
|
||||
"joda-time-2.8.1.jar", "commons-logging-1.2.jar", "commons-codec-1.11.jar" })), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
|
||||
AMAZON_AURORA(new DbVersion4Drivers(EDatabaseTypeName.AMAZON_AURORA, "mysql-connector-java-5.1.30-bin.jar")); //$NON-NLS-1$
|
||||
|
||||
|
||||
@@ -21,8 +21,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.jdt.core.JavaConventions;
|
||||
import org.eclipse.jdt.core.JavaCore;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
@@ -30,6 +33,9 @@ import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.platform.PluginChecker;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.language.LanguageManager;
|
||||
import org.talend.core.model.context.link.ContextLinkService;
|
||||
import org.talend.core.model.context.link.ContextParamLink;
|
||||
import org.talend.core.model.context.link.ItemContextLink;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.MetadataToolHelper;
|
||||
import org.talend.core.model.metadata.types.ContextParameterJavaTypeManager;
|
||||
@@ -43,6 +49,7 @@ import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.cwm.helper.ResourceHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ProcessType;
|
||||
@@ -53,6 +60,8 @@ import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
*/
|
||||
public class ContextUtils {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(ContextUtils.class);
|
||||
|
||||
private static final Set<String> JAVA_KEYWORDS = new HashSet<String>(Arrays.asList("abstract", "continue", "for", "new", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
"switch", "assert", "default", "goto", "package", "synchronized", "boolean", "do", "if", "private", "this", "break", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$
|
||||
"double", "implements", "protected", "throw", "byte", "else", "import", "public", "throws", "case", "enum", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$
|
||||
@@ -82,15 +91,25 @@ public class ContextUtils {
|
||||
* update the JobContextParameter form repository ContextItem by context name.
|
||||
*
|
||||
*/
|
||||
public static boolean updateParameterFromRepository(ContextItem sourceItem, IContextParameter contextParam, String contextName) {
|
||||
public static boolean updateParameterFromRepository(Item sourceItem, IContextParameter contextParam, String contextName) {
|
||||
return updateParameterFromRepository(sourceItem, contextParam, contextName, null);
|
||||
}
|
||||
|
||||
public static boolean updateParameterFromRepository(Item sourceItem, IContextParameter contextParam, String contextName,
|
||||
Map<String, String> renameMap) {
|
||||
if (sourceItem == null || contextParam == null) {
|
||||
return false;
|
||||
}
|
||||
// not found, use default.
|
||||
ContextType contextType = getContextTypeByName(sourceItem, contextName, true);
|
||||
ContextType contextType = getContextTypeByName(sourceItem, contextName);
|
||||
|
||||
if (contextType != null) {
|
||||
ContextParameterType parameterType = getContextParameterTypeByName(contextType, contextParam.getName());
|
||||
String paramName = contextParam.getName();
|
||||
String newName = ContextUtils.getNewNameFromRenameMap(renameMap, paramName);
|
||||
if (newName != null) {
|
||||
paramName = newName;
|
||||
}
|
||||
ContextParameterType parameterType = getContextParameterTypeByName(contextType, paramName);
|
||||
// found parameter, update it.
|
||||
if (parameterType != null) {
|
||||
contextParam.setComment(parameterType.getComment());
|
||||
@@ -98,6 +117,9 @@ public class ContextUtils {
|
||||
contextParam.setPromptNeeded(parameterType.isPromptNeeded());
|
||||
contextParam.setType(parameterType.getType());
|
||||
contextParam.setValue(parameterType.getRawValue());
|
||||
if (!StringUtils.equals(contextParam.getName(), parameterType.getName())) {
|
||||
contextParam.setName(parameterType.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -178,6 +200,28 @@ public class ContextUtils {
|
||||
return parameterType;
|
||||
}
|
||||
|
||||
public static ContextParameterType getContextParameterTypeById(ContextType contextType, final String uuId,
|
||||
boolean isFromContextItem) {
|
||||
if (contextType == null || uuId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ContextParameterType parameterType = null;
|
||||
for (ContextParameterType param : (List<ContextParameterType>) contextType.getContextParameter()) {
|
||||
String paramId = null;
|
||||
if (isFromContextItem) {
|
||||
paramId = ResourceHelper.getUUID(param);
|
||||
} else {
|
||||
paramId = param.getInternalId();
|
||||
}
|
||||
if (uuId.equals(paramId)) {
|
||||
parameterType = param;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parameterType;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean checkObject(Object obj) {
|
||||
if (obj == null) {
|
||||
@@ -372,6 +416,7 @@ public class ContextUtils {
|
||||
targetParam.setValue(sourceParam.getValue());
|
||||
targetParam.setPromptNeeded(sourceParam.isPromptNeeded());
|
||||
targetParam.setComment(sourceParam.getComment());
|
||||
targetParam.setInternalId(sourceParam.getInternalId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -411,7 +456,7 @@ public class ContextUtils {
|
||||
targetParam.setValue(sourceParam.getRawValue());
|
||||
targetParam.setPromptNeeded(sourceParam.isPromptNeeded());
|
||||
targetParam.setComment(sourceParam.getComment());
|
||||
|
||||
targetParam.setInternalId(sourceParam.getInternalId());
|
||||
}
|
||||
|
||||
public static Map<String, Item> getRepositoryContextItemIdMapping() {
|
||||
@@ -538,8 +583,8 @@ public class ContextUtils {
|
||||
}
|
||||
|
||||
// preference name must match TalendDesignerPrefConstants.PROPAGATE_CONTEXT_VARIABLE
|
||||
return Boolean.parseBoolean(CoreRuntimePlugin.getInstance().getDesignerCoreService()
|
||||
.getPreferenceStore("propagateContextVariable")); //$NON-NLS-1$
|
||||
return Boolean.parseBoolean(
|
||||
CoreRuntimePlugin.getInstance().getDesignerCoreService().getPreferenceStore("propagateContextVariable")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,17 +618,17 @@ public class ContextUtils {
|
||||
|
||||
boolean modified = false;
|
||||
for (String varName : set) {
|
||||
ContextParameterType contextParameterType = ContextUtils.getContextParameterTypeByName(
|
||||
contextType, varName);
|
||||
IContextParameter contextParameter = processJobManager.getDefaultContext().getContextParameter(
|
||||
varName);
|
||||
ContextParameterType contextParameterType = ContextUtils
|
||||
.getContextParameterTypeByName(contextType, varName);
|
||||
IContextParameter contextParameter = processJobManager.getDefaultContext()
|
||||
.getContextParameter(varName);
|
||||
if (contextParameter == null) { // added
|
||||
addContextParameterType(processJobManager, contextItem, contextParameterType);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
if (modified) {
|
||||
processJobManager.saveToEmf(processType.getContext());
|
||||
processJobManager.saveToEmf(processType.getContext(), true);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
@@ -672,8 +717,328 @@ public class ContextUtils {
|
||||
|
||||
contextParam.setPromptNeeded(contextParamType.isPromptNeeded());
|
||||
contextParam.setComment(contextParamType.getComment());
|
||||
contextParam.setInternalId(contextParamType.getInternalId());
|
||||
contextParam.setSource(contextItem.getProperty().getId());
|
||||
return contextParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context type from item (ContextItem/JobletProcessItem/ProcessItem), If the name is null will use default
|
||||
* context
|
||||
*
|
||||
* @param item
|
||||
* @param contextName
|
||||
* @return
|
||||
*/
|
||||
public static ContextType getContextTypeByName(Item item, String contextName) {
|
||||
if (item instanceof ContextItem) {
|
||||
ContextItem contextItem = (ContextItem) item;
|
||||
if (contextName == null) {
|
||||
contextName = contextItem.getDefaultContext();
|
||||
}
|
||||
return ContextUtils.getContextTypeByName(contextItem, contextName, true);
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
|
||||
return ContextUtils.getContextTypeByName((List<ContextType>) jobletProcessItem.getJobletProcess().getContext(),
|
||||
contextName, jobletProcessItem.getJobletProcess().getDefaultContext());
|
||||
} else if (item instanceof ProcessItem) {
|
||||
ProcessItem processItem = (ProcessItem) item;
|
||||
return ContextUtils.getContextTypeByName((List<ContextType>) processItem.getProcess().getContext(), contextName,
|
||||
processItem.getProcess().getDefaultContext());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getDefaultContextName(Item item) {
|
||||
if (item instanceof ContextItem) {
|
||||
ContextItem contextItem = (ContextItem) item;
|
||||
return contextItem.getDefaultContext();
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
|
||||
return jobletProcessItem.getJobletProcess().getDefaultContext();
|
||||
} else if (item instanceof ProcessItem) {
|
||||
ProcessItem processItem = (ProcessItem) item;
|
||||
return processItem.getProcess().getDefaultContext();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EList getAllContextType(Item item) {
|
||||
if (item instanceof ContextItem) {
|
||||
ContextItem contextItem = (ContextItem) item;
|
||||
return contextItem.getContext();
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
JobletProcessItem jobletProcessItem = (JobletProcessItem) item;
|
||||
return jobletProcessItem.getJobletProcess().getContext();
|
||||
} else if (item instanceof ProcessItem) {
|
||||
ProcessItem processItem = (ProcessItem) item;
|
||||
return processItem.getProcess().getContext();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Map<String, String> getContextParamterRenamedMap(Item item) {
|
||||
ItemContextLink itemContextLink = null;
|
||||
try {
|
||||
itemContextLink = ContextLinkService.getInstance().loadContextLinkFromJson(item);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
if (itemContextLink != null) {
|
||||
if (item instanceof ConnectionItem) {
|
||||
return compareConnectionContextParamName((ConnectionItem) item, itemContextLink);
|
||||
} else {
|
||||
return compareContextParamName(item, itemContextLink);
|
||||
}
|
||||
}
|
||||
|
||||
return Collections.EMPTY_MAP;
|
||||
}
|
||||
|
||||
private static Map<String, String> compareContextParamName(Item processItem, ItemContextLink itemContextLink) {
|
||||
List<ContextType> contextTypeList = getAllContextType(processItem);
|
||||
return compareContextParamName(contextTypeList, itemContextLink);
|
||||
}
|
||||
|
||||
public static Map<String, String> compareContextParamName(List<ContextType> contextTypeList,
|
||||
ItemContextLink itemContextLink) {
|
||||
Map<String, String> renamedMap = new HashMap<String, String>();
|
||||
Map<String, Item> tempItemMap = new HashMap<String, Item>();
|
||||
for (ContextType contextType : contextTypeList) {
|
||||
for (Object obj : contextType.getContextParameter()) {
|
||||
if (obj instanceof ContextParameterType) {
|
||||
ContextParameterType contextParameterType = (ContextParameterType) obj;
|
||||
ContextParamLink paramLink = itemContextLink.findContextParamLinkByName(
|
||||
contextParameterType.getRepositoryContextId(), contextType.getName(), contextParameterType.getName());
|
||||
if (paramLink != null) {
|
||||
Item item = tempItemMap.get(contextParameterType.getRepositoryContextId());
|
||||
if (item == null) {
|
||||
item = ContextUtils.getRepositoryContextItemById(contextParameterType.getRepositoryContextId());
|
||||
tempItemMap.put(contextParameterType.getRepositoryContextId(), item);
|
||||
}
|
||||
if (item != null) {
|
||||
final ContextType repoContextType = ContextUtils.getContextTypeByName(item, contextType.getName());
|
||||
ContextParameterType repoContextParam = ContextUtils.getContextParameterTypeById(repoContextType,
|
||||
paramLink.getId(), item instanceof ContextItem);
|
||||
if (repoContextParam != null
|
||||
&& !StringUtils.equals(repoContextParam.getName(), contextParameterType.getName())) {
|
||||
renamedMap.put(repoContextParam.getName(), contextParameterType.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return renamedMap;
|
||||
}
|
||||
|
||||
private static Map<String, String> compareConnectionContextParamName(ConnectionItem connectionItem,
|
||||
ItemContextLink itemContextLink) {
|
||||
Map<String, String> renamedMap = new HashMap<String, String>();
|
||||
if (connectionItem.getConnection().isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(connectionItem.getConnection().getContextId());
|
||||
if (contextItem != null) {
|
||||
ContextType contextType = ContextUtils.getContextTypeByName(contextItem,
|
||||
connectionItem.getConnection().getContextName(), false);
|
||||
if (contextType != null) {
|
||||
for (Object obj : contextType.getContextParameter()) {
|
||||
if (obj instanceof ContextParameterType) {
|
||||
ContextParameterType paramType = (ContextParameterType) obj;
|
||||
ContextParamLink paramLink = itemContextLink.findContextParamLinkById(
|
||||
connectionItem.getConnection().getContextId(),
|
||||
connectionItem.getConnection().getContextName(), ResourceHelper.getUUID(paramType));
|
||||
if (paramLink != null && !StringUtils.equals(paramType.getName(), paramLink.getName())) {
|
||||
renamedMap.put(paramType.getName(), paramLink.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return renamedMap;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param itemId
|
||||
* @param contextType
|
||||
* @return rename map. Key is new name and value is old name.
|
||||
*/
|
||||
public static Map<String, String> calculateRenamedMapFromLinkFile(String projectLabel, String itemId, IContext context,
|
||||
Item repoContextItem) {
|
||||
Map<String, String> renamedMap = new HashMap<String, String>();
|
||||
Map<String, Item> idToItemMap = new HashMap<String, Item>();
|
||||
if (repoContextItem != null) {
|
||||
idToItemMap.put(repoContextItem.getProperty().getId(), repoContextItem);
|
||||
}
|
||||
try {
|
||||
ItemContextLink itemContextLink = ContextLinkService.getInstance().doLoadContextLinkFromJson(projectLabel, itemId);
|
||||
if (itemContextLink != null) {
|
||||
for (Object obj : context.getContextParameterList()) {
|
||||
if (obj instanceof IContextParameter) {
|
||||
IContextParameter parameterType = (IContextParameter) obj;
|
||||
ContextParamLink parameterLink = itemContextLink.findContextParamLinkByName(parameterType.getSource(),
|
||||
context.getName(), parameterType.getName());
|
||||
if (parameterLink != null) {
|
||||
Item item = idToItemMap.get(parameterType.getSource());
|
||||
if (item == null) {
|
||||
item = getRepositoryContextItemById(parameterType.getSource());
|
||||
idToItemMap.put(parameterType.getSource(), item);
|
||||
}
|
||||
if (item != null) {
|
||||
ContextType contextType = ContextUtils.getContextTypeByName(item, context.getName());
|
||||
ContextParameterType repoParameterType = ContextUtils.getContextParameterTypeById(contextType,
|
||||
parameterLink.getId(), item instanceof ContextItem);
|
||||
if (repoParameterType != null
|
||||
&& !StringUtils.equals(repoParameterType.getName(), parameterType.getName())) {
|
||||
renamedMap.put(repoParameterType.getName(), parameterType.getName());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
return renamedMap;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* DOC hcw ProcessUpdateManager class global comment. Detailled comment
|
||||
*/
|
||||
public static class ContextItemParamMap {
|
||||
|
||||
private Map<Item, Set<String>> map = new HashMap<Item, Set<String>>();
|
||||
|
||||
public void add(Item item, String param) {
|
||||
Set<String> params = map.get(item);
|
||||
if (params == null) {
|
||||
params = new HashSet<String>();
|
||||
map.put(item, params);
|
||||
}
|
||||
params.add(param);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<String> get(Item item) {
|
||||
Set<String> params = map.get(item);
|
||||
return (params == null) ? Collections.EMPTY_SET : params;
|
||||
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return map.isEmpty();
|
||||
}
|
||||
|
||||
public Set<Item> getContexts() {
|
||||
return map.keySet();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean compareContextParameter(Item contextItem, ContextType contextType, IContextParameter param,
|
||||
ContextParamLink paramLink, Map<Item, Map<String, String>> repositoryRenamedMap, Map<Item, Set<String>> existedParams,
|
||||
ContextItemParamMap unsameMap, ContextItemParamMap deleteParams, boolean onlySimpleShow, boolean isDefaultContext) {
|
||||
boolean builtin = true;
|
||||
String paramName = param.getName();
|
||||
if (paramLink != null && paramLink.getId() != null && contextType != null) {// Compare use UUID
|
||||
String paramId = paramLink.getId();
|
||||
ContextParameterType contextParameterType = null;
|
||||
contextParameterType = getContextParameterTypeById(contextType, paramId, contextItem instanceof ContextItem);
|
||||
if (contextParameterType != null) {
|
||||
if (!StringUtils.equals(contextParameterType.getName(), paramName)) {
|
||||
if (isDefaultContext) {
|
||||
Map<String, String> renameMap = repositoryRenamedMap.get(contextItem);
|
||||
if (renameMap == null) {
|
||||
renameMap = new HashMap<String, String>();
|
||||
repositoryRenamedMap.put(contextItem, renameMap);
|
||||
}
|
||||
renameMap.put(contextParameterType.getName(), paramName);
|
||||
}
|
||||
} else {
|
||||
if (isDefaultContext) {
|
||||
if (existedParams.get(contextItem) == null) {
|
||||
existedParams.put(contextItem, new HashSet<String>());
|
||||
}
|
||||
existedParams.get(contextItem).add(paramName);
|
||||
}
|
||||
if (onlySimpleShow || !samePropertiesForContextParameter(param, contextParameterType)) {
|
||||
unsameMap.add(contextItem, paramName);
|
||||
}
|
||||
}
|
||||
builtin = false;
|
||||
} else {
|
||||
// delete context variable
|
||||
if (isPropagateContextVariable() && isDefaultContext) {
|
||||
deleteParams.add(contextItem, paramName);
|
||||
builtin = false;
|
||||
}
|
||||
}
|
||||
} else { // Compare use Name
|
||||
final ContextParameterType contextParameterType = ContextUtils.getContextParameterTypeByName(contextType, paramName);
|
||||
if (contextParameterType != null) {
|
||||
Item repositoryContext = contextItem;
|
||||
if (isDefaultContext) {
|
||||
if (existedParams.get(contextItem) == null) {
|
||||
existedParams.put(repositoryContext, new HashSet<String>());
|
||||
}
|
||||
existedParams.get(repositoryContext).add(paramName);
|
||||
}
|
||||
if (onlySimpleShow || !ContextUtils.samePropertiesForContextParameter(param, contextParameterType)) {
|
||||
unsameMap.add(contextItem, paramName);
|
||||
}
|
||||
builtin = false;
|
||||
} else {
|
||||
// delete context variable
|
||||
if (ContextUtils.isPropagateContextVariable()) {
|
||||
deleteParams.add(contextItem, paramName);
|
||||
builtin = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return builtin && isDefaultContext;
|
||||
}
|
||||
|
||||
public static String getParamId(IContextParameter param, ContextParamLink paramLink) {
|
||||
if (paramLink != null) {
|
||||
return paramLink.getId();
|
||||
}
|
||||
if (param != null) {
|
||||
return param.getInternalId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Item findContextItem(List<ContextItem> allContextItem, String source) {
|
||||
if (allContextItem != null) {
|
||||
for (ContextItem contextItem : allContextItem) {
|
||||
if (StringUtils.equals(contextItem.getProperty().getId(), source)) {
|
||||
return contextItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getRepositoryContextItemById(source);
|
||||
}
|
||||
|
||||
public static String getNewNameFromRenameMap(Map<String, String> renameMap, String oldName) {
|
||||
if (renameMap != null) {
|
||||
for (String key : renameMap.keySet()) {
|
||||
String value = renameMap.get(key);
|
||||
if (StringUtils.equals(value, oldName)) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isBuildInParameter(ContextParameterType paramType) {
|
||||
if (paramType.getRepositoryContextId() == null || IContextParameter.BUILT_IN.equals(paramType.getRepositoryContextId())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.emf.common.util.BasicEList;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.ecore.util.EcoreUtil;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
import org.talend.core.model.metadata.types.ContextParameterJavaTypeManager;
|
||||
import org.talend.core.model.process.IContext;
|
||||
@@ -30,6 +32,7 @@ import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.cwm.helper.ResourceHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
@@ -74,7 +77,7 @@ public class JobContextManager implements IContextManager {
|
||||
*/
|
||||
private Set<String> originalParamerters = new HashSet<String>();
|
||||
|
||||
private Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
|
||||
private Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
|
||||
|
||||
/*
|
||||
* for context group
|
||||
@@ -251,73 +254,7 @@ public class JobContextManager implements IContextManager {
|
||||
*/
|
||||
@Override
|
||||
public void saveToEmf(EList contextTypeList) {
|
||||
if (contextTypeList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (listContext.isEmpty()) {
|
||||
retrieveDefaultContext();
|
||||
}
|
||||
|
||||
EList newcontextTypeList = new BasicEList();
|
||||
for (int i = 0; i < listContext.size(); i++) {
|
||||
IContext context = listContext.get(i);
|
||||
String contextGroupName = renameGroupContext.get(context);
|
||||
if (contextGroupName == null) {
|
||||
contextGroupName = context.getName();
|
||||
}
|
||||
ContextType contextType = findContextType(contextTypeList, contextGroupName);
|
||||
if (contextType == null) {
|
||||
contextType = TalendFileFactory.eINSTANCE.createContextType();
|
||||
}
|
||||
contextType.setName(context.getName());
|
||||
contextType.setConfirmationNeeded(context.isConfirmationNeeded());
|
||||
newcontextTypeList.add(contextType);
|
||||
|
||||
EList contextTypeParamList = contextType.getContextParameter();
|
||||
List<IContextParameter> contextParameterList = context.getContextParameterList();
|
||||
|
||||
EList newContextTypeParamList = new BasicEList();
|
||||
if (contextParameterList != null) {
|
||||
for (int j = 0; j < contextParameterList.size(); j++) {
|
||||
IContextParameter contextParam = contextParameterList.get(j);
|
||||
String contexParameterName = nameMap.get(contextParam.getName());
|
||||
if (contexParameterName == null) {
|
||||
contexParameterName = contextParam.getName();
|
||||
}
|
||||
ContextParameterType contextParamType = findContextParameterType(contextTypeParamList, contexParameterName);
|
||||
if (contextParamType == null) {
|
||||
contextParamType = TalendFileFactory.eINSTANCE.createContextParameterType();
|
||||
}
|
||||
newContextTypeParamList.add(contextParamType);
|
||||
|
||||
contextParamType.setName(contextParam.getName());
|
||||
contextParamType.setPrompt(contextParam.getPrompt());
|
||||
contextParamType.setType(contextParam.getType());
|
||||
contextParamType.setRawValue(contextParam.getValue());
|
||||
contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
|
||||
contextParamType.setComment(contextParam.getComment());
|
||||
if (!contextParam.isBuiltIn()) {
|
||||
Item item = ContextUtils.getRepositoryContextItemById(contextParam.getSource());
|
||||
if (item != null) {
|
||||
contextParamType.setRepositoryContextId(item.getProperty().getId());
|
||||
} else {
|
||||
String contextId = contextParam.getSource();
|
||||
if (!IContextParameter.BUILT_IN.equals(contextId)) {
|
||||
contextParamType.setRepositoryContextId(contextId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
contextTypeParamList.clear(); // remove old
|
||||
contextTypeParamList.addAll(newContextTypeParamList);
|
||||
}
|
||||
}
|
||||
|
||||
contextTypeList.clear(); // clear old
|
||||
contextTypeList.addAll(newcontextTypeList);
|
||||
|
||||
saveToEmf(contextTypeList, false);
|
||||
}
|
||||
|
||||
private ContextType findContextType(EList contextTypeList, String contextName) {
|
||||
@@ -384,6 +321,7 @@ public class JobContextManager implements IContextManager {
|
||||
contextParam.setContext(context);
|
||||
contextParam.setName(contextParamType.getName());
|
||||
contextParam.setPrompt(contextParamType.getPrompt());
|
||||
contextParam.setInternalId(contextParamType.getInternalId());
|
||||
originalParamerters.add(contextParam.getName());
|
||||
boolean exists = true;
|
||||
try {
|
||||
@@ -486,16 +424,6 @@ public class JobContextManager implements IContextManager {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* ggu Comment method "getLostParameters".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<String> getLostParameters() {
|
||||
return this.lostParameters;
|
||||
}
|
||||
|
||||
public Map<ContextItem, Map<String, String>> getRepositoryRenamedMap() {
|
||||
return this.repositoryRenamedMap;
|
||||
}
|
||||
@@ -516,6 +444,16 @@ public class JobContextManager implements IContextManager {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* ggu Comment method "getLostParameters".
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<String> getLostParameters() {
|
||||
return this.lostParameters;
|
||||
}
|
||||
|
||||
public void addNewParameters(String param) {
|
||||
newParameters.add(param);
|
||||
}
|
||||
@@ -540,11 +478,11 @@ public class JobContextManager implements IContextManager {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<ContextItem, Set<String>> getNewParametersMap() {
|
||||
public Map<Item, Set<String>> getNewParametersMap() {
|
||||
return newParametersMap;
|
||||
}
|
||||
|
||||
public void setNewParametersMap(Map<ContextItem, Set<String>> newParametersMap) {
|
||||
public void setNewParametersMap(Map<Item, Set<String>> newParametersMap) {
|
||||
this.newParametersMap = newParametersMap;
|
||||
}
|
||||
|
||||
@@ -573,4 +511,98 @@ public class JobContextManager implements IContextManager {
|
||||
public void setConfigContextGroup(boolean isConfigContextGroup) {
|
||||
this.isConfigContextGroup = isConfigContextGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveToEmf(EList contextTypeList, boolean useInternalId) {
|
||||
if (contextTypeList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (listContext.isEmpty()) {
|
||||
retrieveDefaultContext();
|
||||
}
|
||||
|
||||
EList newcontextTypeList = new BasicEList();
|
||||
Map<String, Item> idToItemMap = new HashMap<String, Item>();
|
||||
for (int i = 0; i < listContext.size(); i++) {
|
||||
IContext context = listContext.get(i);
|
||||
String contextGroupName = renameGroupContext.get(context);
|
||||
if (contextGroupName == null) {
|
||||
contextGroupName = context.getName();
|
||||
}
|
||||
ContextType contextType = findContextType(contextTypeList, contextGroupName);
|
||||
if (contextType == null) {
|
||||
contextType = TalendFileFactory.eINSTANCE.createContextType();
|
||||
}
|
||||
contextType.setName(context.getName());
|
||||
contextType.setConfirmationNeeded(context.isConfirmationNeeded());
|
||||
newcontextTypeList.add(contextType);
|
||||
|
||||
EList contextTypeParamList = contextType.getContextParameter();
|
||||
List<IContextParameter> contextParameterList = context.getContextParameterList();
|
||||
|
||||
EList newContextTypeParamList = new BasicEList();
|
||||
if (contextParameterList != null) {
|
||||
for (int j = 0; j < contextParameterList.size(); j++) {
|
||||
IContextParameter contextParam = contextParameterList.get(j);
|
||||
String contexParameterName = nameMap.get(contextParam.getName());
|
||||
if (contexParameterName == null) {
|
||||
contexParameterName = contextParam.getName();
|
||||
}
|
||||
ContextParameterType contextParamType = findContextParameterType(contextTypeParamList, contexParameterName);
|
||||
if (contextParamType == null) {
|
||||
contextParamType = TalendFileFactory.eINSTANCE.createContextParameterType();
|
||||
}
|
||||
newContextTypeParamList.add(contextParamType);
|
||||
|
||||
contextParamType.setName(contextParam.getName());
|
||||
contextParamType.setPrompt(contextParam.getPrompt());
|
||||
contextParamType.setType(contextParam.getType());
|
||||
contextParamType.setRawValue(contextParam.getValue());
|
||||
contextParamType.setPromptNeeded(contextParam.isPromptNeeded());
|
||||
contextParamType.setComment(contextParam.getComment());
|
||||
if (!contextParam.isBuiltIn()) {
|
||||
Item item = idToItemMap.get(contextParam.getSource());
|
||||
if (item == null) {
|
||||
item = ContextUtils.getRepositoryContextItemById(contextParam.getSource());
|
||||
idToItemMap.put(contextParam.getSource(), item);
|
||||
}
|
||||
if (item != null) {
|
||||
contextParamType.setRepositoryContextId(item.getProperty().getId());
|
||||
if (item instanceof ContextItem) {
|
||||
ContextType repoContextType = ContextUtils.getContextTypeByName(item, contextType.getName());
|
||||
if (repoContextType != null) {
|
||||
ContextParameterType repoContextParam = ContextUtils
|
||||
.getContextParameterTypeByName(repoContextType, contextParam.getName());
|
||||
if (repoContextParam != null) {
|
||||
ResourceHelper.setUUid(contextParamType, ResourceHelper.getUUID(repoContextParam));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String contextId = contextParam.getSource();
|
||||
if (!IContextParameter.BUILT_IN.equals(contextId)) {
|
||||
contextParamType.setRepositoryContextId(contextId);
|
||||
}
|
||||
}
|
||||
} else if (useInternalId) {
|
||||
String internalId = contextParam.getInternalId();
|
||||
if (StringUtils.isEmpty(internalId)) {
|
||||
internalId = EcoreUtil.generateUUID();
|
||||
contextParamType.setInternalId(internalId);
|
||||
contextParam.setInternalId(internalId);
|
||||
} else {
|
||||
contextParamType.setInternalId(internalId);
|
||||
}
|
||||
}
|
||||
}
|
||||
contextTypeParamList.clear(); // remove old
|
||||
contextTypeParamList.addAll(newContextTypeParamList);
|
||||
}
|
||||
}
|
||||
|
||||
contextTypeList.clear(); // clear old
|
||||
contextTypeList.addAll(newcontextTypeList);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,13 +45,14 @@ public class JobContextParameter implements IContextParameter, Cloneable {
|
||||
|
||||
String[] valueList;
|
||||
|
||||
String internalId;
|
||||
|
||||
/**
|
||||
* change to save id always for bug 13184.
|
||||
*/
|
||||
String source = ""; //$NON-NLS-1$
|
||||
|
||||
public JobContextParameter() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -310,6 +311,14 @@ public class JobContextParameter implements IContextParameter, Cloneable {
|
||||
this.promptNeeded = promptNeeded;
|
||||
}
|
||||
|
||||
public String getInternalId() {
|
||||
return internalId;
|
||||
}
|
||||
|
||||
public void setInternalId(String internalId) {
|
||||
this.internalId = internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IContextParameter clone() {
|
||||
IContextParameter clonedContextParameter = null;
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.model.context.link;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ContextLink {
|
||||
|
||||
@JsonProperty("contextName")
|
||||
private String contextName;
|
||||
|
||||
@JsonProperty("repoId")
|
||||
private String repoId;
|
||||
|
||||
@JsonProperty("parameterList")
|
||||
private List<ContextParamLink> parameterList = new ArrayList<ContextParamLink>();
|
||||
|
||||
public String getRepoId() {
|
||||
return repoId;
|
||||
}
|
||||
|
||||
public void setRepoId(String repoId) {
|
||||
this.repoId = repoId;
|
||||
}
|
||||
|
||||
public List<ContextParamLink> getParameterList() {
|
||||
return parameterList;
|
||||
}
|
||||
|
||||
public void setParameterList(List<ContextParamLink> parameterList) {
|
||||
this.parameterList = parameterList;
|
||||
}
|
||||
|
||||
public String getContextName() {
|
||||
return contextName;
|
||||
}
|
||||
|
||||
public void setContextName(String contextName) {
|
||||
this.contextName = contextName;
|
||||
}
|
||||
|
||||
public ContextParamLink getParamLinkByName(String paramName) {
|
||||
for (ContextParamLink paramLink : parameterList) {
|
||||
if (StringUtils.equals(paramLink.getName(), paramName)) {
|
||||
return paramLink;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContextParamLink getParamLinkById(String id) {
|
||||
for (ContextParamLink paramLink : parameterList) {
|
||||
if (StringUtils.equals(paramLink.getId(), id)) {
|
||||
return paramLink;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContextLink cloneObj() {
|
||||
ContextLink obj = new ContextLink();
|
||||
obj.setContextName(contextName);
|
||||
obj.setRepoId(repoId);
|
||||
for (ContextParamLink p : parameterList) {
|
||||
obj.getParameterList().add(p.cloneObj());
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.model.context.link;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.JobletProcessItem;
|
||||
import org.talend.core.model.properties.ProcessItem;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.cwm.helper.ResourceHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.RepositoryConstants;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class ContextLinkService {
|
||||
|
||||
private static final String CREATOR_EXT_ID = "org.talend.core.runtime.saveItemContextLinkService"; //$NON-NLS-1$
|
||||
|
||||
public static final String LINKS_FOLDER_NAME = "links";
|
||||
|
||||
public static final String LINK_FILE_POSTFIX = ".link";
|
||||
|
||||
private static final List<IItemContextLinkService> registeredService = new ArrayList<IItemContextLinkService>();
|
||||
|
||||
private static ContextLinkService instance = new ContextLinkService();
|
||||
|
||||
private static final String CURRENT_PROJECT_LABEL = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
|
||||
private ContextLinkService() {
|
||||
initService();
|
||||
}
|
||||
|
||||
public static ContextLinkService getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public synchronized boolean saveContextLink(Item item) throws PersistenceException {
|
||||
for (IItemContextLinkService service : registeredService) {
|
||||
if (service.accept(item)) {
|
||||
return service.saveItemLink(item);
|
||||
}
|
||||
}
|
||||
return doSaveContextLink(item);
|
||||
}
|
||||
|
||||
public synchronized boolean doSaveContextLink(Item item) throws PersistenceException {
|
||||
if (item instanceof ProcessItem) {
|
||||
ProcessItem processItem = (ProcessItem) item;
|
||||
return saveContextLink(processItem.getProcess().getContext(), item);
|
||||
} else if (item instanceof JobletProcessItem) {
|
||||
JobletProcessItem jobletItem = (JobletProcessItem) item;
|
||||
return saveContextLink(jobletItem.getJobletProcess().getContext(), item);
|
||||
} else if (item instanceof ConnectionItem) {
|
||||
ConnectionItem connectionItem = (ConnectionItem) item;
|
||||
return saveContextLink(connectionItem.getConnection(), item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private synchronized boolean saveContextLink(Connection connection, Item item) throws PersistenceException {
|
||||
boolean hasLinkFile = false;
|
||||
ItemContextLink itemContextLink = new ItemContextLink();
|
||||
itemContextLink.setItemId(item.getProperty().getId());
|
||||
if (connection.isContextMode()) {
|
||||
String contextId = connection.getContextId();
|
||||
if (StringUtils.isEmpty(contextId) || IContextParameter.BUILT_IN.equals(contextId)) {
|
||||
return hasLinkFile;
|
||||
}
|
||||
ContextLink contextLink = new ContextLink();
|
||||
contextLink.setContextName(connection.getContextName());
|
||||
contextLink.setRepoId(contextId);
|
||||
itemContextLink.getContextList().add(contextLink);
|
||||
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(contextId);
|
||||
if (contextItem != null) {
|
||||
ContextType contextType = ContextUtils.getContextTypeByName(contextItem.getContext(),
|
||||
connection.getContextName());
|
||||
if (contextType != null) {
|
||||
for (Object o : contextType.getContextParameter()) {
|
||||
if (o instanceof ContextParameterType) {
|
||||
ContextParameterType contextParameterType = (ContextParameterType) o;
|
||||
ContextParamLink contextParamLink = new ContextParamLink();
|
||||
contextParamLink.setName(contextParameterType.getName());
|
||||
contextParamLink.setId(ResourceHelper.getUUID(contextParameterType));
|
||||
contextLink.getParameterList().add(contextParamLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemContextLink.getContextList().size() > 0) {
|
||||
saveContextLinkToJson(item, itemContextLink);
|
||||
hasLinkFile = true;
|
||||
} else {
|
||||
deleteContextLinkJsonFile(item);
|
||||
}
|
||||
return hasLinkFile;
|
||||
}
|
||||
|
||||
public synchronized boolean saveContextLink(List<ContextType> contextTypeList, Item item) throws PersistenceException {
|
||||
boolean hasLinkFile = false;
|
||||
String itemId = item.getProperty().getId();
|
||||
ItemContextLink itemContextLink = new ItemContextLink();
|
||||
itemContextLink.setItemId(itemId);
|
||||
Map<String, Item> tempCache = new HashMap<String, Item>();
|
||||
if (contextTypeList != null && contextTypeList.size() > 0) {
|
||||
ItemContextLink backupContextLink = this.loadContextLinkFromJson(item);
|
||||
for (Object object : contextTypeList) {
|
||||
if (object instanceof ContextType) {
|
||||
ContextType jobContextType = (ContextType) object;
|
||||
for (Object o : jobContextType.getContextParameter()) {
|
||||
if (o instanceof ContextParameterType) {
|
||||
ContextParameterType contextParameterType = (ContextParameterType) o;
|
||||
String repositoryContextId = contextParameterType.getRepositoryContextId();
|
||||
if (StringUtils.isEmpty(repositoryContextId)
|
||||
|| IContextParameter.BUILT_IN.equals(repositoryContextId)) {
|
||||
ContextLink contextLink = itemContextLink.findContextLink(item.getProperty().getId(),
|
||||
jobContextType.getName());
|
||||
if (contextLink == null) {
|
||||
contextLink = new ContextLink();
|
||||
contextLink.setContextName(jobContextType.getName());
|
||||
contextLink.setRepoId(itemId);
|
||||
itemContextLink.getContextList().add(contextLink);
|
||||
}
|
||||
ContextParamLink contextParamLink = createParamLink(itemId, jobContextType.getName(),
|
||||
contextParameterType.getName(), contextParameterType.getInternalId(), tempCache,
|
||||
backupContextLink);
|
||||
contextLink.getParameterList().add(contextParamLink);
|
||||
} else {
|
||||
ContextLink contextLink = itemContextLink
|
||||
.findContextLink(contextParameterType.getRepositoryContextId(), jobContextType.getName());
|
||||
if (contextLink == null) {
|
||||
contextLink = new ContextLink();
|
||||
contextLink.setContextName(jobContextType.getName());
|
||||
contextLink.setRepoId(repositoryContextId);
|
||||
itemContextLink.getContextList().add(contextLink);
|
||||
}
|
||||
ContextParamLink contextParamLink = createParamLink(repositoryContextId, jobContextType.getName(),
|
||||
contextParameterType.getName(), contextParameterType.getInternalId(), tempCache,
|
||||
backupContextLink);
|
||||
contextLink.getParameterList().add(contextParamLink);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemContextLink.getContextList().size() > 0) {
|
||||
saveContextLinkToJson(item, itemContextLink);
|
||||
hasLinkFile = true;
|
||||
} else {
|
||||
deleteContextLinkJsonFile(item);
|
||||
}
|
||||
return hasLinkFile;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private ContextParamLink createParamLink(String repositoryContextId, String contextName, String paramName, String internalId,
|
||||
Map<String, Item> tempCache, ItemContextLink oldContextLink) {
|
||||
ContextParamLink contextParamLink = new ContextParamLink();
|
||||
contextParamLink.setName(paramName);
|
||||
contextParamLink.setId(internalId);
|
||||
Item contextItem = tempCache.get(repositoryContextId);
|
||||
if (contextItem == null) {
|
||||
contextItem = ContextUtils.getRepositoryContextItemById(repositoryContextId);
|
||||
tempCache.put(repositoryContextId, contextItem);
|
||||
}
|
||||
if (contextItem != null) {
|
||||
ContextType contextType = ContextUtils.getContextTypeByName(contextItem, contextName);
|
||||
ContextParameterType repoContextParameterType = ContextUtils.getContextParameterTypeByName(contextType, paramName);
|
||||
String uuID = null;
|
||||
if(repoContextParameterType != null) {
|
||||
if (contextItem instanceof ContextItem) {
|
||||
uuID = ResourceHelper.getUUID(repoContextParameterType);
|
||||
} else if (repoContextParameterType.getInternalId() != null) {
|
||||
uuID = repoContextParameterType.getInternalId();
|
||||
}
|
||||
}
|
||||
if (repoContextParameterType == null && oldContextLink != null) {
|
||||
ContextParamLink oldParamLink = oldContextLink.findContextParamLinkByName(repositoryContextId, contextName,
|
||||
paramName);
|
||||
if (oldParamLink != null) {
|
||||
uuID = oldParamLink.getId();
|
||||
}
|
||||
}
|
||||
contextParamLink.setId(uuID);
|
||||
}
|
||||
return contextParamLink;
|
||||
}
|
||||
|
||||
private synchronized void saveContextLinkToJson(Item item, ItemContextLink itemContextLink) throws PersistenceException {
|
||||
IFolder linksFolder = getLinksFolder(getItemProjectLabel(item));
|
||||
if (!linksFolder.exists()) {
|
||||
ResourceUtils.createFolder(linksFolder);
|
||||
}
|
||||
IFile linkFile = calContextLinkFile(item);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
String content = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(itemContextLink);
|
||||
if (!linkFile.exists()) {
|
||||
ResourceUtils.createFile(new ByteArrayInputStream(content.getBytes()), linkFile);
|
||||
} else {
|
||||
ResourceUtils.setFileContent(new ByteArrayInputStream(content.getBytes()), linkFile);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean changeRepositoryId(Item item, Map<String, String> old2NewMap) throws PersistenceException {
|
||||
boolean isModofied = false;
|
||||
ItemContextLink itemContextLink = loadContextLinkFromJson(item);
|
||||
if (itemContextLink != null) {
|
||||
for (ContextLink contextLink : itemContextLink.getContextList()) {
|
||||
if (old2NewMap.containsKey(contextLink.getRepoId())) {
|
||||
contextLink.setRepoId(old2NewMap.get(contextLink.getRepoId()));
|
||||
isModofied = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isModofied) {
|
||||
this.saveContextLinkToJson(item, itemContextLink);
|
||||
}
|
||||
return isModofied;
|
||||
}
|
||||
|
||||
public synchronized ItemContextLink loadContextLinkFromJson(Item item) throws PersistenceException {
|
||||
for (IItemContextLinkService service : registeredService) {
|
||||
if (service.accept(item)) {
|
||||
return service.loadItemLink(item);
|
||||
}
|
||||
}
|
||||
return doLoadContextLinkFromJson(item);
|
||||
}
|
||||
|
||||
public synchronized ItemContextLink doLoadContextLinkFromJson(Item item) throws PersistenceException {
|
||||
IFile linkFile = calContextLinkFile(item);
|
||||
return doLoadContextLinkFromFile(linkFile);
|
||||
}
|
||||
|
||||
public synchronized ItemContextLink doLoadContextLinkFromJson(String projectLabel, String id) throws PersistenceException {
|
||||
IFile linkFile = calContextLinkFile(projectLabel, id);
|
||||
return doLoadContextLinkFromFile(linkFile);
|
||||
}
|
||||
|
||||
public synchronized ItemContextLink doLoadContextLinkFromFile(IFile linkFile) throws PersistenceException {
|
||||
if (linkFile == null || !linkFile.exists()) {
|
||||
return null;
|
||||
}
|
||||
ItemContextLink contextLink = null;
|
||||
try {
|
||||
contextLink = new ObjectMapper().readValue(linkFile.getLocation().toFile(), ItemContextLink.class);
|
||||
} catch (IOException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
return contextLink;
|
||||
}
|
||||
|
||||
public synchronized void deleteContextLinkJsonFile(Item item) throws PersistenceException {
|
||||
IFile linkFile = calContextLinkFile(item);
|
||||
if (linkFile != null && linkFile.exists()) {
|
||||
try {
|
||||
linkFile.delete(true, null);
|
||||
} catch (CoreException e) {
|
||||
throw new PersistenceException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IFile calContextLinkFile(Item item) throws PersistenceException {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
IFolder linksFolder = getLinksFolder(getItemProjectLabel(item));
|
||||
return linksFolder.getFile(calLinkFileName(item.getProperty().getId()));
|
||||
}
|
||||
|
||||
public static IFile calContextLinkFile(String projectLabel, String itemId) throws PersistenceException {
|
||||
if (projectLabel == null || itemId == null) {
|
||||
return null;
|
||||
}
|
||||
IFolder linksFolder = getLinksFolder(projectLabel);
|
||||
return linksFolder.getFile(calLinkFileName(itemId));
|
||||
}
|
||||
|
||||
public static String getItemProjectLabel(Item item) {
|
||||
Project project = ProjectManager.getInstance().getProject(item);
|
||||
if (project != null) {
|
||||
return project.getTechnicalLabel();
|
||||
}
|
||||
return CURRENT_PROJECT_LABEL;
|
||||
}
|
||||
|
||||
private static String calLinkFileName(String id) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(id).append(LINK_FILE_POSTFIX);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static IFile calLinksFile(IFolder projectFolder, String id) {
|
||||
IFolder settingFolder = projectFolder.getFolder(RepositoryConstants.SETTING_DIRECTORY);
|
||||
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
|
||||
return linksFolder.getFile(getLinkFileName(id));
|
||||
}
|
||||
|
||||
public static String calLinksFilePath(String projectPath, String id) {
|
||||
StringBuilder sb = new StringBuilder(projectPath);
|
||||
sb.append(File.separator).append(RepositoryConstants.SETTING_DIRECTORY);
|
||||
sb.append(File.separator).append(LINKS_FOLDER_NAME);
|
||||
sb.append(File.separator).append(getLinkFileName(id));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static IFile calLinksFile(IProject project, String id) {
|
||||
IFolder settingFolder = project.getFolder(RepositoryConstants.SETTING_DIRECTORY);
|
||||
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
|
||||
return linksFolder.getFile(getLinkFileName(id));
|
||||
}
|
||||
|
||||
public static String getLinkFileName(String id) {
|
||||
return id + LINK_FILE_POSTFIX;
|
||||
}
|
||||
|
||||
private static IFolder getLinksFolder(String projectLabel) throws PersistenceException {
|
||||
IProject iProject = ResourceUtils.getProject(projectLabel);
|
||||
IFolder settingFolder = iProject.getFolder(RepositoryConstants.SETTING_DIRECTORY);
|
||||
IFolder linksFolder = settingFolder.getFolder(LINKS_FOLDER_NAME);
|
||||
return linksFolder;
|
||||
}
|
||||
|
||||
private static void initService() {
|
||||
IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CREATOR_EXT_ID);
|
||||
if (extensionPoint != null) {
|
||||
IExtension[] extensions = extensionPoint.getExtensions();
|
||||
for (IExtension extension : extensions) {
|
||||
IConfigurationElement[] configurationElements = extension.getConfigurationElements();
|
||||
for (IConfigurationElement configurationElement : configurationElements) {
|
||||
try {
|
||||
Object creator = configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
|
||||
if (creator instanceof IItemContextLinkService) {
|
||||
IItemContextLinkService service = (IItemContextLinkService) creator;
|
||||
registeredService.add(service);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.model.context.link;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ContextParamLink {
|
||||
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ContextParamLink cloneObj() {
|
||||
ContextParamLink obj = new ContextParamLink();
|
||||
obj.setId(id);
|
||||
obj.setName(name);
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.model.context.link;
|
||||
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.properties.Item;
|
||||
|
||||
public interface IItemContextLinkService {
|
||||
|
||||
boolean accept(Item item);
|
||||
|
||||
boolean saveItemLink(Item item) throws PersistenceException;
|
||||
|
||||
ItemContextLink loadItemLink(Item item) throws PersistenceException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.model.context.link;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class ItemContextLink {
|
||||
|
||||
@JsonProperty("itemId")
|
||||
private String itemId;
|
||||
|
||||
@JsonProperty("contextList")
|
||||
private List<ContextLink> contextList = new ArrayList<ContextLink>();
|
||||
|
||||
public String getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(String itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public List<ContextLink> getContextList() {
|
||||
return contextList;
|
||||
}
|
||||
|
||||
public void setContextList(List<ContextLink> contextList) {
|
||||
this.contextList = contextList;
|
||||
}
|
||||
|
||||
public ContextParamLink findContextParamLinkByName(String repoContextId, String contextName, String paramName) {
|
||||
ContextLink contextLink = findContextLink(repoContextId, contextName);
|
||||
if (contextLink != null) {
|
||||
return contextLink.getParamLinkByName(paramName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContextParamLink findContextParamLinkById(String repoContextId, String contextName, String paramId) {
|
||||
ContextLink contextLink = findContextLink(repoContextId, contextName);
|
||||
if (contextLink != null) {
|
||||
return contextLink.getParamLinkById(paramId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ContextLink findContextLink(String repoContextId, String contextName) {
|
||||
for (ContextLink contextLink : contextList) {
|
||||
if ((repoContextId == null || StringUtils.equals(repoContextId, contextLink.getRepoId()))
|
||||
&& StringUtils.equals(contextName, contextLink.getContextName())) {
|
||||
return contextLink;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemContextLink cloneObj() {
|
||||
ItemContextLink obj = new ItemContextLink();
|
||||
obj.setItemId(itemId);
|
||||
for (ContextLink c : contextList) {
|
||||
obj.getContextList().add(c.cloneObj());
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@ import org.talend.core.model.repository.DragAndDropManager;
|
||||
import org.talend.core.model.update.UpdatesConstants;
|
||||
import org.talend.core.model.utils.IDragAndDropServiceHandler;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.core.runtime.services.IGenericWizardService;
|
||||
import org.talend.core.service.IMetadataManagmentService;
|
||||
import org.talend.core.service.IMetadataManagmentUiService;
|
||||
import org.talend.core.utils.KeywordsValidator;
|
||||
@@ -155,12 +156,12 @@ public class RepositoryToComponentProperty {
|
||||
return getEDIFACTSchemaValue((EDIFACTConnection) connection, value);
|
||||
}
|
||||
|
||||
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
|
||||
if (handler.canHandle(connection)) {
|
||||
return handler.getComponentValue(connection, value, table, targetComponent, contextMap);
|
||||
}
|
||||
// Special for Javajet components: tSalesforceEinsteinBulkExec/tSalesforceEinsteinOutputBulkExec
|
||||
if (targetComponent != null && targetComponent.startsWith("tSalesforceEinstein")) { //$NON-NLS-1$
|
||||
return getSpecialGenericValue(connection, value, table, targetComponent, contextMap);
|
||||
}
|
||||
return null;
|
||||
|
||||
return getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -213,8 +214,7 @@ public class RepositoryToComponentProperty {
|
||||
return;
|
||||
}
|
||||
SAPFunctionUnit unit = null;
|
||||
for (int i = 0; i < conn.getFuntions().size(); i++) {
|
||||
SAPFunctionUnit tmp = conn.getFuntions().get(i);
|
||||
for (SAPFunctionUnit tmp : conn.getFuntions()) {
|
||||
if (tmp.getLabel().equals(functionLabel)) {
|
||||
unit = tmp;
|
||||
break;
|
||||
@@ -230,9 +230,8 @@ public class RepositoryToComponentProperty {
|
||||
if (isInput) {
|
||||
mergeColumn(table, table.getChildren(), value2);
|
||||
} else {
|
||||
for (int i = 0; i < table.getChildren().size(); i++) {
|
||||
for (SAPFunctionParameter column : table.getChildren()) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
SAPFunctionParameter column = table.getChildren().get(i);
|
||||
// this part maybe no use , didn't find OUTPUT_PARAMS in sap component
|
||||
map.put("SAP_PARAMETER_TYPE", column.getType().replace('.', '_')); //$NON-NLS-1$
|
||||
map.put("SAP_TABLE_NAME", TalendQuoteUtils.addQuotes("")); //$NON-NLS-1$
|
||||
@@ -298,8 +297,8 @@ public class RepositoryToComponentProperty {
|
||||
if (conn == null) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < conn.getFuntions().size(); i++) {
|
||||
unit = conn.getFuntions().get(i);
|
||||
for (SAPFunctionUnit element : conn.getFuntions()) {
|
||||
unit = element;
|
||||
if (unit.getLabel().equals(functionLabel)) {
|
||||
break;
|
||||
}
|
||||
@@ -626,6 +625,50 @@ public class RepositoryToComponentProperty {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Object getSpecialGenericValue(Connection connection, String value, IMetadataTable table,
|
||||
String targetComponent,
|
||||
Map<Object, Object> contextMap) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
|
||||
IGenericWizardService wizardService = GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
|
||||
if (wizardService != null && wizardService.isGenericConnection(connection)) {
|
||||
if (value != null) {
|
||||
if ("ENDPOINT".equals(value)) { //$NON-NLS-1$
|
||||
value = "connection.endpoint"; //$NON-NLS-1$
|
||||
} else if ("USER_NAME".equals(value)) { //$NON-NLS-1$
|
||||
value = "connection.userPassword.userId"; //$NON-NLS-1$
|
||||
} else if ("PASSWORD".equals(value)) { //$NON-NLS-1$
|
||||
// salesforce javajet component:pwd = pwd + token
|
||||
value = "connection.userPassword.password"; //$NON-NLS-1$
|
||||
Object password = getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
|
||||
String skValue = "connection.userPassword.securityKey"; //$NON-NLS-1$
|
||||
Object securityKey = getHandlerComponentValue(connection, skValue, table, targetComponent, contextMap);
|
||||
if (securityKey != null) {
|
||||
if (isContextMode(connection, String.valueOf(password))) {
|
||||
return String.valueOf(password) + "+" + String.valueOf(securityKey); //$NON-NLS-1$
|
||||
} else {
|
||||
return TalendQuoteUtils.addQuotes(TalendQuoteUtils.removeQuotesIfExist(String.valueOf(password))
|
||||
+ TalendQuoteUtils.removeQuotesIfExist(String.valueOf(securityKey)));
|
||||
}
|
||||
}
|
||||
return password;
|
||||
}
|
||||
return getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Object getHandlerComponentValue(Connection connection, String value, IMetadataTable table,
|
||||
String targetComponent, Map<Object, Object> contextMap) {
|
||||
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
|
||||
if (handler.canHandle(connection)) {
|
||||
return handler.getComponentValue(connection, value, table, targetComponent, contextMap);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static SalesforceModuleUnit getSaleforceModuleUnitByTable(IMetadataTable table,
|
||||
EList<SalesforceModuleUnit> moduleList) {
|
||||
for (SalesforceModuleUnit unit : moduleList) {
|
||||
@@ -746,9 +789,9 @@ public class RepositoryToComponentProperty {
|
||||
|
||||
public static List<Map<String, String>> getOutputWSDLValue(EList list) {
|
||||
List<Map<String, String>> newList = new ArrayList<Map<String, String>>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
for (Object element : list) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
WSDLParameter node = (WSDLParameter) list.get(i);
|
||||
WSDLParameter node = (WSDLParameter) element;
|
||||
map.put("EXPRESSION", node.getExpression());
|
||||
map.put("COLUMN", node.getColumn());
|
||||
map.put("SOURCE", node.getSource());
|
||||
@@ -1003,8 +1046,9 @@ public class RepositoryToComponentProperty {
|
||||
} else {
|
||||
String version = connection.getDbVersionString();
|
||||
if (EDatabaseVersion4Drivers.ORACLE_18.name().equals(version)) {
|
||||
if (StringUtils.equals(CDCTypeMode.LOG_MODE.getName(), connection.getCdcTypeMode()))
|
||||
if (StringUtils.equals(CDCTypeMode.LOG_MODE.getName(), connection.getCdcTypeMode())) {
|
||||
return CDCTypeMode.LOG_UNSUPPORTED_MODE.getName();
|
||||
}
|
||||
}
|
||||
return connection.getCdcTypeMode();
|
||||
}
|
||||
@@ -1493,7 +1537,7 @@ public class RepositoryToComponentProperty {
|
||||
String clusterID = connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
|
||||
if (clusterID != null) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
|
||||
IHadoopClusterService hadoopClusterService = (IHadoopClusterService) GlobalServiceRegister.getDefault()
|
||||
IHadoopClusterService hadoopClusterService = GlobalServiceRegister.getDefault()
|
||||
.getService(IHadoopClusterService.class);
|
||||
Map<String, String> hadoopCustomLibraries = hadoopClusterService.getHadoopCustomLibraries(clusterID);
|
||||
|
||||
@@ -1746,7 +1790,7 @@ public class RepositoryToComponentProperty {
|
||||
private static boolean isContextMode(Connection connection, String value) {
|
||||
IMetadataManagmentUiService mmService = null;
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentUiService.class)) {
|
||||
mmService = (IMetadataManagmentUiService) GlobalServiceRegister.getDefault()
|
||||
mmService = GlobalServiceRegister.getDefault()
|
||||
.getService(IMetadataManagmentUiService.class);
|
||||
}
|
||||
if (mmService != null) {
|
||||
@@ -2033,7 +2077,7 @@ public class RepositoryToComponentProperty {
|
||||
Path p = new Path(connection.getXmlFilePath());
|
||||
if ((p.toPortableString()).endsWith("xsd")) { //$NON-NLS-1$
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentUiService.class)) {
|
||||
IMetadataManagmentUiService mmUIService = (IMetadataManagmentUiService) GlobalServiceRegister.getDefault()
|
||||
IMetadataManagmentUiService mmUIService = GlobalServiceRegister.getDefault()
|
||||
.getService(IMetadataManagmentUiService.class);
|
||||
String newPath = mmUIService.getAndOpenXSDFileDialog(p);
|
||||
if (newPath != null) {
|
||||
@@ -2153,9 +2197,9 @@ public class RepositoryToComponentProperty {
|
||||
|
||||
public static List<Map<String, String>> getOutputXmlValue(EList list) {
|
||||
List<Map<String, String>> newList = new ArrayList<Map<String, String>>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
for (Object element : list) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
XMLFileNode node = (XMLFileNode) list.get(i);
|
||||
XMLFileNode node = (XMLFileNode) element;
|
||||
String defaultValue = node.getDefaultValue();
|
||||
if (defaultValue == null) {
|
||||
defaultValue = ""; //$NON-NLS-1$
|
||||
@@ -2399,7 +2443,7 @@ public class RepositoryToComponentProperty {
|
||||
|
||||
} else {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentService.class)) {
|
||||
IMetadataManagmentService mmService = (IMetadataManagmentService) GlobalServiceRegister.getDefault()
|
||||
IMetadataManagmentService mmService = GlobalServiceRegister.getDefault()
|
||||
.getService(IMetadataManagmentService.class);
|
||||
IMetadataTable convert = mmService.convertMetadataTable(repTable);
|
||||
String uinqueTableName = node.getProcess()
|
||||
@@ -2654,8 +2698,7 @@ public class RepositoryToComponentProperty {
|
||||
boolean foundColumn = false;
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("QUERY", null); //$NON-NLS-1$
|
||||
for (int i = 0; i < schemaTargets.size(); i++) {
|
||||
SchemaTarget sch = schemaTargets.get(i);
|
||||
for (SchemaTarget sch : schemaTargets) {
|
||||
if (col.getLabel().equals(sch.getTagName())) {
|
||||
// map.put("SCHEMA_COLUMN", sch.getTagName());
|
||||
foundColumn = true;
|
||||
@@ -2664,8 +2707,7 @@ public class RepositoryToComponentProperty {
|
||||
}
|
||||
if (!foundColumn && colRenameMap != null && !colRenameMap.isEmpty()) {
|
||||
Set<String> newNameSet = colRenameMap.keySet();
|
||||
for (int i = 0; i < schemaTargets.size(); i++) {
|
||||
SchemaTarget sch = schemaTargets.get(i);
|
||||
for (SchemaTarget sch : schemaTargets) {
|
||||
if (newNameSet.contains(sch.getTagName())) {
|
||||
String oldColLabel = colRenameMap.get(sch.getTagName());
|
||||
if (col.getLabel().equals(oldColLabel)) {
|
||||
@@ -2724,8 +2766,7 @@ public class RepositoryToComponentProperty {
|
||||
for (IMetadataColumn col : metadataTable.getListColumns()) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("QUERY", null); //$NON-NLS-1$
|
||||
for (int i = 0; i < conceptTargets.size(); i++) {
|
||||
ConceptTarget cpt = conceptTargets.get(i);
|
||||
for (ConceptTarget cpt : conceptTargets) {
|
||||
if (col.getLabel().equals(cpt.getTargetName())) {
|
||||
// map.put("SCHEMA_COLUMN", sch.getTagName());
|
||||
map.put("QUERY", TalendQuoteUtils.addQuotes(cpt.getRelativeLoopExpression())); //$NON-NLS-1$
|
||||
|
||||
@@ -44,6 +44,8 @@ public interface IContextManager {
|
||||
|
||||
public void saveToEmf(EList contextTypeList);
|
||||
|
||||
public void saveToEmf(EList contextTypeList, boolean useInternalId);
|
||||
|
||||
public void loadFromEmf(EList contextTypeList, String defaultContextName);
|
||||
|
||||
public boolean sameAs(IContextManager contextManager);
|
||||
|
||||
@@ -71,4 +71,8 @@ public interface IContextParameter {
|
||||
public void setSource(final String sourceName);
|
||||
|
||||
public boolean isBuiltIn();
|
||||
|
||||
public String getInternalId();
|
||||
|
||||
public void setInternalId(String internalId);
|
||||
}
|
||||
|
||||
@@ -426,6 +426,11 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
*/
|
||||
public final static ERepositoryObjectType JOBLET = ERepositoryObjectType.valueOf("JOBLET"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* <font color="red">This value may be <b>null</b> in some products, <b>should add NPE check</b></font>
|
||||
*/
|
||||
public final static ERepositoryObjectType SERVICES = ERepositoryObjectType.valueOf("SERVICES"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType JOBLET_DESIGNS = ERepositoryObjectType.valueOf("JOBLET_DESIGNS"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType SPARK_JOBLET = ERepositoryObjectType.valueOf("SPARK_JOBLET"); //$NON-NLS-1$
|
||||
@@ -438,6 +443,8 @@ public class ERepositoryObjectType extends DynaEnum<ERepositoryObjectType> {
|
||||
|
||||
public final static ERepositoryObjectType ROUTINES = ERepositoryObjectType.valueOf("ROUTINES"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType BEANS = ERepositoryObjectType.valueOf("BEANS"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType METADATA_HEADER_FOOTER = ERepositoryObjectType.valueOf("METADATA_HEADER_FOOTER"); //$NON-NLS-1$
|
||||
|
||||
public final static ERepositoryObjectType JOB_SCRIPT = ERepositoryObjectType.valueOf("JOB_SCRIPT"); //$NON-NLS-1$
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.model.update;
|
||||
|
||||
import org.talend.core.AbstractRepositoryContextUpdateService;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
|
||||
public class GenericDbContextUpdateService extends AbstractRepositoryContextUpdateService {
|
||||
|
||||
IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
|
||||
|
||||
@Override
|
||||
public boolean accept(Connection connection) {
|
||||
return connection.getCompProperties() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
|
||||
return updateCompPropertiesContextParameter(conn, oldValue, newValue);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,427 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.model.update;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.talend.core.AbstractRepositoryContextUpdateService;
|
||||
import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.database.conn.template.EDatabaseConnTemplate;
|
||||
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
|
||||
import org.talend.core.model.metadata.builder.connection.AdditionalConnectionProperty;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.DelimitedFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.FileExcelConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.LdifFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.PositionalFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.RegexpFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.SAPConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.XmlXPathLoopDescriptor;
|
||||
|
||||
public class RepositoryContextUpdateService extends AbstractRepositoryContextUpdateService {
|
||||
|
||||
@Override
|
||||
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (conn.isContextMode()) {
|
||||
if (conn instanceof DatabaseConnection) {
|
||||
return updateDatabaseConnectinParam((DatabaseConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof FileExcelConnection) {
|
||||
return updateFileExcelConnectionParam((FileExcelConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof DelimitedFileConnection) {
|
||||
return updatDelimitedFileConnectionParam((DelimitedFileConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof RegexpFileConnection) {
|
||||
return updateRegexpFileConnectionParam((RegexpFileConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof LdifFileConnection) {
|
||||
return updateLdifFileConnectionParam((LdifFileConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof PositionalFileConnection) {
|
||||
return updatePositionalFileConnectionParam((PositionalFileConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof XmlFileConnection) {
|
||||
return updateXmlFileConnectionParam((XmlFileConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof SalesforceSchemaConnection) {
|
||||
return updateSalesforceSchemaConnectionParam((SalesforceSchemaConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof WSDLSchemaConnection) {
|
||||
return updateWSDLSchemaConnectionParam((WSDLSchemaConnection) conn, oldValue, newValue);
|
||||
}
|
||||
if (conn instanceof SAPConnection) {
|
||||
return updateSAPConnectionParam((SAPConnection) conn, oldValue, newValue);
|
||||
}
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updateParameters(DatabaseConnection dbConn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
EMap<String, String> parameters = dbConn.getParameters();
|
||||
if (parameters != null && !parameters.isEmpty()) {
|
||||
for (Entry<String, String> entry : parameters.entrySet()) {
|
||||
if (entry != null) {
|
||||
String value = entry.getValue();
|
||||
if (StringUtils.equals(value, oldValue)) {
|
||||
entry.setValue(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean hadoopUpdateResult = updateHadoopPropertiesForDbConnection(dbConn, oldValue, newValue);
|
||||
return isModified || hadoopUpdateResult;
|
||||
}
|
||||
|
||||
private boolean updateHadoopPropertiesForDbConnection(DatabaseConnection dbConn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
EMap<String, String> parameters = dbConn.getParameters();
|
||||
String databaseType = parameters.get(ConnParameterKeys.CONN_PARA_KEY_DB_TYPE);
|
||||
String hadoopProperties = "";
|
||||
if (databaseType != null) {
|
||||
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
|
||||
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES);
|
||||
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
|
||||
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES);
|
||||
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
|
||||
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES);
|
||||
}
|
||||
List<Map<String, Object>> hadoopPropertiesList = HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties);
|
||||
if (!hadoopPropertiesList.isEmpty()) {
|
||||
for (Map<String, Object> propertyMap : hadoopPropertiesList) {
|
||||
String propertyValue = (String) propertyMap.get("VALUE");
|
||||
if (propertyValue.equals(oldValue)) {
|
||||
propertyMap.put("VALUE", newValue);
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
String hadoopPropertiesJson = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopPropertiesList);
|
||||
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
|
||||
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES, hadoopPropertiesJson);
|
||||
isModified = true;
|
||||
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
|
||||
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES, hadoopPropertiesJson);
|
||||
isModified = true;
|
||||
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
|
||||
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES, hadoopPropertiesJson);
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updateDatabaseConnectinParam(DatabaseConnection dbConn, String oldValue, String newValue) {
|
||||
boolean compPropertiesResult = updateCompPropertiesContextParameter(dbConn, oldValue, newValue);
|
||||
boolean isModified = false;
|
||||
if (dbConn.getAdditionalParams() != null && dbConn.getAdditionalParams().equals(oldValue)) {
|
||||
dbConn.setAdditionalParams(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getUsername() != null && dbConn.getUsername().equals(oldValue)) {
|
||||
dbConn.setUsername(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
|
||||
dbConn.setPassword(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getServerName() != null && dbConn.getServerName().equals(oldValue)) {
|
||||
dbConn.setServerName(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getPort() != null && dbConn.getPort().equals(oldValue)) {
|
||||
dbConn.setPort(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getSID() != null && dbConn.getSID().equals(oldValue)) {
|
||||
dbConn.setSID(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getDbmsId() != null && dbConn.getDbmsId().equals(oldValue)) {
|
||||
dbConn.setDbmsId(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getDriverClass() != null && dbConn.getDriverClass().equals(oldValue)) {
|
||||
dbConn.setDriverClass(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getDriverJarPath() != null && dbConn.getDriverJarPath().equals(oldValue)) {
|
||||
dbConn.setDriverJarPath(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getURL() != null && dbConn.getURL().equals(oldValue)) {
|
||||
dbConn.setURL(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getUiSchema() != null && dbConn.getUiSchema().equals(oldValue)) {
|
||||
// Added by Marvin Wang on Nov.7, 2012 for bug TDI-12596, because schema can not
|
||||
// be
|
||||
// propagated to metadata db.
|
||||
dbConn.setUiSchema(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getDatasourceName() != null && dbConn.getDatasourceName().equals(oldValue)) {
|
||||
dbConn.setDatasourceName(newValue);
|
||||
isModified = true;
|
||||
} else {
|
||||
isModified = updateParameters(dbConn, oldValue, newValue);
|
||||
}
|
||||
return isModified || compPropertiesResult;
|
||||
}
|
||||
|
||||
private boolean updateFileExcelConnectionParam(FileExcelConnection conn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (conn.getFirstColumn() != null && conn.getFirstColumn().equals(oldValue)) {
|
||||
conn.setFirstColumn(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getLastColumn() != null && conn.getLastColumn().equals(oldValue)) {
|
||||
conn.setLastColumn(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getThousandSeparator() != null && conn.getThousandSeparator().equals(oldValue)) {
|
||||
conn.setThousandSeparator(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getDecimalSeparator() != null && conn.getDecimalSeparator().equals(oldValue)) {
|
||||
conn.setDecimalSeparator(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
|
||||
conn.setFilePath(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
|
||||
conn.setEncoding(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
|
||||
conn.setLimitValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
|
||||
conn.setHeaderValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
|
||||
conn.setFooterValue(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updatDelimitedFileConnectionParam(DelimitedFileConnection conn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
|
||||
conn.setFilePath(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
|
||||
conn.setEncoding(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
|
||||
conn.setLimitValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
|
||||
conn.setHeaderValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
|
||||
conn.setFooterValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getRowSeparatorValue() != null && conn.getRowSeparatorValue().equals(oldValue)) {
|
||||
conn.setRowSeparatorValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getFieldSeparatorValue() != null && conn.getFieldSeparatorValue().equals(oldValue)) {
|
||||
conn.setFieldSeparatorValue(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updateRegexpFileConnectionParam(RegexpFileConnection conn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
|
||||
conn.setFilePath(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getEncoding() != null && conn.getEncoding().equals(oldValue)) {
|
||||
conn.setEncoding(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getLimitValue() != null && conn.getLimitValue().equals(oldValue)) {
|
||||
conn.setLimitValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getHeaderValue() != null && conn.getHeaderValue().equals(oldValue)) {
|
||||
conn.setHeaderValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getFooterValue() != null && conn.getFooterValue().equals(oldValue)) {
|
||||
conn.setFooterValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getRowSeparatorValue() != null && conn.getRowSeparatorValue().equals(oldValue)) {
|
||||
conn.setRowSeparatorValue(newValue);
|
||||
isModified = true;
|
||||
} else if (conn.getFieldSeparatorValue() != null && conn.getFieldSeparatorValue().equals(oldValue)) {
|
||||
conn.setFieldSeparatorValue(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updateLdifFileConnectionParam(LdifFileConnection conn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (conn.getFilePath() != null && conn.getFilePath().equals(oldValue)) {
|
||||
conn.setFilePath(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updatePositionalFileConnectionParam(PositionalFileConnection dbConn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
|
||||
dbConn.setFilePath(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
|
||||
dbConn.setEncoding(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getLimitValue() != null && dbConn.getLimitValue().equals(oldValue)) {
|
||||
dbConn.setLimitValue(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getHeaderValue() != null && dbConn.getHeaderValue().equals(oldValue)) {
|
||||
dbConn.setHeaderValue(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getFooterValue() != null && dbConn.getFooterValue().equals(oldValue)) {
|
||||
dbConn.setFooterValue(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getRowSeparatorValue() != null && dbConn.getRowSeparatorValue().equals(oldValue)) {
|
||||
dbConn.setRowSeparatorValue(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getFieldSeparatorValue() != null && dbConn.getFieldSeparatorValue().equals(oldValue)) {
|
||||
dbConn.setFieldSeparatorValue(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updateXmlFileConnectionParam(XmlFileConnection dbConn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (dbConn.getXmlFilePath() != null && dbConn.getXmlFilePath().equals(oldValue)) {
|
||||
dbConn.setXmlFilePath(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
|
||||
dbConn.setEncoding(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getOutputFilePath() != null && dbConn.getOutputFilePath().equals(oldValue)) {
|
||||
dbConn.setOutputFilePath(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
EList schema = dbConn.getSchema();
|
||||
if (schema != null && schema.size() > 0) {
|
||||
if (schema.get(0) instanceof XmlXPathLoopDescriptor) {
|
||||
XmlXPathLoopDescriptor descriptor = (XmlXPathLoopDescriptor) schema.get(0);
|
||||
if (descriptor.getAbsoluteXPathQuery() != null && descriptor.getAbsoluteXPathQuery().equals(oldValue)) {
|
||||
descriptor.setAbsoluteXPathQuery(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updateSalesforceSchemaConnectionParam(SalesforceSchemaConnection ssConn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (ssConn.getWebServiceUrl() != null && ssConn.getWebServiceUrl().equals(oldValue)) {
|
||||
ssConn.setWebServiceUrl(newValue);
|
||||
isModified = true;
|
||||
} else if (ssConn.getPassword() != null && ssConn.getPassword().equals(oldValue)) {
|
||||
// in fact, because in context mode. can setPassword directly.
|
||||
// ssConn.setPassword(ssConn.getValue(newValue,true));
|
||||
ssConn.setPassword(newValue);
|
||||
isModified = true;
|
||||
} else if (ssConn.getUserName() != null && ssConn.getUserName().equals(oldValue)) {
|
||||
ssConn.setUserName(newValue);
|
||||
isModified = true;
|
||||
} else if (ssConn.getTimeOut() != null && ssConn.getTimeOut().equals(oldValue)) {
|
||||
ssConn.setTimeOut(newValue);
|
||||
isModified = true;
|
||||
} else if (ssConn.getBatchSize() != null && ssConn.getBatchSize().equals(oldValue)) {
|
||||
ssConn.setBatchSize(newValue);
|
||||
isModified = true;
|
||||
} else if (ssConn.getQueryCondition() != null && ssConn.getQueryCondition().equals(oldValue)) {
|
||||
ssConn.setQueryCondition(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updateWSDLSchemaConnectionParam(WSDLSchemaConnection dbConn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (dbConn.getUserName() != null && dbConn.getUserName().equals(oldValue)) {
|
||||
dbConn.setUserName(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
|
||||
dbConn.setPassword(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getProxyHost() != null && dbConn.getProxyHost().equals(oldValue)) {
|
||||
dbConn.setProxyHost(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getProxyPassword() != null && dbConn.getProxyPassword().equals(oldValue)) {
|
||||
dbConn.setProxyPassword(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getProxyUser() != null && dbConn.getProxyUser().equals(oldValue)) {
|
||||
dbConn.setProxyUser(newValue);
|
||||
isModified = true;
|
||||
} else if (dbConn.getProxyPort() != null && dbConn.getProxyPort().equals(oldValue)) {
|
||||
dbConn.setProxyPort(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
private boolean updateSAPConnectionParam(SAPConnection sapConn, String oldValue, String newValue) {
|
||||
boolean isModified = false;
|
||||
if (sapConn.getClient() != null && sapConn.getClient().equals(oldValue)) {
|
||||
sapConn.setClient(newValue);
|
||||
isModified = true;
|
||||
} else if (sapConn.getUsername() != null && sapConn.getUsername().equals(oldValue)) {
|
||||
sapConn.setUsername(newValue);
|
||||
isModified = true;
|
||||
} else if (sapConn.getPassword() != null && sapConn.getPassword().equals(oldValue)) {
|
||||
sapConn.setPassword(newValue);
|
||||
isModified = true;
|
||||
} else if (sapConn.getHost() != null && sapConn.getHost().equals(oldValue)) {
|
||||
sapConn.setHost(newValue);
|
||||
isModified = true;
|
||||
} else if (sapConn.getSystemNumber() != null && sapConn.getSystemNumber().equals(oldValue)) {
|
||||
sapConn.setSystemNumber(newValue);
|
||||
isModified = true;
|
||||
} else if (sapConn.getLanguage() != null && sapConn.getLanguage().equals(oldValue)) {
|
||||
sapConn.setLanguage(newValue);
|
||||
isModified = true;
|
||||
} else {
|
||||
for (AdditionalConnectionProperty sapProperty : sapConn.getAdditionalProperties()) {
|
||||
if (sapProperty.getValue() != null && sapProperty.getValue().equals(oldValue)) {
|
||||
sapProperty.setValue(newValue);
|
||||
isModified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isModified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(Connection connection) {
|
||||
if (connection instanceof DatabaseConnection || connection instanceof FileExcelConnection
|
||||
|| connection instanceof DelimitedFileConnection || connection instanceof RegexpFileConnection
|
||||
|| connection instanceof LdifFileConnection || connection instanceof PositionalFileConnection
|
||||
|| connection instanceof XmlFileConnection || connection instanceof SalesforceSchemaConnection
|
||||
|| connection instanceof WSDLSchemaConnection || connection instanceof SAPConnection) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,14 +21,12 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.eclipse.emf.common.util.EMap;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
@@ -41,11 +39,8 @@ import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.ICoreService;
|
||||
import org.talend.core.IRepositoryContextUpdateService;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.ITDQPatternService;
|
||||
import org.talend.core.ITDQRepositoryService;
|
||||
import org.talend.core.database.conn.ConnParameterKeys;
|
||||
import org.talend.core.database.conn.template.EDatabaseConnTemplate;
|
||||
import org.talend.core.hadoop.BigDataBasicUtil;
|
||||
import org.talend.core.hadoop.HadoopConstants;
|
||||
import org.talend.core.hadoop.IHadoopClusterService;
|
||||
@@ -54,28 +49,23 @@ import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.context.JobContext;
|
||||
import org.talend.core.model.context.JobContextManager;
|
||||
import org.talend.core.model.context.JobContextParameter;
|
||||
import org.talend.core.model.context.link.ContextLink;
|
||||
import org.talend.core.model.context.link.ContextLinkService;
|
||||
import org.talend.core.model.context.link.ContextParamLink;
|
||||
import org.talend.core.model.context.link.ItemContextLink;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataSchemaType;
|
||||
import org.talend.core.model.metadata.builder.connection.AdditionalConnectionProperty;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.DelimitedFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.FileExcelConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.GenericSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.LdifFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.MetadataTable;
|
||||
import org.talend.core.model.metadata.builder.connection.PositionalFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.QueriesConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.Query;
|
||||
import org.talend.core.model.metadata.builder.connection.RegexpFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.SAPConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.SAPFunctionUnit;
|
||||
import org.talend.core.model.metadata.builder.connection.SAPIDocUnit;
|
||||
import org.talend.core.model.metadata.builder.connection.SalesforceSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.WSDLSchemaConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.XmlFileConnection;
|
||||
import org.talend.core.model.metadata.builder.connection.XmlXPathLoopDescriptor;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
@@ -94,6 +84,7 @@ import org.talend.core.model.relationship.RelationshipItemBuilder;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.IRepositoryViewObject;
|
||||
import org.talend.core.model.update.extension.UpdateManagerProviderDetector;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.model.utils.UpdateRepositoryHelper;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
@@ -111,7 +102,6 @@ import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.runprocess.ItemCacheManager;
|
||||
import org.talend.repository.model.IProxyRepositoryFactory;
|
||||
import org.talend.repository.model.IProxyRepositoryService;
|
||||
import org.talend.repository.model.IRepositoryService;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
|
||||
@@ -120,6 +110,12 @@ import org.talend.repository.model.RepositoryNode;
|
||||
*/
|
||||
public abstract class RepositoryUpdateManager {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(RepositoryUpdateManager.class);
|
||||
|
||||
private static final IProxyRepositoryFactory FACTORY = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
|
||||
private static List<IRepositoryContextUpdateService> CONTEXT_UPDATE_SERVICE_LIST = null;
|
||||
|
||||
/**
|
||||
* for repository context rename.
|
||||
*/
|
||||
@@ -148,7 +144,7 @@ public abstract class RepositoryUpdateManager {
|
||||
*/
|
||||
protected Object parameter;
|
||||
|
||||
private Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
|
||||
private Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
|
||||
|
||||
private boolean onlyOpeningJob = false;
|
||||
|
||||
@@ -280,7 +276,7 @@ public abstract class RepositoryUpdateManager {
|
||||
private boolean openRenameCheckedDialog() {
|
||||
return MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),
|
||||
Messages.getString("RepositoryUpdateManager.RenameContextTitle"), //$NON-NLS-1$
|
||||
Messages.getString("RepositoryUpdateManager.RenameContextMessages")); //$NON-NLS-1$
|
||||
Messages.getString("RepositoryUpdateManager.RenameContextMessagesNoBuiltIn")); //$NON-NLS-1$
|
||||
|
||||
}
|
||||
|
||||
@@ -289,7 +285,7 @@ public abstract class RepositoryUpdateManager {
|
||||
}
|
||||
|
||||
public boolean needForcePropagation() {
|
||||
return needForcePropagationForContext() || (getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty());
|
||||
return getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty();
|
||||
}
|
||||
|
||||
private boolean needForcePropagationForContext() {
|
||||
@@ -688,484 +684,191 @@ public abstract class RepositoryUpdateManager {
|
||||
if (valueMap == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> set = valueMap.keySet();
|
||||
List<String> list = new ArrayList<String>(set);
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
boolean foundCompProperties = false;
|
||||
ConnectionItem dbConnectionItem = null;
|
||||
Map<String, String> oldToNewHM = new HashMap<String, String>();
|
||||
|
||||
for (String newValue : list) {
|
||||
String oldValue = valueMap.get(newValue);
|
||||
oldValue = "context." + oldValue;
|
||||
newValue = "context." + newValue;
|
||||
oldToNewHM.put(oldValue, newValue);
|
||||
List<IRepositoryViewObject> dbConnList = factory.getAll(ERepositoryObjectType.METADATA_CONNECTIONS, true);
|
||||
for (IRepositoryViewObject obj : dbConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof DatabaseConnection) {
|
||||
DatabaseConnection dbConn = (DatabaseConnection) conn;
|
||||
String compProperties = dbConn.getCompProperties();
|
||||
if (!foundCompProperties && StringUtils.isNotBlank(compProperties)) {
|
||||
foundCompProperties = true;
|
||||
dbConnectionItem = (ConnectionItem) item;
|
||||
}
|
||||
if (dbConn.getAdditionalParams() != null && dbConn.getAdditionalParams().equals(oldValue)) {
|
||||
dbConn.setAdditionalParams(newValue);
|
||||
} else if (dbConn.getUsername() != null && dbConn.getUsername().equals(oldValue)) {
|
||||
dbConn.setUsername(newValue);
|
||||
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
|
||||
dbConn.setPassword(newValue);
|
||||
} else if (dbConn.getServerName() != null && dbConn.getServerName().equals(oldValue)) {
|
||||
dbConn.setServerName(newValue);
|
||||
} else if (dbConn.getPort() != null && dbConn.getPort().equals(oldValue)) {
|
||||
dbConn.setPort(newValue);
|
||||
} else if (dbConn.getSID() != null && dbConn.getSID().equals(oldValue)) {
|
||||
dbConn.setSID(newValue);
|
||||
} else if (dbConn.getDbmsId() != null && dbConn.getDbmsId().equals(oldValue)) {
|
||||
dbConn.setDbmsId(newValue);
|
||||
} else if (dbConn.getDriverClass() != null && dbConn.getDriverClass().equals(oldValue)) {
|
||||
dbConn.setDriverClass(newValue);
|
||||
} else if (dbConn.getDriverJarPath() != null && dbConn.getDriverJarPath().equals(oldValue)) {
|
||||
dbConn.setDriverJarPath(newValue);
|
||||
} else if (dbConn.getURL() != null && dbConn.getURL().equals(oldValue)) {
|
||||
dbConn.setURL(newValue);
|
||||
} else if (dbConn.getUiSchema() != null && dbConn.getUiSchema().equals(oldValue)) {
|
||||
// Added by Marvin Wang on Nov.7, 2012 for bug TDI-12596, because schema can not be
|
||||
// propagated to metadata db.
|
||||
dbConn.setUiSchema(newValue);
|
||||
} else {
|
||||
updateParameters(dbConn, oldValue, newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> dbConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_CONNECTIONS, true);
|
||||
for (IRepositoryViewObject obj : dbConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> excelConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_EXCEL, true);
|
||||
for (IRepositoryViewObject obj : excelConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> deliConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_DELIMITED, true);
|
||||
for (IRepositoryViewObject obj : deliConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
List<IRepositoryViewObject> excelConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_EXCEL, true);
|
||||
for (IRepositoryViewObject obj : excelConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof FileExcelConnection) {
|
||||
if (((FileExcelConnection) conn).getFirstColumn() != null
|
||||
&& ((FileExcelConnection) conn).getFirstColumn().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setFirstColumn(newValue);
|
||||
} else if (((FileExcelConnection) conn).getLastColumn() != null
|
||||
&& ((FileExcelConnection) conn).getLastColumn().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setLastColumn(newValue);
|
||||
} else if (((FileExcelConnection) conn).getThousandSeparator() != null
|
||||
&& ((FileExcelConnection) conn).getThousandSeparator().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setThousandSeparator(newValue);
|
||||
} else if (((FileExcelConnection) conn).getDecimalSeparator() != null
|
||||
&& ((FileExcelConnection) conn).getDecimalSeparator().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setDecimalSeparator(newValue);
|
||||
} else if (((FileExcelConnection) conn).getFilePath() != null
|
||||
&& ((FileExcelConnection) conn).getFilePath().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setFilePath(newValue);
|
||||
} else if (((FileExcelConnection) conn).getEncoding() != null
|
||||
&& ((FileExcelConnection) conn).getEncoding().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setEncoding(newValue);
|
||||
} else if (((FileExcelConnection) conn).getLimitValue() != null
|
||||
&& ((FileExcelConnection) conn).getLimitValue().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setLimitValue(newValue);
|
||||
} else if (((FileExcelConnection) conn).getHeaderValue() != null
|
||||
&& ((FileExcelConnection) conn).getHeaderValue().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setHeaderValue(newValue);
|
||||
} else if (((FileExcelConnection) conn).getFooterValue() != null
|
||||
&& ((FileExcelConnection) conn).getFooterValue().equals(oldValue)) {
|
||||
((FileExcelConnection) conn).setFooterValue(newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> regConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_REGEXP, true);
|
||||
for (IRepositoryViewObject obj : regConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> ldifConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_LDIF, true);
|
||||
for (IRepositoryViewObject obj : ldifConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> posiConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_POSITIONAL, true);
|
||||
for (IRepositoryViewObject obj : posiConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> xmlConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_FILE_XML, true);
|
||||
for (IRepositoryViewObject obj : xmlConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> saleConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA, true);
|
||||
for (IRepositoryViewObject obj : saleConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> wsdlConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_WSDL_SCHEMA, true);
|
||||
for (IRepositoryViewObject obj : wsdlConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
|
||||
List<IRepositoryViewObject> deliConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_DELIMITED, true);
|
||||
for (IRepositoryViewObject obj : deliConnList) {
|
||||
List<IRepositoryViewObject> sapConnList = FACTORY.getAll(ERepositoryObjectType.METADATA_SAPCONNECTIONS, true);
|
||||
for (IRepositoryViewObject obj : sapConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
for (String updateType : UpdateRepositoryHelper.getAllHadoopConnectionTypes()) {
|
||||
List<IRepositoryViewObject> hadoopConnList = FACTORY
|
||||
.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, updateType), true);
|
||||
for (IRepositoryViewObject obj : hadoopConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof DelimitedFileConnection) {
|
||||
if (((DelimitedFileConnection) conn).getFilePath() != null
|
||||
&& ((DelimitedFileConnection) conn).getFilePath().equals(oldValue)) {
|
||||
((DelimitedFileConnection) conn).setFilePath(newValue);
|
||||
} else if (((DelimitedFileConnection) conn).getEncoding() != null
|
||||
&& ((DelimitedFileConnection) conn).getEncoding().equals(oldValue)) {
|
||||
((DelimitedFileConnection) conn).setEncoding(newValue);
|
||||
} else if (((DelimitedFileConnection) conn).getLimitValue() != null
|
||||
&& ((DelimitedFileConnection) conn).getLimitValue().equals(oldValue)) {
|
||||
((DelimitedFileConnection) conn).setLimitValue(newValue);
|
||||
} else if (((DelimitedFileConnection) conn).getHeaderValue() != null
|
||||
&& ((DelimitedFileConnection) conn).getHeaderValue().equals(oldValue)) {
|
||||
((DelimitedFileConnection) conn).setHeaderValue(newValue);
|
||||
} else if (((DelimitedFileConnection) conn).getFooterValue() != null
|
||||
&& ((DelimitedFileConnection) conn).getFooterValue().equals(oldValue)) {
|
||||
((DelimitedFileConnection) conn).setFooterValue(newValue);
|
||||
} else if (((DelimitedFileConnection) conn).getRowSeparatorValue() != null
|
||||
&& ((DelimitedFileConnection) conn).getRowSeparatorValue().equals(oldValue)) {
|
||||
((DelimitedFileConnection) conn).setRowSeparatorValue(newValue);
|
||||
} else if (((DelimitedFileConnection) conn).getFieldSeparatorValue() != null
|
||||
&& ((DelimitedFileConnection) conn).getFieldSeparatorValue().equals(oldValue)) {
|
||||
((DelimitedFileConnection) conn).setFieldSeparatorValue(newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> regConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_REGEXP, true);
|
||||
for (IRepositoryViewObject obj : regConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof RegexpFileConnection) {
|
||||
if (((RegexpFileConnection) conn).getFilePath() != null
|
||||
&& ((RegexpFileConnection) conn).getFilePath().equals(oldValue)) {
|
||||
((RegexpFileConnection) conn).setFilePath(newValue);
|
||||
} else if (((RegexpFileConnection) conn).getEncoding() != null
|
||||
&& ((RegexpFileConnection) conn).getEncoding().equals(oldValue)) {
|
||||
((RegexpFileConnection) conn).setEncoding(newValue);
|
||||
} else if (((RegexpFileConnection) conn).getLimitValue() != null
|
||||
&& ((RegexpFileConnection) conn).getLimitValue().equals(oldValue)) {
|
||||
((RegexpFileConnection) conn).setLimitValue(newValue);
|
||||
} else if (((RegexpFileConnection) conn).getHeaderValue() != null
|
||||
&& ((RegexpFileConnection) conn).getHeaderValue().equals(oldValue)) {
|
||||
((RegexpFileConnection) conn).setHeaderValue(newValue);
|
||||
} else if (((RegexpFileConnection) conn).getFooterValue() != null
|
||||
&& ((RegexpFileConnection) conn).getFooterValue().equals(oldValue)) {
|
||||
((RegexpFileConnection) conn).setFooterValue(newValue);
|
||||
} else if (((RegexpFileConnection) conn).getRowSeparatorValue() != null
|
||||
&& ((RegexpFileConnection) conn).getRowSeparatorValue().equals(oldValue)) {
|
||||
((RegexpFileConnection) conn).setRowSeparatorValue(newValue);
|
||||
} else if (((RegexpFileConnection) conn).getFieldSeparatorValue() != null
|
||||
&& ((RegexpFileConnection) conn).getFieldSeparatorValue().equals(oldValue)) {
|
||||
((RegexpFileConnection) conn).setFieldSeparatorValue(newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> ldifConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_LDIF, true);
|
||||
for (IRepositoryViewObject obj : ldifConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof LdifFileConnection) {
|
||||
LdifFileConnection dbConn = (LdifFileConnection) conn;
|
||||
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
|
||||
dbConn.setFilePath(newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> posiConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_POSITIONAL, true);
|
||||
for (IRepositoryViewObject obj : posiConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof PositionalFileConnection) {
|
||||
PositionalFileConnection dbConn = (PositionalFileConnection) conn;
|
||||
if (dbConn.getFilePath() != null && dbConn.getFilePath().equals(oldValue)) {
|
||||
dbConn.setFilePath(newValue);
|
||||
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
|
||||
dbConn.setEncoding(newValue);
|
||||
} else if (dbConn.getLimitValue() != null && dbConn.getLimitValue().equals(oldValue)) {
|
||||
dbConn.setLimitValue(newValue);
|
||||
} else if (dbConn.getHeaderValue() != null && dbConn.getHeaderValue().equals(oldValue)) {
|
||||
dbConn.setHeaderValue(newValue);
|
||||
} else if (dbConn.getFooterValue() != null && dbConn.getFooterValue().equals(oldValue)) {
|
||||
dbConn.setFooterValue(newValue);
|
||||
} else if (dbConn.getRowSeparatorValue() != null
|
||||
&& dbConn.getRowSeparatorValue().equals(oldValue)) {
|
||||
dbConn.setRowSeparatorValue(newValue);
|
||||
} else if (dbConn.getFieldSeparatorValue() != null
|
||||
&& dbConn.getFieldSeparatorValue().equals(oldValue)) {
|
||||
dbConn.setFieldSeparatorValue(newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> xmlConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_XML, true);
|
||||
for (IRepositoryViewObject obj : xmlConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof XmlFileConnection) {
|
||||
XmlFileConnection dbConn = (XmlFileConnection) conn;
|
||||
if (dbConn.getXmlFilePath() != null && dbConn.getXmlFilePath().equals(oldValue)) {
|
||||
dbConn.setXmlFilePath(newValue);
|
||||
} else if (dbConn.getEncoding() != null && dbConn.getEncoding().equals(oldValue)) {
|
||||
dbConn.setEncoding(newValue);
|
||||
} else if (dbConn.getOutputFilePath() != null && dbConn.getOutputFilePath().equals(oldValue)) {
|
||||
dbConn.setOutputFilePath(newValue);
|
||||
}
|
||||
EList schema = dbConn.getSchema();
|
||||
if (schema != null && schema.size() > 0) {
|
||||
if (schema.get(0) instanceof XmlXPathLoopDescriptor) {
|
||||
XmlXPathLoopDescriptor descriptor = (XmlXPathLoopDescriptor) schema.get(0);
|
||||
if (descriptor.getAbsoluteXPathQuery() != null
|
||||
&& descriptor.getAbsoluteXPathQuery().equals(oldValue)) {
|
||||
descriptor.setAbsoluteXPathQuery(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> saleConnList = factory.getAll(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA, true);
|
||||
for (IRepositoryViewObject obj : saleConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof SalesforceSchemaConnection) {
|
||||
SalesforceSchemaConnection ssConn = (SalesforceSchemaConnection) conn;
|
||||
if (ssConn.getWebServiceUrl() != null && ssConn.getWebServiceUrl().equals(oldValue)) {
|
||||
ssConn.setWebServiceUrl(newValue);
|
||||
} else if (ssConn.getPassword() != null && ssConn.getPassword().equals(oldValue)) {
|
||||
// in fact, because in context mode. can setPassword directly.
|
||||
// ssConn.setPassword(ssConn.getValue(newValue,true));
|
||||
ssConn.setPassword(newValue);
|
||||
} else if (ssConn.getUserName() != null && ssConn.getUserName().equals(oldValue)) {
|
||||
ssConn.setUserName(newValue);
|
||||
} else if (ssConn.getTimeOut() != null && ssConn.getTimeOut().equals(oldValue)) {
|
||||
ssConn.setTimeOut(newValue);
|
||||
} else if (ssConn.getBatchSize() != null && ssConn.getBatchSize().equals(oldValue)) {
|
||||
ssConn.setBatchSize(newValue);
|
||||
} else if (ssConn.getQueryCondition() != null && ssConn.getQueryCondition().equals(oldValue)) {
|
||||
ssConn.setQueryCondition(newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
List<IRepositoryViewObject> wsdlConnList = factory.getAll(ERepositoryObjectType.METADATA_WSDL_SCHEMA, true);
|
||||
for (IRepositoryViewObject obj : wsdlConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof WSDLSchemaConnection) {
|
||||
WSDLSchemaConnection dbConn = (WSDLSchemaConnection) conn;
|
||||
if (dbConn.getUserName() != null && dbConn.getUserName().equals(oldValue)) {
|
||||
dbConn.setUserName(newValue);
|
||||
} else if (dbConn.getPassword() != null && dbConn.getPassword().equals(oldValue)) {
|
||||
dbConn.setPassword(newValue);
|
||||
} else if (dbConn.getProxyHost() != null && dbConn.getProxyHost().equals(oldValue)) {
|
||||
dbConn.setProxyHost(newValue);
|
||||
} else if (dbConn.getProxyPassword() != null && dbConn.getProxyPassword().equals(oldValue)) {
|
||||
dbConn.setProxyPassword(newValue);
|
||||
} else if (dbConn.getProxyUser() != null && dbConn.getProxyUser().equals(oldValue)) {
|
||||
dbConn.setProxyUser(newValue);
|
||||
} else if (dbConn.getProxyPort() != null && dbConn.getProxyPort().equals(oldValue)) {
|
||||
dbConn.setProxyPort(newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<IRepositoryViewObject> sapConnList = factory.getAll(ERepositoryObjectType.METADATA_SAPCONNECTIONS, true);
|
||||
for (IRepositoryViewObject obj : sapConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (conn instanceof SAPConnection) {
|
||||
SAPConnection sapConn = (SAPConnection) conn;
|
||||
if (sapConn.getClient() != null && sapConn.getClient().equals(oldValue)) {
|
||||
sapConn.setClient(newValue);
|
||||
} else if (sapConn.getUsername() != null && sapConn.getUsername().equals(oldValue)) {
|
||||
sapConn.setUsername(newValue);
|
||||
} else if (sapConn.getPassword() != null && sapConn.getPassword().equals(oldValue)) {
|
||||
sapConn.setPassword(newValue);
|
||||
} else if (sapConn.getHost() != null && sapConn.getHost().equals(oldValue)) {
|
||||
sapConn.setHost(newValue);
|
||||
} else if (sapConn.getSystemNumber() != null && sapConn.getSystemNumber().equals(oldValue)) {
|
||||
sapConn.setSystemNumber(newValue);
|
||||
} else if (sapConn.getLanguage() != null && sapConn.getLanguage().equals(oldValue)) {
|
||||
sapConn.setLanguage(newValue);
|
||||
} else {
|
||||
for (AdditionalConnectionProperty sapProperty : sapConn.getAdditionalProperties()) {
|
||||
if (sapProperty.getValue() != null && sapProperty.getValue().equals(oldValue)) {
|
||||
sapProperty.setValue(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String updateType : UpdateRepositoryHelper.getAllHadoopConnectionTypes()) {
|
||||
List<IRepositoryViewObject> hadoopConnList = factory
|
||||
.getAll(ERepositoryObjectType.valueOf(ERepositoryObjectType.class, updateType), true);
|
||||
for (IRepositoryViewObject obj : hadoopConnList) {
|
||||
Item item = obj.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
Connection conn = ((ConnectionItem) item).getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
if (contextItem == null) {
|
||||
continue;
|
||||
}
|
||||
if (citem == contextItem) {
|
||||
if (GlobalServiceRegister.getDefault()
|
||||
.isServiceRegistered(IRepositoryContextUpdateService.class)) {
|
||||
IService service = GlobalServiceRegister.getDefault()
|
||||
.getService(IRepositoryContextUpdateService.class);
|
||||
IRepositoryContextUpdateService repositoryContextUpdateService = (IRepositoryContextUpdateService) service;
|
||||
repositoryContextUpdateService.updateRelatedContextVariable(conn, oldValue, newValue);
|
||||
}
|
||||
factory.save(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundCompProperties && GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
|
||||
IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
|
||||
service.updateCompPropertiesForContextMode(dbConnectionItem.getConnection(), oldToNewHM);
|
||||
factory.save(dbConnectionItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateParameters(DatabaseConnection dbConn, String oldValue, String newValue) {
|
||||
EMap<String, String> parameters = dbConn.getParameters();
|
||||
if (parameters != null && !parameters.isEmpty()) {
|
||||
for (Entry<String, String> entry : parameters.entrySet()) {
|
||||
if (entry != null) {
|
||||
String value = entry.getValue();
|
||||
if (StringUtils.equals(value, oldValue)) {
|
||||
entry.setValue(newValue);
|
||||
for (ERepositoryObjectType objectType : service.getAllGenericMetadataDBRepositoryType()) {
|
||||
List<IRepositoryViewObject> repositoryObjects = FACTORY.getAll(objectType);
|
||||
for (IRepositoryViewObject object : repositoryObjects) {
|
||||
Item item = object.getProperty().getItem();
|
||||
if (item instanceof ConnectionItem) {
|
||||
updateConnectionContextParam((ConnectionItem) item, citem, valueMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateHadoopPropertiesForDbConnection(dbConn, oldValue, newValue);
|
||||
}
|
||||
|
||||
private void updateHadoopPropertiesForDbConnection(DatabaseConnection dbConn, String oldValue, String newValue) {
|
||||
EMap<String, String> parameters = dbConn.getParameters();
|
||||
String databaseType = parameters.get(ConnParameterKeys.CONN_PARA_KEY_DB_TYPE);
|
||||
String hadoopProperties = "";
|
||||
if (databaseType != null) {
|
||||
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
|
||||
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES);
|
||||
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
|
||||
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES);
|
||||
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
|
||||
hadoopProperties = parameters.get(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES);
|
||||
private static void updateConnectionContextParam(ConnectionItem conntectionItem, ContextItem citem,
|
||||
Map<String, String> newToOldValueMap) throws PersistenceException {
|
||||
boolean isModified = false;
|
||||
if (conntectionItem != null && conntectionItem.getConnection() != null && citem != null
|
||||
&& citem.getProperty() != null
|
||||
&& StringUtils.equals(conntectionItem.getConnection().getContextId(), citem.getProperty().getId())) {
|
||||
for (String newValue : newToOldValueMap.keySet()) {
|
||||
String oldValue = newToOldValueMap.get(newValue);
|
||||
boolean result = updateConnectionContextParam(conntectionItem, oldValue, newValue);
|
||||
isModified = isModified || result;
|
||||
}
|
||||
if (isModified) {
|
||||
FACTORY.save(conntectionItem, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean updateConnectionContextParam(ConnectionItem conntectionItem, String oldValue, String newValue) {
|
||||
Connection conn = conntectionItem.getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
IRepositoryContextUpdateService updater = null;
|
||||
updater = findContextParameterUpdater(conn);
|
||||
if (updater != null) {
|
||||
return updater.updateContextParameter(conn, addContextParamPrefix(oldValue), addContextParamPrefix(newValue));
|
||||
}
|
||||
List<Map<String, Object>> hadoopPropertiesList = HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties);
|
||||
if (!hadoopPropertiesList.isEmpty()) {
|
||||
for (Map<String, Object> propertyMap : hadoopPropertiesList) {
|
||||
String propertyValue = (String) propertyMap.get("VALUE");
|
||||
if (propertyValue.equals(oldValue)) {
|
||||
propertyMap.put("VALUE", newValue);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void updateConnectionContextParam(RepositoryNode connNode) throws PersistenceException {
|
||||
if (connNode.getObject() == null || connNode.getObject().getProperty() == null
|
||||
|| connNode.getObject().getProperty().getItem() == null) {
|
||||
return;
|
||||
}
|
||||
ConnectionItem conntectionItem = (ConnectionItem) connNode.getObject().getProperty().getItem();
|
||||
updateConnectionContextParam(conntectionItem);
|
||||
}
|
||||
|
||||
public static void updateConnectionContextParam(ConnectionItem conntectionItem)
|
||||
throws PersistenceException {
|
||||
Connection conn = conntectionItem.getConnection();
|
||||
if (conn.isContextMode()) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(conn.getContextId());
|
||||
ItemContextLink itemContextLink = null;
|
||||
try {
|
||||
itemContextLink = ContextLinkService.getInstance().loadContextLinkFromJson(conntectionItem);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
ContextLink contextLink = null;
|
||||
if (itemContextLink != null) {
|
||||
contextLink = itemContextLink.findContextLink(null, conn.getContextName());
|
||||
}
|
||||
if (contextLink != null) {
|
||||
ContextType contextType = ContextUtils.getContextTypeByName(contextItem, conn.getContextName(), false);
|
||||
IRepositoryContextUpdateService updateServce = findContextParameterUpdater(conn);
|
||||
if (updateServce != null) {
|
||||
boolean isModified = false;
|
||||
for (ContextParamLink paramLink : contextLink.getParameterList()) {
|
||||
ContextParameterType paramType = ContextUtils.getContextParameterTypeByName(contextType,
|
||||
paramLink.getName());
|
||||
if (paramType == null) {
|
||||
paramType = ContextUtils.getContextParameterTypeById(contextType, paramLink.getId(), true);
|
||||
if (paramType != null) {
|
||||
boolean result = updateServce.updateContextParameter(conn,
|
||||
addContextParamPrefix(paramLink.getName()), addContextParamPrefix(paramType.getName()));
|
||||
isModified = isModified || result;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isModified) {
|
||||
FACTORY.save(conntectionItem, false);
|
||||
}
|
||||
}
|
||||
String hadoopPropertiesJson = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopPropertiesList);
|
||||
if (EDatabaseConnTemplate.HIVE.getDBDisplayName().equals(databaseType)) {
|
||||
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HIVE_PROPERTIES, hadoopPropertiesJson);
|
||||
} else if (EDatabaseConnTemplate.HBASE.getDBDisplayName().equals(databaseType)) {
|
||||
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HBASE_PROPERTIES, hadoopPropertiesJson);
|
||||
} else if (EDatabaseConnTemplate.MAPRDB.getDBDisplayName().equals(databaseType)) {
|
||||
dbConn.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_PROPERTIES, hadoopPropertiesJson);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String addContextParamPrefix(String value) {
|
||||
if (!value.startsWith(ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX)) {
|
||||
value = ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX + value;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static IEditorReference[] getEditors() {
|
||||
if (CommonsPlugin.isHeadless() || !getProxyRepositoryFactory().isFullLogonFinished()) {
|
||||
if (CommonsPlugin.isHeadless() || !FACTORY.isFullLogonFinished()) {
|
||||
return new IEditorReference[0];
|
||||
}
|
||||
final List<IEditorReference> list = new ArrayList<IEditorReference>();
|
||||
@@ -1261,6 +964,7 @@ public abstract class RepositoryUpdateManager {
|
||||
jobParam.setSource(repositoryId);
|
||||
jobParam.setType(repoParam.getType());
|
||||
jobParam.setValue(repoParam.getValue());
|
||||
jobParam.setInternalId(repoParam.getInternalId());
|
||||
jobContext.getContextParameterList().add(jobParam);
|
||||
}
|
||||
addContextGroupList.add(jobContext);
|
||||
@@ -1545,7 +1249,6 @@ public abstract class RepositoryUpdateManager {
|
||||
*/
|
||||
public static boolean updateServices(ConnectionItem connectionItem, boolean show, final boolean onlySimpleShow) {
|
||||
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
|
||||
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.SERVICES_RELATION);
|
||||
|
||||
@@ -1639,7 +1342,6 @@ public abstract class RepositoryUpdateManager {
|
||||
* @return
|
||||
*/
|
||||
public static boolean updateValidationRuleConnection(ConnectionItem connectionItem, boolean show, boolean onlySimpleShow) {
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
|
||||
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.VALIDATION_RULE_RELATION);
|
||||
@@ -1993,7 +1695,6 @@ public abstract class RepositoryUpdateManager {
|
||||
|
||||
public static boolean updateWSDLConnection(ConnectionItem connectionItem, boolean show, final boolean onlySimpleShow) {
|
||||
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(connectionItem.getProperty().getId(),
|
||||
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
|
||||
|
||||
@@ -2078,7 +1779,6 @@ public abstract class RepositoryUpdateManager {
|
||||
* @return
|
||||
*/
|
||||
public static boolean updateSAPFunction(final SAPFunctionUnit sapFunction, boolean show, boolean onlySimpleShow) {
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(sapFunction.getId(),
|
||||
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
|
||||
@@ -2107,8 +1807,6 @@ public abstract class RepositoryUpdateManager {
|
||||
* @return
|
||||
*/
|
||||
public static boolean updateSAPIDoc(final SAPIDocUnit sapIDoc, boolean show, boolean onlySimpleShow) {
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(sapIDoc.getId(),
|
||||
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
|
||||
|
||||
@@ -2167,8 +1865,6 @@ public abstract class RepositoryUpdateManager {
|
||||
|
||||
protected static boolean updateSchema(final Object table, ConnectionItem connItem, Map<String, String> schemaRenamedMap,
|
||||
boolean show, boolean onlySimpleShow) {
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo((connItem).getProperty().getId(),
|
||||
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PROPERTY_RELATION);
|
||||
|
||||
@@ -2224,8 +1920,6 @@ public abstract class RepositoryUpdateManager {
|
||||
}
|
||||
|
||||
private static boolean updateQueryObject(Object parameter, boolean show, boolean onlySimpleShow) {
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
|
||||
List<Relation> relations = null;
|
||||
if (parameter instanceof Query) {
|
||||
relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(((Query) parameter).getId(),
|
||||
@@ -2356,7 +2050,7 @@ public abstract class RepositoryUpdateManager {
|
||||
repositoryUpdateManager.setContextRenamedMap(repositoryRenamedMap);
|
||||
|
||||
// newly added parameters
|
||||
Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
|
||||
Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
|
||||
if (!repositoryContextManager.getNewParameters().isEmpty()) {
|
||||
newParametersMap.put(item, repositoryContextManager.getNewParameters());
|
||||
}
|
||||
@@ -2368,16 +2062,14 @@ public abstract class RepositoryUpdateManager {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return repositoryUpdateManager.doWork(show, onlySimpleShow);
|
||||
}
|
||||
|
||||
public Map<ContextItem, Set<String>> getNewParametersMap() {
|
||||
public Map<Item, Set<String>> getNewParametersMap() {
|
||||
return newParametersMap;
|
||||
}
|
||||
|
||||
public void setNewParametersMap(Map<ContextItem, Set<String>> newParametersMap) {
|
||||
public void setNewParametersMap(Map<Item, Set<String>> newParametersMap) {
|
||||
this.newParametersMap = newParametersMap;
|
||||
}
|
||||
|
||||
@@ -2480,7 +2172,6 @@ public abstract class RepositoryUpdateManager {
|
||||
// Added TDQ-11688 20170309 yyin
|
||||
public static boolean updateDQPattern(Item patternItem) {
|
||||
List<IRepositoryViewObject> updateList = new ArrayList<IRepositoryViewObject>();
|
||||
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
|
||||
List<Relation> relations = RelationshipItemBuilder.getInstance().getItemsRelatedTo(patternItem.getProperty().getId(),
|
||||
RelationshipItemBuilder.LATEST_VERSION, RelationshipItemBuilder.PATTERN_RELATION);
|
||||
|
||||
@@ -2498,9 +2189,19 @@ public abstract class RepositoryUpdateManager {
|
||||
return repositoryUpdateManager.doWork(true, false);
|
||||
}
|
||||
|
||||
private static IProxyRepositoryFactory getProxyRepositoryFactory() {
|
||||
return ((IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class))
|
||||
.getProxyRepositoryFactory();
|
||||
}
|
||||
public static IRepositoryContextUpdateService findContextParameterUpdater(Connection connection) {
|
||||
if (CONTEXT_UPDATE_SERVICE_LIST == null) {
|
||||
CONTEXT_UPDATE_SERVICE_LIST = GlobalServiceRegister.getDefault()
|
||||
.findAllService(IRepositoryContextUpdateService.class);
|
||||
}
|
||||
for (IRepositoryContextUpdateService updater : CONTEXT_UPDATE_SERVICE_LIST) {
|
||||
if (updater.accept(connection)) {
|
||||
return updater;
|
||||
}
|
||||
}
|
||||
|
||||
LOGGER.error(
|
||||
"Can't find any connection context parameter updater for connection type:" + connection.getClass().getName());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ import org.apache.oro.text.regex.Perl5Compiler;
|
||||
import org.apache.oro.text.regex.Perl5Matcher;
|
||||
import org.apache.oro.text.regex.Perl5Substitution;
|
||||
import org.apache.oro.text.regex.Util;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.talend.commons.utils.PasswordEncryptUtil;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
@@ -48,6 +50,8 @@ import org.talend.core.model.metadata.types.JavaTypesManager;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.repository.IRepositoryPrefConstants;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
@@ -595,8 +599,12 @@ public final class ContextParameterUtils {
|
||||
if (ContextUtils.isJavaKeyWords(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Pattern regex = Pattern.compile(RepositoryConstants.CONTEXT_AND_VARIABLE_PATTERN, Pattern.UNICODE_CHARACTER_CLASS);
|
||||
Pattern regex = null;
|
||||
if (isAllowSpecificCharacters()) {
|
||||
regex = Pattern.compile(RepositoryConstants.CONTEXT_AND_VARIABLE_PATTERN, Pattern.UNICODE_CHARACTER_CLASS);
|
||||
} else {
|
||||
regex = Pattern.compile(RepositoryConstants.COLUMN_NAME_PATTERN, Pattern.UNICODE_CHARACTER_CLASS);
|
||||
}
|
||||
Matcher regexMatcher = regex.matcher(name);
|
||||
|
||||
return regexMatcher.matches();
|
||||
@@ -604,6 +612,11 @@ public final class ContextParameterUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isAllowSpecificCharacters() {
|
||||
IEclipsePreferences coreUIPluginNode = new InstanceScope().getNode(ITalendCorePrefConstants.CoreUIPlugin_ID);
|
||||
return coreUIPluginNode.getBoolean(IRepositoryPrefConstants.ALLOW_SPECIFIC_CHARACTERS_FOR_SCHEMA_COLUMNS, false);
|
||||
}
|
||||
|
||||
public static boolean isEmptyParameter(String source) {
|
||||
return source.equals(StringUtils.EMPTY);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -66,4 +66,6 @@ public interface IGenericDBService extends IService{
|
||||
|
||||
public void updateCompPropertiesForContextMode(Connection connection, Map<String, String> contextVarMap);
|
||||
|
||||
public List<ERepositoryObjectType> getAllGenericMetadataDBRepositoryType();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.core.ui;
|
||||
|
||||
import org.talend.core.IService;
|
||||
|
||||
/**
|
||||
* @author hwang
|
||||
*
|
||||
*/
|
||||
public interface IInstalledPatchService extends IService {
|
||||
|
||||
public String getLatestInstalledVersion(boolean isBar);
|
||||
|
||||
}
|
||||
@@ -46,4 +46,8 @@ public class TrackerUtil {
|
||||
Version version = new Version(strVersion);
|
||||
return getStrVersion(version);
|
||||
}
|
||||
|
||||
public static String getRedshiftTracker() {
|
||||
return "--Talend -v " + getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.eclipse.jdt.core.IJavaProject;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.language.ECodeLanguage;
|
||||
import org.talend.core.language.ICodeProblemsChecker;
|
||||
@@ -245,4 +246,11 @@ public interface IRunProcessService extends IService {
|
||||
|
||||
public boolean isCIMode();
|
||||
|
||||
public static IRunProcessService get() {
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
|
||||
return GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
@@ -91,11 +92,14 @@ public final class ProjectManager {
|
||||
|
||||
private Set<Object> updatedRemoteHandlerRecords;
|
||||
|
||||
private Set<Project> tempProjects;
|
||||
|
||||
private ProjectManager() {
|
||||
beforeLogonRecords = new HashSet<String>();
|
||||
logonRecords = new HashSet<String>();
|
||||
migrationRecords = new HashSet<String>();
|
||||
updatedRemoteHandlerRecords = new HashSet<Object>();
|
||||
tempProjects = new HashSet<>();
|
||||
initCurrentProject();
|
||||
}
|
||||
|
||||
@@ -106,6 +110,18 @@ public final class ProjectManager {
|
||||
return singleton;
|
||||
}
|
||||
|
||||
public void clearTempProjects() {
|
||||
tempProjects.clear();
|
||||
}
|
||||
|
||||
public boolean removeTempProject(Project project) {
|
||||
return tempProjects.remove(project);
|
||||
}
|
||||
|
||||
public boolean addTempProject(Project project) {
|
||||
return tempProjects.add(project);
|
||||
}
|
||||
|
||||
public Project getProjectFromProjectLabel(String label) {
|
||||
if (currentProject == null) {
|
||||
initCurrentProject();
|
||||
@@ -119,6 +135,12 @@ public final class ProjectManager {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
for (Project project : tempProjects) {
|
||||
if (StringUtils.equals(project.getLabel(), label)) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -136,6 +158,11 @@ public final class ProjectManager {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
for (Project project : tempProjects) {
|
||||
if (StringUtils.equals(project.getTechnicalLabel(), label)) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ public enum ERepositoryActionName {
|
||||
|
||||
DELETE_TO_RECYCLE_BIN("delete to recycle bin"), //$NON-NLS-1$
|
||||
DELETE_FOREVER("delete forever"), //$NON-NLS-1$
|
||||
AFTER_DELETE("after delete"), //$NON-NLS-1$
|
||||
|
||||
// these actions bellow are only for jobs and joblet actually, need to review.
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ public class RepositoryConstants {
|
||||
|
||||
public static final String PROJECT_BRANCH_ID = "repository.project.branch"; //$NON-NLS-1$
|
||||
|
||||
public static final String PROJECT_ID = "repository.project.id";
|
||||
|
||||
public static final String IMG_DIRECTORY = "images"; //$NON-NLS-1$
|
||||
|
||||
public static final String IMG_DIRECTORY_OF_JOB_OUTLINE = "images/job_outlines"; //$NON-NLS-1$
|
||||
|
||||
@@ -219,4 +219,13 @@ public class MetadataTableEditor extends ExtendedTableModel<IMetadataColumn> {
|
||||
|
||||
return metadataColumn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadonly() {
|
||||
if (this.metadataTable != null) {
|
||||
return this.metadataTable.isReadOnly();
|
||||
}
|
||||
return super.isReadonly();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,12 @@ package org.talend.core.ui.preference.collector;
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
@@ -28,6 +34,7 @@ import org.talend.core.ui.token.TokenCollectorFactory;
|
||||
public class TalendDataCollectorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
public TalendDataCollectorPreferencePage() {
|
||||
super(GRID);
|
||||
setPreferenceStore(CoreUIPlugin.getDefault().getPreferenceStore());
|
||||
setDescription(Messages.getString("TalendDataCollectorPreferencePage_Description")); //$NON-NLS-1$
|
||||
}
|
||||
@@ -41,6 +48,30 @@ public class TalendDataCollectorPreferencePage extends FieldEditorPreferencePage
|
||||
protected void createFieldEditors() {
|
||||
addField(new BooleanFieldEditor(ITalendCorePrefConstants.DATA_COLLECTOR_ENABLED,
|
||||
Messages.getString("TalendDataCollectorPreferencePage_EnableCapture"), getFieldEditorParent())); //$NON-NLS-1$
|
||||
if (Boolean.getBoolean("talend.DataCollector.visibleSendButton")) {//$NON-NLS-1$
|
||||
createSendDataButton(getFieldEditorParent());
|
||||
}
|
||||
}
|
||||
|
||||
private static void createSendDataButton(Composite parent) {
|
||||
GridData gd = new GridData();
|
||||
gd.horizontalSpan = 1;
|
||||
Button button = new Button(parent, SWT.PUSH | SWT.LEFT);
|
||||
button.setFont(parent.getFont());
|
||||
button.setLayoutData(gd);
|
||||
button.setText("Send Data"); //$NON-NLS-1$
|
||||
button.addSelectionListener(new SelectionListener() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
TokenCollectorFactory.getFactory().processWithoutWait();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.ui.token;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
@@ -49,7 +50,11 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
|
||||
public static String calcUniqueId() {
|
||||
return TokenGenerator.generateMachineToken((src) -> StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM).encrypt(src));
|
||||
}
|
||||
|
||||
|
||||
public static String hashUniqueId() {
|
||||
return TokenGenerator.generateMachineToken((src) -> DigestUtils.sha256Hex(src));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -61,7 +66,7 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
|
||||
// version
|
||||
tokenStudioObject.put(VERSION.getKey(), VersionUtils.getInternalVersion());
|
||||
// uniqueId
|
||||
tokenStudioObject.put(UNIQUE_ID.getKey(), calcUniqueId());
|
||||
tokenStudioObject.put(UNIQUE_ID.getKey(), hashUniqueId());
|
||||
|
||||
// typeStudio
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IBrandingService.class)) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
@@ -197,6 +198,19 @@ public final class TokenCollectorFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void processWithoutWait() {
|
||||
try {
|
||||
log.log(Level.INFO, "Start to collect data");
|
||||
priorCollect();
|
||||
log.log(Level.INFO, "End of collect data");
|
||||
log.log(Level.INFO, "Start to send data");
|
||||
send();
|
||||
log.log(Level.INFO, "End of send data");
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void send() {
|
||||
send(false);
|
||||
}
|
||||
|
||||
@@ -77,5 +77,5 @@ public interface ICoreTisService extends IService {
|
||||
Map<String, String> getDropBundleInfo() throws IOException;
|
||||
|
||||
Set<String> getComponentBlackList();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2813,57 +2813,6 @@ public class ProcessorUtilities {
|
||||
return "tRunJob".equalsIgnoreCase(componentName) || "cTalendJob".equalsIgnoreCase(componentName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a log4j2 config and write it into file
|
||||
*
|
||||
* @param configFile target file where config will be written
|
||||
* @param rootLevel root logger level to be used
|
||||
*/
|
||||
public static void writeLog4j2ConfToFile(File configFile, Level rootLevel) throws IOException {
|
||||
ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
|
||||
FileOutputStream configOs = new FileOutputStream(configFile);
|
||||
final AppenderComponentBuilder appenderBuilder = builder.newAppender("Console", "Console").addAttribute("target", ConsoleAppender.Target.SYSTEM_OUT);
|
||||
appenderBuilder.add(builder.newLayout("PatternLayout").addAttribute("pattern", "[%-5level] %d{HH:mm:ss} %logger{36}- %msg%n"));
|
||||
final RootLoggerComponentBuilder rootLoggerBuilder = builder.newRootLogger(rootLevel).add(builder.newAppenderRef("Console"));
|
||||
builder.add(appenderBuilder);
|
||||
builder.add(rootLoggerBuilder);
|
||||
builder.writeXmlConfiguration(configOs);
|
||||
}
|
||||
|
||||
public static void addFileToJar(String configFile, String jarFile) throws FileNotFoundException, IOException {
|
||||
JarOutputStream jarOs = new JarOutputStream(new FileOutputStream(jarFile));
|
||||
FileInputStream configIs = new FileInputStream(configFile);
|
||||
JarEntry jarEntry = new JarEntry("log4j2.xml");
|
||||
jarOs.putNextEntry(jarEntry);
|
||||
byte[] bytes = new byte[1024];
|
||||
int length;
|
||||
while ((length = configIs.read(bytes)) >= 0) {
|
||||
jarOs.write(bytes, 0, length);
|
||||
}
|
||||
configIs.close();
|
||||
jarOs.closeEntry();
|
||||
jarOs.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a jar containing a log4j2 config file
|
||||
*
|
||||
* @param process job for which to generate jar
|
||||
* @param rootLevel root logger level
|
||||
* @return path of the generated jar
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String buildLog4jConfigJar(IProcess process, String rootLevel) throws IOException {
|
||||
String externalResourcesFolderPath = getJavaProjectExternalResourcesFolderPath(process);
|
||||
String configFilePath = externalResourcesFolderPath + "/log4j2.xml";
|
||||
String jarFilePath = externalResourcesFolderPath + "/talend-studio-log4j2.xml.jar";
|
||||
// Create config file
|
||||
ProcessorUtilities.writeLog4j2ConfToFile(new File(configFilePath), Level.getLevel(rootLevel));
|
||||
// Put config file into jar
|
||||
ProcessorUtilities.addFileToJar(configFilePath, jarFilePath);
|
||||
return jarFilePath;
|
||||
}
|
||||
|
||||
public static boolean isCIMode() {
|
||||
return isCIMode;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<!-- Dependency versions -->
|
||||
<features-maven-plugin.version>2.2.9</features-maven-plugin.version>
|
||||
<maven-install-plugin.version>2.5.1</maven-install-plugin.version>
|
||||
<plexus-utils.version>2.1</plexus-utils.version>
|
||||
<plexus-utils.version>3.0.24</plexus-utils.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>3.0.24</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<artifactId>studio-tacokit-dependencies</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
<tacokit.components.version>1.8.0-SNAPSHOT</tacokit.components.version>
|
||||
<tacokit.components.version>1.10.0-SNAPSHOT</tacokit.components.version>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -535,7 +536,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
"${talend.job.bat.addition}" },
|
||||
new String[] { jvmArgsStr.toString().trim(), getWindowsClasspath(), jobClass,
|
||||
windowsScriptAdditionValue.toString() });
|
||||
|
||||
batContent = normalizeSpaces(batContent);
|
||||
String shContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_SH,
|
||||
templateParameters);
|
||||
shContent = StringUtils
|
||||
@@ -544,7 +545,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
"${talend.job.sh.addition}" },
|
||||
new String[] { jvmArgsStr.toString().trim(), getUnixClasspath(), jobClass,
|
||||
unixScriptAdditionValue.toString() });
|
||||
|
||||
shContent = normalizeSpaces(shContent);
|
||||
String psContent = MavenTemplateManager.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_PS,
|
||||
templateParameters);
|
||||
psContent = StringUtils
|
||||
@@ -553,7 +554,7 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
"${talend.job.class}", "${talend.job.bat.addition}" },
|
||||
new String[] { jvmArgsStrPs1.toString().trim(), getWindowsClasspathForPs1(), jobClass,
|
||||
windowsScriptAdditionValue.toString() });
|
||||
|
||||
psContent = normalizeSpaces(psContent);
|
||||
String jobInfoContent = MavenTemplateManager
|
||||
.getProjectSettingValue(IProjectSettingPreferenceConstants.TEMPLATE_JOB_INFO, templateParameters);
|
||||
String projectTechName = ProjectManager.getInstance().getProject(property).getTechnicalLabel();
|
||||
@@ -649,12 +650,13 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
ERepositoryObjectType.getAllTypesOfCodes().forEach(t -> dependencies.addAll(PomUtil.getCodesDependencies(t)));
|
||||
|
||||
// libraries of talend/3rd party
|
||||
dependencies.addAll(convertToDistinctedJobDependencies(currentJobProperty.getId(), currentJobProperty.getVersion(),
|
||||
processor.getNeededModules(TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED)));
|
||||
dependencies.addAll(processor.getNeededModules(TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED).stream()
|
||||
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet()));
|
||||
|
||||
// missing modules from the job generation of children
|
||||
childrenJobInfo.forEach(j -> dependencies.addAll(convertToDistinctedJobDependencies(j.getJobId(), j.getJobVersion(),
|
||||
LastGenerationInfo.getInstance().getModulesNeededPerJob(j.getJobId(), j.getJobVersion()))));
|
||||
childrenJobInfo.forEach(j -> dependencies
|
||||
.addAll(LastGenerationInfo.getInstance().getModulesNeededPerJob(j.getJobId(), j.getJobVersion()).stream()
|
||||
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet())));
|
||||
|
||||
Set<ModuleNeeded> modules = new HashSet<>();
|
||||
// testcase modules from current job (optional)
|
||||
@@ -733,6 +735,8 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
|
||||
// remove duplicate job dependencies and only keep the latest one
|
||||
// keep high priority dependencies if set by tLibraryLoad
|
||||
// FIXME not used now since tacokit component use specific dependency version. so we must include all job dependencies.
|
||||
// but problem will remain for CI when need to download jars from nexus, maven will only resolve one of them.
|
||||
private Set<Dependency> convertToDistinctedJobDependencies(String jobId, String jobVersion, Set<ModuleNeeded> neededModules) {
|
||||
Set<Dependency> highPriorityDependencies = LastGenerationInfo.getInstance()
|
||||
.getHighPriorityModuleNeededPerJob(jobId, jobVersion).stream().map(m -> createDenpendency(m, false))
|
||||
@@ -931,4 +935,22 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
|
||||
|
||||
}
|
||||
|
||||
// https://jira.talendforge.org/browse/TUP-27053
|
||||
public static String normalizeSpaces(String src) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
try (Scanner scanner = new Scanner(src)) {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
line = StringUtils.normalizeSpace(line.trim());
|
||||
if (!line.isEmpty()) {
|
||||
sb.append(line);
|
||||
}
|
||||
sb.append('\n');
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.core.runtime.jobs.MultiRule;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.eclipse.m2e.core.embedder.MavenModelManager;
|
||||
@@ -563,20 +564,39 @@ public class PomUtil {
|
||||
|
||||
public static String generatePom(MavenArtifact artifact) {
|
||||
try {
|
||||
IProgressMonitor monitor = new NullProgressMonitor();
|
||||
Project project = ProjectManager.getInstance().getCurrentProject();
|
||||
IProject fsProject = ResourceUtils.getProject(project);
|
||||
IFolder tmpFolder = fsProject.getFolder("temp");
|
||||
if (!tmpFolder.exists()) {
|
||||
tmpFolder.create(true, true, null);
|
||||
executeFolderAction(monitor, fsProject, new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
tmpFolder.create(true, true, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
File createTempFile = File.createTempFile(TalendMavenConstants.PACKAGING_POM, "");
|
||||
createTempFile.delete();
|
||||
String tmpFolderName = createTempFile.getName();
|
||||
IFolder folder = tmpFolder.getFolder(tmpFolderName);
|
||||
folder.create(true, true, null);
|
||||
executeFolderAction(monitor, tmpFolder, new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
folder.create(true, true, null);
|
||||
}
|
||||
});
|
||||
IFile pomFile = folder.getFile(TalendMavenConstants.POM_FILE_NAME);
|
||||
|
||||
MODEL_MANAGER.createMavenModel(pomFile, createModel(artifact));
|
||||
executeFolderAction(monitor, folder, new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
MODEL_MANAGER.createMavenModel(pomFile, createModel(artifact));
|
||||
}
|
||||
});
|
||||
return pomFile.getLocation().toPortableString();
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
@@ -588,6 +608,35 @@ public class PomUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void executeFolderAction(IProgressMonitor monitor, IResource parentFolder, IWorkspaceRunnable run)
|
||||
throws CoreException {
|
||||
if (Job.getJobManager().currentRule() == null) {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
ISchedulingRule defaultRule = workspace.getRuleFactory().modifyRule(parentFolder);
|
||||
ISchedulingRule noBlockRule = new ISchedulingRule() {
|
||||
|
||||
@Override
|
||||
public boolean isConflicting(ISchedulingRule rule) {
|
||||
return this.contains(rule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ISchedulingRule rule) {
|
||||
if (this.equals(rule)) {
|
||||
return true;
|
||||
}
|
||||
if (defaultRule.contains(rule)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
workspace.run(run, noBlockRule, IWorkspace.AVOID_UPDATE, monitor);
|
||||
} else {
|
||||
run.run(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
private static Model createModel(MavenArtifact artifact) {
|
||||
Model pomModel = new Model();
|
||||
pomModel.setModelVersion(TalendMavenConstants.POM_VERSION);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,3 @@
|
||||
xmlrpc-client-3.0.jar
|
||||
xmlrpc-common-3.0.jar
|
||||
xmlschema-core-2.0.1.jar
|
||||
xmlbeans-2.3.0.jar
|
||||
xmlbeans-2.6.0.jar
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
<artifactId>org.talend.libraries.apache.xml</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
<properties>
|
||||
<xmlrpc.version>3.0</xmlrpc.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -61,16 +57,6 @@
|
||||
<artifactId>xmlschema-core</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-common</artifactId>
|
||||
<version>${xmlrpc.version}</version>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.apache.xmlrpc</groupId>
|
||||
<artifactId>xmlrpc-client</artifactId>
|
||||
<version>${xmlrpc.version}</version>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
@@ -57,12 +57,32 @@ public class JDBCUtil {
|
||||
throw new RuntimeException("Null value in non-Nullable column");
|
||||
}
|
||||
|
||||
/**
|
||||
* getDate can be called with the resultSet having either a java.sql.Timestamp or a java.sql.Date
|
||||
* the double try implementation is not something im proud of, but having two methods would require
|
||||
* a huge refactoring that in the end is the same as doing that
|
||||
* @param rs
|
||||
* @param index
|
||||
* @return java.util.Date converted from java.sql.Timestamp/Date
|
||||
* @throws java.sql.SQLException
|
||||
*/
|
||||
public static Date getDate(ResultSet rs, int index) throws java.sql.SQLException {
|
||||
if(rs.getTimestamp(index) != null) {
|
||||
return new Date(rs.getTimestamp(index).getTime());
|
||||
Date result = null;
|
||||
try {
|
||||
if(rs.getTimestamp(index) != null) {
|
||||
result = new Date(rs.getTimestamp(index).getTime());
|
||||
return result;
|
||||
}
|
||||
} catch (java.sql.SQLException e) {
|
||||
}
|
||||
|
||||
return null;
|
||||
try {
|
||||
if(rs.getDate(index) != null) {
|
||||
result = new Date(rs.getDate(index).getTime());
|
||||
return result;
|
||||
}
|
||||
} catch (java.sql.SQLException e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//decrease the get method call number
|
||||
|
||||
@@ -54,8 +54,6 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
|
||||
private String SEARCH_SERVICE = "api/search/gavc?"; //$NON-NLS-1$
|
||||
|
||||
private String SEARCH_RESULT_PREFIX = "api/storage/";//$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -218,13 +216,11 @@ public class ArtifacoryRepositoryHandler extends AbstractArtifactRepositoryHandl
|
||||
throw new Exception(resultStr);
|
||||
}
|
||||
if (resultArray != null) {
|
||||
String resultUrl = serverUrl + SEARCH_RESULT_PREFIX;
|
||||
for (int i = 0; i < resultArray.size(); i++) {
|
||||
JSONObject jsonObject = resultArray.getJSONObject(i);
|
||||
String lastUpdated = jsonObject.getString("lastUpdated"); //$NON-NLS-1$
|
||||
String uri = jsonObject.getString("uri"); //$NON-NLS-1$
|
||||
uri = uri.substring(resultUrl.length(), uri.length());
|
||||
String[] split = uri.split("/"); //$NON-NLS-1$
|
||||
String artifactPath = jsonObject.getString("path"); //$NON-NLS-1$
|
||||
String[] split = artifactPath.split("/"); //$NON-NLS-1$
|
||||
if (split.length > 4) {
|
||||
String fileName = split[split.length - 1];
|
||||
if (!fileName.endsWith("pom")) { //$NON-NLS-1$
|
||||
|
||||
@@ -439,8 +439,8 @@ SelectorTableForm.selectAllTables=Select All
|
||||
SelectorTableForm.selectNoneTables=Select None
|
||||
ShadowProcessHelper.logError.previewIsNull01=\nThe ShadowProcess use to extract data or metadata on a File don't run.
|
||||
ShadowProcessHelper.logError.previewIsNull02=\nConfigurationElementsFor("org.talend.repository.filepreview_provider").length \=\= 0 ??
|
||||
ShowAddedContextdialog.Messages=Should add the following context parameters to the jobs or not?
|
||||
ShowAddedContextdialog.Title=Added context
|
||||
ShowAddedContextdialog.dialogMessages=Add the following context parameters to Jobs using this connection?
|
||||
ShowAddedContextdialog.dialogTitle=Add context parameters
|
||||
ShowAddedContextdialog.Variables=Variables
|
||||
StoppablePreviewLoader.inforLabelText.previewInterrupted=Preview interrupted
|
||||
TableWizard.windowTitle=Schema
|
||||
|
||||
@@ -685,17 +685,20 @@ public final class ConnectionContextHelper {
|
||||
// get the context variables from the node parameters.
|
||||
Set<String> neededVars = retrieveContextVar(elementParameters, connection, category);
|
||||
boolean isGeneric = isGenericConnection(connection);
|
||||
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
|
||||
if (neededVars != null && !neededVars.isEmpty() || isGeneric) {
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
|
||||
if (contextItem != null) {
|
||||
// find added variables
|
||||
neededVars.removeAll(renamedMap.keySet());
|
||||
neededVars.addAll(renamedMap.values());
|
||||
Set<String> tempVars = null;
|
||||
if(isGeneric){
|
||||
tempVars = checkAndAddContextVariables(contextItem, process.getContextManager(),
|
||||
false);
|
||||
false, renamedMap);
|
||||
}else{
|
||||
tempVars = checkAndAddContextVariables(contextItem, neededVars, process.getContextManager(),
|
||||
false);
|
||||
false, renamedMap);
|
||||
}
|
||||
Set<String> addedVars = tempVars;
|
||||
|
||||
@@ -785,17 +788,19 @@ public final class ConnectionContextHelper {
|
||||
|
||||
List<ContextItem> contextItems = new ArrayList<>();
|
||||
if (contextItem != null || hadoopClusterContextItem != null) {
|
||||
Map<String, String> renamedMap = ContextUtils
|
||||
.getContextParamterRenamedMap(process.getProperty().getItem());
|
||||
// find added variables
|
||||
Set<String> connAddedVars = null;
|
||||
Set<String> hcAddedVars = null;
|
||||
if (contextItem != null) {
|
||||
connAddedVars = checkAndAddContextVariables(contextItem, neededVars, process.getContextManager(),
|
||||
false);
|
||||
false, renamedMap);
|
||||
contextItems.add(contextItem);
|
||||
}
|
||||
if (hadoopClusterContextItem != null) {
|
||||
hcAddedVars = checkAndAddContextVariables(hadoopClusterContextItem, hcNeededVars,
|
||||
process.getContextManager(), false);
|
||||
process.getContextManager(), false, renamedMap);
|
||||
contextItems.add(hadoopClusterContextItem);
|
||||
}
|
||||
|
||||
@@ -846,7 +851,9 @@ public final class ConnectionContextHelper {
|
||||
|
||||
private static void addContextVarsToExistVariable(IProcess2 process, ContextItem contextItem, Set<String> addedVars,
|
||||
IContextManager contextMgr) {
|
||||
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, addedVars, contextMgr, false);
|
||||
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
|
||||
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, addedVars, contextMgr, false,
|
||||
renamedMap);
|
||||
if (addedContext != null && addedContext.size() > 0) {
|
||||
ConnectionContextHelper.addContextVarForJob(process, contextItem, addedVars);
|
||||
}
|
||||
@@ -904,8 +911,9 @@ public final class ConnectionContextHelper {
|
||||
ShowAddedContextdialog showDialog = new ShowAddedContextdialog(addedVarsMap, true);
|
||||
if (showDialog.open() == Window.OK) {
|
||||
if (ConnectionContextHelper.containsVariable(contextManager)) {
|
||||
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
|
||||
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, addedVars,
|
||||
contextManager, false);
|
||||
contextManager, false, renamedMap);
|
||||
if (addedContext != null && addedContext.size() > 0) {
|
||||
ConnectionContextHelper.addContextVarForJob(process, contextItem, addedVars);
|
||||
}
|
||||
@@ -967,6 +975,7 @@ public final class ConnectionContextHelper {
|
||||
//
|
||||
if (!varsMap.isEmpty()) {
|
||||
Map<String, Set<String>> addedVarsMap = new HashMap<String, Set<String>>();
|
||||
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
|
||||
for (String id : varsMap.keySet()) {
|
||||
ConnectionItem connItem = UpdateRepositoryUtils.getConnectionItemByItemId(id);
|
||||
if (connItem != null) {
|
||||
@@ -974,7 +983,7 @@ public final class ConnectionContextHelper {
|
||||
if (contextItem != null) {
|
||||
// add needed vars into job
|
||||
Set<String> addedVars = checkAndAddContextVariables(contextItem, varsMap.get(id),
|
||||
process.getContextManager(), false);
|
||||
process.getContextManager(), false, renamedMap);
|
||||
if (addedVars != null && !addedVars.isEmpty()) {
|
||||
String source = UpdateRepositoryUtils.getRepositorySourceName(connItem);
|
||||
addedVarsMap.put(source, addedVars);
|
||||
@@ -1065,6 +1074,7 @@ public final class ConnectionContextHelper {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Set<String> retrieveContextVar(List<? extends IElementParameter> elementParameters, Connection connection,
|
||||
EComponentCategory category) {
|
||||
return retrieveContextVar(elementParameters, connection, category, false, new HashMap<Object, Object>());
|
||||
@@ -1567,20 +1577,6 @@ public final class ConnectionContextHelper {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* add the context from contextItem into the ctxManager: add the variables and the context groups.
|
||||
*
|
||||
* @param contextItem
|
||||
* @param ctxManager
|
||||
* @param addedVars the variables need to adding
|
||||
* @param contextGoupNameSet the context group need to adding
|
||||
*/
|
||||
public static void checkAndAddContextVariables(ContextItem contextItem, IContextManager ctxManager, Set<String> addedVars,
|
||||
Set<String> contextGoupNameSet) {
|
||||
mergeContextVariables(contextItem.getContext(), contextItem.getDefaultContext(), contextItem.getProperty().getId(),
|
||||
ctxManager, addedVars, contextGoupNameSet, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* add the variables from ctxParams into JobContext.
|
||||
*
|
||||
@@ -1630,13 +1626,13 @@ public final class ConnectionContextHelper {
|
||||
* ggu Comment method "checkAndAddContextVariables".
|
||||
*/
|
||||
public static Set<String> checkAndAddContextVariables(final ContextItem contextItem, final Set<String> neededVars,
|
||||
final IContextManager ctxManager, boolean added) {
|
||||
final IContextManager ctxManager, boolean added, Map<String, String> renamedMap) {
|
||||
return checkAndAddContextVariables(contextItem.getContext(), contextItem.getDefaultContext(), contextItem.getProperty()
|
||||
.getId(), neededVars, ctxManager, added);
|
||||
.getId(), neededVars, ctxManager, added, renamedMap);
|
||||
}
|
||||
|
||||
public static Set<String> checkAndAddContextVariables(final ContextItem contextItem,
|
||||
final IContextManager ctxManager, boolean added) {
|
||||
final IContextManager ctxManager, boolean added, Map<String, String> renamedMap) {
|
||||
List<ContextType> contexts = contextItem.getContext();
|
||||
String defaultContextName = contextItem.getDefaultContext();
|
||||
String contextItemId = contextItem.getProperty().getId();
|
||||
@@ -1645,9 +1641,17 @@ public final class ConnectionContextHelper {
|
||||
ContextType type = ContextUtils.getContextTypeByName(contexts, context.getName(), defaultContextName);
|
||||
if (type != null) {
|
||||
for (ContextParameterType param :(List<ContextParameterType>)type.getContextParameter()){
|
||||
String paramName = param.getName();
|
||||
if (context.getContextParameter(param.getName()) != null) {
|
||||
continue;
|
||||
}
|
||||
String oldVar = renamedMap.get(paramName);
|
||||
if (oldVar != null) {
|
||||
IContextParameter contextParamter = context.getContextParameter(oldVar);
|
||||
if (contextParamter != null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(added){
|
||||
JobContextParameter contextParam = new JobContextParameter();
|
||||
|
||||
@@ -1678,14 +1682,16 @@ public final class ConnectionContextHelper {
|
||||
* @return
|
||||
*/
|
||||
public static Set<String> checkAndAddContextVariables(final List<ContextType> contexts, final String defaultContextName,
|
||||
final String contextItemId, final Set<String> neededVars, final IContextManager ctxManager, boolean added) {
|
||||
final String contextItemId, final Set<String> neededVars, final IContextManager ctxManager, boolean added,
|
||||
Map<String, String> renamedMap) {
|
||||
Set<String> addedVars = new HashSet<String>();
|
||||
for (IContext context : ctxManager.getListContext()) {
|
||||
ContextType type = ContextUtils.getContextTypeByName(contexts, context.getName(), defaultContextName);
|
||||
if (type != null) {
|
||||
for (IContextParameter jobParam : context.getContextParameterList()) {
|
||||
if (contextItemId.equals(jobParam.getSource())
|
||||
&& ContextUtils.getContextParameterTypeByName(type, jobParam.getName()) == null) {
|
||||
&& (ContextUtils.getContextParameterTypeByName(type, jobParam.getName()) == null
|
||||
&& !renamedMap.values().contains(jobParam.getName()))) {
|
||||
jobParam.setSource(IContextParameter.BUILT_IN);
|
||||
}
|
||||
}
|
||||
@@ -1693,6 +1699,13 @@ public final class ConnectionContextHelper {
|
||||
if (context.containsSameParameterIgnoreCase(var)) {
|
||||
continue;
|
||||
}
|
||||
String oldVar = renamedMap.get(var);
|
||||
if (oldVar != null) {
|
||||
IContextParameter contextParamter = context.getContextParameter(oldVar);
|
||||
if (contextParamter != null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ContextParameterType param = ContextUtils.getContextParameterTypeByName(type, var);
|
||||
if (param != null) {
|
||||
//
|
||||
|
||||
@@ -234,7 +234,7 @@ public class ContextModeWizard extends CheckLastVersionRepositoryWizard implemen
|
||||
if (creation && isCreateContext) {
|
||||
String nextId = factory.getNextId();
|
||||
contextProperty.setId(nextId);
|
||||
contextManager.saveToEmf(contextItem.getContext());
|
||||
contextManager.saveToEmf(contextItem.getContext(), false);
|
||||
contextItem.setDefaultContext(contextManager.getDefaultContext().getName());
|
||||
final IPath path = ((PropertiesWizardPage) contextModePage.getPropertiesPage()).getDestinationPath();
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
@@ -235,7 +235,7 @@ public class ContextWizard extends CheckLastVersionRepositoryWizard implements I
|
||||
if (creation) {
|
||||
String nextId = factory.getNextId();
|
||||
contextProperty.setId(nextId);
|
||||
contextManager.saveToEmf(contextItem.getContext());
|
||||
contextManager.saveToEmf(contextItem.getContext(), false);
|
||||
contextItem.setDefaultContext(contextManager.getDefaultContext().getName());
|
||||
final IPath path = contextWizardPage0.getDestinationPath();
|
||||
final IWorkspaceRunnable op = new IWorkspaceRunnable() {
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.talend.repository.UpdateRepositoryUtils;
|
||||
*/
|
||||
public class ShowAddedContextdialog extends SelectionDialog {
|
||||
|
||||
private static final String TITILE = Messages.getString("ShowAddedContextdialog.Title"); //$NON-NLS-1$
|
||||
private static final String TITILE = Messages.getString("ShowAddedContextdialog.dialogTitle"); //$NON-NLS-1$
|
||||
|
||||
private final List<AddedContextBean> addedVarBeans = new ArrayList<AddedContextBean>();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ShowAddedContextdialog extends SelectionDialog {
|
||||
setBlockOnOpen(true);
|
||||
// setDefaultImage(ImageProvider.getImage(ECoreImage.CONTEXT_ICON));
|
||||
setTitle(TITILE);
|
||||
setMessage(Messages.getString("ShowAddedContextdialog.Messages")); //$NON-NLS-1$
|
||||
setMessage(Messages.getString("ShowAddedContextdialog.dialogMessages")); //$NON-NLS-1$
|
||||
setHelpAvailable(false);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.talend.commons.utils.workbench.extensions.IExtensionPointLimiter;
|
||||
import org.talend.core.database.EDatabase4DriverClassName;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.template.EDatabaseConnTemplate;
|
||||
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.builder.ConvertionHelper;
|
||||
@@ -334,12 +335,16 @@ public class ExtractMetaDataFromDataBase {
|
||||
return connectionStatus;
|
||||
}
|
||||
}
|
||||
if (EDatabaseTypeName.SYBASEASE == EDatabaseTypeName.getTypeFromDisplayName(dbType)) {
|
||||
boolean exsitedSybaseDB = checkSybaseDB(connection, sidOrDatabase);
|
||||
if (!exsitedSybaseDB) {
|
||||
connectionStatus.setMessageException(
|
||||
Messages.getString("ExtractMetaDataFromDataBase.DatabaseNoPresent", sidOrDatabase)); //$NON-NLS-1$
|
||||
return connectionStatus;
|
||||
String property = System.getProperty("disableCheckSybase16");//$NON-NLS-1$
|
||||
Boolean disableCheckSybase16 = StringUtils.isEmpty(property) ? false : Boolean.valueOf(property);
|
||||
if (!disableCheckSybase16) {
|
||||
if (StringUtils.equals(EDatabaseVersion4Drivers.SYBASEIQ_16.getVersionValue(), dbVersionString)) {
|
||||
boolean exsitedSybaseDB = checkSybaseDB(connection, sidOrDatabase);
|
||||
if (!exsitedSybaseDB) {
|
||||
connectionStatus.setMessageException(
|
||||
Messages.getString("ExtractMetaDataFromDataBase.DatabaseNoPresent", sidOrDatabase)); //$NON-NLS-1$
|
||||
return connectionStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.talend.commons.utils.database.EXASOLDatabaseMetaData;
|
||||
import org.talend.commons.utils.database.JtdsDatabaseMetadata;
|
||||
import org.talend.commons.utils.database.SAPHanaDataBaseMetadata;
|
||||
import org.talend.commons.utils.database.SASDataBaseMetadata;
|
||||
import org.talend.commons.utils.database.Sybase16SADatabaseMetaData;
|
||||
import org.talend.commons.utils.database.SybaseDatabaseMetaData;
|
||||
import org.talend.commons.utils.database.SybaseIQDatabaseMetaData;
|
||||
import org.talend.commons.utils.database.TeradataDataBaseMetadata;
|
||||
@@ -79,6 +80,7 @@ import org.talend.core.utils.TalendQuoteUtils;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.metadata.managment.connection.manager.HiveConnectionManager;
|
||||
import org.talend.metadata.managment.hive.EmbeddedHiveDataBaseMetadata;
|
||||
import org.talend.metadata.managment.utils.MetadataConnectionUtils;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.utils.exceptions.MissingDriverException;
|
||||
import org.talend.utils.sql.ConnectionUtils;
|
||||
@@ -275,7 +277,10 @@ public class ExtractMetaDataUtils {
|
||||
if (dbMetaData != null
|
||||
&& EDatabaseTypeName.SYBASEIQ.getDisplayName().equals(dbMetaData.getDatabaseProductName())) {
|
||||
dbMetaData = createSybaseIQFakeDatabaseMetaData(conn);
|
||||
} else {
|
||||
} else if(dbMetaData != null
|
||||
&& EDatabaseTypeName.SYBASEASE_SA.getDisplayName().equals(dbMetaData.getDatabaseProductName())) {
|
||||
dbMetaData = createSybase16SAFakeDatabaseMetaData(conn);
|
||||
}else {
|
||||
dbMetaData = createSybaseFakeDatabaseMetaData(conn);
|
||||
}
|
||||
} else if (EDatabaseTypeName.HIVE.getDisplayName().equals(dbType) && isHiveEmbeddedConn(conn)) {
|
||||
@@ -426,6 +431,11 @@ public class ExtractMetaDataUtils {
|
||||
SybaseDatabaseMetaData dmd = new SybaseDatabaseMetaData(conn);
|
||||
return dmd;
|
||||
}
|
||||
|
||||
private DatabaseMetaData createSybase16SAFakeDatabaseMetaData(Connection conn) throws SQLException {
|
||||
SybaseDatabaseMetaData dmd = new Sybase16SADatabaseMetaData(conn);
|
||||
return dmd;
|
||||
}
|
||||
|
||||
private DatabaseMetaData createSybaseIQFakeDatabaseMetaData(Connection conn) throws SQLException {
|
||||
SybaseIQDatabaseMetaData dmd = new SybaseIQDatabaseMetaData(conn);
|
||||
@@ -1038,6 +1048,7 @@ public class ExtractMetaDataUtils {
|
||||
}else if(driverJarPathArg.contains("/")){
|
||||
if (driverJarPathArg.contains(";")) {
|
||||
String jars[] = driverJarPathArg.split(";");
|
||||
List<String> jarNames = new ArrayList<>();
|
||||
for (String jar : jars) {
|
||||
String jarName = librairesManagerService.getJarNameFromMavenuri(jar);
|
||||
// TDQ-16842 msjian:sometimes for the import jdbc connection, the jarName is null
|
||||
@@ -1046,10 +1057,11 @@ public class ExtractMetaDataUtils {
|
||||
}
|
||||
// TDQ-16842~
|
||||
if (!new File(getJavaLibPath() + jarName).exists()) {
|
||||
librairesManagerService.retrieve(jarName, getJavaLibPath(), new NullProgressMonitor());
|
||||
jarNames.add(jarName);
|
||||
}
|
||||
jarPathList.add(getJavaLibPath() + jarName);
|
||||
}
|
||||
librairesManagerService.retrieve(jarNames, getJavaLibPath(), new NullProgressMonitor());
|
||||
}else{
|
||||
String jarName = librairesManagerService.getJarNameFromMavenuri(driverJarPathArg);
|
||||
if (jarName == null) {
|
||||
|
||||
@@ -37,11 +37,13 @@ import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.commons.utils.data.list.ListUtils;
|
||||
import org.talend.commons.utils.database.AS400DatabaseMetaData;
|
||||
import org.talend.commons.utils.database.DB2ForZosDataBaseMetadata;
|
||||
import org.talend.commons.utils.database.Sybase16SADatabaseMetaData;
|
||||
import org.talend.commons.utils.database.SybaseDatabaseMetaData;
|
||||
import org.talend.commons.utils.database.TeradataDataBaseMetadata;
|
||||
import org.talend.core.ICoreService;
|
||||
import org.talend.core.database.EDatabase4DriverClassName;
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.core.database.conn.version.EDatabaseVersion4Drivers;
|
||||
import org.talend.core.model.metadata.IMetadataConnection;
|
||||
import org.talend.core.model.metadata.MappingTypeRetriever;
|
||||
import org.talend.core.model.metadata.MetadataTalendType;
|
||||
@@ -252,7 +254,7 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
IMetadataConnection metaConnection, List<String> schemaFilter) {
|
||||
List<Schema> returnSchemas = new ArrayList<Schema>();
|
||||
if (dbJDBCMetadata == null || (dbConn != null && ConnectionHelper.getCatalogs(dbConn).size() > 0)
|
||||
|| ConnectionUtils.isSybase(dbJDBCMetadata)) {
|
||||
|| ConnectionUtils.isSybase(dbJDBCMetadata)) {
|
||||
return null;
|
||||
}
|
||||
ResultSet schemas = null;
|
||||
@@ -443,8 +445,14 @@ public class DBConnectionFillerImpl extends MetadataFillerImpl<DatabaseConnectio
|
||||
return catalogList;
|
||||
}
|
||||
ResultSet catalogNames = null;
|
||||
if (dbJDBCMetadata instanceof SybaseDatabaseMetaData) {
|
||||
// Whether in context mode or not, metaConnection can get the correct username always
|
||||
|
||||
if (dbJDBCMetadata instanceof Sybase16SADatabaseMetaData) {
|
||||
String username = metaConnection == null ? dbConn.getUsername() : metaConnection.getUsername();
|
||||
String database = metaConnection == null ? dbConn.getSID() : metaConnection.getDatabase();
|
||||
catalogNames = ((Sybase16SADatabaseMetaData) dbJDBCMetadata).getCatalogs(username, database);
|
||||
} else if (dbJDBCMetadata instanceof SybaseDatabaseMetaData) {
|
||||
// Whether in context mode or not, metaConnection can get the correct username
|
||||
// always
|
||||
String username = metaConnection == null ? dbConn.getUsername() : metaConnection.getUsername();
|
||||
catalogNames = ((SybaseDatabaseMetaData) dbJDBCMetadata).getCatalogs(username);
|
||||
} else {
|
||||
|
||||
@@ -576,6 +576,16 @@ public class MetadataConnectionUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSybase16SA(IMetadataConnection connectionMetadata) throws SQLException {
|
||||
boolean isSybase16SA = false;
|
||||
if(connectionMetadata!=null) {
|
||||
String dbVersionString = connectionMetadata.getDbVersionString();
|
||||
isSybase16SA = StringUtils.equals(EDatabaseVersion4Drivers.SYBASEIQ_16_SA.getVersionValue(),
|
||||
dbVersionString);
|
||||
}
|
||||
return isSybase16SA;
|
||||
}
|
||||
|
||||
public static boolean isSAPHana(DatabaseMetaData connectionMetadata) throws SQLException {
|
||||
if (connectionMetadata.getDriverName() != null && connectionMetadata.getDatabaseProductName() != null) {
|
||||
if ("HDB".equalsIgnoreCase(connectionMetadata.getDatabaseProductName().trim())) { //$NON-NLS-1$
|
||||
|
||||
@@ -255,6 +255,13 @@
|
||||
<details key="namespace" value="##targetNamespace"/>
|
||||
</eAnnotations>
|
||||
</eStructuralFeatures>
|
||||
<eStructuralFeatures xsi:type="ecore:EAttribute" name="internalId" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
|
||||
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
|
||||
<details key="kind" value="attribute"/>
|
||||
<details key="name" value="inernalId"/>
|
||||
<details key="namespace" value="##targetNamespace"/>
|
||||
</eAnnotations>
|
||||
</eStructuralFeatures>
|
||||
</eClassifiers>
|
||||
<eClassifiers xsi:type="ecore:EClass" name="ContextType">
|
||||
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute TalendFile.ecore#//ContextParameterType/repositoryContextId"/>
|
||||
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute TalendFile.ecore#//ContextParameterType/type"/>
|
||||
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute TalendFile.ecore#//ContextParameterType/value"/>
|
||||
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute TalendFile.ecore#//ContextParameterType/internalId"/>
|
||||
</genClasses>
|
||||
<genClasses ecoreClass="TalendFile.ecore#//ContextType">
|
||||
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference TalendFile.ecore#//ContextType/contextParameter"/>
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.eclipse.emf.ecore.EObject;
|
||||
*
|
||||
* <p>
|
||||
* The following features are supported:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getComment <em>Comment</em>}</li>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getName <em>Name</em>}</li>
|
||||
@@ -21,8 +22,8 @@ import org.eclipse.emf.ecore.EObject;
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getRepositoryContextId <em>Repository Context Id</em>}</li>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getType <em>Type</em>}</li>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getValue <em>Value</em>}</li>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getInternalId <em>Internal Id</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
* @see org.talend.designer.core.model.utils.emf.talendfile.TalendFilePackage#getContextParameterType()
|
||||
* @model extendedMetaData="name='ContextParameter_._type' kind='empty'"
|
||||
@@ -245,6 +246,29 @@ public interface ContextParameterType extends EObject {
|
||||
*/
|
||||
void setValue(String value);
|
||||
|
||||
/**
|
||||
* Returns the value of the '<em><b>Internal Id</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @return the value of the '<em>Internal Id</em>' attribute.
|
||||
* @see #setInternalId(String)
|
||||
* @see org.talend.designer.core.model.utils.emf.talendfile.TalendFilePackage#getContextParameterType_InternalId()
|
||||
* @model dataType="org.eclipse.emf.ecore.xml.type.String"
|
||||
* extendedMetaData="kind='attribute' name='inernalId' namespace='##targetNamespace'"
|
||||
* @generated
|
||||
*/
|
||||
String getInternalId();
|
||||
|
||||
/**
|
||||
* Sets the value of the '{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getInternalId <em>Internal Id</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @param value the new value of the '<em>Internal Id</em>' attribute.
|
||||
* @see #getInternalId()
|
||||
* @generated
|
||||
*/
|
||||
void setInternalId(String value);
|
||||
|
||||
/**
|
||||
* Specially for Password type of context, and the value should be encrypt always.
|
||||
*
|
||||
|
||||
@@ -414,6 +414,15 @@ public interface TalendFilePackage extends EPackage {
|
||||
*/
|
||||
int CONTEXT_PARAMETER_TYPE__VALUE = 6;
|
||||
|
||||
/**
|
||||
* The feature id for the '<em><b>Internal Id</b></em>' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @generated
|
||||
* @ordered
|
||||
*/
|
||||
int CONTEXT_PARAMETER_TYPE__INTERNAL_ID = 7;
|
||||
|
||||
/**
|
||||
* The number of structural features of the '<em>Context Parameter Type</em>' class.
|
||||
* <!-- begin-user-doc -->
|
||||
@@ -421,7 +430,7 @@ public interface TalendFilePackage extends EPackage {
|
||||
* @generated
|
||||
* @ordered
|
||||
*/
|
||||
int CONTEXT_PARAMETER_TYPE_FEATURE_COUNT = 7;
|
||||
int CONTEXT_PARAMETER_TYPE_FEATURE_COUNT = 8;
|
||||
|
||||
/**
|
||||
* The meta object id for the '{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl <em>Context Type</em>}' class.
|
||||
@@ -2177,6 +2186,17 @@ public interface TalendFilePackage extends EPackage {
|
||||
*/
|
||||
EAttribute getContextParameterType_Value();
|
||||
|
||||
/**
|
||||
* Returns the meta object for the attribute '{@link org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getInternalId <em>Internal Id</em>}'.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @return the meta object for the attribute '<em>Internal Id</em>'.
|
||||
* @see org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType#getInternalId()
|
||||
* @see #getContextParameterType()
|
||||
* @generated
|
||||
*/
|
||||
EAttribute getContextParameterType_InternalId();
|
||||
|
||||
/**
|
||||
* Returns the meta object for class '{@link org.talend.designer.core.model.utils.emf.talendfile.ContextType <em>Context Type</em>}'.
|
||||
* <!-- begin-user-doc -->
|
||||
@@ -3474,6 +3494,7 @@ public interface TalendFilePackage extends EPackage {
|
||||
* @see java.util.Map.Entry
|
||||
* @model keyDataType="org.eclipse.emf.ecore.EString"
|
||||
* valueDataType="org.eclipse.emf.ecore.xml.type.Base64Binary"
|
||||
* annotation="MapEntry"
|
||||
* @generated
|
||||
*/
|
||||
EClass getScreenshotsMap();
|
||||
@@ -3508,6 +3529,7 @@ public interface TalendFilePackage extends EPackage {
|
||||
* @see java.util.Map.Entry
|
||||
* @model keyDataType="org.eclipse.emf.ecore.EString"
|
||||
* valueDataType="org.eclipse.emf.ecore.EString"
|
||||
* annotation="MapEntry"
|
||||
* @generated
|
||||
*/
|
||||
EClass getAdditionalFieldMap();
|
||||
@@ -3858,6 +3880,14 @@ public interface TalendFilePackage extends EPackage {
|
||||
*/
|
||||
EAttribute CONTEXT_PARAMETER_TYPE__VALUE = eINSTANCE.getContextParameterType_Value();
|
||||
|
||||
/**
|
||||
* The meta object literal for the '<em><b>Internal Id</b></em>' attribute feature.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @generated
|
||||
*/
|
||||
EAttribute CONTEXT_PARAMETER_TYPE__INTERNAL_ID = eINSTANCE.getContextParameterType_InternalId();
|
||||
|
||||
/**
|
||||
* The meta object literal for the '{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl <em>Context Type</em>}' class.
|
||||
* <!-- begin-user-doc -->
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.talend.utils.security.StudioEncryption;
|
||||
* end-user-doc -->
|
||||
* <p>
|
||||
* The following features are implemented:
|
||||
* </p>
|
||||
* <ul>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getComment <em>Comment</em>}</li>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getName <em>Name</em>}</li>
|
||||
@@ -27,8 +28,8 @@ import org.talend.utils.security.StudioEncryption;
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getRepositoryContextId <em>Repository Context Id</em>}</li>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getType <em>Type</em>}</li>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getValue <em>Value</em>}</li>
|
||||
* <li>{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextParameterTypeImpl#getInternalId <em>Internal Id</em>}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
*
|
||||
* @generated
|
||||
*/
|
||||
@@ -182,6 +183,26 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
*/
|
||||
protected String value = VALUE_EDEFAULT;
|
||||
|
||||
/**
|
||||
* The default value of the '{@link #getInternalId() <em>Internal Id</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @see #getInternalId()
|
||||
* @generated
|
||||
* @ordered
|
||||
*/
|
||||
protected static final String INTERNAL_ID_EDEFAULT = null;
|
||||
|
||||
/**
|
||||
* The cached value of the '{@link #getInternalId() <em>Internal Id</em>}' attribute.
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @see #getInternalId()
|
||||
* @generated
|
||||
* @ordered
|
||||
*/
|
||||
protected String internalId = INTERNAL_ID_EDEFAULT;
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc --> <!-- end-user-doc -->
|
||||
* @generated
|
||||
@@ -364,6 +385,27 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
eNotify(new ENotificationImpl(this, Notification.SET, TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE, oldValue, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @generated
|
||||
*/
|
||||
public String getInternalId() {
|
||||
return internalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* <!-- begin-user-doc -->
|
||||
* <!-- end-user-doc -->
|
||||
* @generated
|
||||
*/
|
||||
public void setInternalId(String newInternalId) {
|
||||
String oldInternalId = internalId;
|
||||
internalId = newInternalId;
|
||||
if (eNotificationRequired())
|
||||
eNotify(new ENotificationImpl(this, Notification.SET, TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID, oldInternalId, internalId));
|
||||
}
|
||||
|
||||
public void setRawValue(String newValue) {
|
||||
if (newValue != null && newValue.length() > 0 && PasswordEncryptUtil.isPasswordType(getType())) {
|
||||
String encryptValue = StudioEncryption.getStudioEncryption(StudioEncryption.EncryptionKeyName.SYSTEM)
|
||||
@@ -396,6 +438,8 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
return getType();
|
||||
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE:
|
||||
return getValue();
|
||||
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID:
|
||||
return getInternalId();
|
||||
}
|
||||
return super.eGet(featureID, resolve, coreType);
|
||||
}
|
||||
@@ -427,6 +471,9 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE:
|
||||
setValue((String)newValue);
|
||||
return;
|
||||
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID:
|
||||
setInternalId((String)newValue);
|
||||
return;
|
||||
}
|
||||
super.eSet(featureID, newValue);
|
||||
}
|
||||
@@ -458,6 +505,9 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE:
|
||||
setValue(VALUE_EDEFAULT);
|
||||
return;
|
||||
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID:
|
||||
setInternalId(INTERNAL_ID_EDEFAULT);
|
||||
return;
|
||||
}
|
||||
super.eUnset(featureID);
|
||||
}
|
||||
@@ -482,6 +532,8 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
|
||||
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__VALUE:
|
||||
return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
|
||||
case TalendFilePackage.CONTEXT_PARAMETER_TYPE__INTERNAL_ID:
|
||||
return INTERNAL_ID_EDEFAULT == null ? internalId != null : !INTERNAL_ID_EDEFAULT.equals(internalId);
|
||||
}
|
||||
return super.eIsSet(featureID);
|
||||
}
|
||||
@@ -508,6 +560,8 @@ public class ContextParameterTypeImpl extends EObjectImpl implements ContextPara
|
||||
result.append(type);
|
||||
result.append(", value: ");
|
||||
result.append(value);
|
||||
result.append(", internalId: ");
|
||||
result.append(internalId);
|
||||
result.append(')');
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -92,6 +92,7 @@ import org.talend.core.prefs.IDEInternalPreferences;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.ui.CoreUIPlugin;
|
||||
import org.talend.core.ui.IInstalledPatchService;
|
||||
import org.talend.core.ui.branding.IBrandingConfiguration;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.core.ui.perspective.RestoreAllRegisteredPerspectivesProvider;
|
||||
@@ -184,7 +185,18 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
|
||||
} catch (PersistenceException e) {
|
||||
localProvider = true;
|
||||
}
|
||||
|
||||
String buildIdField = " (" + VersionUtils.getVersion() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (GlobalServiceRegister.getDefault().isServiceRegistered(IInstalledPatchService.class)) {
|
||||
IInstalledPatchService pachService = (IInstalledPatchService) GlobalServiceRegister
|
||||
.getDefault().getService(IInstalledPatchService.class);
|
||||
if (pachService != null) {
|
||||
String patchVersion = pachService.getLatestInstalledVersion(true);
|
||||
if(patchVersion != null) {
|
||||
buildIdField = " (" + patchVersion + ")"; //$NON-NLS-1$ //$NON-NLS-2$;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (TalendPropertiesUtil.isHideBuildNumber()) {
|
||||
buildIdField = ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class DynamicContentProvider extends IntroProvider {
|
||||
if (activeDataCollector && version != null && edition != null) {
|
||||
// uuid
|
||||
DefaultTokenCollector dtc = new DefaultTokenCollector();
|
||||
url.append("?version=").append(sb.toString()).append("&uid=").append(dtc.calcUniqueId()).append("&edition=") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
url.append("?version=").append(sb.toString()).append("&uid=").append(dtc.hashUniqueId()).append("&edition=") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
.append(edition);
|
||||
} else if (!activeDataCollector && version != null && edition != null) {
|
||||
url.append("?version=").append(sb.toString()).append("&edition=").append(edition); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
@@ -252,7 +252,7 @@ public class RegisterManagement {
|
||||
String version = VersionUtils.getVersion();
|
||||
|
||||
// UNIQUE_ID
|
||||
String uniqueId = DefaultTokenCollector.calcUniqueId();
|
||||
String uniqueId = DefaultTokenCollector.hashUniqueId();
|
||||
|
||||
RegisterUserPortTypeProxy proxy = new RegisterUserPortTypeProxy();
|
||||
proxy.setEndpoint("https://www.talend.com/TalendRegisterWS/registerws.php"); //$NON-NLS-1$
|
||||
@@ -464,7 +464,7 @@ public class RegisterManagement {
|
||||
URL registURL = null;
|
||||
try {
|
||||
// UNIQUE_ID
|
||||
String uniqueId = DefaultTokenCollector.calcUniqueId();
|
||||
String uniqueId = DefaultTokenCollector.hashUniqueId();
|
||||
uniqueId = uniqueId.replace("#", "%23");
|
||||
uniqueId = uniqueId.replace("$", "%24");
|
||||
uniqueId = uniqueId.replace("%", "%25");
|
||||
|
||||
@@ -471,16 +471,32 @@ public class ImportExportHandlersManager {
|
||||
|
||||
@Override
|
||||
public int compare(ImportItem o1, ImportItem o2) {
|
||||
if (o1.getRepositoryType().getType().equals("SERVICES")) {
|
||||
return -1;
|
||||
} else if (o2.getRepositoryType().getType().equals("SERVICES")) {
|
||||
return 1;
|
||||
return getImportPriority(o1) - getImportPriority(o2);
|
||||
}
|
||||
|
||||
private int getImportPriority(ImportItem item) {
|
||||
if (ERepositoryObjectType.CONTEXT.getType().equals(item.getRepositoryType().getType())) {
|
||||
return 10;
|
||||
} else if ("SERVICES".equals(item.getRepositoryType().getType())) {
|
||||
return 20;
|
||||
} else if (ERepositoryObjectType.JOBLET != null
|
||||
&& ERepositoryObjectType.JOBLET.getType().equals(item.getRepositoryType().getType())) {
|
||||
return 30;
|
||||
} else if (ERepositoryObjectType.PROCESS_ROUTELET != null
|
||||
&& ERepositoryObjectType.PROCESS_ROUTELET.getType().equals(item.getRepositoryType().getType())) {
|
||||
return 40;
|
||||
}
|
||||
return 0;
|
||||
return 100;
|
||||
}
|
||||
});
|
||||
ImportCacheHelper importCacheHelper = ImportCacheHelper.getInstance();
|
||||
try {
|
||||
|
||||
for (ImportItem itemRecord : checkedItemRecords) {
|
||||
if (itemRecord.getProperty() != null) {
|
||||
itemRecord.setOriginProperyId(itemRecord.getProperty().getId());
|
||||
}
|
||||
}
|
||||
// cache
|
||||
importCacheHelper.beforeImportItems();
|
||||
|
||||
@@ -616,6 +632,7 @@ public class ImportExportHandlersManager {
|
||||
itemRecord.getProperty().setId(id);
|
||||
try {
|
||||
changeIdManager.mapOldId2NewId(oldId, id);
|
||||
ChangeIdManager.oldANDNewIdMap.put(oldId, id);
|
||||
} catch (Exception e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
@@ -1008,6 +1025,8 @@ public class ImportExportHandlersManager {
|
||||
TimeMeasure.display = false;
|
||||
TimeMeasure.displaySteps = false;
|
||||
TimeMeasure.measureActive = false;
|
||||
|
||||
ChangeIdManager.oldANDNewIdMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ package org.talend.repository.items.importexport.handlers.imports;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -31,6 +33,9 @@ import java.util.stream.Collectors;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
@@ -52,9 +57,11 @@ import org.talend.commons.runtime.model.repository.ERepositoryStatus;
|
||||
import org.talend.commons.runtime.utils.io.FileCopyUtils;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.commons.utils.time.TimeMeasure;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.context.link.ContextLinkService;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionPackage;
|
||||
import org.talend.core.model.migration.IMigrationToolService;
|
||||
@@ -808,7 +815,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
tmpItem.getProperty().setAuthor(null);
|
||||
}
|
||||
}
|
||||
|
||||
path = changePathByNewID(path, tmpItem);
|
||||
beforeCreatingItem(selectedImportItem);
|
||||
|
||||
final RepositoryObjectCache repObjectcache = ImportCacheHelper.getInstance().getRepObjectcache();
|
||||
@@ -833,11 +840,14 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
logError(e);
|
||||
}
|
||||
if (selectedImportItem.isImported()) {
|
||||
File linkFile = findSourceContextLinkFile(selectedImportItem);
|
||||
selectedImportItem.setImportPath(path.toPortableString());
|
||||
selectedImportItem.setRepositoryType(itemType);
|
||||
selectedImportItem.setItemId(selectedImportItem.getProperty().getId());
|
||||
selectedImportItem.setItemVersion(selectedImportItem.getProperty().getVersion());
|
||||
|
||||
if (linkFile != null && linkFile.exists()) {
|
||||
copyContextLinkFile(linkFile, tmpItem);
|
||||
}
|
||||
repObjectcache.addToCache(tmpItem);
|
||||
}
|
||||
|
||||
@@ -874,11 +884,42 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isNeedDeleteOnRemote(String importingLabel, String existLabel) {
|
||||
if (importingLabel != null && importingLabel.equalsIgnoreCase(importingLabel) && !importingLabel.equals(existLabel)) {
|
||||
return true;
|
||||
protected File findSourceContextLinkFile(ImportItem importItem) {
|
||||
String techLabel = importItem.getItemProject().getTechnicalLabel();
|
||||
File projectFolder = null, linkFile = null;
|
||||
File file = new File(importItem.getPath().toPortableString());
|
||||
while (file.getParentFile() != null) {
|
||||
if (file.getParentFile().getName().equals(techLabel)) {
|
||||
projectFolder = file.getParentFile();
|
||||
break;
|
||||
}
|
||||
file = file.getParentFile();
|
||||
}
|
||||
if (projectFolder != null) {
|
||||
linkFile = new File(
|
||||
ContextLinkService.calLinksFilePath(projectFolder.getAbsolutePath(), importItem.getOriginProperyId()));
|
||||
}
|
||||
return linkFile;
|
||||
}
|
||||
|
||||
protected void copyContextLinkFile(File sourceLinkFile, Item item)
|
||||
throws IOException, PersistenceException, CoreException {
|
||||
String techLabel = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
|
||||
IProject iProject = ResourceUtils.getProject(techLabel);
|
||||
IFolder settingFolder = ResourceUtils.getFolder(iProject, RepositoryConstants.SETTING_DIRECTORY, false);
|
||||
if (!settingFolder.exists()) {
|
||||
settingFolder.create(true, true, null);
|
||||
}
|
||||
IFolder linksFolder = settingFolder.getFolder(ContextLinkService.LINKS_FOLDER_NAME);
|
||||
if (!linksFolder.exists()) {
|
||||
linksFolder.create(true, true, null);
|
||||
}
|
||||
IFile linkFile = linksFolder.getFile(ContextLinkService.getLinkFileName(item.getProperty().getId()));
|
||||
if (!linkFile.exists()) {
|
||||
ResourceUtils.createFile(new FileInputStream(sourceLinkFile), linkFile);
|
||||
} else {
|
||||
ResourceUtils.setFileContent(new FileInputStream(sourceLinkFile), linkFile);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -994,7 +1035,10 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
|
||||
}
|
||||
|
||||
protected void beforeCreatingItem(ImportItem selectedImportItem) {
|
||||
// noting to do specially.
|
||||
}
|
||||
|
||||
protected IPath changePathByNewID(IPath path, Item item) {
|
||||
return path;
|
||||
}
|
||||
|
||||
protected void afterCreatedItem(ResourcesManager resManager, ImportItem selectedImportItem) throws Exception {
|
||||
|
||||
@@ -73,6 +73,8 @@ public class ImportItem {
|
||||
|
||||
private boolean removeProjectStatslog;
|
||||
|
||||
private String originProperyId;
|
||||
|
||||
/**
|
||||
* add for tdm
|
||||
*/
|
||||
@@ -392,6 +394,14 @@ public class ImportItem {
|
||||
this.isSystemItem = isSystemItem;
|
||||
}
|
||||
|
||||
public String getOriginProperyId() {
|
||||
return originProperyId;
|
||||
}
|
||||
|
||||
public void setOriginProperyId(String originProperyId) {
|
||||
this.originProperyId = originProperyId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.apache.log4j.Priority;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.talend.commons.exception.ExceptionHandler;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.model.context.link.ContextLinkService;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
@@ -71,6 +72,8 @@ public class ChangeIdManager {
|
||||
private Map<String, Collection<String>> refIds2ItemIdsMap = new HashMap<String, Collection<String>>();
|
||||
|
||||
private Map<String, String> oldId2NewIdMap = new HashMap<String, String>();
|
||||
|
||||
public static Map<String, String> oldANDNewIdMap = new HashMap<String, String>();
|
||||
|
||||
private Set<String> idsNeed2CheckRefs = new HashSet<String>();
|
||||
|
||||
@@ -300,6 +303,7 @@ public class ChangeIdManager {
|
||||
} else {
|
||||
throw new Exception("Unsupported id change: id[" + property.getId() + "], name[" + property.getLabel() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
ContextLinkService.getInstance().changeRepositoryId(item, old2NewMap);
|
||||
if (modified) {
|
||||
ProxyRepositoryFactory.getInstance().save(project, item);
|
||||
RelationshipItemBuilder.getInstance().addOrUpdateItem(property.getItem());
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.talend.core.PluginChecker;
|
||||
import org.talend.core.hadoop.IHadoopClusterService;
|
||||
import org.talend.core.hadoop.repository.HadoopRepositoryUtil;
|
||||
import org.talend.core.model.properties.Item;
|
||||
import org.talend.core.model.properties.ItemState;
|
||||
import org.talend.core.model.properties.Project;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.ui.ITestContainerProviderService;
|
||||
@@ -234,9 +235,12 @@ public class ImportNodesBuilder {
|
||||
parentImportNode = findAndCreateFolderNode(typeImportNode, path);
|
||||
parentImportNode.setItemRecord(itemRecord);
|
||||
} else {
|
||||
String path = item.getState().getPath();
|
||||
if (StringUtils.isNotEmpty(path)) { // if has path, will find the real path node.
|
||||
parentImportNode = findAndCreateFolderNode(typeImportNode, new Path(path));
|
||||
ItemState state = item.getState();
|
||||
if (state != null) {
|
||||
String path = state.getPath();
|
||||
if (StringUtils.isNotEmpty(path)) { // if has path, will find the real path node.
|
||||
parentImportNode = findAndCreateFolderNode(typeImportNode, new Path(path));
|
||||
}
|
||||
}
|
||||
ItemImportNode itemNode = new ItemImportNode(itemRecord);
|
||||
parentImportNode.addChild(itemNode);
|
||||
|
||||
@@ -90,6 +90,7 @@ import org.talend.commons.utils.io.FilesUtils;
|
||||
import org.talend.commons.utils.workbench.resources.ResourceUtils;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.context.link.ContextLinkService;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.general.TalendNature;
|
||||
import org.talend.core.model.metadata.MetadataManager;
|
||||
@@ -170,7 +171,12 @@ import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.projectsetting.ProjectPreferenceManager;
|
||||
import org.talend.core.ui.branding.IBrandingService;
|
||||
import org.talend.cwm.helper.ConnectionHelper;
|
||||
import org.talend.cwm.helper.ResourceHelper;
|
||||
import org.talend.cwm.helper.SubItemHelper;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.impl.TalendFilePackageImpl;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.RepositoryWorkUnit;
|
||||
import org.talend.repository.localprovider.exceptions.IncorrectFileException;
|
||||
@@ -1346,11 +1352,17 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
|
||||
// Getting the folder :
|
||||
try {
|
||||
IFolder folder = ResourceUtils.getFolder(fsProject, completePath, true);
|
||||
IFolder folder = null;
|
||||
try {
|
||||
folder = ResourceUtils.getFolder(fsProject, completePath, true);
|
||||
} catch (PersistenceException e) {
|
||||
}
|
||||
// changed by hqzhang for TDI-20600, FolderHelper.deleteFolder will fire the DeletedFolderListener in
|
||||
// ProjectRepoAbstractContentProvider class to refresh the node, if don't delete resource first, the deleted
|
||||
// foler display in repository view
|
||||
deleteResource(folder);
|
||||
if (folder != null && folder.exists()) {
|
||||
deleteResource(folder);
|
||||
}
|
||||
} finally {
|
||||
// even if the folder do not exist anymore, clean the list on the project
|
||||
getFolderHelper(project.getEmfProject()).deleteFolder(completePath);
|
||||
@@ -1790,6 +1802,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
for (Resource resource : affectedResources) {
|
||||
deleteResource(resource, isDeleteOnRemote);
|
||||
}
|
||||
ContextLinkService.getInstance().deleteContextLinkJsonFile(currentProperty.getItem());
|
||||
|
||||
// ADD msjian TDQ-6791 2013-2-20:when the resource is invalid(null), delete its file
|
||||
EList<EObject> eCrossReferences = currentItem.eCrossReferences();
|
||||
@@ -2365,8 +2378,37 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
|
||||
private Resource create(IProject project, ContextItem item, IPath path) throws PersistenceException {
|
||||
Resource itemResource = xmiResourceManager.createItemResource(project, item, path, ERepositoryObjectType.CONTEXT, false);
|
||||
itemResource.getContents().addAll(item.getContext());
|
||||
Map<String, String> contextIdMaps = new HashMap<String, String>();
|
||||
Map<String, Map<String, String>> paramIdMaps = new HashMap<String, Map<String, String>>();
|
||||
EList list = item.getContext();
|
||||
for (Object obj : list) {
|
||||
if (obj instanceof ContextType) {
|
||||
ContextType contextType = (ContextType) obj;
|
||||
contextIdMaps.put(contextType.getName(), ResourceHelper.getUUID(contextType));
|
||||
Map<String, String> idMap = new HashMap<String, String>();
|
||||
paramIdMaps.put(contextType.getName(), idMap);
|
||||
for (Object op : contextType.getContextParameter()) {
|
||||
if (op instanceof ContextParameterType) {
|
||||
ContextParameterType p = (ContextParameterType) op;
|
||||
idMap.put(p.getName(), ResourceHelper.getUUID(p));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
itemResource.getContents().addAll(item.getContext());
|
||||
ContextType[] newContextArray = EcoreUtil
|
||||
.getObjectsByType(itemResource.getContents(), TalendFilePackageImpl.eINSTANCE.getContextType())
|
||||
.toArray(new ContextType[0]);
|
||||
for (int i = 0; i < newContextArray.length; i++) {
|
||||
ContextTypeImpl newContextType = (ContextTypeImpl) newContextArray[i];
|
||||
ResourceHelper.setUUid(newContextType, contextIdMaps.get(newContextType.getName()));
|
||||
Map<String, String> idMap = paramIdMaps.get(newContextType.getName());
|
||||
for (int j = 0; j < newContextType.getContextParameter().size(); j++) {
|
||||
ContextParameterType newParam = (ContextParameterType) newContextType.getContextParameter().get(j);
|
||||
ResourceHelper.setUUid(newParam, idMap.get(newParam.getName()));
|
||||
}
|
||||
}
|
||||
return itemResource;
|
||||
}
|
||||
|
||||
@@ -2623,6 +2665,11 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
}
|
||||
this.copyScreenshotFlag = false;
|
||||
}
|
||||
saveContextLinkInfo(item);
|
||||
}
|
||||
|
||||
private void saveContextLinkInfo(Item item) throws PersistenceException {
|
||||
ContextLinkService.getInstance().saveContextLink(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -3022,7 +3069,7 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
|
||||
xmiResourceManager.saveResource(screenshotsResource);
|
||||
xmiResourceManager.saveResource(itemResource);
|
||||
xmiResourceManager.saveResource(propertyResource);
|
||||
|
||||
saveContextLinkInfo(item);
|
||||
if (isImportItem.length == 0 || !isImportItem[0]) {
|
||||
saveProject(project);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.talend.core.model.properties.DatabaseConnectionItem;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.repository.RepositoryObject;
|
||||
import org.talend.core.model.update.RepositoryUpdateManager;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.repository.ui.actions.metadata.AbstractCreateAction;
|
||||
import org.talend.core.runtime.services.IGenericDBService;
|
||||
@@ -175,12 +176,14 @@ public class CreateConnectionAction extends AbstractCreateAction {
|
||||
Property property = node.getObject().getProperty();
|
||||
Property updatedProperty = null;
|
||||
try {
|
||||
if (!creation) {
|
||||
RepositoryUpdateManager.updateConnectionContextParam(node);
|
||||
}
|
||||
updatedProperty = ProxyRepositoryFactory.getInstance().getUptodateProperty(
|
||||
new Project(ProjectManager.getInstance().getProject(property.getItem())), property);
|
||||
} catch (PersistenceException e) {
|
||||
ExceptionHandler.process(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DatabaseWizard databaseWizard;
|
||||
|
||||
@@ -17,7 +17,6 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -262,7 +261,7 @@ public class UpdateTools {
|
||||
File dropFile = new File(pluginFolderFile, "droplist");
|
||||
if (dropFile.exists()) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Files.lines(dropFile.toPath()).map(File::new).filter(f -> !f.delete())
|
||||
Files.lines(dropFile.toPath()).map(File::new).filter(f -> deleteBundle(f))
|
||||
.forEach(f -> builder.append(f.getAbsolutePath()).append(LINE_SEPARATOR));
|
||||
if (builder.length() > 0) {
|
||||
// if deletion for some bundle failed
|
||||
@@ -273,4 +272,15 @@ public class UpdateTools {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean deleteBundle(File file) {
|
||||
if (!file.exists()) {
|
||||
return false;
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
FilesUtils.deleteFolder(file, true);
|
||||
return file.exists();
|
||||
}
|
||||
return !file.delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
-->
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -40,7 +40,7 @@
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
<version>1.2.17</version>
|
||||
<type>bundle</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?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">
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
<!--
|
||||
Copyright (C) 2010 Talend Inc. - www.talend.com
|
||||
-->
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -40,7 +40,7 @@
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.16</version>
|
||||
<version>1.2.17</version>
|
||||
<type>bundle</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
// ============================================================================
|
||||
package org.talend.utils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -21,9 +23,11 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class ProductVersion implements Comparable<ProductVersion> {
|
||||
|
||||
private static final Pattern THREE_DIGIT_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+).*");
|
||||
private static final Pattern THREE_DIGIT_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+).*"); //$NON-NLS-1$
|
||||
|
||||
private static final Pattern EXTENDED_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*");
|
||||
private static final Pattern EXTENDED_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*"); //$NON-NLS-1$
|
||||
|
||||
private static final Pattern FOUR_PART_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)\\.(.*)"); //$NON-NLS-1$
|
||||
|
||||
private int major;
|
||||
|
||||
@@ -33,6 +37,10 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
|
||||
private boolean setMicro = false;
|
||||
|
||||
private String extraInfo;
|
||||
|
||||
private boolean setExtraInfo = false;
|
||||
|
||||
/**
|
||||
* ProductVersion constructor.
|
||||
*
|
||||
@@ -48,6 +56,20 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
this.setMicro = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* ProductVersion constructor.
|
||||
*
|
||||
* @param major
|
||||
* @param minor
|
||||
* @param micro
|
||||
* @param extraInfo
|
||||
*/
|
||||
public ProductVersion(int major, int minor, int micro, String extraInfo) {
|
||||
this(major, minor, micro);
|
||||
this.extraInfo = extraInfo;
|
||||
this.setExtraInfo = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* ProductVersion constructor.
|
||||
*
|
||||
@@ -62,6 +84,17 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
this.setMicro = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* this ProductVersion constructor generate a ProductVersion with versionDate.
|
||||
*
|
||||
* @param ProductVersion
|
||||
* @param Date
|
||||
*/
|
||||
public ProductVersion(ProductVersion productVersion, Date versionDate) {
|
||||
this(productVersion.getMajor(), productVersion.getMinor(), productVersion.getMicro(),
|
||||
new SimpleDateFormat("yyyyMMdd").format(versionDate)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/**
|
||||
* Method "fromString".
|
||||
*
|
||||
@@ -73,6 +106,7 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
if (!extendedVersion) {
|
||||
return fromString(version);
|
||||
}
|
||||
|
||||
Matcher matcher = EXTENDED_PATTERN.matcher(version);
|
||||
if (matcher.find()) {
|
||||
int major = Integer.parseInt(matcher.group(1));
|
||||
@@ -88,6 +122,29 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* DOC msjian Comment method "fromString".
|
||||
*
|
||||
* @param version the version to parse
|
||||
* @param extendedVersion true if the version could be a 2 or 3 digit version
|
||||
* @param isFourPartVersion true if the version contains 4 part like: 7.3.1.20200507 or 7.3.1.20200417_1111-patch
|
||||
* @return the product version
|
||||
*/
|
||||
public static ProductVersion fromString(String version, boolean extendedVersion, boolean isFourPartVersion) {
|
||||
if (isFourPartVersion) {
|
||||
Matcher matcher4 = FOUR_PART_PATTERN.matcher(version);
|
||||
if (matcher4.find() && matcher4.groupCount() == 4) {
|
||||
int major = Integer.parseInt(matcher4.group(1));
|
||||
int minor = Integer.parseInt(matcher4.group(2));
|
||||
String microStr = matcher4.group(3);
|
||||
String extraInfo = matcher4.group(4);
|
||||
int micro = Integer.parseInt(microStr);
|
||||
return new ProductVersion(major, minor, micro, extraInfo);
|
||||
}
|
||||
}
|
||||
return fromString(version, extendedVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method "fromString".
|
||||
*
|
||||
@@ -121,6 +178,17 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
if (setExtraInfo) {
|
||||
if (other.setExtraInfo) {
|
||||
return extraInfo.compareTo(other.extraInfo);
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
if (other.setExtraInfo) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -131,6 +199,9 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
result = prime * result + major;
|
||||
result = prime * result + micro;
|
||||
result = prime * result + minor;
|
||||
if (setExtraInfo) {
|
||||
result = prime * result + extraInfo.length();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -155,6 +226,11 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
if (micro != other.micro) {
|
||||
return false;
|
||||
}
|
||||
if (setExtraInfo && other.setExtraInfo) {
|
||||
if (!extraInfo.equals(other.extraInfo)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -163,12 +239,16 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
public String toString() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(major);
|
||||
stringBuilder.append(".");
|
||||
stringBuilder.append("."); //$NON-NLS-1$
|
||||
stringBuilder.append(minor);
|
||||
if (setMicro) {
|
||||
stringBuilder.append(".");
|
||||
stringBuilder.append("."); //$NON-NLS-1$
|
||||
stringBuilder.append(micro);
|
||||
}
|
||||
if (setExtraInfo) {
|
||||
stringBuilder.append("."); //$NON-NLS-1$
|
||||
stringBuilder.append(extraInfo);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@@ -183,4 +263,16 @@ public class ProductVersion implements Comparable<ProductVersion> {
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
|
||||
public boolean isSetMicro() {
|
||||
return setMicro;
|
||||
}
|
||||
|
||||
public String getExtraInfo() {
|
||||
return this.extraInfo;
|
||||
}
|
||||
|
||||
public boolean isSetExtraInfo() {
|
||||
return setExtraInfo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class StudioEncryption {
|
||||
|
||||
private static final String PREFIX_PASSWORD_M3 = "ENC:[";
|
||||
|
||||
private static final String PREFIX_PASSWORD = "enc:"; //$NON-NLS-1$
|
||||
public static final String PREFIX_PASSWORD = "enc:"; //$NON-NLS-1$
|
||||
|
||||
private static final Pattern REG_ENCRYPTED_DATA_SYSTEM = Pattern
|
||||
.compile("^enc\\:system\\.encryption\\.key\\.v\\d\\:\\p{Print}+");
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<talend.nexus.url>https://artifacts-zl.talend.com</talend.nexus.url>
|
||||
<org.talend.daikon.crypto-utils.version>1.7.0</org.talend.daikon.crypto-utils.version>
|
||||
<org.talend.daikon.crypto-utils.version>1.15.0</org.talend.daikon.crypto-utils.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
|
||||
@@ -73,21 +73,6 @@ public class VersionUtilsTest {
|
||||
assertEquals(talendVersion, VersionUtils.getMojoVersion("ci.builder.version"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetPluginVersion__MojoProperties() throws Exception {
|
||||
String talendVersion = VersionUtils.getTalendVersion();
|
||||
assertEquals(talendVersion + "-SNAPSHOT", VersionUtils.getMojoVersion("ci.builder.version"));
|
||||
if (mojo_properties.exists()) {
|
||||
mojo_properties.delete();
|
||||
}
|
||||
mojo_properties.createNewFile();
|
||||
setPropertiesValue(mojo_properties, "ci.builder.version", talendVersion + "-patch1");
|
||||
assertEquals(talendVersion + "-patch1", VersionUtils.getMojoVersion("ci.builder.version"));
|
||||
|
||||
setPropertiesValue(mojo_properties, "ci.builder.version", "6.0.0");
|
||||
assertEquals(talendVersion + "-SNAPSHOT", VersionUtils.getMojoVersion("ci.builder.version"));
|
||||
}
|
||||
|
||||
private void setPropertiesValue(File propertiesFile, String key, String value) throws Exception {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(key, value);
|
||||
|
||||
@@ -12,11 +12,16 @@
|
||||
// ============================================================================
|
||||
package org.talend.core.model.utils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.talend.core.model.context.JobContext;
|
||||
@@ -25,6 +30,8 @@ import org.talend.core.model.context.JobContextParameter;
|
||||
import org.talend.core.model.metadata.types.JavaTypesManager;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.repository.IRepositoryPrefConstants;
|
||||
import org.talend.core.prefs.ITalendCorePrefConstants;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
@@ -97,6 +104,8 @@ public class ContextParameterUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testGetVariableFromCode4String() {
|
||||
IEclipsePreferences coreUIPluginNode = new InstanceScope().getNode(ITalendCorePrefConstants.CoreUIPlugin_ID);
|
||||
coreUIPluginNode.putBoolean(IRepositoryPrefConstants.ALLOW_SPECIFIC_CHARACTERS_FOR_SCHEMA_COLUMNS, true);
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode(""));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("abc"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("123"));
|
||||
@@ -116,10 +125,21 @@ public class ContextParameterUtilsTest {
|
||||
Assert.assertEquals("Podgląd", ContextParameterUtils.getVariableFromCode("context.Podgląd"));
|
||||
Assert.assertEquals("Română", ContextParameterUtils.getVariableFromCode("context.Română"));
|
||||
Assert.assertEquals("русский", ContextParameterUtils.getVariableFromCode("context.русский"));
|
||||
|
||||
coreUIPluginNode.putBoolean(IRepositoryPrefConstants.ALLOW_SPECIFIC_CHARACTERS_FOR_SCHEMA_COLUMNS, false);
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.汉语"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.日本語"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.Ελληνική"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.Français"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.Podgląd"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.Română"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.русский"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetVariableFromCode4Context() {
|
||||
IEclipsePreferences coreUIPluginNode = new InstanceScope().getNode(ITalendCorePrefConstants.CoreUIPlugin_ID);
|
||||
coreUIPluginNode.putBoolean(IRepositoryPrefConstants.ALLOW_SPECIFIC_CHARACTERS_FOR_SCHEMA_COLUMNS, true);
|
||||
String var = ContextParameterUtils.getVariableFromCode("context.abc");
|
||||
Assert.assertEquals("abc", var);
|
||||
|
||||
@@ -254,6 +274,16 @@ public class ContextParameterUtilsTest {
|
||||
|
||||
var = ContextParameterUtils.getVariableFromCode("context.русский-123");
|
||||
Assert.assertEquals("русский", var);
|
||||
|
||||
coreUIPluginNode.putBoolean(IRepositoryPrefConstants.ALLOW_SPECIFIC_CHARACTERS_FOR_SCHEMA_COLUMNS, false);
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.マイSQL"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.汉语"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.Ελληνική"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.Română_123"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.русский"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.マイSQL"));
|
||||
Assert.assertNull(ContextParameterUtils.getVariableFromCode("context.Podgląd"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -281,6 +311,8 @@ public class ContextParameterUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testIsValidParameterName() {
|
||||
IEclipsePreferences coreUIPluginNode = new InstanceScope().getNode(ITalendCorePrefConstants.CoreUIPlugin_ID);
|
||||
coreUIPluginNode.putBoolean(IRepositoryPrefConstants.ALLOW_SPECIFIC_CHARACTERS_FOR_SCHEMA_COLUMNS, true);
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("abc"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("abc123"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("abc_123"));
|
||||
@@ -290,6 +322,22 @@ public class ContextParameterUtilsTest {
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("abc%de"));
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("a*&^e"));
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("123abc"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("中文"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("日本語"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("Ελληνική"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("Français"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("Podgląd"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("Română"));
|
||||
assertTrue(ContextParameterUtils.isValidParameterName("русский"));
|
||||
|
||||
coreUIPluginNode.putBoolean(IRepositoryPrefConstants.ALLOW_SPECIFIC_CHARACTERS_FOR_SCHEMA_COLUMNS, false);
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("中文"));
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("日本語"));
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("Ελληνική"));
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("Français"));
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("Podgląd"));
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("Română"));
|
||||
assertFalse(ContextParameterUtils.isValidParameterName("русский"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -544,47 +544,4 @@ public class ProcessorUtilitiesTest {
|
||||
node.getElementParameter().add(jobIdParam);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testWriteLog4j2ConfToFile() throws IOException {
|
||||
String configFilePath = System.getProperty("java.io.tmpdir") + "/log4j2-"+UUID.randomUUID()+".xml";
|
||||
File configFile = new File(configFilePath);
|
||||
ProcessorUtilities.writeLog4j2ConfToFile(configFile, Level.getLevel("INFO"));
|
||||
String actualContent = Files.lines(Paths.get(configFilePath), StandardCharsets.UTF_8).collect(Collectors.joining("\n"));
|
||||
String encodingAttr = actualContent.contains("encoding") ? "encoding='UTF-8'" : "";
|
||||
String expectedContent = "<?xml version='1.0' "+encodingAttr+"?>\n" +
|
||||
"<Configuration>\n" +
|
||||
" <Appenders>\n" +
|
||||
" <Console name=\"Console\" target=\"SYSTEM_OUT\">\n" +
|
||||
" <PatternLayout pattern=\"[%-5level] %d{HH:mm:ss} %logger{36}- %msg%n\"/>\n" +
|
||||
" </Console>\n" +
|
||||
" </Appenders>\n" +
|
||||
" <Loggers>\n" +
|
||||
" <Root level=\"INFO\">\n" +
|
||||
" <AppenderRef ref=\"Console\"/>\n" +
|
||||
" </Root>\n" +
|
||||
" </Loggers>\n" +
|
||||
"</Configuration>";
|
||||
|
||||
assertEquals(expectedContent, actualContent);
|
||||
configFile.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddFileToJar() throws FileNotFoundException, IOException {
|
||||
String configFileName = "log4j2-"+UUID.randomUUID()+".xml";
|
||||
String configFilePath = System.getProperty("java.io.tmpdir") + "/" + configFileName;
|
||||
File configFile = new File(configFilePath);
|
||||
ProcessorUtilities.writeLog4j2ConfToFile(configFile, Level.getLevel("INFO"));
|
||||
String jarFilePath = System.getProperty("java.io.tmpdir") + "/log4j2.xml.jar";
|
||||
ProcessorUtilities.addFileToJar(configFilePath, jarFilePath);
|
||||
JarInputStream jIs = new JarInputStream(new FileInputStream(jarFilePath));
|
||||
JarEntry entry = jIs.getNextJarEntry();
|
||||
jIs.closeEntry();
|
||||
jIs.close();
|
||||
assertEquals("log4j2.xml", entry.getName());
|
||||
configFile.delete();
|
||||
new File(jarFilePath).delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// 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.creator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/*
|
||||
* Created by bhe on May 9, 2020
|
||||
*/
|
||||
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";
|
||||
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";
|
||||
|
||||
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";
|
||||
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";
|
||||
|
||||
String actualSh = CreateMavenJobPom.normalizeSpaces(inputSh);
|
||||
assertEquals(expectSh, actualSh);
|
||||
|
||||
String actualBat = CreateMavenJobPom.normalizeSpaces(inputBat);
|
||||
assertEquals(expectBat, actualBat);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,6 +23,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.maven.model.Dependency;
|
||||
@@ -31,10 +33,17 @@ import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -45,6 +54,7 @@ import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.nexus.TalendMavenResolver;
|
||||
import org.talend.core.runtime.maven.MavenArtifact;
|
||||
import org.talend.core.runtime.maven.MavenConstants;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.designer.maven.model.TalendJavaProjectConstants;
|
||||
import org.talend.designer.maven.model.TalendMavenConstants;
|
||||
import org.talend.designer.maven.template.MavenTemplateManager;
|
||||
@@ -598,6 +608,96 @@ public class PomUtilTest {
|
||||
testFolder.delete(true, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_generatePom_DeadLock() throws Throwable {
|
||||
final Semaphore lock = new Semaphore(1);
|
||||
try {
|
||||
lock.acquire();
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
Throwable ex[] = new Throwable[1];
|
||||
final AtomicBoolean job1Started = new AtomicBoolean(false);
|
||||
Job job1 = new Job("Lock thread") {
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
job1Started.set(true);
|
||||
lock.acquire();
|
||||
} catch (Throwable e) {
|
||||
ex[0] = e;
|
||||
} finally {
|
||||
lock.release();
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job1.setRule(workspace.getRoot());
|
||||
job1.schedule();
|
||||
while (!job1Started.get()) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
if (ex[0] != null) {
|
||||
throw ex[0];
|
||||
}
|
||||
|
||||
Job job2 = new Job("Test thread") {
|
||||
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
MavenArtifact mavenArtifact = MavenUrlHelper.parseMvnUrl("mvn:org.talend.test/subJob1/1.0.0/jar");
|
||||
String pomPath = PomUtil.generatePom(mavenArtifact);
|
||||
File pomFile = new File(pomPath);
|
||||
if (!pomFile.exists()) {
|
||||
throw new Exception("Generate pom file failed!");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
ex[0] = e;
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
};
|
||||
job2.schedule();
|
||||
/**
|
||||
* Normally 10s is enough for PomUtil#generatePom, unless the disk is very very slow.
|
||||
*/
|
||||
boolean succeed = job2.join(10000, new NullProgressMonitor());
|
||||
if (ex[0] != null) {
|
||||
throw ex[0];
|
||||
}
|
||||
job2.cancel();
|
||||
Assert.assertTrue("Dead lock again!", succeed);
|
||||
} finally {
|
||||
lock.release();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_generatePom_runInWorkspaceRunnable() throws Throwable {
|
||||
IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
Throwable ex[] = new Throwable[1];
|
||||
workspace.run(new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
try {
|
||||
MavenArtifact mavenArtifact = MavenUrlHelper.parseMvnUrl("mvn:org.talend.test/subJob1/1.0.0/jar");
|
||||
String pomPath = PomUtil.generatePom(mavenArtifact);
|
||||
File pomFile = new File(pomPath);
|
||||
if (!pomFile.exists()) {
|
||||
throw new Exception("Generate pom file failed!");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
ex[0] = e;
|
||||
}
|
||||
}
|
||||
}, workspace.getRoot(), IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
|
||||
if (ex[0] != null) {
|
||||
throw ex[0];
|
||||
}
|
||||
Assert.assertTrue("As long as no exception, succeed", true);
|
||||
}
|
||||
|
||||
private Model creatModel(String artifactId) {
|
||||
Model model = new Model();
|
||||
model.setModelVersion("4.0.0");
|
||||
|
||||
@@ -12,32 +12,25 @@
|
||||
// ============================================================================
|
||||
package org.talend.metadata.managment.ui.utils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.emf.common.util.BasicEList;
|
||||
import org.eclipse.emf.common.util.EList;
|
||||
import org.junit.Test;
|
||||
import org.talend.commons.utils.VersionUtils;
|
||||
import org.talend.core.context.Context;
|
||||
import org.talend.core.context.RepositoryContext;
|
||||
import org.talend.core.model.context.JobContext;
|
||||
import org.talend.core.model.context.JobContextManager;
|
||||
import org.talend.core.model.context.JobContextParameter;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.ConnectionFactory;
|
||||
import org.talend.core.model.metadata.types.JavaTypesManager;
|
||||
import org.talend.core.model.process.IContext;
|
||||
import org.talend.core.model.process.IContextManager;
|
||||
import org.talend.core.model.process.IContextParameter;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.ItemState;
|
||||
import org.talend.core.model.properties.PropertiesFactory;
|
||||
import org.talend.core.model.properties.Property;
|
||||
import org.talend.core.runtime.CoreRuntimePlugin;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.TalendFileFactory;
|
||||
@@ -108,7 +101,8 @@ public class ConnectionContextHelperTest {
|
||||
contextItem.setProperty(myContextProperty);
|
||||
contextItem.setDefaultContext("Default");
|
||||
|
||||
Set<String> set = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextManager, false);
|
||||
Set<String> set = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextManager, false,
|
||||
new HashMap<String, String>());
|
||||
assertTrue(set.size() == 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,8 @@ public class UpdateToolsTest {
|
||||
} else {
|
||||
bundle = new File(pluginFolder, fileName);
|
||||
bundle.mkdir();
|
||||
File testFile = new File(bundle, "test.txt");
|
||||
testFile.createNewFile();
|
||||
}
|
||||
testFiles.add(bundle);
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ package org.talend.utils;
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.talend.utils.ProductVersion;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/***/
|
||||
public class ProductVersionTest extends TestCase {
|
||||
@@ -28,6 +28,14 @@ public class ProductVersionTest extends TestCase {
|
||||
}
|
||||
|
||||
public void testParse() {
|
||||
assertEquals(new ProductVersion(7, 3, 1, "20200417_1111-patch"),
|
||||
ProductVersion.fromString("7.3.1.20200417_1111-patch", true, true));
|
||||
assertEquals(new ProductVersion(7, 3, 1, "20200507"), ProductVersion.fromString("7.3.1.20200507", true, true));
|
||||
|
||||
assertEquals(new ProductVersion(7, 3, 1), ProductVersion.fromString("7.3.1.20200417_1111-patch", true));
|
||||
assertEquals(new ProductVersion(7, 3, 1), ProductVersion.fromString("7.3.1.20200507", true));
|
||||
|
||||
|
||||
assertEquals(new ProductVersion(1, 2, 3), ProductVersion.fromString("1.2.3"));
|
||||
assertEquals(new ProductVersion(1, 2, 3), ProductVersion.fromString("1.2.3.r12345"));
|
||||
assertEquals(new ProductVersion(1, 2, 3), ProductVersion.fromString("1.2.3RC1"));
|
||||
@@ -40,6 +48,7 @@ public class ProductVersionTest extends TestCase {
|
||||
assertEquals(new ProductVersion(9, 2), ProductVersion.fromString("Oracle9i Release 9.2.0.1.0 - Production", true));
|
||||
assertEquals(new ProductVersion(9, 2), ProductVersion.fromString("Oracle9i Release 9.2.0.1.0 - Production\n"
|
||||
+ "JServer Release 9.2.0.1.0 - Production", true));
|
||||
|
||||
}
|
||||
|
||||
public void testCompare() {
|
||||
@@ -71,5 +80,18 @@ public class ProductVersionTest extends TestCase {
|
||||
fail();
|
||||
}
|
||||
|
||||
ProductVersion productVersion1 = new ProductVersion(7, 3, 1, "20200417_1111-patch");
|
||||
ProductVersion productVersion2 = new ProductVersion(7, 3, 1, "20200507");
|
||||
ProductVersion productVersion3 = ProductVersion.fromString("7.3.1.20200417_1111-patch", true, true);
|
||||
ProductVersion productVersion4 = new ProductVersion(7, 3, 1);
|
||||
Calendar calender = Calendar.getInstance();
|
||||
calender.set(2020, 4, 7);
|
||||
ProductVersion productVersion5 = new ProductVersion(productVersion4, calender.getTime());
|
||||
assertTrue(productVersion1.compareTo(productVersion2) < 0);
|
||||
assertTrue(productVersion1.compareTo(productVersion3) == 0);
|
||||
assertTrue(productVersion1.compareTo(productVersion4) > 0);
|
||||
assertTrue(productVersion2.compareTo(productVersion4) > 0);
|
||||
assertTrue(productVersion2.compareTo(productVersion5) == 0);
|
||||
assertTrue(productVersion1.compareTo(productVersion5) < 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user