diff --git a/app/server/appsmith-plugins/amazons3Plugin/src/main/java/com/external/plugins/AmazonS3Plugin.java b/app/server/appsmith-plugins/amazons3Plugin/src/main/java/com/external/plugins/AmazonS3Plugin.java index 3a824aecb0..4549eda84f 100644 --- a/app/server/appsmith-plugins/amazons3Plugin/src/main/java/com/external/plugins/AmazonS3Plugin.java +++ b/app/server/appsmith-plugins/amazons3Plugin/src/main/java/com/external/plugins/AmazonS3Plugin.java @@ -63,6 +63,7 @@ import static com.appsmith.external.constants.ActionConstants.ACTION_CONFIGURATI import static com.appsmith.external.constants.ActionConstants.ACTION_CONFIGURATION_PATH; import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormData; import static com.appsmith.external.helpers.PluginUtils.getValueSafelyFromFormDataOrDefault; +import static com.appsmith.external.helpers.PluginUtils.setValueSafelyInFormData; import static com.external.plugins.constants.FieldName.BUCKET; import static com.external.plugins.constants.FieldName.COMMAND; import static com.external.plugins.constants.FieldName.CREATE_DATATYPE; @@ -898,9 +899,13 @@ public class AmazonS3Plugin extends BasePlugin { public Mono getDatasourceMetadata(List pluginSpecifiedTemplates, DatasourceConfiguration datasourceConfiguration) { - // Get the metadata from the datasource using pluginSpecifiedTemplate by executing the DB query + // TODO : Ignore the plugin specified templates. Once trigger functionality is implemented for UQI, replace + // this as well with trigger functions + Map configMap = new HashMap<>(); + setValueSafelyInFormData(configMap, COMMAND, "LIST_BUCKETS"); + ActionConfiguration actionConfiguration = new ActionConfiguration(); - actionConfiguration.setPluginSpecifiedTemplates(pluginSpecifiedTemplates); + actionConfiguration.setFormData(configMap); return datasourceCreate(datasourceConfiguration) .flatMap(connection -> execute(connection, datasourceConfiguration, actionConfiguration)); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/CreateDBTablePageSolution.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/CreateDBTablePageSolution.java index 77abd7eebe..940bea5a4e 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/CreateDBTablePageSolution.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/CreateDBTablePageSolution.java @@ -312,7 +312,7 @@ public class CreateDBTablePageSolution { if (Entity.S3_PLUGIN_PACKAGE_NAME.equals(plugin.getPackageName()) && !CollectionUtils.isEmpty(templateActionList)) { mappedColumnsAndTableName.put( - templateActionList.get(0).getUnpublishedAction().getActionConfiguration().getPluginSpecifiedTemplates().get(1).getValue().toString(), + (String) templateActionList.get(0).getUnpublishedAction().getActionConfiguration().getFormData().get("bucket"), tableName ); } @@ -573,7 +573,17 @@ public class CreateDBTablePageSolution { } else { // Recursively replace the column names from template table with user provided table using mappedColumns if (property.getValue() instanceof String) { - final Matcher matcher = WORD_PATTERN.matcher(property.getValue().toString()); + + // In case the entire value finds a match in the mappedColumns, replace it + Pattern replacePattern = Pattern.compile(Pattern.quote(property.getValue().toString())); + Matcher matcher = replacePattern.matcher(property.getValue().toString()); + property.setValue(matcher.replaceAll(key -> + mappedColumns.get(key.group()) == null ? key.group() : mappedColumns.get(key.group())) + ); + + // If the column name is present inside a string (like json), then find all the words and replace + // the column name with user one. + matcher = WORD_PATTERN.matcher(property.getValue().toString()); property.setValue(matcher.replaceAll(key -> mappedColumns.get(key.group()) == null ? key.group() : mappedColumns.get(key.group())) ); diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/CreateDBTablePageSolutionTests.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/CreateDBTablePageSolutionTests.java index f970cfa59c..857ae4ac90 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/CreateDBTablePageSolutionTests.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/CreateDBTablePageSolutionTests.java @@ -581,7 +581,7 @@ public class CreateDBTablePageSolutionTests { for (NewAction action : actions) { ActionConfiguration actionConfiguration = action.getUnpublishedAction().getActionConfiguration(); assertThat(action.getUnpublishedAction().getDatasource().getStructure()).isNull(); - assertThat(actionConfiguration.getPluginSpecifiedTemplates().get(1).getValue().toString()) + assertThat(actionConfiguration.getFormData().get("bucket")) .isEqualTo(resource.getTableName()); }