Source:
<code>public List<QueryHandle> getAllQueries(GrillSessionHandle sessionHandle, String state, String userName, String queryName) throws GrillException { try { acquire(sessionHandle); Status status = null; try { status = StringUtils.isBlank(state) ? null : Status.valueOf(state); } catch (IllegalArgumentException e) { throw new BadRequestException("Bad state argument passed, possible" + " values are " + Status.values(), e); } boolean filterByStatus = status != null; queryName = queryName.toLowerCase(); boolean filterByQueryName = StringUtils.isNotBlank(queryName); if (StringUtils.isBlank(userName)) { userName = getSession(sessionHandle).getUserName(); } List<QueryHandle> all = new ArrayList<QueryHandle>(allQueries.keySet()); Iterator<QueryHandle> itr = all.iterator(); while (itr.hasNext()) { QueryHandle q = itr.next(); QueryContext context = allQueries.get(q); if ((filterByStatus && status != context.getStatus().getStatus()) || (filterByQueryName && !context.getQueryName().toLowerCase().contains(queryName)) || (!"all".equalsIgnoreCase(userName) && !userName.equalsIgnoreCase(context.getSubmittedUser())) ) { itr.remove(); } } <START> if (status == null || status == Status.CANCELED || status == Status.SUCCESSFUL || status == Status.FAILED) { <END> if ("all".equalsIgnoreCase(userName)) { userName = null; } List<QueryHandle> persistedQueries = grillServerDao.findFinishedQueries(userName, queryName); if (persistedQueries != null && !persistedQueries.isEmpty()) { LOG.info("Adding persisted queries " + persistedQueries.size()); all.addAll(persistedQueries); } } return all; } finally { release(sessionHandle); } }</code><technical_language>status filter is passed down, a filter persisted queries pulled. pass status filter well</technical_language>

Target:
public List<QueryHandle> getAllQueries(GrillSessionHandle sessionHandle, String state, String userName, String queryName) throws GrillException { try { acquire(sessionHandle); Status status = null; try { status = StringUtils.isBlank(state) ? null : Status.valueOf(state); } catch (IllegalArgumentException e) { throw new BadRequestException("Bad state argument passed, possible" + " values are " + Status.values(), e); } boolean filterByStatus = status != null; queryName = queryName.toLowerCase(); boolean filterByQueryName = StringUtils.isNotBlank(queryName); if (StringUtils.isBlank(userName)) { userName = getSession(sessionHandle).getUserName(); } List<QueryHandle> all = new ArrayList<QueryHandle>(allQueries.keySet()); Iterator<QueryHandle> itr = all.iterator(); while (itr.hasNext()) { QueryHandle q = itr.next(); QueryContext context = allQueries.get(q); if ((filterByStatus && status != context.getStatus().getStatus()) || (filterByQueryName && !context.getQueryName().toLowerCase().contains(queryName)) || (!"all".equalsIgnoreCase(userName) && !userName.equalsIgnoreCase(context.getSubmittedUser())) ) { itr.remove(); } } if (status == null || status == Status.CANCELED || status == Status.SUCCESSFUL || status == Status.FAILED) { if ("all".equalsIgnoreCase(userName)) { userName = null; } List<QueryHandle> persistedQueries = grillServerDao.findFinishedQueries(state, userName, queryName); if (persistedQueries != null && !persistedQueries.isEmpty()) { LOG.info("Adding persisted queries " + persistedQueries.size()); all.addAll(persistedQueries); } } return all; } finally { release(sessionHandle); } }