2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.db.request.data.repository;
25 import java.sql.Timestamp;
26 import java.text.SimpleDateFormat;
27 import java.util.ArrayList;
28 import java.util.Arrays;
29 import java.util.Collections;
30 import java.util.Date;
31 import java.util.HashMap;
32 import java.util.LinkedList;
33 import java.util.List;
35 import java.util.Map.Entry;
36 import java.util.concurrent.TimeUnit;
38 import javax.persistence.EntityManager;
39 import javax.persistence.NonUniqueResultException;
40 import javax.persistence.Query;
41 import javax.persistence.TypedQuery;
42 import javax.persistence.criteria.CriteriaBuilder;
43 import javax.persistence.criteria.CriteriaQuery;
44 import javax.persistence.criteria.Order;
45 import javax.persistence.criteria.Predicate;
46 import javax.persistence.criteria.Root;
48 import org.onap.so.db.request.beans.InfraActiveRequests;
49 import org.slf4j.Logger;
50 import org.slf4j.LoggerFactory;
51 import org.springframework.beans.factory.annotation.Autowired;
52 import org.springframework.beans.factory.annotation.Qualifier;
53 import org.springframework.stereotype.Repository;
54 import org.springframework.transaction.annotation.Transactional;
58 @Transactional(readOnly = true)
59 public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRepositoryCustom {
62 @Qualifier("requestEntityManagerFactory")
64 private EntityManager entityManager;
66 protected static Logger logger = LoggerFactory.getLogger(InfraActiveRequestsRepositoryImpl.class);
68 protected static final String REQUEST_STATUS = "requestStatus";
69 protected static final String SOURCE = "source";
70 protected static final String START_TIME = "startTime";
71 protected static final String END_TIME = "endTime";
72 protected static final String REQUEST_TYPE = "requestType";
73 protected static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
74 protected static final String SERVICE_INSTANCE_NAME = "serviceInstanceName";
75 protected static final String VNF_INSTANCE_NAME = "vnfName";
76 protected static final String VNF_INSTANCE_ID = "vnfId";
77 protected static final String VOLUME_GROUP_INSTANCE_NAME = "volumeGroupName";
78 protected static final String VOLUME_GROUP_INSTANCE_ID = "volumeGroupId";
79 protected static final String VFMODULE_INSTANCE_NAME = "vfModuleName";
80 protected static final String VFMODULE_INSTANCE_ID = "vfModuleId";
81 protected static final String NETWORK_INSTANCE_NAME = "networkName";
82 protected static final String CONFIGURATION_INSTANCE_ID = "configurationId";
83 protected static final String CONFIGURATION_INSTANCE_NAME = "configurationName";
84 protected static final String OPERATIONAL_ENV_ID = "operationalEnvId";
85 protected static final String OPERATIONAL_ENV_NAME = "operationalEnvName";
86 protected static final String NETWORK_INSTANCE_ID = "networkId";
87 protected static final String GLOBAL_SUBSCRIBER_ID = "globalSubscriberId";
88 protected static final String SERVICE_NAME_VERSION_ID = "serviceNameVersionId";
89 protected static final String SERVICE_ID = "serviceId";
90 protected static final String SERVICE_VERSION = "serviceVersion";
91 protected static final String REQUEST_ID = "requestId";
92 protected static final String REQUESTOR_ID = "requestorId";
93 protected static final String ACTION = "action";
95 private static final List<String> VALID_COLUMNS =
96 Arrays.asList(REQUEST_ID, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, ACTION, REQUEST_STATUS);
102 * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#healthCheck()
105 public boolean healthCheck() {
107 final Query query = entityManager.createNativeQuery(" show tables ");
109 final List<?> list = query.getResultList();
114 private List<InfraActiveRequests> executeInfraQuery(final CriteriaQuery<InfraActiveRequests> crit,
115 final List<Predicate> predicates, final Order order) {
117 final long startTime = System.currentTimeMillis();
118 logger.debug("Execute query on infra active request table");
120 List<InfraActiveRequests> results = new ArrayList<InfraActiveRequests>();
122 final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
123 crit.where(cb.and(predicates.toArray(new Predicate[0])));
125 results = entityManager.createQuery(crit).getResultList();
134 * org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestFromInfraActive(java.
138 public InfraActiveRequests getRequestFromInfraActive(final String requestId) {
139 final long startTime = System.currentTimeMillis();
140 logger.debug("Get request {} from InfraActiveRequests DB", requestId);
142 InfraActiveRequests ar = null;
143 final Query query = entityManager
144 .createQuery("from InfraActiveRequests where requestId = :requestId OR clientRequestId = :requestId");
145 query.setParameter(REQUEST_ID, requestId);
146 ar = this.getSingleResult(query);
154 * org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkInstanceNameDuplicate(java.
155 * util.HashMap, java.lang.String, java.lang.String)
158 public InfraActiveRequests checkInstanceNameDuplicate(final HashMap<String, String> instanceIdMap,
159 final String instanceName, final String requestScope) {
161 final List<Predicate> predicates = new LinkedList<>();
162 final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
163 final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
164 final Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class);
165 InfraActiveRequests infraActiveRequests = null;
167 if (instanceName != null && !instanceName.equals("")) {
169 if ("service".equals(requestScope)) {
170 predicates.add(cb.equal(tableRoot.get(SERVICE_INSTANCE_NAME), instanceName));
171 } else if ("vnf".equals(requestScope)) {
172 predicates.add(cb.equal(tableRoot.get(VNF_INSTANCE_NAME), instanceName));
173 } else if ("volumeGroup".equals(requestScope)) {
174 predicates.add(cb.equal(tableRoot.get(VOLUME_GROUP_INSTANCE_NAME), instanceName));
175 } else if ("vfModule".equals(requestScope)) {
176 predicates.add(cb.equal(tableRoot.get(VFMODULE_INSTANCE_NAME), instanceName));
177 } else if ("network".equals(requestScope)) {
178 predicates.add(cb.equal(tableRoot.get(NETWORK_INSTANCE_NAME), instanceName));
179 } else if (requestScope.equals("configuration")) {
180 predicates.add(cb.equal(tableRoot.get(CONFIGURATION_INSTANCE_NAME), instanceName));
181 } else if (requestScope.equals("operationalEnvironment")) {
182 predicates.add(cb.equal(tableRoot.get(OPERATIONAL_ENV_NAME), instanceName));
186 if (instanceIdMap != null) {
187 if ("service".equals(requestScope) && instanceIdMap.get("serviceInstanceId") != null) {
189 .add(cb.equal(tableRoot.get(SERVICE_INSTANCE_ID), instanceIdMap.get("serviceInstanceId")));
192 if ("vnf".equals(requestScope) && instanceIdMap.get("vnfInstanceId") != null) {
193 predicates.add(cb.equal(tableRoot.get(VNF_INSTANCE_ID), instanceIdMap.get("vnfInstanceId")));
196 if ("vfModule".equals(requestScope) && instanceIdMap.get("vfModuleInstanceId") != null) {
198 cb.equal(tableRoot.get(VFMODULE_INSTANCE_ID), instanceIdMap.get("vfModuleInstanceId")));
201 if ("volumeGroup".equals(requestScope) && instanceIdMap.get("volumeGroupInstanceId") != null) {
202 predicates.add(cb.equal(tableRoot.get(VOLUME_GROUP_INSTANCE_ID),
203 instanceIdMap.get("volumeGroupInstanceId")));
206 if ("network".equals(requestScope) && instanceIdMap.get("networkInstanceId") != null) {
208 .add(cb.equal(tableRoot.get(NETWORK_INSTANCE_ID), instanceIdMap.get("networkInstanceId")));
211 if (requestScope.equals("configuration") && instanceIdMap.get("configurationInstanceId") != null) {
212 predicates.add(cb.equal(tableRoot.get(CONFIGURATION_INSTANCE_ID),
213 instanceIdMap.get("configurationInstanceId")));
216 if (requestScope.equals("operationalEnvironment")
217 && instanceIdMap.get("operationalEnvironmentId") != null) {
219 cb.equal(tableRoot.get(OPERATIONAL_ENV_ID), instanceIdMap.get("operationalEnvironmentId")));
223 if (!predicates.isEmpty()) {
224 predicates.add(tableRoot.get(REQUEST_STATUS)
225 .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK")));
227 final Order order = cb.desc(tableRoot.get(START_TIME));
229 final List<InfraActiveRequests> dupList = executeInfraQuery(crit, predicates, order);
231 if (dupList != null && !dupList.isEmpty()) {
232 infraActiveRequests = dupList.get(0);
236 return infraActiveRequests;
242 * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#
243 * getOrchestrationFiltersFromInfraActive(java.util.Map)
246 public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(
247 final Map<String, List<String>> orchestrationMap) {
250 final List<Predicate> predicates = new LinkedList<>();
251 final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
252 final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
253 final Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class);
254 for (final Map.Entry<String, List<String>> entry : orchestrationMap.entrySet()) {
255 String mapKey = entry.getKey();
256 if ("serviceInstanceId".equalsIgnoreCase(mapKey)) {
257 mapKey = "serviceInstanceId";
258 } else if ("serviceInstanceName".equalsIgnoreCase(mapKey)) {
259 mapKey = "serviceInstanceName";
260 } else if ("vnfInstanceId".equalsIgnoreCase(mapKey)) {
262 } else if ("vnfInstanceName".equalsIgnoreCase(mapKey)) {
264 } else if ("vfModuleInstanceId".equalsIgnoreCase(mapKey)) {
265 mapKey = "vfModuleId";
266 } else if ("vfModuleInstanceName".equalsIgnoreCase(mapKey)) {
267 mapKey = "vfModuleName";
268 } else if ("volumeGroupInstanceId".equalsIgnoreCase(mapKey)) {
269 mapKey = "volumeGroupId";
270 } else if ("volumeGroupInstanceName".equalsIgnoreCase(mapKey)) {
271 mapKey = "volumeGroupName";
272 } else if ("networkInstanceId".equalsIgnoreCase(mapKey)) {
273 mapKey = "networkId";
274 } else if ("networkInstanceName".equalsIgnoreCase(mapKey)) {
275 mapKey = "networkName";
276 } else if (mapKey.equalsIgnoreCase("configurationInstanceId")) {
277 mapKey = "configurationId";
278 } else if (mapKey.equalsIgnoreCase("configurationInstanceName")) {
279 mapKey = "configurationName";
280 } else if ("lcpCloudRegionId".equalsIgnoreCase(mapKey)) {
281 mapKey = "aicCloudRegion";
282 } else if ("tenantId".equalsIgnoreCase(mapKey)) {
284 } else if ("modelType".equalsIgnoreCase(mapKey)) {
285 mapKey = "requestScope";
286 } else if ("requestorId".equalsIgnoreCase(mapKey)) {
287 mapKey = "requestorId";
288 } else if ("requestExecutionDate".equalsIgnoreCase(mapKey)) {
289 mapKey = "startTime";
292 final String propertyValue = entry.getValue().get(1);
293 if ("startTime".equals(mapKey)) {
294 final SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
296 final Date thisDate = format.parse(propertyValue);
297 final Timestamp minTime = new Timestamp(thisDate.getTime());
298 final Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1));
300 if ("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) {
301 predicates.add(cb.or(cb.lessThan(tableRoot.get(mapKey), minTime),
302 cb.greaterThanOrEqualTo(tableRoot.get(mapKey), maxTime)));
304 predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime));
306 } catch (final Exception e) {
307 logger.debug("Exception in getOrchestrationFiltersFromInfraActive(): {}", e.getMessage(), e);
310 } else if ("DOES_NOT_EQUAL".equalsIgnoreCase(entry.getValue().get(0))) {
311 predicates.add(cb.notEqual(tableRoot.get(mapKey), propertyValue));
313 predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue));
318 final Order order = cb.asc(tableRoot.get(START_TIME));
320 return executeInfraQuery(crit, predicates, order);
323 // Added this method for Tenant Isolation project ( 1802-295491a) to query the mso_requests DB
324 // (infra_active_requests table) for operationalEnvId and OperationalEnvName
328 * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#
329 * getCloudOrchestrationFiltersFromInfraActive(java.util.Map)
332 public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(
333 final Map<String, String> orchestrationMap) {
334 final List<Predicate> predicates = new LinkedList<>();
335 final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
336 final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
337 final Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class);
339 // Add criteria on OperationalEnvironment RequestScope when requestorId is only specified in
341 // as the same requestorId can also match on different API methods
342 final String resourceType = orchestrationMap.get("resourceType");
343 if (resourceType == null) {
344 predicates.add(cb.equal(tableRoot.get("requestScope"), "operationalEnvironment"));
347 for (final Map.Entry<String, String> entry : orchestrationMap.entrySet()) {
348 String mapKey = entry.getKey();
349 if (mapKey.equalsIgnoreCase("requestorId")) {
350 mapKey = "requestorId";
351 } else if (mapKey.equalsIgnoreCase("requestExecutionDate")) {
352 mapKey = "startTime";
353 } else if (mapKey.equalsIgnoreCase("operationalEnvironmentId")) {
354 mapKey = "operationalEnvId";
355 } else if (mapKey.equalsIgnoreCase("operationalEnvironmentName")) {
356 mapKey = "operationalEnvName";
357 } else if (mapKey.equalsIgnoreCase("resourceType")) {
358 mapKey = "requestScope";
361 final String propertyValue = entry.getValue();
362 if (mapKey.equals("startTime")) {
363 final SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
365 final Date thisDate = format.parse(propertyValue);
366 final Timestamp minTime = new Timestamp(thisDate.getTime());
367 final Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1));
369 predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime));
370 } catch (final Exception e) {
371 logger.debug("Exception in getCloudOrchestrationFiltersFromInfraActive(): {}", e.getMessage());
375 predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue));
379 final Order order = cb.asc(tableRoot.get(START_TIME));
380 return executeInfraQuery(crit, predicates, order);
387 * org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestListFromInfraActive(java
388 * .lang.String, java.lang.String, java.lang.String)
391 public List<InfraActiveRequests> getRequestListFromInfraActive(final String queryAttributeName,
392 final String queryValue, final String requestType) {
393 logger.debug("Get list of infra requests from DB with {} = {}", queryAttributeName, queryValue);
397 final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
398 final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
399 final Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class);
400 final Predicate isEqual = cb.equal(candidateRoot.get(queryAttributeName), queryValue);
401 final Predicate equalRequestType = cb.equal(candidateRoot.get(REQUEST_TYPE), requestType);
402 final Predicate isNull = cb.isNull(candidateRoot.get(REQUEST_TYPE));
403 final Predicate orClause = cb.or(equalRequestType, isNull);
404 final Order orderDesc = cb.desc(candidateRoot.get(START_TIME));
405 final Order orderAsc = cb.asc(candidateRoot.get(SOURCE));
406 crit.where(cb.and(isEqual, orClause)).orderBy(orderDesc, orderAsc);
408 final List<InfraActiveRequests> arList = entityManager.createQuery(crit).getResultList();
409 if (arList != null && !arList.isEmpty()) {
412 } catch (final Exception exception) {
413 logger.error("Unable to execute query", exception);
415 return Collections.emptyList();
423 * org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestFromInfraActive(java.
424 * lang.String, java.lang.String)
427 public InfraActiveRequests getRequestFromInfraActive(final String requestId, final String requestType) {
428 final long startTime = System.currentTimeMillis();
429 logger.debug("Get infra request from DB with id {}", requestId);
431 InfraActiveRequests ar = null;
433 final Query query = entityManager.createQuery(
434 "from InfraActiveRequests where (requestId = :requestId OR clientRequestId = :requestId) and requestType = :requestType");
435 query.setParameter(REQUEST_ID, requestId);
436 query.setParameter(REQUEST_TYPE, requestType);
437 ar = this.getSingleResult(query);
446 * org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkDuplicateByVnfName(java.lang.
447 * String, java.lang.String, java.lang.String)
450 public InfraActiveRequests checkDuplicateByVnfName(final String vnfName, final String action,
451 final String requestType) {
453 final long startTime = System.currentTimeMillis();
454 logger.debug("Get infra request from DB for VNF {} and action {} and requestType {}", vnfName, action,
457 InfraActiveRequests ar = null;
459 final Query query = entityManager.createQuery(
460 "from InfraActiveRequests where vnfName = :vnfName and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC");
461 query.setParameter("vnfName", vnfName);
462 query.setParameter("action", action);
463 query.setParameter(REQUEST_TYPE, requestType);
464 @SuppressWarnings("unchecked") final List<InfraActiveRequests> results = query.getResultList();
465 if (!results.isEmpty()) {
476 * org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkDuplicateByVnfId(java.lang.
477 * String, java.lang.String, java.lang.String)
480 public InfraActiveRequests checkDuplicateByVnfId(final String vnfId, final String action,
481 final String requestType) {
483 final long startTime = System.currentTimeMillis();
484 logger.debug("Get list of infra requests from DB for VNF {} and action {}", vnfId, action);
486 InfraActiveRequests ar = null;
488 final Query query = entityManager.createQuery(
489 "from InfraActiveRequests where vnfId = :vnfId and action = :action and (requestStatus = 'PENDING' or requestStatus = 'IN_PROGRESS' or requestStatus = 'TIMEOUT' or requestStatus = 'PENDING_MANUAL_TASK') and requestType = :requestType ORDER BY startTime DESC");
490 query.setParameter("vnfId", vnfId);
491 query.setParameter("action", action);
492 query.setParameter(REQUEST_TYPE, requestType);
493 @SuppressWarnings("unchecked") final List<InfraActiveRequests> results = query.getResultList();
494 if (!results.isEmpty()) {
505 * org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkVnfIdStatus(java.lang.String)
508 public InfraActiveRequests checkVnfIdStatus(final String operationalEnvironmentId) {
509 final long startTime = System.currentTimeMillis();
510 logger.debug("Get Infra request from DB for OperationalEnvironmentId {}", operationalEnvironmentId);
512 InfraActiveRequests ar = null;
514 final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
515 final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
516 final Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class);
517 final Predicate operationalEnvEq = cb.equal(candidateRoot.get("operationalEnvId"), operationalEnvironmentId);
518 final Predicate requestStatusNotEq = cb.notEqual(candidateRoot.get(REQUEST_STATUS), "COMPLETE");
519 final Predicate actionEq = cb.equal(candidateRoot.get("action"), "create");
520 final Order startTimeOrder = cb.desc(candidateRoot.get("startTime"));
521 crit.select(candidateRoot);
522 crit.where(cb.and(operationalEnvEq, requestStatusNotEq, actionEq));
523 crit.orderBy(startTimeOrder);
524 final TypedQuery<InfraActiveRequests> query = entityManager.createQuery(crit);
525 final List<InfraActiveRequests> results = query.getResultList();
526 if (!results.isEmpty()) {
533 protected <T> T getSingleResult(final Query query) {
534 query.setMaxResults(1);
535 final List<T> list = query.getResultList();
536 if (list == null || list.isEmpty()) {
538 } else if (list.size() == 1) {
541 throw new NonUniqueResultException();
547 public List<InfraActiveRequests> getInfraActiveRequests(final Map<String, String[]> filters, final long startTime,
548 final long endTime, final Integer maxResult) {
549 if (filters == null) {
550 return Collections.emptyList();
553 final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
554 final CriteriaQuery<InfraActiveRequests> criteriaQuery =
555 criteriaBuilder.createQuery(InfraActiveRequests.class);
556 final Root<InfraActiveRequests> tableRoot = criteriaQuery.from(InfraActiveRequests.class);
557 final List<Predicate> predicates = getPredicates(filters, criteriaBuilder, tableRoot);
559 final Timestamp minTime = new Timestamp(startTime);
560 final Timestamp maxTime = new Timestamp(endTime);
561 predicates.add(criteriaBuilder.greaterThanOrEqualTo(tableRoot.get(START_TIME), minTime));
562 predicates.add(criteriaBuilder.lessThanOrEqualTo(tableRoot.get(END_TIME), maxTime));
564 final Predicate basePredicate = criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
566 final Predicate additionalPredicate = criteriaBuilder.and(tableRoot.get(END_TIME).isNull(),
567 criteriaBuilder.greaterThanOrEqualTo(tableRoot.get(START_TIME), minTime),
568 criteriaBuilder.lessThanOrEqualTo(tableRoot.get(START_TIME), maxTime));
570 criteriaQuery.where(criteriaBuilder.or(basePredicate, additionalPredicate));
572 if (maxResult != null) {
573 return entityManager.createQuery(criteriaQuery).setMaxResults(maxResult).getResultList();
575 return entityManager.createQuery(criteriaQuery).getResultList();
576 } catch (final Exception exception) {
577 logger.error("Unable to execute query using filters: {}", filters, exception);
578 return Collections.emptyList();
582 private List<Predicate> getPredicates(final Map<String, String[]> filters, final CriteriaBuilder criteriaBuilder,
583 final Root<InfraActiveRequests> tableRoot) {
584 final List<Predicate> predicates = new LinkedList<>();
585 for (final Entry<String, String[]> entry : filters.entrySet()) {
586 final String[] params = entry.getValue();
587 if (VALID_COLUMNS.contains(entry.getKey()) && params.length == 2) {
588 final QueryOperationType operationType = QueryOperationType.getQueryOperationType(params[0]);
589 final Predicate predicate =
590 operationType.getPredicate(criteriaBuilder, tableRoot, entry.getKey(), params[1]);
591 predicates.add(predicate);