use of com.thinkbiganalytics.metadata.api.SearchCriteria in project kylo by Teradata.
the class JpaBatchJobExecutionProvider method findAll.
/**
* Find all BatchJobExecution objects with the provided filter. the filter needs to match
*
* @return a paged result set of all the job executions matching the incoming filter
*/
@Override
public Page<? extends BatchJobExecution> findAll(String filter, Pageable pageable) {
QJpaBatchJobExecution jobExecution = QJpaBatchJobExecution.jpaBatchJobExecution;
// if the filter contains a filter on the feed then delegate to the findAllForFeed method to include any check data jobs
List<SearchCriteria> searchCriterias = GenericQueryDslFilter.parseFilterString(filter);
SearchCriteria feedFilter = searchCriterias.stream().map(searchCriteria -> searchCriteria.withKey(CommonFilterTranslations.resolvedFilter(jobExecution, searchCriteria.getKey()))).filter(sc -> sc.getKey().equalsIgnoreCase(CommonFilterTranslations.jobExecutionFeedNameFilterKey)).findFirst().orElse(null);
if (feedFilter != null && feedFilter.getPreviousSearchCriteria() != null && !feedFilter.isValueCollection()) {
// remove the feed filter from the list and filter by this feed
searchCriterias.remove(feedFilter.getPreviousSearchCriteria());
String feedValue = feedFilter.getValue().toString();
// remove any quotes around the feedValue
feedValue = feedValue.replaceAll("^\"|\"$", "");
return findAllForFeed(feedValue, searchCriterias, pageable);
} else {
pageable = CommonFilterTranslations.resolveSortFilters(jobExecution, pageable);
QJpaBatchJobInstance jobInstancePath = new QJpaBatchJobInstance("jobInstance");
QJpaOpsManagerFeed feedPath = new QJpaOpsManagerFeed("feed");
return findAllWithFetch(jobExecution, GenericQueryDslFilter.buildFilter(jobExecution, filter).and(augment(feedPath.id)), pageable, QueryDslFetchJoin.innerJoin(jobExecution.nifiEventJobExecution), QueryDslFetchJoin.innerJoin(jobExecution.jobInstance, jobInstancePath), QueryDslFetchJoin.innerJoin(jobInstancePath.feed, feedPath));
}
}
use of com.thinkbiganalytics.metadata.api.SearchCriteria in project kylo by Teradata.
the class GenericQueryDslFilter method parseFilterString.
/**
* convert a passed in filter string to a list of criteria objects
*
* @param filterString a filter, <column><operator><value> Example: jobinstance.name==jobName,jobExcutionId>=200. that will search for all jobs named 'jobName' and jobExecutionId >= 200
* @return a list of criteria objects
*/
public static List<SearchCriteria> parseFilterString(String filterString) {
List<SearchCriteria> searchCriterias = new ArrayList<>();
if (StringUtils.isNotBlank(filterString)) {
// first match and split on , for various filters
String[] filterConditions = filterString.split(",(?=(?:[^\\\"]*\\\"[^\\\"]*\\\")*[^\\\"]*$)");
List<String> filterConditionsList = Arrays.asList(filterConditions);
// Pattern used to match the <column><operator><value>
String validOperatorsRegEx = operators.keySet().stream().map(key -> key).collect(Collectors.joining("|"));
Pattern columnOperatorValuePattern = Pattern.compile("(.*)(" + validOperatorsRegEx + ")(.*)");
filterConditionsList.stream().forEach(filter -> {
Matcher matcher = columnOperatorValuePattern.matcher(filter);
while (matcher.find()) {
String field = matcher.group(1).trim();
String operator = matcher.group(2).trim();
String value = matcher.group(3).trim();
searchCriterias.add(new SearchCriteria(field, operator, value));
}
});
}
return searchCriterias;
}
Aggregations