UNOMI-50 add entry point to query sessions in ProfileServiceEndPoint

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

Branch: refs/heads/UNOMI-28-ES-2-X-UPGRADE
Commit: eee8d6f5585dc58b96462217cec4abe4f6cb71ba
Parents: 7e372f3
Author: dgaillard <dgaill...@jahia.com>
Authored: Wed Aug 17 17:56:01 2016 +0200
Committer: dgaillard <dgaill...@jahia.com>
Committed: Wed Aug 17 17:56:01 2016 +0200

----------------------------------------------------------------------
 .../org/apache/unomi/api/services/ProfileService.java    |  8 ++++++++
 .../org/apache/unomi/rest/ProfileServiceEndPoint.java    | 11 +++++++++++
 .../unomi/services/services/ProfileServiceImpl.java      |  8 ++++++++
 3 files changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/eee8d6f5/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 ff48abf..c13036a 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
@@ -46,6 +46,14 @@ public interface ProfileService {
     <T extends Profile> PartialList<T> search(Query query, Class<T> clazz);
 
     /**
+     * Retrieves sessions matching the specified query.
+     *
+     * @param query a {@link Query} specifying which elements to retrieve
+     * @return a {@link PartialList} of sessions matching the specified query
+     */
+    PartialList<Session> searchSessions(Query query);
+
+    /**
      * Creates a String containing comma-separated values (CSV) formatted 
version of profiles matching the specified query.
      *
      * @param query the query specifying which profiles to export

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/eee8d6f5/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 43028fe..b806378 100644
--- a/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/ProfileServiceEndPoint.java
@@ -516,4 +516,15 @@ public class ProfileServiceEndPoint {
         return profileService.deletePropertyType(propertyId);
     }
 
+    /**
+     * Retrieves sessions matching the specified query.
+     *
+     * @param query a {@link Query} specifying which elements to retrieve
+     * @return a {@link PartialList} of sessions matching the specified query
+     */
+    @POST
+    @Path("/search/sessions")
+    public PartialList<Session> searchSession(Query query) {
+        return profileService.searchSessions(query);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/eee8d6f5/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 432e1f6..521826e 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
@@ -256,6 +256,14 @@ public class ProfileServiceImpl implements ProfileService, 
SynchronousBundleList
     }
 
     public <T extends Profile> PartialList<T> search(Query query, final 
Class<T> clazz) {
+        return doSearch(query, clazz);
+    }
+
+    public PartialList<Session> searchSessions(Query query) {
+        return doSearch(query, Session.class);
+    }
+
+    private <T extends Item> PartialList<T> doSearch(Query query, Class<T> 
clazz) {
         if (query.getCondition() != null && 
definitionsService.resolveConditionType(query.getCondition())) {
             if (StringUtils.isNotBlank(query.getText())) {
                 return persistenceService.queryFullText(query.getText(), 
query.getCondition(), query.getSortby(), clazz, query.getOffset(), 
query.getLimit());

Reply via email to