Enable date span filtering for getOrchestrationFiltersFromInfraActive
[so.git] / mso-api-handlers / mso-requests-db-repositories / src / main / java / org / onap / so / db / request / data / repository / InfraActiveRequestsRepositoryImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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=========================================================
21  */
22
23 package org.onap.so.db.request.data.repository;
24
25 import java.sql.Timestamp;
26 import java.text.SimpleDateFormat;
27 import java.util.Arrays;
28 import java.util.Collections;
29 import java.util.Date;
30 import java.util.LinkedList;
31 import java.util.List;
32 import java.util.Map;
33 import java.util.Map.Entry;
34 import java.util.concurrent.TimeUnit;
35 import javax.persistence.EntityManager;
36 import javax.persistence.NonUniqueResultException;
37 import javax.persistence.Query;
38 import javax.persistence.TypedQuery;
39 import javax.persistence.criteria.CriteriaBuilder;
40 import javax.persistence.criteria.CriteriaQuery;
41 import javax.persistence.criteria.Order;
42 import javax.persistence.criteria.Predicate;
43 import javax.persistence.criteria.Root;
44 import org.onap.so.db.request.beans.InfraActiveRequests;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
47 import org.springframework.beans.factory.annotation.Autowired;
48 import org.springframework.beans.factory.annotation.Qualifier;
49 import org.springframework.stereotype.Repository;
50 import org.springframework.transaction.annotation.Transactional;
51
52
53 @Repository
54 @Transactional(readOnly = true)
55 public class InfraActiveRequestsRepositoryImpl implements InfraActiveRequestsRepositoryCustom {
56
57
58     @Qualifier("requestEntityManagerFactory")
59     @Autowired
60     private EntityManager entityManager;
61
62     protected static Logger logger = LoggerFactory.getLogger(InfraActiveRequestsRepositoryImpl.class);
63
64     protected static final String REQUEST_STATUS = "requestStatus";
65     protected static final String SOURCE = "source";
66     protected static final String START_TIME = "startTime";
67     protected static final String END_TIME = "endTime";
68     protected static final String SERVICE_INSTANCE_ID = "serviceInstanceId";
69     protected static final String SERVICE_INSTANCE_NAME = "serviceInstanceName";
70     protected static final String VNF_INSTANCE_NAME = "vnfName";
71     protected static final String VNF_INSTANCE_ID = "vnfId";
72     protected static final String VOLUME_GROUP_INSTANCE_NAME = "volumeGroupName";
73     protected static final String VOLUME_GROUP_INSTANCE_ID = "volumeGroupId";
74     protected static final String VFMODULE_INSTANCE_NAME = "vfModuleName";
75     protected static final String VFMODULE_INSTANCE_ID = "vfModuleId";
76     protected static final String NETWORK_INSTANCE_NAME = "networkName";
77     protected static final String CONFIGURATION_INSTANCE_ID = "configurationId";
78     protected static final String CONFIGURATION_INSTANCE_NAME = "configurationName";
79     protected static final String OPERATIONAL_ENV_ID = "operationalEnvId";
80     protected static final String OPERATIONAL_ENV_NAME = "operationalEnvName";
81     protected static final String NETWORK_INSTANCE_ID = "networkId";
82     protected static final String GLOBAL_SUBSCRIBER_ID = "globalSubscriberId";
83     protected static final String SERVICE_NAME_VERSION_ID = "serviceNameVersionId";
84     protected static final String SERVICE_ID = "serviceId";
85     protected static final String SERVICE_VERSION = "serviceVersion";
86     protected static final String REQUEST_ID = "requestId";
87     protected static final String REQUESTOR_ID = "requestorId";
88     protected static final String OPENV = "operationalEnvironment";
89
90     private static final List<String> VALID_COLUMNS =
91             Arrays.asList(REQUEST_ID, SERVICE_INSTANCE_ID, SERVICE_INSTANCE_NAME, REQUEST_STATUS, VFMODULE_INSTANCE_ID,
92                     VNF_INSTANCE_ID, NETWORK_INSTANCE_ID, VOLUME_GROUP_INSTANCE_ID);
93
94
95     /*
96      * (non-Javadoc)
97      * 
98      * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#healthCheck()
99      */
100     @Override
101     public boolean healthCheck() {
102
103         final Query query = entityManager.createNativeQuery(" show tables ");
104
105         final List<?> list = query.getResultList();
106
107         return true;
108     }
109
110     private List<InfraActiveRequests> executeInfraQuery(final CriteriaQuery<InfraActiveRequests> crit,
111             final List<Predicate> predicates, final Order order) {
112
113         logger.debug("Execute query on infra active request table");
114
115         final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
116         crit.where(cb.and(predicates.toArray(new Predicate[0])));
117         crit.orderBy(order);
118
119         return entityManager.createQuery(crit).getResultList();
120     }
121
122     /*
123      * (non-Javadoc)
124      * 
125      * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestFromInfraActive(java. lang.String)
126      */
127     @Override
128     public InfraActiveRequests getRequestFromInfraActive(final String requestId) {
129         logger.debug("Get request {} from InfraActiveRequests DB", requestId);
130
131         InfraActiveRequests ar = null;
132         final Query query = entityManager.createQuery("from InfraActiveRequests where requestId = :requestId");
133         query.setParameter(REQUEST_ID, requestId);
134         ar = this.getSingleResult(query);
135         return ar;
136     }
137
138     /*
139      * (non-Javadoc)
140      * 
141      * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkInstanceNameDuplicate(java. util.HashMap,
142      * java.lang.String, java.lang.String)
143      */
144     @Override
145     public InfraActiveRequests checkInstanceNameDuplicate(final Map<String, String> instanceIdMap,
146             final String instanceName, final String requestScope) {
147
148         final List<Predicate> predicates = new LinkedList<>();
149         final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
150         final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
151         final Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class);
152         InfraActiveRequests infraActiveRequests = null;
153
154         if (instanceName != null && !instanceName.equals("")) {
155
156             if ("service".equals(requestScope)) {
157                 predicates.add(cb.equal(tableRoot.get(SERVICE_INSTANCE_NAME), instanceName));
158             } else if ("vnf".equals(requestScope)) {
159                 predicates.add(cb.equal(tableRoot.get(VNF_INSTANCE_NAME), instanceName));
160             } else if ("volumeGroup".equals(requestScope)) {
161                 predicates.add(cb.equal(tableRoot.get(VOLUME_GROUP_INSTANCE_NAME), instanceName));
162             } else if ("vfModule".equals(requestScope)) {
163                 predicates.add(cb.equal(tableRoot.get(VFMODULE_INSTANCE_NAME), instanceName));
164             } else if ("network".equals(requestScope)) {
165                 predicates.add(cb.equal(tableRoot.get(NETWORK_INSTANCE_NAME), instanceName));
166             } else if (requestScope.equals("configuration")) {
167                 predicates.add(cb.equal(tableRoot.get(CONFIGURATION_INSTANCE_NAME), instanceName));
168             } else if (requestScope.equals(OPENV)) {
169                 predicates.add(cb.equal(tableRoot.get(OPERATIONAL_ENV_NAME), instanceName));
170             }
171
172         } else {
173             if (instanceIdMap != null) {
174                 if ("service".equals(requestScope) && instanceIdMap.get(SERVICE_INSTANCE_ID) != null) {
175                     predicates
176                             .add(cb.equal(tableRoot.get(SERVICE_INSTANCE_ID), instanceIdMap.get("serviceInstanceId")));
177                 }
178
179                 if ("vnf".equals(requestScope) && instanceIdMap.get("vnfInstanceId") != null) {
180                     predicates.add(cb.equal(tableRoot.get(VNF_INSTANCE_ID), instanceIdMap.get("vnfInstanceId")));
181                 }
182
183                 if ("vfModule".equals(requestScope) && instanceIdMap.get("vfModuleInstanceId") != null) {
184                     predicates.add(
185                             cb.equal(tableRoot.get(VFMODULE_INSTANCE_ID), instanceIdMap.get("vfModuleInstanceId")));
186                 }
187
188                 if ("volumeGroup".equals(requestScope) && instanceIdMap.get("volumeGroupInstanceId") != null) {
189                     predicates.add(cb.equal(tableRoot.get(VOLUME_GROUP_INSTANCE_ID),
190                             instanceIdMap.get("volumeGroupInstanceId")));
191                 }
192
193                 if ("network".equals(requestScope) && instanceIdMap.get("networkInstanceId") != null) {
194                     predicates
195                             .add(cb.equal(tableRoot.get(NETWORK_INSTANCE_ID), instanceIdMap.get("networkInstanceId")));
196                 }
197
198                 if (requestScope.equals("configuration") && instanceIdMap.get("configurationInstanceId") != null) {
199                     predicates.add(cb.equal(tableRoot.get(CONFIGURATION_INSTANCE_ID),
200                             instanceIdMap.get("configurationInstanceId")));
201                 }
202
203                 if (requestScope.equals(OPENV) && instanceIdMap.get("operationalEnvironmentId") != null) {
204                     predicates.add(
205                             cb.equal(tableRoot.get(OPERATIONAL_ENV_ID), instanceIdMap.get("operationalEnvironmentId")));
206                 }
207             }
208         }
209         if (!predicates.isEmpty()) {
210             predicates.add(tableRoot.get(REQUEST_STATUS)
211                     .in(Arrays.asList("PENDING", "IN_PROGRESS", "TIMEOUT", "PENDING_MANUAL_TASK")));
212
213             final Order order = cb.desc(tableRoot.get(START_TIME));
214
215             final List<InfraActiveRequests> dupList = executeInfraQuery(crit, predicates, order);
216
217             if (dupList != null && !dupList.isEmpty()) {
218                 infraActiveRequests = dupList.get(0);
219             }
220         }
221
222         return infraActiveRequests;
223     }
224
225     /*
226      * (non-Javadoc)
227      * 
228      * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#
229      * getOrchestrationFiltersFromInfraActive(java.util.Map)
230      */
231     @Override
232     public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(
233             final Map<String, List<String>> orchestrationMap) {
234
235
236         final List<Predicate> predicates = new LinkedList<>();
237         final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
238         final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
239         final Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class);
240         for (final Map.Entry<String, List<String>> entry : orchestrationMap.entrySet()) {
241             String mapKey = entry.getKey();
242             if ("serviceInstanceId".equalsIgnoreCase(mapKey)) {
243                 mapKey = "serviceInstanceId";
244             } else if ("serviceInstanceName".equalsIgnoreCase(mapKey)) {
245                 mapKey = "serviceInstanceName";
246             } else if ("vnfInstanceId".equalsIgnoreCase(mapKey)) {
247                 mapKey = "vnfId";
248             } else if ("pnfName".equalsIgnoreCase(mapKey)) {
249                 mapKey = "pnfName";
250             } else if ("vnfInstanceName".equalsIgnoreCase(mapKey)) {
251                 mapKey = "vnfName";
252             } else if ("vfModuleInstanceId".equalsIgnoreCase(mapKey)) {
253                 mapKey = "vfModuleId";
254             } else if ("vfModuleInstanceName".equalsIgnoreCase(mapKey)) {
255                 mapKey = "vfModuleName";
256             } else if ("volumeGroupInstanceId".equalsIgnoreCase(mapKey)) {
257                 mapKey = "volumeGroupId";
258             } else if ("volumeGroupInstanceName".equalsIgnoreCase(mapKey)) {
259                 mapKey = "volumeGroupName";
260             } else if ("networkInstanceId".equalsIgnoreCase(mapKey)) {
261                 mapKey = "networkId";
262             } else if ("networkInstanceName".equalsIgnoreCase(mapKey)) {
263                 mapKey = "networkName";
264             } else if (mapKey.equalsIgnoreCase("configurationInstanceId")) {
265                 mapKey = "configurationId";
266             } else if (mapKey.equalsIgnoreCase("configurationInstanceName")) {
267                 mapKey = "configurationName";
268             } else if ("lcpCloudRegionId".equalsIgnoreCase(mapKey)) {
269                 mapKey = "cloudRegion";
270             } else if ("tenantId".equalsIgnoreCase(mapKey)) {
271                 mapKey = "tenantId";
272             } else if ("modelType".equalsIgnoreCase(mapKey)) {
273                 mapKey = "requestScope";
274             } else if ("requestorId".equalsIgnoreCase(mapKey)) {
275                 mapKey = "requestorId";
276             } else if ("requestExecutionDate".equalsIgnoreCase(mapKey)) {
277                 mapKey = "startTime";
278             }
279
280             final String operator = entry.getValue().get(0);
281             final String propertyValue = entry.getValue().get(1);
282             if ("startTime".equals(mapKey)) {
283                 final SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
284                 try {
285                     final Date thisDate = format.parse(propertyValue);
286                     final Timestamp minTime = new Timestamp(thisDate.getTime());
287                     Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1));
288
289                     if ("DOES_NOT_EQUAL".equalsIgnoreCase(operator)) {
290                         predicates.add(cb.or(cb.lessThan(tableRoot.get(mapKey), minTime),
291                                 cb.greaterThanOrEqualTo(tableRoot.get(mapKey), maxTime)));
292                     } else if ("BETWEEN_DATES".equalsIgnoreCase(operator)) {
293                         Date endDate = format.parse(entry.getValue().get(2));
294                         maxTime = new Timestamp(endDate.getTime());
295                         predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime));
296                     } else {
297                         predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime));
298                     }
299                 } catch (final Exception e) {
300                     logger.debug("Exception in getOrchestrationFiltersFromInfraActive(): {}", e.getMessage(), e);
301                     return null;
302                 }
303             } else if ("DOES_NOT_EQUAL".equalsIgnoreCase(operator)) {
304                 predicates.add(cb.notEqual(tableRoot.get(mapKey), propertyValue));
305             } else {
306                 predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue));
307             }
308
309         }
310
311         final Order order = cb.asc(tableRoot.get(START_TIME));
312
313         return executeInfraQuery(crit, predicates, order);
314     }
315
316     // Added this method for Tenant Isolation project ( 1802-295491a) to query the mso_requests DB
317     // (infra_active_requests table) for operationalEnvId and OperationalEnvName
318     /*
319      * (non-Javadoc)
320      * 
321      * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#
322      * getCloudOrchestrationFiltersFromInfraActive(java.util.Map)
323      */
324     @Override
325     public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(
326             final Map<String, String> orchestrationMap) {
327         final List<Predicate> predicates = new LinkedList<>();
328         final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
329         final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
330         final Root<InfraActiveRequests> tableRoot = crit.from(InfraActiveRequests.class);
331
332         // Add criteria on OperationalEnvironment RequestScope when requestorId is only specified in
333         // the filter
334         // as the same requestorId can also match on different API methods
335         final String resourceType = orchestrationMap.get("resourceType");
336         if (resourceType == null) {
337             predicates.add(cb.equal(tableRoot.get("requestScope"), OPENV));
338         }
339
340         for (final Map.Entry<String, String> entry : orchestrationMap.entrySet()) {
341             String mapKey = entry.getKey();
342             if (mapKey.equalsIgnoreCase("requestorId")) {
343                 mapKey = "requestorId";
344             } else if (mapKey.equalsIgnoreCase("requestExecutionDate")) {
345                 mapKey = "startTime";
346             } else if (mapKey.equalsIgnoreCase("operationalEnvironmentId")) {
347                 mapKey = "operationalEnvId";
348             } else if (mapKey.equalsIgnoreCase("operationalEnvironmentName")) {
349                 mapKey = "operationalEnvName";
350             } else if (mapKey.equalsIgnoreCase("resourceType")) {
351                 mapKey = "requestScope";
352             }
353
354             final String propertyValue = entry.getValue();
355             if (mapKey.equals("startTime")) {
356                 final SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
357                 try {
358                     final Date thisDate = format.parse(propertyValue);
359                     final Timestamp minTime = new Timestamp(thisDate.getTime());
360                     final Timestamp maxTime = new Timestamp(thisDate.getTime() + TimeUnit.DAYS.toMillis(1));
361
362                     predicates.add(cb.between(tableRoot.get(mapKey), minTime, maxTime));
363                 } catch (final Exception e) {
364                     logger.debug("Exception in getCloudOrchestrationFiltersFromInfraActive(): {}", e.getMessage());
365                     return null;
366                 }
367             } else {
368                 predicates.add(cb.equal(tableRoot.get(mapKey), propertyValue));
369             }
370         }
371
372         final Order order = cb.asc(tableRoot.get(START_TIME));
373         return executeInfraQuery(crit, predicates, order);
374     }
375
376     /*
377      * (non-Javadoc)
378      * 
379      * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestListFromInfraActive(java .lang.String,
380      * java.lang.String, java.lang.String)
381      */
382     @Override
383     public List<InfraActiveRequests> getRequestListFromInfraActive(final String queryAttributeName,
384             final String queryValue, final String requestType) {
385         logger.debug("Get list of infra requests from DB with {} = {}", queryAttributeName, queryValue);
386
387
388         try {
389             final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
390             final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
391             final Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class);
392             final Predicate isEqual = cb.equal(candidateRoot.get(queryAttributeName), queryValue);
393             final Order orderDesc = cb.desc(candidateRoot.get(START_TIME));
394             final Order orderAsc = cb.asc(candidateRoot.get(SOURCE));
395
396             final List<InfraActiveRequests> arList = entityManager.createQuery(crit).getResultList();
397             if (arList != null && !arList.isEmpty()) {
398                 return arList;
399             }
400         } catch (final Exception exception) {
401             logger.error("Unable to execute query", exception);
402         }
403         return Collections.emptyList();
404     }
405
406
407     /*
408      * (non-Javadoc)
409      * 
410      * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#getRequestFromInfraActive(java. lang.String,
411      * java.lang.String)
412      */
413     @Override
414     public InfraActiveRequests getRequestFromInfraActive(final String requestId, final String requestType) {
415         logger.debug("Get infra request from DB with id {}", requestId);
416
417         InfraActiveRequests ar = null;
418
419         final Query query = entityManager
420                 .createQuery("from InfraActiveRequests where requestId = :requestId and requestType = :requestType");
421         query.setParameter(REQUEST_ID, requestId);
422         ar = this.getSingleResult(query);
423         return ar;
424     }
425
426     /*
427      * (non-Javadoc)
428      * 
429      * @see org.onap.so.requestsdb.InfraActiveRequestsRepositoryCustom#checkVnfIdStatus(java.lang.String)
430      */
431     @Override
432     public InfraActiveRequests checkVnfIdStatus(final String operationalEnvironmentId) {
433         logger.debug("Get Infra request from DB for OperationalEnvironmentId {}", operationalEnvironmentId);
434
435         InfraActiveRequests ar = null;
436
437         final CriteriaBuilder cb = entityManager.getCriteriaBuilder();
438         final CriteriaQuery<InfraActiveRequests> crit = cb.createQuery(InfraActiveRequests.class);
439         final Root<InfraActiveRequests> candidateRoot = crit.from(InfraActiveRequests.class);
440         final Predicate operationalEnvEq = cb.equal(candidateRoot.get("operationalEnvId"), operationalEnvironmentId);
441         final Predicate requestStatusNotEq = cb.notEqual(candidateRoot.get(REQUEST_STATUS), "COMPLETE");
442         final Order startTimeOrder = cb.desc(candidateRoot.get("startTime"));
443         crit.select(candidateRoot);
444         crit.where(cb.and(operationalEnvEq, requestStatusNotEq));
445         crit.orderBy(startTimeOrder);
446         final TypedQuery<InfraActiveRequests> query = entityManager.createQuery(crit);
447         final List<InfraActiveRequests> results = query.getResultList();
448         if (!results.isEmpty()) {
449             ar = results.get(0);
450         }
451
452         return ar;
453     }
454
455     protected <T> T getSingleResult(final Query query) {
456         query.setMaxResults(1);
457         final List<T> list = query.getResultList();
458         if (list == null || list.isEmpty()) {
459             return null;
460         } else if (list.size() == 1) {
461             return list.get(0);
462         } else {
463             throw new NonUniqueResultException();
464         }
465
466     }
467
468     @Override
469     public List<InfraActiveRequests> getInfraActiveRequests(final Map<String, String[]> filters, final long startTime,
470             final long endTime, final Integer maxResult) {
471         if (filters == null) {
472             return Collections.emptyList();
473         }
474         try {
475             final CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
476
477             final CriteriaQuery<InfraActiveRequests> criteriaQuery =
478                     criteriaBuilder.createQuery(InfraActiveRequests.class);
479             final Root<InfraActiveRequests> tableRoot = criteriaQuery.from(InfraActiveRequests.class);
480             final List<Predicate> predicates = getPredicates(filters, criteriaBuilder, tableRoot);
481
482             final Timestamp minTime = new Timestamp(startTime);
483             final Timestamp maxTime = new Timestamp(endTime);
484             final Predicate basePredicate = criteriaBuilder.and(predicates.toArray(new Predicate[predicates.size()]));
485             final Predicate additionalPredicate =
486                     criteriaBuilder.and(criteriaBuilder.greaterThanOrEqualTo(tableRoot.get(START_TIME), minTime),
487                             criteriaBuilder.or(tableRoot.get(END_TIME).isNull(),
488                                     criteriaBuilder.lessThanOrEqualTo(tableRoot.get(END_TIME), maxTime)));
489
490             criteriaQuery.where(criteriaBuilder.and(basePredicate, additionalPredicate));
491             if (maxResult != null) {
492                 return entityManager.createQuery(criteriaQuery).setMaxResults(maxResult).getResultList();
493             }
494             return entityManager.createQuery(criteriaQuery).getResultList();
495         } catch (final Exception exception) {
496             logger.error("Unable to execute query using filters: {}", filters, exception);
497             return Collections.emptyList();
498         }
499     }
500
501     protected List<Predicate> getPredicates(final Map<String, String[]> filters, final CriteriaBuilder criteriaBuilder,
502             final Root<InfraActiveRequests> tableRoot) {
503         final List<Predicate> predicates = new LinkedList<>();
504         for (final Entry<String, String[]> entry : filters.entrySet()) {
505             final String[] params = entry.getValue();
506             if (VALID_COLUMNS.contains(entry.getKey()) && params.length == 2) {
507                 final QueryOperationType operationType = QueryOperationType.getQueryOperationType(params[0]);
508                 final Predicate predicate =
509                         operationType.getPredicate(criteriaBuilder, tableRoot, entry.getKey(), params[1]);
510                 predicates.add(predicate);
511             }
512         }
513         return predicates;
514     }
515 }