Repository: incubator-unomi Updated Branches: refs/heads/feature-UNOMI-117 003f8e9c8 -> f479d8f5d
UNOMI-117 apply changes after review from @shuber Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/f479d8f5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/f479d8f5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/f479d8f5 Branch: refs/heads/feature-UNOMI-117 Commit: f479d8f5db528357db2dd0151b7fd4a98e3fd6ff Parents: 003f8e9 Author: dgaillard <[email protected]> Authored: Thu Oct 5 16:54:08 2017 +0200 Committer: dgaillard <[email protected]> Committed: Thu Oct 5 16:54:08 2017 +0200 ---------------------------------------------------------------------- .../src/test/scala/unomi/AdminScenario.scala | 8 +- .../elasticsearch/ESCustomObjectMapper.java | 1 + .../persistence/elasticsearch/ESItemMixIn.java | 1 + .../apache/unomi/shell/migration/Migration.java | 16 ++++ .../shell/migration/impl/MigrationTo130.java | 90 ++++++++++---------- .../shell/services/UnomiManagementService.java | 9 ++ .../resources/OSGI-INF/blueprint/blueprint.xml | 4 +- 7 files changed, 78 insertions(+), 51 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/f479d8f5/performance-tests/src/test/scala/unomi/AdminScenario.scala ---------------------------------------------------------------------- diff --git a/performance-tests/src/test/scala/unomi/AdminScenario.scala b/performance-tests/src/test/scala/unomi/AdminScenario.scala index 74be4d0..1139ab7 100644 --- a/performance-tests/src/test/scala/unomi/AdminScenario.scala +++ b/performance-tests/src/test/scala/unomi/AdminScenario.scala @@ -101,19 +101,19 @@ object AdminScenario { // view the engaged users for the picked campaign ID val campaignEngaged = feed(requestsFeed) - .exec(http("Profile tags").get("/cxs/definitions/tags/profileTags") + .exec(http("Profile system tags").get("/cxs/definitions/systemTags/profileTags") .headers(adminHeaders) .check(jsonPath("$..id").find.is("profileTags"))) - .exec(http("Existing profile properties").get("/cxs/profiles/existingProperties?tag=profileProperties&itemType=profile") + .exec(http("Existing profile properties").get("/cxs/profiles/existingProperties?tag=profileProperties&itemType=profile&isSystemTag=true") .headers(adminHeaders) .check(jsonPath("$..itemId").find.exists)) - .exec(http("Profile conditions").get("/cxs/definitions/conditions/tags/profileCondition") + .exec(http("Profile conditions").get("/cxs/definitions/conditions/systemTags/profileCondition") .headers(adminHeaders) .check(jsonPath("$..id").find.is("booleanCondition"))) - .exec(http("Profile conditions").get("/cxs/definitions/conditions/tags/usableInPastEventCondition") + .exec(http("Profile conditions").get("/cxs/definitions/conditions/systemTags/usableInPastEventCondition") .headers(adminHeaders) .check(jsonPath("$..id").find.exists)) http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/f479d8f5/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESCustomObjectMapper.java ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESCustomObjectMapper.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESCustomObjectMapper.java index 119d1b2..66e0e89 100644 --- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESCustomObjectMapper.java +++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESCustomObjectMapper.java @@ -21,6 +21,7 @@ import org.apache.unomi.api.Item; import org.apache.unomi.persistence.spi.CustomObjectMapper; /** + * This CustomObjectMapper is used to avoid the version parameter to be registered in ES * @author dgaillard */ public class ESCustomObjectMapper extends CustomObjectMapper { http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/f479d8f5/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESItemMixIn.java ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESItemMixIn.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESItemMixIn.java index 40ea3c3..c20d8ef 100644 --- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESItemMixIn.java +++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ESItemMixIn.java @@ -19,6 +19,7 @@ package org.apache.unomi.persistence.elasticsearch; import com.fasterxml.jackson.annotation.JsonIgnore; /** + * This mixin is used in ESCustomObjectMapper to avoid the version parameter to be registered in ES * @author dgaillard */ public abstract class ESItemMixIn { http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/f479d8f5/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/Migration.java ---------------------------------------------------------------------- diff --git a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/Migration.java b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/Migration.java index 08fb797..50307cb 100644 --- a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/Migration.java +++ b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/Migration.java @@ -23,12 +23,28 @@ import org.osgi.framework.Version; import java.io.IOException; /** + * This interface must be implemented if you create a new migration class * @author dgaillard */ public interface Migration { + /** + * This method return the minimal version before applying this migration + * TODO: not used for now + * @return return the version + */ Version getFromVersion(); + /** + * This method return the target version after migration + * @return the target version + */ Version getToVersion(); + /** + * This method is called to execute the migration + * @param session CommandSession + * @param httpClient CloseableHttpClient + * @throws IOException + */ void execute(CommandSession session, CloseableHttpClient httpClient) throws IOException; } http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/f479d8f5/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo130.java ---------------------------------------------------------------------- diff --git a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo130.java b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo130.java index a2cf255..bb252f6 100644 --- a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo130.java +++ b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/impl/MigrationTo130.java @@ -36,7 +36,7 @@ public class MigrationTo130 implements Migration { private CloseableHttpClient httpClient; private CommandSession session; - private LinkedHashMap<String, List<String>> tagsStructurePriorTo200; + private LinkedHashMap<String, List<String>> tagsStructurePriorTo130; @Override public Version getFromVersion() { @@ -63,7 +63,7 @@ public class MigrationTo130 implements Migration { } private void migrateTags() throws IOException { - initTagsStructurePriorTo200(); + initTagsStructurePriorTo130(); String hostAddress = ConsoleUtils.askUserWithDefaultAnswer(session, "Host address (default = http://localhost:9200): ", "http://localhost:9200"); String tagsOperation = ConsoleUtils.askUserWithAuthorizedAnswer(session, "How to manage tags?\nno change: will keep tags in tags property\ncopy: will duplicate tags in systemTags property\nmove: will move tags in systemTags property\n(default/copy/move): ", Arrays.asList("no change", "copy", "move")); @@ -138,8 +138,8 @@ public class MigrationTo130 implements Migration { } for (String tag : tagsBeforeMigration) { - if (tagsStructurePriorTo200.containsKey(tag)) { - tagsAfterMigration.addAll(tagsStructurePriorTo200.get(tag)); + if (tagsStructurePriorTo130.containsKey(tag)) { + tagsAfterMigration.addAll(tagsStructurePriorTo130.get(tag)); } tagsAfterMigration.add(tag); } @@ -185,46 +185,46 @@ public class MigrationTo130 implements Migration { return tags; } - private void initTagsStructurePriorTo200() { - tagsStructurePriorTo200 = new LinkedHashMap<>(); - tagsStructurePriorTo200.put("landing", Collections.singletonList("campaign")); - tagsStructurePriorTo200.put("parameter", Collections.singletonList("campaign")); - tagsStructurePriorTo200.put("referrer", Collections.singletonList("campaign")); - - tagsStructurePriorTo200.put("eventCondition", Collections.singletonList("condition")); - tagsStructurePriorTo200.put("profileCondition", Collections.singletonList("condition")); - tagsStructurePriorTo200.put("sessionCondition", Collections.singletonList("condition")); - tagsStructurePriorTo200.put("sourceEventCondition", Collections.singletonList("condition")); - tagsStructurePriorTo200.put("trackedCondition", Collections.singletonList("condition")); - tagsStructurePriorTo200.put("usableInPastEventCondition", Collections.singletonList("condition")); - - tagsStructurePriorTo200.put("formMappingRule", Collections.<String>emptyList()); - - tagsStructurePriorTo200.put("downloadGoal", Collections.singletonList("goal")); - tagsStructurePriorTo200.put("formGoal", Collections.singletonList("goal")); - tagsStructurePriorTo200.put("funnelGoal", Collections.singletonList("goal")); - tagsStructurePriorTo200.put("landingPageGoal", Collections.singletonList("goal")); - tagsStructurePriorTo200.put("pageVisitGoal", Collections.singletonList("goal")); - tagsStructurePriorTo200.put("videoGoal", Collections.singletonList("goal")); - - tagsStructurePriorTo200.put("aggregated", Collections.singletonList("profileTags")); - tagsStructurePriorTo200.put("autocompleted", Collections.singletonList("profileTags")); - tagsStructurePriorTo200.put("demographic", Collections.singletonList("profileTags")); - tagsStructurePriorTo200.put("event", Collections.singletonList("profileTags")); - tagsStructurePriorTo200.put("geographic", Collections.singletonList("profileTags")); - tagsStructurePriorTo200.put("logical", Collections.singletonList("profileTags")); - - tagsStructurePriorTo200.put("profileProperties", Collections.singletonList("properties")); - tagsStructurePriorTo200.put("systemProfileProperties", Arrays.asList("properties", "profileProperties")); - tagsStructurePriorTo200.put("basicProfileProperties", Arrays.asList("properties", "profileProperties")); - tagsStructurePriorTo200.put("leadProfileProperties", Arrays.asList("properties", "profileProperties")); - tagsStructurePriorTo200.put("contactProfileProperties", Arrays.asList("properties", "profileProperties")); - tagsStructurePriorTo200.put("socialProfileProperties", Arrays.asList("properties", "profileProperties")); - tagsStructurePriorTo200.put("personalProfileProperties", Arrays.asList("properties", "profileProperties")); - tagsStructurePriorTo200.put("workProfileProperties", Arrays.asList("properties", "profileProperties")); - - tagsStructurePriorTo200.put("sessionProperties", Collections.singletonList("properties")); - tagsStructurePriorTo200.put("geographicSessionProperties", Arrays.asList("properties", "sessionProperties")); - tagsStructurePriorTo200.put("technicalSessionProperties", Arrays.asList("properties", "sessionProperties")); + private void initTagsStructurePriorTo130() { + tagsStructurePriorTo130 = new LinkedHashMap<>(); + tagsStructurePriorTo130.put("landing", Collections.singletonList("campaign")); + tagsStructurePriorTo130.put("parameter", Collections.singletonList("campaign")); + tagsStructurePriorTo130.put("referrer", Collections.singletonList("campaign")); + + tagsStructurePriorTo130.put("eventCondition", Collections.singletonList("condition")); + tagsStructurePriorTo130.put("profileCondition", Collections.singletonList("condition")); + tagsStructurePriorTo130.put("sessionCondition", Collections.singletonList("condition")); + tagsStructurePriorTo130.put("sourceEventCondition", Collections.singletonList("condition")); + tagsStructurePriorTo130.put("trackedCondition", Collections.singletonList("condition")); + tagsStructurePriorTo130.put("usableInPastEventCondition", Collections.singletonList("condition")); + + tagsStructurePriorTo130.put("formMappingRule", Collections.<String>emptyList()); + + tagsStructurePriorTo130.put("downloadGoal", Collections.singletonList("goal")); + tagsStructurePriorTo130.put("formGoal", Collections.singletonList("goal")); + tagsStructurePriorTo130.put("funnelGoal", Collections.singletonList("goal")); + tagsStructurePriorTo130.put("landingPageGoal", Collections.singletonList("goal")); + tagsStructurePriorTo130.put("pageVisitGoal", Collections.singletonList("goal")); + tagsStructurePriorTo130.put("videoGoal", Collections.singletonList("goal")); + + tagsStructurePriorTo130.put("aggregated", Collections.singletonList("profileTags")); + tagsStructurePriorTo130.put("autocompleted", Collections.singletonList("profileTags")); + tagsStructurePriorTo130.put("demographic", Collections.singletonList("profileTags")); + tagsStructurePriorTo130.put("event", Collections.singletonList("profileTags")); + tagsStructurePriorTo130.put("geographic", Collections.singletonList("profileTags")); + tagsStructurePriorTo130.put("logical", Collections.singletonList("profileTags")); + + tagsStructurePriorTo130.put("profileProperties", Collections.singletonList("properties")); + tagsStructurePriorTo130.put("systemProfileProperties", Arrays.asList("properties", "profileProperties")); + tagsStructurePriorTo130.put("basicProfileProperties", Arrays.asList("properties", "profileProperties")); + tagsStructurePriorTo130.put("leadProfileProperties", Arrays.asList("properties", "profileProperties")); + tagsStructurePriorTo130.put("contactProfileProperties", Arrays.asList("properties", "profileProperties")); + tagsStructurePriorTo130.put("socialProfileProperties", Arrays.asList("properties", "profileProperties")); + tagsStructurePriorTo130.put("personalProfileProperties", Arrays.asList("properties", "profileProperties")); + tagsStructurePriorTo130.put("workProfileProperties", Arrays.asList("properties", "profileProperties")); + + tagsStructurePriorTo130.put("sessionProperties", Collections.singletonList("properties")); + tagsStructurePriorTo130.put("geographicSessionProperties", Arrays.asList("properties", "sessionProperties")); + tagsStructurePriorTo130.put("technicalSessionProperties", Arrays.asList("properties", "sessionProperties")); } } http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/f479d8f5/tools/shell-commands/src/main/java/org/apache/unomi/shell/services/UnomiManagementService.java ---------------------------------------------------------------------- diff --git a/tools/shell-commands/src/main/java/org/apache/unomi/shell/services/UnomiManagementService.java b/tools/shell-commands/src/main/java/org/apache/unomi/shell/services/UnomiManagementService.java index e77f4b9..f4070c0 100644 --- a/tools/shell-commands/src/main/java/org/apache/unomi/shell/services/UnomiManagementService.java +++ b/tools/shell-commands/src/main/java/org/apache/unomi/shell/services/UnomiManagementService.java @@ -19,11 +19,20 @@ package org.apache.unomi.shell.services; import org.osgi.framework.BundleException; /** + * This service provide method to manage unomi * @author dgaillard */ public interface UnomiManagementService { + /** + * This method will start Apache Unomi + * @throws BundleException + */ void startUnomi() throws BundleException; + /** + * This method will stop Apache Unomi + * @throws BundleException + */ void stopUnomi() throws BundleException; } http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/f479d8f5/tools/shell-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/tools/shell-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/tools/shell-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml index 7b31650..65f91f4 100644 --- a/tools/shell-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ b/tools/shell-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml @@ -21,7 +21,7 @@ xmlns:shell="http://karaf.apache.org/xmlns/shell/v1.1.0" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> - <bean id="migrateTo200" class="org.apache.unomi.shell.migration.impl.MigrationTo130"/> + <bean id="migrateTo130" class="org.apache.unomi.shell.migration.impl.MigrationTo130"/> <shell:command-bundle> <shell:command> @@ -29,7 +29,7 @@ <shell:property name="migrations"> <list> <!-- Migration beans must be executed in the right order so you must place new bean at the end of this list --> - <ref component-id="migrateTo200"/> + <ref component-id="migrateTo130"/> </list> </shell:property> </shell:action>
