From: David ‘Bombe’ Roden Date: Fri, 27 Jul 2012 11:30:24 +0000 (+0200) Subject: Add method to create to new track. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=541d82817c18a1e009f8c74b99832a2703845846;p=demoscenemusic.git Add method to create to new track. --- 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