private boolean jobMatchesRunWhereClause(
      StaplerRequest request, Job<?, ?> job, WhereClause whereClause) {
    if (whereClause == null) {
      return true;
    }

    for (SimpleTerm term : whereClause.children()) {
      PName pname = term.property();
      String prop = pname.namespace + pname.local;
      if (prop.equals(AutomationConstants.AUTOMATION_NAMESPACE + "reportsOnAutomationPlan")
          && !uriMatches(getJobURI(job), term)) {
        return false;
      }
    }

    return true;
  }
 private boolean uriMatches(URI actual, SimpleTerm term) {
   switch (term.type()) {
     case COMPARISON:
       return uriMatchesComparison(actual, (ComparisonTerm) term);
     case IN_TERM:
       return uriMatchesInTerm(actual, (InTerm) term);
     case NESTED:
       throw HttpResponses.status(HttpServletResponse.SC_NOT_IMPLEMENTED);
     default:
       return true;
   }
 }