Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ public InboxResponse getInboxResponse(InboxRequest inboxRequest) {
inboxQueryConfiguration);
List<Inbox> items = getInboxItems(inboxRequest, inboxQueryConfiguration.getIndex());
enrichProcessInstanceInInboxItems(items);
Integer totalCount = CollectionUtils.isEmpty(inboxRequest.getInbox().getProcessSearchCriteria().getStatus()) ? 0
: getTotalApplicationCount(inboxRequest, inboxQueryConfiguration.getIndex());
List<HashMap<String, Object>> statusCountMap = CollectionUtils
.isEmpty(inboxRequest.getInbox().getProcessSearchCriteria().getStatus()) ? new ArrayList<>()
: getStatusCountMap(inboxRequest, inboxQueryConfiguration.getIndex());
Integer totalCount = getTotalApplicationCount(inboxRequest, inboxQueryConfiguration.getIndex());
List<HashMap<String, Object>> statusCountMap = getStatusCountMap(inboxRequest,
inboxQueryConfiguration.getIndex());
Integer nearingSlaCount = CollectionUtils
.isEmpty(inboxRequest.getInbox().getProcessSearchCriteria().getStatus()) ? 0
: getApplicationsNearingSlaCount(inboxRequest, inboxQueryConfiguration.getIndex());
Expand Down Expand Up @@ -194,12 +192,22 @@ public Integer getTotalApplicationCount(InboxRequest inboxRequest, String indexN
}

public List<HashMap<String, Object>> getStatusCountMap(InboxRequest inboxRequest, String indexName) {
List<BusinessService> businessServices = workflowService.getBusinessServices(inboxRequest);

HashMap<String, String> StatusIdNameMap = workflowService.getActionableStatusesForRole(
inboxRequest.getRequestInfo(), businessServices,
inboxRequest.getInbox().getProcessSearchCriteria());
log.info(StatusIdNameMap.toString());
List<String> actionableStatus = new ArrayList<>();
// add keys
StatusIdNameMap.keySet().forEach(actionableStatus::add);
Map<String, Object> finalQueryBody = queryBuilder.getStatusCountQuery(inboxRequest);
log.info("Query for status count: " + finalQueryBody.toString());
StringBuilder uri = getURI(indexName, SEARCH_PATH);
Map<String, Object> response = (Map<String, Object>) serviceRequestRepository.fetchResult(uri, finalQueryBody);
Set<String> actionableStatuses = new HashSet<>(inboxRequest.getInbox().getProcessSearchCriteria().getStatus());
Set<String> actionableStatusHSet = new HashSet<>(actionableStatus);
HashMap<String, Object> statusCountMap = parseStatusCountMapFromAggregationResponse(response,
actionableStatuses);
actionableStatusHSet);
List<HashMap<String, Object>> transformedStatusMap = transformStatusMap(inboxRequest, statusCountMap);
return transformedStatusMap;
}
Expand Down Expand Up @@ -277,13 +285,15 @@ private List<HashMap<String, Object>> transformStatusMap(InboxRequest request,
for (Map.Entry<String, Object> entry : statusCountMap.entrySet()) {
String statusId = entry.getKey();
Integer count = (Integer) entry.getValue();
HashMap<String, Object> map = new HashMap<>();
map.put(COUNT_CONSTANT, count);
map.put(APPLICATION_STATUS_KEY, statusIdToApplicationStatusMap.get(statusId));
map.put(BUSINESSSERVICE_KEY, statusIdToBusinessServiceMap.get(statusId));
map.put(STATUSID_KEY, statusId);
map.put(STATE_KEY, statusIdToStateMap.get(statusId));
statusCountMapTransformed.add(map);
if (statusIdToStateMap.get(statusId) != null) {
HashMap<String, Object> map = new HashMap<>();
map.put(COUNT_CONSTANT, count);
map.put(APPLICATION_STATUS_KEY, statusIdToApplicationStatusMap.get(statusId));
map.put(BUSINESSSERVICE_KEY, statusIdToBusinessServiceMap.get(statusId));
map.put(STATUSID_KEY, statusId);
map.put(STATE_KEY, statusIdToStateMap.get(statusId));
statusCountMapTransformed.add(map);
}
}
return statusCountMapTransformed;
}
Expand All @@ -295,9 +305,11 @@ private HashMap<String, Object> parseStatusCountMapFromAggregationResponse(Map<S
List<Map<String, Object>> statusCountBuckets = JsonPath.read(response,
STATUS_COUNT_AGGREGATIONS_BUCKETS_PATH);
HashMap<String, Object> statusCountMap = new HashMap<>();
actionableStatuses.forEach(status -> {
statusCountMap.put(status, 0);
});
statusCountBuckets.forEach(bucket -> {
if (actionableStatuses.contains(bucket.get(KEY)))
statusCountMap.put((String) bucket.get(KEY), bucket.get(DOC_COUNT_KEY));
statusCountMap.put((String) bucket.get(KEY), bucket.get(DOC_COUNT_KEY));
});
statusCountResponse.add(statusCountMap);
}
Expand Down