Compare commits

...

5 Commits

Author SHA1 Message Date
Zhiwei Xue
fae1ce455c feat(TUP-36683):Selective generateAllPoms (#5772)
* feat(TUP-36683):Selective generateAllPoms (#5753)

* feat(TUP-36683):Selective generateAllPoms (#5676)
2022-11-04 17:19:48 +08:00
sbliu
bbc391c7ab fix(TUP-36726) change tooltip message (#5729) 2022-10-21 11:11:34 +08:00
sbieliaievl
bbc7dffd22 fix(APPINT-34581) - fixed versions 2022-10-18 14:00:31 +02:00
Liu Xinquan
39f3b4d0f6 fix(TDQ-20751) tDqReportRun Snowflake Context (#5704) 2022-10-17 17:18:22 +08:00
Laurent BOURGEOIS
7893b956e6 fix(TBD-14263):Support MongoDB v4+ - Spark Batch 3.1+ - GA (#5686) 2022-10-14 15:09:33 +02:00
11 changed files with 329 additions and 116 deletions

View File

@@ -13,13 +13,15 @@ public class SparkBatchMetadataTalendTypeFilter extends SparkMetadataTalendTypeF
public static List<String> dynamicTypeCompatibleComponents = Arrays.asList(
"tDeltaLakeInput",
"tDeltaLakeOutput",
"tFileInputDelimited",
"tFileInputParquet",
"tFileOutputParquet",
"tJDBCInput",
"tJDBCOutput",
"tLogRow",
"tSqlRow",
"tFileInputDelimited"
"tMongoDBInput",
"tMongoDBOutput",
"tSqlRow"
);
public SparkBatchMetadataTalendTypeFilter(INode node) {

View File

@@ -1,5 +1,6 @@
package org.talend.core.runtime.services;
import org.talend.core.GlobalServiceRegister;
import org.talend.core.IService;
import org.talend.core.model.properties.Item;
@@ -9,4 +10,11 @@ public interface IFilterService extends IService {
public boolean isFilterAccepted(Item item, String filter);
public static IFilterService get() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IFilterService.class)) {
return GlobalServiceRegister.getDefault().getService(IFilterService.class);
}
return null;
}
}

View File

@@ -380,24 +380,27 @@ public final class ProjectManager {
return null;
}
/**
* @deprecated unable to get project when resource is unloaded, use {@link #getProject(EObject)} instead
*/
public org.talend.core.model.properties.Project getProject(Project project, EObject object) {
if (object != null) {
if (object instanceof org.talend.core.model.properties.Project) {
return (org.talend.core.model.properties.Project) object;
}
if (object instanceof Property) {
return getProject(project, ((Property) object).getItem());
}
if (object instanceof Item) {
return getProject(project, ((Item) object).getParent());
}
}
// default
if (project != null) {
return project.getEmfProject();
}
return null;
// if (object != null) {
// if (object instanceof org.talend.core.model.properties.Project) {
// return (org.talend.core.model.properties.Project) object;
// }
// if (object instanceof Property) {
// return getProject(project, ((Property) object).getItem());
// }
// if (object instanceof Item) {
// return getProject(project, ((Item) object).getParent());
// }
// }
//
// // default
// if (project != null) {
// return project.getEmfProject();
// }
return getProject(object);
}
public IProject getResourceProject(org.talend.core.model.properties.Project project) {
@@ -443,7 +446,7 @@ public final class ProjectManager {
public boolean isInMainProject(Project mainProject, EObject object) {
if (object != null) {
org.talend.core.model.properties.Project project = getProject(mainProject, object);
org.talend.core.model.properties.Project project = getProject(object);
if (project != null && mainProject != null) {
return project.getTechnicalLabel().equals(mainProject.getEmfProject().getTechnicalLabel());
}

View File

@@ -14,15 +14,16 @@ package org.talend.designer.maven.tools;
import static org.talend.designer.maven.model.TalendJavaProjectConstants.*;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -64,8 +65,10 @@ import org.talend.core.model.general.ILibrariesService;
import org.talend.core.model.general.ModuleNeeded;
import org.talend.core.model.general.ModuleNeeded.ELibraryInstallStatus;
import org.talend.core.model.general.Project;
import org.talend.core.model.process.JobInfo;
import org.talend.core.model.process.ProcessUtils;
import org.talend.core.model.properties.Item;
import org.talend.core.model.properties.ProcessItem;
import org.talend.core.model.properties.ProjectReference;
import org.talend.core.model.properties.Property;
import org.talend.core.model.relationship.Relation;
@@ -525,7 +528,7 @@ public class AggregatorPomsHelper {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
try {
syncAllPomsWithoutProgress(monitor, PomIdsHelper.getPomFilter());
syncAllPomsWithoutProgress(monitor, PomIdsHelper.getPomFilter(), false);
} catch (Exception e) {
ExceptionHandler.process(e);
}
@@ -620,10 +623,11 @@ public class AggregatorPomsHelper {
}
public void syncAllPomsWithoutProgress(IProgressMonitor monitor) throws Exception {
syncAllPomsWithoutProgress(monitor, PomIdsHelper.getPomFilter());
syncAllPomsWithoutProgress(monitor, PomIdsHelper.getPomFilter(), false);
}
public void syncAllPomsWithoutProgress(IProgressMonitor monitor, String pomFilter) throws Exception {
public void syncAllPomsWithoutProgress(IProgressMonitor monitor, String pomFilter, boolean withDependencies)
throws Exception {
LOGGER.info("syncAllPomsWithoutProgress, pomFilter: " + pomFilter);
IRunProcessService runProcessService = IRunProcessService.get();
if (runProcessService == null) {
@@ -634,11 +638,43 @@ public class AggregatorPomsHelper {
Boolean isCIMode = IRunProcessService.get().isCIMode();
List<IRepositoryViewObject> objects = new ArrayList<>();
List<ERepositoryObjectType> allJobletTypes = ERepositoryObjectType.getAllTypesOfJoblet();
for (ERepositoryObjectType type : ERepositoryObjectType.getAllTypesOfProcess2()) {
if (isCIMode && withDependencies && allJobletTypes.contains(type)) {
continue;
}
objects.addAll(ProxyRepositoryFactory.getInstance().getAll(type, true, true));
}
Iterator<IRepositoryViewObject> iterator = objects.iterator();
while (iterator.hasNext()) {
IRepositoryViewObject object = iterator.next();
if (object.getProperty() == null || object.getProperty().getItem() == null) {
iterator.remove();
continue;
}
if (isCIMode && !allJobletTypes.contains(object.getRepositoryObjectType()) && IFilterService.get() != null
&& !IFilterService.get().isFilterAccepted(object.getProperty().getItem(), pomFilter)) {
iterator.remove();
continue;
}
if (isCIMode && object.isDeleted() && PomIdsHelper.getIfExcludeDeletedItems()) {
iterator.remove();
}
}
Set<Item> allItems;
if (withDependencies) {
allItems = objects.stream().flatMap(object -> {
ProcessItem item = (ProcessItem) object.getProperty().getItem();
Set<JobInfo> allJobInfos = ProcessorUtilities.getChildrenJobInfo(item, false, true);
allJobInfos.add(new JobInfo(item, item.getProcess().getDefaultContext()));
return allJobInfos.stream();
}).map(info -> info.getJobletProperty() != null ? info.getJobletProperty().getItem() : info.getProcessItem())
.collect(Collectors.toSet());
} else {
allItems = objects.stream().map(object -> object.getProperty().getItem()).collect(Collectors.toSet());
}
int size = 3 + objects.size();
int size = 3 + allItems.size();
monitor.setTaskName("Synchronize all poms"); //$NON-NLS-1$
monitor.beginTask("", size); //$NON-NLS-1$
// project pom
@@ -674,41 +710,17 @@ public class AggregatorPomsHelper {
}
// all jobs pom
List<String> modules = new ArrayList<>();
IFilterService filterService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IFilterService.class)) {
filterService = (IFilterService) GlobalServiceRegister.getDefault().getService(IFilterService.class);
}
List<Property> serviceRefJobs = getAllServiceReferencedJobs();
List<ERepositoryObjectType> allJobletTypes = ERepositoryObjectType.getAllTypesOfJoblet();
for (IRepositoryViewObject object : objects) {
if (filterService != null) {
if (isCIMode && !allJobletTypes.contains(object.getRepositoryObjectType())
&& !filterService.isFilterAccepted(object.getProperty().getItem(), pomFilter)) {
continue;
}
}
if (object.getProperty() != null && object.getProperty().getItem() != null) {
if (isCIMode && object.isDeleted() && PomIdsHelper.getIfExcludeDeletedItems()) {
continue;
}
Item item = object.getProperty().getItem();
if (ProjectManager.getInstance().isInCurrentMainProject(item)) {
monitor.subTask("Synchronize job pom: " + item.getProperty().getLabel() //$NON-NLS-1$
+ "_" + item.getProperty().getVersion()); //$NON-NLS-1$
if (runProcessService != null) {
// already filtered
runProcessService.generatePom(item, TalendProcessOptionConstants.GENERATE_POM_NO_FILTER);
} else {
ExceptionHandler.log("Cannot generate pom for " + object.getLabel()
+ " - Reason: RunProcessService is null.");
}
IFile pomFile = getItemPomFolder(item.getProperty()).getFile(TalendMavenConstants.POM_FILE_NAME);
// TODO if not work, use serviceRefJobs.contains(object.getProperty()) to judge
// filter esb data service node
if (isCIMode && !isSOAPServiceProvider(object.getProperty()) && pomFile.exists()) {
modules.add(getModulePath(pomFile));
}
for (Item item : allItems) {
if (ProjectManager.getInstance().isInCurrentMainProject(item)) {
monitor.subTask("Synchronize job pom: " + item.getProperty().getLabel() //$NON-NLS-1$
+ "_" + item.getProperty().getVersion()); //$NON-NLS-1$
runProcessService.generatePom(item, TalendProcessOptionConstants.GENERATE_POM_NO_FILTER);
IFile pomFile = getItemPomFolder(item.getProperty()).getFile(TalendMavenConstants.POM_FILE_NAME);
// filter esb data service node
// FIXME use serviceRefJobs.contains(item.getProperty()) if isSOAPServiceProvider() doesn't work.
if (isCIMode && !isSOAPServiceProvider(item.getProperty()) && pomFile.exists()) {
modules.add(getModulePath(pomFile));
}
}
monitor.worked(1);

View File

@@ -300,10 +300,19 @@ public class PomIdsHelper {
return filter;
}
private static String getPublishCloudVersion(String latestVersion) {
if (null == latestVersion) {
return "0.1.0";
} else {
int i = latestVersion.lastIndexOf('.') + 1;
return latestVersion.substring(0, i) + (Long.parseLong(latestVersion.substring(i)) + 1);
}
}
/**
* @return "<bundleVersion>".
*/
public static String getBundleVersion(Property property, String bundleVersion) {
public static String getNotIteratedBundleVersion(Property property, String bundleVersion) {
String version = null;
if (property != null) {
boolean useSnapshot = false;
@@ -327,7 +336,7 @@ public class PomIdsHelper {
/**
* @return "<featureVersion>".
*/
public static String getFeatureVersion(Property property, String featureVersion) {
public static String getNotIteratedFeatureVersion(Property property, String featureVersion) {
String version = null;
if (property != null) {
boolean useSnapshot = false;
@@ -348,6 +357,53 @@ public class PomIdsHelper {
return version;
}
/**
* @return "<bundleVersion>".
*/
public static String getBundleVersion(Property property, String bundleVersion) {
String version = null;
if (property != null) {
boolean useSnapshot = false;
if (property.getAdditionalProperties() != null) {
version = (String) property.getAdditionalProperties().get(MavenConstants.NAME_USER_VERSION);
useSnapshot = property.getAdditionalProperties().containsKey(MavenConstants.NAME_PUBLISH_AS_SNAPSHOT);
}
if(version == null) {
version = getPublishCloudVersion(bundleVersion);
}
if (version == null) {
version = VersionUtils.getPublishVersion(property.getVersion());
}
if (useSnapshot) {
version += MavenConstants.SNAPSHOT;
}
}
return version;
}
/**
* @return "<featureVersion>".
*/
public static String getFeatureVersion(Property property, String featureVersion) {
String version = null;
if (property != null) {
boolean useSnapshot = false;
if (property.getAdditionalProperties() != null) {
version = (String) property.getAdditionalProperties().get(MavenConstants.NAME_USER_VERSION);
useSnapshot = property.getAdditionalProperties().containsKey(MavenConstants.NAME_PUBLISH_AS_SNAPSHOT);
}
if(version == null) {
version = getPublishCloudVersion(featureVersion);
}
if (version == null) {
version = VersionUtils.getPublishVersion(property.getVersion());
}
if (useSnapshot) {
version += MavenConstants.SNAPSHOT;
}
}
return version;
}
public static boolean useProfileModule() {
String useProfileModule = System.getProperty("talend.profile.module");

View File

@@ -15,6 +15,7 @@ package org.talend.core.model.metadata.builder.database.jdbc;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import org.apache.commons.lang.StringUtils;
import org.talend.core.database.EDatabaseTypeName;
import org.talend.core.model.metadata.IMetadataConnection;
import org.talend.core.model.metadata.builder.ConvertionHelper;
@@ -25,6 +26,57 @@ import org.talend.cwm.helper.TaggedValueHelper;
public class ExtractorFactory {
/*
* when run the tDqReportRun, save the job's context information(selected in the job's Run tab)
*/
private static java.util.Properties STANDALONE_JOB_CONTEXT_PROPERTIES = new java.util.Properties();
public static java.util.Properties getSTANDALONE_JOB_CONTEXT_PROPERTIES() {
return STANDALONE_JOB_CONTEXT_PROPERTIES;
}
public static void setSTANDALONE_JOB_CONTEXT_PROPERTIES(java.util.Properties sTANDALONE_JOB_CONTEXT_PROPERTIES) {
STANDALONE_JOB_CONTEXT_PROPERTIES = sTANDALONE_JOB_CONTEXT_PROPERTIES;
}
public static String getJdbcUrl(java.util.Properties props) {
if (props != null) {
for (Object key : props.keySet()) {
if (key != null && String.valueOf(key).toLowerCase().endsWith("_jdbcurl")) { //$NON-NLS-1$
return String.valueOf(props.get(key));
}
}
}
return null;
}
public static final String DEFAULT = "Default"; //$NON-NLS-1$
public static String getCatalogFromJobContext(DatabaseConnection dbConn) {
return getCatalogSchemaFromJobContext(dbConn, 0);
}
public static String getSchemaFromJobContext(DatabaseConnection dbConn) {
return getCatalogSchemaFromJobContext(dbConn, 1);
}
/**
* @param index: 0-catalog, 1-schema
*/
private static String getCatalogSchemaFromJobContext(DatabaseConnection dbConn, int index) {
IUrlDbNameExtractor extractorInstance =
getExtractorInstance(dbConn, DEFAULT, DEFAULT);
if (extractorInstance != null) {
String jdbcUrl = ExtractorFactory.getJdbcUrl(getSTANDALONE_JOB_CONTEXT_PROPERTIES());
if (!StringUtils.isBlank(jdbcUrl)) {
extractorInstance.setUrl(jdbcUrl);
}
extractorInstance.initUiSchemaOrSID();
return extractorInstance.getExtractResult().get(index);
}
return null;
}
public static IUrlDbNameExtractor getExtractorInstance(DatabaseMetaData dbMetadata,
IMetadataConnection metadataConnection) {
if (dbMetadata == null) {

View File

@@ -13,8 +13,11 @@
package org.talend.metadata.managment.ui.convert;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.EList;
import org.talend.core.database.EDatabaseTypeName;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.database.jdbc.ExtractorFactory;
import org.talend.cwm.helper.CatalogHelper;
import org.talend.cwm.helper.TaggedValueHelper;
@@ -41,14 +44,22 @@ public class CatalogAdapter {
DataManager dataManager = dataManagerList.get(0);
if (dataManager instanceof DatabaseConnection) {
DatabaseConnection parentConnection = (DatabaseConnection) dataManager;
DbConnectionAdapter dbConnectionAdapter =
new DbConnectionAdapter(parentConnection);
if (dbConnectionAdapter.isSwitchWithTaggedValueMode()) {
String originalSID = TaggedValueHelper.getValueString(TaggedValueHelper.ORIGINAL_SID, parentConnection);
String targetSID = TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_SID, parentConnection);
if (catalogName.equals(originalSID)) {
return targetSID;
String originalSID =
TaggedValueHelper.getValueString(TaggedValueHelper.ORIGINAL_SID, parentConnection);
String targetSID = TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_SID, parentConnection);
if (Platform.isRunning()) {
DbConnectionAdapter dbConnectionAdapter =
new DbConnectionAdapter(parentConnection);
if (dbConnectionAdapter.isSwitchWithTaggedValueMode()) {
if (catalogName.equals(originalSID)) {
return targetSID;
}
}
} else if (EDatabaseTypeName.GENERAL_JDBC.getXMLType().equals(parentConnection.getDatabaseType())) {
String tempCatalogName = ExtractorFactory.getCatalogFromJobContext(parentConnection);
catalogName =
StringUtils.isBlank(tempCatalogName) ? catalogName.equals(originalSID) ? targetSID : catalogName
: tempCatalogName;
}
}
return catalogName;
@@ -65,13 +76,25 @@ public class CatalogAdapter {
DataManager dataManager = originalCat.getDataManager().get(0);
if (dataManager instanceof DatabaseConnection) {
DatabaseConnection parentConnection = (DatabaseConnection) dataManager;
DbConnectionAdapter dbConnectionAdapter =
new DbConnectionAdapter(parentConnection);
if (dbConnectionAdapter.isSwitchWithTaggedValueMode()) {
String originalSID = TaggedValueHelper.getValueString(TaggedValueHelper.ORIGINAL_SID, parentConnection);
String targetSID = TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_SID, parentConnection);
if (catalogName.equals(originalSID)) {
return CatalogHelper.getCatalog(parentConnection, targetSID);
String originalSID =
TaggedValueHelper.getValueString(TaggedValueHelper.ORIGINAL_SID, parentConnection);
String targetSID = TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_SID, parentConnection);
if (Platform.isRunning()) {
DbConnectionAdapter dbConnectionAdapter =
new DbConnectionAdapter(parentConnection);
if (dbConnectionAdapter.isSwitchWithTaggedValueMode()) {
if (catalogName.equals(originalSID)) {
return CatalogHelper.getCatalog(parentConnection, targetSID);
}
}
} else if (EDatabaseTypeName.GENERAL_JDBC.getXMLType().equals(parentConnection.getDatabaseType())) {
String tempCatalogName = ExtractorFactory.getCatalogFromJobContext(parentConnection);
if (StringUtils.isBlank(tempCatalogName)) {
if (catalogName.equals(originalSID)) {
return CatalogHelper.getCatalog(parentConnection, targetSID);
}
} else {
return CatalogHelper.getCatalog(parentConnection, tempCatalogName);
}
}
}

View File

@@ -17,6 +17,7 @@ import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.Platform;
import org.talend.core.database.EDatabaseTypeName;
import org.talend.core.model.context.ContextUtils;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
@@ -41,16 +42,26 @@ public class DbConnectionAdapter {
if (originalDB == null) {
return null;
}
return extractedTargetValue(TaggedValueHelper.ORIGINAL_SID, TaggedValueHelper.TARGET_SID,
String sid = extractedTargetValue(TaggedValueHelper.ORIGINAL_SID, TaggedValueHelper.TARGET_SID,
defaultCatalog);
if (!Platform.isRunning()) {
String tempSid = ExtractorFactory.getCatalogFromJobContext(originalDB);
sid = StringUtils.isBlank(tempSid) ? sid : tempSid;
}
return sid;
}
public String getUISchema(String defaultSchema) {
if (originalDB == null) {
return null;
}
return extractedTargetValue(TaggedValueHelper.ORIGINAL_UISCHEMA, TaggedValueHelper.TARGET_UISCHEMA,
String uiSchema = extractedTargetValue(TaggedValueHelper.ORIGINAL_UISCHEMA, TaggedValueHelper.TARGET_UISCHEMA,
defaultSchema);
if (!Platform.isRunning()) {
String tempUiSchema = ExtractorFactory.getSchemaFromJobContext(originalDB);
uiSchema = StringUtils.isBlank(tempUiSchema) ? uiSchema : tempUiSchema;
}
return uiSchema;
}

View File

@@ -16,8 +16,11 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.EList;
import org.talend.core.database.EDatabaseTypeName;
import org.talend.core.model.metadata.builder.connection.DatabaseConnection;
import org.talend.core.model.metadata.builder.database.jdbc.ExtractorFactory;
import org.talend.cwm.helper.CatalogHelper;
import org.talend.cwm.helper.SchemaHelper;
import org.talend.cwm.helper.TaggedValueHelper;
@@ -45,15 +48,26 @@ public class SchemaAdapter {
DataManager dataManager = findConnection(originalSch);
if (dataManager != null && dataManager instanceof DatabaseConnection) {
DatabaseConnection parentConnection = (DatabaseConnection) dataManager;
DbConnectionAdapter dbConnectionAdapter =
new DbConnectionAdapter(parentConnection);
if (dbConnectionAdapter.isSwitchWithTaggedValueMode()) {
String originalUISchema =
TaggedValueHelper.getValueString(TaggedValueHelper.ORIGINAL_UISCHEMA, parentConnection);
String targetUISchema =
TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_UISCHEMA, parentConnection);
if (schemaName.equals(originalUISchema)) {
return targetUISchema;
String originalUISchema =
TaggedValueHelper.getValueString(TaggedValueHelper.ORIGINAL_UISCHEMA, parentConnection);
String targetUISchema =
TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_UISCHEMA, parentConnection);
if (Platform.isRunning()) {
DbConnectionAdapter dbConnectionAdapter =
new DbConnectionAdapter(parentConnection);
if (dbConnectionAdapter.isSwitchWithTaggedValueMode()) {
if (schemaName.equals(originalUISchema)) {
return targetUISchema;
}
}
} else if (EDatabaseTypeName.GENERAL_JDBC.getXMLType().equals(parentConnection.getDatabaseType())) {
String tempSchemaName = ExtractorFactory.getSchemaFromJobContext(parentConnection);
if (StringUtils.isBlank(tempSchemaName)) {
if (parentConnection.isContextMode() && !StringUtils.isBlank(targetUISchema)) {
return targetUISchema;
}
} else {
return tempSchemaName;
}
}
}
@@ -92,37 +106,55 @@ public class SchemaAdapter {
// has catalog case
newParentCatalog = new CatalogAdapter(originalParentCatalog).getCatalog();
dataManager = originalParentCatalog.getDataManager().get(0);
}else {
} else {
// no catalog case
dataManager = originalSch.getDataManager().get(0);
}
if (dataManager instanceof DatabaseConnection) {
DatabaseConnection parentConnection = (DatabaseConnection) dataManager;
if (dataManager instanceof DatabaseConnection) {
DatabaseConnection parentConnection = (DatabaseConnection) dataManager;
String originalUISchema =
TaggedValueHelper.getValueString(TaggedValueHelper.ORIGINAL_UISCHEMA, parentConnection);
String targetUISchema =
TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_UISCHEMA, parentConnection);
if (Platform.isRunning()) {
DbConnectionAdapter dbConnectionAdapter =
new DbConnectionAdapter(parentConnection);
if (dbConnectionAdapter.isSwitchWithTaggedValueMode()) {
String originalUISchema =
TaggedValueHelper.getValueString(TaggedValueHelper.ORIGINAL_UISCHEMA, parentConnection);
String targetUISchema =
TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_UISCHEMA, parentConnection);
if (schemaName.equals(originalUISchema)) {
//schema switch exist then use targetUISchema name to find schema
// schema switch exist then use targetUISchema name to find schema
if (originalParentCatalog != null) {
return SchemaHelper.getSchemaByName(CatalogHelper.getSchemas(newParentCatalog), targetUISchema);
}else {
return SchemaHelper.getSchemaByName(CatalogHelper.getSchemas(newParentCatalog),
targetUISchema);
} else {
return SchemaHelper.getSchema(parentConnection, targetUISchema);
}
}else if(StringUtils.isEmpty(originalUISchema)) {
//schema switch don't exist then use schemaName to find schema
} else if (StringUtils.isEmpty(originalUISchema)) {
// schema switch don't exist then use schemaName to find schema
if (originalParentCatalog != null) {
return SchemaHelper.getSchemaByName(CatalogHelper.getSchemas(newParentCatalog), schemaName);
}else {
return SchemaHelper.getSchemaByName(CatalogHelper.getSchemas(newParentCatalog),
schemaName);
} else {
return SchemaHelper.getSchema(parentConnection, schemaName);
}
}
}
} else if (EDatabaseTypeName.GENERAL_JDBC.getXMLType().equals(parentConnection.getDatabaseType())) {
String tempSchemaName = ExtractorFactory.getSchemaFromJobContext(parentConnection);
if (StringUtils.isBlank(tempSchemaName)) {
if (parentConnection.isContextMode() && !StringUtils.isBlank(targetUISchema)) {
tempSchemaName = targetUISchema;
} else {
tempSchemaName = schemaName;
}
}
if (originalParentCatalog != null) {
return SchemaHelper.getSchemaByName(CatalogHelper.getSchemas(newParentCatalog), tempSchemaName);
} else {
return SchemaHelper.getSchema(parentConnection, tempSchemaName);
}
}
}
return originalSch;
}
@@ -132,23 +164,34 @@ public class SchemaAdapter {
}
Schema firstSchema=inputSchemas.get(0);
DataManager dataManager = findConnection(firstSchema);
String taggedTargetUISchemaName=null;
String taggedTargetUISchemaName = null;
String contextTargetUISchemaName = null;
if (dataManager instanceof DatabaseConnection) {
DatabaseConnection parentConnection = (DatabaseConnection) dataManager;
DbConnectionAdapter dbConnectionAdapter =
new DbConnectionAdapter(parentConnection);
if (dbConnectionAdapter.isSwitchWithTaggedValueMode()) {
taggedTargetUISchemaName=TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_UISCHEMA, parentConnection);
taggedTargetUISchemaName =
TaggedValueHelper.getValueString(TaggedValueHelper.TARGET_UISCHEMA, parentConnection);
}
if (Platform.isRunning()) {
if (StringUtils.isBlank(taggedTargetUISchemaName)) {
return inputSchemas;
}
} else if (EDatabaseTypeName.GENERAL_JDBC.getXMLType().equals(parentConnection.getDatabaseType())) {
contextTargetUISchemaName = ExtractorFactory.getSchemaFromJobContext(parentConnection);
if (!StringUtils.isBlank(contextTargetUISchemaName)) {
taggedTargetUISchemaName = contextTargetUISchemaName;
}
}
}
if (StringUtils.isEmpty(taggedTargetUISchemaName)) {
return inputSchemas;
}
List<Schema> schemaList=new ArrayList<>();
for(Schema targetSchema: inputSchemas) {
if(taggedTargetUISchemaName.equals(targetSchema.getName())) {
schemaList.add(targetSchema);
return schemaList;
if (!StringUtils.isBlank(taggedTargetUISchemaName)) {
List<Schema> schemaList = new ArrayList<>();
for (Schema targetSchema : inputSchemas) {
if (taggedTargetUISchemaName.equals(targetSchema.getName())) {
schemaList.add(targetSchema);
return schemaList;
}
}
}
return inputSchemas;

View File

@@ -984,7 +984,7 @@ DatabaseForm.redshift.driverVersion=Driver version
DatabaseForm.redshift.driverVersion.tip=Select a Redshift driver
DatabaseForm.redshift.useStringAdditionParam=Use string parameter
DatabaseForm.supportnls=Support NLS
DatabaseForm.supportnls.warntip=Change the previous status will take effect after restart studio
DatabaseForm.supportnls.warntip=This setting takes effect only after restarting the Studio.
DatabaseTableFilterForm.allSynonyms=All synonyms
DatabaseTableFilterForm.edit=Edit...
DatabaseTableFilterForm.editFilterName=Edit Filter Name

View File

@@ -21,6 +21,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.talend.core.model.components.IComponent;
@@ -132,11 +133,13 @@ public class MetadataTalendTypeFilterTest {
);
IComponent component = mock(IComponent.class);
when(node.getComponent()).thenReturn(component);
List<String> compatibleComponents = components.stream().filter(componentName -> {
when(component.getName()).thenReturn(componentName);
return Arrays.asList(new SparkBatchMetadataTalendTypeFilter(node).filter(types)).contains(DYNAMIC);
List<String> compatibleComponents = components.stream()
.filter(componentName -> {
when(component.getName()).thenReturn(componentName);
return Arrays.asList(new SparkBatchMetadataTalendTypeFilter(node).filter(types)).contains(DYNAMIC);
}).collect(Collectors.toList());
assertEquals(SparkBatchMetadataTalendTypeFilter.dynamicTypeCompatibleComponents, compatibleComponents);
Assertions.assertThat(SparkBatchMetadataTalendTypeFilter.dynamicTypeCompatibleComponents)
.containsExactlyInAnyOrder(compatibleComponents.toArray(new String[] {}));
}
}