Add method to get all artists for a track.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 14:55:46 +0000 (16:55 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 14:55:46 +0000 (16:55 +0200)
src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java

index 0c6f422..9ec6d73 100644 (file)
@@ -75,6 +75,15 @@ public class DataManager {
                return database.getMultiple(query, artistCreator);
        }
 
+       public List<Artist> getArtistsByTrack(String trackId) throws DatabaseException {
+               Query query = new Query(Type.SELECT, "ARTISTS");
+               query.addField(new Field("ARTISTS.*"));
+               query.addJoin(new Join(JoinType.INNER, "TRACK_ARTISTS", new Field("TRACK_ARTISTS.ARTIST"), new Field("ARTISTS.ID")));
+               query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_ARTISTS.TRACK", new StringParameter(trackId))));
+               query.addOrderField(new OrderField(new Field("TRACK_ARTISTS.DISPLAY_ORDER")));
+               return database.getMultiple(query, artistCreator);
+       }
+
        public Track trackById(String id) throws DatabaseException {
                Query query = new Query(Type.SELECT, "TRACKS");
                query.addField(new Field("TRACKS.*"));