Add method to create a new derivative for a track.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 27 Jul 2012 11:30:13 +0000 (13:30 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 27 Jul 2012 11:30:13 +0000 (13:30 +0200)
src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java

index 03ec2d9..a85c9b2 100644 (file)
@@ -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