Add method to get all groups by artist.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 14:10:23 +0000 (16:10 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 14:10:23 +0000 (16:10 +0200)
src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java

index d1a8769..85f35fa 100644 (file)
@@ -118,6 +118,14 @@ public class DataManager {
                return trackLoader.all();
        }
 
+       public Collection<Group> getGroupsByArtist(String artistId) throws DatabaseException {
+               Query query = new Query(Type.SELECT, "GROUPS");
+               query.addField(new Field("GROUPS.*"));
+               query.addJoin(new Join(JoinType.INNER, "GROUP_ARTISTS", new Field("GROUPS.ID"), new Field("GROUP_ARTISTS.GROUP_")));
+               query.addWhereClause(new ValueFieldWhereClause(new ValueField("GROUP_ARTISTS.ARTIST", new StringParameter(artistId))));
+               return database.getMultiple(query, DefaultGroup.CREATOR);
+       }
+
        private class TrackLoader implements ResultProcessor {
 
                private final List<Track> loadedTracks = new ArrayList<Track>();