branch develop updated (65ab98e -> 425fa05)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git from 65ab98e Generate webmotion mapping → in this way we get a complete declarative mapping new 425fa05 Fix mapping generation The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 425fa0596c7e6b4d78f4ae4c04849975fd0f94ef Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Sep 6 19:32:31 2016 +0200 Fix mapping generation Summary of changes: .../toolbox/GenerateWebmotionMappingMojo.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 425fa0596c7e6b4d78f4ae4c04849975fd0f94ef Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Sep 6 19:32:31 2016 +0200 Fix mapping generation --- .../toolbox/GenerateWebmotionMappingMojo.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/toolbox-maven-plugin/src/main/java/fr/ird/observe/maven/plugins/toolbox/GenerateWebmotionMappingMojo.java b/toolbox-maven-plugin/src/main/java/fr/ird/observe/maven/plugins/toolbox/GenerateWebmotionMappingMojo.java index ba9d798..7204c97 100644 --- a/toolbox-maven-plugin/src/main/java/fr/ird/observe/maven/plugins/toolbox/GenerateWebmotionMappingMojo.java +++ b/toolbox-maven-plugin/src/main/java/fr/ird/observe/maven/plugins/toolbox/GenerateWebmotionMappingMojo.java @@ -22,6 +22,7 @@ package fr.ird.observe.maven.plugins.toolbox; * #L% */ +import org.apache.commons.lang.StringUtils; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; @@ -35,13 +36,12 @@ import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.TreeSet; +import java.util.TreeMap; /** * Generate webmotion mapping file. @@ -182,7 +182,7 @@ public class GenerateWebmotionMappingMojo extends ToolboxMojoSupport { getLog().info("Generate to " + getOutputFile()); - Set<String> rules = new TreeSet<>(); + Map<String, String> rules = new TreeMap<>(); for (Map.Entry<Class<?>, Class<?>> entry : translationMap.entrySet()) { Class<?> sourceClass = entry.getKey(); @@ -192,11 +192,13 @@ public class GenerateWebmotionMappingMojo extends ToolboxMojoSupport { } + int ruleMax = 2 + rules.keySet().stream().mapToInt(String::length).max().orElse(0); + getLog().info(rules.size() + " rule(s) detected."); StringBuilder rulesBuilder = new StringBuilder(); - for (String rule : rules) { - rulesBuilder.append(rule).append("\n"); + for (Map.Entry<String, String> rule : rules.entrySet()) { + rulesBuilder.append(StringUtils.rightPad(rule.getKey(), ruleMax)).append(rule.getValue()).append("\n"); } String rulesStr = rulesBuilder.toString(); try (BufferedWriter writer = Files.newBufferedWriter(getOutputFile(), StandardCharsets.UTF_8)) { @@ -222,7 +224,7 @@ public class GenerateWebmotionMappingMojo extends ToolboxMojoSupport { this.verbose = verbose; } - private void generateForClass(Class<?> sourceClass, Class<?> targetClass, Set<String> rules) throws MissingMethodException, MismatchMethodParameterNameException, MissingClassException, IOException { + private void generateForClass(Class<?> sourceClass, Class<?> targetClass, Map<String, String> rules) throws MissingMethodException, MismatchMethodParameterNameException, MissingClassException, IOException { Objects.requireNonNull(sourceClass); Objects.requireNonNull(targetClass); @@ -235,8 +237,8 @@ public class GenerateWebmotionMappingMojo extends ToolboxMojoSupport { getLog().info("Check " + sourceClass.getName()); } - - String classTargetName = "GET,POST,DELETE /api/v1/" + String.join("/", Arrays.asList(targetClass.getName().substring(targetApiPackageName.length() + 1).split("\\."))) + "/"; + String packagePrefix = targetClass.getName().substring(targetApiPackageName.length() + 1) + "."; + String rulePrefix = "GET,POST,DELETE /api/v1/" + packagePrefix.replace("\\.", "\\"); for (Method sourceMethod : sourceDeclaredMethods) { @@ -244,10 +246,11 @@ public class GenerateWebmotionMappingMojo extends ToolboxMojoSupport { getLog().info("Generate for " + sourceClass.getName() + "#" + sourceMethod.getName()); } - String targetRule = classTargetName + sourceMethod.getName(); + String method = packagePrefix + sourceMethod.getName().replace("/", "."); + String rule = rulePrefix + sourceMethod.getName(); // generate entry in mapping - rules.add(targetRule); + rules.put(rule, method); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm