}
/**
+ * 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 the track with the given ID.
*
* @param id
});
+ /** Memoizer for the remix artists. */
+ private final Memoizer<Void> remixArtistsMemoizer = new Memoizer<Void>(new Callable<Void>() {
+
+ @Override
+ public Void call() throws Exception {
+ if (!hasValue("remixArtists")) {
+ getValue("remixArtists", List.class).set(getRemixArtistsByTrack(getId()));
+ }
+ return null;
+ }
+
+ });
+
/**
* Creates a new track.
*
return super.getStyles();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public List<Artist> getRemixArtists() {
+ remixArtistsMemoizer.get();
+ return super.getRemixArtists();
+ }
+
}
/**
*/
@Override
public Track createObject(ResultSet resultSet) throws SQLException {
- return new LazyTrack(resultSet.getString("TRACKS.ID")).setName(resultSet.getString("TRACKS.NAME"));
+ return new LazyTrack(resultSet.getString("TRACKS.ID")).setName(resultSet.getString("TRACKS.NAME")).setRemix(resultSet.getString("TRACKS.REMIX"));
}
}
return this;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String getRemix() {
+ return getValue("remix", String.class).get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Track setRemix(String remix) {
+ getValue("remix", String.class).set(remix);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public List<Artist> getRemixArtists() {
+ return getValue("remixArtists", List.class).get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Track setRemixArtists(List<Artist> remixArtists) {
+ getValue("remixArtists", List.class).set(remixArtists);
+ return this;
+ }
+
}
*/
public Track setStyles(Collection<? extends Style> styles);
+ /**
+ * Returns the name of this remix. If this track is not a remix,
+ * {@code null} is returned.
+ *
+ * @return The name of this remix, or {@code null} if this track is not a
+ * remix
+ */
+ public String getRemix();
+
+ /**
+ * Sets the name of the remix.
+ *
+ * @param remix
+ * The name of this remix, or {@code null} if this track is not a
+ * remix
+ * @return This track
+ */
+ public Track setRemix(String remix);
+
+ /**
+ * Returns all remix artists involved in this track.
+ *
+ * @return All remix artists involved in this track
+ */
+ public List<Artist> getRemixArtists();
+
+ /**
+ * Sets all remix artists involved in this track.
+ *
+ * @param remixArtists
+ * All remix artists involved in this track
+ * @return This track
+ */
+ public Track setRemixArtists(List<Artist> remixArtists);
+
}