Compare commits
4 Commits
patchrelea
...
patch/7.3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0011cc14a7 | ||
|
|
093d78f386 | ||
|
|
e80c5726e1 | ||
|
|
fffd887f39 |
@@ -791,6 +791,15 @@
|
||||
name="UpdateModuleListInComponentsMigrationTask"
|
||||
version="7.3.1">
|
||||
</projecttask>
|
||||
<projecttask
|
||||
beforeLogon="false"
|
||||
breaks="7.3.0"
|
||||
class="org.talend.designer.core.utils.FixModuleListInBDJDBCMigrationTask"
|
||||
description="Fix context used inside module list."
|
||||
id="org.talend.designer.core.utils.FixModuleListInBDJDBCMigrationTask"
|
||||
name="FixModuleListInBDJDBCMigrationTask"
|
||||
version="7.3.1">
|
||||
</projecttask>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.talend.repository.projectsetting_page">
|
||||
|
||||
@@ -150,16 +150,20 @@ public class ChangeConnTextCommand extends Command {
|
||||
// Name cases:context.a.context.b /context.a.b /a.context.b /a.b /b
|
||||
if (ContextParameterUtils.isContainContextParam(newNameTemp)) {
|
||||
if (newNameTemp.startsWith(ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX)) {
|
||||
int index = newNameTemp.indexOf(".", //$NON-NLS-1$
|
||||
ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX.length());
|
||||
defaultSchemaName = newNameTemp.substring(0, index);
|
||||
defaultTableName = newNameTemp.substring(index + 1, newNameLength);
|
||||
update = true;
|
||||
int contextPrefixLength = ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX.length();
|
||||
int index = newNameTemp.indexOf(".", contextPrefixLength);//$NON-NLS-1$
|
||||
if (index > contextPrefixLength) {
|
||||
defaultSchemaName = newNameTemp.substring(0, index);
|
||||
defaultTableName = newNameTemp.substring(index + 1, newNameLength);
|
||||
update = true;
|
||||
}
|
||||
} else {
|
||||
int index = newNameTemp.indexOf(".");//$NON-NLS-1$
|
||||
defaultSchemaName = newNameTemp.substring(0, index);
|
||||
defaultTableName = newNameTemp.substring(index + 1, newNameLength);
|
||||
update = true;
|
||||
if (index > 0) {
|
||||
defaultSchemaName = newNameTemp.substring(0, index);
|
||||
defaultTableName = newNameTemp.substring(index + 1, newNameLength);
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] names = newNameTemp.split("\\.");//$NON-NLS-1$
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.ui.preferences;
|
||||
|
||||
import org.talend.core.database.EDatabaseTypeName;
|
||||
import org.talend.designer.core.model.process.jobsettings.JobSettingsConstants;
|
||||
|
||||
/**
|
||||
@@ -68,6 +69,17 @@ public class StatsAndLogsConstants {
|
||||
"tJDBCOutput", "tMysqlOutput", "tMSSqlOutput", ORACLE_WITH_SID_CONN_TYPE, ORACLE_WITH_SERVICE_CONN_TYPE, ORACLE_OCI,//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
"tPostgresPlusOutput", "tPostgresqlOutput", "tDB2Output", "tSybaseOutput", "tIngresOutput", "tInterbaseOutput", "tSQLiteOutput", "tFirebirdOutput", "tInformixOutput", "tAccessOutput", "tTeradataOutput" }; //$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$
|
||||
|
||||
// public static final String[] SUPPORT_PRODUCT_NAMES1 = new String[] { "MYSQL", "ORACLE", "POSTGRESPLUS", "POSTGRESQL",
|
||||
// "IBM_DB2", "SYBASE", "SQLITE", "FIREBIRD" };
|
||||
|
||||
public static final String[] SUPPORT_PRODUCT_NAMES = new String[] { EDatabaseTypeName.GENERAL_JDBC.getProduct(),
|
||||
EDatabaseTypeName.MYSQL.getProduct(), EDatabaseTypeName.MSSQL.getProduct(),
|
||||
EDatabaseTypeName.ORACLEFORSID.getProduct(), EDatabaseTypeName.ORACLESN.getProduct(),
|
||||
EDatabaseTypeName.ORACLE_OCI.getProduct(), EDatabaseTypeName.PLUSPSQL.getProduct(),
|
||||
EDatabaseTypeName.PSQL.getProduct(), EDatabaseTypeName.IBMDB2.getProduct(), EDatabaseTypeName.SYBASEASE.getProduct(),
|
||||
EDatabaseTypeName.SQLITE.getProduct(), EDatabaseTypeName.FIREBIRD.getProduct(), EDatabaseTypeName.ACCESS.getProduct(),
|
||||
EDatabaseTypeName.TERADATA.getProduct() };
|
||||
|
||||
private static final String[] PERL_DISPLAY_DBNAMES = new String[] {
|
||||
"MySQL", "Oracle with SID", "Oracle with service name", "Oracle OCI",//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
"PostgresPlus", "PostgreSQL", "IBM DB2", "Sybase", "SQLite", "FireBird" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
@@ -74,7 +73,6 @@ import org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository;
|
||||
import org.talend.designer.core.ui.editor.cmd.LoadProjectSettingsCommand;
|
||||
import org.talend.designer.core.ui.editor.process.Process;
|
||||
import org.talend.designer.core.ui.views.properties.WidgetFactory;
|
||||
import org.talend.designer.core.utils.ConnectionUtil;
|
||||
import org.talend.designer.core.utils.DetectContextVarsUtils;
|
||||
import org.talend.metadata.managment.ui.wizard.metadata.ShowAddedContextdialog;
|
||||
import org.talend.repository.UpdateRepositoryUtils;
|
||||
@@ -222,6 +220,7 @@ public abstract class AbstractJobSettingsPage extends ProjectSettingPage {
|
||||
} else {
|
||||
MessageDialog.openInformation(getShell(), getDisplayName(),
|
||||
"Connection has been deleted ,change to build in automaticlly");
|
||||
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", "");
|
||||
ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem, null,
|
||||
getPropertyTypeName(), EmfComponent.BUILTIN);
|
||||
changeValuesFromRepository1.execute();
|
||||
|
||||
@@ -12,13 +12,16 @@
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.ui.projectsetting;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.gef.commands.CommandStack;
|
||||
import org.eclipse.gef.commands.CommandStackEvent;
|
||||
import org.eclipse.gef.commands.CommandStackEventListener;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.talend.commons.exception.PersistenceException;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
|
||||
import org.talend.core.model.metadata.designerproperties.RepositoryToComponentProperty;
|
||||
import org.talend.core.model.process.EComponentCategory;
|
||||
@@ -32,6 +35,7 @@ import org.talend.core.model.update.UpdatesConstants;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.designer.core.model.components.EmfComponent;
|
||||
import org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository;
|
||||
import org.talend.designer.core.ui.preferences.StatsAndLogsConstants;
|
||||
import org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite;
|
||||
import org.talend.repository.UpdateRepositoryUtils;
|
||||
|
||||
@@ -95,26 +99,31 @@ public class ProjectSettingMultipleThreadDynamicComposite extends MultipleThread
|
||||
String propertyType = (String) elementParameter.getChildParameters().get("PROPERTY_TYPE").getValue();
|
||||
ProxyRepositoryFactory proxyRepositoryFactory = ProxyRepositoryFactory.getInstance();
|
||||
IRepositoryViewObject lastVersion = null;
|
||||
boolean connectionChanged = false;
|
||||
if (null != id && !"".equals(id)) {
|
||||
try {
|
||||
lastVersion = proxyRepositoryFactory.getLastVersion(id);
|
||||
if (null == lastVersion && propertyType.equals(EmfComponent.REPOSITORY)) {
|
||||
List<ConnectionItem> connectionItems = proxyRepositoryFactory.getMetadataConnectionsItem();
|
||||
if (connectionItems.isEmpty()) {
|
||||
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", "");
|
||||
ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem,
|
||||
null, parentParamName + ":" + "PROPERTY_TYPE", EmfComponent.REPOSITORY);
|
||||
changeValuesFromRepository1.execute();
|
||||
}
|
||||
for (ConnectionItem cItem : connectionItems) {
|
||||
if (cItem instanceof DatabaseConnectionItem) {
|
||||
id = cItem.getProperty().getId();
|
||||
lastVersion = proxyRepositoryFactory.getLastVersion(id);
|
||||
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", id);
|
||||
break;
|
||||
if (isSupportDatabaseType(cItem)) {
|
||||
id = cItem.getProperty().getId();
|
||||
lastVersion = proxyRepositoryFactory.getLastVersion(id);
|
||||
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", id);
|
||||
connectionChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (connectionItems.isEmpty() || null == lastVersion) {
|
||||
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", "");
|
||||
ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem,
|
||||
null, parentParamName + ":" + "PROPERTY_TYPE", EmfComponent.BUILTIN);
|
||||
changeValuesFromRepository1.execute();
|
||||
}
|
||||
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
e.printStackTrace();
|
||||
@@ -124,11 +133,14 @@ public class ProjectSettingMultipleThreadDynamicComposite extends MultipleThread
|
||||
List<ConnectionItem> connectionItems = proxyRepositoryFactory.getMetadataConnectionsItem();
|
||||
for (ConnectionItem cItem : connectionItems) {
|
||||
if (cItem instanceof DatabaseConnectionItem) {
|
||||
lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(cItem.getProperty().getId());
|
||||
id = cItem.getProperty().getId();
|
||||
lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(id);
|
||||
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", id);
|
||||
break;
|
||||
if (isSupportDatabaseType(cItem)) {
|
||||
lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(cItem.getProperty().getId());
|
||||
id = cItem.getProperty().getId();
|
||||
lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(id);
|
||||
elem.setPropertyValue("REPOSITORY_PROPERTY_TYPE", id);
|
||||
connectionChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (PersistenceException e) {
|
||||
@@ -177,7 +189,7 @@ public class ProjectSettingMultipleThreadDynamicComposite extends MultipleThread
|
||||
|
||||
}
|
||||
}
|
||||
if (!sameValues) {
|
||||
if (!sameValues || connectionChanged) {
|
||||
ChangeValuesFromRepository changeValuesFromRepository = new ChangeValuesFromRepository(elem, connection,
|
||||
repositoryPropertyName, id);
|
||||
changeValuesFromRepository.execute();
|
||||
@@ -199,4 +211,27 @@ public class ProjectSettingMultipleThreadDynamicComposite extends MultipleThread
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isSupportDatabaseType(ConnectionItem connectionItem) {
|
||||
Connection connection = connectionItem.getConnection();
|
||||
DatabaseConnection dbConnection = null;
|
||||
if (connection instanceof DatabaseConnection) {
|
||||
dbConnection = (DatabaseConnection) connection;
|
||||
}
|
||||
if (dbConnection == null || StringUtils.isBlank(dbConnection.getProductId())) {
|
||||
return false;
|
||||
}
|
||||
// JDBC databaseType with different productId like DeltaLake/SingleStore..
|
||||
String productId = dbConnection.getProductId();
|
||||
String[] supportDatabaseTypeNames = StatsAndLogsConstants.SUPPORT_PRODUCT_NAMES;
|
||||
boolean find = false;
|
||||
if ("ORACLE".equals(productId)) {
|
||||
find = Arrays.stream(StatsAndLogsConstants.DISPLAY_DBNAMES[1])
|
||||
.anyMatch(typeName -> typeName.equals(connectionItem.getTypeName()));
|
||||
} else {
|
||||
find = Arrays.stream(supportDatabaseTypeNames).anyMatch(name -> name.equals(productId));
|
||||
}
|
||||
return find;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2020 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.designer.core.utils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
|
||||
/**
|
||||
* created by bhe on Dec 12, 2020 Detailled comment
|
||||
*
|
||||
*/
|
||||
public class FixModuleListInBDJDBCMigrationTask extends UpdateModuleListInComponentsMigrationTask {
|
||||
|
||||
|
||||
public String getMavenUriForJar(String jarName, List ctxs) {
|
||||
jarName = TalendTextUtils.removeQuotes(jarName);
|
||||
|
||||
if (StringUtils.isEmpty(jarName) || !jarName.startsWith(MavenUrlHelper.MVN_PROTOCOL)) {
|
||||
return jarName;
|
||||
}
|
||||
|
||||
String[] vals = jarName.split("/");
|
||||
if (vals.length > 3 && vals[0].equals("mvn:org.talend.libraries") && vals[2].equals("6.0.0-SNAPSHOT")
|
||||
&& (vals[1].equals("context") || vals[1].startsWith("((String)context"))) {
|
||||
String ctx = vals[1] + "." + vals[vals.length - 1];
|
||||
boolean containContext = containContext(ctx, ctxs);
|
||||
if (containContext) {
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
|
||||
return jarName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.talend.core.model.migration.IProjectMigrationTask#getOrder()
|
||||
*/
|
||||
@Override
|
||||
public Date getOrder() {
|
||||
GregorianCalendar gc = new GregorianCalendar(2020, 12, 12, 12, 0, 0);
|
||||
return gc.getTime();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import org.talend.commons.runtime.model.emf.EmfHelper;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.model.components.ComponentCategory;
|
||||
import org.talend.core.model.components.IComponent;
|
||||
import org.talend.core.model.context.ContextUtils;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.general.Project;
|
||||
import org.talend.core.model.metadata.builder.connection.Connection;
|
||||
@@ -33,16 +34,19 @@ import org.talend.core.model.migration.AbstractItemMigrationTask;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.properties.ConnectionItem;
|
||||
import org.talend.core.model.properties.ContextItem;
|
||||
import org.talend.core.model.properties.ImplicitContextSettings;
|
||||
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.StatAndLogsSettings;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.model.utils.ContextParameterUtils;
|
||||
import org.talend.core.model.utils.TalendTextUtils;
|
||||
import org.talend.core.repository.model.ProxyRepositoryFactory;
|
||||
import org.talend.core.runtime.maven.MavenUrlHelper;
|
||||
import org.talend.core.ui.component.ComponentsFactoryProvider;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ContextType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.ElementValueType;
|
||||
import org.talend.designer.core.model.utils.emf.talendfile.NodeType;
|
||||
@@ -158,7 +162,7 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
final Object object = elementParameter.get(i);
|
||||
if (object instanceof ElementParameterType) {
|
||||
ElementParameterType parameterType = (ElementParameterType) object;
|
||||
if (updateParam(parameterType)) {
|
||||
if (updateParam(parameterType, null)) {
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
@@ -173,7 +177,7 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
final Object object = elementParameter.get(i);
|
||||
if (object instanceof ElementParameterType) {
|
||||
ElementParameterType parameterType = (ElementParameterType) object;
|
||||
if (updateParam(parameterType)) {
|
||||
if (updateParam(parameterType, null)) {
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
@@ -206,10 +210,15 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
protected boolean updateDatabaseConnection(DatabaseConnection dbConnection) throws Exception {
|
||||
String driverJar = dbConnection.getDriverJarPath();
|
||||
if (driverJar != null) {
|
||||
List ctxs = null;
|
||||
ContextItem contextItem = ContextUtils.getContextItemById2(dbConnection.getContextId());
|
||||
if (contextItem != null) {
|
||||
ctxs = contextItem.getContext();
|
||||
}
|
||||
String[] jars = driverJar.split(";");
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String jar : jars) {
|
||||
String uri = getMavenUriForJar(jar);
|
||||
String uri = getMavenUriForJar(jar, ctxs);
|
||||
if (sb.length() > 0) {
|
||||
sb.append(";");
|
||||
}
|
||||
@@ -248,7 +257,7 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
if (p instanceof ElementParameterType) {
|
||||
ElementParameterType param = (ElementParameterType) p;
|
||||
// variable name used for Stat&Logs
|
||||
if (updateParam(param)) {
|
||||
if (updateParam(param, processType)) {
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
@@ -264,7 +273,7 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
boolean isConfig = nodeType.getComponentName().equals("cConfig");
|
||||
for (Object paramObjectType : nodeType.getElementParameter()) {
|
||||
ElementParameterType param = (ElementParameterType) paramObjectType;
|
||||
if (isConfig ? updateParamForcConfig(param) : updateParam(param)) {
|
||||
if (isConfig ? updateParamForcConfig(param, processType) : updateParam(param, processType)) {
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
@@ -292,7 +301,7 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
ElementParameterType param = (ElementParameterType) paramObjectType;
|
||||
IElementParameter paramFromEmf = fNode.getElementParameter(param.getName());
|
||||
if (paramFromEmf != null) {
|
||||
if (isConfig ? updateParamForcConfig(param) : updateParam(param)) {
|
||||
if (isConfig ? updateParamForcConfig(param, processType) : updateParam(param, processType)) {
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
@@ -308,11 +317,12 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
return list;
|
||||
}
|
||||
|
||||
private static boolean updateParam(ElementParameterType param) {
|
||||
private boolean updateParam(ElementParameterType param, ProcessType processType) {
|
||||
boolean modified = false;
|
||||
List ctxs = processType == null ? null : processType.getContext();
|
||||
if (param.getField() != null) {
|
||||
if (param.getField().equals(EParameterFieldType.MODULE_LIST.name()) && param.getValue() != null) {
|
||||
String jarUri = getMavenUriForJar(param.getValue());
|
||||
String jarUri = getMavenUriForJar(param.getValue(), ctxs);
|
||||
param.setValue(jarUri);
|
||||
modified = true;
|
||||
} else if (("DRIVER_JAR".equals(param.getName()) || "DRIVER_JAR_IMPLICIT_CONTEXT".equals(param.getName()))
|
||||
@@ -321,7 +331,7 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
EList<?> elementValues = param.getElementValue();
|
||||
for (Object ev : elementValues) {
|
||||
ElementValueType evt = (ElementValueType) ev;
|
||||
String jarUri = getMavenUriForJar(evt.getValue());
|
||||
String jarUri = getMavenUriForJar(evt.getValue(), ctxs);
|
||||
if (!StringUtils.equals(jarUri, evt.getValue())) {
|
||||
evt.setValue(jarUri);
|
||||
modified = true;
|
||||
@@ -332,11 +342,12 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
return modified;
|
||||
}
|
||||
|
||||
private static boolean updateParamForcConfig(ElementParameterType param) {
|
||||
private boolean updateParamForcConfig(ElementParameterType param, ProcessType processType) {
|
||||
boolean modified = false;
|
||||
List ctxs = processType == null ? null : processType.getContext();
|
||||
if (param.getField() != null) {
|
||||
if (param.getField().equals(EParameterFieldType.MODULE_LIST.name()) && param.getValue() != null) {
|
||||
String jarUri = getMavenUriForJar(param.getValue());
|
||||
String jarUri = getMavenUriForJar(param.getValue(), ctxs);
|
||||
param.setValue(jarUri);
|
||||
modified = true;
|
||||
} else if (("DRIVER_JAR".equals(param.getName()) || "DRIVER_JAR_IMPLICIT_CONTEXT".equals(param.getName()))
|
||||
@@ -350,7 +361,7 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
ElementValueType evt = (ElementValueType) ev;
|
||||
switch (evt.getElementRef()) {
|
||||
case "JAR_NAME": {
|
||||
String jarUri = getMavenUriForJar(evt.getValue());
|
||||
String jarUri = getMavenUriForJar(evt.getValue(), ctxs);
|
||||
if (!StringUtils.equals(jarUri, evt.getValue())) {
|
||||
jn = evt;
|
||||
modified = true;
|
||||
@@ -374,9 +385,10 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
return modified;
|
||||
}
|
||||
|
||||
public static String getMavenUriForJar(String jarName) {
|
||||
public String getMavenUriForJar(String jarName, List ctxs) {
|
||||
jarName = TalendTextUtils.removeQuotes(jarName);
|
||||
if (!StringUtils.isEmpty(jarName) && !MavenUrlHelper.isMvnUrl(jarName)) {
|
||||
boolean containContext = containContext(jarName, ctxs);
|
||||
if (!StringUtils.isEmpty(jarName) && !MavenUrlHelper.isMvnUrl(jarName) && !containContext) {
|
||||
ModuleNeeded mod = new ModuleNeeded(null, jarName, null, true);
|
||||
if (!StringUtils.isEmpty(mod.getCustomMavenUri())) {
|
||||
return mod.getCustomMavenUri();
|
||||
@@ -386,6 +398,20 @@ public class UpdateModuleListInComponentsMigrationTask extends AbstractItemMigra
|
||||
return jarName;
|
||||
}
|
||||
|
||||
public boolean containContext(String jarName, List ctxs) {
|
||||
if (ctxs == null) {
|
||||
// for project settings
|
||||
return ContextParameterUtils.isContainContextParam(jarName);
|
||||
}
|
||||
// check for job and connections
|
||||
for (Object ct : ctxs) {
|
||||
if (ContextParameterUtils.isContextParamOfContextType((ContextType) ct, jarName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -92,14 +92,18 @@ public class SpecialUpdateELTDefaultNameMigrationTask extends AbstractAllJobMigr
|
||||
// Connection name cases:context.a.context.b /context.a.b /a.context.b /a.b /b
|
||||
if (ContextParameterUtils.isContainContextParam(connectionNameTemp)) {
|
||||
if (connectionNameTemp.startsWith(ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX)) {
|
||||
int index = connectionNameTemp.indexOf(".", //$NON-NLS-1$
|
||||
ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX.length());
|
||||
schemaNewValue = connectionNameTemp.substring(0, index);
|
||||
tableNewValue = connectionNameTemp.substring(index + 1, connNameLength);
|
||||
int contextPrefixLength = ContextParameterUtils.JAVA_NEW_CONTEXT_PREFIX.length();
|
||||
int index = connectionNameTemp.indexOf(".", contextPrefixLength);//$NON-NLS-1$
|
||||
if (index > contextPrefixLength) {
|
||||
schemaNewValue = connectionNameTemp.substring(0, index);
|
||||
tableNewValue = connectionNameTemp.substring(index + 1, connNameLength);
|
||||
}
|
||||
} else {
|
||||
int index = connectionNameTemp.indexOf(".");//$NON-NLS-1$
|
||||
schemaNewValue = connectionNameTemp.substring(0, index);
|
||||
tableNewValue = connectionNameTemp.substring(index + 1, connNameLength);
|
||||
if (index > 0) {
|
||||
schemaNewValue = connectionNameTemp.substring(0, index);
|
||||
tableNewValue = connectionNameTemp.substring(index + 1, connNameLength);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String[] names = connectionNameTemp.split("\\.");//$NON-NLS-1$
|
||||
@@ -110,19 +114,20 @@ public class SpecialUpdateELTDefaultNameMigrationTask extends AbstractAllJobMigr
|
||||
}
|
||||
// If global map in link
|
||||
schemaNewValue = TalendTextUtils.removeQuotesIfExist(schemaNewValue);
|
||||
if (schemaNewValue.startsWith("+") && schemaNewValue.endsWith("+")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (schemaNewValue != null && schemaNewValue.startsWith("+") //$NON-NLS-1$
|
||||
&& schemaNewValue.endsWith("+")) { //$NON-NLS-1$
|
||||
schemaNewValue = schemaNewValue.substring(1, schemaNewValue.length() - 1);
|
||||
}
|
||||
tableNewValue = TalendTextUtils.removeQuotesIfExist(tableNewValue);
|
||||
if (tableNewValue.startsWith("+") && tableNewValue.endsWith("+")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (tableNewValue != null && tableNewValue.startsWith("+") && tableNewValue.endsWith("+")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
tableNewValue = tableNewValue.substring(1, tableNewValue.length() - 1);
|
||||
}
|
||||
|
||||
// Update the value
|
||||
if (!schemaNewValue.equals(schemaValue)) {
|
||||
if (schemaNewValue != null && !schemaNewValue.equals(schemaValue)) {
|
||||
ComponentUtilities.setNodeValue(node, "ELT_SCHEMA_NAME", schemaNewValue); //$NON-NLS-1$
|
||||
}
|
||||
if (!tableNewValue.equals(tableValue)) {
|
||||
if (tableNewValue != null && !tableNewValue.equals(tableValue)) {
|
||||
ComponentUtilities.setNodeValue(node, "ELT_TABLE_NAME", tableNewValue); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,4 +195,29 @@ public class ChangeConnTextCommandTest {
|
||||
Assert.assertEquals(nodeInput.getElementParameter("ELT_TABLE_NAME").getValue(),
|
||||
TalendTextUtils.addQuotes("ODS_EGY_TBT_REF_INDICATEUR"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConnectionRenameLinkNameTUP_29072_2() {
|
||||
init4ConnectionRenameLinkName();
|
||||
|
||||
nodeInput.getElementParameter("ELT_SCHEMA_NAME").setValue(TalendTextUtils.addQuotes("context.DWH_Schema"));
|
||||
nodeInput.getElementParameter("ELT_TABLE_NAME").setValue(TalendTextUtils.addQuotes("ODS_EGY_TBT_REF_INDICATEUR"));
|
||||
|
||||
connection = new Connection(nodeInput, nodeMap, EConnectionType.TABLE, EConnectionType.TABLE.getName(), "tELTInput_1",
|
||||
"context.ODS_Schema.ODS_EGY_TBT_REF_INDICATEUR", "tInput_1", false);
|
||||
|
||||
Assert.assertEquals(nodeInput.getElementParameter("ELT_SCHEMA_NAME").getValue(),
|
||||
TalendTextUtils.addQuotes("context.DWH_Schema"));
|
||||
Assert.assertEquals(nodeInput.getElementParameter("ELT_TABLE_NAME").getValue(),
|
||||
TalendTextUtils.addQuotes("ODS_EGY_TBT_REF_INDICATEUR"));
|
||||
|
||||
ChangeConnTextCommand command = new ChangeConnTextCommand(connection, "context.ODS_Schema");
|
||||
command.execute();
|
||||
|
||||
Assert.assertEquals(connection.getName(), "context.ODS_Schema");
|
||||
Assert.assertEquals(nodeInput.getElementParameter("ELT_SCHEMA_NAME").getValue(),
|
||||
TalendTextUtils.addQuotes("context.DWH_Schema"));
|
||||
Assert.assertEquals(nodeInput.getElementParameter("ELT_TABLE_NAME").getValue(),
|
||||
TalendTextUtils.addQuotes("ODS_EGY_TBT_REF_INDICATEUR"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user