From 541d82817c18a1e009f8c74b99832a2703845846 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:24 +0200 Subject: [PATCH] Add method to create to new 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 a85c9b2..df3e9db 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/data/DataManager.java @@ -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 -- 2.7.4