use of org.apache.nifi.update.attributes.FlowFilePolicy in project nifi by apache.
the class UpdateAttribute method search.
@Override
public Collection<SearchResult> search(final SearchContext context) {
final String term = context.getSearchTerm();
final Collection<SearchResult> results = new ArrayList<>();
if (StringUtils.isBlank(context.getAnnotationData())) {
return results;
}
try {
// parse the annotation data
final Criteria criteria = CriteriaSerDe.deserialize(context.getAnnotationData());
// ensure there are some rules
if (criteria.getRules() != null) {
final FlowFilePolicy flowFilePolicy = criteria.getFlowFilePolicy();
if (flowFilePolicy != null && StringUtils.containsIgnoreCase(flowFilePolicy.name(), term)) {
results.add(new SearchResult.Builder().label("FlowFile policy").match(flowFilePolicy.name()).build());
}
for (final Rule rule : criteria.getRules()) {
if (StringUtils.containsIgnoreCase(rule.getName(), term)) {
results.add(new SearchResult.Builder().label("Rule name").match(rule.getName()).build());
}
// ensure there are some conditions
if (rule.getConditions() != null) {
for (final Condition condition : rule.getConditions()) {
if (StringUtils.containsIgnoreCase(condition.getExpression(), term)) {
results.add(new SearchResult.Builder().label(String.format("Condition in rule '%s'", rule.getName())).match(condition.getExpression()).build());
}
}
}
// ensure there are some actions
if (rule.getActions() != null) {
for (final Action action : rule.getActions()) {
if (StringUtils.containsIgnoreCase(action.getAttribute(), term)) {
results.add(new SearchResult.Builder().label(String.format("Action in rule '%s'", rule.getName())).match(action.getAttribute()).build());
}
if (StringUtils.containsIgnoreCase(action.getValue(), term)) {
results.add(new SearchResult.Builder().label(String.format("Action in rule '%s'", rule.getName())).match(action.getValue()).build());
}
}
}
}
}
return results;
} catch (Exception e) {
return results;
}
}
Aggregations