Add method to get styles for a track.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 15:47:56 +0000 (17:47 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 15:47:56 +0000 (17:47 +0200)
src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java

index 405d71a..f53559e 100644 (file)
@@ -108,6 +108,14 @@ public class DataManager {
                return database.getMultiple(query, groupCreator);
        }
 
+       public Collection<Style> getStylesByTrack(String trackId) throws DatabaseException {
+               Query query = new Query(Type.SELECT, "STYLES");
+               query.addField(new Field("STYLES.*"));
+               query.addJoin(new Join(JoinType.INNER, "TRACK_STYLES", new Field("STYLES.ID"), new Field("TRACK_STYLES.STYLE")));
+               query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_STYLES.TRACK", new StringParameter(trackId))));
+               return database.getMultiple(query, styleCreator);
+       }
+
        private class LazyArtist extends DefaultArtist {
 
                private final Memoizer<Void> tracksMemoizer = new Memoizer<Void>(new Callable<Void>() {