From 2fd39b4383b041559364dce6eaf56c9164dbed82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 28 Jul 2012 01:32:24 +0200 Subject: [PATCH] Load the properties of a track together with the track. --- .../demoscenemusic/data/DataManager.java | 33 ++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index df3e9db..c87df73 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -324,7 +324,7 @@ public class DataManager { Query query = new Query(Type.SELECT, "TRACKS"); query.addField(new Field("TRACKS.*")); query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACKS.ID", new StringParameter(id)))); - return database.getSingle(query, trackCreator); + return loadTrackProperties(database.getSingle(query, trackCreator)); } /** @@ -341,7 +341,36 @@ public class DataManager { query.addField(new Field("TRACKS.*")); query.addJoin(new Join(JoinType.INNER, "TRACK_ARTISTS", new Field("TRACKS.ID"), new Field("TRACK_ARTISTS.TRACK"))); query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_ARTISTS.ARTIST", new StringParameter(artistId)))); - return database.getMultiple(query, trackCreator); + return loadTrackProperties(database.getMultiple(query, trackCreator)); + } + + /** + * Loads the properties for the given track. + * + * @param track + * The track for which to load the properties + * @return The track with the properties loaded + * @throws DatabaseException + * if a database error occurs + */ + public Track loadTrackProperties(Track track) throws DatabaseException { + return loadProperties(track, "TRACK_PROPERTIES", "TRACK"); + } + + /** + * Loads the properties for the given tracks. + * + * @param tracks + * The tracks for which to load the properties + * @return The tracks with the properties loaded + * @throws DatabaseException + * if a database error occurs + */ + public List loadTrackProperties(List tracks) throws DatabaseException { + for (Track track : tracks) { + loadTrackProperties(track); + } + return tracks; } /** -- 2.7.4