/******************************************************************************************************************* * * Constrains the search to tracks contained in the given record. * * @param record the record * @return the {@code Finder}, in fluent fashion * ******************************************************************************************************************/ @Nonnull public default TrackFinder inRecord (final @Nonnull Record record) { return inRecord(record.getId()); } }
@Override @Nonnull public TrackFinder findTracks() { return _findTracks().madeBy(this); }
/******************************************************************************************************************* * * Exports the cover art of a record. * * @param id the record id * @return the cover art image * ******************************************************************************************************************/ @RequestMapping(value = "/record/{id}/coverart") public ResponseEntity<byte[]> getRecordCoverArt (final @PathVariable String id) { log.info("getRecordCoverArt({})", id); checkStatus(); return catalog.findTracks().inRecord(new Id(id)) .stream() .flatMap(track -> track.asMany(AudioFileSupplier).stream()) .map(afs -> afs.getAudioFile()) .flatMap(af -> af.getMetadata().getAll(ARTWORK).stream()) .findAny() .map(bytes -> bytesResponse(bytes, "image", "jpeg", "coverart.jpg")) .orElseThrow(NotFoundException::new); }
pw.printf("ALL TRACKS (%d):%n%n", allTracksFinder.count()); final int trackCountQueryCount = getLatestQueryCount(); final Map<String, Track> tracksOrphanOfArtist = allTracksFinder.stream() .collect(toMap(Track::toDumpString, Function.identity(), (u,v) -> v)); final Map<String, Track> tracksOrphanOfRecord = new HashMap<>(tracksOrphanOfArtist); records.forEach(record -> pw.printf(" %s - %d tracks - %s%n", displayNameOf(record), record.findTracks().count(), record.getSource().orElse(new Id("unknown")))); pw.printf(" COUNT OF ALL RECORDS RETRIEVED BY %d QUERIES%n", recordCountQueryCount); pw.printf("%nTRACKS OF %s (%d):%n", displayNameOf(artist), artistTracksFinder.count()); artistTracksFinder.stream().forEach(track -> pw.printf(" TRACKS (%d / %s):%n", recordTrackFinder.count(), record.getTrackCount()); recordTrackFinder.stream().forEach(track ->
public RepositoryBrowserByTrack() { super(catalog -> catalog.findTracks().sort(new ByTrackName())); } }
/******************************************************************************************************************* * * Exports a single track resource. * * @param id the track id * @param source the data source * @param fallback the fallback data source * @return the JSON representation of the track * ******************************************************************************************************************/ @ResponseBody @RequestMapping(value = "/track/{id}", produces = { APPLICATION_JSON_VALUE, APPLICATION_XML_VALUE }) public TrackResource getTrack (final @PathVariable String id, final @RequestParam(required = false, defaultValue = "embedded") String source, final @RequestParam(required = false, defaultValue = "embedded") String fallback) { log.info("getTrack({}, {}, {})", id, source, fallback); checkStatus(); return single(finalized(catalog.findTracks().withId(new Id(id)), source, fallback, TrackResource::new)); }
@Override @Nonnull public TrackFinder findTracks() { return configured(new RepositoryOptimizedTrackFinder(repository, trackCount)).inRecord(this); }
/******************************************************************************************************************* * * Constrains the search to tracks made by the given artist. * * @param artist the artist * @return the {@code Finder}, in fluent fashion * ******************************************************************************************************************/ @Nonnull public default TrackFinder madeBy (final @Nonnull MusicArtist artist) { return madeBy(artist.getId()); }
/******************************************************************************************************************* * * 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))); }