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 ad90f10 UNOMI-332 Improvements to event-list command (#152)
ad90f10 is described below
commit ad90f101d3557af4e5f58dc9739453658c6143d1
Author: Serge Huber <[email protected]>
AuthorDate: Tue Apr 28 18:58:11 2020 +0200
UNOMI-332 Improvements to event-list command (#152)
- List is now sorted in reverse chronological order
- A new argument makes it possible to filter the list by event type.
---
manual/src/main/asciidoc/shell-commands.adoc | 4 ++--
.../java/org/apache/unomi/shell/commands/EventList.java | 16 ++++++++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/manual/src/main/asciidoc/shell-commands.adoc
b/manual/src/main/asciidoc/shell-commands.adoc
index ca22392..e951a30 100644
--- a/manual/src/main/asciidoc/shell-commands.adoc
+++ b/manual/src/main/asciidoc/shell-commands.adoc
@@ -120,9 +120,9 @@ created, EXECUTE means the rule's actions are being
executed.
|event-id
|Dumps a single event in JSON. The `event-id` can be retrieved from the
event-tail command output.
|event-list
-|[max-entries] [--csv]
+|[max-entries] [event-type] [--csv]
|List the last events processed by Apache Unomi. The `max-entries` parameter
can be used to control how many events are
-displayed (default is 100). The `--csv` argument is used to output the list as
a CSV list instead of an ASCII table.
+displayed (default is 100). The `event-type` makes it possible to filter the
list by event type. The `--csv` argument is used to output the list as a CSV
list instead of an ASCII table.
|event-search
|profile-id [event-type] [max-entries]
|This command makes it possible to search for the last events by `profile-id`
and by `event-type`. A `max-entries`
diff --git
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventList.java
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventList.java
index 9991b47..b996a70 100644
---
a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventList.java
+++
b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventList.java
@@ -23,6 +23,7 @@ import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.unomi.api.Event;
import org.apache.unomi.api.PartialList;
import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.query.Query;
import org.apache.unomi.api.services.DefinitionsService;
import org.apache.unomi.api.services.EventService;
import org.apache.unomi.common.DataTable;
@@ -42,6 +43,9 @@ public class EventList extends ListCommandSupport {
@Argument(index = 0, name = "maxEntries", description = "The maximum
number of entries to retrieve (defaults to 100)", required = false, multiValued
= false)
int maxEntries = 100;
+ @Argument(index = 1, name = "eventType", description = "If specified, will
filter the event list by the given event type", required = false, multiValued =
false)
+ String eventType = null;
+
String[] columnHeaders = new String[] {
"ID",
"Type",
@@ -59,8 +63,16 @@ public class EventList extends ListCommandSupport {
@Override
protected DataTable buildDataTable() {
- Condition matchAllCondition = new
Condition(definitionsService.getConditionType("matchAllCondition"));
- PartialList<Event> lastEvents =
eventService.searchEvents(matchAllCondition, 0, maxEntries);
+ Condition condition = new
Condition(definitionsService.getConditionType("matchAllCondition"));
+ if (eventType != null) {
+ condition = new
Condition(definitionsService.getConditionType("eventTypeCondition"));
+ condition.setParameter("eventTypeId", eventType);
+ }
+ Query query = new Query();
+ query.setLimit(maxEntries);
+ query.setCondition(condition);
+ query.setSortby("timeStamp:desc");
+ PartialList<Event> lastEvents = eventService.search(query);
DataTable dataTable = new DataTable();
for (Event event : lastEvents.getList()) {
ArrayList<Comparable> rowData = new ArrayList<>();