/** * Return an Observable containing a stream of job views for jobs in the ApiJobStore. If filter String is non null * and non empty, only return results that satisfy the filter. If filter String is null or empty, return all rows. * If, for any JobRow, the mapping from JobRow to job view fails, an Observable over JobRequestFailedException is * returned. If the ApiJobStore is empty, we return an empty Observable. * * @return An Observable containing a stream of Maps representing the job to be returned to the user */ public Observable<Map<String, String>> getJobViews() { if (filters == null || "".equals(filters)) { return apiJobStore.getAllRows().map(this::mapJobRowsToJobViews); } else { return apiJobStore.getFilteredRows(buildJobStoreFilter(filters)).map(this::mapJobRowsToJobViews); } }
/** * Returns an Observable over the Map representing the job to be returned to the user. * * @param ticket The ticket that uniquely identifies the job * * @return An Observable over the Map representing the job to be returned to the user or an Observable wrapping * JobNotFoundException if the Job is not available in the ApiJobStore */ public Observable<Map<String, String>> getJobViewObservable(String ticket) { return apiJobStore.get(ticket) .switchIfEmpty( Observable.error(new JobNotFoundException(ErrorMessageFormat.JOB_NOT_FOUND.format(ticket))) ) .map(jobRow -> jobPayloadBuilder.buildPayload(jobRow, uriInfo)); }