From: David ‘Bombe’ Roden Date: Thu, 19 Apr 2012 14:55:19 +0000 (+0200) Subject: Use track creator to load tracks. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=4841c89b211b11fccbab4b83e0a1a235336f2114;p=demoscenemusic.git Use track creator to load tracks. --- diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index 5523bbe..5d3c1de 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -82,39 +82,16 @@ public class DataManager { public Track trackById(String id) 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("TRACKS.ID", new StringParameter(id)))); - 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.get(); + return database.getSingle(query, trackCreator); } public Collection 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(); + query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_ARTISTS.ARTIST", new StringParameter(artistId)))); + return database.getMultiple(query, trackCreator); } public Collection getGroupsByArtist(String artistId) throws DatabaseException {