return trackLoader.get();
}
+ public Collection<Track> getTracksByArtist(String artistId) throws DatabaseException {
+ Query query = new Query(Type.SELECT, "TRACKS");
+ query.addField(new Field("TRACKS.*"));
+ query.addField(new Field("TRACK_ARTISTS.*"));
+ query.addField(new Field("ARTISTS.*"));
+ query.addField(new Field("TRACK_STYLES.*"));
+ query.addField(new Field("STYLES.*"));
+ query.addJoin(new Join(JoinType.INNER, "TRACK_ARTISTS", new Field("TRACKS.ID"), new Field("TRACK_ARTISTS.TRACK")));
+ query.addJoin(new Join(JoinType.INNER, "ARTISTS", new Field("TRACK_ARTISTS.ARTIST"), new Field("ARTISTS.ID")));
+ query.addJoin(new Join(JoinType.INNER, "TRACK_STYLES", new Field("TRACKS.ID"), new Field("TRACK_STYLES.TRACK")));
+ query.addJoin(new Join(JoinType.INNER, "STYLES", new Field("TRACK_STYLES.STYLE"), new Field("STYLES.ID")));
+ query.addWhereClause(new ValueFieldWhereClause(new ValueField("ARTISTS.ID", new StringParameter(artistId))));
+ query.addOrderField(new OrderField(new Field("TRACKS.ID"), Order.ASCENDING));
+ query.addOrderField(new OrderField(new Field("TRACK_ARTISTS.DISPLAY_ORDER"), Order.ASCENDING));
+ TrackLoader trackLoader = new TrackLoader();
+ database.process(query, trackLoader);
+ return trackLoader.all();
+ }
+
private class TrackLoader implements ResultProcessor {
private final List<Track> loadedTracks = new ArrayList<Track>();
private Track track;
+ public List<Track> all() {
+ return loadedTracks;
+ }
+
/**
* {@inheritDoc}
*/