+ /**
+ * Returns all artists.
+ *
+ * @return All artists
+ * @throws DatabaseException
+ * if a database error occurs
+ */
+ public Collection<Artist> getAllArtists() throws DatabaseException {
+ Query query = new Query(Type.SELECT, "ARTISTS");
+ query.addField(new Field("ARTISTS.*"));
+ return database.getMultiple(query, artistCreator);
+ }
+
+ /**
+ * Returns the artist with the given ID.
+ *
+ * @param id
+ * The ID of the artist
+ * @return The artist with the given ID, or {@code null} if there is no
+ * artist with the given ID
+ * @throws DatabaseException
+ * if a database error occurs
+ */
+ public Artist getArtistById(String id) throws DatabaseException {
+ Query query = new Query(Type.SELECT, "ARTISTS");
+ query.addField(new Field("ARTISTS.*"));
+ query.addWhereClause(new ValueFieldWhereClause(new ValueField("ARTISTS.ID", new StringParameter(id))));
+ return database.getSingle(query, artistCreator);
+ }
+
+ /**
+ * Returns all artists that belong to the group with the given ID.
+ *
+ * @param groupId
+ * The ID of the group
+ * @return All artists belonging to the given group
+ * @throws DatabaseException
+ * if a database error occurs
+ */
+ public Collection<Artist> getArtistsByGroup(String groupId) throws DatabaseException {
+ Query query = new Query(Type.SELECT, "ARTISTS");
+ query.addField(new Field("ARTISTS.*"));
+ query.addJoin(new Join(JoinType.INNER, "GROUP_ARTISTS", new Field("ARTISTS.ID"), new Field("GROUP_ARTISTS.ARTIST")));
+ query.addWhereClause(new ValueFieldWhereClause(new ValueField("GROUP_ARTISTS.GROUP_", new StringParameter(groupId))));
+ return database.getMultiple(query, artistCreator);
+ }
+
+ /**
+ * Returns all artists involved in the track with the given ID.
+ *
+ * @param trackId
+ * The ID of the track
+ * @return All artists involved in the track, in preferred order
+ * @throws DatabaseException
+ * if a database error occurs
+ */
+ public List<Artist> getArtistsByTrack(String trackId) throws DatabaseException {
+ Query query = new Query(Type.SELECT, "ARTISTS");
+ query.addField(new Field("ARTISTS.*"));
+ query.addJoin(new Join(JoinType.INNER, "TRACK_ARTISTS", new Field("TRACK_ARTISTS.ARTIST"), new Field("ARTISTS.ID")));
+ query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_ARTISTS.TRACK", new StringParameter(trackId))));
+ query.addOrderField(new OrderField(new Field("TRACK_ARTISTS.DISPLAY_ORDER")));
+ return database.getMultiple(query, artistCreator);
+ }
+
+ /**
+ * Returns all remix artists involved in the track with the given ID.
+ *
+ * @param trackId
+ * The ID of the track
+ * @return All remix artists involved in the track, in preferred order
+ * @throws DatabaseException
+ * if a database error occurs
+ */
+ public List<Artist> getRemixArtistsByTrack(String trackId) throws DatabaseException {
+ Query query = new Query(Type.SELECT, "ARTISTS");
+ query.addField(new Field("ARTISTS.*"));
+ query.addJoin(new Join(JoinType.INNER, "TRACK_REMIX_ARTISTS", new Field("TRACK_REMIX_ARTISTS.ARTIST"), new Field("ARTISTS.ID")));
+ query.addWhereClause(new ValueFieldWhereClause(new ValueField("TRACK_REMIX_ARTISTS.TRACK", new StringParameter(trackId))));
+ query.addOrderField(new OrderField(new Field("TRACK_REMIX_ARTISTS.DISPLAY_ORDER")));
+ return database.getMultiple(query, artistCreator);
+ }
+
+ /**
+ * Returns all related tracks for the track with the given ID.
+ *
+ * @param trackId
+ * The ID of the tracks
+ * @return A mapping from relationship to all tracks that match the relation
+ * @throws DatabaseException
+ * if a database error occurs
+ */
+ public Map<Relationship, Collection<Track>> getRelatedTracksByTrack(String trackId) throws DatabaseException {