From 06714ccf9b8445728273f69296e170f3fe141db8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 27 Jul 2012 13:30:13 +0200 Subject: [PATCH] Add method to create a new derivative for a track. --- .../pterodactylus/demoscenemusic/data/DataManager.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 -- 2.7.4