Repository: incubator-unomi Updated Branches: refs/heads/master d7cce6a24 -> 044fd8883
UNOMI-81 add new entry point to allow tag creation from plugins Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/e1e5b581 Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/e1e5b581 Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/e1e5b581 Branch: refs/heads/master Commit: e1e5b58109cb71c00fe0b3725e0b2daa3a7f18a0 Parents: 06030be Author: dgaillard <[email protected]> Authored: Fri Feb 17 19:36:43 2017 +0100 Committer: dgaillard <[email protected]> Committed: Fri Feb 17 19:36:43 2017 +0100 ---------------------------------------------------------------------- .../apache/unomi/api/services/DefinitionsService.java | 6 ++++++ .../apache/unomi/rest/DefinitionsServiceEndPoint.java | 10 ++++++++++ .../unomi/services/services/DefinitionsServiceImpl.java | 11 +++++++++++ 3 files changed, 27 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e1e5b581/api/src/main/java/org/apache/unomi/api/services/DefinitionsService.java ---------------------------------------------------------------------- diff --git a/api/src/main/java/org/apache/unomi/api/services/DefinitionsService.java b/api/src/main/java/org/apache/unomi/api/services/DefinitionsService.java index efd446f..221b3ad 100644 --- a/api/src/main/java/org/apache/unomi/api/services/DefinitionsService.java +++ b/api/src/main/java/org/apache/unomi/api/services/DefinitionsService.java @@ -57,6 +57,12 @@ public interface DefinitionsService { Tag getTag(String tagId); /** + * Add a new tag to the list of tags + * @param tag the tag to add + */ + void addTag(Tag tag); + + /** * Retrieves all condition types. * * @return a Collection of all collection types http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e1e5b581/rest/src/main/java/org/apache/unomi/rest/DefinitionsServiceEndPoint.java ---------------------------------------------------------------------- diff --git a/rest/src/main/java/org/apache/unomi/rest/DefinitionsServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/DefinitionsServiceEndPoint.java index e9754a8..ae660ea 100644 --- a/rest/src/main/java/org/apache/unomi/rest/DefinitionsServiceEndPoint.java +++ b/rest/src/main/java/org/apache/unomi/rest/DefinitionsServiceEndPoint.java @@ -102,6 +102,16 @@ public class DefinitionsServiceEndPoint { } /** + * Add a new tag to the list of tags + * @param tag the tag to add + */ + @POST + @Path("/tags") + public void addTag(Tag tag) { + definitionsService.addTag(tag); + } + + /** * Retrieves all condition types localized using the specified language. * * @param language the language to use to localize. http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e1e5b581/services/src/main/java/org/apache/unomi/services/services/DefinitionsServiceImpl.java ---------------------------------------------------------------------- diff --git a/services/src/main/java/org/apache/unomi/services/services/DefinitionsServiceImpl.java b/services/src/main/java/org/apache/unomi/services/services/DefinitionsServiceImpl.java index 0562a5e..e839836 100644 --- a/services/src/main/java/org/apache/unomi/services/services/DefinitionsServiceImpl.java +++ b/services/src/main/java/org/apache/unomi/services/services/DefinitionsServiceImpl.java @@ -141,6 +141,10 @@ public class DefinitionsServiceImpl implements DefinitionsService, SynchronousBu } // now let's resolve all the children. + resolveTagsChildren(); + } + + private void resolveTagsChildren() { for (Tag tag : tags.values()) { if (tag.getParentId() != null && tag.getParentId().length() > 0) { Tag parentTag = tags.get(tag.getParentId()); @@ -242,6 +246,13 @@ public class DefinitionsServiceImpl implements DefinitionsService, SynchronousBu return completeTag; } + public void addTag(Tag tag) { + tag.setPluginId(bundleContext.getBundle().getBundleId()); + tags.put(tag.getId(), tag); + // now let's resolve all the children. + resolveTagsChildren(); + } + public Map<Long, List<PluginType>> getTypesByPlugin() { return pluginTypes; }
