From: David ‘Bombe’ Roden Date: Fri, 27 Jul 2012 11:30:13 +0000 (+0200) Subject: Add method to create a new derivative for a track. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=06714ccf9b8445728273f69296e170f3fe141db8;p=demoscenemusic.git Add method to create a new derivative for a track. --- diff --git a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java index 03ec2d9..a85c9b2 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -377,6 +377,24 @@ public class DataManager { } /** + * Creates a new derivative for the given track. + * + * @param track + * The track to create the derivative for + * @return The created derivative + * @throws DatabaseException + * if a database error occurs + */ + public TrackDerivative createTrackDerivative(Track track) throws DatabaseException { + Query query = new Query(Type.INSERT, "TRACK_DERIVATIVES"); + String id = UUID.randomUUID().toString(); + query.addValueField(new ValueField("TRACK_DERIVATIVES.ID", new StringParameter(id))); + query.addValueField(new ValueField("TRACK_DERIVATIVES.TRACK", new StringParameter(track.getId()))); + database.insert(query); + return getTrackDerivativeById(id); + } + + /** * Loads the properties for the given track derivative. * * @param trackDerivative