Repository: incubator-unomi Updated Branches: refs/heads/master 510c524bf -> 8b068c291
UNOMI-182 fix code issues Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/8b068c29 Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/8b068c29 Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/8b068c29 Branch: refs/heads/master Commit: 8b068c291dda582f7d0e7cec078384f12e20c082 Parents: 510c524 Author: dgaillard <[email protected]> Authored: Wed May 23 12:29:39 2018 +0200 Committer: dgaillard <[email protected]> Committed: Wed May 23 12:29:39 2018 +0200 ---------------------------------------------------------------------- .../unomi/shell/commands/DeployDefinition.java | 46 ++++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/8b068c29/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java ---------------------------------------------------------------------- diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java index abde5ae..e4cbd7f 100644 --- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java +++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java @@ -56,7 +56,7 @@ public class DeployDefinition extends OsgiCommandSupport { @Argument(index = 0, name = "bundleId", description = "The bundle identifier where to find the definition", required = true, multiValued = false) Long bundleIdentifier; - @Argument(index = 1, name = "fileName", description = "The name of the file which contains the definition", required = true, multiValued = false) + @Argument(index = 1, name = "fileName", description = "The name of the file which contains the definition, without its extension (e.g: firstName)", required = true, multiValued = false) String fileName; protected Object doExecute() throws Exception { @@ -66,10 +66,10 @@ public class DeployDefinition extends OsgiCommandSupport { return null; } - String definitionTypeAnswer = askUserWithAuthorizedAnswer(session,"Which kind of definition do you want to load?" + getDefinitionTypesWithNumber(), Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10")); + String definitionTypeAnswer = askUserWithAuthorizedAnswer(session,"Which kind of definition do you want to load?" + getDefinitionTypesWithNumber() + "\n", Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")); String definitionType = definitionTypes.get(new Integer(definitionTypeAnswer)); - String path = "META-INF/cxs/" + definitionType; + String path = getDefinitionTypePath(definitionType); Enumeration<URL> definitions = bundleToUpdate.findEntries(path, "*.json", true); if (definitions == null) { System.out.println("Couldn't find definitions in bundle with id: " + bundleIdentifier + " and definition path: " + path); @@ -104,7 +104,7 @@ public class DeployDefinition extends OsgiCommandSupport { private String getDefinitionTypesWithNumber() { StringBuilder definitionTypesWithNumber = new StringBuilder(); for (int i = 0; i < definitionTypes.size(); i++) { - definitionTypesWithNumber.append("\n").append(i + 1).append(". ").append(definitionTypes.get(i)); + definitionTypesWithNumber.append("\n").append(i).append(". ").append(definitionTypes.get(i)); } return definitionTypesWithNumber.toString(); } @@ -161,6 +161,44 @@ public class DeployDefinition extends OsgiCommandSupport { } } + private String getDefinitionTypePath(String definitionType) { + StringBuilder path = new StringBuilder("META-INF/cxs/"); + switch (definitionType) { + case "condition": + path.append("conditions"); + break; + case "action": + path.append("actions"); + break; + case "goal": + path.append("goals"); + break; + case "campaign": + path.append("campaigns"); + break; + case "persona": + path.append("personas"); + break; + case "persona with session": + path.append("personas"); + break; + case "property": + path.append("properties"); + break; + case "rule": + path.append("rules"); + break; + case "segment": + path.append("segments"); + break; + case "scoring": + path.append("scoring"); + break; + } + + return path.toString(); + } + public void setDefinitionsService(DefinitionsService definitionsService) { this.definitionsService = definitionsService; }
