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

index a85c9b2..df3e9db 100644 (file)
@@ -345,6 +345,24 @@ public class DataManager {
        }
 
        /**
+        * Creates a new track with the given name.
+        *
+        * @param name
+        *            The name of the track
+        * @return The created track
+        * @throws DatabaseException
+        *             if a database error occurs
+        */
+       public Track createTrack(String name) throws DatabaseException {
+               Query query = new Query(Type.INSERT, "TRACKS");
+               String id = UUID.randomUUID().toString();
+               query.addValueField(new ValueField("ID", new StringParameter(id)));
+               query.addValueField(new ValueField("NAME", new StringParameter(name)));
+               database.insert(query);
+               return getTrackById(id);
+       }
+
+       /**
         * Returns the derivative with the given ID.
         *
         * @param id