From 24f4198972ba0b6f180404508818775245946b0b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 19 Apr 2012 15:03:25 +0200 Subject: [PATCH] Add method to get artist by ID. --- .../net/pterodactylus/demoscenemusic/data/DataManager.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index 214d0c4..520a3d9 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -64,6 +64,20 @@ public class DataManager { return artistLoader.all(); } + public Artist getArtistById(String id) throws DatabaseException { + Query query = new Query(Type.SELECT, "ARTISTS"); + query.addField(new Field("ARTISTS.*")); + query.addField(new Field("GROUP_ARTISTS.*")); + query.addField(new Field("GROUPS.*")); + query.addJoin(new Join(JoinType.INNER, "GROUP_ARTISTS", new Field("ARTISTS.ID"), new Field("GROUP_ARTISTS.ARTIST"))); + query.addJoin(new Join(JoinType.INNER, "GROUPS", new Field("GROUP_ARTISTS.GROUP_"), new Field("GROUPS.ID"))); + query.addWhereClause(new ValueFieldWhereClause(new ValueField("ARTISTS.ID", new StringParameter(id)))); + query.addOrderField(new OrderField(new Field("ARTISTS.ID"))); + ArtistLoader artistLoader = new ArtistLoader(); + database.process(query, artistLoader); + return artistLoader.get(); + } + public Track trackById(String id) throws DatabaseException { Query query = new Query(Type.SELECT, "TRACKS"); query.addField(new Field("TRACKS.*")); -- 2.7.4