You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2020/03/24 16:53:23 UTC
[unomi] branch master updated: UNOMI-297 Add /events/{id} endpoint
and getEvent(id) method (#140)
This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/master by this push:
new c0c0c94 UNOMI-297 Add /events/{id} endpoint and getEvent(id) method (#140)
c0c0c94 is described below
commit c0c0c94f11a2ace47465a34ff67c803fba836421
Author: Pavel Milkevich <pa...@gmail.com>
AuthorDate: Tue Mar 24 19:53:15 2020 +0300
UNOMI-297 Add /events/{id} endpoint and getEvent(id) method (#140)
- also updated search endpoint to use corresponding service method
---
.../org/apache/unomi/api/services/EventService.java | 9 +++++++++
.../org/apache/unomi/rest/EventServiceEndpoint.java | 17 ++++++++++++++++-
.../unomi/services/impl/events/EventServiceImpl.java | 5 +++++
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/api/src/main/java/org/apache/unomi/api/services/EventService.java b/api/src/main/java/org/apache/unomi/api/services/EventService.java
index af0dbc0..84c1ef5 100644
--- a/api/src/main/java/org/apache/unomi/api/services/EventService.java
+++ b/api/src/main/java/org/apache/unomi/api/services/EventService.java
@@ -124,6 +124,15 @@ public interface EventService {
*/
PartialList<Event> search(Query query);
+
+ /**
+ * Retrieves the {@link Event} by its identifier.
+ *
+ * @param id the identifier of the {@link Event} to retrieve
+ * @return the {@link Event} identified by the specified identifier or {@code null} if no such profile exists
+ */
+ Event getEvent(final String id);
+
/**
* Checks whether the specified event has already been raised either for the associated session or profile depending on the specified {@code session} parameter.
*
diff --git a/rest/src/main/java/org/apache/unomi/rest/EventServiceEndpoint.java b/rest/src/main/java/org/apache/unomi/rest/EventServiceEndpoint.java
index d9e028b..f548d77 100644
--- a/rest/src/main/java/org/apache/unomi/rest/EventServiceEndpoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/EventServiceEndpoint.java
@@ -24,8 +24,10 @@ import org.apache.unomi.api.services.EventService;
import javax.jws.WebMethod;
import javax.jws.WebService;
+import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@@ -49,6 +51,7 @@ public class EventServiceEndpoint {
/**
* Allows to search events using a query.
+ *
* @param query the query object to use to search for events. You can specify offset and limits along with a
* condition tree.
* @return a partial list containing the events that match the query.
@@ -56,7 +59,19 @@ public class EventServiceEndpoint {
@POST
@Path("/search")
public PartialList<Event> searchEvents(Query query) {
- return eventService.searchEvents(query.getCondition(), query.getOffset(), query.getLimit());
+ return eventService.search(query);
+ }
+
+ /**
+ * Allows to retrieve event by id.
+ *
+ * @param id the event id.
+ * @return {@link Event} with the provided id.
+ */
+ @GET
+ @Path("/{id}")
+ public Event getEvents(@PathParam("id") final String id) {
+ return eventService.getEvent(id);
}
}
diff --git a/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java b/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
index 4162549..2a1a092 100644
--- a/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/impl/events/EventServiceImpl.java
@@ -268,6 +268,11 @@ public class EventServiceImpl implements EventService {
}
}
+ @Override
+ public Event getEvent(String id) {
+ return persistenceService.load(id, Event.class);
+ }
+
public boolean hasEventAlreadyBeenRaised(Event event, boolean session) {
List<Condition> conditions = new ArrayList<Condition>();