@Override @Nonnull public Optional<Record> getRecord() { return record.get(() -> _findRecords().containingTrack(this).optionalFirstResult()); }
/******************************************************************************************************************* * * Constrains the search to records made by the given artist. * * @param artist the artist * @return the {@code Finder}, in fluent fashion * ******************************************************************************************************************/ @Nonnull public default RecordFinder madeBy (final @Nonnull MusicArtist artist) { return madeBy(artist.getId()); }
/******************************************************************************************************************* * * Constrains the search to records containing the given track. * * @param track the track * @return the {@code Finder}, in fluent fashion * ******************************************************************************************************************/ @Nonnull public default RecordFinder containingTrack (final @Nonnull Track track) { return RecordFinder.this.containingTrack(track.getId()); } }
pw.printf(" ALL TRACKS RETRIEVED BY %d QUERIES%n", getLatestQueryCount()); pw.printf("%n%n%nALL RECORDS (%d):%n%n", allRecordsFinder.count()); final int recordCountQueryCount = getLatestQueryCount(); log.info("QUERYING ALL RECORDS..."); final List<Record> records = allRecordsFinder.stream().sorted(BY_DISPLAY_NAME).collect(toList()); records.forEach(record -> pw.printf(" %s - %d tracks - %s%n", displayNameOf(record), pw.printf("%nRECORDS OF %s (%d):%n", displayNameOf(artist), recordFinder.count()); recordFinder.stream().forEach(record -> pw.printf(" %s%n", displayNameOf(record))); recordFinder.stream().forEach(record -> assertEquals(record.getSource(), artist.getSource())); pw.printf(" RETRIEVED BY %d QUERIES%n", getLatestQueryCount()); });
@Override @Nonnull public Optional<Record> getRecord() { return trackId.flatMap(tid -> new RepositoryRecordFinder(repository).containingTrack(tid).optionalFirstResult()); }
/******************************************************************************************************************* * * Exports a single record resource. * * @param id the record id * @param source the data source * @param fallback the fallback data source * @return the JSON representation of the record * ******************************************************************************************************************/ @ResponseBody @RequestMapping(value = "/record/{id}", produces = { APPLICATION_JSON_VALUE, APPLICATION_XML_VALUE }) public DetailedRecordResource getRecord (final @PathVariable String id, final @RequestParam(required = false, defaultValue = "embedded") String source, final @RequestParam(required = false, defaultValue = "embedded") String fallback) { log.info("getRecord({}, {}, {})", id, source, fallback); checkStatus(); final List<TrackResource> tracks = finalized(catalog.findTracks().inRecord(new Id(id)), source, fallback, TrackResource::new); return single(finalized(catalog.findRecords().withId(new Id(id)), source, fallback, record -> new DetailedRecordResource(record, tracks))); }
@Override @Nonnull public RecordFinder findRecords() { return _findRecords().madeBy(this); }