-
Notifications
You must be signed in to change notification settings - Fork 1.2k
api,server,ui: allow listing events by state #11355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,6 +243,7 @@ | |
| import com.cloud.domain.Domain; | ||
| import com.cloud.domain.DomainVO; | ||
| import com.cloud.domain.dao.DomainDao; | ||
| import com.cloud.event.Event; | ||
| import com.cloud.event.EventVO; | ||
| import com.cloud.event.dao.EventDao; | ||
| import com.cloud.event.dao.EventJoinDao; | ||
|
|
@@ -868,6 +869,7 @@ private Pair<List<Long>, Integer> searchForEventIdsAndCount(ListEventsCmd cmd) { | |
| Long startId = cmd.getStartId(); | ||
| final String resourceUuid = cmd.getResourceId(); | ||
| final String resourceTypeStr = cmd.getResourceType(); | ||
| final String stateStr = cmd.getState(); | ||
| ApiCommandResourceType resourceType = null; | ||
| Long resourceId = null; | ||
| if (resourceTypeStr != null) { | ||
|
|
@@ -897,6 +899,13 @@ private Pair<List<Long>, Integer> searchForEventIdsAndCount(ListEventsCmd cmd) { | |
| accountMgr.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.ListEntry, entity.getAccountId() == caller.getId(), entity); | ||
| } | ||
| } | ||
| Event.State state = null; | ||
| if (StringUtils.isNotBlank(stateStr)) { | ||
| state = EnumUtils.getEnum(Event.State.class, stateStr); | ||
| if (state == null) { | ||
| throw new InvalidParameterValueException(String.format("Invalid %s specified: %s", ApiConstants.STATE, stateStr)); | ||
| } | ||
| } | ||
|
|
||
| Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null); | ||
| accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, cmd.listAll(), false); | ||
|
|
@@ -920,7 +929,7 @@ private Pair<List<Long>, Integer> searchForEventIdsAndCount(ListEventsCmd cmd) { | |
| eventSearchBuilder.and("createDateB", eventSearchBuilder.entity().getCreateDate(), SearchCriteria.Op.BETWEEN); | ||
| eventSearchBuilder.and("createDateG", eventSearchBuilder.entity().getCreateDate(), SearchCriteria.Op.GTEQ); | ||
| eventSearchBuilder.and("createDateL", eventSearchBuilder.entity().getCreateDate(), SearchCriteria.Op.LTEQ); | ||
| eventSearchBuilder.and("state", eventSearchBuilder.entity().getState(), SearchCriteria.Op.NEQ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, are we sure we never depend on a search for states except for…? It seems strange just reversing the condition.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "state" was not being used in the search criteria before this. So I think it is fine to do so. |
||
| eventSearchBuilder.and("state", eventSearchBuilder.entity().getState(), SearchCriteria.Op.EQ); | ||
| eventSearchBuilder.or("startId", eventSearchBuilder.entity().getStartId(), SearchCriteria.Op.EQ); | ||
| eventSearchBuilder.and("createDate", eventSearchBuilder.entity().getCreateDate(), SearchCriteria.Op.BETWEEN); | ||
| eventSearchBuilder.and("displayEvent", eventSearchBuilder.entity().isDisplay(), SearchCriteria.Op.EQ); | ||
|
|
@@ -989,6 +998,10 @@ private Pair<List<Long>, Integer> searchForEventIdsAndCount(ListEventsCmd cmd) { | |
| sc.setParameters("archived", cmd.getArchived()); | ||
| } | ||
|
|
||
| if (state != null) { | ||
| sc.setParameters("state", state); | ||
| } | ||
|
|
||
| Pair<List<Long>, Integer> eventPair; | ||
| // event_view will not have duplicate rows for each event, so | ||
| // searchAndCount should be good enough. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.