Compare commits

..

1 Commits

Author SHA1 Message Date
Liu Xinquan
46a057b0ad fix(TDQ-18322) throw NPE when retrieve the schema on Sybase (#3234) 2020-04-29 17:48:10 +08:00
68 changed files with 1509 additions and 3693 deletions

View File

@@ -21,7 +21,6 @@ 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;
@@ -39,8 +38,6 @@ 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);
@@ -150,21 +147,4 @@ 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);
}
}
}

View File

@@ -1,58 +0,0 @@
// ============================================================================
//
// 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.exception;
public class ClientException extends PersistenceException {
private Integer httpCode;
public ClientException(String message) {
super(message);
}
public ClientException(Integer httpCode, String message) {
super(message);
this.httpCode = httpCode;
}
public ClientException(String message, Throwable cause) {
super(message, cause);
}
public ClientException(Integer httpCode, String message, Throwable cause) {
super(message, cause);
this.httpCode = httpCode;
}
public ClientException(Throwable cause) {
super(cause);
}
public ClientException(Integer httpCode, Throwable cause) {
super(cause);
this.httpCode = httpCode;
}
public Integer getHttpCode() {
return httpCode;
}
public void setHttpCode(Integer httpCode) {
this.httpCode = httpCode;
}
@Override
public String toString() {
return getLocalizedMessage();
}
}

View File

@@ -42,8 +42,6 @@ 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();

View File

@@ -215,12 +215,8 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
lockerValue.getLock().lockInterruptibly();
traceStackForDebugging(lockerValue);
}
@@ -243,12 +239,8 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = this.prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
boolean locked = lockerValue.getLock().tryLock();
if (locked) {
traceStackForDebugging(lockerValue);
@@ -291,12 +283,8 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue;
try {
lockerValue = this.prepareInternalLock(key);
} finally {
this.decrementRunningOperations();
}
LockerValue<KP> lockerValue = prepareInternalLock(key);
decrementRunningOperations();
interruptIfStopping();
boolean locked = lockerValue.getLock().tryLock(timeout, unit);
if (locked) {
@@ -334,17 +322,13 @@ public class LockerByKey<KP> implements ILockerByKey<KP> {
checkKey(key);
blockOperationIfRequired();
incrementRunningOperations();
LockerValue<KP> lockerValue = this.getLockerValue(key);
boolean returnValue;
try {
returnValue = false;
if (lockerValue != null) {
lockerValue.getLock().unlock();
returnValue = true;
}
} finally {
this.decrementRunningOperations();
LockerValue<KP> lockerValue = getLockerValue(key);
boolean returnValue = false;
if (lockerValue != null) {
lockerValue.getLock().unlock();
returnValue = true;
}
decrementRunningOperations();
cleanAccordingOperations();
return returnValue;
}

View File

@@ -873,9 +873,6 @@ 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() };

View File

@@ -12,14 +12,10 @@
// ============================================================================
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;
@@ -32,8 +28,6 @@ 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$
@@ -104,16 +98,7 @@ 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;
}

View File

@@ -13,8 +13,6 @@
package org.talend.core.repository.ui.dialog;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -32,14 +30,12 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.talend.commons.exception.PersistenceException;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.IRepositoryObject;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.repository.utils.RepositoryNodeSortUtil;
import org.talend.core.ui.ITestContainerProviderService;
import org.talend.repository.model.RepositoryNode;
import org.talend.repository.model.IRepositoryNode.EProperties;
@@ -111,8 +107,7 @@ public class PastSelectorDialog extends Dialog {
modificationTime.setWidth(200);
modificationTime.setText("Modification Time");
RepositoryNodeSortUtil util = new RepositoryNodeSortUtil();
for (IRepositoryViewObject object : util.getSortVersion(versions)) {
for (IRepositoryViewObject object : versions) {
TableItem item = new TableItem(table, SWT.NONE);
item.setData(object);
item.setText(0, object.getVersion());
@@ -192,7 +187,7 @@ public class PastSelectorDialog extends Dialog {
});
return composite;
}
public Set<IRepositoryViewObject> getSelectedVersionItems() {
return this.selectedVersionItems;
}

View File

@@ -1,47 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.core.repository.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.talend.commons.utils.Version;
import org.talend.core.model.repository.IRepositoryViewObject;
/**
* @author hwang
*
*/
public class RepositoryNodeSortUtil {
public List<IRepositoryViewObject> getSortVersion(List<IRepositoryViewObject> versions) {
List<IRepositoryViewObject> temp = new ArrayList<IRepositoryViewObject>();
temp.addAll(versions);
Collections.sort(temp, new Comparator<IRepositoryViewObject>() {
@Override
public int compare(IRepositoryViewObject o1, IRepositoryViewObject o2) {
String version1 = o1.getVersion();
String version2 = o2.getVersion();
if(version1 != null && version2 != null) {
return new Version(version1).compareTo(new Version(version2));
}
return 0;
}
});
return temp;
}
}

View File

@@ -28,7 +28,6 @@ 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,

View File

@@ -19,7 +19,6 @@
<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">
@@ -54,16 +53,4 @@
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>

View File

@@ -1,105 +0,0 @@
<?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>

View File

@@ -254,34 +254,6 @@ 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/>
*

View File

@@ -12,49 +12,35 @@
// ============================================================================
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 abstract class AbstractRepositoryContextUpdateService implements IRepositoryContextUpdateService {
protected IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
public class AbstractRepositoryContextUpdateService implements IRepositoryContextUpdateService {
@Override
public void updateRelatedContextVariable(Connection con, String oldValue, String newValue) {
}
protected String updateHadoopProperties(List<Map<String, Object>> hadoopProperties, String oldValue, String newValue) {
String finalProperties = null;
boolean isModified = false;
String finalProperties = "";
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;
}
}
if (isModified) {
finalProperties = HadoopRepositoryUtil.getHadoopPropertiesJsonStr(hadoopProperties);
}
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;
}
}

View File

@@ -12,9 +12,7 @@
// ============================================================================
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;
@@ -249,29 +247,4 @@ 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;
}
}

View File

@@ -20,7 +20,5 @@ import org.talend.core.model.metadata.builder.connection.Connection;
*/
public interface IRepositoryContextUpdateService extends IService {
public boolean accept(Connection connection);
public boolean updateContextParameter(Connection conn, String oldValue, String newValue);
public void updateRelatedContextVariable(Connection con, String oldValue, String newValue);
}

View File

@@ -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.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$
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$
AMAZON_AURORA(new DbVersion4Drivers(EDatabaseTypeName.AMAZON_AURORA, "mysql-connector-java-5.1.30-bin.jar")); //$NON-NLS-1$

View File

@@ -21,11 +21,8 @@ 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;
@@ -33,9 +30,6 @@ 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;
@@ -49,7 +43,6 @@ 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;
@@ -60,8 +53,6 @@ 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$
@@ -91,25 +82,15 @@ public class ContextUtils {
* update the JobContextParameter form repository ContextItem by context name.
*
*/
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) {
public static boolean updateParameterFromRepository(ContextItem sourceItem, IContextParameter contextParam, String contextName) {
if (sourceItem == null || contextParam == null) {
return false;
}
// not found, use default.
ContextType contextType = getContextTypeByName(sourceItem, contextName);
ContextType contextType = getContextTypeByName(sourceItem, contextName, true);
if (contextType != null) {
String paramName = contextParam.getName();
String newName = ContextUtils.getNewNameFromRenameMap(renameMap, paramName);
if (newName != null) {
paramName = newName;
}
ContextParameterType parameterType = getContextParameterTypeByName(contextType, paramName);
ContextParameterType parameterType = getContextParameterTypeByName(contextType, contextParam.getName());
// found parameter, update it.
if (parameterType != null) {
contextParam.setComment(parameterType.getComment());
@@ -117,9 +98,6 @@ 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;
}
}
@@ -200,28 +178,6 @@ 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) {
@@ -416,7 +372,6 @@ public class ContextUtils {
targetParam.setValue(sourceParam.getValue());
targetParam.setPromptNeeded(sourceParam.isPromptNeeded());
targetParam.setComment(sourceParam.getComment());
targetParam.setInternalId(sourceParam.getInternalId());
}
/**
@@ -456,7 +411,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() {
@@ -583,8 +538,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$
}
/**
@@ -618,17 +573,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(), true);
processJobManager.saveToEmf(processType.getContext());
added = true;
}
}
@@ -717,328 +672,8 @@ 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;
}
}

View File

@@ -19,10 +19,8 @@ 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;
@@ -32,7 +30,6 @@ 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;
@@ -77,7 +74,7 @@ public class JobContextManager implements IContextManager {
*/
private Set<String> originalParamerters = new HashSet<String>();
private Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
private Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
/*
* for context group
@@ -254,7 +251,73 @@ public class JobContextManager implements IContextManager {
*/
@Override
public void saveToEmf(EList contextTypeList) {
saveToEmf(contextTypeList, false);
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);
}
private ContextType findContextType(EList contextTypeList, String contextName) {
@@ -321,7 +384,6 @@ 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 {
@@ -424,6 +486,16 @@ 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;
}
@@ -444,16 +516,6 @@ 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);
}
@@ -478,11 +540,11 @@ public class JobContextManager implements IContextManager {
}
}
public Map<Item, Set<String>> getNewParametersMap() {
public Map<ContextItem, Set<String>> getNewParametersMap() {
return newParametersMap;
}
public void setNewParametersMap(Map<Item, Set<String>> newParametersMap) {
public void setNewParametersMap(Map<ContextItem, Set<String>> newParametersMap) {
this.newParametersMap = newParametersMap;
}
@@ -511,98 +573,4 @@ 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);
}
}

View File

@@ -45,14 +45,13 @@ 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
@@ -311,14 +310,6 @@ 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;

View File

@@ -1,85 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.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;
}
}

View File

@@ -1,392 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.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);
}
}
}
}
}
}

View File

@@ -1,48 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.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;
}
}

View File

@@ -1,26 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.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;
}

View File

@@ -1,80 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.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;
}
}

View File

@@ -56,7 +56,6 @@ public class ConnectionBean implements Cloneable {
private static final String TOKEN = "token"; //$NON-NLS-1$
private static final String URL = "url"; //$NON-NLS-1$
/**
* DOC smallet ConnectionBean constructor comment.
*/
@@ -397,15 +396,4 @@ public class ConnectionBean implements Cloneable {
}
}
public String getUrl() {
try {
if (conDetails.has(URL)) {
return conDetails.getString(URL);
}
} catch (JSONException e) {
ExceptionHandler.process(e);
}
return "";
}
}

View File

@@ -87,7 +87,6 @@ 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;
@@ -156,12 +155,12 @@ public class RepositoryToComponentProperty {
return getEDIFACTSchemaValue((EDIFACTConnection) connection, value);
}
// Special for Javajet components: tSalesforceEinsteinBulkExec/tSalesforceEinsteinOutputBulkExec
if (targetComponent != null && targetComponent.startsWith("tSalesforceEinstein")) { //$NON-NLS-1$
return getSpecialGenericValue(connection, value, table, targetComponent, contextMap);
for (IDragAndDropServiceHandler handler : DragAndDropManager.getHandlers()) {
if (handler.canHandle(connection)) {
return handler.getComponentValue(connection, value, table, targetComponent, contextMap);
}
}
return getHandlerComponentValue(connection, value, table, targetComponent, contextMap);
return null;
}
@@ -214,7 +213,8 @@ public class RepositoryToComponentProperty {
return;
}
SAPFunctionUnit unit = null;
for (SAPFunctionUnit tmp : conn.getFuntions()) {
for (int i = 0; i < conn.getFuntions().size(); i++) {
SAPFunctionUnit tmp = conn.getFuntions().get(i);
if (tmp.getLabel().equals(functionLabel)) {
unit = tmp;
break;
@@ -230,8 +230,9 @@ public class RepositoryToComponentProperty {
if (isInput) {
mergeColumn(table, table.getChildren(), value2);
} else {
for (SAPFunctionParameter column : table.getChildren()) {
for (int i = 0; i < table.getChildren().size(); i++) {
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$
@@ -297,8 +298,8 @@ public class RepositoryToComponentProperty {
if (conn == null) {
return null;
}
for (SAPFunctionUnit element : conn.getFuntions()) {
unit = element;
for (int i = 0; i < conn.getFuntions().size(); i++) {
unit = conn.getFuntions().get(i);
if (unit.getLabel().equals(functionLabel)) {
break;
}
@@ -625,50 +626,6 @@ 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) {
@@ -789,9 +746,9 @@ public class RepositoryToComponentProperty {
public static List<Map<String, String>> getOutputWSDLValue(EList list) {
List<Map<String, String>> newList = new ArrayList<Map<String, String>>();
for (Object element : list) {
for (int i = 0; i < list.size(); i++) {
Map<String, String> map = new HashMap<String, String>();
WSDLParameter node = (WSDLParameter) element;
WSDLParameter node = (WSDLParameter) list.get(i);
map.put("EXPRESSION", node.getExpression());
map.put("COLUMN", node.getColumn());
map.put("SOURCE", node.getSource());
@@ -1044,9 +1001,8 @@ 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();
}
@@ -1535,7 +1491,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 = GlobalServiceRegister.getDefault()
IHadoopClusterService hadoopClusterService = (IHadoopClusterService) GlobalServiceRegister.getDefault()
.getService(IHadoopClusterService.class);
Map<String, String> hadoopCustomLibraries = hadoopClusterService.getHadoopCustomLibraries(clusterID);
@@ -1779,7 +1735,7 @@ public class RepositoryToComponentProperty {
private static boolean isContextMode(Connection connection, String value) {
IMetadataManagmentUiService mmService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentUiService.class)) {
mmService = GlobalServiceRegister.getDefault()
mmService = (IMetadataManagmentUiService) GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentUiService.class);
}
if (mmService != null) {
@@ -2066,7 +2022,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 = GlobalServiceRegister.getDefault()
IMetadataManagmentUiService mmUIService = (IMetadataManagmentUiService) GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentUiService.class);
String newPath = mmUIService.getAndOpenXSDFileDialog(p);
if (newPath != null) {
@@ -2186,9 +2142,9 @@ public class RepositoryToComponentProperty {
public static List<Map<String, String>> getOutputXmlValue(EList list) {
List<Map<String, String>> newList = new ArrayList<Map<String, String>>();
for (Object element : list) {
for (int i = 0; i < list.size(); i++) {
Map<String, String> map = new HashMap<String, String>();
XMLFileNode node = (XMLFileNode) element;
XMLFileNode node = (XMLFileNode) list.get(i);
String defaultValue = node.getDefaultValue();
if (defaultValue == null) {
defaultValue = ""; //$NON-NLS-1$
@@ -2432,7 +2388,7 @@ public class RepositoryToComponentProperty {
} else {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentService.class)) {
IMetadataManagmentService mmService = GlobalServiceRegister.getDefault()
IMetadataManagmentService mmService = (IMetadataManagmentService) GlobalServiceRegister.getDefault()
.getService(IMetadataManagmentService.class);
IMetadataTable convert = mmService.convertMetadataTable(repTable);
String uinqueTableName = node.getProcess()
@@ -2687,7 +2643,8 @@ public class RepositoryToComponentProperty {
boolean foundColumn = false;
Map<String, Object> map = new HashMap<String, Object>();
map.put("QUERY", null); //$NON-NLS-1$
for (SchemaTarget sch : schemaTargets) {
for (int i = 0; i < schemaTargets.size(); i++) {
SchemaTarget sch = schemaTargets.get(i);
if (col.getLabel().equals(sch.getTagName())) {
// map.put("SCHEMA_COLUMN", sch.getTagName());
foundColumn = true;
@@ -2696,7 +2653,8 @@ public class RepositoryToComponentProperty {
}
if (!foundColumn && colRenameMap != null && !colRenameMap.isEmpty()) {
Set<String> newNameSet = colRenameMap.keySet();
for (SchemaTarget sch : schemaTargets) {
for (int i = 0; i < schemaTargets.size(); i++) {
SchemaTarget sch = schemaTargets.get(i);
if (newNameSet.contains(sch.getTagName())) {
String oldColLabel = colRenameMap.get(sch.getTagName());
if (col.getLabel().equals(oldColLabel)) {
@@ -2755,7 +2713,8 @@ public class RepositoryToComponentProperty {
for (IMetadataColumn col : metadataTable.getListColumns()) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("QUERY", null); //$NON-NLS-1$
for (ConceptTarget cpt : conceptTargets) {
for (int i = 0; i < conceptTargets.size(); i++) {
ConceptTarget cpt = conceptTargets.get(i);
if (col.getLabel().equals(cpt.getTargetName())) {
// map.put("SCHEMA_COLUMN", sch.getTagName());
map.put("QUERY", TalendQuoteUtils.addQuotes(cpt.getRelativeLoopExpression())); //$NON-NLS-1$

View File

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

View File

@@ -71,8 +71,4 @@ public interface IContextParameter {
public void setSource(final String sourceName);
public boolean isBuiltIn();
public String getInternalId();
public void setInternalId(String internalId);
}

View File

@@ -426,11 +426,6 @@ 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$
@@ -443,8 +438,6 @@ 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$

View File

@@ -1,34 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.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);
}
}

View File

@@ -1,424 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.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 {
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;
}
}

View File

@@ -21,12 +21,14 @@ 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.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.commons.lang.StringUtils;
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;
@@ -39,8 +41,11 @@ 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;
@@ -49,23 +54,28 @@ 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;
@@ -84,12 +94,10 @@ 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;
import org.talend.core.runtime.i18n.Messages;
import org.talend.core.runtime.services.IGenericDBService;
import org.talend.core.service.IMRProcessService;
import org.talend.core.service.IMetadataManagmentService;
import org.talend.core.service.IStormProcessService;
@@ -102,6 +110,7 @@ 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;
@@ -110,12 +119,6 @@ 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.
*/
@@ -144,7 +147,7 @@ public abstract class RepositoryUpdateManager {
*/
protected Object parameter;
private Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
private Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
private boolean onlyOpeningJob = false;
@@ -276,7 +279,7 @@ public abstract class RepositoryUpdateManager {
private boolean openRenameCheckedDialog() {
return MessageDialog.openQuestion(Display.getCurrent().getActiveShell(),
Messages.getString("RepositoryUpdateManager.RenameContextTitle"), //$NON-NLS-1$
Messages.getString("RepositoryUpdateManager.RenameContextMessagesNoBuiltIn")); //$NON-NLS-1$
Messages.getString("RepositoryUpdateManager.RenameContextMessages")); //$NON-NLS-1$
}
@@ -285,7 +288,7 @@ public abstract class RepositoryUpdateManager {
}
public boolean needForcePropagation() {
return getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty();
return needForcePropagationForContext() || (getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty());
}
private boolean needForcePropagationForContext() {
@@ -684,191 +687,469 @@ public abstract class RepositoryUpdateManager {
if (valueMap == null) {
return;
}
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> 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> 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) {
Set<String> set = valueMap.keySet();
List<String> list = new ArrayList<String>(set);
IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
for (String newValue : list) {
String oldValue = valueMap.get(newValue);
oldValue = "context." + oldValue;
newValue = "context." + newValue;
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);
}
}
}
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;
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);
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericDBService.class)) {
IGenericDBService service = GlobalServiceRegister.getDefault().getService(IGenericDBService.class);
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);
}
}
}
}
}
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));
}
}
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;
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);
}
}
}
if (isModified) {
FACTORY.save(conntectionItem, false);
}
}
List<IRepositoryViewObject> deliConnList = factory.getAll(ERepositoryObjectType.METADATA_FILE_DELIMITED, true);
for (IRepositoryViewObject obj : deliConnList) {
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);
}
}
}
}
}
}
}
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);
}
}
}
}
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);
}
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);
}
}
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() || !FACTORY.isFullLogonFinished()) {
if (CommonsPlugin.isHeadless() || !getProxyRepositoryFactory().isFullLogonFinished()) {
return new IEditorReference[0];
}
final List<IEditorReference> list = new ArrayList<IEditorReference>();
@@ -964,7 +1245,6 @@ 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);
@@ -1249,6 +1529,7 @@ 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);
@@ -1342,6 +1623,7 @@ 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);
@@ -1695,6 +1977,7 @@ 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);
@@ -1779,6 +2062,7 @@ 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);
@@ -1807,6 +2091,8 @@ 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);
@@ -1865,6 +2151,8 @@ 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);
@@ -1920,6 +2208,8 @@ 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(),
@@ -2050,7 +2340,7 @@ public abstract class RepositoryUpdateManager {
repositoryUpdateManager.setContextRenamedMap(repositoryRenamedMap);
// newly added parameters
Map<Item, Set<String>> newParametersMap = new HashMap<Item, Set<String>>();
Map<ContextItem, Set<String>> newParametersMap = new HashMap<ContextItem, Set<String>>();
if (!repositoryContextManager.getNewParameters().isEmpty()) {
newParametersMap.put(item, repositoryContextManager.getNewParameters());
}
@@ -2062,14 +2352,16 @@ public abstract class RepositoryUpdateManager {
ExceptionHandler.process(e);
}
return repositoryUpdateManager.doWork(show, onlySimpleShow);
}
public Map<Item, Set<String>> getNewParametersMap() {
public Map<ContextItem, Set<String>> getNewParametersMap() {
return newParametersMap;
}
public void setNewParametersMap(Map<Item, Set<String>> newParametersMap) {
public void setNewParametersMap(Map<ContextItem, Set<String>> newParametersMap) {
this.newParametersMap = newParametersMap;
}
@@ -2172,6 +2464,7 @@ 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);
@@ -2189,19 +2482,9 @@ public abstract class RepositoryUpdateManager {
return repositoryUpdateManager.doWork(true, false);
}
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;
private static IProxyRepositoryFactory getProxyRepositoryFactory() {
return ((IProxyRepositoryService) GlobalServiceRegister.getDefault().getService(IProxyRepositoryService.class))
.getProxyRepositoryFactory();
}
}

View File

@@ -64,8 +64,4 @@ public interface IGenericDBService extends IService{
public ERepositoryObjectType getExtraDBType(ERepositoryObjectType type);
public void updateCompPropertiesForContextMode(Connection connection, Map<String, String> contextVarMap);
public List<ERepositoryObjectType> getAllGenericMetadataDBRepositoryType();
}

View File

@@ -25,7 +25,6 @@ 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;
@@ -246,11 +245,4 @@ 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;
}
}

View File

@@ -21,7 +21,6 @@ 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;
@@ -92,14 +91,11 @@ 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();
}
@@ -110,18 +106,6 @@ 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();
@@ -135,12 +119,6 @@ public final class ProjectManager {
return project;
}
}
for (Project project : tempProjects) {
if (StringUtils.equals(project.getLabel(), label)) {
return project;
}
}
return null;
}
@@ -158,11 +136,6 @@ public final class ProjectManager {
return project;
}
}
for (Project project : tempProjects) {
if (StringUtils.equals(project.getTechnicalLabel(), label)) {
return project;
}
}
return null;
}

View File

@@ -30,7 +30,6 @@ 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.

View File

@@ -33,8 +33,6 @@ 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$

View File

@@ -12,7 +12,6 @@
// ============================================================================
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;
@@ -50,11 +49,7 @@ 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)
*
@@ -66,7 +61,7 @@ public class DefaultTokenCollector extends AbstractTokenCollector {
// version
tokenStudioObject.put(VERSION.getKey(), VersionUtils.getInternalVersion());
// uniqueId
tokenStudioObject.put(UNIQUE_ID.getKey(), hashUniqueId());
tokenStudioObject.put(UNIQUE_ID.getKey(), calcUniqueId());
// typeStudio
if (GlobalServiceRegister.getDefault().isServiceRegistered(IBrandingService.class)) {

View File

@@ -77,7 +77,5 @@ public interface ICoreTisService extends IService {
Map<String, String> getDropBundleInfo() throws IOException;
Set<String> getComponentBlackList();
public String getLatestInstalledVersion();
}

View File

@@ -206,17 +206,6 @@ public abstract class AbstractMavenProcessorPom extends CreateMavenBundleTemplat
// Xpp3Dom minimizeJar = new Xpp3Dom("minimizeJar"); //$NON-NLS-1$
// minimizeJar.setValue("true"); //$NON-NLS-1$
// configuration.addChild(minimizeJar);
// TDQ-18049 when shaded,avoid to conflict the same name class from different jars. e.g,"ImagePreloader"
// in "fop-2.3.jar/META-INF/services/" and "xmlgraphics-commons-2.3.jar"
Xpp3Dom transforms = new Xpp3Dom("transformers"); //$NON-NLS-1$
Xpp3Dom transform = new Xpp3Dom("transform");
transform
.setAttribute("implementation",
"org.apache.maven.plugins.shade.resource.ServicesResourceTransformer");
transforms.addChild(transform);
configuration.addChild(transforms);
Xpp3Dom artifactSet = new Xpp3Dom("artifactSet"); //$NON-NLS-1$
configuration.addChild(artifactSet);
Xpp3Dom excludes = new Xpp3Dom("excludes"); //$NON-NLS-1$

View File

@@ -649,13 +649,12 @@ public class CreateMavenJobPom extends AbstractMavenProcessorPom {
ERepositoryObjectType.getAllTypesOfCodes().forEach(t -> dependencies.addAll(PomUtil.getCodesDependencies(t)));
// libraries of talend/3rd party
dependencies.addAll(processor.getNeededModules(TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED).stream()
.filter(m -> !m.isExcluded()).map(m -> createDenpendency(m, false)).collect(Collectors.toSet()));
dependencies.addAll(convertToDistinctedJobDependencies(currentJobProperty.getId(), currentJobProperty.getVersion(),
processor.getNeededModules(TalendProcessOptionConstants.MODULES_EXCLUDE_SHADED)));
// missing modules from the job generation of children
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())));
childrenJobInfo.forEach(j -> dependencies.addAll(convertToDistinctedJobDependencies(j.getJobId(), j.getJobVersion(),
LastGenerationInfo.getInstance().getModulesNeededPerJob(j.getJobId(), j.getJobVersion()))));
Set<ModuleNeeded> modules = new HashSet<>();
// testcase modules from current job (optional)
@@ -734,8 +733,6 @@ 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))

View File

@@ -14,6 +14,7 @@ package routines.system;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.HashMap;
import java.util.List;
import org.dom4j.Element;
@@ -109,31 +110,26 @@ public class GetJarsToRegister {
private String addLibsPath(String line, java.util.Map<String, String> crcMap) {
for (java.util.Map.Entry<String, String> entry : crcMap.entrySet()) {
line = adaptLibPaths(line, entry);
if (new java.io.File(line).exists()) {
break;
}
}
return line;
}
private String adaptLibPaths(String line, java.util.Map.Entry<String, String> entry) {
line = line.replace("\\", "/");
String jarName = entry.getValue();
String crc = entry.getKey();
String libStringFinder = "../lib/" + jarName;
String libStringFinder2 = "./" + jarName; // for the job jar itself.
String replacement = "../../../cache/lib/" + crc + "/" + jarName;
if (line.contains(libStringFinder)) {
line = line.replace(libStringFinder, replacement);
line = line.replace(libStringFinder, "../../../cache/lib/" + crc + "/" + jarName);
} else if (line.toLowerCase().contains(libStringFinder2)) {
line = line.toLowerCase().replace(libStringFinder2, replacement);
line = line.toLowerCase().replace(libStringFinder2, "../../../cache/lib/" + crc + "/" + jarName);
} else if (line.toLowerCase().equals(jarName)) {
line = replacement;
line = "../../../cache/lib/" + crc + "/" + jarName;
} else if (line.contains(":$ROOT_PATH/" + jarName + ":")) {
line = line.replace(":$ROOT_PATH/" + jarName + ":", ":$ROOT_PATH/" + replacement + ":");
line = line.replace(":$ROOT_PATH/" + jarName + ":", ":$ROOT_PATH/../../../cache/lib/" + crc + "/" + jarName + ":");
} else if (line.contains(";" + jarName + ";")) {
line = line.replace(";" + jarName + ";", ";" + replacement + ";");
line = line.replace(";" + jarName + ";", ";../../../cache/lib/" + crc + "/" + jarName + ";");
}
return line;
}

View File

@@ -58,22 +58,11 @@ public class JDBCUtil {
}
public static Date getDate(ResultSet rs, int index) throws java.sql.SQLException {
Date result = null;
try {
if(rs.getTimestamp(index) != null) {
result = new Date(rs.getTimestamp(index).getTime());
return result;
}
} catch (java.sql.SQLException e) {
if(rs.getTimestamp(index) != null) {
return new Date(rs.getTimestamp(index).getTime());
}
try {
if(rs.getDate(index) != null) {
result = new Date(rs.getDate(index).getTime());
return result;
}
} catch (java.sql.SQLException e) {
}
return result;
return null;
}
//decrease the get method call number

View File

@@ -685,20 +685,17 @@ 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, renamedMap);
false);
}else{
tempVars = checkAndAddContextVariables(contextItem, neededVars, process.getContextManager(),
false, renamedMap);
false);
}
Set<String> addedVars = tempVars;
@@ -788,19 +785,17 @@ 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, renamedMap);
false);
contextItems.add(contextItem);
}
if (hadoopClusterContextItem != null) {
hcAddedVars = checkAndAddContextVariables(hadoopClusterContextItem, hcNeededVars,
process.getContextManager(), false, renamedMap);
process.getContextManager(), false);
contextItems.add(hadoopClusterContextItem);
}
@@ -851,9 +846,7 @@ public final class ConnectionContextHelper {
private static void addContextVarsToExistVariable(IProcess2 process, ContextItem contextItem, Set<String> addedVars,
IContextManager contextMgr) {
Map<String, String> renamedMap = ContextUtils.getContextParamterRenamedMap(process.getProperty().getItem());
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, addedVars, contextMgr, false,
renamedMap);
Set<String> addedContext = ConnectionContextHelper.checkAndAddContextVariables(contextItem, addedVars, contextMgr, false);
if (addedContext != null && addedContext.size() > 0) {
ConnectionContextHelper.addContextVarForJob(process, contextItem, addedVars);
}
@@ -911,9 +904,8 @@ 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, renamedMap);
contextManager, false);
if (addedContext != null && addedContext.size() > 0) {
ConnectionContextHelper.addContextVarForJob(process, contextItem, addedVars);
}
@@ -975,7 +967,6 @@ 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) {
@@ -983,7 +974,7 @@ public final class ConnectionContextHelper {
if (contextItem != null) {
// add needed vars into job
Set<String> addedVars = checkAndAddContextVariables(contextItem, varsMap.get(id),
process.getContextManager(), false, renamedMap);
process.getContextManager(), false);
if (addedVars != null && !addedVars.isEmpty()) {
String source = UpdateRepositoryUtils.getRepositorySourceName(connItem);
addedVarsMap.put(source, addedVars);
@@ -1074,7 +1065,6 @@ 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>());
@@ -1577,6 +1567,20 @@ 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.
*
@@ -1626,13 +1630,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, Map<String, String> renamedMap) {
final IContextManager ctxManager, boolean added) {
return checkAndAddContextVariables(contextItem.getContext(), contextItem.getDefaultContext(), contextItem.getProperty()
.getId(), neededVars, ctxManager, added, renamedMap);
.getId(), neededVars, ctxManager, added);
}
public static Set<String> checkAndAddContextVariables(final ContextItem contextItem,
final IContextManager ctxManager, boolean added, Map<String, String> renamedMap) {
final IContextManager ctxManager, boolean added) {
List<ContextType> contexts = contextItem.getContext();
String defaultContextName = contextItem.getDefaultContext();
String contextItemId = contextItem.getProperty().getId();
@@ -1641,17 +1645,9 @@ 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();
@@ -1682,16 +1678,14 @@ 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,
Map<String, String> renamedMap) {
final String contextItemId, final Set<String> neededVars, final IContextManager ctxManager, boolean added) {
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
&& !renamedMap.values().contains(jobParam.getName()))) {
&& ContextUtils.getContextParameterTypeByName(type, jobParam.getName()) == null) {
jobParam.setSource(IContextParameter.BUILT_IN);
}
}
@@ -1699,13 +1693,6 @@ 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) {
//

View File

@@ -234,7 +234,7 @@ public class ContextModeWizard extends CheckLastVersionRepositoryWizard implemen
if (creation && isCreateContext) {
String nextId = factory.getNextId();
contextProperty.setId(nextId);
contextManager.saveToEmf(contextItem.getContext(), false);
contextManager.saveToEmf(contextItem.getContext());
contextItem.setDefaultContext(contextManager.getDefaultContext().getName());
final IPath path = ((PropertiesWizardPage) contextModePage.getPropertiesPage()).getDestinationPath();
final IWorkspaceRunnable op = new IWorkspaceRunnable() {

View File

@@ -235,7 +235,7 @@ public class ContextWizard extends CheckLastVersionRepositoryWizard implements I
if (creation) {
String nextId = factory.getNextId();
contextProperty.setId(nextId);
contextManager.saveToEmf(contextItem.getContext(), false);
contextManager.saveToEmf(contextItem.getContext());
contextItem.setDefaultContext(contextManager.getDefaultContext().getName());
final IPath path = contextWizardPage0.getDestinationPath();
final IWorkspaceRunnable op = new IWorkspaceRunnable() {

View File

@@ -255,13 +255,6 @@
<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">

View File

@@ -44,7 +44,6 @@
<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"/>

View File

@@ -13,7 +13,6 @@ 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>
@@ -22,8 +21,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'"
@@ -246,29 +245,6 @@ 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.
*

View File

@@ -414,15 +414,6 @@ 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 -->
@@ -430,7 +421,7 @@ public interface TalendFilePackage extends EPackage {
* @generated
* @ordered
*/
int CONTEXT_PARAMETER_TYPE_FEATURE_COUNT = 8;
int CONTEXT_PARAMETER_TYPE_FEATURE_COUNT = 7;
/**
* The meta object id for the '{@link org.talend.designer.core.model.utils.emf.talendfile.impl.ContextTypeImpl <em>Context Type</em>}' class.
@@ -2186,17 +2177,6 @@ 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 -->
@@ -3494,7 +3474,6 @@ 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();
@@ -3529,7 +3508,6 @@ 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();
@@ -3880,14 +3858,6 @@ 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 -->

View File

@@ -19,7 +19,6 @@ 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>
@@ -28,8 +27,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
*/
@@ -183,26 +182,6 @@ 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
@@ -385,27 +364,6 @@ 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)
@@ -438,8 +396,6 @@ 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);
}
@@ -471,9 +427,6 @@ 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);
}
@@ -505,9 +458,6 @@ 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);
}
@@ -532,8 +482,6 @@ 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);
}
@@ -560,8 +508,6 @@ 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();
}

View File

@@ -91,7 +91,6 @@ import org.talend.core.model.utils.TalendPropertiesUtil;
import org.talend.core.prefs.IDEInternalPreferences;
import org.talend.core.prefs.ITalendCorePrefConstants;
import org.talend.core.repository.model.ProxyRepositoryFactory;
import org.talend.core.services.ICoreTisService;
import org.talend.core.ui.CoreUIPlugin;
import org.talend.core.ui.branding.IBrandingConfiguration;
import org.talend.core.ui.branding.IBrandingService;
@@ -185,18 +184,7 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
} catch (PersistenceException e) {
localProvider = true;
}
String buildIdField = " (" + VersionUtils.getVersion() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreTisService.class)) {
ICoreTisService pachService = (ICoreTisService) GlobalServiceRegister
.getDefault().getService(ICoreTisService.class);
if (pachService != null) {
String patchVersion = pachService.getLatestInstalledVersion();
if(patchVersion != null) {
buildIdField = " (" + patchVersion + ")"; //$NON-NLS-1$ //$NON-NLS-2$;
}
}
}
if (TalendPropertiesUtil.isHideBuildNumber()) {
buildIdField = ""; //$NON-NLS-1$
}

View File

@@ -187,7 +187,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.hashUniqueId()).append("&edition=") //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
url.append("?version=").append(sb.toString()).append("&uid=").append(dtc.calcUniqueId()).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$

View File

@@ -252,7 +252,7 @@ public class RegisterManagement {
String version = VersionUtils.getVersion();
// UNIQUE_ID
String uniqueId = DefaultTokenCollector.hashUniqueId();
String uniqueId = DefaultTokenCollector.calcUniqueId();
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.hashUniqueId();
String uniqueId = DefaultTokenCollector.calcUniqueId();
uniqueId = uniqueId.replace("#", "%23");
uniqueId = uniqueId.replace("$", "%24");
uniqueId = uniqueId.replace("%", "%25");

View File

@@ -471,32 +471,16 @@ public class ImportExportHandlersManager {
@Override
public int compare(ImportItem o1, ImportItem o2) {
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;
if (o1.getRepositoryType().getType().equals("SERVICES")) {
return -1;
} else if (o2.getRepositoryType().getType().equals("SERVICES")) {
return 1;
}
return 100;
return 0;
}
});
ImportCacheHelper importCacheHelper = ImportCacheHelper.getInstance();
try {
for (ImportItem itemRecord : checkedItemRecords) {
if (itemRecord.getProperty() != null) {
itemRecord.setOriginProperyId(itemRecord.getProperty().getId());
}
}
// cache
importCacheHelper.beforeImportItems();

View File

@@ -14,8 +14,6 @@ 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;
@@ -33,9 +31,6 @@ 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;
@@ -57,11 +52,9 @@ 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;
@@ -840,14 +833,11 @@ 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);
}
@@ -884,42 +874,11 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
}
}
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);
private boolean isNeedDeleteOnRemote(String importingLabel, String existLabel) {
if (importingLabel != null && importingLabel.equalsIgnoreCase(importingLabel) && !importingLabel.equals(existLabel)) {
return true;
}
return false;
}
/**
@@ -1035,6 +994,7 @@ public class ImportBasicHandler extends AbstractImportExecutableHandler {
}
protected void beforeCreatingItem(ImportItem selectedImportItem) {
// noting to do specially.
}
protected void afterCreatedItem(ResourcesManager resManager, ImportItem selectedImportItem) throws Exception {

View File

@@ -73,8 +73,6 @@ public class ImportItem {
private boolean removeProjectStatslog;
private String originProperyId;
/**
* add for tdm
*/
@@ -394,14 +392,6 @@ 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;

View File

@@ -27,7 +27,6 @@ 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;
@@ -301,7 +300,6 @@ 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());

View File

@@ -29,7 +29,6 @@ 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;
@@ -235,12 +234,9 @@ public class ImportNodesBuilder {
parentImportNode = findAndCreateFolderNode(typeImportNode, path);
parentImportNode.setItemRecord(itemRecord);
} else {
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));
}
String path = item.getState().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);

View File

@@ -90,7 +90,6 @@ 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;
@@ -171,12 +170,7 @@ 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;
@@ -1352,17 +1346,11 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
// Getting the folder :
try {
IFolder folder = null;
try {
folder = ResourceUtils.getFolder(fsProject, completePath, true);
} catch (PersistenceException e) {
}
IFolder folder = ResourceUtils.getFolder(fsProject, completePath, true);
// 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
if (folder != null && folder.exists()) {
deleteResource(folder);
}
deleteResource(folder);
} finally {
// even if the folder do not exist anymore, clean the list on the project
getFolderHelper(project.getEmfProject()).deleteFolder(completePath);
@@ -1802,7 +1790,6 @@ 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();
@@ -2378,37 +2365,8 @@ 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);
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;
}
@@ -2665,11 +2623,6 @@ public class LocalRepositoryFactory extends AbstractEMFRepositoryFactory impleme
}
this.copyScreenshotFlag = false;
}
saveContextLinkInfo(item);
}
private void saveContextLinkInfo(Item item) throws PersistenceException {
ContextLinkService.getInstance().saveContextLink(item);
}
@Override
@@ -3069,7 +3022,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);
}

View File

@@ -33,7 +33,6 @@ 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;
@@ -176,14 +175,12 @@ 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;

View File

@@ -12,8 +12,6 @@
// ============================================================================
package org.talend.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -23,11 +21,9 @@ import java.util.regex.Pattern;
*/
public class ProductVersion implements Comparable<ProductVersion> {
private static final Pattern THREE_DIGIT_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+).*"); //$NON-NLS-1$
private static final Pattern THREE_DIGIT_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 static final Pattern EXTENDED_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*");
private int major;
@@ -37,10 +33,6 @@ public class ProductVersion implements Comparable<ProductVersion> {
private boolean setMicro = false;
private String extraInfo;
private boolean setExtraInfo = false;
/**
* ProductVersion constructor.
*
@@ -56,20 +48,6 @@ 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.
*
@@ -84,17 +62,6 @@ 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".
*
@@ -106,7 +73,6 @@ 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));
@@ -122,29 +88,6 @@ 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".
*
@@ -178,17 +121,6 @@ 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;
}
@@ -199,9 +131,6 @@ 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;
}
@@ -226,11 +155,6 @@ 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;
}
@@ -239,16 +163,12 @@ public class ProductVersion implements Comparable<ProductVersion> {
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(major);
stringBuilder.append("."); //$NON-NLS-1$
stringBuilder.append(".");
stringBuilder.append(minor);
if (setMicro) {
stringBuilder.append("."); //$NON-NLS-1$
stringBuilder.append(".");
stringBuilder.append(micro);
}
if (setExtraInfo) {
stringBuilder.append("."); //$NON-NLS-1$
stringBuilder.append(extraInfo);
}
return stringBuilder.toString();
}
@@ -263,16 +183,4 @@ 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;
}
}

View File

@@ -44,7 +44,7 @@ public class StudioEncryption {
private static final String PREFIX_PASSWORD_M3 = "ENC:[";
public static final String PREFIX_PASSWORD = "enc:"; //$NON-NLS-1$
private 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}+");

View File

@@ -1,82 +0,0 @@
// ============================================================================
//
// Copyright (C) 2006-2019 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.repository.utils;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.talend.core.model.properties.ItemState;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.PropertiesFactory;
import org.talend.core.model.properties.Property;
import org.talend.core.model.repository.IRepositoryViewObject;
import org.talend.core.model.repository.RepositoryViewObject;
import org.talend.core.repository.utils.RepositoryNodeSortUtil;
/**
* @author hwang
*
*/
public class RepositoryNodeSortUtilTest {
@Test
public void testGetSortVersion() {
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId("property1"); //$NON-NLS-1$
property1.setVersion("2.9"); //$NON-NLS-1$
property1.setLabel("test1");//$NON-NLS-1$
ProcessItem item1 = PropertiesFactory.eINSTANCE.createProcessItem();
ItemState state = PropertiesFactory.eINSTANCE.createItemState();
state.setDeleted(false);
item1.setState(state);
property1.setItem(item1);
IRepositoryViewObject object1 = new RepositoryViewObject(property1, true);
property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId("property1"); //$NON-NLS-1$
property1.setVersion("0.3"); //$NON-NLS-1$
property1.setLabel("test1");//$NON-NLS-1$
item1 = PropertiesFactory.eINSTANCE.createProcessItem();
state = PropertiesFactory.eINSTANCE.createItemState();
state.setDeleted(false);
item1.setState(state);
property1.setItem(item1);
IRepositoryViewObject object2 = new RepositoryViewObject(property1, true);
property1 = PropertiesFactory.eINSTANCE.createProperty();
property1.setId("property1"); //$NON-NLS-1$
property1.setVersion("2.11"); //$NON-NLS-1$
property1.setLabel("test1");//$NON-NLS-1$
item1 = PropertiesFactory.eINSTANCE.createProcessItem();
state = PropertiesFactory.eINSTANCE.createItemState();
state.setDeleted(false);
item1.setState(state);
property1.setItem(item1);
IRepositoryViewObject object3 = new RepositoryViewObject(property1, true);
List<IRepositoryViewObject> temp = new ArrayList<IRepositoryViewObject>();
RepositoryNodeSortUtil util = new RepositoryNodeSortUtil();
temp = new ArrayList<IRepositoryViewObject>();
temp.add(object3);
temp.add(object2);
temp.add(object1);
List<IRepositoryViewObject> result = util.getSortVersion(temp);
assertTrue("0.3".equals(result.get(0).getVersion()));
assertTrue("2.9".equals(result.get(1).getVersion()));
assertTrue("2.11".equals(result.get(2).getVersion()));
}
}

View File

@@ -12,25 +12,32 @@
// ============================================================================
package org.talend.metadata.managment.ui.utils;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
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;
@@ -101,8 +108,7 @@ public class ConnectionContextHelperTest {
contextItem.setProperty(myContextProperty);
contextItem.setDefaultContext("Default");
Set<String> set = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextManager, false,
new HashMap<String, String>());
Set<String> set = ConnectionContextHelper.checkAndAddContextVariables(contextItem, contextManager, false);
assertTrue(set.size() == 2);
}

View File

@@ -12,10 +12,10 @@ package org.talend.utils;
//
// ============================================================================
import java.util.Calendar;
import junit.framework.TestCase;
import org.talend.utils.ProductVersion;
/***/
public class ProductVersionTest extends TestCase {
@@ -28,14 +28,6 @@ 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"));
@@ -48,7 +40,6 @@ 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() {
@@ -80,18 +71,5 @@ 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);
}
}