You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dg...@apache.org on 2017/10/06 13:33:33 UTC

[09/15] incubator-unomi git commit: UNOMI-117 add query parameters to look in tags or system tags

UNOMI-117 add query parameters to look in tags or system tags


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/cd730387
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/cd730387
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/cd730387

Branch: refs/heads/master
Commit: cd730387c772fa3bafe7f7f51c8e358616ce0b8e
Parents: 8e6132d
Author: dgaillard <dg...@jahia.com>
Authored: Fri Sep 29 16:12:45 2017 +0200
Committer: dgaillard <dg...@jahia.com>
Committed: Fri Sep 29 16:12:45 2017 +0200

----------------------------------------------------------------------
 .../apache/unomi/api/services/ProfileService.java | 11 +++++++++++
 .../apache/unomi/rest/ProfileServiceEndPoint.java | 18 ++++++++++++------
 .../services/services/ProfileServiceImpl.java     |  7 ++++++-
 3 files changed, 29 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cd730387/api/src/main/java/org/apache/unomi/api/services/ProfileService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/unomi/api/services/ProfileService.java b/api/src/main/java/org/apache/unomi/api/services/ProfileService.java
index c8917e3..30518a8 100644
--- a/api/src/main/java/org/apache/unomi/api/services/ProfileService.java
+++ b/api/src/main/java/org/apache/unomi/api/services/ProfileService.java
@@ -330,5 +330,16 @@ public interface ProfileService {
      */
     Set<PropertyType> getExistingProperties(String tag, String itemType);
 
+    /**
+     * Retrieves the existing property types for the specified type as defined by the Item subclass public field {@code ITEM_TYPE} and with the specified tag.
+     *
+     * TODO: move to a different class
+     *
+     * @param tag      the tag we're interested in
+     * @param itemType the String representation of the item type we want to retrieve the count of, as defined by its class' {@code ITEM_TYPE} field
+     * @return all property types defined for the specified item type and with the specified tag
+     */
+    Set<PropertyType> getExistingProperties(String tag, String itemType, boolean systemTag);
+
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cd730387/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
----------------------------------------------------------------------
diff --git a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
index 770f8b6..dff5bab 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
@@ -439,19 +439,25 @@ public class ProfileServiceEndPoint {
     }
 
     /**
-     * Retrieves the existing property types for the specified type as defined by the Item subclass public field {@code ITEM_TYPE} and with the specified tag.
+     * Retrieves the existing property types for the specified type as defined by the Item subclass public field {@code ITEM_TYPE} and with the specified tag or system tag.
      *
      * TODO: move to a different class
      *
-     * @param tag      the tag we're interested in
-     * @param itemType the String representation of the item type we want to retrieve the count of, as defined by its class' {@code ITEM_TYPE} field
-     * @param language the value of the {@code Accept-Language} header to specify in which locale the properties description should be returned TODO unused
+     * @param tag           the tag we're interested in
+     * @param isSystemTag   if we should look in system tags instead of tags
+     * @param itemType      the String representation of the item type we want to retrieve the count of, as defined by its class' {@code ITEM_TYPE} field
+     * @param language      the value of the {@code Accept-Language} header to specify in which locale the properties description should be returned TODO unused
      * @return all property types defined for the specified item type and with the specified tag
      */
     @GET
     @Path("/existingProperties")
-    public Collection<PropertyType> getExistingProperties(@QueryParam("tag") String tag, @QueryParam("itemType") String itemType, @HeaderParam("Accept-Language") String language) {
-        Set<PropertyType> properties = profileService.getExistingProperties(tag, itemType);
+    public Collection<PropertyType> getExistingProperties(@QueryParam("tag") String tag, @QueryParam("isSystemTag") boolean isSystemTag, @QueryParam("itemType") String itemType, @HeaderParam("Accept-Language") String language) {
+        Set<PropertyType> properties;
+        if (isSystemTag) {
+            properties = profileService.getExistingProperties(tag, itemType, isSystemTag);
+        } else {
+            properties = profileService.getExistingProperties(tag, itemType);
+        }
         return properties;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/cd730387/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java b/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
index 17e4ea5..746dceb 100644
--- a/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/services/ProfileServiceImpl.java
@@ -295,9 +295,14 @@ public class ProfileServiceImpl implements ProfileService, SynchronousBundleList
 
     @Override
     public Set<PropertyType> getExistingProperties(String tag, String itemType) {
+        return getExistingProperties(tag, itemType, false);
+    }
+
+    @Override
+    public Set<PropertyType> getExistingProperties(String tag, String itemType, boolean systemTag) {
         Set<PropertyType> filteredProperties = new LinkedHashSet<PropertyType>();
         // TODO: here we limit the result to the definition we have, but what if some properties haven't definition but exist in ES mapping ?
-        Set<PropertyType> profileProperties = getPropertyTypeByTag(tag);
+        Set<PropertyType> profileProperties = systemTag ? getPropertyTypeBySystemTag(tag) : getPropertyTypeByTag(tag);
         Map<String, Map<String, Object>> itemMapping = persistenceService.getPropertiesMapping(itemType);
 
         if (itemMapping == null || itemMapping.isEmpty() || itemMapping.get("properties") == null || itemMapping.get("properties").get("properties") == null) {