You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by to...@apache.org on 2022/04/17 04:08:19 UTC
[shardingsphere] branch master updated: Supports the combined generation of transaction, product, and operational modes (#16881)
This is an automated email from the ASF dual-hosted git repository.
totalo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 9826246fb0e Supports the combined generation of transaction, product, and operational modes (#16881)
9826246fb0e is described below
commit 9826246fb0ee52b3cf2a4143cc59f0f00dcaa161
Author: Simple <36...@users.noreply.github.com>
AuthorDate: Sun Apr 17 12:08:08 2022 +0800
Supports the combined generation of transaction, product, and operational modes (#16881)
* Add sample configuration check
* Add sample configuration check
* delete test configuration
* add shadow
* optimization code
* add final for YamlExampleConfigurationValidator
* Supports the combined generation of transaction, product, and operational modes
* Supports the combined generation of transaction, product, and operational modes
---
.../example/generator/core/ExampleGenerator.java | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGenerator.java b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGenerator.java
index 020d8caa3f8..5603acccc94 100644
--- a/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGenerator.java
+++ b/examples/shardingsphere-example-generator/src/main/java/org/apache/shardingsphere/example/generator/core/ExampleGenerator.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.infra.autogen.version.ShardingSphereVersion;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Properties;
/**
* Example generator.
@@ -36,20 +37,23 @@ public interface ExampleGenerator {
String RESOURCES_PATH = "src/main/resources";
default void generate(final Configuration templateConfig, final YamlExampleConfiguration configuration) throws IOException, TemplateException {
- for (String eachFramework : configuration.getFrameworks()) {
- for (String eachFeature : GenerateUtil.generateCombination(configuration.getFeatures())) {
- generate(templateConfig, buildDataModel(configuration, eachFramework, eachFeature), eachFramework, eachFeature);
+ for (String eachMode : configuration.getModes()) {
+ for (String eachTransaction : configuration.getTransactions()) {
+ for (String eachFramework : configuration.getFrameworks()) {
+ for (String eachFeature : GenerateUtil.generateCombination(configuration.getFeatures())) {
+ generate(templateConfig, buildDataModel(configuration.getProps(), eachMode, eachTransaction, eachFramework, eachFeature), eachFramework, eachFeature);
+ }
+ }
}
}
}
-
- default Map<String, String> buildDataModel(final YamlExampleConfiguration configuration, final String framework, final String feature) {
+
+ default Map<String, String> buildDataModel(final Properties props, final String mode, final String transaction, final String framework, final String feature) {
Map<String, String> result = new LinkedHashMap<>();
- configuration.getProps().forEach((key, value) -> result.put(key.toString(), value.toString()));
+ props.forEach((key, value) -> result.put(key.toString(), value.toString()));
result.put("product", getType());
- // TODO support mode & transaction combination
- result.put("mode", configuration.getModes().size() > 0 ? configuration.getModes().get(0) : "");
- result.put("transaction", configuration.getTransactions().size() > 0 ? configuration.getTransactions().get(0) : "");
+ result.put("mode", mode);
+ result.put("transaction", transaction);
result.put("feature", feature);
result.put("framework", framework);
result.put("shardingsphereVersion", ShardingSphereVersion.VERSION);