Java Code Examples for org.apache.commons.collections.PredicateUtils#allPredicate()
The following examples show how to use
org.apache.commons.collections.PredicateUtils#allPredicate() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterUtil.java From incubator-atlas with Apache License 2.0 | 5 votes |
public static Predicate getPredicateFromSearchFilter(SearchFilter searchFilter) { List<Predicate> predicates = new ArrayList<>(); final String type = searchFilter.getParam(SearchFilter.PARAM_TYPE); final String name = searchFilter.getParam(SearchFilter.PARAM_NAME); final String supertype = searchFilter.getParam(SearchFilter.PARAM_SUPERTYPE); final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE); // Add filter for the type/category if (StringUtils.isNotBlank(type)) { predicates.add(getTypePredicate(type)); } // Add filter for the name if (StringUtils.isNotBlank(name)) { predicates.add(getNamePredicate(name)); } // Add filter for the supertype if (StringUtils.isNotBlank(supertype)) { predicates.add(getSuperTypePredicate(supertype)); } // Add filter for the supertype negation if (StringUtils.isNotBlank(notSupertype)) { predicates.add(new NotPredicate(getSuperTypePredicate(notSupertype))); } return PredicateUtils.allPredicate(predicates); }
Example 2
Source File: FilterUtil.java From atlas with Apache License 2.0 | 4 votes |
public static Predicate getPredicateFromSearchFilter(SearchFilter searchFilter) { List<Predicate> predicates = new ArrayList<>(); final String type = searchFilter.getParam(SearchFilter.PARAM_TYPE); final String name = searchFilter.getParam(SearchFilter.PARAM_NAME); final String supertype = searchFilter.getParam(SearchFilter.PARAM_SUPERTYPE); final String serviceType = searchFilter.getParam(SearchFilter.PARAM_SERVICETYPE); final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE); final String notServiceType = searchFilter.getParam(SearchFilter.PARAM_NOT_SERVICETYPE); final List<String> notNames = searchFilter.getParams(SearchFilter.PARAM_NOT_NAME); // Add filter for the type/category if (StringUtils.isNotBlank(type)) { predicates.add(getTypePredicate(type)); } // Add filter for the name if (StringUtils.isNotBlank(name)) { predicates.add(getNamePredicate(name)); } // Add filter for the serviceType if(StringUtils.isNotBlank(serviceType)) { predicates.add(getServiceTypePredicate(serviceType)); } // Add filter for the supertype if (StringUtils.isNotBlank(supertype)) { predicates.add(getSuperTypePredicate(supertype)); } // Add filter for the supertype negation if (StringUtils.isNotBlank(notSupertype)) { predicates.add(new NotPredicate(getSuperTypePredicate(notSupertype))); } // Add filter for the serviceType negation // NOTE: Creating code for the exclusion of multiple service types is currently useless. // In fact the getSearchFilter in TypeREST.java uses the HttpServletRequest.getParameter(key) // that if the key takes more values it takes only the first the value. Could be useful // to change the getSearchFilter to use getParameterValues instead of getParameter. if (StringUtils.isNotBlank(notServiceType)) { predicates.add(new NotPredicate(getServiceTypePredicate(notServiceType))); } // Add filter for the type negation if (CollectionUtils.isNotEmpty(notNames)) { for (String notName : notNames) { predicates.add(new NotPredicate(getNamePredicate(notName))); } } return PredicateUtils.allPredicate(predicates); }
Example 3
Source File: KmsKeyMgr.java From ranger with Apache License 2.0 | 3 votes |
private Predicate getPredicate(KeySearchFilter filter) { if(filter == null || filter.isEmpty()) { return null; } List<Predicate> predicates = new ArrayList<Predicate>(); addPredicateForKeyName(filter.getParam(KeySearchFilter.KEY_NAME), predicates); Predicate ret = CollectionUtils.isEmpty(predicates) ? null : PredicateUtils.allPredicate(predicates); return ret; }
Example 4
Source File: AbstractPredicateUtil.java From ranger with Apache License 2.0 | 3 votes |
public Predicate getPredicate(SearchFilter filter) { if(filter == null || filter.isEmpty()) { return null; } List<Predicate> predicates = new ArrayList<>(); addPredicates(filter, predicates); Predicate ret = CollectionUtils.isEmpty(predicates) ? null : PredicateUtils.allPredicate(predicates); return ret; }